@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 +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +13 -13
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.iife.js
CHANGED
|
@@ -165,7 +165,7 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
165
165
|
day
|
|
166
166
|
});
|
|
167
167
|
const value = yy << 9 | month << 5 | day;
|
|
168
|
-
const buf = new Uint8Array(2);
|
|
168
|
+
const buf = /* @__PURE__ */ new Uint8Array(2);
|
|
169
169
|
buf[0] = value >> 8 & 255;
|
|
170
170
|
buf[1] = value & 255;
|
|
171
171
|
return buf;
|
|
@@ -193,7 +193,7 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
193
193
|
const duration = date.getTime() - REFERENCE_DATE;
|
|
194
194
|
const seconds = Math.floor(duration / 1e3);
|
|
195
195
|
if (seconds < 0 || seconds > 4294967295) throw new ProvenanceMarkError("DateOutOfRange", void 0, { details: "seconds value out of range for u32" });
|
|
196
|
-
const buf = new Uint8Array(4);
|
|
196
|
+
const buf = /* @__PURE__ */ new Uint8Array(4);
|
|
197
197
|
buf[0] = seconds >> 24 & 255;
|
|
198
198
|
buf[1] = seconds >> 16 & 255;
|
|
199
199
|
buf[2] = seconds >> 8 & 255;
|
|
@@ -215,7 +215,7 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
215
215
|
const duration = date.getTime() - REFERENCE_DATE;
|
|
216
216
|
const milliseconds = BigInt(duration);
|
|
217
217
|
if (milliseconds < 0n || milliseconds > BigInt(MAX_6_BYTE_VALUE)) throw new ProvenanceMarkError("DateOutOfRange", void 0, { details: "date exceeds maximum representable value" });
|
|
218
|
-
const buf = new Uint8Array(6);
|
|
218
|
+
const buf = /* @__PURE__ */ new Uint8Array(6);
|
|
219
219
|
buf[0] = Number(milliseconds >> 40n & 255n);
|
|
220
220
|
buf[1] = Number(milliseconds >> 32n & 255n);
|
|
221
221
|
buf[2] = Number(milliseconds >> 24n & 255n);
|
|
@@ -461,13 +461,13 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
461
461
|
if (!Number.isInteger(seq) || seq < 0) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `sequence number must be a non-negative integer, got ${seq}` });
|
|
462
462
|
if (seqBytesLength(res) === 2) {
|
|
463
463
|
if (seq > 65535) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `sequence number ${seq} out of range for 2-byte format (max 65535)` });
|
|
464
|
-
const buf = new Uint8Array(2);
|
|
464
|
+
const buf = /* @__PURE__ */ new Uint8Array(2);
|
|
465
465
|
buf[0] = seq >> 8 & 255;
|
|
466
466
|
buf[1] = seq & 255;
|
|
467
467
|
return buf;
|
|
468
468
|
}
|
|
469
469
|
if (seq > 4294967295) throw new ProvenanceMarkError("ResolutionError", void 0, { details: `sequence number ${seq} out of range for 4-byte format (max 4294967295)` });
|
|
470
|
-
const buf = new Uint8Array(4);
|
|
470
|
+
const buf = /* @__PURE__ */ new Uint8Array(4);
|
|
471
471
|
buf[0] = seq >>> 24 & 255;
|
|
472
472
|
buf[1] = seq >>> 16 & 255;
|
|
473
473
|
buf[2] = seq >>> 8 & 255;
|
|
@@ -534,22 +534,22 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
534
534
|
* Extend a key to 32 bytes using HKDF-HMAC-SHA-256.
|
|
535
535
|
*/
|
|
536
536
|
function extendKey(data) {
|
|
537
|
-
return hkdfHmacSha256(data, new Uint8Array(0), 32);
|
|
537
|
+
return hkdfHmacSha256(data, /* @__PURE__ */ new Uint8Array(0), 32);
|
|
538
538
|
}
|
|
539
539
|
/**
|
|
540
540
|
* Compute HKDF-HMAC-SHA-256 for the given key material.
|
|
541
541
|
*/
|
|
542
542
|
function hkdfHmacSha256(keyMaterial, salt, keyLen) {
|
|
543
|
-
return (0, _noble_hashes_hkdf_js.hkdf)(_noble_hashes_sha2_js.sha256, keyMaterial, salt.length > 0 ? salt : void 0, new Uint8Array(0), keyLen);
|
|
543
|
+
return (0, _noble_hashes_hkdf_js.hkdf)(_noble_hashes_sha2_js.sha256, keyMaterial, salt.length > 0 ? salt : void 0, /* @__PURE__ */ new Uint8Array(0), keyLen);
|
|
544
544
|
}
|
|
545
545
|
/**
|
|
546
546
|
* Obfuscate (or deobfuscate) a message using ChaCha20.
|
|
547
547
|
* The function is symmetric - applying it twice returns the original message.
|
|
548
548
|
*/
|
|
549
549
|
function obfuscate(key, message) {
|
|
550
|
-
if (message.length === 0) return new Uint8Array(0);
|
|
550
|
+
if (message.length === 0) return /* @__PURE__ */ new Uint8Array(0);
|
|
551
551
|
const extendedKey = extendKey(key instanceof Uint8Array ? key : new Uint8Array(key));
|
|
552
|
-
const iv = new Uint8Array(12);
|
|
552
|
+
const iv = /* @__PURE__ */ new Uint8Array(12);
|
|
553
553
|
for (let i = 0; i < 12; i++) iv[i] = extendedKey[31 - i];
|
|
554
554
|
return (0, _noble_ciphers_chacha_js.chacha20)(extendedKey, iv, message instanceof Uint8Array ? message : new Uint8Array(message));
|
|
555
555
|
}
|
|
@@ -752,7 +752,7 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
752
752
|
* Serialize the state to 32 bytes (little-endian).
|
|
753
753
|
*/
|
|
754
754
|
toData() {
|
|
755
|
-
const data = new Uint8Array(32);
|
|
755
|
+
const data = /* @__PURE__ */ new Uint8Array(32);
|
|
756
756
|
for (let i = 0; i < 4; i++) {
|
|
757
757
|
const val = this.s[i];
|
|
758
758
|
for (let j = 0; j < 8; j++) data[i * 8 + j] = Number(val >> BigInt(j * 8) & 255n);
|
|
@@ -1276,7 +1276,7 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
1276
1276
|
const dateBytes = serializeDate(res, date);
|
|
1277
1277
|
const seqBytes = serializeSeq(res, seq);
|
|
1278
1278
|
const normalizedDate = deserializeDate(res, dateBytes);
|
|
1279
|
-
const infoBytes = info !== void 0 ? (0, _bcts_dcbor.cborData)(info) : new Uint8Array(0);
|
|
1279
|
+
const infoBytes = info !== void 0 ? (0, _bcts_dcbor.cborData)(info) : /* @__PURE__ */ new Uint8Array(0);
|
|
1280
1280
|
const hash = ProvenanceMark.makeHash(res, key, nextKey, chainId, seqBytes, dateBytes, infoBytes);
|
|
1281
1281
|
return new ProvenanceMark(res, new Uint8Array(key), hash, new Uint8Array(chainId), seqBytes, dateBytes, infoBytes, seq, normalizedDate);
|
|
1282
1282
|
}
|
|
@@ -1331,7 +1331,7 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
1331
1331
|
* resolution.
|
|
1332
1332
|
*/
|
|
1333
1333
|
id() {
|
|
1334
|
-
const result = new Uint8Array(32);
|
|
1334
|
+
const result = /* @__PURE__ */ new Uint8Array(32);
|
|
1335
1335
|
const n = this._hash.length;
|
|
1336
1336
|
result.set(this._hash, 0);
|
|
1337
1337
|
if (n < 32) {
|
|
@@ -1759,7 +1759,7 @@ var bctsProvenanceMark = (function(exports, _bcts_dcbor, _bcts_rand, _noble_hash
|
|
|
1759
1759
|
const date = new Date(dateStr);
|
|
1760
1760
|
const seqBytes = serializeSeq(res, seq);
|
|
1761
1761
|
const dateBytes = serializeDate(res, date);
|
|
1762
|
-
let infoBytes = new Uint8Array(0);
|
|
1762
|
+
let infoBytes = /* @__PURE__ */ new Uint8Array(0);
|
|
1763
1763
|
if (typeof json["info_bytes"] === "string") {
|
|
1764
1764
|
infoBytes = fromBase64(json["info_bytes"]);
|
|
1765
1765
|
if (infoBytes.length > 0) try {
|