@blockcerts/blockcerts-verifier 1.72.3 → 1.72.4

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 (34) hide show
  1. package/bundle-stats.html +1 -1
  2. package/coverage/lcov.info +93 -93
  3. package/dist/{DataIntegrityProof-BhL7Kkhm-affsdujn.js → DataIntegrityProof-x-pKdBCc-B_YUlE0Z.js} +1 -1
  4. package/dist/{EcdsaSd2023-CUjrjGzC-Cx7ejHu-.js → EcdsaSd2023-CU35O_1w-CISk0lEt.js} +6 -6
  5. package/dist/{EcdsaSecp256k1Signature2019-D90cAynb-Bf5kILPF.js → EcdsaSecp256k1Signature2019-DiXIv8yq-B2kEN_Qo.js} +1 -1
  6. package/dist/{Ed25519Signature2020-fJGvlbIp-B6XhFwr4.js → Ed25519Signature2020-B6yblwC5-BRlzT2Yc.js} +5 -5
  7. package/dist/EddsaRdfc2022-Csk9U_qt-B798omlR.js +14 -0
  8. package/dist/{HashlinkVerifier-udsj5z09-BTqOkVoD.js → HashlinkVerifier-Bi7nn19S-DMjUYzMR.js} +1 -1
  9. package/dist/{MerkleProof2017-C0RhRNNx-zjQMRSQY.js → MerkleProof2017-BIJKwMk5-CLYAJK4G.js} +1 -1
  10. package/dist/{MerkleProof2019-B7f1hhem-CjLDyx6Q.js → MerkleProof2019-CeAt2OGM-DOuISx_E.js} +1 -1
  11. package/dist/_polyfill-node.crypto-MVmI5M_M-exGcp6nW.js +1 -0
  12. package/dist/{checkCredentialSchemaConformity-CgpOS3eC-AjSPoJub.js → checkCredentialSchemaConformity-CECtM4WI-C1vg05zb.js} +1 -1
  13. package/dist/{checkRevocationStatusList2021-D4VNDRlW-DgNfOAoI.js → checkRevocationStatusList2021-B7NFlV-5-C3Zng1tA.js} +1 -1
  14. package/dist/controlVerificationMethod-Cuyek_Vk-C_Uq2iA5.js +1 -0
  15. package/dist/{index-DjD0A6uJ-BdFUkPCF.js → index-D7PA_QcD-CyttRwCk.js} +4 -4
  16. package/dist/{index-DZ7aUhT_-D0G2DVsh.js → index-DFOHyoZq-BCuOIg2Z.js} +11 -11
  17. package/dist/{jsonld-signatures-D4X_Irzi-D_wBqxSl.js → jsonld-signatures-BtZPa7MV-DTekMXP5.js} +2 -2
  18. package/dist/main.js +10 -10
  19. package/dist/{retrieveVerificationMethodPublicKey-D_autuwE-DGbK-RPm.js → retrieveVerificationMethodPublicKey-DcEGtx_h-D1zuvtQB.js} +1 -1
  20. package/dist/verifyIssuerProfile-DQji41Fc-l31-7imR.js +1 -0
  21. package/dist/webcrypto.es-aoUxIxUm-gGk5JRJH.js +40 -0
  22. package/package.json +2 -2
  23. package/dist/EddsaRdfc2022-XufziFi3-D5IoKiRE.js +0 -14
  24. package/dist/_polyfill-node.crypto-DGISCHrB-C5-OOGc0.js +0 -1
  25. package/dist/controlVerificationMethod-CSwPoUL8-CvUADmjg.js +0 -1
  26. package/dist/ed25519-key-pair.esm-DxoBwwVJ-D8j8wFfG.js +0 -1
  27. package/dist/tslib.es6--gQC4x5c-CmLYFWVC.js +0 -1
  28. package/dist/verifyIssuerProfile-2PhdMtQZ-CfqcAkBL.js +0 -1
  29. package/dist/webcrypto.es-BOyMRPOj-CAxP3jJR.js +0 -40
  30. /package/dist/{Suite-Bu3gszvt-Dmvbh142.js → Suite-CBLHluYK-Dmvbh142.js} +0 -0
  31. /package/dist/{ensureNotRevoked-ByWaYoog-BheL-ZKZ.js → ensureNotRevoked-CNUfpW4F-BheL-ZKZ.js} +0 -0
  32. /package/dist/{ensureValidIssuingKey-DEV9E0Ph-DY8BTObG.js → ensureValidIssuingKey-DN2kpCwj-DY8BTObG.js} +0 -0
  33. /package/dist/{index-CyNtT_1q-Dgus2xdV.js → index-6G1g4ypj-Dgus2xdV.js} +0 -0
  34. /package/dist/{index-tlZQQ_rg-CYTlxhyY.js → index-DNlz8u7B-CYTlxhyY.js} +0 -0
@@ -2274,13 +2274,13 @@ FN:22,(anonymous_3)
2274
2274
  FNF:4
2275
2275
  FNH:4
2276
2276
  FNDA:681,dispatchActionsFactory
2277
- FNDA:40,dispatchActions
2277
+ FNDA:50,dispatchActions
2278
2278
  FNDA:681,stepVerified
2279
2279
  FNDA:681,(anonymous_3)
2280
2280
  DA:8,39
2281
2281
  DA:11,681
2282
- DA:12,40
2283
- DA:17,40
2282
+ DA:12,50
2283
+ DA:17,50
2284
2284
  DA:22,681
2285
2285
  DA:23,681
2286
2286
  DA:24,681
@@ -2398,69 +2398,69 @@ FN:45,updateParentStepStatus
2398
2398
  FN:46,(anonymous_9)
2399
2399
  FNF:10
2400
2400
  FNH:10
2401
- FNDA:228,stepVerificationIsSuccessful
2402
- FNDA:328,stepVerificationIsFailure
2403
- FNDA:23,oneChildIsSuccess
2404
- FNDA:20,(anonymous_3)
2405
- FNDA:37,allChildrenAreSuccess
2406
- FNDA:30,(anonymous_5)
2407
- FNDA:48,oneChildIsFailure
2408
- FNDA:41,(anonymous_7)
2409
- FNDA:48,updateParentStepStatus
2410
- FNDA:48,(anonymous_9)
2411
- DA:9,228
2412
- DA:13,328
2413
- DA:17,23
2414
- DA:18,23
2415
- DA:19,20
2416
- DA:21,23
2417
- DA:25,37
2418
- DA:26,37
2419
- DA:27,30
2420
- DA:29,37
2421
- DA:33,48
2422
- DA:34,48
2423
- DA:35,41
2424
- DA:37,48
2425
- DA:46,48
2426
- DA:47,48
2401
+ FNDA:278,stepVerificationIsSuccessful
2402
+ FNDA:408,stepVerificationIsFailure
2403
+ FNDA:25,oneChildIsSuccess
2404
+ FNDA:22,(anonymous_3)
2405
+ FNDA:47,allChildrenAreSuccess
2406
+ FNDA:40,(anonymous_5)
2407
+ FNDA:58,oneChildIsFailure
2408
+ FNDA:51,(anonymous_7)
2409
+ FNDA:58,updateParentStepStatus
2410
+ FNDA:58,(anonymous_9)
2411
+ DA:9,278
2412
+ DA:13,408
2413
+ DA:17,25
2414
+ DA:18,25
2415
+ DA:19,22
2416
+ DA:21,25
2417
+ DA:25,47
2418
+ DA:26,47
2419
+ DA:27,40
2420
+ DA:29,47
2421
+ DA:33,58
2422
+ DA:34,58
2423
+ DA:35,51
2424
+ DA:37,58
2425
+ DA:46,58
2426
+ DA:47,58
2427
2427
  DA:48,0
2428
- DA:51,48
2429
- DA:53,48
2430
- DA:54,48
2431
- DA:56,48
2432
- DA:57,12
2433
- DA:60,48
2428
+ DA:51,58
2429
+ DA:53,58
2430
+ DA:54,58
2431
+ DA:56,58
2432
+ DA:57,14
2433
+ DA:60,58
2434
2434
  DA:61,7
2435
- DA:64,48
2435
+ DA:64,58
2436
2436
  DA:65,2
2437
- DA:68,48
2437
+ DA:68,58
2438
2438
  LF:27
2439
2439
  LH:26
2440
- BRDA:18,0,0,20
2440
+ BRDA:18,0,0,22
2441
2441
  BRDA:18,0,1,3
2442
- BRDA:21,1,0,23
2442
+ BRDA:21,1,0,25
2443
2443
  BRDA:21,1,1,11
2444
- BRDA:26,2,0,30
2444
+ BRDA:26,2,0,40
2445
2445
  BRDA:26,2,1,7
2446
- BRDA:29,3,0,37
2446
+ BRDA:29,3,0,47
2447
2447
  BRDA:29,3,1,11
2448
- BRDA:34,4,0,41
2448
+ BRDA:34,4,0,51
2449
2449
  BRDA:34,4,1,7
2450
- BRDA:37,5,0,48
2451
- BRDA:37,5,1,46
2450
+ BRDA:37,5,0,58
2451
+ BRDA:37,5,1,56
2452
2452
  BRDA:47,6,0,0
2453
- BRDA:47,6,1,48
2454
- BRDA:56,7,0,12
2455
- BRDA:56,7,1,36
2456
- BRDA:56,8,0,48
2457
- BRDA:56,8,1,23
2453
+ BRDA:47,6,1,58
2454
+ BRDA:56,7,0,14
2455
+ BRDA:56,7,1,44
2456
+ BRDA:56,8,0,58
2457
+ BRDA:56,8,1,25
2458
2458
  BRDA:60,9,0,7
2459
- BRDA:60,9,1,41
2460
- BRDA:60,10,0,48
2461
- BRDA:60,10,1,37
2459
+ BRDA:60,9,1,51
2460
+ BRDA:60,10,0,58
2461
+ BRDA:60,10,1,47
2462
2462
  BRDA:64,11,0,2
2463
- BRDA:64,11,1,46
2463
+ BRDA:64,11,1,56
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:681,(anonymous_2)
5028
- FNDA:42,(anonymous_3)
5028
+ FNDA:52,(anonymous_3)
5029
5029
  FNDA:681,(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,681
5038
5038
  DA:23,681
5039
- DA:28,42
5040
- DA:29,42
5041
- DA:30,40
5039
+ DA:28,52
5040
+ DA:29,52
5041
+ DA:30,50
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,681
5053
5053
  BRDA:22,0,1,0
5054
- BRDA:29,1,0,40
5054
+ BRDA:29,1,0,50
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:1378,app
5525
- DA:19,1378
5524
+ FNDA:1398,app
5525
+ DA:19,1398
5526
5526
  DA:21,86
5527
5527
  DA:24,22
5528
5528
  DA:27,149
5529
5529
  DA:30,11
5530
5530
  DA:33,6
5531
- DA:36,48
5531
+ DA:36,58
5532
5532
  DA:39,12
5533
5533
  DA:42,165
5534
5534
  DA:45,152
5535
- DA:48,40
5535
+ DA:48,50
5536
5536
  DA:51,156
5537
5537
  DA:54,83
5538
5538
  DA:57,0
@@ -5544,11 +5544,11 @@ BRDA:19,0,1,22
5544
5544
  BRDA:19,0,2,149
5545
5545
  BRDA:19,0,3,11
5546
5546
  BRDA:19,0,4,6
5547
- BRDA:19,0,5,48
5547
+ BRDA:19,0,5,58
5548
5548
  BRDA:19,0,6,12
5549
5549
  BRDA:19,0,7,165
5550
5550
  BRDA:19,0,8,152
5551
- BRDA:19,0,9,40
5551
+ BRDA:19,0,9,50
5552
5552
  BRDA:19,0,10,156
5553
5553
  BRDA:19,0,11,83
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:40,updateSubstepIn
5617
+ FNDA:50,updateSubstepIn
5618
5618
  FNDA:6,(anonymous_1)
5619
- FNDA:36,(anonymous_2)
5620
- FNDA:108,(anonymous_3)
5621
- FNDA:40,stepVerified
5622
- DA:7,40
5623
- DA:8,40
5619
+ FNDA:46,(anonymous_2)
5620
+ FNDA:146,(anonymous_3)
5621
+ FNDA:50,stepVerified
5622
+ DA:7,50
5623
+ DA:8,50
5624
5624
  DA:9,4
5625
5625
  DA:10,4
5626
- DA:12,36
5627
- DA:13,36
5628
- DA:14,108
5629
- DA:15,36
5630
- DA:16,36
5631
- DA:23,40
5632
- DA:24,40
5633
- DA:25,40
5634
- DA:27,40
5626
+ DA:12,46
5627
+ DA:13,46
5628
+ DA:14,146
5629
+ DA:15,46
5630
+ DA:16,46
5631
+ DA:23,50
5632
+ DA:24,50
5633
+ DA:25,50
5634
+ DA:27,50
5635
5635
  LF:13
5636
5636
  LH:13
5637
5637
  BRDA:8,0,0,4
5638
- BRDA:8,0,1,36
5639
- BRDA:12,1,0,36
5638
+ BRDA:8,0,1,46
5639
+ BRDA:12,1,0,46
5640
5640
  BRDA:12,1,1,0
5641
- BRDA:15,2,0,36
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:48,updateParentStepStatus
5702
- DA:7,48
5703
- DA:9,48
5704
- DA:11,48
5705
- DA:13,48
5701
+ FNDA:58,updateParentStepStatus
5702
+ DA:7,58
5703
+ DA:9,58
5704
+ DA:11,58
5705
+ DA:13,58
5706
5706
  LF:4
5707
5707
  LH:4
5708
5708
  BRF:0
@@ -5972,9 +5972,9 @@ FNDA:25,(anonymous_27)
5972
5972
  FNDA:15,isTestChain
5973
5973
  FNDA:11,(anonymous_29)
5974
5974
  FNDA:0,isTestChainAtIndex
5975
- FNDA:168,getVerifiedSteps
5976
- FNDA:140,getParentStep
5977
- FNDA:160,(anonymous_33)
5975
+ FNDA:198,getVerifiedSteps
5976
+ FNDA:170,getParentStep
5977
+ FNDA:190,(anonymous_33)
5978
5978
  FNDA:1,getStartedVerificationSteps
5979
5979
  FNDA:2,(anonymous_35)
5980
5980
  FNDA:5,getHasError
@@ -6126,8 +6126,8 @@ DA:321,0
6126
6126
  DA:322,0
6127
6127
  DA:323,0
6128
6128
  DA:325,0
6129
- DA:329,168
6130
- DA:334,160
6129
+ DA:329,198
6130
+ DA:334,190
6131
6131
  DA:338,1
6132
6132
  DA:340,2
6133
6133
  DA:344,9
@@ -6260,7 +6260,7 @@ BRDA:322,41,0,0
6260
6260
  BRDA:322,41,1,0
6261
6261
  BRDA:325,42,0,0
6262
6262
  BRDA:325,42,1,0
6263
- BRDA:329,43,0,168
6263
+ BRDA:329,43,0,198
6264
6264
  BRDA:329,43,1,0
6265
6265
  BRDA:379,44,0,0
6266
6266
  BRDA:379,44,1,12
@@ -1,4 +1,4 @@
1
- import{r as t}from"./Suite-Bu3gszvt-Dmvbh142.js";import{u as e,f as r,s as o}from"./main.js";import{j as i}from"./jsonld-signatures-D4X_Irzi-D_wBqxSl.js";var n=t();
1
+ import{r as t}from"./Suite-CBLHluYK-Dmvbh142.js";import{v as e,f as r,t as o}from"./main.js";import{j as i}from"./jsonld-signatures-BtZPa7MV-DTekMXP5.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))}
@@ -1,4 +1,4 @@
1
- import{d as e,p as t,V as n,s as r,u as o,t as i}from"./main.js";import{j as a}from"./jsonld-signatures-D4X_Irzi-D_wBqxSl.js";import{S as s,j as u}from"./Suite-Bu3gszvt-Dmvbh142.js";import{D as c,r as f}from"./DataIntegrityProof-BhL7Kkhm-affsdujn.js";import{f as l}from"./index-DZ7aUhT_-D0G2DVsh.js";import"./pako.esm-BGRKTPxS-Bodm4Eha.js";import"./index-CyNtT_1q-Dgus2xdV.js";import{r as d}from"./retrieveVerificationMethodPublicKey-D_autuwE-DGbK-RPm.js";import"./sha2-JcCWfgvE-By1_saxP.js";
1
+ import{d as e,p as t,V as n,t as r,v as o,u as i}from"./main.js";import{j as a}from"./jsonld-signatures-BtZPa7MV-DTekMXP5.js";import{S as s,j as u}from"./Suite-CBLHluYK-Dmvbh142.js";import{D as c,r as f}from"./DataIntegrityProof-x-pKdBCc-B_YUlE0Z.js";import{f as l}from"./index-DFOHyoZq-BCuOIg2Z.js";import"./pako.esm-BGRKTPxS-Bodm4Eha.js";import"./index-6G1g4ypj-Dgus2xdV.js";import{r as d}from"./retrieveVerificationMethodPublicKey-DcEGtx_h-D1zuvtQB.js";import"./sha2-JcCWfgvE-By1_saxP.js";
2
2
  /*!
3
3
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
4
4
  */
@@ -8,16 +8,16 @@ const h=globalThis.crypto;
8
8
  */function p({algorithm:e="sha256"}={}){if("sha256"!==e)throw new Error(`Unsupported algorithm "${e}".`);return{hash:async e=>new Uint8Array(await h.subtle.digest("SHA-256",e))}}
9
9
  /*!
10
10
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
11
- */const y=new TextEncoder;function w(e){return y.encode(e)}
11
+ */const y=new TextEncoder;function g(e){return y.encode(e)}
12
12
  /*!
13
13
  * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
14
- */async function g({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 m(e,{...r,canonicalIdMap:i}):await m(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}}
14
+ */async function w({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 m(e,{...r,canonicalIdMap:i}):await m(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}}
15
15
  /*!
16
16
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
17
- */({document:e,labelMapFactoryFunction:t,options:n});return r}async function m(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 b({document:e,proof:t,options:n,hasher:r}={}){r||(r=p());const o=await async function({document:e,proof:t,options:n}={}){return delete(t={"@context":e["@context"],...t}).proofValue,m(t,n)}({document:e,proof:t,options:n});return r.hash(w(o))}const v=["string","number","bigint","symbol"],E=["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 M(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(v.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(E.includes(t))return t;return}(e);return n||"Object"}class ${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}}$.uint=new $(0,"uint",!0),$.negint=new $(1,"negint",!0),$.bytes=new $(2,"bytes",!0),$.string=new $(3,"string",!0),$.array=new $(4,"array",!1),$.map=new $(5,"map",!1),$.tag=new $(6,"tag",!1),$.float=new $(7,"float",!0),$.false=new $(7,"false",!0),$.true=new $(7,"true",!0),$.null=new $(7,"null",!0),$.undefined=new $(7,"undefined",!0),$.break=new $(7,"break",!0);class A{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 T=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,S=new TextDecoder,k=new TextEncoder;function I(e){return T&&globalThis.Buffer.isBuffer(e)}const j=T?(e,t,n)=>n-t>64?globalThis.Buffer.from(e.subarray(t,n)).toString("utf8"):N(e,t,n):(e,t,n)=>n-t>64?S.decode(e.subarray(t,n)):N(e,t,n),V=T?e=>e.length>64?globalThis.Buffer.from(e):B(e):e=>e.length>64?k.encode(e):B(e),U=T?(e,t,n)=>I(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n);function B(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 N(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<=D)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=D));return n}(r)}const D=4096;const x="CBOR decode error:",P="CBOR encode error:";function K(e,t,n){if(e.length-t<n)throw new Error(`${x} not enough data for type`)}const F=[24,256,65536,4294967296,BigInt("18446744073709551616")];function C(e,t,n){K(e,t,1);const r=e[t];if(!0===n.strict&&r<F[0])throw new Error(`${x} integer encoded in more bytes than necessary (strict decode)`);return r}function z(e,t,n){K(e,t,2);const r=e[t]<<8|e[t+1];if(!0===n.strict&&r<F[1])throw new Error(`${x} integer encoded in more bytes than necessary (strict decode)`);return r}function H(e,t,n){K(e,t,4);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(!0===n.strict&&r<F[2])throw new Error(`${x} integer encoded in more bytes than necessary (strict decode)`);return r}function _(e,t,n){K(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<F[3])throw new Error(`${x} 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(`${x} integers outside of the safe integer range are not supported`)}function O(e,t){return L(e,0,t.value)}function L(e,t,n){if(n<F[0]){const r=Number(n);e.push([t|r])}else if(n<F[1]){const r=Number(n);e.push([24|t,r])}else if(n<F[2]){const r=Number(n);e.push([25|t,r>>>8,255&r])}else if(n<F[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<F[4]))throw new Error(`${x} 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)}}}O.encodedSize=function(e){return L.encodedSize(e.value)},L.encodedSize=function(e){return e<F[0]?1:e<F[1]?2:e<F[2]?3:e<F[3]?5:9},O.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};const R=BigInt(-1),G=BigInt(1);function q(e,t){const n=t.value,r="bigint"==typeof n?n*R-G:-1*n-1;L(e,t.type.majorEncoded,r)}function W(e,t,n,r){K(e,t,n+r);const o=U(e,t+n,t+n+r);return new A($.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===$.string?V(e.value):e.value),e.encodedBytes}function Z(e,t){const n=X(t);L(e,t.type.majorEncoded,n.length),e.push(n)}function Q(e,t,n,r,o){const i=n+r;K(e,t,i);const a=new A($.string,j(e,t+n,t+i),i);return!0===o.retainStringBytes&&(a.byteValue=U(e,t+n,t+i)),a}function Y(e,t,n,r){return Q(e,t,1,n,r)}q.encodedSize=function(e){const t=e.value,n="bigint"==typeof t?t*R-G:-1*t-1;return n<F[0]?1:n<F[1]?2:n<F[2]?3:n<F[3]?5:9},q.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0},Z.encodedSize=function(e){const t=X(e);return L.encodedSize(t.length)+t.length},Z.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(I(e)&&I(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 ee=Z;function te(e,t,n,r){return new A($.array,r,n)}function ne(e,t,n,r){return te(0,0,1,n)}function re(e,t){L(e,$.array.majorEncoded,t.value)}function oe(e,t,n,r){return new A($.map,r,n)}function ie(e,t,n,r){return oe(0,0,1,n)}function ae(e,t){L(e,$.map.majorEncoded,t.value)}function se(e,t,n,r){return new A($.tag,n,1)}function ue(e,t){L(e,$.tag.majorEncoded,t.value)}re.compareTokens=O.compareTokens,re.encodedSize=function(e){return L.encodedSize(e.value)},ae.compareTokens=O.compareTokens,ae.encodedSize=function(e){return L.encodedSize(e.value)},ue.compareTokens=O.compareTokens,ue.encodedSize=function(e){return L.encodedSize(e.value)};function ce(e,t,n){if(n){if(!1===n.allowNaN&&Number.isNaN(e))throw new Error(`${x} NaN values are not supported`);if(!1===n.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${x} Infinity values are not supported`)}return new A($.float,e,t)}function fe(e,t,n){const r=t.value;if(!1===r)e.push([20|$.float.majorEncoded]);else if(!0===r)e.push([21|$.float.majorEncoded]);else if(null===r)e.push([22|$.float.majorEncoded]);else if(void 0===r)e.push([23|$.float.majorEncoded]);else{let t,i=!1;n&&!0===n.float64||(pe(r),t=ye(he,1),r===t||Number.isNaN(r)?(he[0]=249,e.push(he.slice(0,3)),i=!0):(we(r),t=ge(he,1),r===t&&(he[0]=250,e.push(he.slice(0,5)),i=!0))),i||(o=r,de.setFloat64(0,o,!1),t=me(he,1),he[0]=251,e.push(he.slice(0,9)))}var o}fe.encodedSize=function(e,t){const n=e.value;if(!1===n||!0===n||null==n)return 1;if(!t||!0!==t.float64){pe(n);let e=ye(he,1);if(n===e||Number.isNaN(n))return 3;if(we(n),e=ge(he,1),n===e)return 5}return 9};const le=new ArrayBuffer(9),de=new DataView(le,1),he=new Uint8Array(le,0);function pe(e){if(e===1/0)de.setUint16(0,31744,!1);else if(e===-1/0)de.setUint16(0,64512,!1);else if(Number.isNaN(e))de.setUint16(0,32256,!1);else{de.setFloat32(0,e);const t=de.getUint32(0),n=(2139095040&t)>>23,r=8388607&t;if(255===n)de.setUint16(0,31744,!1);else if(0===n)de.setUint16(0,(2147483648&e)>>16|r>>13,!1);else{const e=n-127;e<-24?de.setUint16(0,0):e<-14?de.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):de.setUint16(0,(2147483648&t)>>16|e+15<<10|r>>13,!1)}}}function ye(e,t){if(e.length-t<2)throw new Error(`${x} 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 we(e){de.setFloat32(0,e,!1)}function ge(e,t){if(e.length-t<4)throw new Error(`${x} not enough data for float32`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function me(e,t){if(e.length-t<8)throw new Error(`${x} not enough data for float64`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function be(e,t,n){throw new Error(`${x} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function ve(e){return()=>{throw new Error(`${x} ${e}`)}}fe.compareTokens=O.compareTokens;const Ee=[];for(let e=0;e<=23;e++)Ee[e]=be;Ee[24]=function(e,t,n,r){return new A($.uint,C(e,t+1,r),2)},Ee[25]=function(e,t,n,r){return new A($.uint,z(e,t+1,r),3)},Ee[26]=function(e,t,n,r){return new A($.uint,H(e,t+1,r),5)},Ee[27]=function(e,t,n,r){return new A($.uint,_(e,t+1,r),9)},Ee[28]=be,Ee[29]=be,Ee[30]=be,Ee[31]=be;for(let e=32;e<=55;e++)Ee[e]=be;Ee[56]=function(e,t,n,r){return new A($.negint,-1-C(e,t+1,r),2)},Ee[57]=function(e,t,n,r){return new A($.negint,-1-z(e,t+1,r),3)},Ee[58]=function(e,t,n,r){return new A($.negint,-1-H(e,t+1,r),5)},Ee[59]=function(e,t,n,r){const o=_(e,t+1,r);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new A($.negint,e,9)}if(!0!==r.allowBigInt)throw new Error(`${x} integers outside of the safe integer range are not supported`);return new A($.negint,R-BigInt(o),9)},Ee[60]=be,Ee[61]=be,Ee[62]=be,Ee[63]=be;for(let e=64;e<=87;e++)Ee[e]=J;Ee[88]=function(e,t,n,r){return W(e,t,2,C(e,t+1,r))},Ee[89]=function(e,t,n,r){return W(e,t,3,z(e,t+1,r))},Ee[90]=function(e,t,n,r){return W(e,t,5,H(e,t+1,r))},Ee[91]=function(e,t,n,r){const o=_(e,t+1,r);if("bigint"==typeof o)throw new Error(`${x} 64-bit integer bytes lengths not supported`);return W(e,t,9,o)},Ee[92]=be,Ee[93]=be,Ee[94]=be,Ee[95]=ve("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)Ee[e]=Y;Ee[120]=function(e,t,n,r){return Q(e,t,2,C(e,t+1,r),r)},Ee[121]=function(e,t,n,r){return Q(e,t,3,z(e,t+1,r),r)},Ee[122]=function(e,t,n,r){return Q(e,t,5,H(e,t+1,r),r)},Ee[123]=function(e,t,n,r){const o=_(e,t+1,r);if("bigint"==typeof o)throw new Error(`${x} 64-bit integer string lengths not supported`);return Q(e,t,9,o,r)},Ee[124]=be,Ee[125]=be,Ee[126]=be,Ee[127]=ve("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)Ee[e]=ne;Ee[152]=function(e,t,n,r){return te(0,0,2,C(e,t+1,r))},Ee[153]=function(e,t,n,r){return te(0,0,3,z(e,t+1,r))},Ee[154]=function(e,t,n,r){return te(0,0,5,H(e,t+1,r))},Ee[155]=function(e,t,n,r){const o=_(e,t+1,r);if("bigint"==typeof o)throw new Error(`${x} 64-bit integer array lengths not supported`);return te(0,0,9,o)},Ee[156]=be,Ee[157]=be,Ee[158]=be,Ee[159]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${x} indefinite length items not allowed`);return te(0,0,1,1/0)};for(let e=160;e<=183;e++)Ee[e]=ie;Ee[184]=function(e,t,n,r){return oe(0,0,2,C(e,t+1,r))},Ee[185]=function(e,t,n,r){return oe(0,0,3,z(e,t+1,r))},Ee[186]=function(e,t,n,r){return oe(0,0,5,H(e,t+1,r))},Ee[187]=function(e,t,n,r){const o=_(e,t+1,r);if("bigint"==typeof o)throw new Error(`${x} 64-bit integer map lengths not supported`);return oe(0,0,9,o)},Ee[188]=be,Ee[189]=be,Ee[190]=be,Ee[191]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${x} indefinite length items not allowed`);return oe(0,0,1,1/0)};for(let e=192;e<=215;e++)Ee[e]=se;Ee[216]=function(e,t,n,r){return new A($.tag,C(e,t+1,r),2)},Ee[217]=function(e,t,n,r){return new A($.tag,z(e,t+1,r),3)},Ee[218]=function(e,t,n,r){return new A($.tag,H(e,t+1,r),5)},Ee[219]=function(e,t,n,r){return new A($.tag,_(e,t+1,r),9)},Ee[220]=be,Ee[221]=be,Ee[222]=be,Ee[223]=be;for(let e=224;e<=243;e++)Ee[e]=ve("simple values are not supported");Ee[244]=be,Ee[245]=be,Ee[246]=be,Ee[247]=function(e,t,n,r){if(!1===r.allowUndefined)throw new Error(`${x} undefined values are not supported`);return!0===r.coerceUndefinedToNull?new A($.null,null,1):new A($.undefined,void 0,1)},Ee[248]=ve("simple values are not supported"),Ee[249]=function(e,t,n,r){return ce(ye(e,t+1),3,r)},Ee[250]=function(e,t,n,r){return ce(ge(e,t+1),5,r)},Ee[251]=function(e,t,n,r){return ce(me(e,t+1),9,r)},Ee[252]=be,Ee[253]=be,Ee[254]=be,Ee[255]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${x} indefinite length items not allowed`);return new A($.break,void 0,1)};const Me=[];for(let e=0;e<24;e++)Me[e]=new A($.uint,e,1);for(let e=-1;e>=-24;e--)Me[31-e]=new A($.negint,e,1);Me[64]=new A($.bytes,new Uint8Array(0),1),Me[96]=new A($.string,"",1),Me[128]=new A($.array,0,1),Me[160]=new A($.map,0,1),Me[244]=new A($.false,!1,1),Me[245]=new A($.true,!0,1),Me[246]=new A($.null,null,1),function(){const e=[];e[$.uint.major]=O,e[$.negint.major]=q,e[$.bytes.major]=Z,e[$.string.major]=ee,e[$.array.major]=re,e[$.map.major]=ae,e[$.tag.major]=ue,e[$.float.major]=fe}();class $e{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(`${P} object contains circular references`);return new $e(t,e)}}const Ae={null:new A($.null,null),undefined:new A($.undefined,void 0),true:new A($.true,!0),false:new A($.false,!1),emptyArray:new A($.array,0),emptyMap:new A($.map,0)},Te={number:(e,t,n,r)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new A(e>=0?$.uint:$.negint,e):new A($.float,e),bigint:(e,t,n,r)=>e>=BigInt(0)?new A($.uint,e):new A($.negint,e),Uint8Array:(e,t,n,r)=>new A($.bytes,e),string:(e,t,n,r)=>new A($.string,e),boolean:(e,t,n,r)=>e?Ae.true:Ae.false,null:(e,t,n,r)=>Ae.null,undefined:(e,t,n,r)=>Ae.undefined,ArrayBuffer:(e,t,n,r)=>new A($.bytes,new Uint8Array(e)),DataView:(e,t,n,r)=>new A($.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,n,r){if(!e.length)return!0===n.addBreakTokens?[Ae.emptyArray,new A($.break)]:Ae.emptyArray;r=$e.createCheck(r,e);const o=[];let i=0;for(const t of e)o[i++]=Se(t,n,r);return n.addBreakTokens?[new A($.array,e.length),o,new A($.break)]:[new A($.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?[Ae.emptyMap,new A($.break)]:Ae.emptyMap;r=$e.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 A($.map,a),s,new A($.break)]:[new A($.map,a),s]}};Te.Map=Te.Object,Te.Buffer=Te.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Te[`${e}Array`]=Te.DataView;function Se(e,t={},n){const r=M(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Te[r];if("function"==typeof o){const i=o(e,r,t,n);if(null!=i)return i}const i=Te[r];if(!i)throw new Error(`${P} unsupported type: ${r}`);return i(e,r,t,n)}const ke={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class Ie{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=Me[e];if(void 0===t){const n=Ee[e];if(!n)throw new Error(`${x} 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 Ue(e,t){if(e.done())return je;const n=e.next();if(n.type===$.break)return Ve;if(n.type.terminal)return n.value;if(n.type===$.array)return function(e,t,n){const r=[];for(let o=0;o<e.value;o++){const i=Ue(t,n);if(i===Ve){if(e.value===1/0)break;throw new Error(`${x} got unexpected break to lengthed array`)}if(i===je)throw new Error(`${x} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}(n,e,t);if(n.type===$.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=Ue(t,n);if(s===Ve){if(e.value===1/0)break;throw new Error(`${x} got unexpected break to lengthed map`)}if(s===je)throw new Error(`${x} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!0!==r&&"string"!=typeof s)throw new Error(`${x} non-string keys not supported (got ${typeof s})`);if(!0===n.rejectDuplicateMapKeys&&(r&&i.has(s)||!r&&s in o))throw new Error(`${x} found repeat map key "${s}"`);const u=Ue(t,n);if(u===je)throw new Error(`${x} 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===$.tag){if(t.tags&&"function"==typeof t.tags[n.value]){const r=Ue(e,t);return t.tags[n.value](r)}throw new Error(`${x} tag not supported (${n.value})`)}throw new Error("unsupported")}function Be(e,t){const[n,r]=function(e,t){if(!(e instanceof Uint8Array))throw new Error(`${x} data to decode must be a Uint8Array`);const n=(t=Object.assign({},ke,t)).tokenizer||new Ie(e,t),r=Ue(n,t);if(r===je)throw new Error(`${x} did not find any content to decode`);if(r===Ve)throw new Error(`${x} got unexpected break`);return[r,e.subarray(n.pos())]}(e,t);if(r.length>0)throw new Error(`${x} too many terminals, data makes no sense`);return n}
17
+ */({document:e,labelMapFactoryFunction:t,options:n});return r}async function m(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 b({document:e,proof:t,options:n,hasher:r}={}){r||(r=p());const o=await async function({document:e,proof:t,options:n}={}){return delete(t={"@context":e["@context"],...t}).proofValue,m(t,n)}({document:e,proof:t,options:n});return r.hash(g(o))}const v=["string","number","bigint","symbol"],E=["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 M(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(v.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(E.includes(t))return t;return}(e);return n||"Object"}class ${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}}$.uint=new $(0,"uint",!0),$.negint=new $(1,"negint",!0),$.bytes=new $(2,"bytes",!0),$.string=new $(3,"string",!0),$.array=new $(4,"array",!1),$.map=new $(5,"map",!1),$.tag=new $(6,"tag",!1),$.float=new $(7,"float",!0),$.false=new $(7,"false",!0),$.true=new $(7,"true",!0),$.null=new $(7,"null",!0),$.undefined=new $(7,"undefined",!0),$.break=new $(7,"break",!0);class A{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 S=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,T=new TextDecoder,k=new TextEncoder;function j(e){return S&&globalThis.Buffer.isBuffer(e)}const I=S?(e,t,n)=>n-t>64?globalThis.Buffer.from(e.subarray(t,n)).toString("utf8"):x(e,t,n):(e,t,n)=>n-t>64?T.decode(e.subarray(t,n)):x(e,t,n),V=S?e=>e.length>64?globalThis.Buffer.from(e):U(e):e=>e.length>64?k.encode(e):U(e),B=S?(e,t,n)=>j(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n);function U(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 x(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 P="CBOR decode error:",D="CBOR encode error:";function K(e,t,n){if(e.length-t<n)throw new Error(`${P} not enough data for type`)}const F=[24,256,65536,4294967296,BigInt("18446744073709551616")];function C(e,t,n){K(e,t,1);const r=e[t];if(!0===n.strict&&r<F[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function H(e,t,n){K(e,t,2);const r=e[t]<<8|e[t+1];if(!0===n.strict&&r<F[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function z(e,t,n){K(e,t,4);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(!0===n.strict&&r<F[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function O(e,t,n){K(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<F[3])throw new Error(`${P} 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(`${P} integers outside of the safe integer range are not supported`)}function _(e,t){return L(e,0,t.value)}function L(e,t,n){if(n<F[0]){const r=Number(n);e.push([t|r])}else if(n<F[1]){const r=Number(n);e.push([24|t,r])}else if(n<F[2]){const r=Number(n);e.push([25|t,r>>>8,255&r])}else if(n<F[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<F[4]))throw new Error(`${P} 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)}}}_.encodedSize=function(e){return L.encodedSize(e.value)},L.encodedSize=function(e){return e<F[0]?1:e<F[1]?2:e<F[2]?3:e<F[3]?5:9},_.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};const G=BigInt(-1),R=BigInt(1);function q(e,t){const n=t.value,r="bigint"==typeof n?n*G-R:-1*n-1;L(e,t.type.majorEncoded,r)}function W(e,t,n,r){K(e,t,n+r);const o=B(e,t+n,t+n+r);return new A($.bytes,o,n+r)}function J(e,t,n,r){return W(e,t,1,n)}function Z(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===$.string?V(e.value):e.value),e.encodedBytes}function X(e,t){const n=Z(t);L(e,t.type.majorEncoded,n.length),e.push(n)}function Y(e,t,n,r,o){const i=n+r;K(e,t,i);const a=new A($.string,I(e,t+n,t+i),i);return!0===o.retainStringBytes&&(a.byteValue=B(e,t+n,t+i)),a}function Q(e,t,n,r){return Y(e,t,1,n,r)}q.encodedSize=function(e){const t=e.value,n="bigint"==typeof t?t*G-R:-1*t-1;return n<F[0]?1:n<F[1]?2:n<F[2]?3:n<F[3]?5:9},q.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0},X.encodedSize=function(e){const t=Z(e);return L.encodedSize(t.length)+t.length},X.compareTokens=function(e,t){return n=Z(e),r=Z(t),n.length<r.length?-1:n.length>r.length?1:function(e,t){if(j(e)&&j(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 ee=X;function te(e,t,n,r){return new A($.array,r,n)}function ne(e,t,n,r){return te(0,0,1,n)}function re(e,t){L(e,$.array.majorEncoded,t.value)}function oe(e,t,n,r){return new A($.map,r,n)}function ie(e,t,n,r){return oe(0,0,1,n)}function ae(e,t){L(e,$.map.majorEncoded,t.value)}function se(e,t,n,r){return new A($.tag,n,1)}function ue(e,t){L(e,$.tag.majorEncoded,t.value)}re.compareTokens=_.compareTokens,re.encodedSize=function(e){return L.encodedSize(e.value)},ae.compareTokens=_.compareTokens,ae.encodedSize=function(e){return L.encodedSize(e.value)},ue.compareTokens=_.compareTokens,ue.encodedSize=function(e){return L.encodedSize(e.value)};function ce(e,t,n){if(n){if(!1===n.allowNaN&&Number.isNaN(e))throw new Error(`${P} NaN values are not supported`);if(!1===n.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new A($.float,e,t)}function fe(e,t,n){const r=t.value;if(!1===r)e.push([20|$.float.majorEncoded]);else if(!0===r)e.push([21|$.float.majorEncoded]);else if(null===r)e.push([22|$.float.majorEncoded]);else if(void 0===r)e.push([23|$.float.majorEncoded]);else{let t,i=!1;n&&!0===n.float64||(pe(r),t=ye(he,1),r===t||Number.isNaN(r)?(he[0]=249,e.push(he.slice(0,3)),i=!0):(ge(r),t=we(he,1),r===t&&(he[0]=250,e.push(he.slice(0,5)),i=!0))),i||(o=r,de.setFloat64(0,o,!1),t=me(he,1),he[0]=251,e.push(he.slice(0,9)))}var o}fe.encodedSize=function(e,t){const n=e.value;if(!1===n||!0===n||null==n)return 1;if(!t||!0!==t.float64){pe(n);let e=ye(he,1);if(n===e||Number.isNaN(n))return 3;if(ge(n),e=we(he,1),n===e)return 5}return 9};const le=new ArrayBuffer(9),de=new DataView(le,1),he=new Uint8Array(le,0);function pe(e){if(e===1/0)de.setUint16(0,31744,!1);else if(e===-1/0)de.setUint16(0,64512,!1);else if(Number.isNaN(e))de.setUint16(0,32256,!1);else{de.setFloat32(0,e);const t=de.getUint32(0),n=(2139095040&t)>>23,r=8388607&t;if(255===n)de.setUint16(0,31744,!1);else if(0===n)de.setUint16(0,(2147483648&e)>>16|r>>13,!1);else{const e=n-127;e<-24?de.setUint16(0,0):e<-14?de.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):de.setUint16(0,(2147483648&t)>>16|e+15<<10|r>>13,!1)}}}function ye(e,t){if(e.length-t<2)throw new Error(`${P} 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){de.setFloat32(0,e,!1)}function we(e,t){if(e.length-t<4)throw new Error(`${P} not enough data for float32`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function me(e,t){if(e.length-t<8)throw new Error(`${P} not enough data for float64`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function be(e,t,n){throw new Error(`${P} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function ve(e){return()=>{throw new Error(`${P} ${e}`)}}fe.compareTokens=_.compareTokens;const Ee=[];for(let e=0;e<=23;e++)Ee[e]=be;Ee[24]=function(e,t,n,r){return new A($.uint,C(e,t+1,r),2)},Ee[25]=function(e,t,n,r){return new A($.uint,H(e,t+1,r),3)},Ee[26]=function(e,t,n,r){return new A($.uint,z(e,t+1,r),5)},Ee[27]=function(e,t,n,r){return new A($.uint,O(e,t+1,r),9)},Ee[28]=be,Ee[29]=be,Ee[30]=be,Ee[31]=be;for(let e=32;e<=55;e++)Ee[e]=be;Ee[56]=function(e,t,n,r){return new A($.negint,-1-C(e,t+1,r),2)},Ee[57]=function(e,t,n,r){return new A($.negint,-1-H(e,t+1,r),3)},Ee[58]=function(e,t,n,r){return new A($.negint,-1-z(e,t+1,r),5)},Ee[59]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new A($.negint,e,9)}if(!0!==r.allowBigInt)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new A($.negint,G-BigInt(o),9)},Ee[60]=be,Ee[61]=be,Ee[62]=be,Ee[63]=be;for(let e=64;e<=87;e++)Ee[e]=J;Ee[88]=function(e,t,n,r){return W(e,t,2,C(e,t+1,r))},Ee[89]=function(e,t,n,r){return W(e,t,3,H(e,t+1,r))},Ee[90]=function(e,t,n,r){return W(e,t,5,z(e,t+1,r))},Ee[91]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer bytes lengths not supported`);return W(e,t,9,o)},Ee[92]=be,Ee[93]=be,Ee[94]=be,Ee[95]=ve("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)Ee[e]=Q;Ee[120]=function(e,t,n,r){return Y(e,t,2,C(e,t+1,r),r)},Ee[121]=function(e,t,n,r){return Y(e,t,3,H(e,t+1,r),r)},Ee[122]=function(e,t,n,r){return Y(e,t,5,z(e,t+1,r),r)},Ee[123]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer string lengths not supported`);return Y(e,t,9,o,r)},Ee[124]=be,Ee[125]=be,Ee[126]=be,Ee[127]=ve("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)Ee[e]=ne;Ee[152]=function(e,t,n,r){return te(0,0,2,C(e,t+1,r))},Ee[153]=function(e,t,n,r){return te(0,0,3,H(e,t+1,r))},Ee[154]=function(e,t,n,r){return te(0,0,5,z(e,t+1,r))},Ee[155]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer array lengths not supported`);return te(0,0,9,o)},Ee[156]=be,Ee[157]=be,Ee[158]=be,Ee[159]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return te(0,0,1,1/0)};for(let e=160;e<=183;e++)Ee[e]=ie;Ee[184]=function(e,t,n,r){return oe(0,0,2,C(e,t+1,r))},Ee[185]=function(e,t,n,r){return oe(0,0,3,H(e,t+1,r))},Ee[186]=function(e,t,n,r){return oe(0,0,5,z(e,t+1,r))},Ee[187]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer map lengths not supported`);return oe(0,0,9,o)},Ee[188]=be,Ee[189]=be,Ee[190]=be,Ee[191]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return oe(0,0,1,1/0)};for(let e=192;e<=215;e++)Ee[e]=se;Ee[216]=function(e,t,n,r){return new A($.tag,C(e,t+1,r),2)},Ee[217]=function(e,t,n,r){return new A($.tag,H(e,t+1,r),3)},Ee[218]=function(e,t,n,r){return new A($.tag,z(e,t+1,r),5)},Ee[219]=function(e,t,n,r){return new A($.tag,O(e,t+1,r),9)},Ee[220]=be,Ee[221]=be,Ee[222]=be,Ee[223]=be;for(let e=224;e<=243;e++)Ee[e]=ve("simple values are not supported");Ee[244]=be,Ee[245]=be,Ee[246]=be,Ee[247]=function(e,t,n,r){if(!1===r.allowUndefined)throw new Error(`${P} undefined values are not supported`);return!0===r.coerceUndefinedToNull?new A($.null,null,1):new A($.undefined,void 0,1)},Ee[248]=ve("simple values are not supported"),Ee[249]=function(e,t,n,r){return ce(ye(e,t+1),3,r)},Ee[250]=function(e,t,n,r){return ce(we(e,t+1),5,r)},Ee[251]=function(e,t,n,r){return ce(me(e,t+1),9,r)},Ee[252]=be,Ee[253]=be,Ee[254]=be,Ee[255]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return new A($.break,void 0,1)};const Me=[];for(let e=0;e<24;e++)Me[e]=new A($.uint,e,1);for(let e=-1;e>=-24;e--)Me[31-e]=new A($.negint,e,1);Me[64]=new A($.bytes,new Uint8Array(0),1),Me[96]=new A($.string,"",1),Me[128]=new A($.array,0,1),Me[160]=new A($.map,0,1),Me[244]=new A($.false,!1,1),Me[245]=new A($.true,!0,1),Me[246]=new A($.null,null,1),function(){const e=[];e[$.uint.major]=_,e[$.negint.major]=q,e[$.bytes.major]=X,e[$.string.major]=ee,e[$.array.major]=re,e[$.map.major]=ae,e[$.tag.major]=ue,e[$.float.major]=fe}();class $e{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(`${D} object contains circular references`);return new $e(t,e)}}const Ae={null:new A($.null,null),undefined:new A($.undefined,void 0),true:new A($.true,!0),false:new A($.false,!1),emptyArray:new A($.array,0),emptyMap:new A($.map,0)},Se={number:(e,t,n,r)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new A(e>=0?$.uint:$.negint,e):new A($.float,e),bigint:(e,t,n,r)=>e>=BigInt(0)?new A($.uint,e):new A($.negint,e),Uint8Array:(e,t,n,r)=>new A($.bytes,e),string:(e,t,n,r)=>new A($.string,e),boolean:(e,t,n,r)=>e?Ae.true:Ae.false,null:(e,t,n,r)=>Ae.null,undefined:(e,t,n,r)=>Ae.undefined,ArrayBuffer:(e,t,n,r)=>new A($.bytes,new Uint8Array(e)),DataView:(e,t,n,r)=>new A($.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,n,r){if(!e.length)return!0===n.addBreakTokens?[Ae.emptyArray,new A($.break)]:Ae.emptyArray;r=$e.createCheck(r,e);const o=[];let i=0;for(const t of e)o[i++]=Te(t,n,r);return n.addBreakTokens?[new A($.array,e.length),o,new A($.break)]:[new A($.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?[Ae.emptyMap,new A($.break)]:Ae.emptyMap;r=$e.createCheck(r,e);const s=[];let u=0;for(const t of i)s[u++]=[Te(t,n,r),Te(o?e.get(t):e[t],n,r)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(s,n),n.addBreakTokens?[new A($.map,a),s,new A($.break)]:[new A($.map,a),s]}};Se.Map=Se.Object,Se.Buffer=Se.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Se[`${e}Array`]=Se.DataView;function Te(e,t={},n){const r=M(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Se[r];if("function"==typeof o){const i=o(e,r,t,n);if(null!=i)return i}const i=Se[r];if(!i)throw new Error(`${D} unsupported type: ${r}`);return i(e,r,t,n)}const ke={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class je{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=Me[e];if(void 0===t){const n=Ee[e];if(!n)throw new Error(`${P} 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 Ie=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function Be(e,t){if(e.done())return Ie;const n=e.next();if(n.type===$.break)return Ve;if(n.type.terminal)return n.value;if(n.type===$.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(`${P} got unexpected break to lengthed array`)}if(i===Ie)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}(n,e,t);if(n.type===$.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(`${P} got unexpected break to lengthed map`)}if(s===Ie)throw new Error(`${P} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!0!==r&&"string"!=typeof s)throw new Error(`${P} non-string keys not supported (got ${typeof s})`);if(!0===n.rejectDuplicateMapKeys&&(r&&i.has(s)||!r&&s in o))throw new Error(`${P} found repeat map key "${s}"`);const u=Be(t,n);if(u===Ie)throw new Error(`${P} 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===$.tag){if(t.tags&&"function"==typeof t.tags[n.value]){const r=Be(e,t);return t.tags[n.value](r)}throw new Error(`${P} tag not supported (${n.value})`)}throw new Error("unsupported")}function Ue(e,t){const[n,r]=function(e,t){if(!(e instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);const n=(t=Object.assign({},ke,t)).tokenizer||new je(e,t),r=Be(n,t);if(r===Ie)throw new Error(`${P} did not find any content to decode`);if(r===Ve)throw new Error(`${P} got unexpected break`);return[r,e.subarray(n.pos())]}(e,t);if(r.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return n}
18
18
  /*!
19
19
  * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
20
- */const Ne=new Uint8Array([217,93,1]),De=[];function xe({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=r(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,Ne))throw new TypeError('"proof.proofValue" must be a derived proof.');const n=t.subarray(Ne.length),[o,a,s,u,c]=Be(n,{useMaps:!0,tags:De}),f=function(e){const t=new Map;for(const[n,r]of e.entries())t.set(`c14n${n}`,`u${i(r)}`);return t}(u),l={baseSignature:o,publicKey:a,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 Pe({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])}De[64]=function(e){return e}
20
+ */const xe=new Uint8Array([217,93,1]),Ne=[];function Pe({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=r(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,xe))throw new TypeError('"proof.proofValue" must be a derived proof.');const n=t.subarray(xe.length),[o,a,s,u,c]=Ue(n,{useMaps:!0,tags:Ne}),f=function(e){const t=new Map;for(const[n,r]of e.entries())t.set(`c14n${n}`,`u${i(r)}`);return t}(u),l={baseSignature:o,publicKey:a,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 De({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}
21
21
  /*!
22
22
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
23
23
  */;const Ke="ecdsa-sd-2023";
@@ -27,4 +27,4 @@ const h=globalThis.crypto;
27
27
  /*!
28
28
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
29
29
  */
30
- function Fe({requiredAlgorithm:e="P-256"}={}){return{name:Ke,requiredAlgorithm:e,createVerifier:Ce,createVerifyData:ze}}async function Ce({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:i,signatures:a,nonMandatory:s,mandatoryHash:u}=t,c="z"+o(i),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:w(s[t]),signature:e})))).some(e=>!e))return!1;const h=await Pe({proofHash:r,publicKey:i,mandatoryHash:u});return e.verify({data:h,signature:n})}({verifier:t,data:e})}}async function ze({cryptosuite:e,document:t,proof:n,documentLoader:r}){if(e?.name!==Ke)throw new TypeError(`"cryptosuite.name" must be "${Ke}".`);const o={documentLoader:r},i=b({document:t,proof:n,options:o}).catch(e=>e),{baseSignature:a,publicKey:s,signatures:u,labelMap:c,mandatoryIndexes:f}=await xe({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 g({document:t,labelMapFactoryFunction:l,options:o}),h=[],y=[];for(const[e,t]of d.entries())f.includes(e)?h.push(t):y.push(t);const{mandatoryHash:m}=await async function({mandatory:e,hasher:t}={}){return t||(t=p()),{mandatoryHash:await t.hash(w(e.join("")))}}({mandatory:h}),v=await i;if(v instanceof Error)throw v;return{baseSignature:a,proofHash:v,publicKey:s,signatures:u,nonMandatory:y,mandatoryHash:m}}const{purposes:{AssertionProofPurpose:He,AuthenticationProofPurpose:_e}}=a;var Oe;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(Oe||(Oe={}));class Le extends s{verificationProcess=[Oe.retrieveVerificationMethodPublicKey,Oe.ensureVerificationMethodValidity,Oe.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:_e,assertionMethod:He},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(Oe.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=d(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),!this.verificationMethod)throw new n(Oe.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(this.verificationMethod.revoked)throw new n(Oe.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return this.verificationMethod},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(Oe.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(Oe.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new n(Oe.ensureVerificationMethodValidity,"The verification key has been revoked")},this.type)}async checkDocumentSignature(){await this.executeStep(Oe.checkDocumentSignature,async()=>{const e=new c({cryptosuite:Fe({requiredAlgorithm:"K-256"})}),t=this.documentToVerify.proof.verificationMethod;"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const r=await a.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(!r.verified)throw console.error(JSON.stringify(r,null,2)),new n(Oe.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(r)}`);console.log(`Credential ${this.type} signature successfully verified`)},this.type)}}export{Le as default};
30
+ function Fe({requiredAlgorithm:e="P-256"}={}){return{name:Ke,requiredAlgorithm:e,createVerifier:Ce,createVerifyData:He}}async function Ce({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:i,signatures:a,nonMandatory:s,mandatoryHash:u}=t,c="z"+o(i),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 De({proofHash:r,publicKey:i,mandatoryHash:u});return e.verify({data:h,signature:n})}({verifier:t,data:e})}}async function He({cryptosuite:e,document:t,proof:n,documentLoader:r}){if(e?.name!==Ke)throw new TypeError(`"cryptosuite.name" must be "${Ke}".`);const o={documentLoader:r},i=b({document:t,proof:n,options:o}).catch(e=>e),{baseSignature:a,publicKey:s,signatures:u,labelMap:c,mandatoryIndexes:f}=await Pe({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 w({document:t,labelMapFactoryFunction:l,options:o}),h=[],y=[];for(const[e,t]of d.entries())f.includes(e)?h.push(t):y.push(t);const{mandatoryHash:m}=await async function({mandatory:e,hasher:t}={}){return t||(t=p()),{mandatoryHash:await t.hash(g(e.join("")))}}({mandatory:h}),v=await i;if(v instanceof Error)throw v;return{baseSignature:a,proofHash:v,publicKey:s,signatures:u,nonMandatory:y,mandatoryHash:m}}const{purposes:{AssertionProofPurpose:ze,AuthenticationProofPurpose:Oe}}=a;var _e;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(_e||(_e={}));class Le extends s{verificationProcess=[_e.retrieveVerificationMethodPublicKey,_e.ensureVerificationMethodValidity,_e.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:Oe,assertionMethod:ze},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(_e.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=d(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),!this.verificationMethod)throw new n(_e.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(this.verificationMethod.revoked)throw new n(_e.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return this.verificationMethod},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(_e.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(_e.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new n(_e.ensureVerificationMethodValidity,"The verification key has been revoked")},this.type)}async checkDocumentSignature(){await this.executeStep(_e.checkDocumentSignature,async()=>{const e=new c({cryptosuite:Fe({requiredAlgorithm:"K-256"})}),t=this.documentToVerify.proof.verificationMethod;"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const r=await a.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(!r.verified)throw console.error(JSON.stringify(r,null,2)),new n(_e.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(r)}`);console.log(`Credential ${this.type} signature successfully verified`)},this.type)}}export{Le as default};
@@ -1 +1 @@
1
- import{d as e,p as t,a as i,v as o,w as r,E as n,V as s}from"./main.js";import{j as c}from"./jsonld-signatures-D4X_Irzi-D_wBqxSl.js";import{S as a,j as d}from"./Suite-Bu3gszvt-Dmvbh142.js";import"./pako.esm-BGRKTPxS-Bodm4Eha.js";import"./index-CyNtT_1q-Dgus2xdV.js";import{r as h}from"./retrieveVerificationMethodPublicKey-D_autuwE-DGbK-RPm.js";const u="https://ns.did.ai/suites/secp256k1-2019/v1",p="https://www.w3.org/ns/credentials/v2",f=({document:e,contextUrl:t})=>{const i=e["@context"];return Array.isArray(i)?t.some(e=>i.includes(e)):t.includes(i)},y=({document:e})=>{const t=f({document:e,contextUrl:[u,"https://w3id.org/security/suites/secp256k1-2019/v1"]}),i=f({document:e,contextUrl:["https://www.w3.org/2018/credentials/v1"]}),o=f({document:e,contextUrl:[p]}),r=f({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 l=class extends c.suites.LinkedDataSignature{requiredKeyType;constructor(e={}){super({type:"EcdsaSecp256k1Signature2019",LDKeyClass:n,contextUrl:u,...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(!y({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(!y({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}){y({document:e})&&!f({document:e,contextUrl:[p]})||super.ensureSuiteContext({document:e,addSuiteContext:t})}isVerificationMethodMatchingKeyId(e){return e===this.key.id||e===`${this.key.controller}${this.key.id}`}};l.CONTEXT_URL=u,l.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:w,AuthenticationProofPurpose:g}}=c;var m;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(m||(m={}));class v extends a{verificationProcess=[m.retrieveVerificationMethodPublicKey,m.ensureVerificationMethodValidity,m.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:g,assertionMethod:w},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(m.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=h(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(m.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(e.revoked)throw new s(m.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return e},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(m.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new s(m.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new s(m.ensureVerificationMethodValidity,"The verification key has been revoked")},this.type)}async checkDocumentSignature(){await this.executeStep(m.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 c.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(m.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`);console.log("Credential Secp256k1 signature successfully verified")},this.type)}}export{v as default};
1
+ import{d as e,p as t,a as i,w as o,x as r,E as n,V as s}from"./main.js";import{j as c}from"./jsonld-signatures-BtZPa7MV-DTekMXP5.js";import{S as a,j as d}from"./Suite-CBLHluYK-Dmvbh142.js";import"./pako.esm-BGRKTPxS-Bodm4Eha.js";import"./index-6G1g4ypj-Dgus2xdV.js";import{r as h}from"./retrieveVerificationMethodPublicKey-DcEGtx_h-D1zuvtQB.js";const u="https://ns.did.ai/suites/secp256k1-2019/v1",p="https://www.w3.org/ns/credentials/v2",f=({document:e,contextUrl:t})=>{const i=e["@context"];return Array.isArray(i)?t.some(e=>i.includes(e)):t.includes(i)},y=({document:e})=>{const t=f({document:e,contextUrl:[u,"https://w3id.org/security/suites/secp256k1-2019/v1"]}),i=f({document:e,contextUrl:["https://www.w3.org/2018/credentials/v1"]}),o=f({document:e,contextUrl:[p]}),r=f({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 l=class extends c.suites.LinkedDataSignature{requiredKeyType;constructor(e={}){super({type:"EcdsaSecp256k1Signature2019",LDKeyClass:n,contextUrl:u,...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(!y({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(!y({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}){y({document:e})&&!f({document:e,contextUrl:[p]})||super.ensureSuiteContext({document:e,addSuiteContext:t})}isVerificationMethodMatchingKeyId(e){return e===this.key.id||e===`${this.key.controller}${this.key.id}`}};l.CONTEXT_URL=u,l.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:w}}=c;var m;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(m||(m={}));class v extends a{verificationProcess=[m.retrieveVerificationMethodPublicKey,m.ensureVerificationMethodValidity,m.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:w,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(m.retrieveVerificationMethodPublicKey,async()=>{if(this.verificationMethod=h(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(m.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(e.revoked)throw new s(m.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return e},this.type)}async ensureVerificationMethodValidity(){await this.executeStep(m.ensureVerificationMethodValidity,async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new s(m.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new s(m.ensureVerificationMethodValidity,"The verification key has been revoked")},this.type)}async checkDocumentSignature(){await this.executeStep(m.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 c.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(m.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`);console.log("Credential Secp256k1 signature successfully verified")},this.type)}}export{v as default};