@blockcerts/blockcerts-verifier 1.58.0 → 1.59.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/bundle-stats.html +24 -20
  2. package/dist/EcdsaSecp256k1Signature2019-XwuS-fWx-7dFfMy74.js +4 -0
  3. package/dist/Ed25519Signature2020-IJ4ybcbU--hEL5-Pa.js +52 -0
  4. package/dist/{HashlinkVerifier-40818bdd-tYZmELFg.js → HashlinkVerifier-wyKYZ83G-bzhltPG4.js} +1 -1
  5. package/dist/{MerkleProof2017-MZJbBTpc-NVfw6WgB.js → MerkleProof2017-MZJbBTpc-0GcGcIV-.js} +1 -1
  6. package/dist/{MerkleProof2017-ac8d147b-6wk-NtfB.js → MerkleProof2017-Ub6_JUVj-x8awkeml.js} +1 -1
  7. package/dist/MerkleProof2019-QUwyEIHd-iYt21yPG.js +3 -0
  8. package/dist/base64url-qi3FT6uz-yv4mTXpu.js +4 -0
  9. package/dist/checkRevocationStatusList2021-d1qO1xnj-DH6pO-9Q.js +13 -0
  10. package/dist/controlVerificationMethod-6GJtYmqY-Ivo3O8nb.js +1 -0
  11. package/dist/{did-key-common.esm-2e9ab4e3-X4avzjKx.js → did-key-common.esm-Fyh_U6fK-cOLlHenk.js} +3 -3
  12. package/dist/{did-key-ed25519.esm-54d2cbca-E7NBXv8_.js → did-key-ed25519.esm-1lIlZtof-Grj-JpU9.js} +1 -1
  13. package/dist/did-key-secp256k1.esm-hA8kGTM0-G8ct6CwH.js +1 -0
  14. package/dist/{downloadPDF-5Pw6AlBs.js → downloadPDF--IVgfc2I.js} +8 -8
  15. package/dist/{elliptic-a9d84078-BGmaMzNc.js → elliptic-il_lPAr--VPyWJbY1.js} +1 -1
  16. package/dist/{ensureNotRevoked-2dc26afb-U5ByLE-t.js → ensureNotRevoked-2QGGtBqy-t8Yk4QI-.js} +1 -1
  17. package/dist/ensureNotRevoked-gui-UMnE-kFmYZEJe.js +1 -0
  18. package/dist/{ensureValidIssuingKey-b950fb8b-oM__XftS.js → ensureValidIssuingKey-zZEv5-cH-UoJe_Wnf.js} +1 -1
  19. package/dist/index-CZOUZnn4-Lnb5-WZi.js +5 -0
  20. package/dist/{index-6d4132ca-BtAgIaHS.js → index-MC635rre-_DW5MUyk.js} +2 -2
  21. package/dist/{index-WX6J-tsk.js → index-UlvMASNZ.js} +1 -1
  22. package/dist/index-xsnp_Fid-o1HUYRUQ.js +1 -0
  23. package/dist/index.es-dEKcVerc.js +56 -0
  24. package/dist/{jsonld-6909fb49-vaWL2Y4h.js → jsonld-CXlzLf4P-ioHKtwiZ.js} +6 -6
  25. package/dist/{jsonld-signatures-8ecbbaa2-MztjIc1c.js → jsonld-signatures-ooFWZVS--ThP8ltUY.js} +7 -7
  26. package/dist/main.js +110 -110
  27. package/dist/{purify-xGHUwWlQ.js → purify-GC91XaSq.js} +1 -1
  28. package/dist/{sha256-71400caa-o9J6pXuo.js → sha256-wKeS8_4l-9eo2gOQb.js} +1 -1
  29. package/dist/tslib.es6-M1zqH4el-x9kNW1T_.js +1 -0
  30. package/dist/x25519-NtRELWAG-2RynHlmX.js +1 -0
  31. package/package.json +4 -4
  32. package/scripts/automated-update-blockcerts.org.sh +7 -1
  33. package/dist/EcdsaSecp256k1Signature2019-01e33e56-_kD7OEMM.js +0 -4
  34. package/dist/Ed25519Signature2020-722d8d24-52XGswpx.js +0 -74
  35. package/dist/MerkleProof2019-6596bc5f-AOhD0MU2.js +0 -3
  36. package/dist/checkRevocationStatusList2021-904b13ff-HXtw_2Lc.js +0 -17
  37. package/dist/controlVerificationMethod-80d0e7f0-8ug9g49U.js +0 -1
  38. package/dist/did-key-secp256k1.esm-8a01b23c-iRA0puBs.js +0 -1
  39. package/dist/ensureNotRevoked-gui-UMnE-9nObicUP.js +0 -1
  40. package/dist/index-0469d008-LwXIiw03.js +0 -1
  41. package/dist/index-85f56501-xkysxAxC.js +0 -4
  42. package/dist/index-F1HqK0qm.js +0 -1
  43. package/dist/index-a93e1e88-w6XCMY1g.js +0 -1
  44. package/dist/index.es-YP2tdnLj.js +0 -56
  45. package/dist/tslib.es6-28b6776b-qWIKDnpX.js +0 -1
  46. package/dist/x25519-08f432f1-4TKeGPT6.js +0 -1
  47. /package/dist/{Suite-e65d26ad-e2QgHGhx.js → Suite-Bhitn5l3-e2QgHGhx.js} +0 -0
  48. /package/dist/{_commonjs-dynamic-modules-1e49c0dd-fkA6S-_a.js → _commonjs-dynamic-modules-F7P8sER7-fkA6S-_a.js} +0 -0
  49. /package/dist/{pako.esm-7a9981ef-RAILONW0.js → pako.esm-jjCKMBM4-RAILONW0.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{d as e,D as t,c as r,i as o}from"./main.js";import{a as n}from"./jsonld-6909fb49-vaWL2Y4h.js";var i,a,s=(function(e,t){!function(e,t){for(var r in t)e[r]=t[r]}(t,function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){
1
+ import{g as e,u as t,B as r,i as o}from"./main.js";import{a as n}from"./jsonld-CXlzLf4P-ioHKtwiZ.js";var i,a,s=(function(e,t){!function(e,t){for(var r in t)e[r]=t[r]}(t,function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){
2
2
  /*!
3
3
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
4
4
  */
@@ -25,20 +25,20 @@ const{constants:y}=m;var w={SECURITY_CONTEXT_URL:y.SECURITY_CONTEXT_V2_URL,SECUR
25
25
  /*!
26
26
  * Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
27
27
  */
28
- const T=new Map([[v.SECURITY_CONTEXT_V1_URL,g.get(v.SECURITY_CONTEXT_V1_URL)],[v.SECURITY_CONTEXT_V2_URL,g.get(v.SECURITY_CONTEXT_V2_URL)]]),E={};var x=E;E.extendContextLoader=e=>async t=>{const r=T.get(t);return void 0!==r?{contextUrl:null,documentUrl:t,document:r,tag:"static"}:e(t)},E.strictDocumentLoader=E.extendContextLoader((e=>{throw new Error(`${e} not found.`)}));class b extends Error{constructor(e){super(b._prepareSuperMessage(e)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,b)}static _prepareSuperMessage(e){try{return JSON.stringify(e)}catch(t){return String(e)}}}const S=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],L=Symbol(".toJSON called"),_=({from:e,seen:t,to_:n,forceEnumerable:i,maxDepth:a,depth:s})=>{const c=n||(Array.isArray(e)?[]:{});if(t.push(e),s>=a)return c;if("function"==typeof e.toJSON&&!0!==e[L])return(e=>{e[L]=!0;const t=e.toJSON();return delete e[L],t})(e);for(const[n,p]of Object.entries(e))"function"==typeof r&&o(p)?c[n]="[object Buffer]":"function"!=typeof p&&(p&&"object"==typeof p?t.includes(e[n])?c[n]="[Circular]":(s++,c[n]=_({from:e[n],seen:t.slice(),forceEnumerable:i,maxDepth:a,depth:s})):c[n]=p);for(const{property:t,enumerable:r}of S)"string"==typeof e[t]&&Object.defineProperty(c,t,{value:e[t],enumerable:!!i||r,configurable:!0,writable:!0});return c};var M={serializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;return"object"==typeof e&&null!==e?_({from:e,seen:[],forceEnumerable:!0,maxDepth:r,depth:0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e},deserializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;if(e instanceof Error)return e;if("object"==typeof e&&null!==e&&!Array.isArray(e)){const t=new Error;return _({from:e,seen:[],to_:t,maxDepth:r,depth:0}),t}return new b(e)}};
28
+ const T=new Map([[v.SECURITY_CONTEXT_V1_URL,g.get(v.SECURITY_CONTEXT_V1_URL)],[v.SECURITY_CONTEXT_V2_URL,g.get(v.SECURITY_CONTEXT_V2_URL)]]),E={};var x=E;E.extendContextLoader=e=>async t=>{const r=T.get(t);return void 0!==r?{contextUrl:null,documentUrl:t,document:r,tag:"static"}:e(t)},E.strictDocumentLoader=E.extendContextLoader((e=>{throw new Error(`${e} not found.`)}));class b extends Error{constructor(e){super(b._prepareSuperMessage(e)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,b)}static _prepareSuperMessage(e){try{return JSON.stringify(e)}catch{return String(e)}}}const S=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],L=Symbol(".toJSON called"),_=({from:e,seen:t,to_:n,forceEnumerable:i,maxDepth:a,depth:s})=>{const c=n||(Array.isArray(e)?[]:{});if(t.push(e),s>=a)return c;if("function"==typeof e.toJSON&&!0!==e[L])return(e=>{e[L]=!0;const t=e.toJSON();return delete e[L],t})(e);for(const[n,p]of Object.entries(e))"function"==typeof r&&o(p)?c[n]="[object Buffer]":"function"!=typeof p&&(p&&"object"==typeof p?t.includes(e[n])?c[n]="[Circular]":(s++,c[n]=_({from:e[n],seen:t.slice(),forceEnumerable:i,maxDepth:a,depth:s})):c[n]=p);for(const{property:t,enumerable:r}of S)"string"==typeof e[t]&&Object.defineProperty(c,t,{value:e[t],enumerable:!!i||r,configurable:!0,writable:!0});return c};var C={serializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;return"object"==typeof e&&null!==e?_({from:e,seen:[],forceEnumerable:!0,maxDepth:r,depth:0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e},deserializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;if(e instanceof Error)return e;if("object"==typeof e&&null!==e&&!Array.isArray(e)){const t=new Error;return _({from:e,seen:[],to_:t,maxDepth:r,depth:0}),t}return new b(e)}};
29
29
  /*!
30
30
  * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
31
- */const C=w,O=n,{extendContextLoader:R,strictDocumentLoader:U}=x,{serializeError:D}=M;function K({document:e}){let t;t=O.getValues(e,"proof");const r=e["@context"]||C.SECURITY_CONTEXT_URL;return t=t.map((e=>({"@context":r,...e}))),t}function N(e){Object.defineProperty(e,"toJSON",{value:function(){return D(this)},configurable:!0,writable:!0})}var P=class extends Error{constructor(e){super("Verification error(s)."),this.name="VerificationError",this.errors=[].concat(e)}},A=class{constructor({type:e}={}){if("string"!=typeof e)throw new TypeError('A LinkedDataProof must have a "type".');this.type=e}async createProof({}){throw new Error('"createProof" must be implemented in a derived class.')}async derive({}){throw new Error('"deriveProof" must be implemented in a derived class.')}async verifyProof({}){throw new Error('"verifyProof" must be implemented in a derived class.')}async matchProof({proof:e}){return e.type===this.type}};
31
+ */const M=w,O=n,{extendContextLoader:R,strictDocumentLoader:U}=x,{serializeError:K}=C;function D({document:e}){let t;t=O.getValues(e,"proof");const r=e["@context"]||M.SECURITY_CONTEXT_URL;return t=t.map((e=>({"@context":r,...e}))),t}function P(e){Object.defineProperty(e,"toJSON",{value:function(){return K(this)},configurable:!0,writable:!0})}var N=class extends Error{constructor(e){super("Verification error(s)."),this.name="VerificationError",this.errors=[].concat(e)}},A=class{constructor({type:e}={}){if("string"!=typeof e)throw new TypeError('A LinkedDataProof must have a "type".');this.type=e}async createProof({}){throw new Error('"createProof" must be implemented in a derived class.')}async derive({}){throw new Error('"deriveProof" must be implemented in a derived class.')}async verifyProof({}){throw new Error('"verifyProof" must be implemented in a derived class.')}async matchProof({proof:e}){return e.type===this.type}};
32
32
  /*!
33
33
  * Copyright (c) 2018-2023 Digital Bazaar, Inc. All rights reserved.
34
34
  */const V={};var I=V;V.w3cDate=e=>{null==e?e=new Date:"number"!=typeof e&&"string"!=typeof e||(e=new Date(e));const t=e.toISOString();return t.substr(0,t.length-5)+"Z"},V.concat=(e,t)=>{const r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r};const j=self&&(self.crypto||self.msCrypto);var k={async sha256digest({string:e}){const t=(new TextEncoder).encode(e);return new Uint8Array(await j.subtle.digest("SHA-256",t))}};
35
35
  /*!
36
36
  * Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
37
- */const X=w,Y=n,z=I,{sha256digest:q}=k,$=A;
37
+ */const X=w,z=n,Y=I,{sha256digest:q}=k,$=A;
38
38
  /*!
39
39
  * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
40
40
  */
41
- const W={};var B=W;W.suites={LinkedDataProof:A,LinkedDataSignature:class extends ${constructor({type:e,proof:t,LDKeyClass:r,date:o,key:n,signer:i,verifier:a,useNativeCanonize:s,canonizeOptions:c,contextUrl:p}={}){super({type:e}),this.LDKeyClass=r,this.contextUrl=p,this.proof=t;const d=function({key:e,signer:t,verifier:r}){const o={};if(e){if(o.key=e,o.verificationMethod=e.id,"function"==typeof e.signer&&(o.signer=e.signer()),"function"==typeof e.verifier&&(o.verifier=e.verifier()),!o.signer&&!o.verifier)throw new TypeError('The "key" parameter must contain a "signer" or "verifier" method.')}else o.verificationMethod=t&&t.id||r&&r.id,o.signer=t,o.verifier=r;if(o.signer&&"function"!=typeof o.signer.sign)throw new TypeError("A signer API has not been specified.");if(o.verifier&&"function"!=typeof o.verifier.verify)throw new TypeError("A verifier API has not been specified.");return o}({key:n,signer:i,verifier:a});if(this.verificationMethod=d.verificationMethod,this.key=d.key,this.signer=d.signer,this.verifier=d.verifier,this.canonizeOptions=c,o&&(this.date=new Date(o),isNaN(this.date)))throw TypeError(`"date" "${o}" is not a valid date.`);this.useNativeCanonize=s,this._hashCache=null}async createProof({document:e,purpose:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');let i;i=this.proof?{...this.proof}:{},i.type=this.type;let a=this.date;void 0===i.created&&void 0===a&&(a=new Date),a&&"string"!=typeof a&&(a=z.w3cDate(a)),a&&(i.created=a),i.verificationMethod=this.verificationMethod,i=await this.updateProof({document:e,proof:i,proofSet:r,purpose:t,documentLoader:o}),i=await t.update(i,{document:e,suite:this,documentLoader:o});const s=await this.createVerifyData({document:e,proof:i,proofSet:r,documentLoader:o});return i=await this.sign({verifyData:s,document:e,proof:i,documentLoader:o}),i}async updateProof({proof:e,expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e}async verifyProof({proof:e,document:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');try{const i=await this.createVerifyData({document:t,proof:e,proofSet:r,documentLoader:o,expansionMap:n}),a=await this.getVerificationMethod({proof:e,document:t,documentLoader:o,expansionMap:n});if(!await this.verifySignature({verifyData:i,verificationMethod:a,document:t,proof:e,documentLoader:o,expansionMap:n}))throw new Error("Invalid signature.");return{verified:!0,verificationMethod:a}}catch(e){return{verified:!1,error:e}}}async canonize(e,{documentLoader:t,expansionMap:r,skipExpansion:o}){if(r)throw new Error('"expansionMap" not supported.');return Y.canonize(e,{algorithm:"URDNA2015",base:null,format:"application/n-quads",documentLoader:t,safe:!0,skipExpansion:o,useNative:this.useNativeCanonize,...this.canonizeOptions})}async canonizeProof(e,{document:t,documentLoader:r,expansionMap:o}){if(o)throw new Error('"expansionMap" not supported.');return delete(e={"@context":t["@context"]||X.SECURITY_CONTEXT_URL,...e}).jws,delete e.signatureValue,delete e.proofValue,this.canonize(e,{documentLoader:r,expansionMap:o,skipExpansion:!1,...this.canonizeOptions})}async createVerifyData({document:e,proof:t,documentLoader:r,expansionMap:o}){if(o)throw new Error('"expansionMap" not supported.');let n;const{_hashCache:i}=this;i&&i.document===e?n=i.hash:this._hashCache={document:e,hash:n=this.canonize(e,{documentLoader:r,expansionMap:o}).then((e=>q({string:e})))};const[a,s]=await Promise.all([this.canonizeProof(t,{document:e,documentLoader:r,expansionMap:o}).then((e=>q({string:e}))),n]);return z.concat(a,s)}async derive(){throw new Error("Must be implemented by a derived class.")}async getVerificationMethod({proof:e,documentLoader:t}){let{verificationMethod:r}=e;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const o=await Y.frame(r,{"@context":X.SECURITY_CONTEXT_URL,"@embed":"@always",id:r},{documentLoader:t,compactToRelative:!1,safe:!0});if(!o)throw new Error(`Verification method ${r} not found.`);if(void 0!==o.revoked)throw new Error("The verification method has been revoked.");return o}async sign(){throw new Error("Must be implemented by a derived class.")}async verifySignature(){throw new Error("Must be implemented by a derived class.")}ensureSuiteContext({document:e,addSuiteContext:t}){const{contextUrl:r}=this;if(function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}({document:e,contextUrl:r}))return;if(!t)throw new TypeError(`The document to be signed must contain this suite's @context, "${r}".`);const o=e["@context"]||[];e["@context"]=Array.isArray(o)?[...o,r]:[o,r]}}};
41
+ const B={};var W=B;B.suites={LinkedDataProof:A,LinkedDataSignature:class extends ${constructor({type:e,proof:t,LDKeyClass:r,date:o,key:n,signer:i,verifier:a,useNativeCanonize:s,canonizeOptions:c,contextUrl:p}={}){super({type:e}),this.LDKeyClass=r,this.contextUrl=p,this.proof=t;const d=function({key:e,signer:t,verifier:r}){const o={};if(e){if(o.key=e,o.verificationMethod=e.id,"function"==typeof e.signer&&(o.signer=e.signer()),"function"==typeof e.verifier&&(o.verifier=e.verifier()),!o.signer&&!o.verifier)throw new TypeError('The "key" parameter must contain a "signer" or "verifier" method.')}else o.verificationMethod=t&&t.id||r&&r.id,o.signer=t,o.verifier=r;if(o.signer&&"function"!=typeof o.signer.sign)throw new TypeError("A signer API has not been specified.");if(o.verifier&&"function"!=typeof o.verifier.verify)throw new TypeError("A verifier API has not been specified.");return o}({key:n,signer:i,verifier:a});if(this.verificationMethod=d.verificationMethod,this.key=d.key,this.signer=d.signer,this.verifier=d.verifier,this.canonizeOptions=c,o&&(this.date=new Date(o),isNaN(this.date)))throw TypeError(`"date" "${o}" is not a valid date.`);this.useNativeCanonize=s,this._hashCache=null}async createProof({document:e,purpose:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');let i;i=this.proof?{...this.proof}:{},i.type=this.type;let a=this.date;void 0===i.created&&void 0===a&&(a=new Date),a&&"string"!=typeof a&&(a=Y.w3cDate(a)),a&&(i.created=a),i.verificationMethod=this.verificationMethod,i=await this.updateProof({document:e,proof:i,proofSet:r,purpose:t,documentLoader:o}),i=await t.update(i,{document:e,suite:this,documentLoader:o});const s=await this.createVerifyData({document:e,proof:i,proofSet:r,documentLoader:o});return i=await this.sign({verifyData:s,document:e,proof:i,documentLoader:o}),i}async updateProof({proof:e,expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e}async verifyProof({proof:e,document:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');try{const i=await this.createVerifyData({document:t,proof:e,proofSet:r,documentLoader:o,expansionMap:n}),a=await this.getVerificationMethod({proof:e,document:t,documentLoader:o,expansionMap:n});if(!await this.verifySignature({verifyData:i,verificationMethod:a,document:t,proof:e,documentLoader:o,expansionMap:n}))throw new Error("Invalid signature.");return{verified:!0,verificationMethod:a}}catch(e){return{verified:!1,error:e}}}async canonize(e,{documentLoader:t,expansionMap:r,skipExpansion:o}){if(r)throw new Error('"expansionMap" not supported.');return z.canonize(e,{algorithm:"URDNA2015",base:null,format:"application/n-quads",documentLoader:t,safe:!0,skipExpansion:o,useNative:this.useNativeCanonize,...this.canonizeOptions})}async canonizeProof(e,{document:t,documentLoader:r,expansionMap:o}){if(o)throw new Error('"expansionMap" not supported.');return delete(e={"@context":t["@context"]||X.SECURITY_CONTEXT_URL,...e}).jws,delete e.signatureValue,delete e.proofValue,this.canonize(e,{documentLoader:r,expansionMap:o,skipExpansion:!1,...this.canonizeOptions})}async createVerifyData({document:e,proof:t,documentLoader:r,expansionMap:o}){if(o)throw new Error('"expansionMap" not supported.');let n;const{_hashCache:i}=this;i&&i.document===e?n=i.hash:this._hashCache={document:e,hash:n=this.canonize(e,{documentLoader:r,expansionMap:o}).then((e=>q({string:e})))};const[a,s]=await Promise.all([this.canonizeProof(t,{document:e,documentLoader:r,expansionMap:o}).then((e=>q({string:e}))),n]);return Y.concat(a,s)}async derive(){throw new Error("Must be implemented by a derived class.")}async getVerificationMethod({proof:e,documentLoader:t}){let{verificationMethod:r}=e;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const o=await z.frame(r,{"@context":X.SECURITY_CONTEXT_URL,"@embed":"@always",id:r},{documentLoader:t,compactToRelative:!1,safe:!0});if(!o)throw new Error(`Verification method ${r} not found.`);if(void 0!==o.revoked)throw new Error("The verification method has been revoked.");return o}async sign(){throw new Error("Must be implemented by a derived class.")}async verifySignature(){throw new Error("Must be implemented by a derived class.")}ensureSuiteContext({document:e,addSuiteContext:t}){const{contextUrl:r}=this;if(function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}({document:e,contextUrl:r}))return;if(!t)throw new TypeError(`The document to be signed must contain this suite's @context, "${r}".`);const o=e["@context"]||[];e["@context"]=Array.isArray(o)?[...o,r]:[o,r]}}};
42
42
  /*!
43
43
  * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
44
44
  */
@@ -60,7 +60,7 @@ const oe={};var ne=oe;oe.purposes={AssertionProofPurpose:class extends te{constr
60
60
  /*!
61
61
  * Copyright (c) 2010-2023 Digital Bazaar, Inc. All rights reserved.
62
62
  */
63
- const ie={};var ae=ie;const se=w;Object.assign(ie,se);const ce=class{async add(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');o=o?R(o):U;const n={...e};delete n.proof;const i=K({document:e}),a=await t.createProof({document:n,purpose:r,proofSet:i,documentLoader:o});return O.addValue(e,"proof",a),e}async derive(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');o=o?R(o):U;const n={...e};delete n.proof;const i=K({document:e});return await t.derive({document:n,purpose:r,proofSet:i,documentLoader:o})}async verify(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');const n=Array.isArray(t)?t:[t];if(0===n.length)throw new TypeError("At least one suite is required.");o=o?R(o):U;try{const t=K({document:e={...e}});if(0===t.length)throw new Error("No matching proofs found in the given document.");delete e.proof;const i=await async function({document:e,suites:t,proofSet:r,purpose:o,documentLoader:n}){const i=Array.isArray(o)?o:[o],a=new Map,s=new Map,c=new Map;if(await Promise.all(i.map((o=>async function({purposeToProofs:e,proofToSuite:t,purpose:r,proofSet:o,suites:n,suiteMatchQueue:i,document:a,documentLoader:s}){for(const c of o){if(!await r.match(c,{document:a,documentLoader:s}))continue;let o=!1;for(const e of n){let r=i.get(e);r||i.set(e,r=new Map);let n=r.get(c);if(n||(n=e.matchProof({proof:c,document:a,documentLoader:s}),r.set(c,n)),await n){o=!0,t.set(c,e);break}}if(o){const t=e.get(r);t?t.push(c):e.set(r,[c])}}}
63
+ const ie={};var ae=ie;const se=w;Object.assign(ie,se);const ce=class{async add(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');o=o?R(o):U;const n={...e};delete n.proof;const i=D({document:e}),a=await t.createProof({document:n,purpose:r,proofSet:i,documentLoader:o});return O.addValue(e,"proof",a),e}async derive(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');o=o?R(o):U;const n={...e};delete n.proof;const i=D({document:e});return await t.derive({document:n,purpose:r,proofSet:i,documentLoader:o})}async verify(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');const n=Array.isArray(t)?t:[t];if(0===n.length)throw new TypeError("At least one suite is required.");o=o?R(o):U;try{const t=D({document:e={...e}});if(0===t.length)throw new Error("No matching proofs found in the given document.");delete e.proof;const i=await async function({document:e,suites:t,proofSet:r,purpose:o,documentLoader:n}){const i=Array.isArray(o)?o:[o],a=new Map,s=new Map,c=new Map;if(await Promise.all(i.map((o=>async function({purposeToProofs:e,proofToSuite:t,purpose:r,proofSet:o,suites:n,suiteMatchQueue:i,document:a,documentLoader:s}){for(const c of o){if(!await r.match(c,{document:a,documentLoader:s}))continue;let o=!1;for(const e of n){let r=i.get(e);r||i.set(e,r=new Map);let n=r.get(c);if(n||(n=e.matchProof({proof:c,document:a,documentLoader:s}),r.set(c,n)),await n){o=!0,t.set(c,e);break}}if(o){const t=e.get(r);t?t.push(c):e.set(r,[c])}}}
64
64
  /*!
65
65
  * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
66
- */({purposeToProofs:a,proofToSuite:s,purpose:o,proofSet:r,suites:t,suiteMatchQueue:c,document:e,documentLoader:n})))),a.size<i.length)return[];const p=new Map;return await Promise.all([...s.entries()].map((async([t,o])=>{let i;try{let a;const s={validate:async(e,{verificationMethod:t})=>(a=t,{valid:!0})},{verified:c,verificationMethod:p,error:d}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});a||(a=p),i={proof:t,verified:c,verificationMethod:a,error:d}}catch(e){i={proof:t,verified:!1,error:e}}i.error&&N(i.error),p.set(t,i)}))),await Promise.all([...a.entries()].map((async([t,r])=>{for(const o of r){const r=p.get(o);if(!r.verified)continue;const{verificationMethod:i}=r,a=s.get(o);let c;try{c=await t.validate(o,{document:e,suite:a,verificationMethod:i,documentLoader:n})}catch(e){c={valid:!1,error:e}}r.purposeResult?Array.isArray(r.purposeResult)?r.purposeResult.push(c):r.purposeResult=[r.purposeResult,c]:r.purposeResult=c,c.valid||(N(c.error),r.error||(r.verified=!1,r.error=c.error))}}))),[...p.values()]}({document:e,suites:n,proofSet:t,purpose:r,documentLoader:o});if(0===i.length){const e=new Error("Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).");throw e.name="NotFoundError",e}const a=i.some((e=>e.verified));if(!a){const e=[].concat(...i.filter((e=>e.error)).map((e=>e.error))),t={verified:a,results:i};return e.length>0&&(t.error=e),t}return{verified:a,results:i}}catch(e){return N(e),{verified:!1,error:e}}}},pe=P;ie.derive=async function(e,{suite:t,purpose:r,documentLoader:o,addSuiteContext:n=!0}={}){if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:n});try{return await(new ce).derive(e,{suite:t,purpose:r,documentLoader:o})}catch(e){if(!o&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "derive".`);throw r.cause=e,r}throw e}},ie.sign=async function(e,{suite:t,purpose:r,documentLoader:o,expansionMap:n,addSuiteContext:i=!0}={}){if(n)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:i});try{return await(new ce).add(e,{suite:t,purpose:r,documentLoader:o})}catch(e){if(!o&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "sign".`);throw r.cause=e,r}throw e}},ie.verify=async function(e,{suite:t,purpose:r,documentLoader:o,expansionMap:n}={}){if(n)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');const i=await(new ce).verify(e,{suite:t,purpose:r,documentLoader:o}),{error:a}=i;if(a)if(o||"jsonld.InvalidUrl"!==a.name)i.error=new pe(a);else{const{details:{url:e}}=a,t=new Error(`A URL "${e}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".`);i.error=new pe(t)}return i},ie.suites=B.suites,ie.purposes=ne.purposes,Object.assign(ie,x);var de=e(ae);export{de as j};
66
+ */({purposeToProofs:a,proofToSuite:s,purpose:o,proofSet:r,suites:t,suiteMatchQueue:c,document:e,documentLoader:n})))),a.size<i.length)return[];const p=new Map;return await Promise.all([...s.entries()].map((async([t,o])=>{let i;try{let a;const s={validate:async(e,{verificationMethod:t})=>(a=t,{valid:!0})},{verified:c,verificationMethod:p,error:d}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});a||(a=p),i={proof:t,verified:c,verificationMethod:a,error:d}}catch(e){i={proof:t,verified:!1,error:e}}i.error&&P(i.error),p.set(t,i)}))),await Promise.all([...a.entries()].map((async([t,r])=>{for(const o of r){const r=p.get(o);if(!r.verified)continue;const{verificationMethod:i}=r,a=s.get(o);let c;try{c=await t.validate(o,{document:e,suite:a,verificationMethod:i,documentLoader:n})}catch(e){c={valid:!1,error:e}}r.purposeResult?Array.isArray(r.purposeResult)?r.purposeResult.push(c):r.purposeResult=[r.purposeResult,c]:r.purposeResult=c,c.valid||(P(c.error),r.error||(r.verified=!1,r.error=c.error))}}))),[...p.values()]}({document:e,suites:n,proofSet:t,purpose:r,documentLoader:o});if(0===i.length){const e=new Error("Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).");throw e.name="NotFoundError",e}const a=i.some((e=>e.verified));if(!a){const e=[].concat(...i.filter((e=>e.error)).map((e=>e.error))),t={verified:a,results:i};return e.length>0&&(t.error=e),t}return{verified:a,results:i}}catch(e){return P(e),{verified:!1,error:e}}}},pe=N;ie.derive=async function(e,{suite:t,purpose:r,documentLoader:o,addSuiteContext:n=!0}={}){if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:n});try{return await(new ce).derive(e,{suite:t,purpose:r,documentLoader:o})}catch(e){if(!o&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "derive".`);throw r.cause=e,r}throw e}},ie.sign=async function(e,{suite:t,purpose:r,documentLoader:o,expansionMap:n,addSuiteContext:i=!0}={}){if(n)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:i});try{return await(new ce).add(e,{suite:t,purpose:r,documentLoader:o})}catch(e){if(!o&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "sign".`);throw r.cause=e,r}throw e}},ie.verify=async function(e,{suite:t,purpose:r,documentLoader:o,expansionMap:n}={}){if(n)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');const i=await(new ce).verify(e,{suite:t,purpose:r,documentLoader:o}),{error:a}=i;if(a)if(o||"jsonld.InvalidUrl"!==a.name)i.error=new pe(a);else{const{details:{url:e}}=a,t=new Error(`A URL "${e}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".`);i.error=new pe(t)}return i},ie.suites=W.suites,ie.purposes=ne.purposes,Object.assign(ie,x);var de=e(ae);export{de as j};