@did-btcr2/method 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +5240 -6079
- package/dist/browser.mjs +5240 -6079
- package/dist/cjs/core/beacon/aggregation/cohort/index.js +3 -3
- package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +1 -9
- package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
- package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/coordinator.js +14 -14
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +4 -3
- package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +1 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/cjs/core/beacon/cas-beacon.js +55 -0
- package/dist/cjs/core/beacon/cas-beacon.js.map +1 -0
- package/dist/cjs/core/beacon/factory.js +11 -10
- package/dist/cjs/core/beacon/factory.js.map +1 -1
- package/dist/cjs/core/beacon/interfaces.js +32 -0
- package/dist/cjs/core/beacon/interfaces.js.map +1 -0
- package/dist/cjs/core/beacon/singleton.js +59 -135
- package/dist/cjs/core/beacon/singleton.js.map +1 -1
- package/dist/cjs/core/beacon/smt-beacon.js +56 -0
- package/dist/cjs/core/beacon/smt-beacon.js.map +1 -0
- package/dist/cjs/core/beacon/utils.js +67 -105
- package/dist/cjs/core/beacon/utils.js.map +1 -1
- package/dist/cjs/core/identifier.js +18 -21
- package/dist/cjs/core/identifier.js.map +1 -1
- package/dist/cjs/core/interfaces.js +2 -0
- package/dist/cjs/core/interfaces.js.map +1 -0
- package/dist/cjs/core/resolve.js +511 -0
- package/dist/cjs/core/resolve.js.map +1 -0
- package/dist/cjs/{utils → core}/types.js.map +1 -1
- package/dist/cjs/core/{crud/update.js → update.js} +62 -52
- package/dist/cjs/core/update.js.map +1 -0
- package/dist/cjs/did-btcr2.js +109 -75
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +14 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/appendix.js +10 -18
- package/dist/cjs/utils/appendix.js.map +1 -1
- package/dist/cjs/utils/did-document.js +51 -58
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/cjs/utils/general.js +1 -1
- package/dist/cjs/utils/general.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/index.js +3 -3
- package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js +1 -9
- package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
- package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js +14 -14
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/participant.js +4 -3
- package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +55 -0
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -0
- package/dist/esm/core/beacon/factory.js +11 -10
- package/dist/esm/core/beacon/factory.js.map +1 -1
- package/dist/esm/core/beacon/interfaces.js +32 -0
- package/dist/esm/core/beacon/interfaces.js.map +1 -0
- package/dist/esm/core/beacon/singleton.js +59 -135
- package/dist/esm/core/beacon/singleton.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +56 -0
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -0
- package/dist/esm/core/beacon/utils.js +67 -105
- package/dist/esm/core/beacon/utils.js.map +1 -1
- package/dist/esm/core/identifier.js +18 -21
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/esm/core/interfaces.js +2 -0
- package/dist/esm/core/interfaces.js.map +1 -0
- package/dist/esm/core/resolve.js +511 -0
- package/dist/esm/core/resolve.js.map +1 -0
- package/dist/esm/{utils → core}/types.js.map +1 -1
- package/dist/esm/core/{crud/update.js → update.js} +62 -52
- package/dist/esm/core/update.js.map +1 -0
- package/dist/esm/did-btcr2.js +109 -75
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +14 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/appendix.js +10 -18
- package/dist/esm/utils/appendix.js.map +1 -1
- package/dist/esm/utils/did-document.js +51 -58
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/esm/utils/general.js +1 -1
- package/dist/esm/utils/general.js.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +0 -7
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +13 -5
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +17 -29
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +47 -0
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -0
- package/dist/types/core/beacon/factory.d.ts +5 -4
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/interfaces.d.ts +98 -0
- package/dist/types/core/beacon/interfaces.d.ts.map +1 -0
- package/dist/types/core/beacon/singleton.d.ts +22 -65
- package/dist/types/core/beacon/singleton.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +48 -0
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -0
- package/dist/types/core/beacon/utils.d.ts +19 -97
- package/dist/types/core/beacon/utils.d.ts.map +1 -1
- package/dist/types/core/identifier.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +94 -0
- package/dist/types/core/interfaces.d.ts.map +1 -0
- package/dist/types/core/resolve.d.ts +105 -0
- package/dist/types/core/resolve.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +71 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/core/{crud/update.d.ts → update.d.ts} +21 -20
- package/dist/types/core/update.d.ts.map +1 -0
- package/dist/types/did-btcr2.d.ts +45 -57
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +14 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +5 -10
- package/dist/types/utils/appendix.d.ts.map +1 -1
- package/dist/types/utils/did-document-builder.d.ts +1 -1
- package/dist/types/utils/did-document-builder.d.ts.map +1 -1
- package/dist/types/utils/did-document.d.ts +31 -29
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/core/beacon/aggregation/cohort/index.ts +3 -3
- package/src/core/beacon/aggregation/cohort/messages/base.ts +1 -12
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -2
- package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -2
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +43 -21
- package/src/core/beacon/aggregation/coordinator.ts +41 -29
- package/src/core/beacon/aggregation/participant.ts +4 -3
- package/src/core/beacon/aggregation/session/index.ts +1 -1
- package/src/core/beacon/cas-beacon.ts +67 -0
- package/src/core/beacon/factory.ts +13 -15
- package/src/core/beacon/interfaces.ts +124 -0
- package/src/core/beacon/singleton.ts +75 -145
- package/src/core/beacon/smt-beacon.ts +70 -0
- package/src/core/beacon/utils.ts +80 -170
- package/src/core/identifier.ts +21 -24
- package/src/core/interfaces.ts +101 -0
- package/src/core/resolve.ts +707 -0
- package/src/core/types.ts +78 -0
- package/src/core/{crud/update.ts → update.ts} +75 -68
- package/src/did-btcr2.ts +152 -92
- package/src/index.ts +14 -24
- package/src/utils/appendix.ts +18 -22
- package/src/utils/did-document-builder.ts +1 -1
- package/src/utils/did-document.ts +67 -71
- package/src/utils/general.ts +1 -1
- package/dist/cjs/core/beacon/cid-aggregate.js +0 -116
- package/dist/cjs/core/beacon/cid-aggregate.js.map +0 -1
- package/dist/cjs/core/beacon/smt-aggregate.js +0 -126
- package/dist/cjs/core/beacon/smt-aggregate.js.map +0 -1
- package/dist/cjs/core/crud/deactivate.js +0 -14
- package/dist/cjs/core/crud/deactivate.js.map +0 -1
- package/dist/cjs/core/crud/read.js +0 -679
- package/dist/cjs/core/crud/read.js.map +0 -1
- package/dist/cjs/core/crud/update.js.map +0 -1
- package/dist/cjs/interfaces/beacon.js +0 -41
- package/dist/cjs/interfaces/beacon.js.map +0 -1
- package/dist/cjs/interfaces/crud.js +0 -2
- package/dist/cjs/interfaces/crud.js.map +0 -1
- package/dist/esm/core/beacon/cid-aggregate.js +0 -116
- package/dist/esm/core/beacon/cid-aggregate.js.map +0 -1
- package/dist/esm/core/beacon/smt-aggregate.js +0 -126
- package/dist/esm/core/beacon/smt-aggregate.js.map +0 -1
- package/dist/esm/core/crud/deactivate.js +0 -14
- package/dist/esm/core/crud/deactivate.js.map +0 -1
- package/dist/esm/core/crud/read.js +0 -679
- package/dist/esm/core/crud/read.js.map +0 -1
- package/dist/esm/core/crud/update.js.map +0 -1
- package/dist/esm/interfaces/beacon.js +0 -41
- package/dist/esm/interfaces/beacon.js.map +0 -1
- package/dist/esm/interfaces/crud.js +0 -2
- package/dist/esm/interfaces/crud.js.map +0 -1
- package/dist/types/core/beacon/cid-aggregate.d.ts +0 -102
- package/dist/types/core/beacon/cid-aggregate.d.ts.map +0 -1
- package/dist/types/core/beacon/smt-aggregate.d.ts +0 -111
- package/dist/types/core/beacon/smt-aggregate.d.ts.map +0 -1
- package/dist/types/core/crud/deactivate.d.ts +0 -13
- package/dist/types/core/crud/deactivate.d.ts.map +0 -1
- package/dist/types/core/crud/read.d.ts +0 -334
- package/dist/types/core/crud/read.d.ts.map +0 -1
- package/dist/types/core/crud/update.d.ts.map +0 -1
- package/dist/types/interfaces/beacon.d.ts +0 -116
- package/dist/types/interfaces/beacon.d.ts.map +0 -1
- package/dist/types/interfaces/crud.d.ts +0 -32
- package/dist/types/interfaces/crud.d.ts.map +0 -1
- package/dist/types/utils/types.d.ts +0 -38
- package/dist/types/utils/types.d.ts.map +0 -1
- package/src/canonicalize.d.ts +0 -6
- package/src/core/beacon/cid-aggregate.ts +0 -153
- package/src/core/beacon/smt-aggregate.ts +0 -135
- package/src/core/crud/deactivate.ts +0 -13
- package/src/core/crud/read.ts +0 -948
- package/src/interfaces/beacon.ts +0 -137
- package/src/interfaces/crud.ts +0 -33
- package/src/utils/types.ts +0 -41
- /package/dist/cjs/{utils → core}/types.js +0 -0
- /package/dist/esm/{utils → core}/types.js +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { HexString } from '@did-btcr2/common';
|
|
2
|
+
import { BTCR2SignedUpdate } from '@did-btcr2/cryptosuite';
|
|
3
|
+
import { SMTProof } from './interfaces.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@link https://dcdpr.github.io/did-btcr2/data-structures.html#cas-announcement | CAS Announcement }
|
|
7
|
+
* a data structure that maps DIDs to BTCR2 Signed Update hashes. All BTCR2 Signed
|
|
8
|
+
* Updates (data structure) MUST be hashed with the JSON Document Hashing algorithm.
|
|
9
|
+
* The concrete representation of this data structure will be published to a CAS.
|
|
10
|
+
* @example
|
|
11
|
+
* ```json
|
|
12
|
+
* {
|
|
13
|
+
* "did:btcr2:k1q5pa5tq86fzrl0ez32nh8e0ks4tzzkxnnmn8tdvxk04ahzt70u09dag02h0cp": "a4ayc_80_OGda4BO_1o_V0etpOqiLx1JwB5S3beHW0s",
|
|
14
|
+
* "did:btcr2:x1qhjw6jnhwcyu5wau4x0cpwvz74c3g82c3uaehqpaf7lzfgmnwsd7spmmf54": "1HNeOiZeFu7gP1lxi5tdAwGcB9i2xR-Q2jpmbuwTqzU",
|
|
15
|
+
* "did:btcr2:k1qgp5h79scv4sfqkzak5g6y89dsy3cq0pd2nussu2cm3zjfhn4ekwrucc4q7t7": "TgdAhWK-24tgzgXB3s_jrRa3IjCWfeAfZAt-Rym0n84"
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type CASAnnouncement = {
|
|
20
|
+
[key: string]: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* See {@link https://dcdpr.github.io/did-btcr2/terminology.html#sidecar | Sidecar }
|
|
25
|
+
* for more details about the sidecar mechanism. See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#sidecar-data | Sidecar Data}
|
|
26
|
+
* for more details about the data structure.
|
|
27
|
+
*/
|
|
28
|
+
export type Sidecar = {
|
|
29
|
+
/**
|
|
30
|
+
* The context string "https://btcr2.dev/context/v1"
|
|
31
|
+
*/
|
|
32
|
+
'@context'?: string,
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Optional Genesis Did Document. Required when resolving did:btcr2 identifiers
|
|
36
|
+
* with `x` HRP.D
|
|
37
|
+
*/
|
|
38
|
+
genesisDocument?: object;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Optional array of BTCR2 Signed Updates. Required if the DID being resolved
|
|
42
|
+
* has ever had a published BTCR2 Update.
|
|
43
|
+
*/
|
|
44
|
+
updates?: Array<BTCR2SignedUpdate>
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Optional array of CAS Announcements. Required if the DID being reslved has
|
|
48
|
+
* used a CAS Beacon to publish a BTCR2 Update.
|
|
49
|
+
*/
|
|
50
|
+
casUpdates?: Array<CASAnnouncement>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Optional array of SMT Proofs. Required if the DID being resolved has used
|
|
54
|
+
* an SMT Beacon to publish a BTCR2 Update.
|
|
55
|
+
*/
|
|
56
|
+
smtProofs?: Array<SMTProof>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The Sidecar data structure post-processing used for resolution.
|
|
61
|
+
*/
|
|
62
|
+
export type SidecarData = {
|
|
63
|
+
/**
|
|
64
|
+
* Map of BTCR2 Signed Updates by their hash bytes.
|
|
65
|
+
* @type {Map<HexString, BTCR2SignedUpdate>}
|
|
66
|
+
*/
|
|
67
|
+
updateMap: Map<HexString, BTCR2SignedUpdate>;
|
|
68
|
+
/**
|
|
69
|
+
* Map of CAS Announcements by their hash bytes.
|
|
70
|
+
* @type {Map<HexString, CASAnnouncement>}
|
|
71
|
+
*/
|
|
72
|
+
casMap: Map<HexString, CASAnnouncement>;
|
|
73
|
+
/**
|
|
74
|
+
* Map of SMT Proofs by their ID.
|
|
75
|
+
* @type {Map<string, SMTProof>}
|
|
76
|
+
*/
|
|
77
|
+
smtMap: Map<string, SMTProof>;
|
|
78
|
+
}
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BTCR2_DID_UPDATE_PAYLOAD_CONTEXT,
|
|
3
|
-
DidUpdateInvocation,
|
|
4
|
-
DidUpdatePayload,
|
|
5
2
|
INVALID_DID_DOCUMENT,
|
|
6
3
|
INVALID_DID_UPDATE,
|
|
7
4
|
INVALID_PUBLIC_KEY_TYPE,
|
|
8
|
-
|
|
5
|
+
JSONPatch,
|
|
9
6
|
MethodError,
|
|
10
7
|
NOT_FOUND,
|
|
11
8
|
PatchOperation,
|
|
12
|
-
|
|
9
|
+
UpdateError
|
|
13
10
|
} from '@did-btcr2/common';
|
|
14
|
-
import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
11
|
+
import { BTCR2SignedUpdate, BTCR2UnsignedUpdate, DataIntegrityConfig, SchnorrMultikey } from '@did-btcr2/cryptosuite';
|
|
15
12
|
import { CompressedSecp256k1PublicKey, SchnorrKeyPair, Secp256k1SecretKey } from '@did-btcr2/keypair';
|
|
16
13
|
import { Kms } from '@did-btcr2/kms';
|
|
17
14
|
import type { DidService } from '@web5/dids';
|
|
18
|
-
import {
|
|
19
|
-
import { Appendix } from '
|
|
20
|
-
import { DidDocument, DidVerificationMethod } from '
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
15
|
+
import { canonicalization } from '../did-btcr2.js';
|
|
16
|
+
import { Appendix } from '../utils/appendix.js';
|
|
17
|
+
import { DidDocument, DidVerificationMethod } from '../utils/did-document.js';
|
|
18
|
+
import { BeaconService } from './beacon/interfaces.js';
|
|
19
|
+
import { Identifier } from './identifier.js';
|
|
20
|
+
import { SidecarData } from './types.js';
|
|
24
21
|
|
|
25
22
|
export interface ConstructUpdateParams {
|
|
26
23
|
identifier: string;
|
|
@@ -36,7 +33,7 @@ export interface UpdateParams extends ConstructUpdateParams {
|
|
|
36
33
|
|
|
37
34
|
export type InvokePayloadParams = {
|
|
38
35
|
identifier: string;
|
|
39
|
-
|
|
36
|
+
BTCR2SignedUpdate: BTCR2SignedUpdate;
|
|
40
37
|
verificationMethod: DidVerificationMethod;
|
|
41
38
|
}
|
|
42
39
|
|
|
@@ -65,7 +62,7 @@ export class Update {
|
|
|
65
62
|
* @param {DidDocument} params.sourceDocument The source document to be updated.
|
|
66
63
|
* @param {string} params.sourceVersionId The versionId of the source document.
|
|
67
64
|
* @param {DidDocumentPatch} params.patch The JSON patch to be applied to the source document.
|
|
68
|
-
* @returns {Promise<
|
|
65
|
+
* @returns {Promise<BTCR2SignedUpdate>} The constructed BTCR2SignedUpdate object.
|
|
69
66
|
* @throws {MethodError} InvalidDid if sourceDocument.id does not match identifier.
|
|
70
67
|
*/
|
|
71
68
|
public static async construct({
|
|
@@ -78,76 +75,79 @@ export class Update {
|
|
|
78
75
|
sourceDocument: DidDocument;
|
|
79
76
|
sourceVersionId: number;
|
|
80
77
|
patch: PatchOperation[];
|
|
81
|
-
}): Promise<
|
|
78
|
+
}): Promise<BTCR2UnsignedUpdate> {
|
|
82
79
|
|
|
83
80
|
// 1. Check that sourceDocument.id equals identifier else MUST raise invalidDIDUpdate error.
|
|
84
81
|
if (sourceDocument.id !== identifier) {
|
|
85
|
-
throw new
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{ sourceDocument, identifier}
|
|
82
|
+
throw new UpdateError(
|
|
83
|
+
'Identifier mismatch: sourceDocument.id !== identifier',
|
|
84
|
+
INVALID_DID_UPDATE, { sourceDocument, identifier }
|
|
89
85
|
);
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
// 2. Initialize
|
|
93
|
-
const
|
|
94
|
-
// 3. Set
|
|
95
|
-
'@context' :
|
|
96
|
-
|
|
88
|
+
// 2. Initialize an unsigned update.
|
|
89
|
+
const unsignedUpdate: BTCR2UnsignedUpdate = {
|
|
90
|
+
// 3. Set BTCR2SignedUpdate.@context to the following list
|
|
91
|
+
'@context' : [
|
|
92
|
+
'https://w3id.org/security/v2',
|
|
93
|
+
'https://w3id.org/zcap/v1',
|
|
94
|
+
'https://w3id.org/json-ld-patch/v1',
|
|
95
|
+
'https://btcr2.dev/context/v1'
|
|
96
|
+
],
|
|
97
|
+
// 4. Set BTCR2SignedUpdate.patch to documentPatch.
|
|
97
98
|
patch,
|
|
98
99
|
targetHash : '',
|
|
99
100
|
targetVersionId : 0,
|
|
100
101
|
sourceHash : '',
|
|
101
102
|
};
|
|
102
|
-
// TODO: Need to add btcr2 context. ["https://w3id.org/zcap/v1", "https://w3id.org/security/data-integrity/v2", "https://w3id.org/json-ld-patch/v1"]
|
|
103
103
|
|
|
104
104
|
// 5. Set targetDocument to the result of applying the documentPatch to the sourceDocument, following the JSON Patch
|
|
105
105
|
// specification.
|
|
106
|
-
const targetDocument =
|
|
106
|
+
const targetDocument = JSONPatch.apply(sourceDocument, patch) as DidDocument;
|
|
107
107
|
|
|
108
108
|
// 6. Validate targetDocument is a conformant DID document, else MUST raise invalidDIDUpdate error.
|
|
109
109
|
DidDocument.validate(targetDocument);
|
|
110
110
|
|
|
111
111
|
// 7. Set sourceHashBytes to the result of passing sourceDocument into the JSON Canonicalization and Hash algorithm.
|
|
112
|
-
// 8. Set
|
|
113
|
-
|
|
112
|
+
// 8. Set BTCR2SignedUpdate.sourceHash to the base58-btc Multibase encoding of sourceHashBytes.
|
|
113
|
+
unsignedUpdate.sourceHash = (canonicalization.process(sourceDocument, { encoding: 'base58' })).slice(1);
|
|
114
114
|
// TODO: Question - is base58btc the correct encoding scheme?
|
|
115
115
|
|
|
116
116
|
// 9. Set targetHashBytes to the result of passing targetDocument into the JSON Canonicalization and Hash algorithm.
|
|
117
|
-
// 10. Set
|
|
118
|
-
|
|
117
|
+
// 10. Set BTCR2SignedUpdate.targetHash to the base58-btc Multibase encoding of targetHashBytes.
|
|
118
|
+
unsignedUpdate.targetHash = (canonicalization.process(targetDocument, { encoding: 'base58' })).slice(1);
|
|
119
119
|
|
|
120
|
-
// 11. Set
|
|
121
|
-
|
|
120
|
+
// 11. Set BTCR2SignedUpdate.targetVersionId to sourceVersionId + 1.
|
|
121
|
+
unsignedUpdate.targetVersionId = sourceVersionId + 1;
|
|
122
122
|
|
|
123
123
|
// 12. Return updatePayload.
|
|
124
|
-
return
|
|
124
|
+
return unsignedUpdate;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* {@link https://dcdpr.github.io/did-btcr2/#invoke-did-update-payload | 4.3.2 Invoke DID Update Payload}.
|
|
129
129
|
*
|
|
130
|
-
* The Invoke DID Update Payload algorithm takes in a Identifier, an unsigned
|
|
130
|
+
* The Invoke DID Update Payload algorithm takes in a Identifier, an unsigned BTCR2SignedUpdate, and a
|
|
131
131
|
* verificationMethod. It retrieves the privateKeyBytes for the verificationMethod and adds a capability invocation in
|
|
132
132
|
* the form of a Data Integrity proof following the Authorization Capabilities (ZCAP-LD) and VC Data Integrity
|
|
133
133
|
* specifications. It returns the invoked DID Update Payload.
|
|
134
134
|
*
|
|
135
135
|
* @param {InvokePayloadParams} params Required params for calling the invokePayload method
|
|
136
136
|
* @param {string} params.identifier The did-btcr2 identifier to derive the root capability from
|
|
137
|
-
* @param {
|
|
137
|
+
* @param {BTCR2SignedUpdate} params.BTCR2SignedUpdate The updatePayload object to be signed
|
|
138
138
|
* @param {DidVerificationMethod} params.verificationMethod The verificationMethod object to be used for signing
|
|
139
|
-
* @returns {
|
|
139
|
+
* @returns {BTCR2SignedUpdate} Did update payload secured with a proof => BTCR2SignedUpdate
|
|
140
140
|
* @throws {MethodError} if the privateKeyBytes are invalid
|
|
141
141
|
*/
|
|
142
142
|
public static async invoke({
|
|
143
143
|
identifier,
|
|
144
|
-
|
|
144
|
+
unsignedUpdate,
|
|
145
145
|
verificationMethod
|
|
146
146
|
}: {
|
|
147
147
|
identifier: string;
|
|
148
|
-
|
|
148
|
+
unsignedUpdate: BTCR2UnsignedUpdate;
|
|
149
149
|
verificationMethod: DidVerificationMethod;
|
|
150
|
-
}): Promise<
|
|
150
|
+
}): Promise<BTCR2SignedUpdate> {
|
|
151
151
|
// Deconstruct the verificationMethod
|
|
152
152
|
const { id: fullId, controller, publicKeyMultibase, secretKeyMultibase } = verificationMethod;
|
|
153
153
|
|
|
@@ -169,7 +169,7 @@ export class Update {
|
|
|
169
169
|
const keyUri = new CompressedSecp256k1PublicKey(components.genesisBytes).hex;
|
|
170
170
|
const keys = secretKeyMultibase
|
|
171
171
|
? new SchnorrKeyPair({ secretKey: Secp256k1SecretKey.decode(secretKeyMultibase) })
|
|
172
|
-
:
|
|
172
|
+
: Kms.getKey(keyUri as string);
|
|
173
173
|
if (!keys) {
|
|
174
174
|
throw new MethodError(
|
|
175
175
|
'No privateKey found in kms or vm',
|
|
@@ -199,7 +199,13 @@ export class Update {
|
|
|
199
199
|
// 7. Set proofOptions.proofPurpose to capabilityInvocation.
|
|
200
200
|
// 8. Set proofOptions.capability to rootCapability.id.
|
|
201
201
|
// 9. Set proofOptions.capabilityAction to Write.
|
|
202
|
-
const
|
|
202
|
+
const config: DataIntegrityConfig = {
|
|
203
|
+
'@context' : [
|
|
204
|
+
'https://w3id.org/security/v2',
|
|
205
|
+
'https://w3id.org/zcap/v1',
|
|
206
|
+
'https://w3id.org/json-ld-patch/v1',
|
|
207
|
+
'https://btcr2.dev/context/v1'
|
|
208
|
+
],
|
|
203
209
|
cryptosuite,
|
|
204
210
|
type : 'DataIntegrityProof',
|
|
205
211
|
verificationMethod : fullId,
|
|
@@ -210,12 +216,12 @@ export class Update {
|
|
|
210
216
|
|
|
211
217
|
// 10. Set cryptosuite to the result of executing the Cryptosuite Instantiation algorithm from the BIP340 Data
|
|
212
218
|
// Integrity specification passing in proofOptions.
|
|
213
|
-
const diproof = multikey.toCryptosuite(
|
|
219
|
+
const diproof = multikey.toCryptosuite().toDataIntegrityProof();
|
|
214
220
|
|
|
215
|
-
// 12. Set
|
|
216
|
-
//
|
|
217
|
-
// 13. Return
|
|
218
|
-
return await diproof.addProof(
|
|
221
|
+
// 12. Set BTCR2SignedUpdate to the result of executing the Add Proof algorithm from VC Data Integrity passing
|
|
222
|
+
// BTCR2SignedUpdate as the input document, cryptosuite, and the set of proofOptions.
|
|
223
|
+
// 13. Return BTCR2SignedUpdate.
|
|
224
|
+
return await diproof.addProof(unsignedUpdate, config);
|
|
219
225
|
}
|
|
220
226
|
|
|
221
227
|
/**
|
|
@@ -223,30 +229,30 @@ export class Update {
|
|
|
223
229
|
*
|
|
224
230
|
* The Announce DID Update algorithm retrieves beaconServices from the sourceDocument and calls the Broadcast DID
|
|
225
231
|
* Update algorithm corresponding to the type of the Beacon. It takes in a Identifier, sourceDocument, an array of
|
|
226
|
-
* beaconIds, and a
|
|
227
|
-
* data to validate the Beacon Signal against the
|
|
232
|
+
* beaconIds, and a BTCR2SignedUpdate. It returns an array of signalsMetadata, containing the necessary
|
|
233
|
+
* data to validate the Beacon Signal against the BTCR2SignedUpdate.
|
|
228
234
|
*
|
|
229
235
|
* @param {AnnounceUpdatePayloadParams} params Required params for calling the announcePayload method
|
|
230
236
|
* @param {DidDocument} params.sourceDocument The did-btcr2 did document to derive the root capability from
|
|
231
|
-
* @param {string[]} params.beaconIds The
|
|
232
|
-
* @param {
|
|
233
|
-
* @returns {
|
|
237
|
+
* @param {string[]} params.beaconIds The BTCR2SignedUpdate object to be signed
|
|
238
|
+
* @param {BTCR2SignedUpdate} params.BTCR2SignedUpdate The verificationMethod object to be used for signing
|
|
239
|
+
* @returns {BTCR2SignedUpdate} The BTCR2SignedUpdate object containing data to validate the Beacon Signal
|
|
234
240
|
* @throws {MethodError} if the beaconService type is invalid
|
|
235
241
|
*/
|
|
236
242
|
public static async announce({
|
|
237
243
|
sourceDocument,
|
|
238
244
|
beaconIds,
|
|
239
|
-
|
|
245
|
+
signedUpdate
|
|
240
246
|
}: {
|
|
241
247
|
sourceDocument: DidDocument;
|
|
242
248
|
beaconIds: string[];
|
|
243
|
-
|
|
244
|
-
}): Promise<
|
|
249
|
+
signedUpdate: BTCR2SignedUpdate;
|
|
250
|
+
}): Promise<SidecarData> {
|
|
245
251
|
// 1. Set beaconServices to an empty array.
|
|
246
252
|
const beaconServices: BeaconService[] = [];
|
|
247
253
|
|
|
248
|
-
// 2.
|
|
249
|
-
let
|
|
254
|
+
// 2. sidecarData to an empty array.
|
|
255
|
+
let sidecarData: SidecarData | undefined;
|
|
250
256
|
|
|
251
257
|
// 3. For beaconId in beaconIds:
|
|
252
258
|
for (const beaconId of beaconIds) {
|
|
@@ -266,27 +272,28 @@ export class Update {
|
|
|
266
272
|
for (const beaconService of beaconServices) {
|
|
267
273
|
// 4.1 Set signalMetadata to null.
|
|
268
274
|
// 4.2 If beaconService.type == SingletonBeacon:
|
|
269
|
-
// 4.2.1 Set signalMetadata to the result of passing beaconService and
|
|
275
|
+
// 4.2.1 Set signalMetadata to the result of passing beaconService and BTCR2SignedUpdate to the Broadcast
|
|
270
276
|
// Singleton Beacon Signal algorithm.
|
|
271
|
-
// 4.3 Else If beaconService.type ==
|
|
272
|
-
// 4.3.1 Set signalMetadata to the result of passing Identifier, beaconService and
|
|
277
|
+
// 4.3 Else If beaconService.type == CASBeacon:
|
|
278
|
+
// 4.3.1 Set signalMetadata to the result of passing Identifier, beaconService and BTCR2SignedUpdate to
|
|
273
279
|
// the Broadcast CIDAggregate Beacon Signal algorithm.
|
|
274
|
-
// 4.4 Else If beaconService.type ==
|
|
275
|
-
// 4.4.1 Set signalMetadata to the result of passing Identifier, beaconService and
|
|
280
|
+
// 4.4 Else If beaconService.type == SMTBeacon:
|
|
281
|
+
// 4.4.1 Set signalMetadata to the result of passing Identifier, beaconService and BTCR2SignedUpdate to
|
|
276
282
|
// the Broadcast SMTAggregate Beacon Signal algorithm.
|
|
277
283
|
// 4.5 Else:
|
|
278
284
|
// 4.5.1 MUST throw invalidBeacon error.
|
|
279
|
-
const beacon = BeaconFactory.establish(beaconService);
|
|
280
|
-
|
|
285
|
+
// const beacon = BeaconFactory.establish(beaconService);
|
|
286
|
+
// sidecarData = await beacon.broadcastSignal(signedUpdate);
|
|
287
|
+
console.log('TODO: refactor this code', signedUpdate, beaconService);
|
|
281
288
|
}
|
|
282
|
-
if(!
|
|
289
|
+
if(!sidecarData) {
|
|
283
290
|
throw new MethodError(
|
|
284
|
-
'Invalid beacon: no
|
|
291
|
+
'Invalid beacon: no sidecarData found',
|
|
285
292
|
INVALID_DID_DOCUMENT, { beaconServices }
|
|
286
293
|
);
|
|
287
294
|
}
|
|
288
|
-
|
|
289
|
-
// Return the
|
|
290
|
-
return
|
|
295
|
+
|
|
296
|
+
// Return the sidecarData
|
|
297
|
+
return sidecarData;
|
|
291
298
|
}
|
|
292
299
|
}
|