@did-btcr2/method 0.59.0 → 0.61.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.
@@ -4,6 +4,7 @@ import { canonicalHash, INVALID_DID_UPDATE, JSONPatch, UpdateError } from '@did-
4
4
  import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
5
5
  import type { Signer } from '@did-btcr2/keypair';
6
6
  import type { Btcr2DataIntegrityConfig, SignedBTCR2Update, UnsignedBTCR2Update } from './btcr2-update.js';
7
+ import { BTCR2_UPDATE_CONTEXT } from './btcr2-update.js';
7
8
  import { DidDocument, type Btcr2DidDocument, type DidVerificationMethod } from '../utils/did-document.js';
8
9
  import type { BroadcastResult } from './beacon/beacon.js';
9
10
  import type { CASBroadcastOptions } from './beacon/cas-beacon.js';
@@ -214,12 +215,9 @@ export class Updater {
214
215
  sourceVersionId: number,
215
216
  ): UnsignedBTCR2Update {
216
217
  const unsignedUpdate: UnsignedBTCR2Update = {
217
- '@context' : [
218
- 'https://w3id.org/security/v2',
219
- 'https://w3id.org/zcap/v1',
220
- 'https://w3id.org/json-ld-patch/v1',
221
- 'https://btcr2.dev/context/v1'
222
- ],
218
+ // The array the specification pins, as a fresh copy: the update is a plain JSON
219
+ // object that callers may edit, and the shared constant is frozen.
220
+ '@context' : [ ...BTCR2_UPDATE_CONTEXT ],
223
221
  patch : patches,
224
222
  targetHash : '',
225
223
  targetVersionId : sourceVersionId + 1,
@@ -311,12 +309,10 @@ export class Updater {
311
309
  }
312
310
 
313
311
  const config: Btcr2DataIntegrityConfig = {
314
- '@context' : [
315
- 'https://w3id.org/security/v2',
316
- 'https://w3id.org/zcap/v1',
317
- 'https://w3id.org/json-ld-patch/v1',
318
- 'https://btcr2.dev/context/v1'
319
- ],
312
+ // The proof must carry the same array as the update. The cryptosuite copies the
313
+ // document @context into the proof when the document has one, so the two arrays
314
+ // are equal by construction; this value is the fallback for a document without one.
315
+ '@context' : [ ...BTCR2_UPDATE_CONTEXT ],
320
316
  cryptosuite : 'bip340-jcs-2025',
321
317
  type : 'DataIntegrityProof',
322
318
  // The proof names the signing method by absolute DID URL, even when the document
@@ -161,9 +161,10 @@ export class Appendix {
161
161
  * ```
162
162
  * {
163
163
  * "@context": [
164
+ * "https://w3id.org/json-ld-patch/v1",
164
165
  * "https://w3id.org/zcap/v1",
165
166
  * "https://w3id.org/security/data-integrity/v2",
166
- * "https://w3id.org/json-ld-patch/v1"
167
+ * "https://btcr2.dev/context/v1"
167
168
  * ],
168
169
  * "patch": [
169
170
  * {