Loading CHANGES.md +5 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,11 @@ To be released. <q>Body already consumed</q> when the content type of the response was an HTML document and there's no link to a JSON-LD document. - Fixed a bug where `verifySignature()` and `verifyJsonLd()` functions sometimes had thrown a `jsonld.ValidationError` error. Now such errors are caught and logged as warnings, and the signature to verify is considered as invalid. Version 1.0.7 ------------- Loading src/sig/ld.ts +20 −2 Original line number Diff line number Diff line Loading @@ -238,10 +238,28 @@ export async function verifySignature( delete sigOpts.type; delete sigOpts.id; delete sigOpts.signatureValue; const sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader); let sigOptsHash: string; try { sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader); } catch (error) { logger.warn( "Failed to verify; failed to hash the signature options: {signatureOptions}\n{error}", { signatureOptions: sigOpts, error }, ); return null; } const document: { signature?: unknown } = { ...jsonLd }; delete document.signature; const docHash = await hashJsonLd(document, options.contextLoader); let docHash: string; try { docHash = await hashJsonLd(document, options.contextLoader); } catch (error) { logger.warn( "Failed to verify; failed to hash the document: {document}\n{error}", { document, error }, ); return null; } const encoder = new TextEncoder(); const message = sigOptsHash + docHash; const messageBytes = encoder.encode(message); Loading Loading
CHANGES.md +5 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,11 @@ To be released. <q>Body already consumed</q> when the content type of the response was an HTML document and there's no link to a JSON-LD document. - Fixed a bug where `verifySignature()` and `verifyJsonLd()` functions sometimes had thrown a `jsonld.ValidationError` error. Now such errors are caught and logged as warnings, and the signature to verify is considered as invalid. Version 1.0.7 ------------- Loading
src/sig/ld.ts +20 −2 Original line number Diff line number Diff line Loading @@ -238,10 +238,28 @@ export async function verifySignature( delete sigOpts.type; delete sigOpts.id; delete sigOpts.signatureValue; const sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader); let sigOptsHash: string; try { sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader); } catch (error) { logger.warn( "Failed to verify; failed to hash the signature options: {signatureOptions}\n{error}", { signatureOptions: sigOpts, error }, ); return null; } const document: { signature?: unknown } = { ...jsonLd }; delete document.signature; const docHash = await hashJsonLd(document, options.contextLoader); let docHash: string; try { docHash = await hashJsonLd(document, options.contextLoader); } catch (error) { logger.warn( "Failed to verify; failed to hash the document: {document}\n{error}", { document, error }, ); return null; } const encoder = new TextEncoder(); const message = sigOptsHash + docHash; const messageBytes = encoder.encode(message); Loading