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