@bcts/provenance-mark 1.0.0-beta.2 → 1.0.0-beta.3

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/index.cjs CHANGED
@@ -172,7 +172,7 @@ function serialize2Bytes(date) {
172
172
  day
173
173
  });
174
174
  const value = yy << 9 | month << 5 | day;
175
- const buf = new Uint8Array(2);
175
+ const buf = /* @__PURE__ */ new Uint8Array(2);
176
176
  buf[0] = value >> 8 & 255;
177
177
  buf[1] = value & 255;
178
178
  return buf;
@@ -200,7 +200,7 @@ function serialize4Bytes(date) {
200
200
  const duration = date.getTime() - REFERENCE_DATE;
201
201
  const seconds = Math.floor(duration / 1e3);
202
202
  if (seconds < 0 || seconds > 4294967295) throw new ProvenanceMarkError("DateOutOfRange", void 0, { details: "seconds value out of range for u32" });
203
- const buf = new Uint8Array(4);
203
+ const buf = /* @__PURE__ */ new Uint8Array(4);
204
204
  buf[0] = seconds >> 24 & 255;
205
205
  buf[1] = seconds >> 16 & 255;
206
206
  buf[2] = seconds >> 8 & 255;
@@ -222,7 +222,7 @@ function serialize6Bytes(date) {
222
222
  const duration = date.getTime() - REFERENCE_DATE;
223
223
  const milliseconds = BigInt(duration);
224
224
  if (milliseconds < 0n || milliseconds > BigInt(MAX_6_BYTE_VALUE)) throw new ProvenanceMarkError("DateOutOfRange", void 0, { details: "date exceeds maximum representable value" });
225
- const buf = new Uint8Array(6);
225
+ const buf = /* @__PURE__ */ new Uint8Array(6);
226
226
  buf[0] = Number(milliseconds >> 40n & 255n);
227
227
  buf[1] = Number(milliseconds >> 32n & 255n);
228
228
  buf[2] = Number(milliseconds >> 24n & 255n);
@@ -468,13 +468,13 @@ function serializeSeq(res, seq) {
468
468
  if (!Number.isInteger(seq) || seq < 0) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `sequence number must be a non-negative integer, got ${seq}` });
469
469
  if (seqBytesLength(res) === 2) {
470
470
  if (seq > 65535) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `sequence number ${seq} out of range for 2-byte format (max 65535)` });
471
- const buf = new Uint8Array(2);
471
+ const buf = /* @__PURE__ */ new Uint8Array(2);
472
472
  buf[0] = seq >> 8 & 255;
473
473
  buf[1] = seq & 255;
474
474
  return buf;
475
475
  }
476
476
  if (seq > 4294967295) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `sequence number ${seq} out of range for 4-byte format (max 4294967295)` });
477
- const buf = new Uint8Array(4);
477
+ const buf = /* @__PURE__ */ new Uint8Array(4);
478
478
  buf[0] = seq >>> 24 & 255;
479
479
  buf[1] = seq >>> 16 & 255;
480
480
  buf[2] = seq >>> 8 & 255;
@@ -541,22 +541,22 @@ function sha256Prefix(data, prefix) {
541
541
  * Extend a key to 32 bytes using HKDF-HMAC-SHA-256.
542
542
  */
543
543
  function extendKey(data) {
544
- return hkdfHmacSha256(data, new Uint8Array(0), 32);
544
+ return hkdfHmacSha256(data, /* @__PURE__ */ new Uint8Array(0), 32);
545
545
  }
546
546
  /**
547
547
  * Compute HKDF-HMAC-SHA-256 for the given key material.
548
548
  */
549
549
  function hkdfHmacSha256(keyMaterial, salt, keyLen) {
550
- return (0, _noble_hashes_hkdf_js.hkdf)(_noble_hashes_sha2_js.sha256, keyMaterial, salt.length > 0 ? salt : void 0, new Uint8Array(0), keyLen);
550
+ return (0, _noble_hashes_hkdf_js.hkdf)(_noble_hashes_sha2_js.sha256, keyMaterial, salt.length > 0 ? salt : void 0, /* @__PURE__ */ new Uint8Array(0), keyLen);
551
551
  }
552
552
  /**
553
553
  * Obfuscate (or deobfuscate) a message using ChaCha20.
554
554
  * The function is symmetric - applying it twice returns the original message.
555
555
  */
556
556
  function obfuscate(key, message) {
557
- if (message.length === 0) return new Uint8Array(0);
557
+ if (message.length === 0) return /* @__PURE__ */ new Uint8Array(0);
558
558
  const extendedKey = extendKey(key instanceof Uint8Array ? key : new Uint8Array(key));
559
- const iv = new Uint8Array(12);
559
+ const iv = /* @__PURE__ */ new Uint8Array(12);
560
560
  for (let i = 0; i < 12; i++) iv[i] = extendedKey[31 - i];
561
561
  return (0, _noble_ciphers_chacha_js.chacha20)(extendedKey, iv, message instanceof Uint8Array ? message : new Uint8Array(message));
562
562
  }
@@ -759,7 +759,7 @@ var Xoshiro256StarStar = class Xoshiro256StarStar {
759
759
  * Serialize the state to 32 bytes (little-endian).
760
760
  */
761
761
  toData() {
762
- const data = new Uint8Array(32);
762
+ const data = /* @__PURE__ */ new Uint8Array(32);
763
763
  for (let i = 0; i < 4; i++) {
764
764
  const val = this.s[i];
765
765
  for (let j = 0; j < 8; j++) data[i * 8 + j] = Number(val >> BigInt(j * 8) & 255n);
@@ -1283,7 +1283,7 @@ var ProvenanceMark = class ProvenanceMark {
1283
1283
  const dateBytes = serializeDate(res, date);
1284
1284
  const seqBytes = serializeSeq(res, seq);
1285
1285
  const normalizedDate = deserializeDate(res, dateBytes);
1286
- const infoBytes = info !== void 0 ? (0, _bcts_dcbor.cborData)(info) : new Uint8Array(0);
1286
+ const infoBytes = info !== void 0 ? (0, _bcts_dcbor.cborData)(info) : /* @__PURE__ */ new Uint8Array(0);
1287
1287
  const hash = ProvenanceMark.makeHash(res, key, nextKey, chainId, seqBytes, dateBytes, infoBytes);
1288
1288
  return new ProvenanceMark(res, new Uint8Array(key), hash, new Uint8Array(chainId), seqBytes, dateBytes, infoBytes, seq, normalizedDate);
1289
1289
  }
@@ -1338,7 +1338,7 @@ var ProvenanceMark = class ProvenanceMark {
1338
1338
  * resolution.
1339
1339
  */
1340
1340
  id() {
1341
- const result = new Uint8Array(32);
1341
+ const result = /* @__PURE__ */ new Uint8Array(32);
1342
1342
  const n = this._hash.length;
1343
1343
  result.set(this._hash, 0);
1344
1344
  if (n < 32) {
@@ -1766,7 +1766,7 @@ var ProvenanceMark = class ProvenanceMark {
1766
1766
  const date = new Date(dateStr);
1767
1767
  const seqBytes = serializeSeq(res, seq);
1768
1768
  const dateBytes = serializeDate(res, date);
1769
- let infoBytes = new Uint8Array(0);
1769
+ let infoBytes = /* @__PURE__ */ new Uint8Array(0);
1770
1770
  if (typeof json["info_bytes"] === "string") {
1771
1771
  infoBytes = fromBase64(json["info_bytes"]);
1772
1772
  if (infoBytes.length > 0) try {