@blockcerts/blockcerts-verifier 1.68.0 → 1.70.0

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 (36) hide show
  1. package/bundle-stats.html +2229 -2122
  2. package/dist/{EcdsaSd2023-CJsktwwK-COovFO-E.js → EcdsaSd2023-DcsELLJj-DreWzXlX.js} +9 -9
  3. package/dist/EcdsaSecp256k1Signature2019-Cy1mIkjt-DJmj4ZAc.js +1 -0
  4. package/dist/{Ed25519Signature2020-D3owGts_-BB1fBq0Z.js → Ed25519Signature2020-B-CFC9WC-DJkVVmwk.js} +6 -6
  5. package/dist/{MerkleProof2017-BrDGNMx2-Ct7-Dmh5.js → MerkleProof2017-DqA3Y12J-D6qS7nCf.js} +1 -1
  6. package/dist/{MerkleProof2019-D70TTI_--BhNFm4-a.js → MerkleProof2019-B4HSvmJo-Cwc-hu-Y.js} +2 -2
  7. package/dist/checkCredentialSchemaConformity-ChaCRIqw-7U54o8BA.js +1 -0
  8. package/dist/controlVerificationMethod-qY02GU_H-B-4U8WJQ.js +1 -0
  9. package/dist/{did-key-common.esm-D_08iodm-FY3lD1HA.js → did-key-common.esm-nDfdwcKN-BTWid9-w.js} +3 -3
  10. package/dist/{did-key-ed25519.esm-Cah33z_9-CXstsY-H.js → did-key-ed25519.esm-DNra0jwE-CTwAEzy6.js} +1 -1
  11. package/dist/{did-key-secp256k1.esm-C27OwLgS-C9mjnb5S.js → did-key-secp256k1.esm-Dv1NXpDw-_M-qRy-N.js} +1 -1
  12. package/dist/{downloadPDF-XZlmMePj.js → downloadPDF-DQVfeIBI.js} +8 -8
  13. package/dist/{index-Bxtpkwnp-BkEvuYc3.js → index-BM3knvQR-D4vxi3Vi.js} +15 -15
  14. package/dist/{index-PZL1xHXK-CH1Nkb1O.js → index-Bi-O7G4n-Bgz40JYf.js} +7 -7
  15. package/dist/{index-Br-3L8ut-BI4gpx_q.js → index-ButIU7pZ-Djl5IfSw.js} +1 -1
  16. package/dist/{index.es-B13oYDrC.js → index.es-BqQdvz5C.js} +2 -2
  17. package/dist/main.js +112 -112
  18. package/dist/purify.es-DJj7iNgQ.js +2 -0
  19. package/dist/{retrieveVerificationMethodPublicKey-DMLSSemm-uQidviAv.js → retrieveVerificationMethodPublicKey-6-rH9LB2-DvFOhdlW.js} +1 -1
  20. package/dist/verifyIssuerProfile-DnjbDuXe-BVFzyjSL.js +1 -0
  21. package/dist/{webcrypto.es-CjDwtULr-D7dA51Yn.js → webcrypto.es-BxABHF-B-TCzLuarM.js} +1 -1
  22. package/package.json +4 -4
  23. package/dist/EcdsaSecp256k1Signature2019-hg62McNW-DMCKToe3.js +0 -1
  24. package/dist/checkCredentialSchemaConformity-D7h9tZ1Y-B0tA00kY.js +0 -1
  25. package/dist/controlVerificationMethod-DPnoI09o-D_Ktjb-C.js +0 -1
  26. package/dist/purify-hA3K4SAZ.js +0 -2
  27. /package/dist/{HashlinkVerifier-BE8mYTIj-dg5WNZnc.js → HashlinkVerifier-hQgVXluZ-dg5WNZnc.js} +0 -0
  28. /package/dist/{checkRevocationStatusList2021-CtVHNZ7k-XCu3zkCJ.js → checkRevocationStatusList2021-CPFaTtUR-XCu3zkCJ.js} +0 -0
  29. /package/dist/{elliptic-D7vAoLbk-DQmYEk-8.js → elliptic-D-ZnlFdt-DQmYEk-8.js} +0 -0
  30. /package/dist/{ensureNotRevoked-BEtBmERU-DvMIgM4L.js → ensureNotRevoked-D9FFjDJd-DvMIgM4L.js} +0 -0
  31. /package/dist/{ensureValidIssuingKey-BrJmJb4L-wu9SdYxL.js → ensureValidIssuingKey-Cz0isOdi-wu9SdYxL.js} +0 -0
  32. /package/dist/{index-BeIcTgye-C0eXpZGn.js → index-0q2-1l6i-C0eXpZGn.js} +0 -0
  33. /package/dist/{index-CQB1Suna-Dgus2xdV.js → index-ZJb8DPW9-Dgus2xdV.js} +0 -0
  34. /package/dist/{jsonld-D-rUqx_B-CQeQQNYP.js → jsonld-CQCA9cVk-CQeQQNYP.js} +0 -0
  35. /package/dist/{sha256-BIbQVOZh-C1PUWFZm.js → sha256-BIUNvBZY-C1PUWFZm.js} +0 -0
  36. /package/dist/{x25519-C5Qlh_Lh-NSl6svWQ.js → x25519-CEFq6uo8-NSl6svWQ.js} +0 -0
@@ -1,8 +1,8 @@
1
- import{g as e,u as t,B as r,i as o}from"./main.js";import{a as n,b as a,c as i}from"./jsonld-D-rUqx_B-CQeQQNYP.js";var s,c,u,d,p,h,l,f,m,g,y,w,v,T,b,x,E=(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,b as i,c as a}from"./jsonld-CQCA9cVk-CQeQQNYP.js";var s,c,u,d,p,h,l,f,m,g,y,w,v,T,b,x,E=(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
  */
5
- const o=r(1),n=r(2),a=r(3),{CONTEXT_URL:i,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c}=a,u=new Map;u.set(s,o),u.set(c,n),e.exports={constants:a,contexts:u,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c,CONTEXT_URL:i,CONTEXT:n}},function(e,t,r){
5
+ const o=r(1),n=r(2),i=r(3),{CONTEXT_URL:a,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c}=i,u=new Map;u.set(s,o),u.set(c,n),e.exports={constants:i,contexts:u,SECURITY_CONTEXT_V1_URL:s,SECURITY_CONTEXT_V2_URL:c,CONTEXT_URL:a,CONTEXT:n}},function(e,t,r){
6
6
  /*!
7
7
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
8
8
  */
@@ -20,52 +20,52 @@ e.exports={SECURITY_CONTEXT_V1_URL:"https://w3id.org/security/v1",SECURITY_CONTE
20
20
  */function A(){if(h)return p;h=1;const e=k(),{contexts:t}=M;return p=new Map([[e.SECURITY_CONTEXT_V1_URL,t.get(e.SECURITY_CONTEXT_V1_URL)],[e.SECURITY_CONTEXT_V2_URL,t.get(e.SECURITY_CONTEXT_V2_URL)]])}
21
21
  /*!
22
22
  * Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
23
- */function L(){if(f)return l;f=1;const e=A(),t={};return l=t,t.extendContextLoader=t=>async r=>{const o=e.get(r);return void 0!==o?{contextUrl:null,documentUrl:r,document:o,tag:"static"}:t(r)},t.strictDocumentLoader=t.extendContextLoader((e=>{throw new Error(`${e} not found.`)})),l}function U(){if(g)return m;g=1;class e extends Error{constructor(t){super(e._prepareSuperMessage(t)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,e)}static _prepareSuperMessage(e){try{return JSON.stringify(e)}catch{return String(e)}}}const t=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],n=Symbol(".toJSON called"),a=({from:e,seen:i,to_:s,forceEnumerable:c,maxDepth:u,depth:d})=>{const p=s||(Array.isArray(e)?[]:{});if(i.push(e),d>=u)return p;if("function"==typeof e.toJSON&&!0!==e[n])return(e=>{e[n]=!0;const t=e.toJSON();return delete e[n],t})(e);for(const[t,n]of Object.entries(e))"function"==typeof r&&o(n)?p[t]="[object Buffer]":"function"!=typeof n&&(n&&"object"==typeof n?i.includes(e[t])?p[t]="[Circular]":(d++,p[t]=a({from:e[t],seen:i.slice(),forceEnumerable:c,maxDepth:u,depth:d})):p[t]=n);for(const{property:r,enumerable:o}of t)"string"==typeof e[r]&&Object.defineProperty(p,r,{value:e[r],enumerable:!!c||o,configurable:!0,writable:!0});return p};return m={serializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;return"object"==typeof e&&null!==e?a({from:e,seen:[],forceEnumerable:!0,maxDepth:r,depth:0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e},deserializeError:(t,r={})=>{const{maxDepth:o=Number.POSITIVE_INFINITY}=r;if(t instanceof Error)return t;if("object"==typeof t&&null!==t&&!Array.isArray(t)){const e=new Error;return a({from:t,seen:[],to_:e,maxDepth:o,depth:0}),e}return new e(t)}}}
23
+ */function L(){if(f)return l;f=1;const e=A(),t={};return l=t,t.extendContextLoader=t=>async r=>{const o=e.get(r);return void 0!==o?{contextUrl:null,documentUrl:r,document:o,tag:"static"}:t(r)},t.strictDocumentLoader=t.extendContextLoader((e=>{throw new Error(`${e} not found.`)})),l}function U(){if(g)return m;g=1;class e extends Error{constructor(t){super(e._prepareSuperMessage(t)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,e)}static _prepareSuperMessage(e){try{return JSON.stringify(e)}catch{return String(e)}}}const t=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],n=Symbol(".toJSON called"),i=({from:e,seen:a,to_:s,forceEnumerable:c,maxDepth:u,depth:d})=>{const p=s||(Array.isArray(e)?[]:{});if(a.push(e),d>=u)return p;if("function"==typeof e.toJSON&&!0!==e[n])return(e=>{e[n]=!0;const t=e.toJSON();return delete e[n],t})(e);for(const[t,n]of Object.entries(e))"function"==typeof r&&o(n)?p[t]="[object Buffer]":"function"!=typeof n&&(n&&"object"==typeof n?a.includes(e[t])?p[t]="[Circular]":(d++,p[t]=i({from:e[t],seen:a.slice(),forceEnumerable:c,maxDepth:u,depth:d})):p[t]=n);for(const{property:r,enumerable:o}of t)"string"==typeof e[r]&&Object.defineProperty(p,r,{value:e[r],enumerable:!!c||o,configurable:!0,writable:!0});return p};return m={serializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;return"object"==typeof e&&null!==e?i({from:e,seen:[],forceEnumerable:!0,maxDepth:r,depth:0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e},deserializeError:(t,r={})=>{const{maxDepth:o=Number.POSITIVE_INFINITY}=r;if(t instanceof Error)return t;if("object"==typeof t&&null!==t&&!Array.isArray(t)){const e=new Error;return i({from:t,seen:[],to_:e,maxDepth:o,depth:0}),e}return new e(t)}}}
24
24
  /*!
25
25
  * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
26
- */function j(){if(w)return y;w=1;const e=k(),t=n(),{extendContextLoader:r,strictDocumentLoader:o}=L(),{serializeError:a}=U();function i({document:r}){let o;o=t.getValues(r,"proof");const n=r["@context"]||e.SECURITY_CONTEXT_URL;return o=o.map((e=>{const{cryptosuite:t}=e;return t?.includes?.("-jcs-")?e:{"@context":n,...e}})),o}function s(e){Object.defineProperty(e,"toJSON",{value:function(){return a(this)},configurable:!0,writable:!0})}return y=class{async add(e,{suite:n,purpose:a,documentLoader:s}={}){if(!n)throw new TypeError('"options.suite" is required.');if(!a)throw new TypeError('"options.purpose" is required.');s=s?r(s):o;const c={...e};delete c.proof;const u=i({document:e}),d=await n.createProof({document:c,purpose:a,proofSet:u,documentLoader:s});return t.addValue(e,"proof",d),e}async derive(e,{suite:t,purpose:n,documentLoader:a}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!n)throw new TypeError('"options.purpose" is required.');a=a?r(a):o;const s={...e};delete s.proof;const c=i({document:e});return await t.derive({document:s,purpose:n,proofSet:c,documentLoader:a})}async verify(e,{suite:t,purpose:n,documentLoader:a}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!n)throw new TypeError('"options.purpose" is required.');const c=Array.isArray(t)?t:[t];if(0===c.length)throw new TypeError("At least one suite is required.");a=a?r(a):o;try{const t=i({document:e={...e}});if(0===t.length)throw new Error("No matching proofs found in the given document.");delete e.proof;const r=await async function({document:e,suites:t,proofSet:r,purpose:o,documentLoader:n}){const a=Array.isArray(o)?o:[o],i=new Map,c=new Map,u=new Map;if(await Promise.all(a.map((o=>async function({purposeToProofs:e,proofToSuite:t,purpose:r,proofSet:o,suites:n,suiteMatchQueue:a,document:i,documentLoader:s}){for(const c of o){if(!await r.match(c,{document:i,documentLoader:s}))continue;let o=!1;for(const e of n){let r=a.get(e);r||a.set(e,r=new Map);let n=r.get(c);if(n||(n=e.matchProof({proof:c,document:i,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])}}}({purposeToProofs:i,proofToSuite:c,purpose:o,proofSet:r,suites:t,suiteMatchQueue:u,document:e,documentLoader:n})))),i.size<a.length)return[];const d=new Map;return await Promise.all([...c.entries()].map((async([t,o])=>{let a;try{let i;const s={validate:async(e,{verificationMethod:t})=>(i=t,{valid:!0})},{verified:c,verificationMethod:u,error:d}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});i||(i=u),a={proof:t,verified:c,verificationMethod:i,error:d}}catch(e){a={proof:t,verified:!1,error:e}}a.error&&s(a.error),d.set(t,a)}))),await Promise.all([...i.entries()].map((async([t,r])=>{for(const o of r){const r=d.get(o);if(!r.verified)continue;const{verificationMethod:a}=r,i=c.get(o);let u;try{u=await t.validate(o,{document:e,suite:i,verificationMethod:a,documentLoader:n})}catch(e){u={valid:!1,error:e}}r.purposeResult?Array.isArray(r.purposeResult)?r.purposeResult.push(u):r.purposeResult=[r.purposeResult,u]:r.purposeResult=u,u.valid||(s(u.error),r.error||(r.verified=!1,r.error=u.error))}}))),[...d.values()]}({document:e,suites:c,proofSet:t,purpose:n,documentLoader:a});if(0===r.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 o=r.some((e=>e.verified));if(!o){const e=[].concat(...r.filter((e=>e.error)).map((e=>e.error))),t={verified:o,results:r};return e.length>0&&(t.error=e),t}return{verified:o,results:r}}catch(e){return s(e),{verified:!1,error:e}}}},y}
26
+ */function j(){if(w)return y;w=1;const e=k(),t=n(),{extendContextLoader:r,strictDocumentLoader:o}=L(),{serializeError:i}=U();function a({document:r}){let o;o=t.getValues(r,"proof");const n=r["@context"]||e.SECURITY_CONTEXT_URL;return o=o.map((e=>{const{cryptosuite:t}=e;return t?.includes?.("-jcs-")?e:{"@context":n,...e}})),o}function s(e){Object.defineProperty(e,"toJSON",{value:function(){return i(this)},configurable:!0,writable:!0})}return y=class{async add(e,{suite:n,purpose:i,documentLoader:s}={}){if(!n)throw new TypeError('"options.suite" is required.');if(!i)throw new TypeError('"options.purpose" is required.');s=s?r(s):o;const c={...e};delete c.proof;const u=a({document:e}),d=await n.createProof({document:c,purpose:i,proofSet:u,documentLoader:s});return t.addValue(e,"proof",d),e}async derive(e,{suite:t,purpose:n,documentLoader:i}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!n)throw new TypeError('"options.purpose" is required.');i=i?r(i):o;const s={...e};delete s.proof;const c=a({document:e});return await t.derive({document:s,purpose:n,proofSet:c,documentLoader:i})}async verify(e,{suite:t,purpose:n,documentLoader:i}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!n)throw new TypeError('"options.purpose" is required.');const c=Array.isArray(t)?t:[t];if(0===c.length)throw new TypeError("At least one suite is required.");i=i?r(i):o;try{const t=a({document:e={...e}});if(0===t.length)throw new Error("No matching proofs found in the given document.");delete e.proof;const r=await async function({document:e,suites:t,proofSet:r,purpose:o,documentLoader:n}){const i=Array.isArray(o)?o:[o],a=new Map,c=new Map,u=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])}}}({purposeToProofs:a,proofToSuite:c,purpose:o,proofSet:r,suites:t,suiteMatchQueue:u,document:e,documentLoader:n})))),a.size<i.length)return[];const d=new Map;return await Promise.all([...c.entries()].map((async([t,o])=>{let i;try{let a;const s={validate:async(e,{verificationMethod:t})=>(a=t,{valid:!0})},{verified:c,verificationMethod:u,error:d}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});a||(a=u),i={proof:t,verified:c,verificationMethod:a,error:d}}catch(e){i={proof:t,verified:!1,error:e}}i.error&&s(i.error),d.set(t,i)}))),await Promise.all([...a.entries()].map((async([t,r])=>{for(const o of r){const r=d.get(o);if(!r.verified)continue;const{verificationMethod:i}=r,a=c.get(o);let u;try{u=await t.validate(o,{document:e,suite:a,verificationMethod:i,documentLoader:n})}catch(e){u={valid:!1,error:e}}r.purposeResult?Array.isArray(r.purposeResult)?r.purposeResult.push(u):r.purposeResult=[r.purposeResult,u]:r.purposeResult=u,u.valid||(s(u.error),r.error||(r.verified=!1,r.error=u.error))}}))),[...d.values()]}({document:e,suites:c,proofSet:t,purpose:n,documentLoader:i});if(0===r.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 o=r.some((e=>e.verified));if(!o){const e=[].concat(...r.filter((e=>e.error)).map((e=>e.error))),t={verified:o,results:r};return e.length>0&&(t.error=e),t}return{verified:o,results:r}}catch(e){return s(e),{verified:!1,error:e}}}},y}
27
27
  /*!
28
28
  * Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
29
- */function O(){return x?b:(x=1,b=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}})}var P,K,z={};function V(){return K?P:(K=1,P=class e{constructor(e,t=new Map,r=0){this.prefix=e,this._existing=t,this.counter=r}clone(){const{prefix:t,_existing:r,counter:o}=this;return new e(t,new Map(r),o)}getId(e){const t=e&&this._existing.get(e);if(t)return t;const r=this.prefix+this.counter;return this.counter++,e&&this._existing.set(e,r),r}hasId(e){return this._existing.has(e)}getOldIds(){return[...this._existing.keys()]}})}var F,q,B,X,$,H,Q,Y,W,G,J,Z,ee,te,re,oe,ne,ae,ie,se,ce,ue,de,pe,he,le,fe,me,ge,ye,we,ve,Te,be,xe={};
29
+ */function O(){return x?b:(x=1,b=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}})}var P,K,z={};function V(){return K?P:(K=1,P=class e{constructor(e,t=new Map,r=0){this.prefix=e,this._existing=t,this.counter=r}clone(){const{prefix:t,_existing:r,counter:o}=this;return new e(t,new Map(r),o)}getId(e){const t=e&&this._existing.get(e);if(t)return t;const r=this.prefix+this.counter;return this.counter++,e&&this._existing.set(e,r),r}hasId(e){return this._existing.has(e)}getOldIds(){return[...this._existing.keys()]}})}var F,q,B,X,$,Q,H,Y,W,G,J,Z,ee,te,re,oe,ne,ie,ae,se,ce,ue,de,pe,he,le,fe,me,ge,ye,we,ve,Te,be,xe={};
30
30
  /*!
31
31
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
32
- */function Ee(){if(F)return xe;F=1,i(),xe.setImmediate=setImmediate,xe.crypto=globalThis.crypto;const e=[];for(let t=0;t<=255;++t)e.push(t.toString(16).padStart(2,"0"));return xe.bufferToHex=function(t){let r="";const o=new Uint8Array(t);for(let t=0;t<o.length;++t)r+=e[o[t]];return r},xe}
32
+ */function Ee(){if(F)return xe;F=1,a(),xe.setImmediate=setImmediate,xe.crypto=globalThis.crypto;const e=[];for(let t=0;t<=255;++t)e.push(t.toString(16).padStart(2,"0"));return xe.bufferToHex=function(t){let r="";const o=new Uint8Array(t);for(let t=0;t<o.length;++t)r+=e[o[t]];return r},xe}
33
33
  /*!
34
34
  * Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
35
35
  */function Ie(){if(B)return q;B=1;const{bufferToHex:e,crypto:t}=Ee(),r=new Map([["sha256","SHA-256"],["SHA256","SHA-256"],["SHA-256","SHA-256"],["sha384","SHA-384"],["SHA384","SHA-384"],["SHA-384","SHA-384"],["sha512","SHA-512"],["SHA512","SHA-512"],["SHA-512","SHA-512"]]);return q=class{constructor(e){if(!t||!t.subtle)throw new Error("crypto.subtle not found.");if(!r.has(e))throw new Error(`Unsupported algorithm "${e}".`);this.algorithm=r.get(e),this._content=""}update(e){this._content+=e}async digest(){const r=(new TextEncoder).encode(this._content),o=await t.subtle.digest(this.algorithm,r);return e(o)}}}
36
36
  /*!
37
37
  * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
38
- */function _e(){return $?X:($=1,X=class{constructor(e){this.current=e.sort(),this.done=!1,this.dir=new Map;for(let t=0;t<e.length;++t)this.dir.set(e[t],!0)}hasNext(){return!this.done}next(){const{current:e,dir:t}=this,r=e.slice();let o=null,n=0;const a=e.length;for(let r=0;r<a;++r){const i=e[r],s=t.get(i);(null===o||i>o)&&(s&&r>0&&i>e[r-1]||!s&&r<a-1&&i>e[r+1])&&(o=i,n=r)}if(null===o)this.done=!0;else{const r=t.get(o)?n-1:n+1;e[n]=e[r],e[r]=o;for(const r of e)r>o&&t.set(r,!t.get(r))}return r}})}
38
+ */function _e(){return $?X:($=1,X=class{constructor(e){this.current=e.sort(),this.done=!1,this.dir=new Map;for(let t=0;t<e.length;++t)this.dir.set(e[t],!0)}hasNext(){return!this.done}next(){const{current:e,dir:t}=this,r=e.slice();let o=null,n=0;const i=e.length;for(let r=0;r<i;++r){const a=e[r],s=t.get(a);(null===o||a>o)&&(s&&r>0&&a>e[r-1]||!s&&r<i-1&&a>e[r+1])&&(o=a,n=r)}if(null===o)this.done=!0;else{const r=t.get(o)?n-1:n+1;e[n]=e[r],e[r]=o;for(const r of e)r>o&&t.set(r,!t.get(r))}return r}})}
39
39
  /*!
40
40
  * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
41
- */function De(){if(Q)return H;Q=1;const e="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",t="http://www.w3.org/2001/XMLSchema#string",r="NamedNode",o="BlankNode",n="Literal",a={};function i(e,t){return e.subject.termType===t.subject.termType&&e.object.termType===t.object.termType&&(e.subject.value===t.subject.value&&e.predicate.value===t.predicate.value&&e.object.value===t.object.value&&(e.object.termType!==n||e.object.datatype.termType===t.object.datatype.termType&&e.object.language===t.object.language&&e.object.datatype.value===t.object.datatype.value))}(()=>{const e="A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�_",t=e+"0-9-·̀-ͯ‿-⁀",r="_:((?:["+e+"0-9])(?:(?:["+t+".])*(?:["+t+"]))?)",o='(?:<((?:[^\0- <>"{}|^`\\\\]|\\\\u[0-9A-Fa-f]{4}|\\\\U[0-9A-Fa-f]{8})*)>)',n="[ \\t]+",i="[ \\t]*",s="(?:"+o+"|"+r+")"+n,c=o+n,u="(?:"+o+"|"+r+"|"+('(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:'+("(?:\\^\\^"+o+")")+"|(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)))?)")+")"+i,d="(?:\\.|(?:(?:"+o+"|"+r+")"+i+"\\.))";a.eoln=/(?:\r\n)|(?:\n)|(?:\r)/g,a.empty=new RegExp("^"+i+"$"),a.quad=new RegExp("^"+i+s+c+u+d+i+"$")})(),H=class u{static parse(s){const c=[],u={},p=s.split(a.eoln);let h=0;for(const s of p){if(h++,a.empty.test(s))continue;const p=s.match(a.quad);if(null===p)throw new Error("N-Quads parse error on line "+h+".");const l={subject:null,predicate:null,object:null,graph:null};if(void 0!==p[1]?l.subject={termType:r,value:m(p[1])}:l.subject={termType:o,value:p[2]},l.predicate={termType:r,value:m(p[3])},void 0!==p[4]?l.object={termType:r,value:m(p[4])}:void 0!==p[5]?l.object={termType:o,value:p[5]}:(l.object={termType:n,value:void 0,datatype:{termType:r}},void 0!==p[7]?l.object.datatype.value=m(p[7]):void 0!==p[8]?(l.object.datatype.value=e,l.object.language=p[8]):l.object.datatype.value=t,l.object.value=d(p[6])),void 0!==p[9]?l.graph={termType:r,value:m(p[9])}:void 0!==p[10]?l.graph={termType:o,value:p[10]}:l.graph={termType:"DefaultGraph",value:""},l.graph.value in u){let e=!0;const t=u[l.graph.value];for(const r of t)if(i(r,l)){e=!1;break}e&&(t.push(l),c.push(l))}else u[l.graph.value]=[l],c.push(l)}return c}static serialize(e){const t=[];for(const r of e)t.push(u.serializeQuad(r));return t.sort().join("")}static serializeQuadComponents(n,a,i,u){let d="";return n.termType===r?d+=`<${l(n.value)}>`:d+=`_:${n.value}`,a.termType===r?d+=` <${l(a.value)}> `:d+=` _:${a.value} `,i.termType===r?d+=`<${l(i.value)}>`:i.termType===o?d+=`_:${i.value}`:(d+=`"${function(e){if(!s.test(e))return e;return e.replace(s,(function(e){return c[e.codePointAt(0)]}))}(i.value)}"`,i.datatype.value===e?i.language&&(d+=`@${i.language}`):i.datatype.value!==t&&(d+=`^^<${l(i.datatype.value)}>`)),u.termType===r?d+=` <${l(u.value)}>`:u.termType===o&&(d+=` _:${u.value}`),d+=" .\n",d}static serializeQuad(e){return u.serializeQuadComponents(e.subject,e.predicate,e.object,e.graph)}};const s=/[\u0000-\u001F\u007F"\\]/g,c=[];for(let e=0;e<=127;++e)s.test(String.fromCharCode(e))&&(c[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),s.lastIndex=0);c["\b".codePointAt(0)]="\\b",c["\t".codePointAt(0)]="\\t",c["\n".codePointAt(0)]="\\n",c["\f".codePointAt(0)]="\\f",c["\r".codePointAt(0)]="\\r",c['"'.codePointAt(0)]='\\"',c["\\".codePointAt(0)]="\\\\";const u=/(?:\\([btnfr"'\\]))|(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function d(e){return u.test(e)?e.replace(u,(function(e,t,r,o){if(t)switch(t){case"b":return"\b";case"t":return"\t";case"n":return"\n";case"f":return"\f";case"r":return"\r";case'"':return'"';case"'":return"'";case"\\":return"\\"}return r?String.fromCharCode(parseInt(r,16)):o?String.fromCodePoint(parseInt(o,16)):void 0})):e}const p=/[\u0000-\u0020<>"{}|^`\\]/g,h=[];for(let e=0;e<=127;++e)p.test(String.fromCharCode(e))&&(h[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),p.lastIndex=0);function l(e){return p.test(e)?e.replace(p,(function(e){return h[e.codePointAt(0)]})):e}const f=/(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function m(e){return f.test(e)?e.replace(f,(function(e,t,r){return t?String.fromCharCode(parseInt(t,16)):r?String.fromCodePoint(parseInt(r,16)):void 0})):e}return H}
41
+ */function De(){if(H)return Q;H=1;const e="http://www.w3.org/1999/02/22-rdf-syntax-ns#langString",t="http://www.w3.org/2001/XMLSchema#string",r="NamedNode",o="BlankNode",n="Literal",i={};function a(e,t){return e.subject.termType===t.subject.termType&&e.object.termType===t.object.termType&&(e.subject.value===t.subject.value&&e.predicate.value===t.predicate.value&&e.object.value===t.object.value&&(e.object.termType!==n||e.object.datatype.termType===t.object.datatype.termType&&e.object.language===t.object.language&&e.object.datatype.value===t.object.datatype.value))}(()=>{const e="A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�_",t=e+"0-9-·̀-ͯ‿-⁀",r="_:((?:["+e+"0-9])(?:(?:["+t+".])*(?:["+t+"]))?)",o='(?:<((?:[^\0- <>"{}|^`\\\\]|\\\\u[0-9A-Fa-f]{4}|\\\\U[0-9A-Fa-f]{8})*)>)',n="[ \\t]+",a="[ \\t]*",s="(?:"+o+"|"+r+")"+n,c=o+n,u="(?:"+o+"|"+r+"|"+('(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"(?:'+("(?:\\^\\^"+o+")")+"|(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)))?)")+")"+a,d="(?:\\.|(?:(?:"+o+"|"+r+")"+a+"\\.))";i.eoln=/(?:\r\n)|(?:\n)|(?:\r)/g,i.empty=new RegExp("^"+a+"$"),i.quad=new RegExp("^"+a+s+c+u+d+a+"$")})(),Q=class u{static parse(s){const c=[],u={},p=s.split(i.eoln);let h=0;for(const s of p){if(h++,i.empty.test(s))continue;const p=s.match(i.quad);if(null===p)throw new Error("N-Quads parse error on line "+h+".");const l={subject:null,predicate:null,object:null,graph:null};if(void 0!==p[1]?l.subject={termType:r,value:m(p[1])}:l.subject={termType:o,value:p[2]},l.predicate={termType:r,value:m(p[3])},void 0!==p[4]?l.object={termType:r,value:m(p[4])}:void 0!==p[5]?l.object={termType:o,value:p[5]}:(l.object={termType:n,value:void 0,datatype:{termType:r}},void 0!==p[7]?l.object.datatype.value=m(p[7]):void 0!==p[8]?(l.object.datatype.value=e,l.object.language=p[8]):l.object.datatype.value=t,l.object.value=d(p[6])),void 0!==p[9]?l.graph={termType:r,value:m(p[9])}:void 0!==p[10]?l.graph={termType:o,value:p[10]}:l.graph={termType:"DefaultGraph",value:""},l.graph.value in u){let e=!0;const t=u[l.graph.value];for(const r of t)if(a(r,l)){e=!1;break}e&&(t.push(l),c.push(l))}else u[l.graph.value]=[l],c.push(l)}return c}static serialize(e){const t=[];for(const r of e)t.push(u.serializeQuad(r));return t.sort().join("")}static serializeQuadComponents(n,i,a,u){let d="";return n.termType===r?d+=`<${l(n.value)}>`:d+=`_:${n.value}`,i.termType===r?d+=` <${l(i.value)}> `:d+=` _:${i.value} `,a.termType===r?d+=`<${l(a.value)}>`:a.termType===o?d+=`_:${a.value}`:(d+=`"${function(e){if(!s.test(e))return e;return e.replace(s,(function(e){return c[e.codePointAt(0)]}))}(a.value)}"`,a.datatype.value===e?a.language&&(d+=`@${a.language}`):a.datatype.value!==t&&(d+=`^^<${l(a.datatype.value)}>`)),u.termType===r?d+=` <${l(u.value)}>`:u.termType===o&&(d+=` _:${u.value}`),d+=" .\n",d}static serializeQuad(e){return u.serializeQuadComponents(e.subject,e.predicate,e.object,e.graph)}};const s=/[\u0000-\u001F\u007F"\\]/g,c=[];for(let e=0;e<=127;++e)s.test(String.fromCharCode(e))&&(c[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),s.lastIndex=0);c["\b".codePointAt(0)]="\\b",c["\t".codePointAt(0)]="\\t",c["\n".codePointAt(0)]="\\n",c["\f".codePointAt(0)]="\\f",c["\r".codePointAt(0)]="\\r",c['"'.codePointAt(0)]='\\"',c["\\".codePointAt(0)]="\\\\";const u=/(?:\\([btnfr"'\\]))|(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function d(e){return u.test(e)?e.replace(u,(function(e,t,r,o){if(t)switch(t){case"b":return"\b";case"t":return"\t";case"n":return"\n";case"f":return"\f";case"r":return"\r";case'"':return'"';case"'":return"'";case"\\":return"\\"}return r?String.fromCharCode(parseInt(r,16)):o?String.fromCodePoint(parseInt(o,16)):void 0})):e}const p=/[\u0000-\u0020<>"{}|^`\\]/g,h=[];for(let e=0;e<=127;++e)p.test(String.fromCharCode(e))&&(h[e]="\\u"+e.toString(16).toUpperCase().padStart(4,"0"),p.lastIndex=0);function l(e){return p.test(e)?e.replace(p,(function(e){return h[e.codePointAt(0)]})):e}const f=/(?:\\u([0-9A-Fa-f]{4}))|(?:\\U([0-9A-Fa-f]{8}))/g;function m(e){return f.test(e)?e.replace(f,(function(e,t,r){return t?String.fromCharCode(parseInt(t,16)):r?String.fromCodePoint(parseInt(r,16)):void 0})):e}return Q}
42
42
  /*!
43
43
  * Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
44
- */function Ne(){return Z||(Z=1,function(e){const t=function(){if(W)return Y;W=1;const e=V(),t=Ie(),r=_e(),o=De(),{setImmediate:n}=Ee();function a(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return Y=class{constructor({createMessageDigest:r=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:n=new Map,maxWorkFactor:a=1,maxDeepIterations:i=-1,signal:s=null}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",n),this.createMessageDigest=r||(()=>new t(o)),this.maxWorkFactor=a,this.maxDeepIterations=i,this.remainingDeepIterations=0,this.signal=s,this.quads=null}async main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const r=new Map,n=[...this.blankNodeInfo.keys()];let i=0;for(const e of n)++i%100==0&&await this._yield(),await this._hashAndTrackBlankNode({id:e,hashToBlankNodes:r});const s=[...r.keys()].sort(),c=[];for(const e of s){const t=r.get(e);if(t.length>1){c.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=c.reduce(((e,t)=>e+t.length),0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of c){const r=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const n=await this.hashNDegreeQuads(o,t);r.push(n)}r.sort(a);for(const e of r){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const u=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));u.push(t)}return u.sort(),u.join("")}async hashFirstDegreeQuads(e){const t=[],r=this.blankNodeInfo.get(e),n=r.quads;for(const r of n)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,r.subject,"subject"),r.predicate,this.modifyFirstDegreeComponent(e,r.object,"object"),this.modifyFirstDegreeComponent(e,r.graph,"graph")));t.sort();const a=this.createMessageDigest();for(const e of t)a.update(e);return r.hash=await a.digest(),r.hash}async hashRelatedBlankNode(e,t,r,o){const n=this.createMessageDigest();let a;return n.update(o),"g"!==o&&n.update(this.getRelatedPredicate(t)),a=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):r.hasId(e)?"_:"+r.getId(e):this.blankNodeInfo.get(e).hash,n.update(a),n.digest()}async hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),n=await this.createHashToRelated(e,t),a=[...n.keys()].sort();for(const e of a){o.update(e);let a,i="";const s=new r(n.get(e));let c=0;for(;s.hasNext();){const e=s.next();if(++c%3==0){if(this.signal&&this.signal.aborted)throw new Error(`Abort signal received: "${this.signal.reason}".`);await this._yield()}let r=t.clone(),o="";const n=[];let u=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(r.hasId(t)||n.push(t),o+="_:"+r.getId(t)),0!==i.length&&o>i){u=!0;break}if(!u){for(const e of n){const t=await this.hashNDegreeQuads(e,r);if(o+="_:"+r.getId(e),o+=`<${t.hash}>`,r=t.issuer,0!==i.length&&o>i){u=!0;break}}u||(0===i.length||o<i)&&(i=o,a=r)}}o.update(i),t=a}return{hash:await o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}async createHashToRelated(e,t){const r=new Map,o=this.blankNodeInfo.get(e).quads;let n=0;for(const a of o)++n%100==0&&await this._yield(),await Promise.all([this._addRelatedBlankNodeHash({quad:a,component:a.subject,position:"s",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:a,component:a.object,position:"o",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:a,component:a.graph,position:"g",id:e,issuer:t,hashToRelated:r})]);return r}async _hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const r=await this.hashFirstDegreeQuads(e),o=t.get(r);o?o.push(e):t.set(r,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const r=t.value,o=this.blankNodeInfo.get(r);o?o.quads.add(e):this.blankNodeInfo.set(r,{quads:new Set([e]),hash:null})}async _addRelatedBlankNodeHash({quad:e,component:t,position:r,id:o,issuer:n,hashToRelated:a}){if("BlankNode"!==t.termType||t.value===o)return;const i=t.value,s=await this.hashRelatedBlankNode(i,e,n,r),c=a.get(s);c?c.push(i):a.set(s,[i])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}async _yield(){return new Promise((e=>n(e)))}}}
44
+ */function Ne(){return Z||(Z=1,function(e){const t=function(){if(W)return Y;W=1;const e=V(),t=Ie(),r=_e(),o=De(),{setImmediate:n}=Ee();function i(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return Y=class{constructor({createMessageDigest:r=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:n=new Map,maxWorkFactor:i=1,maxDeepIterations:a=-1,signal:s=null}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",n),this.createMessageDigest=r||(()=>new t(o)),this.maxWorkFactor=i,this.maxDeepIterations=a,this.remainingDeepIterations=0,this.signal=s,this.quads=null}async main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const r=new Map,n=[...this.blankNodeInfo.keys()];let a=0;for(const e of n)++a%100==0&&await this._yield(),await this._hashAndTrackBlankNode({id:e,hashToBlankNodes:r});const s=[...r.keys()].sort(),c=[];for(const e of s){const t=r.get(e);if(t.length>1){c.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=c.reduce(((e,t)=>e+t.length),0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of c){const r=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const n=await this.hashNDegreeQuads(o,t);r.push(n)}r.sort(i);for(const e of r){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const u=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));u.push(t)}return u.sort(),u.join("")}async hashFirstDegreeQuads(e){const t=[],r=this.blankNodeInfo.get(e),n=r.quads;for(const r of n)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,r.subject,"subject"),r.predicate,this.modifyFirstDegreeComponent(e,r.object,"object"),this.modifyFirstDegreeComponent(e,r.graph,"graph")));t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return r.hash=await i.digest(),r.hash}async hashRelatedBlankNode(e,t,r,o){const n=this.createMessageDigest();let i;return n.update(o),"g"!==o&&n.update(this.getRelatedPredicate(t)),i=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):r.hasId(e)?"_:"+r.getId(e):this.blankNodeInfo.get(e).hash,n.update(i),n.digest()}async hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),n=await this.createHashToRelated(e,t),i=[...n.keys()].sort();for(const e of i){o.update(e);let i,a="";const s=new r(n.get(e));let c=0;for(;s.hasNext();){const e=s.next();if(++c%3==0){if(this.signal&&this.signal.aborted)throw new Error(`Abort signal received: "${this.signal.reason}".`);await this._yield()}let r=t.clone(),o="";const n=[];let u=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(r.hasId(t)||n.push(t),o+="_:"+r.getId(t)),0!==a.length&&o>a){u=!0;break}if(!u){for(const e of n){const t=await this.hashNDegreeQuads(e,r);if(o+="_:"+r.getId(e),o+=`<${t.hash}>`,r=t.issuer,0!==a.length&&o>a){u=!0;break}}u||(0===a.length||o<a)&&(a=o,i=r)}}o.update(a),t=i}return{hash:await o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}async createHashToRelated(e,t){const r=new Map,o=this.blankNodeInfo.get(e).quads;let n=0;for(const i of o)++n%100==0&&await this._yield(),await Promise.all([this._addRelatedBlankNodeHash({quad:i,component:i.subject,position:"s",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:i,component:i.object,position:"o",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:i,component:i.graph,position:"g",id:e,issuer:t,hashToRelated:r})]);return r}async _hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const r=await this.hashFirstDegreeQuads(e),o=t.get(r);o?o.push(e):t.set(r,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const r=t.value,o=this.blankNodeInfo.get(r);o?o.quads.add(e):this.blankNodeInfo.set(r,{quads:new Set([e]),hash:null})}async _addRelatedBlankNodeHash({quad:e,component:t,position:r,id:o,issuer:n,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=await this.hashRelatedBlankNode(a,e,n,r),c=i.get(s);c?c.push(a):i.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}async _yield(){return new Promise((e=>n(e)))}}}
45
45
  /*!
46
46
  * Copyright (c) 2016-2023 Digital Bazaar, Inc. All rights reserved.
47
- */(),r=function(){if(J)return G;J=1;const e=V(),t=Ie(),r=_e(),o=De();function n(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return G=class{constructor({createMessageDigest:r=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:n=new Map,maxWorkFactor:a=1,maxDeepIterations:i=-1,timeout:s=0}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",n),this.createMessageDigest=r||(()=>new t(o)),this.maxWorkFactor=a,this.maxDeepIterations=i,this.remainingDeepIterations=0,this.timeout=s,s>0&&(this.startTime=Date.now()),this.quads=null}main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const r=new Map,a=[...this.blankNodeInfo.keys()];for(const e of a)this._hashAndTrackBlankNode({id:e,hashToBlankNodes:r});const i=[...r.keys()].sort(),s=[];for(const e of i){const t=r.get(e);if(t.length>1){s.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=s.reduce(((e,t)=>e+t.length),0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of s){const r=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const n=this.hashNDegreeQuads(o,t);r.push(n)}r.sort(n);for(const e of r){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const c=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));c.push(t)}return c.sort(),c.join("")}hashFirstDegreeQuads(e){const t=[],r=this.blankNodeInfo.get(e),n=r.quads;for(const r of n)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,r.subject,"subject"),r.predicate,this.modifyFirstDegreeComponent(e,r.object,"object"),this.modifyFirstDegreeComponent(e,r.graph,"graph")));t.sort();const a=this.createMessageDigest();for(const e of t)a.update(e);return r.hash=a.digest(),r.hash}hashRelatedBlankNode(e,t,r,o){const n=this.createMessageDigest();let a;return n.update(o),"g"!==o&&n.update(this.getRelatedPredicate(t)),a=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):r.hasId(e)?"_:"+r.getId(e):this.blankNodeInfo.get(e).hash,n.update(a),n.digest()}hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),n=this.createHashToRelated(e,t),a=[...n.keys()].sort();for(const e of a){o.update(e);let a,i="";const s=new r(n.get(e));let c=0;for(;s.hasNext();){const e=s.next();if(++c%3==0&&this.timeout>0&&Date.now()-this.startTime>this.timeout)throw new Error("Canonize timeout.");let r=t.clone(),o="";const n=[];let u=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(r.hasId(t)||n.push(t),o+="_:"+r.getId(t)),0!==i.length&&o>i){u=!0;break}if(!u){for(const e of n){const t=this.hashNDegreeQuads(e,r);if(o+="_:"+r.getId(e),o+=`<${t.hash}>`,r=t.issuer,0!==i.length&&o>i){u=!0;break}}u||(0===i.length||o<i)&&(i=o,a=r)}}o.update(i),t=a}return{hash:o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}createHashToRelated(e,t){const r=new Map,o=this.blankNodeInfo.get(e).quads;for(const n of o)this._addRelatedBlankNodeHash({quad:n,component:n.subject,position:"s",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:n,component:n.object,position:"o",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:n,component:n.graph,position:"g",id:e,issuer:t,hashToRelated:r});return r}_hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const r=this.hashFirstDegreeQuads(e),o=t.get(r);o?o.push(e):t.set(r,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const r=t.value,o=this.blankNodeInfo.get(r);o?o.quads.add(e):this.blankNodeInfo.set(r,{quads:new Set([e]),hash:null})}_addRelatedBlankNodeHash({quad:e,component:t,position:r,id:o,issuer:n,hashToRelated:a}){if("BlankNode"!==t.termType||t.value===o)return;const i=t.value,s=this.hashRelatedBlankNode(i,e,n,r),c=a.get(s);c?c.push(i):a.set(s,[i])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}}}();let o;try{o=a}catch(e){}function n(t,r){if(r.inputFormat){if("application/n-quads"===r.inputFormat){if("string"!=typeof t)throw new Error("N-Quads input must be a string.");return e.NQuads.parse(t)}throw new Error(`Unknown canonicalization input format: "${r.inputFormat}".`)}return t}function i(e){if(e.format&&"application/n-quads"!==e.format)throw new Error(`Unknown canonicalization output format: "${e.format}".`)}function s(){globalThis.RDF_CANONIZE_TRACE_URDNA2015&&console.trace("[rdf-canonize] URDNA2015 is deprecated, use RDFC-1.0")}e.NQuads=De(),e.IdentifierIssuer=V(),e._rdfCanonizeNative=function(e){return e&&(o=e),o},e.canonize=async function(e,r={}){const a=n(e,r);if(i(r),r.useNative){if(!o)throw new Error("rdf-canonize-native not available");if(r.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return new Promise(((e,t)=>o.canonize(a,r,((r,o)=>r?t(r):e(o)))))}if(!("algorithm"in r))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===r.algorithm)return new t(r).main(a);if("URDNA2015"===r.algorithm&&!r.rejectURDNA2015)return s(),new t(r).main(a);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+r.algorithm)},e._canonizeSync=function(e,t={}){const a=n(e,t);if(i(t),t.useNative){if(!o)throw new Error("rdf-canonize-native not available");if(t.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return o.canonizeSync(a,t)}if(!("algorithm"in t))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===t.algorithm)return new r(t).main(a);if("URDNA2015"===t.algorithm&&!t.rejectURDNA2015)return s(),new r(t).main(a);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+t.algorithm)}}(z)),z}function Se(){return te?ee:(te=1,ee=Ne())}function Ce(){if(oe)return re;oe=1;const e={};return re=e,e.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"},e.concat=(e,t)=>{const r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},re}function Re(){if(se)return ie;se=1;const e=k(),t=n(),r=Se(),o=Ce(),{sha256digest:a}=function(){if(ae)return ne;ae=1;const e=self&&(self.crypto||self.msCrypto);return ne={async sha256digest({string:t}){const r=(new TextEncoder).encode(t);return new Uint8Array(await e.subtle.digest("SHA-256",r))}}}
47
+ */(),r=function(){if(J)return G;J=1;const e=V(),t=Ie(),r=_e(),o=De();function n(e,t){return e.hash<t.hash?-1:e.hash>t.hash?1:0}return G=class{constructor({createMessageDigest:r=null,messageDigestAlgorithm:o="sha256",canonicalIdMap:n=new Map,maxWorkFactor:i=1,maxDeepIterations:a=-1,timeout:s=0}={}){this.name="RDFC-1.0",this.blankNodeInfo=new Map,this.canonicalIssuer=new e("c14n",n),this.createMessageDigest=r||(()=>new t(o)),this.maxWorkFactor=i,this.maxDeepIterations=a,this.remainingDeepIterations=0,this.timeout=s,s>0&&(this.startTime=Date.now()),this.quads=null}main(t){this.quads=t;for(const e of t)this._addBlankNodeQuadInfo({quad:e,component:e.subject}),this._addBlankNodeQuadInfo({quad:e,component:e.object}),this._addBlankNodeQuadInfo({quad:e,component:e.graph});const r=new Map,i=[...this.blankNodeInfo.keys()];for(const e of i)this._hashAndTrackBlankNode({id:e,hashToBlankNodes:r});const a=[...r.keys()].sort(),s=[];for(const e of a){const t=r.get(e);if(t.length>1){s.push(t);continue}const o=t[0];this.canonicalIssuer.getId(o)}if(this.maxDeepIterations<0)if(0===this.maxWorkFactor)this.maxDeepIterations=0;else if(this.maxWorkFactor===1/0)this.maxDeepIterations=1/0;else{const e=s.reduce(((e,t)=>e+t.length),0);this.maxDeepIterations=e**this.maxWorkFactor}this.maxDeepIterations>Number.MAX_SAFE_INTEGER&&(this.maxDeepIterations=1/0),this.remainingDeepIterations=this.maxDeepIterations;for(const t of s){const r=[];for(const o of t){if(this.canonicalIssuer.hasId(o))continue;const t=new e("b");t.getId(o);const n=this.hashNDegreeQuads(o,t);r.push(n)}r.sort(n);for(const e of r){const t=e.issuer.getOldIds();for(const e of t)this.canonicalIssuer.getId(e)}}const c=[];for(const e of this.quads){const t=o.serializeQuadComponents(this._componentWithCanonicalId(e.subject),e.predicate,this._componentWithCanonicalId(e.object),this._componentWithCanonicalId(e.graph));c.push(t)}return c.sort(),c.join("")}hashFirstDegreeQuads(e){const t=[],r=this.blankNodeInfo.get(e),n=r.quads;for(const r of n)t.push(o.serializeQuadComponents(this.modifyFirstDegreeComponent(e,r.subject,"subject"),r.predicate,this.modifyFirstDegreeComponent(e,r.object,"object"),this.modifyFirstDegreeComponent(e,r.graph,"graph")));t.sort();const i=this.createMessageDigest();for(const e of t)i.update(e);return r.hash=i.digest(),r.hash}hashRelatedBlankNode(e,t,r,o){const n=this.createMessageDigest();let i;return n.update(o),"g"!==o&&n.update(this.getRelatedPredicate(t)),i=this.canonicalIssuer.hasId(e)?"_:"+this.canonicalIssuer.getId(e):r.hasId(e)?"_:"+r.getId(e):this.blankNodeInfo.get(e).hash,n.update(i),n.digest()}hashNDegreeQuads(e,t){if(0===this.remainingDeepIterations)throw new Error(`Maximum deep iterations exceeded (${this.maxDeepIterations}).`);this.remainingDeepIterations--;const o=this.createMessageDigest(),n=this.createHashToRelated(e,t),i=[...n.keys()].sort();for(const e of i){o.update(e);let i,a="";const s=new r(n.get(e));let c=0;for(;s.hasNext();){const e=s.next();if(++c%3==0&&this.timeout>0&&Date.now()-this.startTime>this.timeout)throw new Error("Canonize timeout.");let r=t.clone(),o="";const n=[];let u=!1;for(const t of e)if(this.canonicalIssuer.hasId(t)?o+="_:"+this.canonicalIssuer.getId(t):(r.hasId(t)||n.push(t),o+="_:"+r.getId(t)),0!==a.length&&o>a){u=!0;break}if(!u){for(const e of n){const t=this.hashNDegreeQuads(e,r);if(o+="_:"+r.getId(e),o+=`<${t.hash}>`,r=t.issuer,0!==a.length&&o>a){u=!0;break}}u||(0===a.length||o<a)&&(a=o,i=r)}}o.update(a),t=i}return{hash:o.digest(),issuer:t}}modifyFirstDegreeComponent(e,t){return"BlankNode"!==t.termType?t:{termType:"BlankNode",value:t.value===e?"a":"z"}}getRelatedPredicate(e){return`<${e.predicate.value}>`}createHashToRelated(e,t){const r=new Map,o=this.blankNodeInfo.get(e).quads;for(const n of o)this._addRelatedBlankNodeHash({quad:n,component:n.subject,position:"s",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:n,component:n.object,position:"o",id:e,issuer:t,hashToRelated:r}),this._addRelatedBlankNodeHash({quad:n,component:n.graph,position:"g",id:e,issuer:t,hashToRelated:r});return r}_hashAndTrackBlankNode({id:e,hashToBlankNodes:t}){const r=this.hashFirstDegreeQuads(e),o=t.get(r);o?o.push(e):t.set(r,[e])}_addBlankNodeQuadInfo({quad:e,component:t}){if("BlankNode"!==t.termType)return;const r=t.value,o=this.blankNodeInfo.get(r);o?o.quads.add(e):this.blankNodeInfo.set(r,{quads:new Set([e]),hash:null})}_addRelatedBlankNodeHash({quad:e,component:t,position:r,id:o,issuer:n,hashToRelated:i}){if("BlankNode"!==t.termType||t.value===o)return;const a=t.value,s=this.hashRelatedBlankNode(a,e,n,r),c=i.get(s);c?c.push(a):i.set(s,[a])}_componentWithCanonicalId(e){return"BlankNode"!==e.termType||e.value.startsWith(this.canonicalIssuer.prefix)?e:{termType:"BlankNode",value:this.canonicalIssuer.getId(e.value)}}}}();let o;try{o=i}catch(e){}function n(t,r){if(r.inputFormat){if("application/n-quads"===r.inputFormat){if("string"!=typeof t)throw new Error("N-Quads input must be a string.");return e.NQuads.parse(t)}throw new Error(`Unknown canonicalization input format: "${r.inputFormat}".`)}return t}function a(e){if(e.format&&"application/n-quads"!==e.format)throw new Error(`Unknown canonicalization output format: "${e.format}".`)}function s(){globalThis.RDF_CANONIZE_TRACE_URDNA2015&&console.trace("[rdf-canonize] URDNA2015 is deprecated, use RDFC-1.0")}e.NQuads=De(),e.IdentifierIssuer=V(),e._rdfCanonizeNative=function(e){return e&&(o=e),o},e.canonize=async function(e,r={}){const i=n(e,r);if(a(r),r.useNative){if(!o)throw new Error("rdf-canonize-native not available");if(r.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return new Promise(((e,t)=>o.canonize(i,r,((r,o)=>r?t(r):e(o)))))}if(!("algorithm"in r))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===r.algorithm)return new t(r).main(i);if("URDNA2015"===r.algorithm&&!r.rejectURDNA2015)return s(),new t(r).main(i);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+r.algorithm)},e._canonizeSync=function(e,t={}){const i=n(e,t);if(a(t),t.useNative){if(!o)throw new Error("rdf-canonize-native not available");if(t.createMessageDigest)throw new Error('"createMessageDigest" cannot be used with "useNative".');return o.canonizeSync(i,t)}if(!("algorithm"in t))throw new Error("No RDF Dataset Canonicalization algorithm specified.");if("RDFC-1.0"===t.algorithm)return new r(t).main(i);if("URDNA2015"===t.algorithm&&!t.rejectURDNA2015)return s(),new r(t).main(i);throw new Error("Invalid RDF Dataset Canonicalization algorithm: "+t.algorithm)}}(z)),z}function Se(){return te?ee:(te=1,ee=Ne())}function Ce(){if(oe)return re;oe=1;const e={};return re=e,e.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"},e.concat=(e,t)=>{const r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r},re}function Re(){if(se)return ae;se=1;const e=k(),t=n(),r=Se(),o=Ce(),{sha256digest:i}=function(){if(ie)return ne;ie=1;const e=self&&(self.crypto||self.msCrypto);return ne={async sha256digest({string:t}){const r=(new TextEncoder).encode(t);return new Uint8Array(await e.subtle.digest("SHA-256",r))}}}
48
48
  /*!
49
49
  * Copyright (c) 2017-2024 Digital Bazaar, Inc. All rights reserved.
50
- */(),i=O();return ie=class extends i{constructor({type:e,proof:t,LDKeyClass:r,date:o,key:n,signer:a,verifier:i,useNativeCanonize:s,canonizeOptions:c,contextUrl:u}={}){super({type:e}),this.LDKeyClass=r,this.contextUrl=u,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:a,verifier:i});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:n,expansionMap:a}){if(a)throw new Error('"expansionMap" not supported.');let i;i=this.proof?{...this.proof}:{},i.type=this.type;let s=this.date;void 0===i.created&&void 0===s&&(s=new Date),s&&"string"!=typeof s&&(s=o.w3cDate(s)),s&&(i.created=s),i.verificationMethod=this.verificationMethod,i=await this.updateProof({document:e,proof:i,proofSet:r,purpose:t,documentLoader:n}),i=await t.update(i,{document:e,suite:this,documentLoader:n});const c=await this.createVerifyData({document:e,proof:i,proofSet:r,documentLoader:n});return i=await this.sign({verifyData:c,document:e,proof:i,documentLoader:n}),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 a=await this.createVerifyData({document:t,proof:e,proofSet:r,documentLoader:o,expansionMap:n}),i=await this.getVerificationMethod({proof:e,document:t,documentLoader:o,expansionMap:n});if(!await this.verifySignature({verifyData:a,verificationMethod:i,document:t,proof:e,documentLoader:o,expansionMap:n}))throw new Error("Invalid signature.");return{verified:!0,verificationMethod:i}}catch(e){return{verified:!1,error:e}}}async canonize(e,{documentLoader:o,expansionMap:n,skipExpansion:a}){if(n)throw new Error('"expansionMap" not supported.');return async function(e,o){const n={...o};delete n.format,n.produceGeneralizedRdf=!1;const a=await t.toRDF(e,n);return r.canonize(a,o)}(e,{algorithm:"RDFC-1.0",base:null,format:"application/n-quads",documentLoader:o,safe:!0,skipExpansion:a,useNative:this.useNativeCanonize,...this.canonizeOptions})}async canonizeProof(t,{document:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');return delete(t={"@context":r["@context"]||e.SECURITY_CONTEXT_URL,...t}).jws,delete t.signatureValue,delete t.proofValue,this.canonize(t,{documentLoader:o,expansionMap:n,skipExpansion:!1,...this.canonizeOptions})}async createVerifyData({document:e,proof:t,documentLoader:r,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');let i;const{_hashCache:s}=this;s&&s.document===e?i=s.hash:this._hashCache={document:e,hash:i=this.canonize(e,{documentLoader:r,expansionMap:n}).then((e=>a({string:e})))};const[c,u]=await Promise.all([this.canonizeProof(t,{document:e,documentLoader:r,expansionMap:n}).then((e=>a({string:e}))),i]);return o.concat(c,u)}async derive(){throw new Error("Must be implemented by a derived class.")}async getVerificationMethod({proof:r,documentLoader:o}){let{verificationMethod:n}=r;if("object"==typeof n&&(n=n.id),!n)throw new Error('No "verificationMethod" found in proof.');const a=await t.frame(n,{"@context":e.SECURITY_CONTEXT_URL,"@embed":"@always",id:n},{documentLoader:o,compactToRelative:!1,safe:!0});if(!a)throw new Error(`Verification method ${n} not found.`);if(void 0!==a.revoked)throw new Error("The verification method has been revoked.");return a}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]}},ie}
50
+ */(),a=O();return ae=class extends a{constructor({type:e,proof:t,LDKeyClass:r,date:o,key:n,signer:i,verifier:a,useNativeCanonize:s,canonizeOptions:c,contextUrl:u}={}){super({type:e}),this.LDKeyClass=r,this.contextUrl=u,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:n,expansionMap:i}){if(i)throw new Error('"expansionMap" not supported.');let a;a=this.proof?{...this.proof}:{},a.type=this.type;let s=this.date;void 0===a.created&&void 0===s&&(s=new Date),s&&"string"!=typeof s&&(s=o.w3cDate(s)),s&&(a.created=s),a.verificationMethod=this.verificationMethod,a=await this.updateProof({document:e,proof:a,proofSet:r,purpose:t,documentLoader:n}),a=await t.update(a,{document:e,suite:this,documentLoader:n});const c=await this.createVerifyData({document:e,proof:a,proofSet:r,documentLoader:n});return a=await this.sign({verifyData:c,document:e,proof:a,documentLoader:n}),a}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:o,expansionMap:n,skipExpansion:i}){if(n)throw new Error('"expansionMap" not supported.');return async function(e,o){const n={rdfDirection:"i18n-datatype",...o,produceGeneralizedRdf:!1};delete n.format;const i=await t.toRDF(e,n);return r.canonize(i,o)}(e,{algorithm:"RDFC-1.0",base:null,format:"application/n-quads",documentLoader:o,safe:!0,skipExpansion:i,useNative:this.useNativeCanonize,...this.canonizeOptions})}async canonizeProof(t,{document:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');return delete(t={"@context":r["@context"]||e.SECURITY_CONTEXT_URL,...t}).jws,delete t.signatureValue,delete t.proofValue,this.canonize(t,{documentLoader:o,expansionMap:n,skipExpansion:!1,...this.canonizeOptions})}async createVerifyData({document:e,proof:t,documentLoader:r,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');let a;const{_hashCache:s}=this;s&&s.document===e?a=s.hash:this._hashCache={document:e,hash:a=this.canonize(e,{documentLoader:r,expansionMap:n}).then((e=>i({string:e})))};const[c,u]=await Promise.all([this.canonizeProof(t,{document:e,documentLoader:r,expansionMap:n}).then((e=>i({string:e}))),a]);return o.concat(c,u)}async derive(){throw new Error("Must be implemented by a derived class.")}async getVerificationMethod({proof:r,documentLoader:o}){let{verificationMethod:n}=r;if("object"==typeof n&&(n=n.id),!n)throw new Error('No "verificationMethod" found in proof.');const i=await t.frame(n,{"@context":e.SECURITY_CONTEXT_URL,"@embed":"@always",id:n},{documentLoader:o,compactToRelative:!1,safe:!0});if(!i)throw new Error(`Verification method ${n} not found.`);if(void 0!==i.revoked)throw new Error("The verification method has been revoked.");return i}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]}},ae}
51
51
  /*!
52
52
  * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
53
53
  */function Me(){return pe?de:(pe=1,de=class{constructor({term:e,date:t,maxTimestampDelta:r=1/0}={}){if(void 0===e)throw new Error('"term" is required.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxTimestampDelta" must be a number.');if(this.term=e,void 0!==t&&(this.date=new Date(t),isNaN(this.date)))throw TypeError(`"date" "${t}" is not a valid date.`);this.maxTimestampDelta=r}async validate(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');try{if(this.maxTimestampDelta!==1/0){const t=(this.date||new Date).getTime(),r=1e3*this.maxTimestampDelta,o=new Date(e.created).getTime();if(!(o>=t-r&&o<=t+r))throw new Error("The proof's created timestamp is out of range.")}return{valid:!0}}catch(e){return{valid:!1,error:e}}}async update(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose=this.term,e}async match(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose===this.term}})}
54
54
  /*!
55
55
  * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
56
- */function ke(){if(le)return he;le=1;const e=k(),t=n(),r=Me(),o="https://www.w3.org/ns/did/v1",a=["assertionMethod","authentication","capabilityInvocation","capabilityDelegation","keyAgreement","verificationMethod"];return he=class extends r{constructor({term:e,controller:t,date:r,maxTimestampDelta:o=1/0}={}){if(super({term:e,date:r,maxTimestampDelta:o}),void 0!==t){if("object"!=typeof t)throw new TypeError('"controller" must be an object.');this.controller=t}this._termDefinedByDIDContext=a.includes(e)}async validate(r,{verificationMethod:n,documentLoader:a,expansionMap:i}){try{const s=await super.validate(r,{verificationMethod:n,documentLoader:a,expansionMap:i});if(!s.valid)throw s.error;const{id:c}=n;if("string"!=typeof c)throw new Error(`Verification method ID "${n.id}" must be a string.`);const{term:u,_termDefinedByDIDContext:d}=this;if(this.controller)s.controller=this.controller;else{const{controller:r}=n;let i;if(r)if("object"==typeof r)i=r.id;else{if("string"!=typeof r)throw new TypeError('"controller" must be a string representing a URL.');i=r}let{document:p}=await a(i);!(d&&p["@context"]===o||Array.isArray(p["@context"])&&p["@context"][0]===o)&&(p=await t.frame(p,{"@context":e.SECURITY_CONTEXT_URL,id:i,[u]:{"@embed":"@never",id:c}},{documentLoader:a,compactToRelative:!1,safe:!0})),s.controller=p}const p=t.getValues(s.controller,u);if(s.valid=p.some((e=>e===c||"object"==typeof e&&e.id===c)),!s.valid)throw new Error(`Verification method "${n.id}" not authorized by controller for proof purpose "${this.term}".`);return s}catch(e){return{valid:!1,error:e}}}},he}
56
+ */function ke(){if(le)return he;le=1;const e=k(),t=n(),r=Me(),o="https://www.w3.org/ns/did/v1",i=["assertionMethod","authentication","capabilityInvocation","capabilityDelegation","keyAgreement","verificationMethod"];return he=class extends r{constructor({term:e,controller:t,date:r,maxTimestampDelta:o=1/0}={}){if(super({term:e,date:r,maxTimestampDelta:o}),void 0!==t){if("object"!=typeof t)throw new TypeError('"controller" must be an object.');this.controller=t}this._termDefinedByDIDContext=i.includes(e)}async validate(r,{verificationMethod:n,documentLoader:i,expansionMap:a}){try{const s=await super.validate(r,{verificationMethod:n,documentLoader:i,expansionMap:a});if(!s.valid)throw s.error;const{id:c}=n;if("string"!=typeof c)throw new Error(`Verification method ID "${n.id}" must be a string.`);const{term:u,_termDefinedByDIDContext:d}=this;if(this.controller)s.controller=this.controller;else{const{controller:r}=n;let a;if(r)if("object"==typeof r)a=r.id;else{if("string"!=typeof r)throw new TypeError('"controller" must be a string representing a URL.');a=r}let{document:p}=await i(a);!(d&&p["@context"]===o||Array.isArray(p["@context"])&&p["@context"][0]===o)&&(p=await t.frame(p,{"@context":e.SECURITY_CONTEXT_URL,id:a,[u]:{"@embed":"@never",id:c}},{documentLoader:i,compactToRelative:!1,safe:!0})),s.controller=p}const p=t.getValues(s.controller,u);if(s.valid=p.some((e=>e===c||"object"==typeof e&&e.id===c)),!s.valid)throw new Error(`Verification method "${n.id}" not authorized by controller for proof purpose "${this.term}".`);return s}catch(e){return{valid:!1,error:e}}}},he}
57
57
  /*!
58
58
  * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
59
59
  */function Ae(){if(me)return fe;me=1;const e=ke();return fe=class extends e{constructor({term:e="assertionMethod",controller:t,date:r,maxTimestampDelta:o=1/0}={}){super({term:e,controller:t,date:r,maxTimestampDelta:o})}}}
60
60
  /*!
61
61
  * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
62
- */function Le(){if(ye)return ge;ye=1;const e=ke();return ge=class extends e{constructor({term:e="authentication",controller:t,challenge:r,date:o,domain:n,maxTimestampDelta:a=1/0}={}){if(super({term:e,controller:t,date:o,maxTimestampDelta:a}),"string"!=typeof r)throw new TypeError('"challenge" must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('"domain" must be a string.');this.challenge=r,this.domain=n}async validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o}){try{if(e.challenge!==this.challenge)throw new Error(`The challenge is not as expected; challenge="${e.challenge}", expected="${this.challenge}"`);if(void 0!==this.domain&&e.domain!==this.domain)throw new Error(`The domain is not as expected; domain="${e.domain}", expected="${this.domain}"`);return super.validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o})}catch(e){return{valid:!1,error:e}}}async update(e,{document:t,suite:r,documentLoader:o,expansionMap:n}){return(e=await super.update(e,{document:t,suite:r,documentLoader:o,expansionMap:n})).challenge=this.challenge,void 0!==this.domain&&(e.domain=this.domain),e}},ge}
62
+ */function Le(){if(ye)return ge;ye=1;const e=ke();return ge=class extends e{constructor({term:e="authentication",controller:t,challenge:r,date:o,domain:n,maxTimestampDelta:i=1/0}={}){if(super({term:e,controller:t,date:o,maxTimestampDelta:i}),"string"!=typeof r)throw new TypeError('"challenge" must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('"domain" must be a string.');this.challenge=r,this.domain=n}async validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o}){try{if(e.challenge!==this.challenge)throw new Error(`The challenge is not as expected; challenge="${e.challenge}", expected="${this.challenge}"`);if(void 0!==this.domain){const{domain:t}=e;if(!(t===this.domain||Array.isArray(t)&&t.includes(this.domain)))throw new Error(`The domain is not as expected; domain=${JSON.stringify(t)}, expected=${JSON.stringify(this.domain)}`)}return super.validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o})}catch(e){return{valid:!1,error:e}}}async update(e,{document:t,suite:r,documentLoader:o,expansionMap:n}){return(e=await super.update(e,{document:t,suite:r,documentLoader:o,expansionMap:n})).challenge=this.challenge,void 0!==this.domain&&(e.domain=this.domain),e}},ge}
63
63
  /*!
64
64
  * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
65
65
  */var Ue=function(){if(be)return Te;be=1;const e={};Te=e;const t=k();Object.assign(e,t);const r=j(),o=function(){if(T)return v;T=1;class e extends Error{constructor(e){super("Verification error(s)."),this.name="VerificationError",this.errors=[].concat(e)}}return v=e}
66
66
  /*!
67
67
  * Copyright (c) 2018-2023 Digital Bazaar, Inc. All rights reserved.
68
- */();return e.derive=async function(e,{suite:t,purpose:o,documentLoader:n,addSuiteContext:a=!0}={}){if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:a});try{return await(new r).derive(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"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}},e.sign=async function(e,{suite:t,purpose:o,documentLoader:n,expansionMap:a,addSuiteContext:i=!0}={}){if(a)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 r).add(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"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}},e.verify=async function(e,{suite:t,purpose:n,documentLoader:a,expansionMap:i}={}){if(i)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');const s=await(new r).verify(e,{suite:t,purpose:n,documentLoader:a}),{error:c}=s;if(c)if(a||"jsonld.InvalidUrl"!==c.name)s.error=new o(c);else{const{details:{url:e}}=c,t=new Error(`A URL "${e}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".`);s.error=new o(t)}return s},e.suites=function(){if(ue)return ce;ue=1;const e={};return ce=e,e.suites={LinkedDataProof:O(),LinkedDataSignature:Re()},ce}
68
+ */();return e.derive=async function(e,{suite:t,purpose:o,documentLoader:n,addSuiteContext:i=!0}={}){if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:i});try{return await(new r).derive(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"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}},e.sign=async function(e,{suite:t,purpose:o,documentLoader:n,expansionMap:i,addSuiteContext:a=!0}={}){if(i)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:a});try{return await(new r).add(e,{suite:t,purpose:o,documentLoader:n})}catch(e){if(!n&&"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}},e.verify=async function(e,{suite:t,purpose:n,documentLoader:i,expansionMap:a}={}){if(a)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');const s=await(new r).verify(e,{suite:t,purpose:n,documentLoader:i}),{error:c}=s;if(c)if(i||"jsonld.InvalidUrl"!==c.name)s.error=new o(c);else{const{details:{url:e}}=c,t=new Error(`A URL "${e}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".`);s.error=new o(t)}return s},e.suites=function(){if(ue)return ce;ue=1;const e={};return ce=e,e.suites={LinkedDataProof:O(),LinkedDataSignature:Re()},ce}
69
69
  /*!
70
70
  * Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
71
71
  */().suites,e.purposes=function(){if(ve)return we;ve=1;const e={};return we=e,e.purposes={AssertionProofPurpose:Ae(),AuthenticationProofPurpose:Le(),ControllerProofPurpose:ke(),ProofPurpose:Me()},we}
@@ -75,4 +75,4 @@ e.exports={SECURITY_CONTEXT_V1_URL:"https://w3id.org/security/v1",SECURITY_CONTE
75
75
  /*!
76
76
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
77
77
  */
78
- const Pe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ke(e,t){return function(e,t){if(!(e instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(0===e.length)return"";let r="",o=0;const n=t.length,a=t.charAt(0),i=[0];for(o=0;o<e.length;++o){let t=e[o];for(let e=0;e<i.length;++e)t+=i[e]<<8,i[e]=t%n,t=t/n|0;for(;t>0;)i.push(t%n),t=t/n|0}for(o=0;0===e[o]&&o<e.length-1;++o)r+=a;for(o=i.length-1;o>=0;--o)r+=t[i[o]];return r}(e,Pe)}function ze(e){return function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if(0===e.length)return new Uint8Array;let r=Oe[t];if(!r){r=Oe[t]=[];for(let e=0;e<t.length;++e)r[t.charCodeAt(e)]=e}e=e.replace(/\s/g,"");const o=t.length,n=t.charAt(0),a=[0];for(let t=0;t<e.length;t++){const n=r[e.charCodeAt(t)];if(void 0===n)return;let i=n;for(let e=0;e<a.length;++e)i+=a[e]*o,a[e]=255&i,i>>=8;for(;i>0;)a.push(255&i),i>>=8}for(let t=0;e[t]===n&&t<e.length-1;++t)a.push(0);return new Uint8Array(a.reverse())}(e,Pe)}export{ze as d,Ke as e,je as j};
78
+ const Pe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ke(e,t){return function(e,t){if(!(e instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(0===e.length)return"";let r="",o=0;const n=t.length,i=t.charAt(0),a=[0];for(o=0;o<e.length;++o){let t=e[o];for(let e=0;e<a.length;++e)t+=a[e]<<8,a[e]=t%n,t=t/n|0;for(;t>0;)a.push(t%n),t=t/n|0}for(o=0;0===e[o]&&o<e.length-1;++o)r+=i;for(o=a.length-1;o>=0;--o)r+=t[a[o]];return r}(e,Pe)}function ze(e){return function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if(0===e.length)return new Uint8Array;let r=Oe[t];if(!r){r=Oe[t]=[];for(let e=0;e<t.length;++e)r[t.charCodeAt(e)]=e}e=e.replace(/\s/g,"");const o=t.length,n=t.charAt(0),i=[0];for(let t=0;t<e.length;t++){const n=r[e.charCodeAt(t)];if(void 0===n)return;let a=n;for(let e=0;e<i.length;++e)a+=i[e]*o,i[e]=255&a,a>>=8;for(;a>0;)i.push(255&a),a>>=8}for(let t=0;e[t]===n&&t<e.length-1;++t)i.push(0);return new Uint8Array(i.reverse())}(e,Pe)}export{ze as d,Ke as e,je as j};
@@ -1,22 +1,22 @@
1
- import{d as e,e as t}from"./index-Bxtpkwnp-BkEvuYc3.js";import{d as r}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{g as i}from"./main.js";import{r as n}from"./elliptic-D7vAoLbk-DQmYEk-8.js";
1
+ import{d as e,e as t}from"./index-BM3knvQR-D4vxi3Vi.js";import{d as r}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{g as i}from"./main.js";import{r as n}from"./elliptic-D-ZnlFdt-DQmYEk-8.js";
2
2
  /*!
3
3
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
4
4
  */
5
- const c="ECDSA",u=!0,y="https://w3id.org/security/suites/ecdsa-2019/v1",o="https://w3id.org/security/multikey/v1",s="z",a=new Uint8Array([231,1]),l=new Uint8Array([128,36]),p=new Uint8Array([129,36]),w=new Uint8Array([130,36]),b=new Uint8Array([134,33]),f=new Uint8Array([134,38]),k=new Uint8Array([135,38]),K=new Uint8Array([136,38]),m="P-256",d="P-384",h="P-521",g="K-256",v="SHA-256",A="SHA-384",U="SHA-512",M=globalThis.crypto,C=globalThis.CryptoKey??M.CryptoKey;function E({curve:e}){if(e===m||e===g)return v;if(e===d)return A;if(e===h)return U;throw new TypeError(`Unsupported curve "${e}".`)}
5
+ const c="ECDSA",u=!0,y="https://w3id.org/security/suites/ecdsa-2019/v1",o="https://w3id.org/security/multikey/v1",s="z",a=new Uint8Array([231,1]),l=new Uint8Array([128,36]),p=new Uint8Array([129,36]),w=new Uint8Array([130,36]),b=new Uint8Array([134,33]),f=new Uint8Array([134,38]),k=new Uint8Array([135,38]),K=new Uint8Array([136,38]),m="P-256",d="P-384",h="P-521",g="K-256",v="SHA-256",A="SHA-384",M="SHA-512",E=globalThis.crypto,U=globalThis.CryptoKey??E.CryptoKey;function C({curve:e}){if(e===m||e===g)return v;if(e===d)return A;if(e===h)return M;throw new TypeError(`Unsupported curve "${e}".`)}
6
6
  /*!
7
7
  * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
8
- */function j({publicMultikey:e}){if(e[0]===l[0]&&e[1]===l[1])return m;if(e[0]===p[0]&&e[1]===p[1])return d;if(e[0]===w[0]&&e[1]===w[1])return h;if(e[0]===a[0]&&e[1]===a[1])return g;throw new TypeError("Unsupported public multikey header.")}function x({secretMultikey:e}){if(e[0]===f[0]&&e[1]===f[1])return m;if(e[0]===k[0]&&e[1]===k[1])return d;if(e[0]===K[0]&&e[1]===K[1])return h;if(e[0]===b[0]&&e[1]===b[1])return g;throw new TypeError("Unsupported secret multikey header.")}function T({curve:e}){if(e===m||e===g)return 32;if(e===d)return 48;if(e===h)return 66;throw new TypeError(`Unsupported curve "${e}".`)}var P=n(),D=i(P);
8
+ */function x({publicMultikey:e}){if(e[0]===l[0]&&e[1]===l[1])return m;if(e[0]===p[0]&&e[1]===p[1])return d;if(e[0]===w[0]&&e[1]===w[1])return h;if(e[0]===a[0]&&e[1]===a[1])return g;throw new TypeError("Unsupported public multikey header.")}function j({secretMultikey:e}){if(e[0]===f[0]&&e[1]===f[1])return m;if(e[0]===k[0]&&e[1]===k[1])return d;if(e[0]===K[0]&&e[1]===K[1])return h;if(e[0]===b[0]&&e[1]===b[1])return g;throw new TypeError("Unsupported secret multikey header.")}function B({curve:e}){if(e===m||e===g)return 32;if(e===d)return 48;if(e===h)return 66;throw new TypeError(`Unsupported curve "${e}".`)}var T=n(),P=i(T);
9
9
  /*!
10
10
  * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
11
11
  */
12
- const S=new Map([[m,{secret:new Uint8Array([48,103,2,1,0,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,4,77,48,75,2,1,1,4,32]),public:new Uint8Array([161,36,3,34,0])}],[d,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,4,109,48,107,2,1,1,4,48]),public:new Uint8Array([161,52,3,50,0])}],[h,{secret:new Uint8Array([48,129,170,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,4,129,146,48,129,143,2,1,1,4,66]),public:new Uint8Array([161,70,3,68,0])}],[g,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,4,109,48,107,2,1,1,4,32]),public:new Uint8Array([161,68,3,66,0])}]]),$=new Map([[m,new Uint8Array([48,57,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,34,0])],[d,new Uint8Array([48,70,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,50,0])],[h,new Uint8Array([48,88,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,3,68,0])],[g,new Uint8Array([48,86,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,3,66,0])]]);function L(e){const t=new D.ec("secp256k1");return Uint8Array.from(t.keyFromPublic(e).getPublic(!1,"array"))}async function H({id:t,controller:r,secretKeyMultibase:i,publicKeyMultibase:n,keyAgreement:y=!1}){if(!n)throw new TypeError('The "publicKeyMultibase" property is required.');const o={id:t,controller:r};if(!n||"string"!=typeof n||n[0]!==s)throw new TypeError('"publicKeyMultibase" must be a multibase, base58-encoded string.');const a=e(n.slice(1)),l={name:y?"ECDH":c,namedCurve:j({publicMultikey:a})},p=function({publicMultikey:e}){const t=j({publicMultikey:e});let r=e.subarray(2);t===g&&(r=L(r));return function({curve:e,publicKey:t}){const r=$.get(e),i=new Uint8Array(r.length+t.length);let n=0;return i.set(r,n),n+=r.length,i.set(t,n),i}
12
+ const H=new Map([[m,{secret:new Uint8Array([48,103,2,1,0,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,4,77,48,75,2,1,1,4,32]),public:new Uint8Array([161,36,3,34,0])}],[d,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,4,109,48,107,2,1,1,4,48]),public:new Uint8Array([161,52,3,50,0])}],[h,{secret:new Uint8Array([48,129,170,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,4,129,146,48,129,143,2,1,1,4,66]),public:new Uint8Array([161,70,3,68,0])}],[g,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,4,109,48,107,2,1,1,4,32]),public:new Uint8Array([161,68,3,66,0])}]]),S=new Map([[m,new Uint8Array([48,57,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,34,0])],[d,new Uint8Array([48,70,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,50,0])],[h,new Uint8Array([48,88,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,3,68,0])],[g,new Uint8Array([48,86,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,3,66,0])]]);function $(e){const t=new P.ec("secp256k1");return Uint8Array.from(t.keyFromPublic(e).getPublic(!1,"array"))}async function F({id:t,controller:r,secretKeyMultibase:i,publicKeyMultibase:n,keyAgreement:y=!1}){if(!n)throw new TypeError('The "publicKeyMultibase" property is required.');const o={id:t,controller:r};if(!n||"string"!=typeof n||n[0]!==s)throw new TypeError('"publicKeyMultibase" must be a multibase, base58-encoded string.');const a=e(n.slice(1)),l={name:y?"ECDH":c,namedCurve:x({publicMultikey:a})},p=function({publicMultikey:e}){const t=x({publicMultikey:e});let r=e.subarray(2);t===g&&(r=$(r));return function({curve:e,publicKey:t}){const r=S.get(e),i=new Uint8Array(r.length+t.length);let n=0;return i.set(r,n),n+=r.length,i.set(t,n),i}
13
13
  /*!
14
14
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
15
- */({curve:t,publicKey:r})}({publicMultikey:a}),w=y?[]:["verify"];if(l.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-CjDwtULr-D7dA51Yn.js"),t=new e;o.publicKey=await t.subtle.importKey("spki",p,l,u,w)}else o.publicKey=await M.subtle.importKey("spki",p,l,u,w);if(i){if("string"!=typeof i||i[0]!==s)throw new TypeError('"secretKeyMultibase" must be a multibase, base58-encoded string.');const t=e(i.slice(1));!function({secretMultikey:e,publicMultikey:t}){const r=j({publicMultikey:t}),i=x({secretMultikey:e});if(r!==i)throw new Error(`Public key curve ('${r}') does not match secret key curve ('${i}').`)}({secretMultikey:t,publicMultikey:a});const r=function({secretMultikey:e,publicMultikey:t}){const r=x({secretMultikey:e}),i=e.subarray(2),n=t.subarray(2);return function({curve:e,secretKey:t,publicKey:r}){const i=S.get(e);if(!i)throw new Error(`Unsupported curve "${e}".`);e===g&&(r=L(r));const n=new Uint8Array(i.secret.length+t.length+i.public.length+r.length);let c=0;return n.set(i.secret,c),c+=i.secret.length,n.set(t,c),c+=t.length,n.set(i.public,c),c+=i.public.length,n.set(r,c),n}({curve:r,secretKey:i,publicKey:n})}({secretMultikey:t,publicMultikey:a}),n=y?["deriveBits"]:["sign"];if(l.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-CjDwtULr-D7dA51Yn.js"),t=new e;o.secretKey=await t.subtle.importKey("pkcs8",r,l,u,n)}else o.secretKey=await M.subtle.importKey("pkcs8",r,l,u,n)}return o}function q({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:i}=e,n=T({curve:i}),c=r(e.x),u=r(e.y),y=new Uint8Array(2+(n+1));!function({curve:e,buffer:t}){if(e===m)t[0]=l[0],t[1]=l[1];else if(e===d)t[0]=p[0],t[1]=p[1];else if(e===h)t[0]=w[0],t[1]=w[1];else{if(e!==g)throw new TypeError(`Unsupported curve "${e}".`);t[0]=a[0],t[1]=a[1]}}({curve:i,buffer:y});const o=u[u.length-1]%2==0;y[2]=o?2:3,y.set(c,y.length-c.length);return s+t(y)}function B({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:i}=e,n=T({curve:i}),c=r(e.d),u=new Uint8Array(2+n);!function({curve:e,buffer:t}){if(e===m)t[0]=f[0],t[1]=f[1];else if(e===d)t[0]=k[0],t[1]=k[1];else if(e===h)t[0]=K[0],t[1]=K[1];else{if(e!==g)throw new TypeError(`Unsupported curve "${e}".`);t[0]=b[0],t[1]=b[1]}}({curve:e.crv,buffer:u}),u.set(c,u.length-c.length);return s+t(u)}const V=new Set(["EcdsaSecp256r1VerificationKey2019","EcdsaSecp384r1VerificationKey2019","EcdsaSecp521r1VerificationKey2019","EcdsaSecp256k1VerificationKey2019"]);async function J({keyPair:e}){if(!V.has(e.type))throw new TypeError(`Unsupported key type "${e.type}".`);if(e["@context"]||(e["@context"]=y),!function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}
15
+ */({curve:t,publicKey:r})}({publicMultikey:a}),w=y?[]:["verify"];if(l.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-BxABHF-B-TCzLuarM.js"),t=new e;o.publicKey=await t.subtle.importKey("spki",p,l,u,w)}else o.publicKey=await E.subtle.importKey("spki",p,l,u,w);if(i){if("string"!=typeof i||i[0]!==s)throw new TypeError('"secretKeyMultibase" must be a multibase, base58-encoded string.');const t=e(i.slice(1));!function({secretMultikey:e,publicMultikey:t}){const r=x({publicMultikey:t}),i=j({secretMultikey:e});if(r!==i)throw new Error(`Public key curve ('${r}') does not match secret key curve ('${i}').`)}({secretMultikey:t,publicMultikey:a});const r=function({secretMultikey:e,publicMultikey:t}){const r=j({secretMultikey:e}),i=e.subarray(2),n=t.subarray(2);return function({curve:e,secretKey:t,publicKey:r}){const i=H.get(e);if(!i)throw new Error(`Unsupported curve "${e}".`);e===g&&(r=$(r));const n=new Uint8Array(i.secret.length+t.length+i.public.length+r.length);let c=0;return n.set(i.secret,c),c+=i.secret.length,n.set(t,c),c+=t.length,n.set(i.public,c),c+=i.public.length,n.set(r,c),n}({curve:r,secretKey:i,publicKey:n})}({secretMultikey:t,publicMultikey:a}),n=y?["deriveBits"]:["sign"];if(l.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-BxABHF-B-TCzLuarM.js"),t=new e;o.secretKey=await t.subtle.importKey("pkcs8",r,l,u,n)}else o.secretKey=await E.subtle.importKey("pkcs8",r,l,u,n)}return o}function q({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:i}=e,n=B({curve:i}),c=r(e.x),u=r(e.y),y=new Uint8Array(2+(n+1));!function({curve:e,buffer:t}){if(e===m)t[0]=l[0],t[1]=l[1];else if(e===d)t[0]=p[0],t[1]=p[1];else if(e===h)t[0]=w[0],t[1]=w[1];else{if(e!==g)throw new TypeError(`Unsupported curve "${e}".`);t[0]=a[0],t[1]=a[1]}}({curve:i,buffer:y});const o=u[u.length-1]%2==0;y[2]=o?2:3,y.set(c,y.length-c.length);return s+t(y)}function D({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:i}=e,n=B({curve:i}),c=r(e.d),u=new Uint8Array(2+n);!function({curve:e,buffer:t}){if(e===m)t[0]=f[0],t[1]=f[1];else if(e===d)t[0]=k[0],t[1]=k[1];else if(e===h)t[0]=K[0],t[1]=K[1];else{if(e!==g)throw new TypeError(`Unsupported curve "${e}".`);t[0]=b[0],t[1]=b[1]}}({curve:e.crv,buffer:u}),u.set(c,u.length-c.length);return s+t(u)}const V=new Set(["EcdsaSecp256r1VerificationKey2019","EcdsaSecp384r1VerificationKey2019","EcdsaSecp521r1VerificationKey2019","EcdsaSecp256k1VerificationKey2019"]);async function J({keyPair:e}){if(!V.has(e.type))throw new TypeError(`Unsupported key type "${e.type}".`);if(e["@context"]||(e["@context"]=y),!function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}
16
16
  /*!
17
17
  * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
18
- */({document:e,contextUrl:y}))throw new TypeError(`Context not supported "${e["@context"]}".`);return{"@context":o,id:e.id,type:"Multikey",controller:e.controller,publicKeyMultibase:e.publicKeyMultibase,secretKeyMultibase:e.secretKeyMultibase}}async function N(e,t={}){"boolean"==typeof t&&(t={keyAgreement:t});const{keyAgreement:r}=t;let i={...e};if("Multikey"!==i.type){if(i.publicKeyJwk)return async function({jwk:e,secretKey:t=!1}={}){const r={"@context":o,type:"Multikey",publicKeyMultibase:q({jwk:e})};t&&e.d&&(r.secretKeyMultibase=B({jwk:e}));const i=!e.key_ops||e.key_ops.includes("deriveBits");return N(r,i)}({jwk:i.publicKeyJwk,secretKey:!1});if(i.type)return i=await J({keyPair:i}),z({keyPair:i,keyAgreement:r})}return i.type||(i.type="Multikey"),i["@context"]||(i["@context"]=o),i.controller&&!i.id&&(i.id=`${e.controller}#${e.publicKeyMultibase}`),function(e){if(!e||"object"!=typeof e)throw new TypeError('"key" must be an object.');if("Multikey"!==e.type)throw new TypeError('"key" must be a Multikey with type "Multikey".');if(!(e["@context"]===o||Array.isArray(e["@context"])&&e["@context"].includes(o)))throw new TypeError(`"key" must be a Multikey with context "${o}".`)}(i),z({keyPair:i,keyAgreement:r})}async function _({keyPair:e,secretKey:t=!1}={}){e?.publicKey instanceof C||(e=await H(e));const r=t&&!!e.secretKey?e.secretKey:e.publicKey;let i;if(e.publicKey.algorithm.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-CjDwtULr-D7dA51Yn.js"),t=new e;i=await t.subtle.exportKey("jwk",r)}else i=await M.subtle.exportKey("jwk",r);return i}async function z({keyPair:e,keyAgreement:t=!1}){e?.publicKey instanceof C||e.publicKey?.algorithm.namedCurve===g||(e=await H(e));const i=async({publicKey:t=!0,secretKey:i=!1,includeContext:n=!0,raw:c=!1}={})=>{if(c){const n=await _({keyPair:e,secretKey:i}),c={};return t&&(c.publicKey=function({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:t}=e,i=T({curve:t}),n=r(e.x),c=r(e.y),u=new Uint8Array(i+1),y=c[c.length-1]%2==0;return u[0]=y?2:3,u.set(n,u.length-n.length),u}({jwk:n})),i&&(c.secretKey=function({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:t}=e,i=T({curve:t}),n=r(e.d),c=new Uint8Array(i);return c.set(n,c.length-n.length),c}({jwk:n})),c}return async function({keyPair:e,secretKey:t,publicKey:r,includeContext:i}={}){if(!r&&!t)throw new TypeError('Export requires specifying either "publicKey" or "secretKey".');const n=t&&!!e.secretKey,c=n?e.secretKey:e.publicKey;let u;if(c.algorithm.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-CjDwtULr-D7dA51Yn.js"),t=new e;u=await t.subtle.exportKey("jwk",c)}else u=await M.subtle.exportKey("jwk",c);const y={};return i&&(y["@context"]=o),y.id=e.id,y.type="Multikey",y.controller=e.controller,r&&(y.publicKeyMultibase=q({jwk:u})),n&&(y.secretKeyMultibase=B({jwk:u})),y}({keyPair:e,publicKey:t,secretKey:i,includeContext:n})},{publicKeyMultibase:n,secretKeyMultibase:u}=await i({publicKey:!0,secretKey:!0,includeContext:!0});return e={...e,publicKeyMultibase:n,secretKeyMultibase:u,keyAgreement:t,export:i,signer(){const{id:t,secretKey:r}=e;
18
+ */({document:e,contextUrl:y}))throw new TypeError(`Context not supported "${e["@context"]}".`);return{"@context":o,id:e.id,type:"Multikey",controller:e.controller,publicKeyMultibase:e.publicKeyMultibase,secretKeyMultibase:e.secretKeyMultibase}}async function L(e,t={}){"boolean"==typeof t&&(t={keyAgreement:t});const{keyAgreement:r}=t;let i={...e};if("Multikey"!==i.type){if(i.publicKeyJwk)return async function({jwk:e,secretKey:t=!1}={}){const r={"@context":o,type:"Multikey",publicKeyMultibase:q({jwk:e})};t&&e.d&&(r.secretKeyMultibase=D({jwk:e}));const i=!e.key_ops||e.key_ops.includes("deriveBits");return L(r,i)}({jwk:i.publicKeyJwk,secretKey:!1});if(i.type)return i=await J({keyPair:i}),_({keyPair:i,keyAgreement:r})}return i.type||(i.type="Multikey"),i["@context"]||(i["@context"]=o),i.controller&&!i.id&&(i.id=`${e.controller}#${e.publicKeyMultibase}`),function(e){if(!e||"object"!=typeof e)throw new TypeError('"key" must be an object.');if("Multikey"!==e.type)throw new TypeError('"key" must be a Multikey with type "Multikey".');if(!(e["@context"]===o||Array.isArray(e["@context"])&&e["@context"].includes(o)))throw new TypeError(`"key" must be a Multikey with context "${o}".`)}(i),_({keyPair:i,keyAgreement:r})}async function N({keyPair:e,secretKey:t=!1}={}){e?.publicKey instanceof U||(e=await F(e));const r=t&&!!e.secretKey?e.secretKey:e.publicKey;let i;if(e.publicKey.algorithm.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-BxABHF-B-TCzLuarM.js"),t=new e;i=await t.subtle.exportKey("jwk",r)}else i=await E.subtle.exportKey("jwk",r);return i}async function _({keyPair:e,keyAgreement:t=!1}){e?.publicKey instanceof U||e.publicKey?.algorithm.namedCurve===g||(e=await F(e));const i=async({publicKey:t=!0,secretKey:i=!1,includeContext:n=!0,raw:c=!1}={})=>{if(c){const n=await N({keyPair:e,secretKey:i}),c={};return t&&(c.publicKey=function({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:t}=e,i=B({curve:t}),n=r(e.x),c=r(e.y),u=new Uint8Array(i+1),y=c[c.length-1]%2==0;return u[0]=y?2:3,u.set(n,u.length-n.length),u}({jwk:n})),i&&(c.secretKey=function({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:t}=e,i=B({curve:t}),n=r(e.d),c=new Uint8Array(i);return c.set(n,c.length-n.length),c}({jwk:n})),c}return async function({keyPair:e,secretKey:t,publicKey:r,includeContext:i}={}){if(!r&&!t)throw new TypeError('Export requires specifying either "publicKey" or "secretKey".');const n=t&&!!e.secretKey,c=n?e.secretKey:e.publicKey;let u;if(c.algorithm.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-BxABHF-B-TCzLuarM.js"),t=new e;u=await t.subtle.exportKey("jwk",c)}else u=await E.subtle.exportKey("jwk",c);const y={};return i&&(y["@context"]=o),y.id=e.id,y.type="Multikey",y.controller=e.controller,r&&(y.publicKeyMultibase=q({jwk:u})),n&&(y.secretKeyMultibase=D({jwk:u})),y}({keyPair:e,publicKey:t,secretKey:i,includeContext:n})},{publicKeyMultibase:n,secretKeyMultibase:u}=await i({publicKey:!0,secretKey:!0,includeContext:!0});return e={...e,publicKeyMultibase:n,secretKeyMultibase:u,keyAgreement:t,export:i,signer(){const{id:t,secretKey:r}=e;
19
19
  /*!
20
20
  * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
21
21
  */
22
- return function({id:e,secretKey:t}){if(!t)throw new Error('"secretKey" is required for signing.');const{namedCurve:r}=t.algorithm,i={name:c,hash:{name:E({curve:r})}};return{algorithm:r,id:e,async sign({data:e}={}){if(r===g){const{Crypto:r}=await import("./webcrypto.es-CjDwtULr-D7dA51Yn.js"),n=new r;return new Uint8Array(await n.subtle.sign(i,t,e))}return new Uint8Array(await M.subtle.sign(i,t,e))}}}({id:t,secretKey:r})},verifier(){const{id:t,publicKey:r}=e;return function({id:e,publicKey:t}){if(!t)throw new Error('"publicKey" is required for verifying.');const{namedCurve:r}=t.algorithm,i={name:c,hash:{name:E({curve:r})}};return{algorithm:r,id:e,async verify({data:e,signature:n}={}){if(r===g){const{Crypto:r}=await import("./webcrypto.es-CjDwtULr-D7dA51Yn.js");return(new r).subtle.verify(i,t,n,e)}return M.subtle.verify(i,t,n,e)}}}({id:t,publicKey:r})},async deriveSecret({publicKey:t,remotePublicKey:r}={}){if(r&&t)throw new Error('Only one of "remotePublicKey" and "publicKey" must be given.');if(!e.keyAgreement){const e=Error('"keyAgreement" is not supported by this keypair.');throw e.name="NotSupportedError",e}return async function({localKeyPair:e,remoteKeyPair:t}){if(!e.secretKey){const e=Error('"secretKey" required to derive secret.');throw e.name="NotSupportedError",e}e=await H({...e,keyAgreement:!0}),t=await H({...t,keyAgreement:!0});const{namedCurve:r}=e.secretKey.algorithm,i=T({curve:r});if(r===g){const{Crypto:n}=await import("./webcrypto.es-CjDwtULr-D7dA51Yn.js"),c=new n,u=await c.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*i);return new Uint8Array(u,0,i)}const n=await M.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*i);return new Uint8Array(n,0,i)}({localKeyPair:this,remoteKeyPair:r||t})}}}export{P as e,N as f,_ as t};
22
+ return function({id:e,secretKey:t}){if(!t)throw new Error('"secretKey" is required for signing.');const{namedCurve:r}=t.algorithm,i={name:c,hash:{name:C({curve:r})}};return{algorithm:r,id:e,async sign({data:e}={}){if(r===g){const{Crypto:r}=await import("./webcrypto.es-BxABHF-B-TCzLuarM.js"),n=new r;return new Uint8Array(await n.subtle.sign(i,t,e))}return new Uint8Array(await E.subtle.sign(i,t,e))}}}({id:t,secretKey:r})},verifier(){const{id:t,publicKey:r}=e;return function({id:e,publicKey:t}){if(!t)throw new Error('"publicKey" is required for verifying.');const{namedCurve:r}=t.algorithm,i={name:c,hash:{name:C({curve:r})}};return{algorithm:r,id:e,async verify({data:e,signature:n}={}){if(r===g){const{Crypto:r}=await import("./webcrypto.es-BxABHF-B-TCzLuarM.js");return(new r).subtle.verify(i,t,n,e)}return E.subtle.verify(i,t,n,e)}}}({id:t,publicKey:r})},async deriveSecret({publicKey:t,remotePublicKey:r}={}){if(r&&t)throw new Error('Only one of "remotePublicKey" and "publicKey" must be given.');if(!e.keyAgreement){const e=Error('"keyAgreement" is not supported by this keypair.');throw e.name="NotSupportedError",e}return async function({localKeyPair:e,remoteKeyPair:t}){if(!e.secretKey){const e=Error('"secretKey" required to derive secret.');throw e.name="NotSupportedError",e}e=await F({...e,keyAgreement:!0}),t=await F({...t,keyAgreement:!0});const{namedCurve:r}=e.secretKey.algorithm,i=B({curve:r});if(r===g){const{Crypto:n}=await import("./webcrypto.es-BxABHF-B-TCzLuarM.js"),c=new n,u=await c.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*i);return new Uint8Array(u,0,i)}const n=await E.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*i);return new Uint8Array(n,0,i)}({localKeyPair:this,remoteKeyPair:r||t})}}}export{T as e,L as f,N as t};