@blockcerts/blockcerts-verifier 1.73.0 → 1.74.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 (42) hide show
  1. package/bundle-stats.html +1 -1
  2. package/coverage/lcov.info +104 -104
  3. package/dist/{DataIntegrityProof-D8TnXEkl-CGiIg0kn.js → DataIntegrityProof-DRK-bLb_-CItV0ZXY.js} +2 -2
  4. package/dist/EcdsaSd2023-CdilbQE4-BlaeM9K_.js +26 -0
  5. package/dist/EcdsaSecp256k1Signature2019-rfxWS2XE-C73WHAtH.js +1 -0
  6. package/dist/{Ed25519Signature2020-D2tdrIA4-PSi5TCQH.js → Ed25519Signature2020-CDbX0d2Z-Dc1L-exZ.js} +8 -8
  7. package/dist/{EddsaRdfc2022-CpZAUc7W-BJP0532C.js → EddsaRdfc2022-Do0HFpDb-BcV_n8Fk.js} +4 -4
  8. package/dist/{HashlinkVerifier-BcdAFe02-DMjUYzMR.js → HashlinkVerifier-Cdnza1Dw-A9htzw7A.js} +1 -1
  9. package/dist/MerkleProof2017-5uQFQKSe-dtmePIpg.js +1 -0
  10. package/dist/MerkleProof2019-DraC60XD-B9XV8wNx.js +5 -0
  11. package/dist/checkBitStringStatusList-CKk6xxUL-D99R7EXK.js +1 -0
  12. package/dist/checkCredentialSchemaConformity-U2NlIuJZ-swOY09NS.js +1 -0
  13. package/dist/controlVerificationMethod-Blm4pE1t-BYBRLxNP.js +1 -0
  14. package/dist/{downloadPDF-BU6CfP-N.js → downloadPDF-C-y2U2YC.js} +2 -2
  15. package/dist/{ensureNotRevoked-BWp1jPEo-DSQMtjrj.js → ensureNotRevoked-DrQAPfcJ-BheL-ZKZ.js} +1 -1
  16. package/dist/ensureValidIssuingKey-D7OT4D35--HN0afRq.js +1 -0
  17. package/dist/index-BNsIYV4r-BnYxKy2f.js +14 -0
  18. package/dist/{index-OtXtCWrq-CyttRwCk.js → index-C4ZZHHRx-BOdwDnYa.js} +1 -1
  19. package/dist/index-CVS5Gn9h-DNgvq6Wk.js +7 -0
  20. package/dist/index-D2bS6rRi-D_ppNIsb.js +66 -0
  21. package/dist/{index-CB7VaVsF-G_Mj6xql.js → index-Dr7MpiEc-D5LHgMik.js} +12 -12
  22. package/dist/{index.es-C2GPR7m7.js → index.es-BmC2s_4v.js} +1 -1
  23. package/dist/jsonld-DOUjwF6J-dtl20tiV.js +33 -0
  24. package/dist/jsonld-signatures-BJXipuab-CB799Kkm.js +56 -0
  25. package/dist/main.js +122 -122
  26. package/dist/retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js +1 -0
  27. package/dist/{verifyIssuerProfile-zkczSLpC-CTHpISfH.js → verifyIssuerProfile-BG-odQrl-0JjZhiiC.js} +1 -1
  28. package/package.json +2 -2
  29. package/dist/EcdsaSd2023-D2eJBmaY-mHNjbn8h.js +0 -26
  30. package/dist/EcdsaSecp256k1Signature2019-BRdQnZ0o-D_QN8KrS.js +0 -1
  31. package/dist/MerkleProof2017-DW_9FhLr-C0dPtifx.js +0 -1
  32. package/dist/MerkleProof2019-DJbo7uW--CHlhsnHk.js +0 -5
  33. package/dist/checkBitStringStatusList-BUPuVWy_-CYedocxJ.js +0 -13
  34. package/dist/checkCredentialSchemaConformity-CJdGwNcY-CaSak-bD.js +0 -1
  35. package/dist/controlVerificationMethod-C71lJp3H-n-AbzkO8.js +0 -1
  36. package/dist/ensureValidIssuingKey-BYAR3LEF-76kiqVKA.js +0 -1
  37. package/dist/index-Jn9Q6fuB-uChPhl1c.js +0 -56
  38. package/dist/jsonld-DqC1oHcn-ruRlORc0.js +0 -88
  39. package/dist/retrieveVerificationMethodPublicKey-Dai7em0K-BqIH8qzD.js +0 -1
  40. /package/dist/{index-BCu3PGuw-Dh4-8Ruv.js → index-uKBVup0_-Dh4-8Ruv.js} +0 -0
  41. /package/dist/{index-KzSDgEl9-Dgus2xdV.js → index-yOIIz7AL-Dgus2xdV.js} +0 -0
  42. /package/dist/{webcrypto.es-9hytEjC6-gGk5JRJH.js → webcrypto.es-FKUHCUj--gGk5JRJH.js} +0 -0
@@ -2274,13 +2274,13 @@ FN:22,(anonymous_3)
2274
2274
  FNF:4
2275
2275
  FNH:4
2276
2276
  FNDA:691,dispatchActionsFactory
2277
- FNDA:29,dispatchActions
2277
+ FNDA:51,dispatchActions
2278
2278
  FNDA:691,stepVerified
2279
2279
  FNDA:691,(anonymous_3)
2280
2280
  DA:8,39
2281
2281
  DA:11,691
2282
- DA:12,29
2283
- DA:17,29
2282
+ DA:12,51
2283
+ DA:17,51
2284
2284
  DA:22,691
2285
2285
  DA:23,691
2286
2286
  DA:24,691
@@ -2398,69 +2398,69 @@ FN:45,updateParentStepStatus
2398
2398
  FN:46,(anonymous_9)
2399
2399
  FNF:10
2400
2400
  FNH:10
2401
- FNDA:184,stepVerificationIsSuccessful
2402
- FNDA:240,stepVerificationIsFailure
2403
- FNDA:18,oneChildIsSuccess
2404
- FNDA:15,(anonymous_3)
2405
- FNDA:27,allChildrenAreSuccess
2406
- FNDA:20,(anonymous_5)
2407
- FNDA:37,oneChildIsFailure
2408
- FNDA:30,(anonymous_7)
2409
- FNDA:37,updateParentStepStatus
2410
- FNDA:37,(anonymous_9)
2411
- DA:9,184
2412
- DA:13,240
2413
- DA:17,18
2414
- DA:18,18
2415
- DA:19,15
2416
- DA:21,18
2417
- DA:25,27
2418
- DA:26,27
2419
- DA:27,20
2420
- DA:29,27
2421
- DA:33,37
2422
- DA:34,37
2423
- DA:35,30
2424
- DA:37,37
2425
- DA:46,37
2426
- DA:47,37
2401
+ FNDA:281,stepVerificationIsSuccessful
2402
+ FNDA:410,stepVerificationIsFailure
2403
+ FNDA:27,oneChildIsSuccess
2404
+ FNDA:23,(anonymous_3)
2405
+ FNDA:48,allChildrenAreSuccess
2406
+ FNDA:40,(anonymous_5)
2407
+ FNDA:59,oneChildIsFailure
2408
+ FNDA:51,(anonymous_7)
2409
+ FNDA:59,updateParentStepStatus
2410
+ FNDA:59,(anonymous_9)
2411
+ DA:9,281
2412
+ DA:13,410
2413
+ DA:17,27
2414
+ DA:18,27
2415
+ DA:19,23
2416
+ DA:21,27
2417
+ DA:25,48
2418
+ DA:26,48
2419
+ DA:27,40
2420
+ DA:29,48
2421
+ DA:33,59
2422
+ DA:34,59
2423
+ DA:35,51
2424
+ DA:37,59
2425
+ DA:46,59
2426
+ DA:47,59
2427
2427
  DA:48,0
2428
- DA:51,37
2429
- DA:53,37
2430
- DA:54,37
2431
- DA:56,37
2432
- DA:57,8
2433
- DA:60,37
2434
- DA:61,7
2435
- DA:64,37
2428
+ DA:51,59
2429
+ DA:53,59
2430
+ DA:54,59
2431
+ DA:56,59
2432
+ DA:57,16
2433
+ DA:60,59
2434
+ DA:61,8
2435
+ DA:64,59
2436
2436
  DA:65,2
2437
- DA:68,37
2437
+ DA:68,59
2438
2438
  LF:27
2439
2439
  LH:26
2440
- BRDA:18,0,0,15
2441
- BRDA:18,0,1,3
2442
- BRDA:21,1,0,18
2443
- BRDA:21,1,1,10
2444
- BRDA:26,2,0,20
2445
- BRDA:26,2,1,7
2446
- BRDA:29,3,0,27
2447
- BRDA:29,3,1,11
2448
- BRDA:34,4,0,30
2449
- BRDA:34,4,1,7
2450
- BRDA:37,5,0,37
2451
- BRDA:37,5,1,35
2440
+ BRDA:18,0,0,23
2441
+ BRDA:18,0,1,4
2442
+ BRDA:21,1,0,27
2443
+ BRDA:21,1,1,11
2444
+ BRDA:26,2,0,40
2445
+ BRDA:26,2,1,8
2446
+ BRDA:29,3,0,48
2447
+ BRDA:29,3,1,13
2448
+ BRDA:34,4,0,51
2449
+ BRDA:34,4,1,8
2450
+ BRDA:37,5,0,59
2451
+ BRDA:37,5,1,57
2452
2452
  BRDA:47,6,0,0
2453
- BRDA:47,6,1,37
2454
- BRDA:56,7,0,8
2455
- BRDA:56,7,1,29
2456
- BRDA:56,8,0,37
2457
- BRDA:56,8,1,18
2458
- BRDA:60,9,0,7
2459
- BRDA:60,9,1,30
2460
- BRDA:60,10,0,37
2461
- BRDA:60,10,1,27
2453
+ BRDA:47,6,1,59
2454
+ BRDA:56,7,0,16
2455
+ BRDA:56,7,1,43
2456
+ BRDA:56,8,0,59
2457
+ BRDA:56,8,1,27
2458
+ BRDA:60,9,0,8
2459
+ BRDA:60,9,1,51
2460
+ BRDA:60,10,0,59
2461
+ BRDA:60,10,1,48
2462
2462
  BRDA:64,11,0,2
2463
- BRDA:64,11,1,35
2463
+ BRDA:64,11,1,57
2464
2464
  BRF:24
2465
2465
  BRH:23
2466
2466
  end_of_record
@@ -5025,7 +5025,7 @@ FNH:6
5025
5025
  FNDA:38,(anonymous_0)
5026
5026
  FNDA:19,(anonymous_1)
5027
5027
  FNDA:691,(anonymous_2)
5028
- FNDA:31,(anonymous_3)
5028
+ FNDA:53,(anonymous_3)
5029
5029
  FNDA:691,(anonymous_4)
5030
5030
  FNDA:38,(anonymous_5)
5031
5031
  DA:10,38
@@ -5036,9 +5036,9 @@ DA:14,38
5036
5036
  DA:18,19
5037
5037
  DA:22,691
5038
5038
  DA:23,691
5039
- DA:28,31
5040
- DA:29,31
5041
- DA:30,29
5039
+ DA:28,53
5040
+ DA:29,53
5041
+ DA:30,51
5042
5042
  DA:31,2
5043
5043
  DA:32,2
5044
5044
  DA:33,2
@@ -5051,7 +5051,7 @@ LF:19
5051
5051
  LH:19
5052
5052
  BRDA:22,0,0,691
5053
5053
  BRDA:22,0,1,0
5054
- BRDA:29,1,0,29
5054
+ BRDA:29,1,0,51
5055
5055
  BRDA:29,1,1,2
5056
5056
  BRDA:31,2,0,2
5057
5057
  BRDA:31,2,1,0
@@ -5521,18 +5521,18 @@ SF:src/reducers/index.ts
5521
5521
  FN:18,app
5522
5522
  FNF:1
5523
5523
  FNH:1
5524
- FNDA:1367,app
5525
- DA:19,1367
5524
+ FNDA:1411,app
5525
+ DA:19,1411
5526
5526
  DA:21,87
5527
5527
  DA:24,23
5528
5528
  DA:27,150
5529
5529
  DA:30,11
5530
5530
  DA:33,6
5531
- DA:36,37
5531
+ DA:36,59
5532
5532
  DA:39,12
5533
5533
  DA:42,166
5534
5534
  DA:45,153
5535
- DA:48,29
5535
+ DA:48,51
5536
5536
  DA:51,158
5537
5537
  DA:54,84
5538
5538
  DA:57,0
@@ -5544,11 +5544,11 @@ BRDA:19,0,1,23
5544
5544
  BRDA:19,0,2,150
5545
5545
  BRDA:19,0,3,11
5546
5546
  BRDA:19,0,4,6
5547
- BRDA:19,0,5,37
5547
+ BRDA:19,0,5,59
5548
5548
  BRDA:19,0,6,12
5549
5549
  BRDA:19,0,7,166
5550
5550
  BRDA:19,0,8,153
5551
- BRDA:19,0,9,29
5551
+ BRDA:19,0,9,51
5552
5552
  BRDA:19,0,10,158
5553
5553
  BRDA:19,0,11,84
5554
5554
  BRDA:19,0,12,0
@@ -5614,31 +5614,31 @@ FN:14,(anonymous_3)
5614
5614
  FN:22,stepVerified
5615
5615
  FNF:5
5616
5616
  FNH:5
5617
- FNDA:29,updateSubstepIn
5618
- FNDA:6,(anonymous_1)
5619
- FNDA:25,(anonymous_2)
5620
- FNDA:85,(anonymous_3)
5621
- FNDA:29,stepVerified
5622
- DA:7,29
5623
- DA:8,29
5624
- DA:9,4
5625
- DA:10,4
5626
- DA:12,25
5627
- DA:13,25
5628
- DA:14,85
5629
- DA:15,25
5630
- DA:16,25
5631
- DA:23,29
5632
- DA:24,29
5633
- DA:25,29
5634
- DA:27,29
5617
+ FNDA:51,updateSubstepIn
5618
+ FNDA:7,(anonymous_1)
5619
+ FNDA:46,(anonymous_2)
5620
+ FNDA:147,(anonymous_3)
5621
+ FNDA:51,stepVerified
5622
+ DA:7,51
5623
+ DA:8,51
5624
+ DA:9,5
5625
+ DA:10,5
5626
+ DA:12,46
5627
+ DA:13,46
5628
+ DA:14,147
5629
+ DA:15,46
5630
+ DA:16,46
5631
+ DA:23,51
5632
+ DA:24,51
5633
+ DA:25,51
5634
+ DA:27,51
5635
5635
  LF:13
5636
5636
  LH:13
5637
- BRDA:8,0,0,4
5638
- BRDA:8,0,1,25
5639
- BRDA:12,1,0,25
5637
+ BRDA:8,0,0,5
5638
+ BRDA:8,0,1,46
5639
+ BRDA:12,1,0,46
5640
5640
  BRDA:12,1,1,0
5641
- BRDA:15,2,0,25
5641
+ BRDA:15,2,0,46
5642
5642
  BRDA:15,2,1,0
5643
5643
  BRF:6
5644
5644
  BRH:4
@@ -5698,11 +5698,11 @@ SF:src/reducers/updateParentStepStatus.ts
5698
5698
  FN:6,updateParentStepStatus
5699
5699
  FNF:1
5700
5700
  FNH:1
5701
- FNDA:37,updateParentStepStatus
5702
- DA:7,37
5703
- DA:9,37
5704
- DA:11,37
5705
- DA:13,37
5701
+ FNDA:59,updateParentStepStatus
5702
+ DA:7,59
5703
+ DA:9,59
5704
+ DA:11,59
5705
+ DA:13,59
5706
5706
  LF:4
5707
5707
  LH:4
5708
5708
  BRF:0
@@ -5975,9 +5975,9 @@ FNDA:25,(anonymous_27)
5975
5975
  FNDA:15,isTestChain
5976
5976
  FNDA:11,(anonymous_29)
5977
5977
  FNDA:0,isTestChainAtIndex
5978
- FNDA:135,getVerifiedSteps
5979
- FNDA:107,getParentStep
5980
- FNDA:127,(anonymous_33)
5978
+ FNDA:201,getVerifiedSteps
5979
+ FNDA:173,getParentStep
5980
+ FNDA:196,(anonymous_33)
5981
5981
  FNDA:1,getStartedVerificationSteps
5982
5982
  FNDA:2,(anonymous_35)
5983
5983
  FNDA:5,getHasError
@@ -6129,8 +6129,8 @@ DA:321,0
6129
6129
  DA:322,0
6130
6130
  DA:323,0
6131
6131
  DA:325,0
6132
- DA:329,135
6133
- DA:334,127
6132
+ DA:329,201
6133
+ DA:334,196
6134
6134
  DA:338,1
6135
6135
  DA:340,2
6136
6136
  DA:344,9
@@ -6263,7 +6263,7 @@ BRDA:322,41,0,0
6263
6263
  BRDA:322,41,1,0
6264
6264
  BRDA:325,42,0,0
6265
6265
  BRDA:325,42,1,0
6266
- BRDA:329,43,0,135
6266
+ BRDA:329,43,0,201
6267
6267
  BRDA:329,43,1,0
6268
6268
  BRDA:379,44,0,0
6269
6269
  BRDA:379,44,1,12
@@ -1,7 +1,7 @@
1
- import{a as t,r as e}from"./jsonld-DqC1oHcn-ruRlORc0.js";import{v as r,f as o,t as i}from"./main.js";var n=e();
1
+ import{r as t}from"./jsonld-DOUjwF6J-dtl20tiV.js";import{w as e,f as r,u as o}from"./main.js";import{j as i}from"./jsonld-signatures-BJXipuab-CB799Kkm.js";var n=t();
2
2
  /*!
3
3
  * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
4
4
  */const a=new RegExp("-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](.[0-9]+)?|(24:00:00(.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"),s=t=>a.test(t),c=self&&(self.crypto||self.msCrypto);async function u({string:t}){const e=(new TextEncoder).encode(t);return new Uint8Array(await c.subtle.digest("SHA-256",e))}
5
5
  /*!
6
6
  * Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
7
- */const{suites:{LinkedDataProof:d}}=t;class f extends d{constructor({signer:t,date:e,cryptosuite:r,legacyContext:o=!1}={}){super({type:"DataIntegrityProof"});const{canonize:i,createVerifier:n,name:a,requiredAlgorithm:s,derive:c,createProofValue:u,createVerifyData:d}=r;if(!n||"function"!=typeof n)throw new TypeError('"cryptosuite.createVerifier" must be a function.');if(c&&"function"!=typeof c)throw new TypeError('"cryptosuite.derive" must be a function.');if(u&&"function"!=typeof u)throw new TypeError('"cryptosuite.createProofValue" must be a function.');if(d&&"function"!=typeof d)throw new TypeError('"cryptosuite.createVerifyData" must be a function.');if(this.contextUrl="https://w3id.org/security/data-integrity/v2",o&&(this.contextUrl="https://w3id.org/security/data-integrity/v1"),this.canonize=i,this.createVerifier=n,this.cryptosuite=a,this._cryptosuite=r,this.requiredAlgorithm=s,e){if(this.date=new Date(e),isNaN(this.date))throw TypeError(`"date" "${e}" is not a valid date.`)}else null===e&&(this.date=null);const f=function({signer:t,requiredAlgorithm:e}){const r={verificationMethod:void 0,signer:void 0};if(!t)return r;if("function"!=typeof t.sign)throw new TypeError("A signer API has not been specified.");const o=Array.isArray(e)?e.includes(t.algorithm):e===t.algorithm;if(!o){const r=Array.isArray(e)?e.join(", "):e,o=Array.isArray(e)?`is not a supported algorithm for the cryptosuite. The supported algorithms are: "${r}".`:`does not match the required algorithm for the cryptosuite "${r}".`,i=`The signer's algorithm "${t.algorithm}" ${o}`;throw new Error(i)}return r.signer=t,r.verificationMethod=t.id,r}({signer:t,requiredAlgorithm:s});this.verificationMethod=f.verificationMethod,this.signer=f.signer}async sign({verifyData:t,proof:e}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const o=await this.signer.sign({data:t});return e.proofValue="z"+r(o),e}async verifySignature({verifyData:t,verificationMethod:e,proof:r}){const n=await this.createVerifier({verificationMethod:e});if(!(Array.isArray(this.requiredAlgorithm)?this.requiredAlgorithm.includes(n.algorithm):this.requiredAlgorithm===n.algorithm)){const t=Array.isArray(this.requiredAlgorithm)?this.requiredAlgorithm.join(", "):this.requiredAlgorithm,e=Array.isArray(this.requiredAlgorithm)?`is not a supported algorithm for the cryptosuite. The supported algorithms are: "${t}".`:`does not match the required algorithm for the cryptosuite "${t}".`,r=`The verifier's algorithm "${n.algorithm}" ${e}`;throw new Error(r)}const{proofValue:a}=r;if(!a||"string"!=typeof a)throw new TypeError('The proof does not include a valid "proofValue" property.');const s=a[0];let c;if("z"===s)c=o(a.slice(1));else{if("u"!==s)throw new Error("Only base58btc or base64url multibase encoding is supported.");c=i(a.slice(1))}return n.verify({data:t,signature:c})}async createProof({document:t,purpose:e,proofSet:r,documentLoader:o}){let i;i=this.proof?{...this.proof}:{},i.type=this.type;let n,a=this.date;return void 0===i.created&&void 0===a&&(a=new Date),a&&"string"!=typeof a&&(a=(t=>(null==t?t=new Date:"number"!=typeof t&&"string"!=typeof t||(t=new Date(t)),t.toISOString().slice(0,-5)+"Z"))(a)),a&&(i.created=a),i.verificationMethod=this.verificationMethod,i.cryptosuite=this.cryptosuite,i=await this.updateProof({document:t,proof:i,purpose:e,proofSet:r,documentLoader:o}),i=await e.update(i,{document:t,suite:this,documentLoader:o}),n=this._cryptosuite.createVerifyData?await this._cryptosuite.createVerifyData({cryptosuite:this._cryptosuite,document:t,proof:i,proofSet:r,documentLoader:o,dataIntegrityProof:this}):await this.createVerifyData({document:t,proof:i,proofSet:r,documentLoader:o}),this._cryptosuite.createProofValue?i.proofValue=await this._cryptosuite.createProofValue({cryptosuite:this._cryptosuite,verifyData:n,document:t,proof:i,proofSet:r,documentLoader:o,dataIntegrityProof:this}):i=await this.sign({verifyData:n,document:t,proof:i,proofSet:r,documentLoader:o}),i}async derive({document:t,purpose:e,proofSet:r,documentLoader:o}){if(!this._cryptosuite.derive)throw new Error('"cryptosuite.derive" not provided.');return this._cryptosuite.derive({cryptosuite:this._cryptosuite,document:t,purpose:e,proofSet:r,documentLoader:o,dataIntegrityProof:this})}async updateProof({proof:t}){return t}async verifyProof({proof:t,proofSet:e,document:r,documentLoader:o}){try{const i=await this.getVerificationMethod({proof:t,documentLoader:o});let n;n=this._cryptosuite.createVerifyData?await this._cryptosuite.createVerifyData({cryptosuite:this._cryptosuite,document:r,proof:t,proofSet:e,documentLoader:o,dataIntegrityProof:this,verificationMethod:i}):await this.createVerifyData({document:r,proof:t,proofSet:e,documentLoader:o,verificationMethod:i});if(!await this.verifySignature({verifyData:n,verificationMethod:i,proof:t}))throw new Error("Invalid signature.");if(void 0!==t.created&&!s(t.created))throw new Error(`"proof.created" ("${t.created}") must be an XSD dateTimeStamp.`);if(void 0!==t.expires&&!s(t.expires))throw new Error(`"proof.expires" ("${t.expires}") must be an XSD dateTimeStamp.`);return{verified:!0,verificationMethod:i}}catch(t){return{verified:!1,error:t}}}async createVerifyData({document:t,proof:e,documentLoader:r}){let o;const{_hashCache:i}=this;i&&i.document===t?o=i.hash:this._hashCache={document:t,hash:o=this.canonize(t,{documentLoader:r,base:null,safe:!0}).then(t=>u({string:t}))};const[n,a]=await Promise.all([this.canonizeProof(e,{document:t,documentLoader:r}).then(t=>u({string:t})),o]);return((t,e)=>{const r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r})(n,a)}async getVerificationMethod({proof:t,documentLoader:e}){let{verificationMethod:r}=t;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const o=await e(r);if(!o)throw new Error(`Unable to load verification method "${r}".`);const{document:i}=o;return r="string"==typeof i?JSON.parse(i):i,r}async canonizeProof(t,{documentLoader:e,document:r}){return t={"@context":r["@context"],...t},this.ensureSuiteContext({document:t,addSuiteContext:!0}),delete t.proofValue,this.canonize(t,{documentLoader:e,safe:!0,base:null,skipExpansion:!1})}async matchProof({proof:t}){const{type:e,cryptosuite:r}=t;return e===this.type&&r===this.cryptosuite}ensureSuiteContext({document:t,addSuiteContext:e}){const{contextUrl:r}=this;if(h({document:t,contextUrl:r})||h({document:t,contextUrl:"https://www.w3.org/ns/credentials/v2"}))return;if(!e)throw new TypeError(`The document to be signed must contain this suite's @context, "${r}".`);const o=t["@context"]||[];t["@context"]=Array.isArray(o)?[...o,r]:[o,r]}}function h({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}export{f as D,n as r};
7
+ */const{suites:{LinkedDataProof:d}}=i;class f extends d{constructor({signer:t,date:e,cryptosuite:r,legacyContext:o=!1}={}){super({type:"DataIntegrityProof"});const{canonize:i,createVerifier:n,name:a,requiredAlgorithm:s,derive:c,createProofValue:u,createVerifyData:d}=r;if(!n||"function"!=typeof n)throw new TypeError('"cryptosuite.createVerifier" must be a function.');if(c&&"function"!=typeof c)throw new TypeError('"cryptosuite.derive" must be a function.');if(u&&"function"!=typeof u)throw new TypeError('"cryptosuite.createProofValue" must be a function.');if(d&&"function"!=typeof d)throw new TypeError('"cryptosuite.createVerifyData" must be a function.');if(this.contextUrl="https://w3id.org/security/data-integrity/v2",o&&(this.contextUrl="https://w3id.org/security/data-integrity/v1"),this.canonize=i,this.createVerifier=n,this.cryptosuite=a,this._cryptosuite=r,this.requiredAlgorithm=s,e){if(this.date=new Date(e),isNaN(this.date))throw TypeError(`"date" "${e}" is not a valid date.`)}else null===e&&(this.date=null);const f=function({signer:t,requiredAlgorithm:e}){const r={verificationMethod:void 0,signer:void 0};if(!t)return r;if("function"!=typeof t.sign)throw new TypeError("A signer API has not been specified.");const o=Array.isArray(e)?e.includes(t.algorithm):e===t.algorithm;if(!o){const r=Array.isArray(e)?e.join(", "):e,o=Array.isArray(e)?`is not a supported algorithm for the cryptosuite. The supported algorithms are: "${r}".`:`does not match the required algorithm for the cryptosuite "${r}".`,i=`The signer's algorithm "${t.algorithm}" ${o}`;throw new Error(i)}return r.signer=t,r.verificationMethod=t.id,r}({signer:t,requiredAlgorithm:s});this.verificationMethod=f.verificationMethod,this.signer=f.signer}async sign({verifyData:t,proof:r}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const o=await this.signer.sign({data:t});return r.proofValue="z"+e(o),r}async verifySignature({verifyData:t,verificationMethod:e,proof:i}){const n=await this.createVerifier({verificationMethod:e});if(!(Array.isArray(this.requiredAlgorithm)?this.requiredAlgorithm.includes(n.algorithm):this.requiredAlgorithm===n.algorithm)){const t=Array.isArray(this.requiredAlgorithm)?this.requiredAlgorithm.join(", "):this.requiredAlgorithm,e=Array.isArray(this.requiredAlgorithm)?`is not a supported algorithm for the cryptosuite. The supported algorithms are: "${t}".`:`does not match the required algorithm for the cryptosuite "${t}".`,r=`The verifier's algorithm "${n.algorithm}" ${e}`;throw new Error(r)}const{proofValue:a}=i;if(!a||"string"!=typeof a)throw new TypeError('The proof does not include a valid "proofValue" property.');const s=a[0];let c;if("z"===s)c=r(a.slice(1));else{if("u"!==s)throw new Error("Only base58btc or base64url multibase encoding is supported.");c=o(a.slice(1))}return n.verify({data:t,signature:c})}async createProof({document:t,purpose:e,proofSet:r,documentLoader:o}){let i;i=this.proof?{...this.proof}:{},i.type=this.type;let n,a=this.date;return void 0===i.created&&void 0===a&&(a=new Date),a&&"string"!=typeof a&&(a=(t=>(null==t?t=new Date:"number"!=typeof t&&"string"!=typeof t||(t=new Date(t)),t.toISOString().slice(0,-5)+"Z"))(a)),a&&(i.created=a),i.verificationMethod=this.verificationMethod,i.cryptosuite=this.cryptosuite,i=await this.updateProof({document:t,proof:i,purpose:e,proofSet:r,documentLoader:o}),i=await e.update(i,{document:t,suite:this,documentLoader:o}),n=this._cryptosuite.createVerifyData?await this._cryptosuite.createVerifyData({cryptosuite:this._cryptosuite,document:t,proof:i,proofSet:r,documentLoader:o,dataIntegrityProof:this}):await this.createVerifyData({document:t,proof:i,proofSet:r,documentLoader:o}),this._cryptosuite.createProofValue?i.proofValue=await this._cryptosuite.createProofValue({cryptosuite:this._cryptosuite,verifyData:n,document:t,proof:i,proofSet:r,documentLoader:o,dataIntegrityProof:this}):i=await this.sign({verifyData:n,document:t,proof:i,proofSet:r,documentLoader:o}),i}async derive({document:t,purpose:e,proofSet:r,documentLoader:o}){if(!this._cryptosuite.derive)throw new Error('"cryptosuite.derive" not provided.');return this._cryptosuite.derive({cryptosuite:this._cryptosuite,document:t,purpose:e,proofSet:r,documentLoader:o,dataIntegrityProof:this})}async updateProof({proof:t}){return t}async verifyProof({proof:t,proofSet:e,document:r,documentLoader:o}){try{const i=await this.getVerificationMethod({proof:t,documentLoader:o});let n;n=this._cryptosuite.createVerifyData?await this._cryptosuite.createVerifyData({cryptosuite:this._cryptosuite,document:r,proof:t,proofSet:e,documentLoader:o,dataIntegrityProof:this,verificationMethod:i}):await this.createVerifyData({document:r,proof:t,proofSet:e,documentLoader:o,verificationMethod:i});if(!await this.verifySignature({verifyData:n,verificationMethod:i,proof:t}))throw new Error("Invalid signature.");if(void 0!==t.created&&!s(t.created))throw new Error(`"proof.created" ("${t.created}") must be an XSD dateTimeStamp.`);if(void 0!==t.expires&&!s(t.expires))throw new Error(`"proof.expires" ("${t.expires}") must be an XSD dateTimeStamp.`);return{verified:!0,verificationMethod:i}}catch(t){return{verified:!1,error:t}}}async createVerifyData({document:t,proof:e,documentLoader:r}){let o;const{_hashCache:i}=this;i&&i.document===t?o=i.hash:this._hashCache={document:t,hash:o=this.canonize(t,{documentLoader:r,base:null,safe:!0}).then(t=>u({string:t}))};const[n,a]=await Promise.all([this.canonizeProof(e,{document:t,documentLoader:r}).then(t=>u({string:t})),o]);return((t,e)=>{const r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r})(n,a)}async getVerificationMethod({proof:t,documentLoader:e}){let{verificationMethod:r}=t;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const o=await e(r);if(!o)throw new Error(`Unable to load verification method "${r}".`);const{document:i}=o;return r="string"==typeof i?JSON.parse(i):i,r}async canonizeProof(t,{documentLoader:e,document:r}){return t={"@context":r["@context"],...t},this.ensureSuiteContext({document:t,addSuiteContext:!0}),delete t.proofValue,this.canonize(t,{documentLoader:e,safe:!0,base:null,skipExpansion:!1})}async matchProof({proof:t}){const{type:e,cryptosuite:r}=t;return e===this.type&&r===this.cryptosuite}ensureSuiteContext({document:t,addSuiteContext:e}){const{contextUrl:r}=this;if(h({document:t,contextUrl:r})||h({document:t,contextUrl:"https://www.w3.org/ns/credentials/v2"}))return;if(!e)throw new TypeError(`The document to be signed must contain this suite's @context, "${r}".`);const o=t["@context"]||[];t["@context"]=Array.isArray(o)?[...o,r]:[o,r]}}function h({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}export{f as D,n as r};
@@ -0,0 +1,26 @@
1
+ import{d as e,p as t,V as n,P as r,u as o,w as i,v as a}from"./main.js";import{j as s}from"./jsonld-signatures-BJXipuab-CB799Kkm.js";import{j as u}from"./jsonld-DOUjwF6J-dtl20tiV.js";import{D as c,r as f}from"./DataIntegrityProof-DRK-bLb_-CItV0ZXY.js";import{f as l}from"./index-Dr7MpiEc-D5LHgMik.js";import{S as d}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./index-yOIIz7AL-Dgus2xdV.js";import{r as h}from"./retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js";
2
+ /*!
3
+ * Copyright (c) 2023-2026 Digital Bazaar, Inc.
4
+ */const p=globalThis.crypto;function y({algorithm:e="sha256"}={}){if("sha256"!==e)throw new Error(`Unsupported algorithm "${e}".`);return{hash:async e=>new Uint8Array(await p.subtle.digest("SHA-256",e))}}
5
+ /*!
6
+ * Copyright (c) 2023-2026 Digital Bazaar, Inc.
7
+ */const w=new TextEncoder;function g(e){return w.encode(e)}
8
+ /*!
9
+ * Copyright (c) 2023-2026 Digital Bazaar, Inc.
10
+ */async function m({document:e,labelMapFactoryFunction:t,options:n}={}){const{nquads:r}=await async function({document:e,nquads:t,labelMapFactoryFunction:n,options:r}={}){let o,i=new Map;o=e?await b(e,{...r,canonicalIdMap:i}):await b(t.join(""),{...r,inputFormat:"application/n-quads",canonicalIdMap:i});i=function(e){let t=!1,n=!1,r=!1;const o=new Map;for(const[i,a]of e){if(!t&&(t=!0,n=i.startsWith("_:"),r=a.startsWith("_:"),!n&&!r))return e;o.set(n?i.slice(2):i,r?a.slice(2):a)}return o}(i);const a=await n({canonicalIdMap:i}),s=new Map;for(const[e,t]of a)s.set(i.get(e),t);const u=(e,t,n)=>"_:"+s.get(n);return{nquads:o.split("\n").slice(0,-1).map(e=>e.replace(/(_:([^\s]+))/g,u)+"\n").sort(),labelMap:a}}
11
+ /*!
12
+ * Copyright (c) 2023-2026 Digital Bazaar, Inc.
13
+ */({document:e,labelMapFactoryFunction:t,options:n});return r}async function b(e,t){if(!t||"object"!=typeof t)throw new TypeError('"options" must be an object.');if(t={algorithm:"RDFC-1.0",format:"application/n-quads",base:null,safe:!0,...t},"string"!=typeof e){const n={rdfDirection:"i18n-datatype",...t,produceGeneralizedRdf:!1};delete n.format,e=await u.toRDF(e,n)}return f.canonize(e,t)}async function v({document:e,proof:t,options:n,hasher:r}={}){r||(r=y());const o=await async function({document:e,proof:t,options:n}={}){return delete(t={"@context":e["@context"],...t}).proofValue,b(t,n)}({document:e,proof:t,options:n});return r.hash(g(o))}const E=["string","number","bigint","symbol"],M=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function A(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(E.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";const n=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(M.includes(t))return t;return}(e);return n||"Object"}class T{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}}T.uint=new T(0,"uint",!0),T.negint=new T(1,"negint",!0),T.bytes=new T(2,"bytes",!0),T.string=new T(3,"string",!0),T.array=new T(4,"array",!1),T.map=new T(5,"map",!1),T.tag=new T(6,"tag",!1),T.float=new T(7,"float",!0),T.false=new T(7,"false",!0),T.true=new T(7,"true",!0),T.null=new T(7,"null",!0),T.undefined=new T(7,"undefined",!0),T.break=new T(7,"break",!0);class ${constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}}const I=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,S=new TextDecoder,k=new TextEncoder;function U(e){return I&&globalThis.Buffer.isBuffer(e)}const j=I?(e,t,n)=>n-t>64?globalThis.Buffer.from(e.subarray(t,n)).toString("utf8"):R(e,t,n):(e,t,n)=>n-t>64?S.decode(e.subarray(t,n)):R(e,t,n),V=I?e=>e.length>64?globalThis.Buffer.from(e):P(e):e=>e.length>64?k.encode(e):P(e),B=I?(e,t,n)=>U(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n);function P(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t}function R(e,t,n){const r=[];for(;t<n;){const o=e[t];let i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=n){let n,r,s,u;switch(a){case 1:o<128&&(i=o);break;case 2:n=e[t+1],128==(192&n)&&(u=(31&o)<<6|63&n,u>127&&(i=u));break;case 3:n=e[t+1],r=e[t+2],128==(192&n)&&128==(192&r)&&(u=(15&o)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:n=e[t+1],r=e[t+2],s=e[t+3],128==(192&n)&&128==(192&r)&&128==(192&s)&&(u=(15&o)<<18|(63&n)<<12|(63&r)<<6|63&s,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),t+=a}return function(e){const t=e.length;if(t<=N)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=N));return n}(r)}const N=4096;const D="CBOR decode error:",x="CBOR encode error:";function C(e,t,n){if(e.length-t<n)throw new Error(`${D} not enough data for type`)}const O=[24,256,65536,4294967296,BigInt("18446744073709551616")];function F(e,t,n){C(e,t,1);const r=e[t];if(!0===n.strict&&r<O[0])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return r}function K(e,t,n){C(e,t,2);const r=e[t]<<8|e[t+1];if(!0===n.strict&&r<O[1])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return r}function _(e,t,n){C(e,t,4);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(!0===n.strict&&r<O[2])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);return r}function H(e,t,n){C(e,t,8);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=16777216*e[t+4]+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(!0===n.strict&&i<O[3])throw new Error(`${D} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(!0===n.allowBigInt)return i;throw new Error(`${D} integers outside of the safe integer range are not supported`)}function z(e,t){return L(e,0,t.value)}function L(e,t,n){if(n<O[0]){const r=Number(n);e.push([t|r])}else if(n<O[1]){const r=Number(n);e.push([24|t,r])}else if(n<O[2]){const r=Number(n);e.push([25|t,r>>>8,255&r])}else if(n<O[3]){const r=Number(n);e.push([26|t,r>>>24&255,r>>>16&255,r>>>8&255,255&r])}else{const r=BigInt(n);if(!(r<O[4]))throw new Error(`${D} encountered BigInt larger than allowable range`);{const n=[27|t,0,0,0,0,0,0,0];let o=Number(r&BigInt(4294967295)),i=Number(r>>BigInt(32)&BigInt(4294967295));n[8]=255&o,o>>=8,n[7]=255&o,o>>=8,n[6]=255&o,o>>=8,n[5]=255&o,n[4]=255&i,i>>=8,n[3]=255&i,i>>=8,n[2]=255&i,i>>=8,n[1]=255&i,e.push(n)}}}z.encodedSize=function(e){return L.encodedSize(e.value)},L.encodedSize=function(e){return e<O[0]?1:e<O[1]?2:e<O[2]?3:e<O[3]?5:9},z.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};const G=BigInt(-1),Y=BigInt(1);function q(e,t){const n=t.value,r="bigint"==typeof n?n*G-Y:-1*n-1;L(e,t.type.majorEncoded,r)}function W(e,t,n,r){C(e,t,n+r);const o=B(e,t+n,t+n+r);return new $(T.bytes,o,n+r)}function J(e,t,n,r){return W(e,t,1,n)}function X(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===T.string?V(e.value):e.value),e.encodedBytes}function Q(e,t){const n=X(t);L(e,t.type.majorEncoded,n.length),e.push(n)}function Z(e,t,n,r,o){const i=n+r;C(e,t,i);const a=new $(T.string,j(e,t+n,t+i),i);return!0===o.retainStringBytes&&(a.byteValue=B(e,t+n,t+i)),a}function ee(e,t,n,r){return Z(e,t,1,n,r)}q.encodedSize=function(e){const t=e.value,n="bigint"==typeof t?t*G-Y:-1*t-1;return n<O[0]?1:n<O[1]?2:n<O[2]?3:n<O[3]?5:9},q.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0},Q.encodedSize=function(e){const t=X(e);return L.encodedSize(t.length)+t.length},Q.compareTokens=function(e,t){return n=X(e),r=X(t),n.length<r.length?-1:n.length>r.length?1:function(e,t){if(U(e)&&U(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}(n,r);var n,r};const te=Q;function ne(e,t,n,r){return new $(T.array,r,n)}function re(e,t,n,r){return ne(0,0,1,n)}function oe(e,t){L(e,T.array.majorEncoded,t.value)}function ie(e,t,n,r){return new $(T.map,r,n)}function ae(e,t,n,r){return ie(0,0,1,n)}function se(e,t){L(e,T.map.majorEncoded,t.value)}function ue(e,t,n,r){return new $(T.tag,n,1)}function ce(e,t){L(e,T.tag.majorEncoded,t.value)}oe.compareTokens=z.compareTokens,oe.encodedSize=function(e){return L.encodedSize(e.value)},se.compareTokens=z.compareTokens,se.encodedSize=function(e){return L.encodedSize(e.value)},ce.compareTokens=z.compareTokens,ce.encodedSize=function(e){return L.encodedSize(e.value)};function fe(e,t,n){if(n){if(!1===n.allowNaN&&Number.isNaN(e))throw new Error(`${D} NaN values are not supported`);if(!1===n.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${D} Infinity values are not supported`)}return new $(T.float,e,t)}function le(e,t,n){const r=t.value;if(!1===r)e.push([20|T.float.majorEncoded]);else if(!0===r)e.push([21|T.float.majorEncoded]);else if(null===r)e.push([22|T.float.majorEncoded]);else if(void 0===r)e.push([23|T.float.majorEncoded]);else{let t,i=!1;n&&!0===n.float64||(ye(r),t=we(pe,1),r===t||Number.isNaN(r)?(pe[0]=249,e.push(pe.slice(0,3)),i=!0):(ge(r),t=me(pe,1),r===t&&(pe[0]=250,e.push(pe.slice(0,5)),i=!0))),i||(o=r,he.setFloat64(0,o,!1),t=be(pe,1),pe[0]=251,e.push(pe.slice(0,9)))}var o}le.encodedSize=function(e,t){const n=e.value;if(!1===n||!0===n||null==n)return 1;if(!t||!0!==t.float64){ye(n);let e=we(pe,1);if(n===e||Number.isNaN(n))return 3;if(ge(n),e=me(pe,1),n===e)return 5}return 9};const de=new ArrayBuffer(9),he=new DataView(de,1),pe=new Uint8Array(de,0);function ye(e){if(e===1/0)he.setUint16(0,31744,!1);else if(e===-1/0)he.setUint16(0,64512,!1);else if(Number.isNaN(e))he.setUint16(0,32256,!1);else{he.setFloat32(0,e);const t=he.getUint32(0),n=(2139095040&t)>>23,r=8388607&t;if(255===n)he.setUint16(0,31744,!1);else if(0===n)he.setUint16(0,(2147483648&e)>>16|r>>13,!1);else{const e=n-127;e<-24?he.setUint16(0,0):e<-14?he.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):he.setUint16(0,(2147483648&t)>>16|e+15<<10|r>>13,!1)}}}function we(e,t){if(e.length-t<2)throw new Error(`${D} not enough data for float16`);const n=(e[t]<<8)+e[t+1];if(31744===n)return 1/0;if(64512===n)return-1/0;if(32256===n)return NaN;const r=n>>10&31,o=1023&n;let i;return i=0===r?o*2**-24:31!==r?(o+1024)*2**(r-25):0===o?1/0:NaN,32768&n?-i:i}function ge(e){he.setFloat32(0,e,!1)}function me(e,t){if(e.length-t<4)throw new Error(`${D} not enough data for float32`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function be(e,t){if(e.length-t<8)throw new Error(`${D} not enough data for float64`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function ve(e,t,n){throw new Error(`${D} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function Ee(e){return()=>{throw new Error(`${D} ${e}`)}}le.compareTokens=z.compareTokens;const Me=[];for(let e=0;e<=23;e++)Me[e]=ve;Me[24]=function(e,t,n,r){return new $(T.uint,F(e,t+1,r),2)},Me[25]=function(e,t,n,r){return new $(T.uint,K(e,t+1,r),3)},Me[26]=function(e,t,n,r){return new $(T.uint,_(e,t+1,r),5)},Me[27]=function(e,t,n,r){return new $(T.uint,H(e,t+1,r),9)},Me[28]=ve,Me[29]=ve,Me[30]=ve,Me[31]=ve;for(let e=32;e<=55;e++)Me[e]=ve;Me[56]=function(e,t,n,r){return new $(T.negint,-1-F(e,t+1,r),2)},Me[57]=function(e,t,n,r){return new $(T.negint,-1-K(e,t+1,r),3)},Me[58]=function(e,t,n,r){return new $(T.negint,-1-_(e,t+1,r),5)},Me[59]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new $(T.negint,e,9)}if(!0!==r.allowBigInt)throw new Error(`${D} integers outside of the safe integer range are not supported`);return new $(T.negint,G-BigInt(o),9)},Me[60]=ve,Me[61]=ve,Me[62]=ve,Me[63]=ve;for(let e=64;e<=87;e++)Me[e]=J;Me[88]=function(e,t,n,r){return W(e,t,2,F(e,t+1,r))},Me[89]=function(e,t,n,r){return W(e,t,3,K(e,t+1,r))},Me[90]=function(e,t,n,r){return W(e,t,5,_(e,t+1,r))},Me[91]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer bytes lengths not supported`);return W(e,t,9,o)},Me[92]=ve,Me[93]=ve,Me[94]=ve,Me[95]=Ee("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)Me[e]=ee;Me[120]=function(e,t,n,r){return Z(e,t,2,F(e,t+1,r),r)},Me[121]=function(e,t,n,r){return Z(e,t,3,K(e,t+1,r),r)},Me[122]=function(e,t,n,r){return Z(e,t,5,_(e,t+1,r),r)},Me[123]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer string lengths not supported`);return Z(e,t,9,o,r)},Me[124]=ve,Me[125]=ve,Me[126]=ve,Me[127]=Ee("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)Me[e]=re;Me[152]=function(e,t,n,r){return ne(0,0,2,F(e,t+1,r))},Me[153]=function(e,t,n,r){return ne(0,0,3,K(e,t+1,r))},Me[154]=function(e,t,n,r){return ne(0,0,5,_(e,t+1,r))},Me[155]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer array lengths not supported`);return ne(0,0,9,o)},Me[156]=ve,Me[157]=ve,Me[158]=ve,Me[159]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${D} indefinite length items not allowed`);return ne(0,0,1,1/0)};for(let e=160;e<=183;e++)Me[e]=ae;Me[184]=function(e,t,n,r){return ie(0,0,2,F(e,t+1,r))},Me[185]=function(e,t,n,r){return ie(0,0,3,K(e,t+1,r))},Me[186]=function(e,t,n,r){return ie(0,0,5,_(e,t+1,r))},Me[187]=function(e,t,n,r){const o=H(e,t+1,r);if("bigint"==typeof o)throw new Error(`${D} 64-bit integer map lengths not supported`);return ie(0,0,9,o)},Me[188]=ve,Me[189]=ve,Me[190]=ve,Me[191]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${D} indefinite length items not allowed`);return ie(0,0,1,1/0)};for(let e=192;e<=215;e++)Me[e]=ue;Me[216]=function(e,t,n,r){return new $(T.tag,F(e,t+1,r),2)},Me[217]=function(e,t,n,r){return new $(T.tag,K(e,t+1,r),3)},Me[218]=function(e,t,n,r){return new $(T.tag,_(e,t+1,r),5)},Me[219]=function(e,t,n,r){return new $(T.tag,H(e,t+1,r),9)},Me[220]=ve,Me[221]=ve,Me[222]=ve,Me[223]=ve;for(let e=224;e<=243;e++)Me[e]=Ee("simple values are not supported");Me[244]=ve,Me[245]=ve,Me[246]=ve,Me[247]=function(e,t,n,r){if(!1===r.allowUndefined)throw new Error(`${D} undefined values are not supported`);return!0===r.coerceUndefinedToNull?new $(T.null,null,1):new $(T.undefined,void 0,1)},Me[248]=Ee("simple values are not supported"),Me[249]=function(e,t,n,r){return fe(we(e,t+1),3,r)},Me[250]=function(e,t,n,r){return fe(me(e,t+1),5,r)},Me[251]=function(e,t,n,r){return fe(be(e,t+1),9,r)},Me[252]=ve,Me[253]=ve,Me[254]=ve,Me[255]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${D} indefinite length items not allowed`);return new $(T.break,void 0,1)};const Ae=[];for(let e=0;e<24;e++)Ae[e]=new $(T.uint,e,1);for(let e=-1;e>=-24;e--)Ae[31-e]=new $(T.negint,e,1);Ae[64]=new $(T.bytes,new Uint8Array(0),1),Ae[96]=new $(T.string,"",1),Ae[128]=new $(T.array,0,1),Ae[160]=new $(T.map,0,1),Ae[244]=new $(T.false,!1,1),Ae[245]=new $(T.true,!0,1),Ae[246]=new $(T.null,null,1),function(){const e=[];e[T.uint.major]=z,e[T.negint.major]=q,e[T.bytes.major]=Q,e[T.string.major]=te,e[T.array.major]=oe,e[T.map.major]=se,e[T.tag.major]=ce,e[T.float.major]=le}();class Te{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${x} object contains circular references`);return new Te(t,e)}}const $e={null:new $(T.null,null),undefined:new $(T.undefined,void 0),true:new $(T.true,!0),false:new $(T.false,!1),emptyArray:new $(T.array,0),emptyMap:new $(T.map,0)},Ie={number:(e,t,n,r)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new $(e>=0?T.uint:T.negint,e):new $(T.float,e),bigint:(e,t,n,r)=>e>=BigInt(0)?new $(T.uint,e):new $(T.negint,e),Uint8Array:(e,t,n,r)=>new $(T.bytes,e),string:(e,t,n,r)=>new $(T.string,e),boolean:(e,t,n,r)=>e?$e.true:$e.false,null:(e,t,n,r)=>$e.null,undefined:(e,t,n,r)=>$e.undefined,ArrayBuffer:(e,t,n,r)=>new $(T.bytes,new Uint8Array(e)),DataView:(e,t,n,r)=>new $(T.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,n,r){if(!e.length)return!0===n.addBreakTokens?[$e.emptyArray,new $(T.break)]:$e.emptyArray;r=Te.createCheck(r,e);const o=[];let i=0;for(const t of e)o[i++]=Se(t,n,r);return n.addBreakTokens?[new $(T.array,e.length),o,new $(T.break)]:[new $(T.array,e.length),o]},Object(e,t,n,r){const o="Object"!==t,i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return!0===n.addBreakTokens?[$e.emptyMap,new $(T.break)]:$e.emptyMap;r=Te.createCheck(r,e);const s=[];let u=0;for(const t of i)s[u++]=[Se(t,n,r),Se(o?e.get(t):e[t],n,r)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(s,n),n.addBreakTokens?[new $(T.map,a),s,new $(T.break)]:[new $(T.map,a),s]}};Ie.Map=Ie.Object,Ie.Buffer=Ie.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ie[`${e}Array`]=Ie.DataView;function Se(e,t={},n){const r=A(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Ie[r];if("function"==typeof o){const i=o(e,r,t,n);if(null!=i)return i}const i=Ie[r];if(!i)throw new Error(`${x} unsupported type: ${r}`);return i(e,r,t,n)}const ke={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class Ue{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){const e=this.data[this._pos];let t=Ae[e];if(void 0===t){const n=Me[e];if(!n)throw new Error(`${D} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const r=31&e;t=n(this.data,this._pos,r,this.options)}return this._pos+=t.encodedLength,t}}const je=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function Be(e,t){if(e.done())return je;const n=e.next();if(n.type===T.break)return Ve;if(n.type.terminal)return n.value;if(n.type===T.array)return function(e,t,n){const r=[];for(let o=0;o<e.value;o++){const i=Be(t,n);if(i===Ve){if(e.value===1/0)break;throw new Error(`${D} got unexpected break to lengthed array`)}if(i===je)throw new Error(`${D} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}(n,e,t);if(n.type===T.map)return function(e,t,n){const r=!0===n.useMaps,o=r?void 0:{},i=r?new Map:void 0;for(let a=0;a<e.value;a++){const s=Be(t,n);if(s===Ve){if(e.value===1/0)break;throw new Error(`${D} got unexpected break to lengthed map`)}if(s===je)throw new Error(`${D} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!0!==r&&"string"!=typeof s)throw new Error(`${D} non-string keys not supported (got ${typeof s})`);if(!0===n.rejectDuplicateMapKeys&&(r&&i.has(s)||!r&&s in o))throw new Error(`${D} found repeat map key "${s}"`);const u=Be(t,n);if(u===je)throw new Error(`${D} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?i.set(s,u):o[s]=u}return r?i:o}(n,e,t);if(n.type===T.tag){if(t.tags&&"function"==typeof t.tags[n.value]){const r=Be(e,t);return t.tags[n.value](r)}throw new Error(`${D} tag not supported (${n.value})`)}throw new Error("unsupported")}function Pe(e,t){const[n,r]=function(e,t){if(!(e instanceof Uint8Array))throw new Error(`${D} data to decode must be a Uint8Array`);const n=(t=Object.assign({},ke,t)).tokenizer||new Ue(e,t),r=Be(n,t);if(r===je)throw new Error(`${D} did not find any content to decode`);if(r===Ve)throw new Error(`${D} got unexpected break`);return[r,e.subarray(n.pos())]}(e,t);if(r.length>0)throw new Error(`${D} too many terminals, data makes no sense`);return n}
14
+ /*!
15
+ * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
16
+ */const Re=new Uint8Array([217,93,1]),Ne=[];function De({proof:e}={}){try{if("string"!=typeof e?.proofValue)throw new TypeError('"proof.proofValue" must be a string.');if("u"!==e.proofValue[0])throw new Error("Only base64url multibase encoding is supported.");const t=o(e.proofValue.slice(1));if(!function(e,t){for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}(t,Re))throw new TypeError('"proof.proofValue" must be a derived proof.');const n=t.subarray(Re.length),[r,i,s,u,c]=Pe(n,{useMaps:!0,tags:Ne}),f=function(e){const t=new Map;for(const[n,r]of e.entries())t.set(`c14n${n}`,`u${a(r)}`);return t}(u),l={baseSignature:r,publicKey:i,signatures:s,labelMap:f,mandatoryIndexes:c};return function({baseSignature:e,publicKey:t,signatures:n,labelMap:r,mandatoryIndexes:o}){if(!(e instanceof Uint8Array&&64===e.length))throw new TypeError('"baseSignature" must be a Uint8Array of length 64.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!Array.isArray(n)||!n.every(e=>e instanceof Uint8Array))throw new TypeError('"signatures" must be an array of Uint8Arrays.');if(!(r instanceof Map&&[...r.entries()].every(([e,t])=>"string"==typeof e&&"string"==typeof t)))throw new TypeError('"labelMap" must be a Map of strings to strings.');if(!Array.isArray(o)||!o.every(Number.isInteger))throw new TypeError('"mandatoryIndexes" must be an array of integers.')}(l),l}catch(e){const t=new TypeError('The proof does not include a valid "proofValue" property.');throw t.cause=e,t}}function xe({proofHash:e,publicKey:t,mandatoryHash:n}={}){!function({proofHash:e,publicKey:t,mandatoryHash:n}){if(!(e instanceof Uint8Array&&32===e.length))throw new TypeError('"proofHash" must be a Uint8Array of length 32.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!(n instanceof Uint8Array&&32===n.length))throw new TypeError('"mandatoryHash" must be a Uint8Array of length 32.')}({proofHash:e,publicKey:t,mandatoryHash:n});return function(e){const t=new Uint8Array(e.reduce((e,t)=>e+t.length,0));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t}([e,t,n])}Ne[64]=function(e){return e}
17
+ /*!
18
+ * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
19
+ */;const Ce="ecdsa-sd-2023";
20
+ /*!
21
+ * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
22
+ */
23
+ /*!
24
+ * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
25
+ */
26
+ function Oe({requiredAlgorithm:e="P-256"}={}){return{name:Ce,requiredAlgorithm:e,createVerifier:Fe,createVerifyData:Ke}}async function Fe({verificationMethod:e}){const t=(await l(e)).verifier();return{algorithm:t.algorithm,id:t.id,verify:async({data:e})=>async function({verifier:e,data:t}={}){const{baseSignature:n,proofHash:r,publicKey:o,signatures:a,nonMandatory:s,mandatoryHash:u}=t,c="z"+i(o),f=await l({publicKeyMultibase:c});if(a.length!==s.length)throw new Error(`Signature count (${a.length}) does not match non-mandatory message count (${s.length}).`);const{verify:d}=f.verifier();if((await Promise.all(a.map((e,t)=>d({data:g(s[t]),signature:e})))).some(e=>!e))return!1;const h=await xe({proofHash:r,publicKey:o,mandatoryHash:u});return e.verify({data:h,signature:n})}({verifier:t,data:e})}}async function Ke({cryptosuite:e,document:t,proof:n,documentLoader:r}){if(e?.name!==Ce)throw new TypeError(`"cryptosuite.name" must be "${Ce}".`);const o={documentLoader:r},i=v({document:t,proof:n,options:o}).catch(e=>e),{baseSignature:a,publicKey:s,signatures:u,labelMap:c,mandatoryIndexes:f}=await De({proof:n}),l=await function({labelMap:e}={}){return async({canonicalIdMap:t})=>{const n=new Map;for(const[r,o]of t)n.set(r,e.get(o));return n}}({labelMap:c}),d=await m({document:t,labelMapFactoryFunction:l,options:o}),h=[],p=[];for(const[e,t]of d.entries())f.includes(e)?h.push(t):p.push(t);const{mandatoryHash:w}=await async function({mandatory:e,hasher:t}={}){return t||(t=y()),{mandatoryHash:await t.hash(g(e.join("")))}}({mandatory:h}),b=await i;if(b instanceof Error)throw b;return{baseSignature:a,proofHash:b,publicKey:s,signatures:u,nonMandatory:p,mandatoryHash:w}}const{purposes:{AssertionProofPurpose:_e,AuthenticationProofPurpose:He}}=s;var ze;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(ze||(ze={}));class Le extends d{verificationProcess=[ze.retrieveVerificationMethodPublicKey,ze.ensureVerificationMethodValidity,ze.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSd2023";cryptosuite="ecdsa-sd-2023";publicKey;verificationKey;verificationMethod;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:He,assertionMethod:_e},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map(n=>e.verifier.convertToVerificationSubsteps(t,n))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,n){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const e=this.proof.type;if("DataIntegrityProof"===e){const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`);return}if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}generateDocumentLoader(e=[]){e.forEach(e=>{t[e.url]=e.value}),t[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(e){return e in t?{contextUrl:null,document:t[e],documentUrl:e}:u.documentLoader(e)}}getErrorMessage(e){return e.error.errors[0].message}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find(e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod)??null}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(ze.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=h(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),!this.verificationMethod)throw new n(ze.retrieveVerificationMethodPublicKey,"Could not derive the verification key",r.CRYPTOGRAPHIC_SECURITY_ERROR);if(this.verificationMethod.revoked)throw new n(ze.retrieveVerificationMethodPublicKey,"The verification key has been revoked",r.CRYPTOGRAPHIC_SECURITY_ERROR);return this.verificationMethod},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(ze.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(ze.ensureVerificationMethodValidity,"The verification key has expired",r.CRYPTOGRAPHIC_SECURITY_ERROR)}if(this.verificationMethod.revoked)throw new n(ze.ensureVerificationMethodValidity,"The verification key has been revoked",r.CRYPTOGRAPHIC_SECURITY_ERROR)},this.type)}async checkDocumentSignature(){await this.executeStep(ze.checkDocumentSignature,async()=>{const e=new c({cryptosuite:Oe({requiredAlgorithm:"K-256"})}),t=this.documentToVerify.proof.verificationMethod;"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const o=await s.verify(this.documentToVerify,{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader([{url:t,value:this.verificationKey}])});if(!o.verified)throw console.error(JSON.stringify(o,null,2)),new n(ze.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(o)}`,r.PROOF_VERIFICATION_ERROR);console.log(`Credential ${this.type} signature successfully verified`)},this.type)}}export{Le as default};
@@ -0,0 +1 @@
1
+ import{d as e,p as t,a as i,x as o,y as r,E as n,V as s,P as c}from"./main.js";import{j as a}from"./jsonld-signatures-BJXipuab-CB799Kkm.js";import{j as d}from"./jsonld-DOUjwF6J-dtl20tiV.js";import{S as h}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./index-yOIIz7AL-Dgus2xdV.js";import{r as u}from"./retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js";const p="https://ns.did.ai/suites/secp256k1-2019/v1",f="https://www.w3.org/ns/credentials/v2",y=({document:e,contextUrl:t})=>{const i=e["@context"];return Array.isArray(i)?t.some(e=>i.includes(e)):t.includes(i)},l=({document:e})=>{const t=y({document:e,contextUrl:[p,"https://w3id.org/security/suites/secp256k1-2019/v1"]}),i=y({document:e,contextUrl:["https://www.w3.org/2018/credentials/v1"]}),o=y({document:e,contextUrl:[f]}),r=y({document:e,contextUrl:["https://w3id.org/security/v2"]});return t&&i?(console.warn("Warning: The secp256k1-2019/v1 and credentials/v1 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the credentials/v1 context is sufficient."),!1):!t&&o?(console.warn("This library does not (yet) follow the Data Integrity Proof format."),console.warn("When using the credentials/v2 context, consumers need to specify the secp256k1-2019/v1 context."),!1):t&&r?(console.warn("Warning: The secp256k1-2019/v1 and security/v2 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the security/v2 context is sufficient."),!1):t||i||r};let w=class extends a.suites.LinkedDataSignature{requiredKeyType;constructor(e={}){super({type:"EcdsaSecp256k1Signature2019",LDKeyClass:n,contextUrl:p,...e}),this.requiredKeyType="EcdsaSecp256k1VerificationKey2019"}async sign({verifyData:e,proof:t}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");return{...t,jws:await this.signer.sign({data:e})}}async verifySignature({verifyData:e,verificationMethod:t,proof:i}){const{jws:o}=i;if(!o||"string"!=typeof o)throw new TypeError('The proof does not include a valid "jws" property.');let{verifier:r}=this;if(!r){r=(await this.LDKeyClass.from(t)).verifier()}return r.verify({data:e,signature:o})}async assertVerificationMethod({verificationMethod:e}){if(!l({document:e}))throw new TypeError(`The verification method (key) must contain "${this.contextUrl}".`);if(!d.hasValue(e,"type",this.requiredKeyType))throw new Error(`Invalid key type. Key type must be "${this.requiredKeyType}".`);if(void 0!==e.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:e,documentLoader:t}){if(this.key)return this.key.export({publicKey:!0});const i="object"==typeof e.verificationMethod?e.verificationMethod.id:e.verificationMethod;if(!i)throw new Error('No "verificationMethod" found in proof.');const o=await d.frame(i,{"@context":this.contextUrl,"@embed":"@always",id:i},{documentLoader:t,compactToRelative:!1});if(!o)throw new Error(`Verification method ${i} not found.`);if(void 0!==o.revoked)throw new Error("The verification method has been revoked.");return await this.assertVerificationMethod({verificationMethod:o}),o}async matchProof({proof:e,document:t,purpose:i,documentLoader:o,expansionMap:r}){if(!l({document:t}))return!1;if(!await super.matchProof({proof:e,document:t,purpose:i,documentLoader:o,expansionMap:r}))return!1;if(!this.key)return!0;const{verificationMethod:n}=e,s="object"==typeof n?n.id:n;return this.isVerificationMethodMatchingKeyId(s)}ensureSuiteContext({document:e,addSuiteContext:t}){l({document:e})&&!y({document:e,contextUrl:[f]})||super.ensureSuiteContext({document:e,addSuiteContext:t})}isVerificationMethodMatchingKeyId(e){return e===this.key.id||e===`${this.key.controller}${this.key.id}`}};w.CONTEXT_URL=p,w.CONTEXT={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},EcdsaSecp256k1VerificationKey2019:{"@id":"https://w3id.org/security#EcdsaSecp256k1VerificationKey2019","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},blockchainAccountId:{"@id":"https://w3id.org/security#blockchainAccountId"},publicKeyJwk:{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"},publicKeyBase58:{"@id":"https://w3id.org/security#publicKeyBase58"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},EcdsaSecp256k1Signature2019:{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},jws:{"@id":"https://w3id.org/security#jws"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}};const{purposes:{AssertionProofPurpose:g,AuthenticationProofPurpose:m}}=a;var v;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(v||(v={}));class M extends h{verificationProcess=[v.retrieveVerificationMethodPublicKey,v.ensureVerificationMethodValidity,v.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSecp256k1Signature2019";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:m,assertionMethod:g},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map(i=>e.verifier.convertToVerificationSubsteps(t,i))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){t[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(e){return e in t?{contextUrl:null,document:t[e],documentUrl:e}:d.documentLoader(e)}}retrieveInitialDocument(){const e=i(this.documentToVerify);if(Array.isArray(e.proof)){const t=e.proof.find(e=>e.type===this.type);delete e.proof,e.proof=t}return e}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find(e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod)??null}getErrorMessage(e){return e.error.errors[0].message}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(v.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=u(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),this.verificationMethod.publicKeyJwk&&!this.verificationMethod.publicKeyBase58){const e=o(this.verificationMethod.publicKeyJwk);this.verificationMethod.publicKeyBase58=r(e),this.documentToVerify["@context"].includes("https://www.w3.org/ns/credentials/v2")&&!this.documentToVerify["@context"].includes("https://w3id.org/security/suites/secp256k1-2019/v1")&&this.documentToVerify["@context"].push("https://w3id.org/security/suites/secp256k1-2019/v1")}this.publicKey=this.verificationMethod.publicKeyBase58;const e=n.from({...this.verificationMethod});if(!e)throw new s(v.retrieveVerificationMethodPublicKey,"Could not derive the verification key",c.CRYPTOGRAPHIC_SECURITY_ERROR);if(e.revoked)throw new s(v.retrieveVerificationMethodPublicKey,"The verification key has been revoked",c.CRYPTOGRAPHIC_SECURITY_ERROR);return e},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(v.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new s(v.ensureVerificationMethodValidity,"The verification key has expired",c.CRYPTOGRAPHIC_SECURITY_ERROR)}if(this.verificationMethod.revoked)throw new s(v.ensureVerificationMethodValidity,"The verification key has been revoked",c.CRYPTOGRAPHIC_SECURITY_ERROR)},this.type)}async checkDocumentSignature(){await this.executeStep(v.checkDocumentSignature,async()=>{const e=new w({key:this.verificationKey});e.date=new Date(Date.now()).toISOString(),"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const t=await a.verify(this.retrieveInitialDocument(),{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!t.verified)throw console.error(JSON.stringify(t,null,2)),new s(v.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`,c.PROOF_VERIFICATION_ERROR);console.log("Credential Secp256k1 signature successfully verified")},this.type)}}export{M as default};
@@ -1,17 +1,17 @@
1
- import{d as e,s as t,p as i,a as r,V as o,f as n,t as s,u as c,v as a}from"./main.js";import{a as u,j as d}from"./jsonld-DqC1oHcn-ruRlORc0.js";import{f as p,v as y,s as h,g as f}from"./index-OtXtCWrq-CyttRwCk.js";import{S as l}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./_polyfill-node.crypto-MVmI5M_M-exGcp6nW.js";
1
+ import{d as e,t,p as i,a as r,V as o,P as n,f as s,u as a,v as c,w as u}from"./main.js";import{j as d}from"./jsonld-signatures-BJXipuab-CB799Kkm.js";import{j as p}from"./jsonld-DOUjwF6J-dtl20tiV.js";import{f as y,v as h,s as f,g as l}from"./index-C4ZZHHRx-BOdwDnYa.js";import{S as w}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./_polyfill-node.crypto-MVmI5M_M-exGcp6nW.js";
2
2
  /*!
3
3
  * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
4
- */function w({bytes:e,expectedLength:t=32,code:i}){if(!(e instanceof Uint8Array))throw new TypeError('"bytes" must be a Uint8Array.');if(e.length!==t){const e=new Error(`"bytes" must be a ${t}-byte Uint8Array.`);throw e.name="DataError",i&&(e.code=i),e}}
4
+ */function b({bytes:e,expectedLength:t=32,code:i}){if(!(e instanceof Uint8Array))throw new TypeError('"bytes" must be a Uint8Array.');if(e.length!==t){const e=new Error(`"bytes" must be a ${t}-byte Uint8Array.`);throw e.name="DataError",i&&(e.code=i),e}}
5
5
  /*!
6
6
  * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
7
- */const b=globalThis.crypto;if(!b.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');var g={async generateKeyPair(){const e=new Uint8Array(32);b.getRandomValues(e);const t=await v(e);return e.fill(0),t},generateKeyPairFromSeed:v,sign:async(e,t)=>h(t,e.slice(0,32)),verify:async(e,t,i)=>y(i,t,e),sha256digest:async({data:e})=>b.subtle.digest("SHA-256",e)};async function v(e){w({bytes:e,expectedLength:32});const t=await f(e),i=new Uint8Array(64);return i.set(e),i.set(t,e.length),{publicKey:t,secretKey:i}}
7
+ */const g=globalThis.crypto;if(!g.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');var v={async generateKeyPair(){const e=new Uint8Array(32);g.getRandomValues(e);const t=await m(e);return e.fill(0),t},generateKeyPairFromSeed:m,sign:async(e,t)=>f(t,e.slice(0,32)),verify:async(e,t,i)=>h(i,t,e),sha256digest:async({data:e})=>g.subtle.digest("SHA-256",e)};async function m(e){b({bytes:e,expectedLength:32});const t=await l(e),i=new Uint8Array(64);return i.set(e),i.set(t,e.length),{publicKey:t,secretKey:i}}
8
8
  /*!
9
9
  * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
10
- */class m{constructor({id:e,controller:t,revoked:i}={}){this.id=e,this.controller=t,this.revoked=i}static async generate(){throw new Error("Abstract method, must be implemented in subclass.")}static async fromKeyDocument({document:e,checkContext:t=!0,checkRevoked:i=!0}={}){if(!e)throw new TypeError('The "document" parameter is required.');if(t){if(![].concat(e["@context"]).includes(this.SUITE_CONTEXT))throw new Error('Key document does not contain required context "'+this.SUITE_CONTEXT+'".')}if(i&&e.revoked)throw new Error(`Key has been revoked since: "${e.revoked}".`);return this.from(e)}static async from(){throw new Error("Abstract method from() must be implemented in subclass.")}export({publicKey:e=!1,privateKey:t=!1}={}){if(!e&&!t)throw new Error('Export requires specifying either "publicKey" or "privateKey".');const i={id:this.id,type:this.type,controller:this.controller};return this.revoked&&(i.revoked=this.revoked),i}fingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}verifyFingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}signer(){return{async sign({}){throw new Error("Abstract method, must be implemented in subclass.")}}}verifier(){return{async verify({}){throw new Error("Abstract method, must be implemented in subclass.")}}}}m.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";
10
+ */class K{constructor({id:e,controller:t,revoked:i}={}){this.id=e,this.controller=t,this.revoked=i}static async generate(){throw new Error("Abstract method, must be implemented in subclass.")}static async fromKeyDocument({document:e,checkContext:t=!0,checkRevoked:i=!0}={}){if(!e)throw new TypeError('The "document" parameter is required.');if(t){if(![].concat(e["@context"]).includes(this.SUITE_CONTEXT))throw new Error('Key document does not contain required context "'+this.SUITE_CONTEXT+'".')}if(i&&e.revoked)throw new Error(`Key has been revoked since: "${e.revoked}".`);return this.from(e)}static async from(){throw new Error("Abstract method from() must be implemented in subclass.")}export({publicKey:e=!1,privateKey:t=!1}={}){if(!e&&!t)throw new Error('Export requires specifying either "publicKey" or "privateKey".');const i={id:this.id,type:this.type,controller:this.controller};return this.revoked&&(i.revoked=this.revoked),i}fingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}verifyFingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}signer(){return{async sign({}){throw new Error("Abstract method, must be implemented in subclass.")}}}verifier(){return{async verify({}){throw new Error("Abstract method, must be implemented in subclass.")}}}}K.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";
11
11
  /*!
12
12
  * Copyright (c) 2021-2024 Digital Bazaar, Inc. All rights reserved.
13
13
  */
14
- const K="Ed25519VerificationKey2020",M=new Uint8Array([237,1]),E=new Uint8Array([128,38]);class T extends m{constructor(e={}){super(e),this.type=K;const{publicKeyMultibase:t,privateKeyMultibase:i}=e;if(!t)throw new TypeError('The "publicKeyMultibase" property is required.');if(!t||!k(t,M))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${t}".`);if(i&&!k(i,E))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=t,this.privateKeyMultibase=i,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`),w({bytes:this._publicKeyBuffer,code:"invalidPublicKeyLength",expectedLength:32})}static async from(e){return"Ed25519VerificationKey2018"===e.type?T.fromEd25519VerificationKey2018(e):"JsonWebKey"===e.type||"JsonWebKey2020"===e.type?T.fromJsonWebKey(e):new T(e)}static fromEd25519VerificationKey2018({keyPair:e}={}){const t=x(M,n(e.publicKeyBase58)),i=new T({id:e.id,controller:e.controller,publicKeyMultibase:t});return e.privateKeyBase58&&(i.privateKeyMultibase=x(E,n(e.privateKeyBase58))),i}static fromJsonWebKey2020({id:e,type:t,controller:i,publicKeyJwk:r}={}){if("JsonWebKey2020"!==t)throw new TypeError(`Invalid key type: "${t}".`);return T.fromJsonWebKey({id:e,type:t,controller:i,publicKeyJwk:r})}static fromJsonWebKey({id:e,type:t,controller:i,publicKeyJwk:r}={}){if("JsonWebKey"!==t&&"JsonWebKey2020"!==t)throw new TypeError(`Invalid key type: "${t}".`);if(!r)throw new TypeError('"publicKeyJwk" property is required.');const{kty:o,crv:n}=r;if("OKP"!==o)throw new TypeError('"kty" is required to be "OKP".');if("Ed25519"!==n)throw new TypeError('"crv" is required to be "Ed25519".');const{x:c}=r,a=x(M,s(c));return T.from({id:e,controller:i,publicKeyMultibase:a})}static async generate({seed:e,...t}={}){let i;i=e?await g.generateKeyPairFromSeed(e):await g.generateKeyPair();const r=x(M,i.publicKey),o=x(E,i.secretKey);return new T({publicKeyMultibase:r,privateKeyMultibase:o,...t})}static fromFingerprint({fingerprint:e}={}){return new T({publicKeyMultibase:e})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return n(this.publicKeyMultibase.substr(1)).slice(M.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return n(this.privateKeyMultibase.substr(1)).slice(E.length)}fingerprint(){return this.publicKeyMultibase}export({publicKey:e=!1,privateKey:t=!1,includeContext:i=!1}={}){if(!e&&!t)throw new TypeError('Export requires specifying either "publicKey" or "privateKey".');const r={id:this.id,type:this.type};return i&&(r["@context"]=T.SUITE_CONTEXT),this.controller&&(r.controller=this.controller),e&&(r.publicKeyMultibase=this.publicKeyMultibase),t&&(r.privateKeyMultibase=this.privateKeyMultibase),this.revoked&&(r.revoked=this.revoked),r}toJwk({publicKey:e=!0,privateKey:t=!1}={}){if(!e&&!t)throw TypeError('Either a "publicKey" or a "privateKey" is required.');const i={crv:"Ed25519",kty:"OKP"};return e&&(i.x=c(this._publicKeyBuffer)),t&&(i.d=c(this._privateKeyBuffer)),i}async jwkThumbprint(){const e=`{"crv":"Ed25519","kty":"OKP","x":"${c(this._publicKeyBuffer)}"}`,t=(new TextEncoder).encode(e);return c(new Uint8Array(await g.sha256digest({data:t})))}async toJsonWebKey(){return{"@context":"https://w3id.org/security/jwk/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}async toJsonWebKey2020(){return{"@context":"https://w3id.org/security/jws/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey2020",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}verifyFingerprint({fingerprint:e}={}){if("string"!=typeof e||"z"!==e[0])return{error:new Error('"fingerprint" must be a multibase encoded string.'),valid:!1};let t;try{if(t=n(e.substr(1)),!t)throw new TypeError("Invalid encoding of fingerprint.")}catch(e){return{error:e,valid:!1}}const i=function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}(this._publicKeyBuffer,t.slice(2)),r=t[0]===M[0]&&t[1]===M[1]&&i;return r?{valid:r}:{error:new Error("The fingerprint does not match the public key."),valid:!1}}signer(){const e=this._privateKeyBuffer;return{async sign({data:t}){if(!e)throw new Error("A private key is not available for signing.");return g.sign(e,t)},id:this.id}}verifier(){const e=this._publicKeyBuffer;return{async verify({data:t,signature:i}){if(!e)throw new Error("A public key is not available for verifying.");return g.verify(e,t,i)},id:this.id}}}function k(e,t){if("string"!=typeof e||"z"!==e[0])return!1;const i=n(e.slice(1));return t.every((e,t)=>i[t]===e)}function x(e,t){const i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),"z"+a(i)}T.suite=K,T.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var V,P,S=(function(e,t){!function(e,t){for(var i in t)e[i]=t[i]}(t,function(e){var t={};function i(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(r,o,function(t){return e[t]}.bind(null,o));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=2)}([function(e,t,i){
14
+ const E="Ed25519VerificationKey2020",T=new Uint8Array([237,1]),M=new Uint8Array([128,38]);class P extends K{constructor(e={}){super(e),this.type=E;const{publicKeyMultibase:t,privateKeyMultibase:i}=e;if(!t)throw new TypeError('The "publicKeyMultibase" property is required.');if(!t||!k(t,T))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${t}".`);if(i&&!k(i,M))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=t,this.privateKeyMultibase=i,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`),b({bytes:this._publicKeyBuffer,code:"invalidPublicKeyLength",expectedLength:32})}static async from(e){return"Ed25519VerificationKey2018"===e.type?P.fromEd25519VerificationKey2018(e):"JsonWebKey"===e.type||"JsonWebKey2020"===e.type?P.fromJsonWebKey(e):new P(e)}static fromEd25519VerificationKey2018({keyPair:e}={}){const t=x(T,s(e.publicKeyBase58)),i=new P({id:e.id,controller:e.controller,publicKeyMultibase:t});return e.privateKeyBase58&&(i.privateKeyMultibase=x(M,s(e.privateKeyBase58))),i}static fromJsonWebKey2020({id:e,type:t,controller:i,publicKeyJwk:r}={}){if("JsonWebKey2020"!==t)throw new TypeError(`Invalid key type: "${t}".`);return P.fromJsonWebKey({id:e,type:t,controller:i,publicKeyJwk:r})}static fromJsonWebKey({id:e,type:t,controller:i,publicKeyJwk:r}={}){if("JsonWebKey"!==t&&"JsonWebKey2020"!==t)throw new TypeError(`Invalid key type: "${t}".`);if(!r)throw new TypeError('"publicKeyJwk" property is required.');const{kty:o,crv:n}=r;if("OKP"!==o)throw new TypeError('"kty" is required to be "OKP".');if("Ed25519"!==n)throw new TypeError('"crv" is required to be "Ed25519".');const{x:s}=r,c=x(T,a(s));return P.from({id:e,controller:i,publicKeyMultibase:c})}static async generate({seed:e,...t}={}){let i;i=e?await v.generateKeyPairFromSeed(e):await v.generateKeyPair();const r=x(T,i.publicKey),o=x(M,i.secretKey);return new P({publicKeyMultibase:r,privateKeyMultibase:o,...t})}static fromFingerprint({fingerprint:e}={}){return new P({publicKeyMultibase:e})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return s(this.publicKeyMultibase.substr(1)).slice(T.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return s(this.privateKeyMultibase.substr(1)).slice(M.length)}fingerprint(){return this.publicKeyMultibase}export({publicKey:e=!1,privateKey:t=!1,includeContext:i=!1}={}){if(!e&&!t)throw new TypeError('Export requires specifying either "publicKey" or "privateKey".');const r={id:this.id,type:this.type};return i&&(r["@context"]=P.SUITE_CONTEXT),this.controller&&(r.controller=this.controller),e&&(r.publicKeyMultibase=this.publicKeyMultibase),t&&(r.privateKeyMultibase=this.privateKeyMultibase),this.revoked&&(r.revoked=this.revoked),r}toJwk({publicKey:e=!0,privateKey:t=!1}={}){if(!e&&!t)throw TypeError('Either a "publicKey" or a "privateKey" is required.');const i={crv:"Ed25519",kty:"OKP"};return e&&(i.x=c(this._publicKeyBuffer)),t&&(i.d=c(this._privateKeyBuffer)),i}async jwkThumbprint(){const e=`{"crv":"Ed25519","kty":"OKP","x":"${c(this._publicKeyBuffer)}"}`,t=(new TextEncoder).encode(e);return c(new Uint8Array(await v.sha256digest({data:t})))}async toJsonWebKey(){return{"@context":"https://w3id.org/security/jwk/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}async toJsonWebKey2020(){return{"@context":"https://w3id.org/security/jws/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey2020",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}verifyFingerprint({fingerprint:e}={}){if("string"!=typeof e||"z"!==e[0])return{error:new Error('"fingerprint" must be a multibase encoded string.'),valid:!1};let t;try{if(t=s(e.substr(1)),!t)throw new TypeError("Invalid encoding of fingerprint.")}catch(e){return{error:e,valid:!1}}const i=function(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}(this._publicKeyBuffer,t.slice(2)),r=t[0]===T[0]&&t[1]===T[1]&&i;return r?{valid:r}:{error:new Error("The fingerprint does not match the public key."),valid:!1}}signer(){const e=this._privateKeyBuffer;return{async sign({data:t}){if(!e)throw new Error("A private key is not available for signing.");return v.sign(e,t)},id:this.id}}verifier(){const e=this._publicKeyBuffer;return{async verify({data:t,signature:i}){if(!e)throw new Error("A public key is not available for verifying.");return v.verify(e,t,i)},id:this.id}}}function k(e,t){if("string"!=typeof e||"z"!==e[0])return!1;const i=s(e.slice(1));return t.every((e,t)=>i[t]===e)}function x(e,t){const i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),"z"+u(i)}P.suite=E,P.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var V,C,R=(function(e,t){!function(e,t){for(var i in t)e[i]=t[i]}(t,function(e){var t={};function i(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(r,o,function(t){return e[t]}.bind(null,o));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=2)}([function(e,t,i){
15
15
  /*!
16
16
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
17
17
  */
@@ -23,12 +23,12 @@ e.exports={CONTEXT_FILENAME:"ed25519-signature-2020-v1.jsonld",CONTEXT_URL:"http
23
23
  /*!
24
24
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
25
25
  */
26
- const r=i(0),o=i(1),{documentLoader:n}=i(3),{CONTEXT_URL:s,CBORLD_CODEC_VALUE:c}=o,a=new Map;a.set(o.CONTEXT_URL,r);const u=new Map;u.set(s,c),e.exports={constants:o,contexts:a,appContextMap:u,documentLoader:n,CONTEXT_URL:s,CONTEXT:r}},function(e,t,i){
26
+ const r=i(0),o=i(1),{documentLoader:n}=i(3),{CONTEXT_URL:s,CBORLD_CODEC_VALUE:a}=o,c=new Map;c.set(o.CONTEXT_URL,r);const u=new Map;u.set(s,a),e.exports={constants:o,contexts:c,appContextMap:u,documentLoader:n,CONTEXT_URL:s,CONTEXT:r}},function(e,t,i){
27
27
  /*!
28
28
  * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
29
29
  */
30
- const{CONTEXT_URL:r}=i(1),o=i(0);e.exports={documentLoader(e){if(e!==r)throw new Error(`Loading document "${e}" is not allowed.`);return{contextUrl:null,document:o,documentUrl:e}}}}]))}(V={exports:{}},V.exports),V.exports),C=(P=S)&&P.__esModule&&Object.prototype.hasOwnProperty.call(P,"default")?P.default:P;S.contexts,S.constants,S.CONTEXT,S.CONTEXT_URL,S.appContextMap,S.documentLoader;
30
+ const{CONTEXT_URL:r}=i(1),o=i(0);e.exports={documentLoader(e){if(e!==r)throw new Error(`Loading document "${e}" is not allowed.`);return{contextUrl:null,document:o,documentUrl:e}}}}]))}(V={exports:{}},V.exports),V.exports),O=(C=R)&&C.__esModule&&Object.prototype.hasOwnProperty.call(C,"default")?C.default:C;R.contexts,R.constants,R.CONTEXT,R.CONTEXT_URL,R.appContextMap,R.documentLoader;
31
31
  /*!
32
32
  * Copyright (c) 2020-2024 Digital Bazaar, Inc. All rights reserved.
33
33
  */
34
- const{suites:{LinkedDataSignature:O}}=u,D=C.constants.CONTEXT_URL;let L=class extends O{constructor({key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}={}){super({type:"Ed25519Signature2020",LDKeyClass:T,contextUrl:D,key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:e,proof:t}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const i=await this.signer.sign({data:e});return t.proofValue="z"+a(i),t}async verifySignature({verifyData:e,verificationMethod:t,proof:i}){const{proofValue:r}=i;if(!r||"string"!=typeof r)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==r[0])throw new Error("Only base58btc multibase encoding is supported.");const o=n(r.substr(1));let{verifier:s}=this;if(!s){s=(await p(t)).verifier()}return s.verify({data:e,signature:o})}async assertVerificationMethod({verificationMethod:e}){let t;if("Ed25519VerificationKey2020"!==e.type)throw new Error(`Unsupported key type "${e.type}".`);if(t=D,!_({document:e,contextUrl:t}))throw new TypeError(`The verification method (key) must contain "${t}" context.`);if(void 0!==e.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:e,documentLoader:t}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:i}=e;if("object"==typeof i&&(i=i.id),!i)throw new Error('No "verificationMethod" found in proof.');const{document:r}=await t(i);i="string"==typeof r?JSON.parse(r):r;const o=await p(i);return i={...await o.export({publicKey:!0,includeContext:!0}),"@context":D,type:"Ed25519VerificationKey2020"},await this.assertVerificationMethod({verificationMethod:i}),i}async matchProof({proof:e,document:t,purpose:i,documentLoader:r}){if(!_({document:t,contextUrl:D}))return!1;if(!await super.matchProof({proof:e,document:t,purpose:i,documentLoader:r}))return!1;if(!this.key)return!0;const{verificationMethod:o}=e;return"object"==typeof o?o.id===this.key.id:o===this.key.id}};function _({document:e,contextUrl:t}){const i=e["@context"];return i===t||Array.isArray(i)&&i.includes(t)}L.CONTEXT_URL=D,L.CONTEXT=C.contexts.get(D);const{purposes:{AssertionProofPurpose:U,AuthenticationProofPurpose:A}}=u;var J;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(J||(J={}));class I extends l{verificationProcess=[J.retrieveVerificationMethodPublicKey,J.ensureVerificationMethodValidity,J.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:A,assertionMethod:U},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map(i=>e.verifier.convertToVerificationSubsteps(t,i))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}publicKeyJwkToString(e){return t(e.publicKeyJwk)}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){i[this.documentToVerify.issuer]=this.issuer.didDocument;return function(e){return e in i?{contextUrl:null,document:i[e],documentUrl:e}:d.documentLoader(e)}}retrieveInitialDocument(){const e=r(this.documentToVerify);if(Array.isArray(e.proof)){const t=e.proof.find(e=>e.type===this.type);delete e.proof,e.proof=t}return delete e.didDocument,e}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find(e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod)??null}getErrorMessage(e){return e.error.errors[0].message}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(J.retrieveVerificationMethodPublicKey,async()=>{const e=this.getTargetVerificationMethodContainer();if(!e)throw new o(J.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");if(this.verificationMethod=this.findVerificationMethod(e.verificationMethod,e.id),!this.verificationMethod)throw new o(J.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=this.verificationMethod.publicKeyMultibase??this.publicKeyJwkToString(this.verificationMethod)}catch(e){console.error("ERROR retrieving Ed25519Signature2020 public key",e)}const t=await T.from({...this.verificationMethod});if(!t)throw new o(J.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(t.revoked)throw new o(J.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return t},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(J.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new o(J.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new o(J.ensureVerificationMethodValidity,"The verification key has been revoked")},this.type)}async checkDocumentSignature(){await this.executeStep(J.checkDocumentSignature,async()=>{const e=new L({key:this.verificationKey});e.date=new Date(Date.now()).toISOString(),"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const t=await u.verify(this.retrieveInitialDocument(),{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!t.verified)throw console.error(JSON.stringify(t,null,2)),new o(J.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`);console.log("Credential Ed25519 signature successfully verified")},this.type)}}export{I as default};
34
+ const{suites:{LinkedDataSignature:S}}=d,_=O.constants.CONTEXT_URL;let U=class extends S{constructor({key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}={}){super({type:"Ed25519Signature2020",LDKeyClass:P,contextUrl:_,key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:e,proof:t}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const i=await this.signer.sign({data:e});return t.proofValue="z"+u(i),t}async verifySignature({verifyData:e,verificationMethod:t,proof:i}){const{proofValue:r}=i;if(!r||"string"!=typeof r)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==r[0])throw new Error("Only base58btc multibase encoding is supported.");const o=s(r.substr(1));let{verifier:n}=this;if(!n){n=(await y(t)).verifier()}return n.verify({data:e,signature:o})}async assertVerificationMethod({verificationMethod:e}){let t;if("Ed25519VerificationKey2020"!==e.type)throw new Error(`Unsupported key type "${e.type}".`);if(t=_,!I({document:e,contextUrl:t}))throw new TypeError(`The verification method (key) must contain "${t}" context.`);if(void 0!==e.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:e,documentLoader:t}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:i}=e;if("object"==typeof i&&(i=i.id),!i)throw new Error('No "verificationMethod" found in proof.');const{document:r}=await t(i);i="string"==typeof r?JSON.parse(r):r;const o=await y(i);return i={...await o.export({publicKey:!0,includeContext:!0}),"@context":_,type:"Ed25519VerificationKey2020"},await this.assertVerificationMethod({verificationMethod:i}),i}async matchProof({proof:e,document:t,purpose:i,documentLoader:r}){if(!I({document:t,contextUrl:_}))return!1;if(!await super.matchProof({proof:e,document:t,purpose:i,documentLoader:r}))return!1;if(!this.key)return!0;const{verificationMethod:o}=e;return"object"==typeof o?o.id===this.key.id:o===this.key.id}};function I({document:e,contextUrl:t}){const i=e["@context"];return i===t||Array.isArray(i)&&i.includes(t)}U.CONTEXT_URL=_,U.CONTEXT=O.contexts.get(_);const{purposes:{AssertionProofPurpose:A,AuthenticationProofPurpose:D}}=d;var L;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(L||(L={}));class J extends w{verificationProcess=[L.retrieveVerificationMethodPublicKey,L.ensureVerificationMethodValidity,L.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:D,assertionMethod:A},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map(i=>e.verifier.convertToVerificationSubsteps(t,i))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}publicKeyJwkToString(e){return t(e.publicKeyJwk)}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){i[this.documentToVerify.issuer]=this.issuer.didDocument;return function(e){return e in i?{contextUrl:null,document:i[e],documentUrl:e}:p.documentLoader(e)}}retrieveInitialDocument(){const e=r(this.documentToVerify);if(Array.isArray(e.proof)){const t=e.proof.find(e=>e.type===this.type);delete e.proof,e.proof=t}return delete e.didDocument,e}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find(e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod)??null}getErrorMessage(e){return e.error.errors[0].message}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(L.retrieveVerificationMethodPublicKey,async()=>{const e=this.getTargetVerificationMethodContainer();if(!e)throw new o(L.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.",n.CRYPTOGRAPHIC_SECURITY_ERROR);if(this.verificationMethod=this.findVerificationMethod(e.verificationMethod,e.id),!this.verificationMethod)throw new o(L.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.",n.CRYPTOGRAPHIC_SECURITY_ERROR);try{this.publicKey=this.verificationMethod.publicKeyMultibase??this.publicKeyJwkToString(this.verificationMethod)}catch(e){console.error("ERROR retrieving Ed25519Signature2020 public key",e)}const t=await P.from({...this.verificationMethod});if(!t)throw new o(L.retrieveVerificationMethodPublicKey,"Could not derive the verification key",n.CRYPTOGRAPHIC_SECURITY_ERROR);if(t.revoked)throw new o(L.retrieveVerificationMethodPublicKey,"The verification key has been revoked",n.CRYPTOGRAPHIC_SECURITY_ERROR);return t},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(L.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new o(L.ensureVerificationMethodValidity,"The verification key has expired",n.CRYPTOGRAPHIC_SECURITY_ERROR)}if(this.verificationMethod.revoked)throw new o(L.ensureVerificationMethodValidity,"The verification key has been revoked",n.CRYPTOGRAPHIC_SECURITY_ERROR)},this.type)}async checkDocumentSignature(){await this.executeStep(L.checkDocumentSignature,async()=>{const e=new U({key:this.verificationKey});e.date=new Date(Date.now()).toISOString(),"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const t=await d.verify(this.retrieveInitialDocument(),{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!t.verified)throw console.error(JSON.stringify(t,null,2)),new o(L.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`,n.PROOF_VERIFICATION_ERROR);console.log("Credential Ed25519 signature successfully verified")},this.type)}}export{J as default};