@did-btcr2/method 0.40.1 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/browser.js +18 -15
  3. package/dist/browser.mjs +18 -15
  4. package/dist/esm/core/btcr2-update.js +2 -0
  5. package/dist/esm/core/btcr2-update.js.map +1 -0
  6. package/dist/esm/core/updater.js.map +1 -1
  7. package/dist/esm/index.js +1 -0
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/types/core/beacon/beacon.d.ts +1 -1
  10. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  11. package/dist/types/core/beacon/cas-beacon.d.ts +1 -1
  12. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  13. package/dist/types/core/beacon/singleton-beacon.d.ts +1 -1
  14. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  15. package/dist/types/core/beacon/smt-beacon.d.ts +1 -1
  16. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  17. package/dist/types/core/btcr2-update.d.ts +76 -0
  18. package/dist/types/core/btcr2-update.d.ts.map +1 -0
  19. package/dist/types/core/resolver.d.ts +1 -1
  20. package/dist/types/core/resolver.d.ts.map +1 -1
  21. package/dist/types/core/types.d.ts +1 -1
  22. package/dist/types/core/types.d.ts.map +1 -1
  23. package/dist/types/core/updater.d.ts +1 -1
  24. package/dist/types/core/updater.d.ts.map +1 -1
  25. package/dist/types/index.d.ts +1 -0
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/package.json +4 -4
  28. package/src/core/beacon/beacon.ts +1 -1
  29. package/src/core/beacon/cas-beacon.ts +1 -1
  30. package/src/core/beacon/singleton-beacon.ts +1 -1
  31. package/src/core/beacon/smt-beacon.ts +1 -1
  32. package/src/core/btcr2-update.ts +87 -0
  33. package/src/core/resolver.ts +1 -1
  34. package/src/core/types.ts +1 -1
  35. package/src/core/updater.ts +3 -2
  36. package/src/index.ts +1 -0
@@ -0,0 +1,87 @@
1
+ import type { PatchOperation } from '@did-btcr2/common';
2
+ import type { DataIntegrityProofObject, DataIntegrityProofOptions } from '@did-btcr2/cryptosuite';
3
+
4
+ /**
5
+ * A {@link https://dcdpr.github.io/did-btcr2/terminology.html#btcr2-update | BTCR2 Update} without a data integrity proof.
6
+ * See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#btcr2-unsigned-update | BTCR2 Unsigned Update (data structure)}.
7
+ *
8
+ * This is the did:btcr2-specific document the generic `@did-btcr2/cryptosuite`
9
+ * suite secures; the suite itself is method-agnostic and knows nothing about it.
10
+ * Declared as a type alias (not an interface) so it satisfies the suite's
11
+ * generic `UnsecuredDocument` (a plain JSON record) constraint.
12
+ */
13
+ export type UnsignedBTCR2Update = {
14
+ /**
15
+ * JSON-LD context URIs for interpreting this payload, including contexts
16
+ * for ZCAP (capabilities), Data Integrity proofs, and JSON-LD patch ops.
17
+ */
18
+ '@context': string[];
19
+
20
+ /**
21
+ * A JSON Patch (or JSON-LD Patch) object defining the mutations to apply to
22
+ * the DID Document. Applying this patch to the current DID Document yields
23
+ * the new DID Document (which must remain valid per DID Core spec).
24
+ */
25
+ patch: Array<PatchOperation>;
26
+
27
+ /**
28
+ * The multihash of the current (source) DID Document, encoded as a multibase
29
+ * base58-btc string. This is a SHA-256 hash of the canonicalized source DID
30
+ * Document, used to ensure the patch is applied to the correct document state.
31
+ */
32
+ sourceHash: string;
33
+
34
+ /**
35
+ * The multihash of the updated (target) DID Document, encoded as multibase
36
+ * base58-btc. This is the SHA-256 hash of the canonicalized DID Document
37
+ * after applying the patch, used to verify the update result.
38
+ */
39
+ targetHash: string;
40
+
41
+ /**
42
+ * The version number of the DID Document after this update.
43
+ * It is equal to the previous document version + 1.
44
+ */
45
+ targetVersionId: number;
46
+ };
47
+
48
+ /**
49
+ * A Data Integrity proof on a BTCR2 update: the generic proof object plus the
50
+ * ZCAP capability-invocation fields a did:btcr2 update proof carries.
51
+ */
52
+ export type Btcr2DataIntegrityProof = DataIntegrityProofObject & {
53
+ /** The root capability being invoked, e.g. `urn:zcap:root:<urlencoded-did>`. */
54
+ capability?: string;
55
+
56
+ /** The action performed under the capability, set to `"Write"` for DID document updates. */
57
+ capabilityAction?: string;
58
+ };
59
+
60
+ /**
61
+ * A {@link https://dcdpr.github.io/did-btcr2/terminology.html#btcr2-signed-update | BTCR2 Update} with a data integrity proof.
62
+ * See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#btcr2-signed-update | BTCR2 Signed Update (data structure)}.
63
+ */
64
+ export type SignedBTCR2Update = UnsignedBTCR2Update & {
65
+ /** The Data Integrity proof that converts an unsigned update into a signed update. */
66
+ proof: Btcr2DataIntegrityProof;
67
+ };
68
+
69
+ /** Either form of a BTCR2 Update. */
70
+ export type BTCR2Update = UnsignedBTCR2Update | SignedBTCR2Update;
71
+
72
+ /**
73
+ * Data Integrity proof options for a BTCR2 update: the standard
74
+ * {@link DataIntegrityProofOptions} plus the ZCAP capability-invocation fields a
75
+ * did:btcr2 update proof carries. See
76
+ * {@link https://dcdpr.github.io/did-btcr2/data-structures.html#data-integrity-config | Data Integrity Config}.
77
+ */
78
+ export type Btcr2DataIntegrityConfig = DataIntegrityProofOptions & {
79
+ /** JSON-LD context URIs for the proof (ZCAP, Data Integrity, JSON-LD patch). */
80
+ '@context': string[];
81
+
82
+ /** The root capability being invoked, e.g. `urn:zcap:root:<urlencoded-did>`. */
83
+ capability?: string;
84
+
85
+ /** The action performed under the capability, set to `"Write"` for DID document updates. */
86
+ capabilityAction?: string;
87
+ };
@@ -17,7 +17,7 @@ import type { HashBytes } from '@did-btcr2/common';
17
17
  import type {
18
18
  SignedBTCR2Update,
19
19
  UnsignedBTCR2Update
20
- } from '@did-btcr2/cryptosuite';
20
+ } from './btcr2-update.js';
21
21
  import {
22
22
  BIP340Cryptosuite,
23
23
  BIP340DataIntegrityProof,
package/src/core/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
1
+ import type { SignedBTCR2Update } from './btcr2-update.js';
2
2
  import type { SMTProof } from './interfaces.js';
3
3
 
4
4
  /**
@@ -1,8 +1,9 @@
1
1
  import type { BitcoinConnection } from '@did-btcr2/bitcoin';
2
2
  import type { PatchOperation } from '@did-btcr2/common';
3
3
  import { canonicalHash, INVALID_DID_UPDATE, JSONPatch, UpdateError } from '@did-btcr2/common';
4
- import { SchnorrMultikey, type DataIntegrityConfig, type SignedBTCR2Update, type UnsignedBTCR2Update } from '@did-btcr2/cryptosuite';
4
+ import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
5
5
  import type { Signer } from '@did-btcr2/keypair';
6
+ import type { Btcr2DataIntegrityConfig, SignedBTCR2Update, UnsignedBTCR2Update } from './btcr2-update.js';
6
7
  import { DidDocument, type Btcr2DidDocument, type DidVerificationMethod } from '../utils/did-document.js';
7
8
  import { BeaconFactory } from './beacon/factory.js';
8
9
  import type { BeaconService } from './beacon/interfaces.js';
@@ -287,7 +288,7 @@ export class Updater {
287
288
  );
288
289
  }
289
290
 
290
- const config: DataIntegrityConfig = {
291
+ const config: Btcr2DataIntegrityConfig = {
291
292
  '@context' : [
292
293
  'https://w3id.org/security/v2',
293
294
  'https://w3id.org/zcap/v1',
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export * from './core/beacon/smt-beacon.js';
11
11
  export * from './core/beacon/utils.js';
12
12
 
13
13
  // Core
14
+ export * from './core/btcr2-update.js';
14
15
  export * from './core/did-sender-resolver.js';
15
16
  export * from './core/identifier.js';
16
17
  export * from './core/interfaces.js';