@blockcerts/blockcerts-verifier 1.70.0 → 1.71.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.
- package/__mocks__/@polymer/lit-element.ts +1 -1
- package/bundle-stats.html +13 -13
- package/dist/DataIntegrityProof-elCNKq16-DBDuaDNt.js +7 -0
- package/dist/EcdsaSd2023-B0XPAIp6-K61axvBA.js +30 -0
- package/dist/EcdsaSecp256k1Signature2019-BHgoxmKI-DT2qHZod.js +1 -0
- package/dist/Ed25519Signature2020-BQsESRnS-TKZI_1AX.js +34 -0
- package/dist/EddsaRdfc2022-DQKzWHK4-BILzDBp-.js +14 -0
- package/dist/HashlinkVerifier-BsVlaml5-B4Niv2-b.js +8 -0
- package/dist/{MerkleProof2017-DqA3Y12J-D6qS7nCf.js → MerkleProof2017-CYM8CJHB-FYpMvld0.js} +1 -1
- package/dist/{MerkleProof2017-MZJbBTpc-CeZmtqCh.js → MerkleProof2017-MZJbBTpc-Cwfnte6F.js} +6 -6
- package/dist/MerkleProof2019-BLrywo8h-Bo9rH2Eq.js +13 -0
- package/dist/checkCredentialSchemaConformity-CKNtOu_t-B9iaCRUE.js +1 -0
- package/dist/{checkRevocationStatusList2021-CPFaTtUR-XCu3zkCJ.js → checkRevocationStatusList2021-CMAVXAVE-BEBD8TO8.js} +1 -1
- package/dist/{controlVerificationMethod-qY02GU_H-B-4U8WJQ.js → controlVerificationMethod-B4TgLED0-BGpxLjMq.js} +1 -1
- package/dist/{did-key-common.esm-nDfdwcKN-BTWid9-w.js → did-key-common.esm-BIftA62j-hVrUMxjy.js} +3 -3
- package/dist/{did-key-ed25519.esm-DNra0jwE-CTwAEzy6.js → did-key-ed25519.esm-Drn3Y7PF-CqD0ifNk.js} +1 -1
- package/dist/did-key-secp256k1.esm-DH-f3o5q-C66E7IxB.js +1 -0
- package/dist/{downloadPDF-DQVfeIBI.js → downloadPDF-eGAsbwF0.js} +19 -19
- package/dist/ed25519-key-pair.esm-DPOFpdJ2-BrwuS0Ia.js +25 -0
- package/dist/elliptic-4aZS_cwf-BpaNaVm0.js +1 -0
- package/dist/elliptic-BYqApR8Y-CKp7atgR.js +1 -0
- package/dist/{ensureNotRevoked-gui-UMnE-DnVNmhNy.js → ensureNotRevoked-gui-UMnE-o08xNOvL.js} +1 -1
- package/dist/{ensureValidIssuingKey-Cz0isOdi-wu9SdYxL.js → ensureValidIssuingKey-BMVCi2T2-BdV46XBb.js} +1 -1
- package/dist/{index-Bi-O7G4n-Bgz40JYf.js → index-BgTFEYQ4-DMaz98iZ.js} +7 -7
- package/dist/index-CEj3k9G6.js +2 -0
- package/dist/index-DZLKRa_V-D_IQzjvG.js +5 -0
- package/dist/index-lyuTDW_o-nyi7dklX.js +1 -0
- package/dist/index.es-B7xY76Pb.js +56 -0
- package/dist/{jsonld-CQCA9cVk-CQeQQNYP.js → jsonld-B_Q2jvnp-BJ5uVeOU.js} +3 -3
- package/dist/{index-BM3knvQR-D4vxi3Vi.js → jsonld-signatures-BbILf-Q7-DTp6__ud.js} +16 -20
- package/dist/keyUtils-ExMI0fmg-NVOmd8LH.js +1 -0
- package/dist/main.js +128 -128
- package/dist/pako.esm-BGRKTPxS-UdHShO7y.js +2 -0
- package/dist/purify.es-CkKsfeyH.js +2 -0
- package/dist/{retrieveVerificationMethodPublicKey-6-rH9LB2-DvFOhdlW.js → retrieveVerificationMethodPublicKey-C5Gafl1E-Lv4waRy7.js} +1 -1
- package/dist/verifyIssuerProfile-DCJyz3ho-BwuCK9F3.js +1 -0
- package/dist/webcrypto.es-DpqeDikX-BnVhHKeM.js +40 -0
- package/dist/{x25519-CEFq6uo8-NSl6svWQ.js → x25519-Kp6t9B5a-Dh8L0KYb.js} +1 -1
- package/eslint.config.mjs +21 -0
- package/package.json +35 -46
- package/vitest.config.ts +11 -0
- package/web-test-runner.config.mjs +7 -0
- package/.eslintrc.js +0 -29
- package/dist/EcdsaSd2023-DcsELLJj-DreWzXlX.js +0 -36
- package/dist/EcdsaSecp256k1Signature2019-Cy1mIkjt-DJmj4ZAc.js +0 -1
- package/dist/Ed25519Signature2020-B-CFC9WC-DJkVVmwk.js +0 -52
- package/dist/HashlinkVerifier-hQgVXluZ-dg5WNZnc.js +0 -11
- package/dist/MerkleProof2019-B4HSvmJo-Cwc-hu-Y.js +0 -3
- package/dist/checkCredentialSchemaConformity-ChaCRIqw-7U54o8BA.js +0 -1
- package/dist/did-key-secp256k1.esm-Dv1NXpDw-_M-qRy-N.js +0 -1
- package/dist/elliptic-D-ZnlFdt-DQmYEk-8.js +0 -1
- package/dist/index-ButIU7pZ-Djl5IfSw.js +0 -1
- package/dist/index-C-APorIs.js +0 -2
- package/dist/index.es-BqQdvz5C.js +0 -56
- package/dist/pako.esm-DnD5dZGi-Bw1vqMku.js +0 -2
- package/dist/purify.es-DJj7iNgQ.js +0 -2
- package/dist/verifyIssuerProfile-DnjbDuXe-BVFzyjSL.js +0 -1
- package/dist/webcrypto.es-BxABHF-B-TCzLuarM.js +0 -40
- package/karma.conf.js +0 -27
- /package/dist/{Suite-B7Vy9AuU-D1ucdMDB.js → Suite-BmP2Qu19-D1ucdMDB.js} +0 -0
- /package/dist/{ensureNotRevoked-D9FFjDJd-DvMIgM4L.js → ensureNotRevoked-hGps0prO-DvMIgM4L.js} +0 -0
- /package/dist/{index-ZJb8DPW9-Dgus2xdV.js → index-BS134367-Dgus2xdV.js} +0 -0
- /package/dist/{index-0q2-1l6i-C0eXpZGn.js → index-CQYVZlSE-C0eXpZGn.js} +0 -0
- /package/dist/{sha256-BIUNvBZY-C1PUWFZm.js → sha256-u2xsd4MQ-C1PUWFZm.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{g as e,
|
|
1
|
+
import{g as e,q as t,B as r,i as o}from"./main.js";import{a as n,b as a,c as i}from"./jsonld-B_Q2jvnp-BJ5uVeOU.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),
|
|
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){
|
|
6
6
|
/*!
|
|
7
7
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
8
8
|
*/
|
|
@@ -20,59 +20,55 @@ 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
|
|
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 j(){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)}}}
|
|
24
24
|
/*!
|
|
25
25
|
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
26
|
-
*/function
|
|
26
|
+
*/function U(){if(w)return y;w=1;const e=k(),t=n(),{extendContextLoader:r,strictDocumentLoader:o}=L(),{serializeError:a}=j();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}
|
|
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,
|
|
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,ae,ie,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,
|
|
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}
|
|
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
|
|
38
|
+
*/function _e(){return X?$:(X=1,$=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}})}
|
|
39
39
|
/*!
|
|
40
40
|
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
|
|
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",
|
|
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",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+"$")})(),Q=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 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
|
|
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)))}}}
|
|
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:
|
|
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))}}}
|
|
48
48
|
/*!
|
|
49
49
|
* Copyright (c) 2017-2024 Digital Bazaar, Inc. All rights reserved.
|
|
50
|
-
*/(),
|
|
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={rdfDirection:"i18n-datatype",...o,produceGeneralizedRdf:!1};delete n.format;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}
|
|
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",
|
|
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}
|
|
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:
|
|
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){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
|
-
*/var
|
|
65
|
+
*/var je=function(){if(be)return Te;be=1;const e={};Te=e;const t=k();Object.assign(e,t);const r=U(),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:
|
|
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}
|
|
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}
|
|
72
72
|
/*!
|
|
73
73
|
* Copyright (c) 2010-2023 Digital Bazaar, Inc. All rights reserved.
|
|
74
|
-
*/().purposes,Object.assign(e,L()),Te}(),
|
|
75
|
-
/*!
|
|
76
|
-
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
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,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};
|
|
74
|
+
*/().purposes,Object.assign(e,L()),Te}(),Ue=e(je);export{Ue as j,Se as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as r,s as e,b as t}from"./elliptic-BYqApR8Y-CKp7atgR.js";import{B as n}from"./main.js";import{d as o}from"./base64url-Cy03LJLt-vkTPfQOh.js";const s="undefined"==typeof Buffer?n:Buffer,i=t=>{const n=r.from({...t,crv:"K-256"},"jwk").toString("blk","public"),o=e.publicKeyConvert(s.from(n,"hex"),!0);return s.from(o).toString("hex")},f=r=>t.encode(s.from(r,"hex"));const c=r=>{const e=new Uint8Array([237,1]),n=function(r){const{kty:e,crv:t,x:n}=r;if("OKP"!==e)throw new TypeError('"jwk.kty" must be "OKP".');if("Ed25519"!==t)throw new TypeError('"jwk.crv" must be "Ed25519".');if("string"!=typeof n)throw new TypeError('"jwk.x" must be a string.');const s=o(r.x);if(32!==s.length)throw new Error(`Invalid public key size (${s.length}); expected 32.`);return s}(r),s=new Uint8Array(e.length+n.length);s.set(e),s.set(n,e.length);var i;return`z${i=s,t.encode(i)}`};export{f as a,c as j,i as p};
|