Ensure the returned DID matches the one requested.

Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
This commit is contained in:
costdev 2025-07-28 05:31:15 +01:00
parent 9ce4b13d15
commit 53a9d260f4

View file

@ -122,7 +122,17 @@ function fetch_package_metadata( string $id ) {
}
$repo_url = $service->serviceEndpoint;
return fetch_metadata_doc( $repo_url );
$metadata = fetch_metadata_doc( $repo_url );
if ( is_wp_error( $metadata ) ) {
return $metadata;
}
if ( $metadata->id !== $id ) {
return new WP_Error( 'fair.packages.fetch_metadata.mismatch', __( 'Fetched metadata does not match the requested DID.', 'fair' ) );
}
return $metadata;
}
/**