@bcts/provenance-mark 1.0.0-alpha.21 → 1.0.0-alpha.23

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.
@@ -1,9 +1,7 @@
1
1
  var bctsProvenanceMark = (function(exports, _bcts_dcbor, _noble_hashes_sha2_js, _noble_hashes_hkdf_js, _noble_ciphers_chacha_js, _bcts_rand, _bcts_tags, _bcts_uniform_resources, _bcts_envelope) {
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- //#region src/error.ts
6
- /**
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ //#region src/error.ts
4
+ /**
7
5
  * Copyright © 2023-2026 Blockchain Commons, LLC
8
6
  * Copyright © 2025-2026 Parity Technologies
9
7
  *
@@ -81,37 +79,36 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
81
79
  return JSON.stringify(value);
82
80
  };
83
81
  switch (type) {
84
- case ProvenanceMarkErrorType.InvalidSeedLength: return `invalid seed length: expected 32 bytes, got ${d("actual")} bytes`;
85
- case ProvenanceMarkErrorType.DuplicateKey: return `duplicate key: ${d("key")}`;
86
- case ProvenanceMarkErrorType.MissingKey: return `missing key: ${d("key")}`;
87
- case ProvenanceMarkErrorType.InvalidKey: return `invalid key: ${d("key")}`;
88
- case ProvenanceMarkErrorType.ExtraKeys: return `wrong number of keys: expected ${d("expected")}, got ${d("actual")}`;
89
- case ProvenanceMarkErrorType.InvalidKeyLength: return `invalid key length: expected ${d("expected")}, got ${d("actual")}`;
90
- case ProvenanceMarkErrorType.InvalidNextKeyLength: return `invalid next key length: expected ${d("expected")}, got ${d("actual")}`;
91
- case ProvenanceMarkErrorType.InvalidChainIdLength: return `invalid chain ID length: expected ${d("expected")}, got ${d("actual")}`;
92
- case ProvenanceMarkErrorType.InvalidMessageLength: return `invalid message length: expected at least ${d("expected")}, got ${d("actual")}`;
93
- case ProvenanceMarkErrorType.InvalidInfoCbor: return "invalid CBOR data in info field";
94
- case ProvenanceMarkErrorType.DateOutOfRange: return `date out of range: ${d("details")}`;
95
- case ProvenanceMarkErrorType.InvalidDate: return `invalid date: ${d("details")}`;
96
- case ProvenanceMarkErrorType.MissingUrlParameter: return `missing required URL parameter: ${d("parameter")}`;
97
- case ProvenanceMarkErrorType.YearOutOfRange: return `year out of range for 2-byte serialization: must be between 2023-2150, got ${d("year")}`;
98
- case ProvenanceMarkErrorType.InvalidMonthOrDay: return `invalid month (${d("month")}) or day (${d("day")}) for year ${d("year")}`;
99
- case ProvenanceMarkErrorType.ResolutionError: return `resolution serialization error: ${d("details")}`;
100
- case ProvenanceMarkErrorType.BytewordsError: return `bytewords error: ${d("message")}`;
101
- case ProvenanceMarkErrorType.CborError: return `CBOR error: ${d("message")}`;
102
- case ProvenanceMarkErrorType.UrlError: return `URL parsing error: ${d("message")}`;
103
- case ProvenanceMarkErrorType.Base64Error: return `base64 decoding error: ${d("message")}`;
104
- case ProvenanceMarkErrorType.JsonError: return `JSON error: ${d("message")}`;
105
- case ProvenanceMarkErrorType.IntegerConversionError: return `integer conversion error: ${d("message")}`;
106
- case ProvenanceMarkErrorType.ValidationError: return `validation error: ${d("message")}`;
82
+ case "InvalidSeedLength": return `invalid seed length: expected 32 bytes, got ${d("actual")} bytes`;
83
+ case "DuplicateKey": return `duplicate key: ${d("key")}`;
84
+ case "MissingKey": return `missing key: ${d("key")}`;
85
+ case "InvalidKey": return `invalid key: ${d("key")}`;
86
+ case "ExtraKeys": return `wrong number of keys: expected ${d("expected")}, got ${d("actual")}`;
87
+ case "InvalidKeyLength": return `invalid key length: expected ${d("expected")}, got ${d("actual")}`;
88
+ case "InvalidNextKeyLength": return `invalid next key length: expected ${d("expected")}, got ${d("actual")}`;
89
+ case "InvalidChainIdLength": return `invalid chain ID length: expected ${d("expected")}, got ${d("actual")}`;
90
+ case "InvalidMessageLength": return `invalid message length: expected at least ${d("expected")}, got ${d("actual")}`;
91
+ case "InvalidInfoCbor": return "invalid CBOR data in info field";
92
+ case "DateOutOfRange": return `date out of range: ${d("details")}`;
93
+ case "InvalidDate": return `invalid date: ${d("details")}`;
94
+ case "MissingUrlParameter": return `missing required URL parameter: ${d("parameter")}`;
95
+ case "YearOutOfRange": return `year out of range for 2-byte serialization: must be between 2023-2150, got ${d("year")}`;
96
+ case "InvalidMonthOrDay": return `invalid month (${d("month")}) or day (${d("day")}) for year ${d("year")}`;
97
+ case "ResolutionError": return `resolution serialization error: ${d("details")}`;
98
+ case "BytewordsError": return `bytewords error: ${d("message")}`;
99
+ case "CborError": return `CBOR error: ${d("message")}`;
100
+ case "UrlError": return `URL parsing error: ${d("message")}`;
101
+ case "Base64Error": return `base64 decoding error: ${d("message")}`;
102
+ case "JsonError": return `JSON error: ${d("message")}`;
103
+ case "IntegerConversionError": return `integer conversion error: ${d("message")}`;
104
+ case "ValidationError": return `validation error: ${d("message")}`;
107
105
  default: return type;
108
106
  }
109
107
  }
110
108
  };
111
-
112
- //#endregion
113
- //#region src/date.ts
114
- /**
109
+ //#endregion
110
+ //#region src/date.ts
111
+ /**
115
112
  * Copyright © 2023-2026 Blockchain Commons, LLC
116
113
  * Copyright © 2025-2026 Parity Technologies
117
114
  *
@@ -147,8 +144,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
147
144
  const month = date.getUTCMonth() + 1;
148
145
  const day = date.getUTCDate();
149
146
  const yy = year - 2023;
150
- if (yy < 0 || yy >= 128) throw new ProvenanceMarkError(ProvenanceMarkErrorType.YearOutOfRange, void 0, { year });
151
- if (month < 1 || month > 12 || day < 1 || day > 31) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidMonthOrDay, void 0, {
147
+ if (yy < 0 || yy >= 128) throw new ProvenanceMarkError("YearOutOfRange", void 0, { year });
148
+ if (month < 1 || month > 12 || day < 1 || day > 31) throw new ProvenanceMarkError("InvalidMonthOrDay", void 0, {
152
149
  year,
153
150
  month,
154
151
  day
@@ -163,12 +160,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
163
160
  * Deserialize 2 bytes to a date.
164
161
  */
165
162
  function deserialize2Bytes(bytes) {
166
- if (bytes.length !== 2) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidDate, void 0, { details: `expected 2 bytes, got ${bytes.length}` });
163
+ if (bytes.length !== 2) throw new ProvenanceMarkError("InvalidDate", void 0, { details: `expected 2 bytes, got ${bytes.length}` });
167
164
  const value = bytes[0] << 8 | bytes[1];
168
165
  const day = value & 31;
169
166
  const month = value >> 5 & 15;
170
167
  const year = (value >> 9 & 127) + 2023;
171
- if (month < 1 || month > 12 || !isValidDay(year, month, day)) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidMonthOrDay, void 0, {
168
+ if (month < 1 || month > 12 || !isValidDay(year, month, day)) throw new ProvenanceMarkError("InvalidMonthOrDay", void 0, {
172
169
  year,
173
170
  month,
174
171
  day
@@ -181,7 +178,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
181
178
  function serialize4Bytes(date) {
182
179
  const duration = date.getTime() - REFERENCE_DATE;
183
180
  const seconds = Math.floor(duration / 1e3);
184
- if (seconds < 0 || seconds > 4294967295) throw new ProvenanceMarkError(ProvenanceMarkErrorType.DateOutOfRange, void 0, { details: "seconds value out of range for u32" });
181
+ if (seconds < 0 || seconds > 4294967295) throw new ProvenanceMarkError("DateOutOfRange", void 0, { details: "seconds value out of range for u32" });
185
182
  const buf = new Uint8Array(4);
186
183
  buf[0] = seconds >> 24 & 255;
187
184
  buf[1] = seconds >> 16 & 255;
@@ -193,7 +190,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
193
190
  * Deserialize 4 bytes to a date.
194
191
  */
195
192
  function deserialize4Bytes(bytes) {
196
- if (bytes.length !== 4) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidDate, void 0, { details: `expected 4 bytes, got ${bytes.length}` });
193
+ if (bytes.length !== 4) throw new ProvenanceMarkError("InvalidDate", void 0, { details: `expected 4 bytes, got ${bytes.length}` });
197
194
  const seconds = (bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3]) >>> 0;
198
195
  return new Date(REFERENCE_DATE + seconds * 1e3);
199
196
  }
@@ -203,7 +200,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
203
200
  function serialize6Bytes(date) {
204
201
  const duration = date.getTime() - REFERENCE_DATE;
205
202
  const milliseconds = BigInt(duration);
206
- if (milliseconds < 0n || milliseconds > BigInt(MAX_6_BYTE_VALUE)) throw new ProvenanceMarkError(ProvenanceMarkErrorType.DateOutOfRange, void 0, { details: "date exceeds maximum representable value" });
203
+ if (milliseconds < 0n || milliseconds > BigInt(MAX_6_BYTE_VALUE)) throw new ProvenanceMarkError("DateOutOfRange", void 0, { details: "date exceeds maximum representable value" });
207
204
  const buf = new Uint8Array(6);
208
205
  buf[0] = Number(milliseconds >> 40n & 255n);
209
206
  buf[1] = Number(milliseconds >> 32n & 255n);
@@ -217,9 +214,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
217
214
  * Deserialize 6 bytes to a date.
218
215
  */
219
216
  function deserialize6Bytes(bytes) {
220
- if (bytes.length !== 6) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidDate, void 0, { details: `expected 6 bytes, got ${bytes.length}` });
217
+ if (bytes.length !== 6) throw new ProvenanceMarkError("InvalidDate", void 0, { details: `expected 6 bytes, got ${bytes.length}` });
221
218
  const milliseconds = BigInt(bytes[0]) << 40n | BigInt(bytes[1]) << 32n | BigInt(bytes[2]) << 24n | BigInt(bytes[3]) << 16n | BigInt(bytes[4]) << 8n | BigInt(bytes[5]);
222
- if (milliseconds > BigInt(MAX_6_BYTE_VALUE)) throw new ProvenanceMarkError(ProvenanceMarkErrorType.DateOutOfRange, void 0, { details: "date exceeds maximum representable value" });
219
+ if (milliseconds > BigInt(MAX_6_BYTE_VALUE)) throw new ProvenanceMarkError("DateOutOfRange", void 0, { details: "date exceeds maximum representable value" });
223
220
  return new Date(REFERENCE_DATE + Number(milliseconds));
224
221
  }
225
222
  /**
@@ -242,7 +239,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
242
239
  */
243
240
  function dateFromIso8601(str) {
244
241
  const date = new Date(str);
245
- if (isNaN(date.getTime())) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidDate, void 0, { details: `cannot parse date: ${str}` });
242
+ if (isNaN(date.getTime())) throw new ProvenanceMarkError("InvalidDate", void 0, { details: `cannot parse date: ${str}` });
246
243
  return date;
247
244
  }
248
245
  /**
@@ -251,10 +248,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
251
248
  function dateToDateString(date) {
252
249
  return `${date.getUTCFullYear()}-${(date.getUTCMonth() + 1).toString().padStart(2, "0")}-${date.getUTCDate().toString().padStart(2, "0")}`;
253
250
  }
254
-
255
- //#endregion
256
- //#region src/resolution.ts
257
- /**
251
+ //#endregion
252
+ //#region src/resolution.ts
253
+ /**
258
254
  * Copyright © 2023-2026 Blockchain Commons, LLC
259
255
  * Copyright © 2025-2026 Parity Technologies
260
256
  *
@@ -281,11 +277,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
281
277
  */
282
278
  function resolutionFromNumber(value) {
283
279
  switch (value) {
284
- case 0: return ProvenanceMarkResolution.Low;
285
- case 1: return ProvenanceMarkResolution.Medium;
286
- case 2: return ProvenanceMarkResolution.Quartile;
287
- case 3: return ProvenanceMarkResolution.High;
288
- default: throw new ProvenanceMarkError(ProvenanceMarkErrorType.ResolutionError, void 0, { details: `invalid provenance mark resolution value: ${value}` });
280
+ case 0: return 0;
281
+ case 1: return 1;
282
+ case 2: return 2;
283
+ case 3: return 3;
284
+ default: throw new ProvenanceMarkError("ResolutionError", void 0, { details: `invalid provenance mark resolution value: ${value}` });
289
285
  }
290
286
  }
291
287
  /**
@@ -293,10 +289,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
293
289
  */
294
290
  function linkLength(res) {
295
291
  switch (res) {
296
- case ProvenanceMarkResolution.Low: return 4;
297
- case ProvenanceMarkResolution.Medium: return 8;
298
- case ProvenanceMarkResolution.Quartile: return 16;
299
- case ProvenanceMarkResolution.High: return 32;
292
+ case 0: return 4;
293
+ case 1: return 8;
294
+ case 2: return 16;
295
+ case 3: return 32;
300
296
  }
301
297
  }
302
298
  /**
@@ -304,10 +300,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
304
300
  */
305
301
  function seqBytesLength(res) {
306
302
  switch (res) {
307
- case ProvenanceMarkResolution.Low: return 2;
308
- case ProvenanceMarkResolution.Medium:
309
- case ProvenanceMarkResolution.Quartile:
310
- case ProvenanceMarkResolution.High: return 4;
303
+ case 0: return 2;
304
+ case 1:
305
+ case 2:
306
+ case 3: return 4;
311
307
  }
312
308
  }
313
309
  /**
@@ -315,10 +311,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
315
311
  */
316
312
  function dateBytesLength(res) {
317
313
  switch (res) {
318
- case ProvenanceMarkResolution.Low: return 2;
319
- case ProvenanceMarkResolution.Medium: return 4;
320
- case ProvenanceMarkResolution.Quartile:
321
- case ProvenanceMarkResolution.High: return 6;
314
+ case 0: return 2;
315
+ case 1: return 4;
316
+ case 2:
317
+ case 3: return 6;
322
318
  }
323
319
  }
324
320
  /**
@@ -386,10 +382,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
386
382
  */
387
383
  function serializeDate(res, date) {
388
384
  switch (res) {
389
- case ProvenanceMarkResolution.Low: return serialize2Bytes(date);
390
- case ProvenanceMarkResolution.Medium: return serialize4Bytes(date);
391
- case ProvenanceMarkResolution.Quartile:
392
- case ProvenanceMarkResolution.High: return serialize6Bytes(date);
385
+ case 0: return serialize2Bytes(date);
386
+ case 1: return serialize4Bytes(date);
387
+ case 2:
388
+ case 3: return serialize6Bytes(date);
393
389
  }
394
390
  }
395
391
  /**
@@ -397,15 +393,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
397
393
  */
398
394
  function deserializeDate(res, data) {
399
395
  switch (res) {
400
- case ProvenanceMarkResolution.Low:
401
- if (data.length !== 2) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ResolutionError, void 0, { details: `invalid date length: expected 2 bytes, got ${data.length}` });
396
+ case 0:
397
+ if (data.length !== 2) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `invalid date length: expected 2 bytes, got ${data.length}` });
402
398
  return deserialize2Bytes(data);
403
- case ProvenanceMarkResolution.Medium:
404
- if (data.length !== 4) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ResolutionError, void 0, { details: `invalid date length: expected 4 bytes, got ${data.length}` });
399
+ case 1:
400
+ if (data.length !== 4) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `invalid date length: expected 4 bytes, got ${data.length}` });
405
401
  return deserialize4Bytes(data);
406
- case ProvenanceMarkResolution.Quartile:
407
- case ProvenanceMarkResolution.High:
408
- if (data.length !== 6) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ResolutionError, void 0, { details: `invalid date length: expected 6 bytes, got ${data.length}` });
402
+ case 2:
403
+ case 3:
404
+ if (data.length !== 6) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `invalid date length: expected 6 bytes, got ${data.length}` });
409
405
  return deserialize6Bytes(data);
410
406
  }
411
407
  }
@@ -414,7 +410,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
414
410
  */
415
411
  function serializeSeq(res, seq) {
416
412
  if (seqBytesLength(res) === 2) {
417
- if (seq > 65535) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ResolutionError, void 0, { details: `sequence number ${seq} out of range for 2-byte format (max 65535)` });
413
+ if (seq > 65535) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `sequence number ${seq} out of range for 2-byte format (max 65535)` });
418
414
  const buf = new Uint8Array(2);
419
415
  buf[0] = seq >> 8 & 255;
420
416
  buf[1] = seq & 255;
@@ -433,10 +429,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
433
429
  */
434
430
  function deserializeSeq(res, data) {
435
431
  if (seqBytesLength(res) === 2) {
436
- if (data.length !== 2) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ResolutionError, void 0, { details: `invalid sequence number length: expected 2 bytes, got ${data.length}` });
432
+ if (data.length !== 2) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `invalid sequence number length: expected 2 bytes, got ${data.length}` });
437
433
  return data[0] << 8 | data[1];
438
434
  } else {
439
- if (data.length !== 4) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ResolutionError, void 0, { details: `invalid sequence number length: expected 4 bytes, got ${data.length}` });
435
+ if (data.length !== 4) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `invalid sequence number length: expected 4 bytes, got ${data.length}` });
440
436
  return (data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]) >>> 0;
441
437
  }
442
438
  }
@@ -445,10 +441,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
445
441
  */
446
442
  function resolutionToString(res) {
447
443
  switch (res) {
448
- case ProvenanceMarkResolution.Low: return "low";
449
- case ProvenanceMarkResolution.Medium: return "medium";
450
- case ProvenanceMarkResolution.Quartile: return "quartile";
451
- case ProvenanceMarkResolution.High: return "high";
444
+ case 0: return "low";
445
+ case 1: return "medium";
446
+ case 2: return "quartile";
447
+ case 3: return "high";
452
448
  }
453
449
  }
454
450
  /**
@@ -464,10 +460,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
464
460
  const value = (0, _bcts_dcbor.expectUnsigned)(cborValue);
465
461
  return resolutionFromNumber(Number(value));
466
462
  }
467
-
468
- //#endregion
469
- //#region src/crypto-utils.ts
470
- /**
463
+ //#endregion
464
+ //#region src/crypto-utils.ts
465
+ /**
471
466
  * Copyright © 2023-2026 Blockchain Commons, LLC
472
467
  * Copyright © 2025-2026 Parity Technologies
473
468
  *
@@ -508,10 +503,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
508
503
  for (let i = 0; i < 12; i++) iv[i] = extendedKey[31 - i];
509
504
  return (0, _noble_ciphers_chacha_js.chacha20)(extendedKey, iv, message instanceof Uint8Array ? message : new Uint8Array(message));
510
505
  }
511
-
512
- //#endregion
513
- //#region src/xoshiro256starstar.ts
514
- /**
506
+ //#endregion
507
+ //#region src/xoshiro256starstar.ts
508
+ /**
515
509
  * Copyright © 2023-2026 Blockchain Commons, LLC
516
510
  * Copyright © 2025-2026 Parity Technologies
517
511
  *
@@ -636,10 +630,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
636
630
  this.s[3] = this.rotateLeft64(this.s[3], 45n);
637
631
  }
638
632
  };
639
-
640
- //#endregion
641
- //#region src/rng-state.ts
642
- /**
633
+ //#endregion
634
+ //#region src/rng-state.ts
635
+ /**
643
636
  * Copyright © 2023-2026 Blockchain Commons, LLC
644
637
  * Copyright © 2025-2026 Parity Technologies
645
638
  *
@@ -663,7 +656,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
663
656
  * Create from a 32-byte array.
664
657
  */
665
658
  static fromBytes(bytes) {
666
- if (bytes.length !== RNG_STATE_LENGTH) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidSeedLength, void 0, { actual: bytes.length });
659
+ if (bytes.length !== 32) throw new ProvenanceMarkError("InvalidSeedLength", void 0, { actual: bytes.length });
667
660
  return new RngState(new Uint8Array(bytes));
668
661
  }
669
662
  /**
@@ -692,10 +685,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
692
685
  return RngState.fromBytes(bytes);
693
686
  }
694
687
  };
695
-
696
- //#endregion
697
- //#region src/seed.ts
698
- /**
688
+ //#endregion
689
+ //#region src/seed.ts
690
+ /**
699
691
  * Copyright © 2023-2026 Blockchain Commons, LLC
700
692
  * Copyright © 2025-2026 Parity Technologies
701
693
  *
@@ -713,15 +705,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
713
705
  * Create a new random seed using secure random number generation.
714
706
  */
715
707
  static new() {
716
- const data = (0, _bcts_rand.randomData)(PROVENANCE_SEED_LENGTH);
708
+ const data = (0, _bcts_rand.randomData)(32);
717
709
  return ProvenanceSeed.fromBytes(data);
718
710
  }
719
711
  /**
720
712
  * Create a new seed using custom random data.
721
713
  */
722
714
  static newUsing(randomData) {
723
- if (randomData.length < PROVENANCE_SEED_LENGTH) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidSeedLength, void 0, { actual: randomData.length });
724
- return ProvenanceSeed.fromBytes(randomData.slice(0, PROVENANCE_SEED_LENGTH));
715
+ if (randomData.length < 32) throw new ProvenanceMarkError("InvalidSeedLength", void 0, { actual: randomData.length });
716
+ return ProvenanceSeed.fromBytes(randomData.slice(0, 32));
725
717
  }
726
718
  /**
727
719
  * Create a new seed from a passphrase.
@@ -740,7 +732,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
740
732
  * Create from a 32-byte array.
741
733
  */
742
734
  static fromBytes(bytes) {
743
- if (bytes.length !== PROVENANCE_SEED_LENGTH) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidSeedLength, void 0, { actual: bytes.length });
735
+ if (bytes.length !== 32) throw new ProvenanceMarkError("InvalidSeedLength", void 0, { actual: bytes.length });
744
736
  return new ProvenanceSeed(new Uint8Array(bytes));
745
737
  }
746
738
  /**
@@ -769,10 +761,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
769
761
  return ProvenanceSeed.fromBytes(bytes);
770
762
  }
771
763
  };
772
-
773
- //#endregion
774
- //#region src/utils.ts
775
- /**
764
+ //#endregion
765
+ //#region src/utils.ts
766
+ /**
776
767
  * Copyright © 2023-2026 Blockchain Commons, LLC
777
768
  * Copyright © 2025-2026 Parity Technologies
778
769
  *
@@ -818,10 +809,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
818
809
  for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
819
810
  return bytes;
820
811
  }
821
-
822
- //#endregion
823
- //#region src/validate.ts
824
- /**
812
+ //#endregion
813
+ //#region src/validate.ts
814
+ /**
825
815
  * Format for validation report output.
826
816
  */
827
817
  let ValidationReportFormat = /* @__PURE__ */ function(ValidationReportFormat) {
@@ -893,7 +883,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
893
883
  if (!chain.hasGenesis) lines.push(" Warning: No genesis mark found");
894
884
  for (const seq of chain.sequences) for (const flaggedMark of seq.marks) {
895
885
  const mark = flaggedMark.mark;
896
- const shortId = mark.identifier();
886
+ const shortId = mark.idHex().slice(0, 8);
897
887
  const seqNum = mark.seq();
898
888
  const annotations = [];
899
889
  if (mark.isGenesis()) annotations.push("genesis mark");
@@ -933,9 +923,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
933
923
  */
934
924
  function formatReport(report, format) {
935
925
  switch (format) {
936
- case ValidationReportFormat.Text: return formatText(report);
937
- case ValidationReportFormat.JsonCompact: return JSON.stringify(reportToJSON(report));
938
- case ValidationReportFormat.JsonPretty: return JSON.stringify(reportToJSON(report), null, 2);
926
+ case "text": return formatText(report);
927
+ case "json-compact": return JSON.stringify(reportToJSON(report));
928
+ case "json-pretty": return JSON.stringify(reportToJSON(report), null, 2);
939
929
  }
940
930
  }
941
931
  /**
@@ -1091,10 +1081,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1091
1081
  for (let i = 0; i < hex.length; i += 2) bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
1092
1082
  return bytes;
1093
1083
  }
1094
-
1095
- //#endregion
1096
- //#region src/mark.ts
1097
- /**
1084
+ //#endregion
1085
+ //#region src/mark.ts
1086
+ /**
1098
1087
  * Copyright © 2023-2026 Blockchain Commons, LLC
1099
1088
  * Copyright © 2025-2026 Parity Technologies
1100
1089
  *
@@ -1173,15 +1162,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1173
1162
  */
1174
1163
  static new(res, key, nextKey, chainId, seq, date, info) {
1175
1164
  const linkLen = linkLength(res);
1176
- if (key.length !== linkLen) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidKeyLength, void 0, {
1165
+ if (key.length !== linkLen) throw new ProvenanceMarkError("InvalidKeyLength", void 0, {
1177
1166
  expected: linkLen,
1178
1167
  actual: key.length
1179
1168
  });
1180
- if (nextKey.length !== linkLen) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidNextKeyLength, void 0, {
1169
+ if (nextKey.length !== linkLen) throw new ProvenanceMarkError("InvalidNextKeyLength", void 0, {
1181
1170
  expected: linkLen,
1182
1171
  actual: nextKey.length
1183
1172
  });
1184
- if (chainId.length !== linkLen) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidChainIdLength, void 0, {
1173
+ if (chainId.length !== linkLen) throw new ProvenanceMarkError("InvalidChainIdLength", void 0, {
1185
1174
  expected: linkLen,
1186
1175
  actual: chainId.length
1187
1176
  });
@@ -1197,7 +1186,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1197
1186
  */
1198
1187
  static fromMessage(res, message) {
1199
1188
  const minLen = fixedLength(res);
1200
- if (message.length < minLen) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidMessageLength, void 0, {
1189
+ if (message.length < minLen) throw new ProvenanceMarkError("InvalidMessageLength", void 0, {
1201
1190
  expected: minLen,
1202
1191
  actual: message.length
1203
1192
  });
@@ -1220,7 +1209,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1220
1209
  if (infoBytes.length > 0) try {
1221
1210
  (0, _bcts_dcbor.decodeCbor)(infoBytes);
1222
1211
  } catch {
1223
- throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidInfoCbor);
1212
+ throw new ProvenanceMarkError("InvalidInfoCbor");
1224
1213
  }
1225
1214
  return new ProvenanceMark(res, new Uint8Array(key), new Uint8Array(hash), new Uint8Array(chainId), new Uint8Array(seqBytes), new Uint8Array(dateBytes), new Uint8Array(infoBytes), seq, date);
1226
1215
  }
@@ -1235,51 +1224,174 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1235
1224
  ]), linkLength(res));
1236
1225
  }
1237
1226
  /**
1238
- * Get the first four bytes of the hash as a hex string identifier.
1227
+ * The 32-byte Mark ID.
1228
+ *
1229
+ * The first `linkLength` bytes are the mark's stored hash. The remaining
1230
+ * bytes come from the mark's fingerprint (SHA-256 of CBOR encoding),
1231
+ * ensuring a full 32-byte value is always available regardless of
1232
+ * resolution.
1233
+ */
1234
+ id() {
1235
+ const result = new Uint8Array(32);
1236
+ const n = this._hash.length;
1237
+ result.set(this._hash, 0);
1238
+ if (n < 32) {
1239
+ const fp = this.fingerprint();
1240
+ result.set(fp.subarray(0, 32 - n), n);
1241
+ }
1242
+ return result;
1243
+ }
1244
+ /**
1245
+ * The full 32-byte Mark ID as a 64-character hex string.
1246
+ */
1247
+ idHex() {
1248
+ return bytesToHex(this.id());
1249
+ }
1250
+ /**
1251
+ * The first `wordCount` bytes of the Mark ID as upper-case ByteWords.
1252
+ *
1253
+ * @param wordCount Number of bytes to encode, must be in `4..=32`.
1254
+ * @param prefix If `true`, prepends the provenance-mark prefix character.
1255
+ * @throws if `wordCount` is not in the range `4..=32`.
1256
+ */
1257
+ idBytewords(wordCount, prefix) {
1258
+ if (!Number.isInteger(wordCount) || wordCount < 4 || wordCount > 32) throw new Error(`word_count must be 4..=32, got ${wordCount}`);
1259
+ const s = (0, _bcts_uniform_resources.encodeToWords)(this.id().subarray(0, wordCount)).toUpperCase();
1260
+ return prefix ? `\u{1F151} ${s}` : s;
1261
+ }
1262
+ /**
1263
+ * The first `wordCount` bytes of the Mark ID as Bytemoji.
1264
+ *
1265
+ * @param wordCount Number of bytes to encode, must be in `4..=32`.
1266
+ * @param prefix If `true`, prepends the provenance-mark prefix character.
1267
+ * @throws if `wordCount` is not in the range `4..=32`.
1268
+ */
1269
+ idBytemoji(wordCount, prefix) {
1270
+ if (!Number.isInteger(wordCount) || wordCount < 4 || wordCount > 32) throw new Error(`word_count must be 4..=32, got ${wordCount}`);
1271
+ const s = (0, _bcts_uniform_resources.encodeToBytemojis)(this.id().subarray(0, wordCount)).toUpperCase();
1272
+ return prefix ? `\u{1F151} ${s}` : s;
1273
+ }
1274
+ /**
1275
+ * The first `wordCount` bytes of the Mark ID as upper-case minimal
1276
+ * ByteWords (2 letters per byte, concatenated without separator).
1277
+ *
1278
+ * @param wordCount Number of bytes to encode, must be in `4..=32`.
1279
+ * @param prefix If `true`, prepends the provenance-mark prefix character.
1280
+ * @throws if `wordCount` is not in the range `4..=32`.
1281
+ */
1282
+ idBytewordsMinimal(wordCount, prefix) {
1283
+ if (!Number.isInteger(wordCount) || wordCount < 4 || wordCount > 32) throw new Error(`word_count must be 4..=32, got ${wordCount}`);
1284
+ const s = (0, _bcts_uniform_resources.encodeToMinimalBytewords)(this.id().subarray(0, wordCount)).toUpperCase();
1285
+ return prefix ? `\u{1F151} ${s}` : s;
1286
+ }
1287
+ /**
1288
+ * Legacy 8-character hex identifier — the first 4 bytes of the Mark ID.
1289
+ *
1290
+ * @deprecated Use {@link idHex} for the full 64-char hex, or
1291
+ * `idHex().slice(0, 8)` for this legacy short form. Retained for
1292
+ * backwards compatibility; will be removed in a future alpha.
1239
1293
  */
1240
1294
  identifier() {
1241
- return Array.from(this._hash.slice(0, 4)).map((b) => b.toString(16).padStart(2, "0")).join("");
1295
+ return this.idHex().slice(0, 8);
1242
1296
  }
1243
1297
  /**
1244
- * Get the first four bytes of the hash as upper-case ByteWords.
1298
+ * Legacy 4-byte upper-case ByteWords identifier.
1299
+ *
1300
+ * @deprecated Equivalent to `idBytewords(4, prefix)`. Retained for
1301
+ * backwards compatibility; will be removed in a future alpha.
1245
1302
  */
1246
1303
  bytewordsIdentifier(prefix) {
1247
- const s = (0, _bcts_uniform_resources.encodeBytewordsIdentifier)(this._hash.slice(0, 4)).toUpperCase();
1248
- return prefix ? `\u{1F151} ${s}` : s;
1304
+ return this.idBytewords(4, prefix);
1249
1305
  }
1250
1306
  /**
1251
- * A compact 8-letter identifier derived from the upper-case ByteWords
1252
- * identifier by taking the first and last letter of each ByteWords word
1253
- * (4 words x 2 letters = 8 letters).
1307
+ * Legacy 8-letter minimal ByteWords identifier (first+last letter of each
1308
+ * of the 4 ByteWords). Example: "ABLE ACID ALSO APEX" -> "AEADAOAX".
1254
1309
  *
1255
- * Example: "ABLE ACID ALSO APEX" -> "AEADAOAX"
1256
- * If prefix is true, prepends the provenance mark prefix character.
1310
+ * @deprecated Equivalent to `idBytewordsMinimal(4, prefix)`. Retained
1311
+ * for backwards compatibility; will be removed in a future alpha.
1257
1312
  */
1258
1313
  bytewordsMinimalIdentifier(prefix) {
1259
- const full = (0, _bcts_uniform_resources.encodeBytewordsIdentifier)(this._hash.slice(0, 4));
1260
- const words = full.split(/\s+/);
1261
- let out = "";
1262
- if (words.length === 4) for (const w of words) {
1263
- if (w.length === 0) continue;
1264
- out += w[0].toUpperCase();
1265
- out += w[w.length - 1].toUpperCase();
1314
+ return this.idBytewordsMinimal(4, prefix);
1315
+ }
1316
+ /**
1317
+ * Legacy 4-byte upper-case Bytemoji identifier.
1318
+ *
1319
+ * @deprecated Equivalent to `idBytemoji(4, prefix)`. Retained for
1320
+ * backwards compatibility; will be removed in a future alpha.
1321
+ */
1322
+ bytemojiIdentifier(prefix) {
1323
+ return this.idBytemoji(4, prefix);
1324
+ }
1325
+ /**
1326
+ * Computes the minimum prefix length (in bytes, `4..=32`) each mark needs
1327
+ * so that every mark in the set has a unique Mark ID prefix.
1328
+ *
1329
+ * Non-colliding marks get the minimum of 4. Only marks whose 4-byte
1330
+ * prefixes collide are extended.
1331
+ */
1332
+ static minimalNoncollidingPrefixLengths(ids) {
1333
+ const n = ids.length;
1334
+ const lengths = new Array(n).fill(4);
1335
+ const groups = /* @__PURE__ */ new Map();
1336
+ for (let i = 0; i < n; i++) {
1337
+ const key = bytesToHex(ids[i].subarray(0, 4));
1338
+ const g = groups.get(key);
1339
+ if (g !== void 0) g.push(i);
1340
+ else groups.set(key, [i]);
1341
+ }
1342
+ for (const indices of groups.values()) {
1343
+ if (indices.length <= 1) continue;
1344
+ ProvenanceMark.resolveCollisionGroup(ids, indices, lengths);
1266
1345
  }
1267
- if (out.length !== 8) {
1268
- out = "";
1269
- const compact = full.replace(/[^a-zA-Z]/g, "").toUpperCase();
1270
- for (let i = 0; i + 3 < compact.length; i += 4) {
1271
- out += compact[i];
1272
- out += compact[i + 3];
1346
+ return lengths;
1347
+ }
1348
+ static resolveCollisionGroup(ids, initialIndices, lengths) {
1349
+ let unresolved = [...initialIndices];
1350
+ for (let prefixLen = 5; prefixLen <= 32; prefixLen++) {
1351
+ const subGroups = /* @__PURE__ */ new Map();
1352
+ for (const i of unresolved) {
1353
+ const key = bytesToHex(ids[i].subarray(0, prefixLen));
1354
+ const g = subGroups.get(key);
1355
+ if (g !== void 0) g.push(i);
1356
+ else subGroups.set(key, [i]);
1273
1357
  }
1358
+ const nextUnresolved = [];
1359
+ for (const subIndices of subGroups.values()) if (subIndices.length === 1) lengths[subIndices[0]] = prefixLen;
1360
+ else nextUnresolved.push(...subIndices);
1361
+ if (nextUnresolved.length === 0) return;
1362
+ unresolved = nextUnresolved;
1274
1363
  }
1275
- return prefix ? `\u{1F151} ${out}` : out;
1364
+ for (const i of unresolved) lengths[i] = 32;
1276
1365
  }
1277
1366
  /**
1278
- * Get the first four bytes of the hash as Bytemoji.
1279
- */
1280
- bytemojiIdentifier(prefix) {
1281
- const s = (0, _bcts_uniform_resources.encodeBytemojisIdentifier)(this._hash.slice(0, 4)).toUpperCase();
1282
- return prefix ? `\u{1F151} ${s}` : s;
1367
+ * Returns disambiguated upper-case ByteWords Mark IDs for a set of marks.
1368
+ *
1369
+ * Non-colliding marks get 4-word identifiers. Only marks whose 4-byte
1370
+ * prefixes collide are extended with additional words (up to 32 bytes
1371
+ * per identifier).
1372
+ */
1373
+ static disambiguatedIdBytewords(marks, prefix) {
1374
+ const ids = marks.map((m) => m.id());
1375
+ const lengths = ProvenanceMark.minimalNoncollidingPrefixLengths(ids);
1376
+ return ids.map((id, i) => {
1377
+ const s = (0, _bcts_uniform_resources.encodeToWords)(id.subarray(0, lengths[i])).toUpperCase();
1378
+ return prefix ? `\u{1F151} ${s}` : s;
1379
+ });
1380
+ }
1381
+ /**
1382
+ * Returns disambiguated Bytemoji Mark IDs for a set of marks.
1383
+ *
1384
+ * Non-colliding marks get 4-emoji identifiers. Only marks whose 4-byte
1385
+ * prefixes collide are extended with additional emojis (up to 32 bytes
1386
+ * per identifier).
1387
+ */
1388
+ static disambiguatedIdBytemoji(marks, prefix) {
1389
+ const ids = marks.map((m) => m.id());
1390
+ const lengths = ProvenanceMark.minimalNoncollidingPrefixLengths(ids);
1391
+ return ids.map((id, i) => {
1392
+ const s = (0, _bcts_uniform_resources.encodeToBytemojis)(id.subarray(0, lengths[i])).toUpperCase();
1393
+ return prefix ? `\u{1F151} ${s}` : s;
1394
+ });
1283
1395
  }
1284
1396
  /**
1285
1397
  * Check if this mark precedes another mark in the chain.
@@ -1298,15 +1410,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1298
1410
  * `Error::Validation(ValidationIssue)` pattern.
1299
1411
  */
1300
1412
  precedesOpt(next) {
1301
- if (next._seq === 0) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ValidationError, "non-genesis mark at sequence 0", { validationIssue: { type: "NonGenesisAtZero" } });
1302
- if (arraysEqual(next._key, next._chainId)) throw new ProvenanceMarkError(ProvenanceMarkErrorType.ValidationError, "genesis mark must have key equal to chain_id", { validationIssue: { type: "InvalidGenesisKey" } });
1413
+ if (next._seq === 0) throw new ProvenanceMarkError("ValidationError", "non-genesis mark at sequence 0", { validationIssue: { type: "NonGenesisAtZero" } });
1414
+ if (arraysEqual(next._key, next._chainId)) throw new ProvenanceMarkError("ValidationError", "genesis mark must have key equal to chain_id", { validationIssue: { type: "InvalidGenesisKey" } });
1303
1415
  if (this._seq !== next._seq - 1) {
1304
1416
  const issue = {
1305
1417
  type: "SequenceGap",
1306
1418
  expected: this._seq + 1,
1307
1419
  actual: next._seq
1308
1420
  };
1309
- throw new ProvenanceMarkError(ProvenanceMarkErrorType.ValidationError, `sequence gap: expected ${this._seq + 1}, got ${next._seq}`, { validationIssue: issue });
1421
+ throw new ProvenanceMarkError("ValidationError", `sequence gap: expected ${this._seq + 1}, got ${next._seq}`, { validationIssue: issue });
1310
1422
  }
1311
1423
  if (this._date > next._date) {
1312
1424
  const dateStr = this._date.toISOString().replace(".000Z", "Z");
@@ -1316,7 +1428,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1316
1428
  previous: dateStr,
1317
1429
  next: nextDateStr
1318
1430
  };
1319
- throw new ProvenanceMarkError(ProvenanceMarkErrorType.ValidationError, `date ordering: ${dateStr} > ${nextDateStr}`, { validationIssue: issue });
1431
+ throw new ProvenanceMarkError("ValidationError", `date ordering: ${dateStr} > ${nextDateStr}`, { validationIssue: issue });
1320
1432
  }
1321
1433
  const expectedHash = ProvenanceMark.makeHash(this._res, this._key, next._key, this._chainId, this._seqBytes, this._dateBytes, this._infoBytes);
1322
1434
  if (!arraysEqual(this._hash, expectedHash)) {
@@ -1325,7 +1437,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1325
1437
  expected: bytesToHex(expectedHash),
1326
1438
  actual: bytesToHex(this._hash)
1327
1439
  };
1328
- throw new ProvenanceMarkError(ProvenanceMarkErrorType.ValidationError, `hash mismatch: expected ${bytesToHex(expectedHash)}, got ${bytesToHex(this._hash)}`, { validationIssue: issue });
1440
+ throw new ProvenanceMarkError("ValidationError", `hash mismatch: expected ${bytesToHex(expectedHash)}, got ${bytesToHex(this._hash)}`, { validationIssue: issue });
1329
1441
  }
1330
1442
  }
1331
1443
  /**
@@ -1386,7 +1498,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1386
1498
  */
1387
1499
  static fromURString(urString) {
1388
1500
  const ur = _bcts_uniform_resources.UR.fromURString(urString);
1389
- if (ur.urTypeStr() !== "provenance") throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: `Expected UR type 'provenance', got '${ur.urTypeStr()}'` });
1501
+ if (ur.urTypeStr() !== "provenance") throw new ProvenanceMarkError("CborError", void 0, { message: `Expected UR type 'provenance', got '${ur.urTypeStr()}'` });
1390
1502
  return ProvenanceMark.fromUntaggedCbor(ur.cbor());
1391
1503
  }
1392
1504
  /**
@@ -1402,7 +1514,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1402
1514
  */
1403
1515
  static fromUrl(url) {
1404
1516
  const param = url.searchParams.get("provenance");
1405
- if (param === null || param === "") throw new ProvenanceMarkError(ProvenanceMarkErrorType.MissingUrlParameter, void 0, { parameter: "provenance" });
1517
+ if (param === null || param === "") throw new ProvenanceMarkError("MissingUrlParameter", void 0, { parameter: "provenance" });
1406
1518
  return ProvenanceMark.fromUrlEncoding(param);
1407
1519
  }
1408
1520
  /**
@@ -1431,7 +1543,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1431
1543
  */
1432
1544
  static fromUntaggedCbor(cborValue) {
1433
1545
  const arr = (0, _bcts_dcbor.expectArray)(cborValue);
1434
- if (arr.length !== 2) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: "Invalid provenance mark length" });
1546
+ if (arr.length !== 2) throw new ProvenanceMarkError("CborError", void 0, { message: "Invalid provenance mark length" });
1435
1547
  const res = resolutionFromCbor(arr[0]);
1436
1548
  const message = (0, _bcts_dcbor.expectBytes)(arr[1]);
1437
1549
  return ProvenanceMark.fromMessage(res, message);
@@ -1441,8 +1553,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1441
1553
  */
1442
1554
  static fromTaggedCbor(cborValue) {
1443
1555
  const cborObj = cborValue;
1444
- if (cborObj.tag !== _bcts_tags.PROVENANCE_MARK.value) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: `Expected tag ${_bcts_tags.PROVENANCE_MARK.value}, got ${String(cborObj.tag)}` });
1445
- if (cborObj.value === void 0) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: "Tagged CBOR value is missing" });
1556
+ if (cborObj.tag !== _bcts_tags.PROVENANCE_MARK.value) throw new ProvenanceMarkError("CborError", void 0, { message: `Expected tag ${_bcts_tags.PROVENANCE_MARK.value}, got ${String(cborObj.tag)}` });
1557
+ if (cborObj.value === void 0) throw new ProvenanceMarkError("CborError", void 0, { message: "Tagged CBOR value is missing" });
1446
1558
  return ProvenanceMark.fromUntaggedCbor(cborObj.value);
1447
1559
  }
1448
1560
  /**
@@ -1460,9 +1572,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1460
1572
  }
1461
1573
  /**
1462
1574
  * Debug string representation.
1575
+ *
1576
+ * As of provenance-mark v0.24, this includes the full 64-character Mark ID
1577
+ * hex (matching rust's `Display` impl). Pre-v0.24 callers that depended on
1578
+ * the 8-character prefix should use `idHex().slice(0, 8)` directly.
1463
1579
  */
1464
1580
  toString() {
1465
- return `ProvenanceMark(${this.identifier()})`;
1581
+ return `ProvenanceMark(${this.idHex()})`;
1466
1582
  }
1467
1583
  /**
1468
1584
  * Detailed debug representation.
@@ -1553,7 +1669,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1553
1669
  static fromEnvelope(envelope) {
1554
1670
  const leaf = envelope.subject().asLeaf();
1555
1671
  if (leaf !== void 0) return ProvenanceMark.fromTaggedCbor(leaf);
1556
- throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: "Could not extract ProvenanceMark from envelope" });
1672
+ throw new ProvenanceMarkError("CborError", void 0, { message: "Could not extract ProvenanceMark from envelope" });
1557
1673
  }
1558
1674
  };
1559
1675
  /**
@@ -1564,10 +1680,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1564
1680
  for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
1565
1681
  return true;
1566
1682
  }
1567
-
1568
- //#endregion
1569
- //#region src/generator.ts
1570
- /**
1683
+ //#endregion
1684
+ //#region src/generator.ts
1685
+ /**
1571
1686
  * Copyright © 2023-2026 Blockchain Commons, LLC
1572
1687
  * Copyright © 2025-2026 Parity Technologies
1573
1688
  *
@@ -1638,7 +1753,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1638
1753
  */
1639
1754
  static new(res, seed, chainId, nextSeq, rngState) {
1640
1755
  const linkLen = linkLength(res);
1641
- if (chainId.length !== linkLen) throw new ProvenanceMarkError(ProvenanceMarkErrorType.InvalidChainIdLength, void 0, {
1756
+ if (chainId.length !== linkLen) throw new ProvenanceMarkError("InvalidChainIdLength", void 0, {
1642
1757
  expected: linkLen,
1643
1758
  actual: chainId.length
1644
1759
  });
@@ -1721,38 +1836,37 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1721
1836
  */
1722
1837
  static fromEnvelope(envelope) {
1723
1838
  const env = envelope;
1724
- if (!env.hasType("provenance-generator")) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: "Envelope is not a provenance-generator" });
1839
+ if (!env.hasType("provenance-generator")) throw new ProvenanceMarkError("CborError", void 0, { message: "Envelope is not a provenance-generator" });
1725
1840
  const chainId = env.subject().asByteString();
1726
- if (chainId === void 0) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: "Could not extract chain ID" });
1841
+ if (chainId === void 0) throw new ProvenanceMarkError("CborError", void 0, { message: "Could not extract chain ID" });
1727
1842
  const extractAssertion = (predicate) => {
1728
1843
  const assertions = env.assertionsWithPredicate(predicate);
1729
- if (assertions.length === 0) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: `Missing ${predicate} assertion` });
1844
+ if (assertions.length === 0) throw new ProvenanceMarkError("CborError", void 0, { message: `Missing ${predicate} assertion` });
1730
1845
  const assertionCase = assertions[0].case();
1731
- if (assertionCase.type !== "assertion") throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: `Invalid ${predicate} assertion` });
1846
+ if (assertionCase.type !== "assertion") throw new ProvenanceMarkError("CborError", void 0, { message: `Invalid ${predicate} assertion` });
1732
1847
  const obj = assertionCase.assertion.object();
1733
1848
  const objCase = obj.case();
1734
1849
  if (objCase.type === "leaf") return {
1735
1850
  cbor: objCase.cbor,
1736
1851
  bytes: obj.asByteString()
1737
1852
  };
1738
- throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: `Invalid ${predicate} value` });
1853
+ throw new ProvenanceMarkError("CborError", void 0, { message: `Invalid ${predicate} value` });
1739
1854
  };
1740
1855
  const res = resolutionFromCbor(extractAssertion("res").cbor);
1741
1856
  const seedValue = extractAssertion("seed");
1742
- if (seedValue.bytes === void 0) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: "Invalid seed data" });
1857
+ if (seedValue.bytes === void 0) throw new ProvenanceMarkError("CborError", void 0, { message: "Invalid seed data" });
1743
1858
  const seed = ProvenanceSeed.fromBytes(seedValue.bytes);
1744
1859
  const seqValue = extractAssertion("next-seq");
1745
1860
  const nextSeq = Number(seqValue.cbor);
1746
1861
  const rngValue = extractAssertion("rng-state");
1747
- if (rngValue.bytes === void 0) throw new ProvenanceMarkError(ProvenanceMarkErrorType.CborError, void 0, { message: "Invalid rng-state data" });
1862
+ if (rngValue.bytes === void 0) throw new ProvenanceMarkError("CborError", void 0, { message: "Invalid rng-state data" });
1748
1863
  const rngState = RngState.fromBytes(rngValue.bytes);
1749
1864
  return ProvenanceMarkGenerator.new(res, seed, chainId, nextSeq, rngState);
1750
1865
  }
1751
1866
  };
1752
-
1753
- //#endregion
1754
- //#region src/mark-info.ts
1755
- /**
1867
+ //#endregion
1868
+ //#region src/mark-info.ts
1869
+ /**
1756
1870
  * Copyright © 2023-2026 Blockchain Commons, LLC
1757
1871
  * Copyright © 2025-2026 Parity Technologies
1758
1872
  *
@@ -1780,7 +1894,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1780
1894
  const tagName = _bcts_tags.PROVENANCE_MARK.name;
1781
1895
  if (tagName === void 0) throw new Error("PROVENANCE_MARK tag has no name");
1782
1896
  const cborValue = (0, _bcts_dcbor.decodeCbor)(mark.toCborData());
1783
- return new ProvenanceMarkInfo(mark, _bcts_uniform_resources.UR.new(tagName, cborValue), mark.bytewordsIdentifier(true), mark.bytemojiIdentifier(true), comment);
1897
+ return new ProvenanceMarkInfo(mark, _bcts_uniform_resources.UR.new(tagName, cborValue), mark.idBytewords(4, true), mark.idBytemoji(4, true), comment);
1784
1898
  }
1785
1899
  mark() {
1786
1900
  return this._mark;
@@ -1844,10 +1958,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1844
1958
  return new ProvenanceMarkInfo(mark, ur, bytewords, bytemoji, typeof json["comment"] === "string" ? json["comment"] : "");
1845
1959
  }
1846
1960
  };
1847
-
1848
- //#endregion
1849
- //#region src/envelope.ts
1850
- /**
1961
+ //#endregion
1962
+ //#region src/envelope.ts
1963
+ /**
1851
1964
  * Copyright © 2023-2026 Blockchain Commons, LLC
1852
1965
  * Copyright © 2025-2026 Parity Technologies
1853
1966
  *
@@ -1942,72 +2055,72 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1942
2055
  function provenanceMarkGeneratorFromEnvelope(envelope) {
1943
2056
  return ProvenanceMarkGenerator.fromEnvelope(envelope);
1944
2057
  }
1945
-
1946
- //#endregion
1947
- Object.defineProperty(exports, 'FormatContext', {
1948
- enumerable: true,
1949
- get: function () {
1950
- return _bcts_envelope.FormatContext;
1951
- }
1952
- });
1953
- exports.PROVENANCE_SEED_LENGTH = PROVENANCE_SEED_LENGTH;
1954
- exports.ProvenanceMark = ProvenanceMark;
1955
- exports.ProvenanceMarkError = ProvenanceMarkError;
1956
- exports.ProvenanceMarkErrorType = ProvenanceMarkErrorType;
1957
- exports.ProvenanceMarkGenerator = ProvenanceMarkGenerator;
1958
- exports.ProvenanceMarkInfo = ProvenanceMarkInfo;
1959
- exports.ProvenanceMarkResolution = ProvenanceMarkResolution;
1960
- exports.ProvenanceSeed = ProvenanceSeed;
1961
- exports.RNG_STATE_LENGTH = RNG_STATE_LENGTH;
1962
- exports.RngState = RngState;
1963
- exports.SHA256_SIZE = SHA256_SIZE;
1964
- exports.ValidationReportFormat = ValidationReportFormat;
1965
- exports.Xoshiro256StarStar = Xoshiro256StarStar;
1966
- exports.chainIdHex = chainIdHex;
1967
- exports.chainIdRange = chainIdRange;
1968
- exports.dateBytesLength = dateBytesLength;
1969
- exports.dateBytesRange = dateBytesRange;
1970
- exports.dateFromIso8601 = dateFromIso8601;
1971
- exports.dateToDateString = dateToDateString;
1972
- exports.dateToIso8601 = dateToIso8601;
1973
- exports.deserialize2Bytes = deserialize2Bytes;
1974
- exports.deserialize4Bytes = deserialize4Bytes;
1975
- exports.deserialize6Bytes = deserialize6Bytes;
1976
- exports.deserializeDate = deserializeDate;
1977
- exports.deserializeSeq = deserializeSeq;
1978
- exports.extendKey = extendKey;
1979
- exports.fixedLength = fixedLength;
1980
- exports.formatReport = formatReport;
1981
- exports.formatValidationIssue = formatValidationIssue;
1982
- exports.hasIssues = hasIssues;
1983
- exports.hashRange = hashRange;
1984
- exports.hkdfHmacSha256 = hkdfHmacSha256;
1985
- exports.infoRangeStart = infoRangeStart;
1986
- exports.keyRange = keyRange;
1987
- exports.linkLength = linkLength;
1988
- exports.obfuscate = obfuscate;
1989
- exports.provenanceMarkFromEnvelope = provenanceMarkFromEnvelope;
1990
- exports.provenanceMarkGeneratorFromEnvelope = provenanceMarkGeneratorFromEnvelope;
1991
- exports.provenanceMarkGeneratorToEnvelope = provenanceMarkGeneratorToEnvelope;
1992
- exports.provenanceMarkToEnvelope = provenanceMarkToEnvelope;
1993
- exports.rangeOfDaysInMonth = rangeOfDaysInMonth;
1994
- exports.registerTags = registerTags;
1995
- exports.registerTagsIn = registerTagsIn;
1996
- exports.resolutionFromCbor = resolutionFromCbor;
1997
- exports.resolutionFromNumber = resolutionFromNumber;
1998
- exports.resolutionToCbor = resolutionToCbor;
1999
- exports.resolutionToNumber = resolutionToNumber;
2000
- exports.resolutionToString = resolutionToString;
2001
- exports.seqBytesLength = seqBytesLength;
2002
- exports.seqBytesRange = seqBytesRange;
2003
- exports.serialize2Bytes = serialize2Bytes;
2004
- exports.serialize4Bytes = serialize4Bytes;
2005
- exports.serialize6Bytes = serialize6Bytes;
2006
- exports.serializeDate = serializeDate;
2007
- exports.serializeSeq = serializeSeq;
2008
- exports.sha256 = sha256;
2009
- exports.sha256Prefix = sha256Prefix;
2010
- exports.validate = validate;
2011
- return exports;
2058
+ //#endregion
2059
+ Object.defineProperty(exports, "FormatContext", {
2060
+ enumerable: true,
2061
+ get: function() {
2062
+ return _bcts_envelope.FormatContext;
2063
+ }
2064
+ });
2065
+ exports.PROVENANCE_SEED_LENGTH = PROVENANCE_SEED_LENGTH;
2066
+ exports.ProvenanceMark = ProvenanceMark;
2067
+ exports.ProvenanceMarkError = ProvenanceMarkError;
2068
+ exports.ProvenanceMarkErrorType = ProvenanceMarkErrorType;
2069
+ exports.ProvenanceMarkGenerator = ProvenanceMarkGenerator;
2070
+ exports.ProvenanceMarkInfo = ProvenanceMarkInfo;
2071
+ exports.ProvenanceMarkResolution = ProvenanceMarkResolution;
2072
+ exports.ProvenanceSeed = ProvenanceSeed;
2073
+ exports.RNG_STATE_LENGTH = RNG_STATE_LENGTH;
2074
+ exports.RngState = RngState;
2075
+ exports.SHA256_SIZE = SHA256_SIZE;
2076
+ exports.ValidationReportFormat = ValidationReportFormat;
2077
+ exports.Xoshiro256StarStar = Xoshiro256StarStar;
2078
+ exports.chainIdHex = chainIdHex;
2079
+ exports.chainIdRange = chainIdRange;
2080
+ exports.dateBytesLength = dateBytesLength;
2081
+ exports.dateBytesRange = dateBytesRange;
2082
+ exports.dateFromIso8601 = dateFromIso8601;
2083
+ exports.dateToDateString = dateToDateString;
2084
+ exports.dateToIso8601 = dateToIso8601;
2085
+ exports.deserialize2Bytes = deserialize2Bytes;
2086
+ exports.deserialize4Bytes = deserialize4Bytes;
2087
+ exports.deserialize6Bytes = deserialize6Bytes;
2088
+ exports.deserializeDate = deserializeDate;
2089
+ exports.deserializeSeq = deserializeSeq;
2090
+ exports.extendKey = extendKey;
2091
+ exports.fixedLength = fixedLength;
2092
+ exports.formatReport = formatReport;
2093
+ exports.formatValidationIssue = formatValidationIssue;
2094
+ exports.hasIssues = hasIssues;
2095
+ exports.hashRange = hashRange;
2096
+ exports.hkdfHmacSha256 = hkdfHmacSha256;
2097
+ exports.infoRangeStart = infoRangeStart;
2098
+ exports.keyRange = keyRange;
2099
+ exports.linkLength = linkLength;
2100
+ exports.obfuscate = obfuscate;
2101
+ exports.provenanceMarkFromEnvelope = provenanceMarkFromEnvelope;
2102
+ exports.provenanceMarkGeneratorFromEnvelope = provenanceMarkGeneratorFromEnvelope;
2103
+ exports.provenanceMarkGeneratorToEnvelope = provenanceMarkGeneratorToEnvelope;
2104
+ exports.provenanceMarkToEnvelope = provenanceMarkToEnvelope;
2105
+ exports.rangeOfDaysInMonth = rangeOfDaysInMonth;
2106
+ exports.registerTags = registerTags;
2107
+ exports.registerTagsIn = registerTagsIn;
2108
+ exports.resolutionFromCbor = resolutionFromCbor;
2109
+ exports.resolutionFromNumber = resolutionFromNumber;
2110
+ exports.resolutionToCbor = resolutionToCbor;
2111
+ exports.resolutionToNumber = resolutionToNumber;
2112
+ exports.resolutionToString = resolutionToString;
2113
+ exports.seqBytesLength = seqBytesLength;
2114
+ exports.seqBytesRange = seqBytesRange;
2115
+ exports.serialize2Bytes = serialize2Bytes;
2116
+ exports.serialize4Bytes = serialize4Bytes;
2117
+ exports.serialize6Bytes = serialize6Bytes;
2118
+ exports.serializeDate = serializeDate;
2119
+ exports.serializeSeq = serializeSeq;
2120
+ exports.sha256 = sha256;
2121
+ exports.sha256Prefix = sha256Prefix;
2122
+ exports.validate = validate;
2123
+ return exports;
2012
2124
  })({}, bctsDcbor, nobleHashesSha2, nobleHashesHkdf, nobleCiphersChacha, bctsRand, bctsTags, bctsUniformResources, bctsEnvelope);
2125
+
2013
2126
  //# sourceMappingURL=index.iife.js.map