@wishknish/knishio-client-js 1.0.0 → 1.1.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.
- package/README.md +13 -0
- package/dist/client.cjs.js +25 -25
- package/dist/client.cjs.js.map +1 -1
- package/dist/client.es.mjs +1544 -839
- package/dist/client.es.mjs.map +1 -1
- package/dist/client.iife.js +25 -25
- package/dist/client.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/exception/SecretStorageException.js +10 -0
- package/src/index.js +11 -1
- package/src/storage/FileStorageBackend.js +199 -0
- package/src/storage/MemorySecretStorageProvider.js +69 -1
- package/src/storage/NonExtractableKeySecretStorageProvider.js +514 -0
- package/src/storage/WebAuthnPrfSecretStorageProvider.js +646 -0
- package/src/storage/WebCryptoSecretStorageProvider.js +107 -129
- package/src/storage/WebStorageBackend.js +117 -0
- package/src/storage/index.js +25 -3
- package/src/storage/secretEnvelope.js +208 -0
package/dist/client.es.mjs
CHANGED
|
@@ -464,20 +464,20 @@ function oe(t = null, n = 2048) {
|
|
|
464
464
|
}
|
|
465
465
|
return f(n);
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function se(t, n = null) {
|
|
468
468
|
let r = new e("SHAKE256", "TEXT");
|
|
469
469
|
return r.update(t), r.getHash("HEX", { outputLen: 256 });
|
|
470
470
|
}
|
|
471
|
-
function
|
|
471
|
+
function ce(t, n) {
|
|
472
472
|
let r = new e("SHAKE256", "TEXT");
|
|
473
473
|
return r.update(t), r.getHash("HEX", { outputLen: n });
|
|
474
474
|
}
|
|
475
|
-
function
|
|
476
|
-
return e !== null && t !== null ?
|
|
475
|
+
function le({ molecularHash: e = null, index: t = null }) {
|
|
476
|
+
return e !== null && t !== null ? se(String(e) + String(t), "generateBatchId") : f(64);
|
|
477
477
|
}
|
|
478
478
|
//#endregion
|
|
479
479
|
//#region src/TokenUnit.js
|
|
480
|
-
var
|
|
480
|
+
var ue = class e {
|
|
481
481
|
constructor(e, t, n) {
|
|
482
482
|
this.id = e, this.name = t, this.metas = n || {};
|
|
483
483
|
}
|
|
@@ -508,98 +508,98 @@ var le = class e {
|
|
|
508
508
|
metas: JSON.stringify(this.metas)
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
|
-
},
|
|
511
|
+
}, de = class extends C {
|
|
512
512
|
constructor(e = "Attempting to create a wallet with no credentials (secret or bundle hash)", t = null, n = null) {
|
|
513
513
|
super(e, t, n), this.name = "WalletCredentialException";
|
|
514
514
|
}
|
|
515
|
-
},
|
|
516
|
-
function
|
|
515
|
+
}, fe = /* @__PURE__ */ BigInt(2 ** 32 - 1), pe = /* @__PURE__ */ BigInt(32);
|
|
516
|
+
function me(e, t = !1) {
|
|
517
517
|
return t ? {
|
|
518
|
-
h: Number(e &
|
|
519
|
-
l: Number(e >>
|
|
518
|
+
h: Number(e & fe),
|
|
519
|
+
l: Number(e >> pe & fe)
|
|
520
520
|
} : {
|
|
521
|
-
h: Number(e >>
|
|
522
|
-
l: Number(e &
|
|
521
|
+
h: Number(e >> pe & fe) | 0,
|
|
522
|
+
l: Number(e & fe) | 0
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
|
-
function
|
|
525
|
+
function he(e, t = !1) {
|
|
526
526
|
let n = e.length, r = new Uint32Array(n), i = new Uint32Array(n);
|
|
527
527
|
for (let a = 0; a < n; a++) {
|
|
528
|
-
let { h: n, l: o } =
|
|
528
|
+
let { h: n, l: o } = me(e[a], t);
|
|
529
529
|
[r[a], i[a]] = [n, o];
|
|
530
530
|
}
|
|
531
531
|
return [r, i];
|
|
532
532
|
}
|
|
533
533
|
//#endregion
|
|
534
534
|
//#region node_modules/@noble/hashes/utils.js
|
|
535
|
-
function
|
|
535
|
+
function ge(e) {
|
|
536
536
|
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in e && e.BYTES_PER_ELEMENT === 1;
|
|
537
537
|
}
|
|
538
|
-
var
|
|
539
|
-
function
|
|
540
|
-
if (typeof e != "number") throw TypeError(
|
|
541
|
-
if (!Number.isSafeInteger(e) || e < 0) throw RangeError(
|
|
538
|
+
var _e = (e) => e ? `"${e}" ` : "";
|
|
539
|
+
function E(e, t = "") {
|
|
540
|
+
if (typeof e != "number") throw TypeError(_e(t) + "expected number, got " + typeof e);
|
|
541
|
+
if (!Number.isSafeInteger(e) || e < 0) throw RangeError(_e(t) + "expected integer >= 0, got " + e);
|
|
542
542
|
return e;
|
|
543
543
|
}
|
|
544
|
-
function
|
|
545
|
-
if (typeof e != "boolean") throw TypeError(
|
|
544
|
+
function ve(e, t = "") {
|
|
545
|
+
if (typeof e != "boolean") throw TypeError(_e(t) + "expected boolean, got type=" + typeof e);
|
|
546
546
|
return e;
|
|
547
547
|
}
|
|
548
|
-
function
|
|
549
|
-
if (
|
|
550
|
-
t !== void 0 &&
|
|
551
|
-
let r =
|
|
548
|
+
function D(e, t, n = "") {
|
|
549
|
+
if (ge(e) && (t === void 0 || e.length === t)) return e;
|
|
550
|
+
t !== void 0 && E(t, "length");
|
|
551
|
+
let r = ge(e), i = t === void 0 ? "" : ` of length ${t}`, a = r ? `length=${e.length}` : `type=${typeof e}`, o = _e(n) + "expected Uint8Array" + i + ", got " + a;
|
|
552
552
|
throw r ? RangeError(o) : TypeError(o);
|
|
553
553
|
}
|
|
554
|
-
var
|
|
554
|
+
var ye = (e, t) => {
|
|
555
555
|
if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError((t === "object" ? "" : `"${t}" `) + "expected object, got type=" + typeof e);
|
|
556
|
-
},
|
|
557
|
-
|
|
556
|
+
}, be = (e, t) => {
|
|
557
|
+
ye(e, t);
|
|
558
558
|
let n = Object.getPrototypeOf(e);
|
|
559
559
|
if (n !== Object.prototype && n !== null) throw TypeError(`"${t}" expected plain object`);
|
|
560
560
|
if (Object.hasOwn(e, "__proto__")) throw TypeError(`"${t}.__proto__" is not allowed`);
|
|
561
561
|
};
|
|
562
|
-
function
|
|
562
|
+
function xe(e, t = !0) {
|
|
563
563
|
if (e.destroyed) throw Error("hash was destroyed");
|
|
564
564
|
if (t && e.finished) throw Error("digest() was already called");
|
|
565
565
|
}
|
|
566
|
-
function
|
|
567
|
-
|
|
566
|
+
function Se(e, t) {
|
|
567
|
+
D(e, void 0, "output");
|
|
568
568
|
let n = t.outputLen;
|
|
569
569
|
if (!(e.length >= n)) throw RangeError("\"output\" expected length >= " + n);
|
|
570
570
|
}
|
|
571
|
-
function
|
|
571
|
+
function Ce(e) {
|
|
572
572
|
return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
|
|
573
573
|
}
|
|
574
|
-
function
|
|
574
|
+
function we(...e) {
|
|
575
575
|
for (let t = 0; t < e.length; t++) e[t].fill(0);
|
|
576
576
|
}
|
|
577
|
-
var
|
|
578
|
-
function
|
|
577
|
+
var Te = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
578
|
+
function Ee(e) {
|
|
579
579
|
return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
for (let t = 0; t < e.length; t++) e[t] =
|
|
581
|
+
function De(e) {
|
|
582
|
+
for (let t = 0; t < e.length; t++) e[t] = Ee(e[t]);
|
|
583
583
|
return e;
|
|
584
584
|
}
|
|
585
|
-
var
|
|
586
|
-
function
|
|
587
|
-
return
|
|
585
|
+
var Oe = Te ? (e) => e : De;
|
|
586
|
+
function ke(e, t, n = "opts") {
|
|
587
|
+
return be(e, "defaults"), t !== void 0 && be(t, n), Object.assign(Object.create(null), e, t);
|
|
588
588
|
}
|
|
589
|
-
function
|
|
589
|
+
function Ae(e, t = {}) {
|
|
590
590
|
if (typeof e != "function") throw TypeError("\"hashCons\" expected function, got type=" + typeof e);
|
|
591
|
-
t =
|
|
591
|
+
t = ke({}, t, "info");
|
|
592
592
|
let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
|
|
593
593
|
return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
|
|
594
594
|
}
|
|
595
|
-
function
|
|
596
|
-
|
|
595
|
+
function je(e = 32) {
|
|
596
|
+
E(e, "bytesLength");
|
|
597
597
|
let t = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
598
598
|
if (typeof t?.getRandomValues != "function") throw Error("crypto.getRandomValues must be defined");
|
|
599
599
|
if (e > 65536) throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);
|
|
600
600
|
return t.getRandomValues(new Uint8Array(e));
|
|
601
601
|
}
|
|
602
|
-
var
|
|
602
|
+
var Me = (e) => ({ oid: Uint8Array.from([
|
|
603
603
|
6,
|
|
604
604
|
9,
|
|
605
605
|
96,
|
|
@@ -611,38 +611,38 @@ var je = (e) => ({ oid: Uint8Array.from([
|
|
|
611
611
|
4,
|
|
612
612
|
2,
|
|
613
613
|
e
|
|
614
|
-
]) }),
|
|
615
|
-
for (let e = 0, t =
|
|
616
|
-
[n, r] = [r, (2 * n + 3 * r) % 5],
|
|
617
|
-
let i =
|
|
618
|
-
for (let e = 0; e < 7; e++) t = (t <<
|
|
619
|
-
|
|
614
|
+
]) }), Ne = BigInt(0), Pe = BigInt(1), Fe = BigInt(2), Ie = BigInt(7), Le = BigInt(256), Re = BigInt(113), ze = [], Be = [], Ve = [];
|
|
615
|
+
for (let e = 0, t = Pe, n = 1, r = 0; e < 24; e++) {
|
|
616
|
+
[n, r] = [r, (2 * n + 3 * r) % 5], ze.push(2 * (5 * r + n)), Be.push((e + 1) * (e + 2) / 2 % 64);
|
|
617
|
+
let i = Ne;
|
|
618
|
+
for (let e = 0; e < 7; e++) t = (t << Pe ^ (t >> Ie) * Re) % Le, t & Fe && (i ^= Pe << (Pe << BigInt(e)) - Pe);
|
|
619
|
+
Ve.push(i);
|
|
620
620
|
}
|
|
621
|
-
var
|
|
622
|
-
function
|
|
621
|
+
var He = he(Ve, !0), Ue = He[0], We = He[1], Ge = (e, t, n) => e << n | t >>> 32 - n, Ke = (e, t, n) => t << n | e >>> 32 - n, qe = (e, t, n) => t << n - 32 | e >>> 64 - n, Je = (e, t, n) => e << n - 32 | t >>> 64 - n, Ye = (e, t, n) => n > 32 ? qe(e, t, n) : Ge(e, t, n), Xe = (e, t, n) => n > 32 ? Je(e, t, n) : Ke(e, t, n), Ze = /* @__PURE__ */ new Uint32Array(10);
|
|
622
|
+
function Qe(e, t = 24) {
|
|
623
623
|
if (!(e instanceof Uint32Array)) throw TypeError("\"s\" expected Uint32Array(50), got type=" + typeof e);
|
|
624
624
|
if (e.length !== 50) throw RangeError("\"s\" expected Uint32Array(50), got length=" + e.length);
|
|
625
|
-
if (
|
|
625
|
+
if (E(t, "rounds"), t < 1 || t > 24) throw Error("\"rounds\" expected integer 1..24");
|
|
626
626
|
for (let n = 24 - t; n < 24; n++) {
|
|
627
|
-
for (let t = 0; t < 10; t++)
|
|
627
|
+
for (let t = 0; t < 10; t++) Ze[t] = e[t] ^ e[t + 10] ^ e[t + 20] ^ e[t + 30] ^ e[t + 40];
|
|
628
628
|
for (let t = 0; t < 10; t += 2) {
|
|
629
|
-
let n = (t + 8) % 10, r = (t + 2) % 10, i =
|
|
629
|
+
let n = (t + 8) % 10, r = (t + 2) % 10, i = Ze[r], a = Ze[r + 1], o = Ye(i, a, 1) ^ Ze[n], s = Xe(i, a, 1) ^ Ze[n + 1];
|
|
630
630
|
for (let n = 0; n < 50; n += 10) e[t + n] ^= o, e[t + n + 1] ^= s;
|
|
631
631
|
}
|
|
632
632
|
let t = e[2], r = e[3];
|
|
633
633
|
for (let n = 0; n < 24; n++) {
|
|
634
|
-
let i =
|
|
634
|
+
let i = Be[n], a = Ye(t, r, i), o = Xe(t, r, i), s = ze[n];
|
|
635
635
|
t = e[s], r = e[s + 1], e[s] = a, e[s + 1] = o;
|
|
636
636
|
}
|
|
637
637
|
for (let t = 0; t < 50; t += 10) {
|
|
638
638
|
let n = e[t], r = e[t + 1], i = e[t + 2], a = e[t + 3];
|
|
639
639
|
e[t] ^= ~e[t + 2] & e[t + 4], e[t + 1] ^= ~e[t + 3] & e[t + 5], e[t + 2] ^= ~e[t + 4] & e[t + 6], e[t + 3] ^= ~e[t + 5] & e[t + 7], e[t + 4] ^= ~e[t + 6] & e[t + 8], e[t + 5] ^= ~e[t + 7] & e[t + 9], e[t + 6] ^= ~e[t + 8] & n, e[t + 7] ^= ~e[t + 9] & r, e[t + 8] ^= ~n & i, e[t + 9] ^= ~r & a;
|
|
640
640
|
}
|
|
641
|
-
e[0] ^=
|
|
641
|
+
e[0] ^= Ue[n], e[1] ^= We[n];
|
|
642
642
|
}
|
|
643
|
-
|
|
643
|
+
we(Ze);
|
|
644
644
|
}
|
|
645
|
-
var
|
|
645
|
+
var $e = class e {
|
|
646
646
|
state;
|
|
647
647
|
pos = 0;
|
|
648
648
|
posOut = 0;
|
|
@@ -656,18 +656,18 @@ var Qe = class e {
|
|
|
656
656
|
enableXOF = !1;
|
|
657
657
|
rounds;
|
|
658
658
|
constructor(e, t, n, r = !1, i = 24) {
|
|
659
|
-
if (
|
|
660
|
-
this.state = /* @__PURE__ */ new Uint8Array(200), this.state32 =
|
|
659
|
+
if (E(e, "blockLen"), E(t, "suffix"), E(i, "rounds"), ve(r, "enableXOF"), this.blockLen = e, this.suffix = t, this.outputLen = n, this.enableXOF = r, this.canXOF = r, this.rounds = i, E(n, "outputLen"), !(0 < e && e < 200)) throw Error("\"blockLen\" must be 1..199");
|
|
660
|
+
this.state = /* @__PURE__ */ new Uint8Array(200), this.state32 = Ce(this.state);
|
|
661
661
|
}
|
|
662
662
|
clone() {
|
|
663
663
|
return this._cloneInto();
|
|
664
664
|
}
|
|
665
665
|
keccak() {
|
|
666
|
-
|
|
666
|
+
Oe(this.state32), Qe(this.state32, this.rounds), Oe(this.state32), this.posOut = 0, this.pos = 0;
|
|
667
667
|
}
|
|
668
668
|
update(e) {
|
|
669
|
-
|
|
670
|
-
let { blockLen: t, state: n, state32: r } = this, i = e.length, a = t % 4 == 0 && e.byteOffset % 4 == 0, o = t / 4, s = a && i >= t ?
|
|
669
|
+
xe(this), D(e);
|
|
670
|
+
let { blockLen: t, state: n, state32: r } = this, i = e.length, a = t % 4 == 0 && e.byteOffset % 4 == 0, o = t / 4, s = a && i >= t ? Ce(e) : void 0;
|
|
671
671
|
for (let a = 0; a < i;) {
|
|
672
672
|
if (s !== void 0 && this.pos === 0 && a % 4 == 0 && i - a >= t) {
|
|
673
673
|
for (let e = 0, t = a / 4; e < o; e++) r[e] ^= s[t + e];
|
|
@@ -687,7 +687,7 @@ var Qe = class e {
|
|
|
687
687
|
e[n] ^= t, t & 128 && n === r - 1 && this.keccak(), e[r - 1] ^= 128, this.keccak();
|
|
688
688
|
}
|
|
689
689
|
writeInto(e) {
|
|
690
|
-
|
|
690
|
+
xe(this, !1), D(e), this.finish();
|
|
691
691
|
let t = this.state, { blockLen: n } = this;
|
|
692
692
|
for (let r = 0, i = e.length; r < i;) {
|
|
693
693
|
this.posOut >= n && this.keccak();
|
|
@@ -701,10 +701,10 @@ var Qe = class e {
|
|
|
701
701
|
return this.writeInto(e);
|
|
702
702
|
}
|
|
703
703
|
xof(e) {
|
|
704
|
-
return
|
|
704
|
+
return E(e), this.xofInto(new Uint8Array(e));
|
|
705
705
|
}
|
|
706
706
|
digestInto(e) {
|
|
707
|
-
if (
|
|
707
|
+
if (Se(e, this), this.finished) throw Error("digest() was already called");
|
|
708
708
|
this.writeInto(e.length === this.outputLen ? e : e.subarray(0, this.outputLen)), this.destroy();
|
|
709
709
|
}
|
|
710
710
|
digest() {
|
|
@@ -712,21 +712,21 @@ var Qe = class e {
|
|
|
712
712
|
return this.digestInto(e), e;
|
|
713
713
|
}
|
|
714
714
|
destroy() {
|
|
715
|
-
this.destroyed = !0,
|
|
715
|
+
this.destroyed = !0, we(this.state);
|
|
716
716
|
}
|
|
717
717
|
_cloneInto(t) {
|
|
718
718
|
let { blockLen: n, suffix: r, outputLen: i, rounds: a, enableXOF: o } = this;
|
|
719
719
|
return t ||= new e(n, r, i, o, a), t.blockLen = n, t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = a, t.suffix = r, t.outputLen = i, t.enableXOF = o, t.canXOF = this.canXOF, t.destroyed = this.destroyed, t;
|
|
720
720
|
}
|
|
721
|
-
},
|
|
721
|
+
}, et = (e, t, n, r = {}) => Ae(() => new $e(t, e, n), r), tt = /* @__PURE__ */ et(6, 136, 32, /* @__PURE__ */ Me(8)), nt = /* @__PURE__ */ et(6, 72, 64, /* @__PURE__ */ Me(10)), rt = (e, t, n, r = {}) => Ae((r = {}) => (r = ke({}, r), new $e(t, e, r.dkLen === void 0 ? n : r.dkLen, !0)), r), it = /* @__PURE__ */ rt(31, 168, 16, /* @__PURE__ */ Me(11)), at = /* @__PURE__ */ rt(31, 136, 32, /* @__PURE__ */ Me(12));
|
|
722
722
|
//#endregion
|
|
723
723
|
//#region node_modules/@noble/curves/utils.js
|
|
724
|
-
function
|
|
724
|
+
function ot(e, t = "object") {
|
|
725
725
|
if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError(t === "object" ? "expected valid options object" : `"${t}" expected object, got type=${typeof e}`);
|
|
726
726
|
return e;
|
|
727
727
|
}
|
|
728
|
-
function
|
|
729
|
-
|
|
728
|
+
function st(e, t = {}, n = {}, r = "object") {
|
|
729
|
+
ot(e, r), ot(t, "fields"), ot(n, "optFields");
|
|
730
730
|
function i(t, n, i) {
|
|
731
731
|
let a = r === "object" ? `param "${String(t)}"` : `"${r}.${String(t)}"`, o = e[t];
|
|
732
732
|
if (!Object.hasOwn(e, t) && (i ? o !== void 0 : n !== "function")) throw TypeError(`${a} is invalid: expected own property`);
|
|
@@ -739,31 +739,31 @@ function ot(e, t = {}, n = {}, r = "object") {
|
|
|
739
739
|
}
|
|
740
740
|
//#endregion
|
|
741
741
|
//#region node_modules/@noble/curves/abstract/fft.js
|
|
742
|
-
function
|
|
742
|
+
function ct(e, t = "n") {
|
|
743
743
|
if (typeof e != "number") throw TypeError(`wrong u32 integer "${t}": expected number, got type=${typeof e}`);
|
|
744
744
|
if (!Number.isSafeInteger(e) || e < 0 || e > 4294967295) throw RangeError(`wrong u32 integer "${t}": expected 0..4294967295, got ${e}`);
|
|
745
745
|
return e;
|
|
746
746
|
}
|
|
747
|
-
function
|
|
748
|
-
return
|
|
747
|
+
function lt(e) {
|
|
748
|
+
return ct(e, "x"), !(e & e - 1) && e !== 0;
|
|
749
749
|
}
|
|
750
|
-
function
|
|
751
|
-
if (
|
|
750
|
+
function ut(e, t) {
|
|
751
|
+
if (ct(e), typeof t != "number") throw TypeError("\"bits\" expected number, got type=" + typeof t);
|
|
752
752
|
if (!Number.isSafeInteger(t) || t < 0 || t > 32) throw Error(`expected integer 0 <= bits <= 32, got ${t}`);
|
|
753
753
|
let n = 0;
|
|
754
754
|
for (let r = 0; r < t; r++, e >>>= 1) n = n << 1 | e & 1;
|
|
755
755
|
return n >>> 0;
|
|
756
756
|
}
|
|
757
|
-
function ut(e) {
|
|
758
|
-
return st(e), 31 - Math.clz32(e);
|
|
759
|
-
}
|
|
760
757
|
function dt(e) {
|
|
758
|
+
return ct(e), 31 - Math.clz32(e);
|
|
759
|
+
}
|
|
760
|
+
function ft(e) {
|
|
761
761
|
if (!e || typeof e != "object" || typeof e.length != "number") throw TypeError("\"values\" expected array-like, got type=" + typeof e);
|
|
762
762
|
let t = e.length;
|
|
763
|
-
if (!
|
|
764
|
-
let n =
|
|
763
|
+
if (!lt(t)) throw Error("expected positive power-of-two length, got " + t);
|
|
764
|
+
let n = dt(t);
|
|
765
765
|
for (let r = 0; r < t; r++) {
|
|
766
|
-
let t =
|
|
766
|
+
let t = ut(r, n);
|
|
767
767
|
if (r < t) {
|
|
768
768
|
let n = e[r];
|
|
769
769
|
e[r] = e[t], e[t] = n;
|
|
@@ -771,8 +771,8 @@ function dt(e) {
|
|
|
771
771
|
}
|
|
772
772
|
return e;
|
|
773
773
|
}
|
|
774
|
-
var
|
|
775
|
-
|
|
774
|
+
var pt = (e, t) => {
|
|
775
|
+
st(t, {
|
|
776
776
|
N: "number",
|
|
777
777
|
roots: "object",
|
|
778
778
|
dit: "boolean"
|
|
@@ -782,17 +782,17 @@ var ft = (e, t) => {
|
|
|
782
782
|
brp: "boolean"
|
|
783
783
|
}, "coreOpts");
|
|
784
784
|
let { N: n, roots: r, dit: i, invertButterflies: a = !1, skipStages: o = 0, brp: s = !0 } = t;
|
|
785
|
-
|
|
786
|
-
let c =
|
|
787
|
-
if (!
|
|
788
|
-
|
|
785
|
+
ct(n, "coreOpts.N");
|
|
786
|
+
let c = dt(n);
|
|
787
|
+
if (!lt(n)) throw Error("FFT: Polynomial size should be power of two");
|
|
788
|
+
ct(o, "coreOpts.skipStages");
|
|
789
789
|
let l = c === 0 ? 0 : c - 1;
|
|
790
790
|
if (o > l) throw Error(`FFT: wrong skipStages: expected 0 <= skipStages <= ${l}`);
|
|
791
791
|
if (r.length !== n) throw Error(`FFT: wrong roots length: expected ${n}, got ${r.length}`);
|
|
792
792
|
let u = i !== a;
|
|
793
793
|
return (t) => {
|
|
794
794
|
if (t.length !== n) throw Error("FFT: wrong Polynomial length");
|
|
795
|
-
i && s &&
|
|
795
|
+
i && s && ft(t);
|
|
796
796
|
for (let s = 0, l = 1; s < c - o; s++) {
|
|
797
797
|
let d = i ? s + 1 + o : c - s, f = 1 << d, p = f >> 1, m = n >> d;
|
|
798
798
|
for (let o = 0; o < n; o += f) for (let s = 0, c = l++; s < p; s++) {
|
|
@@ -803,24 +803,24 @@ var ft = (e, t) => {
|
|
|
803
803
|
} else a ? (t[d] = e.add(g, _), t[f] = e.mul(e.sub(g, _), h)) : (t[d] = e.add(_, g), t[f] = e.mul(e.sub(_, g), h));
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
|
-
return !i && s &&
|
|
806
|
+
return !i && s && ft(t), t;
|
|
807
807
|
};
|
|
808
|
-
},
|
|
809
|
-
function
|
|
808
|
+
}, O = D, mt = je;
|
|
809
|
+
function ht(e, t, n = () => {}) {
|
|
810
810
|
if (!Array.isArray(e)) throw TypeError(`"${t}" expected array, got type=${typeof e}`);
|
|
811
811
|
for (let r = 0; r < e.length; r++) n(e[r], `${t}[${r}]`);
|
|
812
812
|
return e;
|
|
813
813
|
}
|
|
814
|
-
function
|
|
815
|
-
if (e =
|
|
814
|
+
function gt(e, t) {
|
|
815
|
+
if (e = D(e), t = D(t), e.length !== t.length) return !1;
|
|
816
816
|
let n = 0;
|
|
817
817
|
for (let r = 0; r < e.length; r++) n |= e[r] ^ t[r];
|
|
818
818
|
return n === 0;
|
|
819
819
|
}
|
|
820
|
-
function
|
|
821
|
-
return new Uint8Array(
|
|
820
|
+
function _t(e) {
|
|
821
|
+
return new Uint8Array(D(e));
|
|
822
822
|
}
|
|
823
|
-
function
|
|
823
|
+
function vt(e, ...t) {
|
|
824
824
|
let n = (e) => typeof e == "number" ? e : e.bytesLen, r = t.reduce((e, t) => e + n(t), 0);
|
|
825
825
|
return {
|
|
826
826
|
bytesLen: r,
|
|
@@ -828,12 +828,12 @@ function _t(e, ...t) {
|
|
|
828
828
|
let a = new Uint8Array(r);
|
|
829
829
|
for (let r = 0, o = 0; r < t.length; r++) {
|
|
830
830
|
let s = t[r], c = n(s), l = typeof s == "number" ? i[r] : s.encode(i[r]);
|
|
831
|
-
|
|
831
|
+
D(l, c, e), a.set(l, o), typeof s != "number" && l.fill(0), o += c;
|
|
832
832
|
}
|
|
833
833
|
return a;
|
|
834
834
|
},
|
|
835
835
|
decode: (i) => {
|
|
836
|
-
|
|
836
|
+
D(i, r, e);
|
|
837
837
|
let a = [];
|
|
838
838
|
for (let e of t) {
|
|
839
839
|
let t = n(e), r = i.subarray(0, t);
|
|
@@ -843,12 +843,12 @@ function _t(e, ...t) {
|
|
|
843
843
|
}
|
|
844
844
|
};
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function yt(e, t) {
|
|
847
847
|
let n = e, r = t * n.bytesLen;
|
|
848
848
|
return {
|
|
849
849
|
bytesLen: r,
|
|
850
850
|
encode: (e) => {
|
|
851
|
-
let i =
|
|
851
|
+
let i = ht(e, "u");
|
|
852
852
|
if (i.length !== t) throw RangeError(`vecCoder.encode: wrong length=${i.length}. Expected: ${t}`);
|
|
853
853
|
let a = new Uint8Array(r);
|
|
854
854
|
for (let e = 0, t = 0; e < i.length; e++) {
|
|
@@ -858,24 +858,24 @@ function vt(e, t) {
|
|
|
858
858
|
return a;
|
|
859
859
|
},
|
|
860
860
|
decode: (e) => {
|
|
861
|
-
|
|
861
|
+
D(e, r);
|
|
862
862
|
let t = [];
|
|
863
863
|
for (let r = 0; r < e.length; r += n.bytesLen) t.push(n.decode(e.subarray(r, r + n.bytesLen)));
|
|
864
864
|
return t;
|
|
865
865
|
}
|
|
866
866
|
};
|
|
867
867
|
}
|
|
868
|
-
function
|
|
868
|
+
function k(...e) {
|
|
869
869
|
for (let t of e) if (Array.isArray(t)) for (let e of t) e.fill(0);
|
|
870
870
|
else t.fill(0);
|
|
871
871
|
}
|
|
872
|
-
function
|
|
873
|
-
if (
|
|
872
|
+
function bt(e) {
|
|
873
|
+
if (E(e, "bits"), e > 32) throw RangeError("\"bits\" expected <= 32, got " + e);
|
|
874
874
|
return e === 32 ? 4294967295 : ~(-1 << e) >>> 0;
|
|
875
875
|
}
|
|
876
876
|
//#endregion
|
|
877
877
|
//#region node_modules/@noble/post-quantum/_crystals.js
|
|
878
|
-
var
|
|
878
|
+
var xt = (e) => {
|
|
879
879
|
let { newPoly: t, N: n, Q: r, F: i, ROOT_OF_UNITY: a, brvBits: o, isKyber: s } = e, c = (e, t = r) => {
|
|
880
880
|
let n = e % t | 0;
|
|
881
881
|
return (n >= 0 ? n | 0 : t + n | 0) | 0;
|
|
@@ -886,7 +886,7 @@ var bt = (e) => {
|
|
|
886
886
|
function u() {
|
|
887
887
|
let e = t(n);
|
|
888
888
|
for (let t = 0; t < n; t++) {
|
|
889
|
-
let n =
|
|
889
|
+
let n = ut(t, o), i = BigInt(a) ** BigInt(n) % BigInt(r);
|
|
890
890
|
e[t] = Number(i) | 0;
|
|
891
891
|
}
|
|
892
892
|
return e;
|
|
@@ -915,10 +915,10 @@ var bt = (e) => {
|
|
|
915
915
|
invertButterflies: !0,
|
|
916
916
|
skipStages: +!!s,
|
|
917
917
|
brp: !1
|
|
918
|
-
}, h =
|
|
918
|
+
}, h = pt(p, {
|
|
919
919
|
dit: !1,
|
|
920
920
|
...m
|
|
921
|
-
}), g =
|
|
921
|
+
}), g = pt(p, {
|
|
922
922
|
dit: !0,
|
|
923
923
|
...m
|
|
924
924
|
}), _ = {
|
|
@@ -938,8 +938,8 @@ var bt = (e) => {
|
|
|
938
938
|
decode: (e) => _.decode(e)
|
|
939
939
|
},
|
|
940
940
|
bitsCoder: (e, r) => {
|
|
941
|
-
for (let t = 0, r = 0; t < n; t++) r += e, r > 32 &&
|
|
942
|
-
let i =
|
|
941
|
+
for (let t = 0, r = 0; t < n; t++) r += e, r > 32 && bt(r), r %= 8;
|
|
942
|
+
let i = bt(e), a = n / 8 * e;
|
|
943
943
|
return {
|
|
944
944
|
bytesLen: a,
|
|
945
945
|
encode: (t) => {
|
|
@@ -955,7 +955,7 @@ var bt = (e) => {
|
|
|
955
955
|
};
|
|
956
956
|
}
|
|
957
957
|
};
|
|
958
|
-
},
|
|
958
|
+
}, St = /* @__PURE__ */ ((e) => (t, n) => {
|
|
959
959
|
n ||= e.blockLen;
|
|
960
960
|
let r = new Uint8Array(t.length + 2);
|
|
961
961
|
r.set(t);
|
|
@@ -967,21 +967,21 @@ var bt = (e) => {
|
|
|
967
967
|
}),
|
|
968
968
|
get: (t, n) => (r[i + 0] = t, r[i + 1] = n, o.destroy(), o = e.create({}).update(r), s++, () => (c++, o.xofInto(a))),
|
|
969
969
|
clean: () => {
|
|
970
|
-
o.destroy(),
|
|
970
|
+
o.destroy(), k(a, r);
|
|
971
971
|
}
|
|
972
972
|
};
|
|
973
|
-
})(
|
|
974
|
-
N:
|
|
975
|
-
Q:
|
|
973
|
+
})(it), A = 256, j = 3329, M = /* @__PURE__ */ xt({
|
|
974
|
+
N: A,
|
|
975
|
+
Q: j,
|
|
976
976
|
F: 3303,
|
|
977
977
|
ROOT_OF_UNITY: 17,
|
|
978
978
|
newPoly: (e) => new Uint16Array(e),
|
|
979
979
|
brvBits: 7,
|
|
980
980
|
isKyber: !0
|
|
981
|
-
}),
|
|
981
|
+
}), Ct = /* @__PURE__ */ Object.freeze({
|
|
982
982
|
512: Object.freeze({
|
|
983
|
-
N:
|
|
984
|
-
Q:
|
|
983
|
+
N: A,
|
|
984
|
+
Q: j,
|
|
985
985
|
K: 2,
|
|
986
986
|
ETA1: 3,
|
|
987
987
|
ETA2: 2,
|
|
@@ -990,8 +990,8 @@ var bt = (e) => {
|
|
|
990
990
|
RBGstrength: 128
|
|
991
991
|
}),
|
|
992
992
|
768: Object.freeze({
|
|
993
|
-
N:
|
|
994
|
-
Q:
|
|
993
|
+
N: A,
|
|
994
|
+
Q: j,
|
|
995
995
|
K: 3,
|
|
996
996
|
ETA1: 2,
|
|
997
997
|
ETA2: 2,
|
|
@@ -1000,8 +1000,8 @@ var bt = (e) => {
|
|
|
1000
1000
|
RBGstrength: 192
|
|
1001
1001
|
}),
|
|
1002
1002
|
1024: Object.freeze({
|
|
1003
|
-
N:
|
|
1004
|
-
Q:
|
|
1003
|
+
N: A,
|
|
1004
|
+
Q: j,
|
|
1005
1005
|
K: 4,
|
|
1006
1006
|
ETA1: 2,
|
|
1007
1007
|
ETA2: 2,
|
|
@@ -1009,93 +1009,93 @@ var bt = (e) => {
|
|
|
1009
1009
|
dv: 5,
|
|
1010
1010
|
RBGstrength: 256
|
|
1011
1011
|
})
|
|
1012
|
-
}),
|
|
1012
|
+
}), wt = (e) => {
|
|
1013
1013
|
if (e >= 12) return {
|
|
1014
1014
|
encode: (e) => e,
|
|
1015
|
-
decode: (e) => e >=
|
|
1015
|
+
decode: (e) => e >= j ? e - j : e
|
|
1016
1016
|
};
|
|
1017
1017
|
let t = 2 ** (e - 1);
|
|
1018
1018
|
return {
|
|
1019
|
-
encode: (t) => ((t << e) +
|
|
1020
|
-
decode: (n) => n *
|
|
1019
|
+
encode: (t) => ((t << e) + j / 2) / j,
|
|
1020
|
+
decode: (n) => n * j + t >>> e
|
|
1021
1021
|
};
|
|
1022
|
-
},
|
|
1022
|
+
}, Tt = (e) => M.bitsCoder(e, e === 12 ? {
|
|
1023
1023
|
encode: (e) => e,
|
|
1024
|
-
decode: (e) => e >=
|
|
1024
|
+
decode: (e) => e >= j ? e - j : e
|
|
1025
1025
|
} : {
|
|
1026
1026
|
encode: (e) => e,
|
|
1027
1027
|
decode: (e) => e
|
|
1028
|
-
}),
|
|
1029
|
-
function
|
|
1028
|
+
}), Et = (e) => e === 12 ? Tt(12) : M.bitsCoder(e, wt(e));
|
|
1029
|
+
function Dt(e, t) {
|
|
1030
1030
|
let n = e, r = t;
|
|
1031
|
-
for (let e = 0; e <
|
|
1031
|
+
for (let e = 0; e < A; e++) {
|
|
1032
1032
|
let t = n[e] + r[e];
|
|
1033
|
-
n[e] = t >=
|
|
1033
|
+
n[e] = t >= j ? t - j : t;
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
1036
|
-
function
|
|
1036
|
+
function Ot(e, t) {
|
|
1037
1037
|
let n = e, r = t;
|
|
1038
|
-
for (let e = 0; e <
|
|
1038
|
+
for (let e = 0; e < A; e++) {
|
|
1039
1039
|
let t = n[e] - r[e];
|
|
1040
|
-
n[e] = t < 0 ? t +
|
|
1040
|
+
n[e] = t < 0 ? t + j : t;
|
|
1041
1041
|
}
|
|
1042
1042
|
}
|
|
1043
|
-
function
|
|
1043
|
+
function kt(e, t, n, r, i) {
|
|
1044
1044
|
return {
|
|
1045
|
-
c0:
|
|
1046
|
-
c1:
|
|
1045
|
+
c0: M.mod(M.mod(t * r) * i + e * n),
|
|
1046
|
+
c1: M.mod(e * r + t * n)
|
|
1047
1047
|
};
|
|
1048
1048
|
}
|
|
1049
|
-
function
|
|
1049
|
+
function At(e, t) {
|
|
1050
1050
|
let n = e, r = t;
|
|
1051
|
-
for (let e = 0; e <
|
|
1052
|
-
let t =
|
|
1051
|
+
for (let e = 0; e < A / 2; e++) {
|
|
1052
|
+
let t = M.nttZetas[64 + (e >> 1)];
|
|
1053
1053
|
e & 1 && (t = -t);
|
|
1054
|
-
let { c0: i, c1: a } =
|
|
1054
|
+
let { c0: i, c1: a } = kt(n[2 * e + 0], n[2 * e + 1], r[2 * e + 0], r[2 * e + 1], t);
|
|
1055
1055
|
n[2 * e + 0] = i, n[2 * e + 1] = a;
|
|
1056
1056
|
}
|
|
1057
1057
|
return n;
|
|
1058
1058
|
}
|
|
1059
|
-
function
|
|
1060
|
-
let t = e, n = new Uint16Array(
|
|
1061
|
-
for (let e = 0; e <
|
|
1059
|
+
function jt(e) {
|
|
1060
|
+
let t = e, n = new Uint16Array(A);
|
|
1061
|
+
for (let e = 0; e < A;) {
|
|
1062
1062
|
let r = t();
|
|
1063
1063
|
if (r.length % 3) throw Error("SampleNTT: unaligned block");
|
|
1064
|
-
for (let t = 0; e <
|
|
1064
|
+
for (let t = 0; e < A && t + 3 <= r.length; t += 3) {
|
|
1065
1065
|
let i = (r[t + 0] >> 0 | r[t + 1] << 8) & 4095, a = (r[t + 1] >> 4 | r[t + 2] << 4) & 4095;
|
|
1066
|
-
i <
|
|
1066
|
+
i < j && (n[e++] = i), e < A && a < j && (n[e++] = a);
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
1069
|
return n;
|
|
1070
1070
|
}
|
|
1071
|
-
var
|
|
1072
|
-
let n = new Uint16Array(
|
|
1073
|
-
|
|
1071
|
+
var Mt = (e, t) => {
|
|
1072
|
+
let n = new Uint16Array(A), r = Ce(e);
|
|
1073
|
+
Oe(r);
|
|
1074
1074
|
let i = 0;
|
|
1075
1075
|
for (let e = 0, a = 0, o = 0, s = 0; e < r.length; e++) {
|
|
1076
1076
|
let c = r[e];
|
|
1077
|
-
for (let e = 0; e < 32; e++) o += c & 1, c >>= 1, i += 1, i === t ? (s = o, o = 0) : i === 2 * t && (n[a++] =
|
|
1077
|
+
for (let e = 0; e < 32; e++) o += c & 1, c >>= 1, i += 1, i === t ? (s = o, o = 0) : i === 2 * t && (n[a++] = M.mod(s - o), o = 0, i = 0);
|
|
1078
1078
|
}
|
|
1079
|
-
if (
|
|
1079
|
+
if (Oe(r), i) throw Error(`sampleCBD: leftover bits: ${i}`);
|
|
1080
1080
|
return n;
|
|
1081
1081
|
};
|
|
1082
|
-
function
|
|
1083
|
-
return
|
|
1082
|
+
function Nt(e, t, n, r) {
|
|
1083
|
+
return Mt(e(r * A / 4, t, n), r);
|
|
1084
1084
|
}
|
|
1085
|
-
var
|
|
1086
|
-
let { K: t, PRF: n, XOF: r, HASH512: i, ETA1: a, ETA2: o, du: s, dv: c } = e, l =
|
|
1085
|
+
var Pt = (e) => {
|
|
1086
|
+
let { K: t, PRF: n, XOF: r, HASH512: i, ETA1: a, ETA2: o, du: s, dv: c } = e, l = Et(1), u = Et(c), d = Et(s), f = vt("publicKey", yt(Et(12), t), 32), p = yt(Et(12), t), m = vt("ciphertext", yt(d, t), u), h = vt("seed", 32, 32), g = (e, r, i, s) => {
|
|
1087
1087
|
let c = [];
|
|
1088
|
-
for (let e = 0; e < t; e++) c.push(
|
|
1089
|
-
let u = new Uint16Array(
|
|
1088
|
+
for (let e = 0; e < t; e++) c.push(M.NTT.encode(Nt(n, s, e, a)));
|
|
1089
|
+
let u = new Uint16Array(A), d = [];
|
|
1090
1090
|
for (let i = 0; i < t; i++) {
|
|
1091
|
-
let a =
|
|
1092
|
-
for (let e = 0; e < t; e++)
|
|
1093
|
-
|
|
1091
|
+
let a = Nt(n, s, t + i, o), l = new Uint16Array(A);
|
|
1092
|
+
for (let e = 0; e < t; e++) Dt(l, At(r(i, e), c[e]));
|
|
1093
|
+
Dt(a, M.NTT.decode(l)), d.push(a), Dt(u, At(e[i], c[i])), k(l);
|
|
1094
1094
|
}
|
|
1095
|
-
let f =
|
|
1096
|
-
|
|
1095
|
+
let f = Nt(n, s, 2 * t, o);
|
|
1096
|
+
Dt(f, M.NTT.decode(u));
|
|
1097
1097
|
let p = l.decode(i);
|
|
1098
|
-
return
|
|
1098
|
+
return Dt(p, f), k(e, c, u, f), m.encode([d, p]);
|
|
1099
1099
|
};
|
|
1100
1100
|
return {
|
|
1101
1101
|
secretCoder: p,
|
|
@@ -1105,15 +1105,15 @@ var Mt = (e) => {
|
|
|
1105
1105
|
cipherText: m.bytesLen
|
|
1106
1106
|
},
|
|
1107
1107
|
keygen: (e) => {
|
|
1108
|
-
|
|
1108
|
+
O(e, 32, "seed");
|
|
1109
1109
|
let o = /* @__PURE__ */ new Uint8Array(33);
|
|
1110
1110
|
o.set(e), o[32] = t;
|
|
1111
1111
|
let s = i(o), [c, l] = h.decode(s), u = [], d = [];
|
|
1112
|
-
for (let e = 0; e < t; e++) u.push(
|
|
1112
|
+
for (let e = 0; e < t; e++) u.push(M.NTT.encode(Nt(n, l, e, a)));
|
|
1113
1113
|
let m = r(c);
|
|
1114
1114
|
for (let e = 0; e < t; e++) {
|
|
1115
|
-
let r =
|
|
1116
|
-
for (let n = 0; n < t; n++)
|
|
1115
|
+
let r = M.NTT.encode(Nt(n, l, t + e, a));
|
|
1116
|
+
for (let n = 0; n < t; n++) Dt(r, At(jt(m.get(n, e)), u[n]));
|
|
1117
1117
|
d.push(r);
|
|
1118
1118
|
}
|
|
1119
1119
|
m.clean();
|
|
@@ -1121,33 +1121,33 @@ var Mt = (e) => {
|
|
|
1121
1121
|
publicKey: f.encode([d, c]),
|
|
1122
1122
|
secretKey: p.encode(u)
|
|
1123
1123
|
};
|
|
1124
|
-
return
|
|
1124
|
+
return k(c, l, u, d, o, s), g;
|
|
1125
1125
|
},
|
|
1126
1126
|
encrypt: (e, t, n) => {
|
|
1127
|
-
let [i, a] = f.decode(e), o = r(a), s = g(i, (e, t) =>
|
|
1127
|
+
let [i, a] = f.decode(e), o = r(a), s = g(i, (e, t) => jt(o.get(e, t)), t, n);
|
|
1128
1128
|
return o.clean(), s;
|
|
1129
1129
|
},
|
|
1130
1130
|
prepare: (e) => {
|
|
1131
1131
|
let [n, i] = f.decode(e), a = r(i), o = [];
|
|
1132
|
-
for (let e = 0; e < t; e++) for (let n = 0; n < t; n++) o.push(
|
|
1132
|
+
for (let e = 0; e < t; e++) for (let n = 0; n < t; n++) o.push(jt(a.get(e, n)));
|
|
1133
1133
|
return a.clean(), {
|
|
1134
1134
|
encrypt: (e, r) => g(n.map((e) => e.slice()), (e, n) => o[e * t + n].slice(), e, r),
|
|
1135
|
-
clean: () =>
|
|
1135
|
+
clean: () => k(n, o)
|
|
1136
1136
|
};
|
|
1137
1137
|
},
|
|
1138
1138
|
decrypt: (e, n) => {
|
|
1139
|
-
let [r, i] = m.decode(e), a = p.decode(n), o = new Uint16Array(
|
|
1140
|
-
for (let e = 0; e < t; e++)
|
|
1141
|
-
|
|
1139
|
+
let [r, i] = m.decode(e), a = p.decode(n), o = new Uint16Array(A);
|
|
1140
|
+
for (let e = 0; e < t; e++) Dt(o, At(a[e], M.NTT.encode(r[e])));
|
|
1141
|
+
Ot(i, M.NTT.decode(o));
|
|
1142
1142
|
let s = l.encode(i);
|
|
1143
|
-
return
|
|
1143
|
+
return k(o, a, r, i), s;
|
|
1144
1144
|
}
|
|
1145
1145
|
};
|
|
1146
1146
|
};
|
|
1147
|
-
function
|
|
1148
|
-
let t = e, n =
|
|
1149
|
-
let r = e.subarray(0, 384 * t.K), i = o.encode(o.decode(
|
|
1150
|
-
if (
|
|
1147
|
+
function Ft(e) {
|
|
1148
|
+
let t = e, n = Pt(t), { HASH256: r, HASH512: i, KDF: a } = t, { secretCoder: o, lengths: s } = n, c = vt("secretKey", s.secretKey, s.publicKey, 32, 32), l = (e, n) => {
|
|
1149
|
+
let r = e.subarray(0, 384 * t.K), i = o.encode(o.decode(_t(r))), a = gt(i, r);
|
|
1150
|
+
if (k(i), !a) throw Error(`ML-KEM.${n}: wrong publicKey modulus`);
|
|
1151
1151
|
}, u = Object.freeze({
|
|
1152
1152
|
...s,
|
|
1153
1153
|
seed: 64,
|
|
@@ -1159,9 +1159,9 @@ function Nt(e) {
|
|
|
1159
1159
|
info: Object.freeze({ type: "ml-kem" }),
|
|
1160
1160
|
lengths: u,
|
|
1161
1161
|
keygen: (e) => {
|
|
1162
|
-
let t = e === void 0, i = t ?
|
|
1162
|
+
let t = e === void 0, i = t ? mt(64) : e, a, o;
|
|
1163
1163
|
try {
|
|
1164
|
-
|
|
1164
|
+
O(i, 64, "seed");
|
|
1165
1165
|
let e = n.keygen(i.subarray(0, 32)), t = e.publicKey;
|
|
1166
1166
|
return a = e.secretKey, o = r(t), {
|
|
1167
1167
|
publicKey: t,
|
|
@@ -1173,7 +1173,7 @@ function Nt(e) {
|
|
|
1173
1173
|
])
|
|
1174
1174
|
};
|
|
1175
1175
|
} finally {
|
|
1176
|
-
a !== void 0 &&
|
|
1176
|
+
a !== void 0 && k(a), o !== void 0 && k(o), t && k(i);
|
|
1177
1177
|
}
|
|
1178
1178
|
},
|
|
1179
1179
|
getPublicKey: (e) => {
|
|
@@ -1181,90 +1181,90 @@ function Nt(e) {
|
|
|
1181
1181
|
return Uint8Array.from(n);
|
|
1182
1182
|
},
|
|
1183
1183
|
encapsulate: (e, t) => {
|
|
1184
|
-
let a = t === void 0, o = a ?
|
|
1184
|
+
let a = t === void 0, o = a ? mt(32) : t, c;
|
|
1185
1185
|
try {
|
|
1186
|
-
return
|
|
1186
|
+
return O(e, s.publicKey, "publicKey"), O(o, 32, "message"), l(e, "encapsulate"), c = i.create().update(o).update(r(e)).digest(), {
|
|
1187
1187
|
cipherText: n.encrypt(e, o, c.subarray(32, 64)),
|
|
1188
1188
|
sharedSecret: c.subarray(0, 32)
|
|
1189
1189
|
};
|
|
1190
1190
|
} finally {
|
|
1191
|
-
c !== void 0 &&
|
|
1191
|
+
c !== void 0 && k(c.subarray(32)), a && k(o);
|
|
1192
1192
|
}
|
|
1193
1193
|
},
|
|
1194
1194
|
decapsulate: (e, t) => {
|
|
1195
|
-
|
|
1195
|
+
O(t, c.bytesLen, "secretKey"), O(e, s.cipherText, "cipherText");
|
|
1196
1196
|
let o = c.bytesLen - 96, l = o + 32;
|
|
1197
|
-
if (!
|
|
1198
|
-
let [u, d, f, p] = c.decode(t), m = n.decrypt(e, u), h = i.create().update(m).update(f).digest(), g = h.subarray(0, 32), _ = n.encrypt(d, m, h.subarray(32, 64)), v =
|
|
1199
|
-
return
|
|
1197
|
+
if (!gt(r(t.subarray(o / 2, l)), t.subarray(l, l + 32))) throw Error("invalid secretKey: hash check failed");
|
|
1198
|
+
let [u, d, f, p] = c.decode(t), m = n.decrypt(e, u), h = i.create().update(m).update(f).digest(), g = h.subarray(0, 32), _ = n.encrypt(d, m, h.subarray(32, 64)), v = gt(e, _), y = a.create({ dkLen: 32 }).update(p).update(e).digest();
|
|
1199
|
+
return k(m, _, h.subarray(32), v ? y : g), v ? g : y;
|
|
1200
1200
|
},
|
|
1201
1201
|
prepare: (e) => {
|
|
1202
|
-
|
|
1203
|
-
let t =
|
|
1202
|
+
O(e, s.publicKey, "publicKey"), l(e, "prepare");
|
|
1203
|
+
let t = _t(e), o = r(t), u = n.prepare(t);
|
|
1204
1204
|
return Object.freeze({
|
|
1205
1205
|
publicKey: t,
|
|
1206
1206
|
encapsulate: (e) => {
|
|
1207
|
-
let t = e === void 0, n = t ?
|
|
1207
|
+
let t = e === void 0, n = t ? mt(32) : e, r;
|
|
1208
1208
|
try {
|
|
1209
|
-
return
|
|
1209
|
+
return O(n, 32, "message"), r = i.create().update(n).update(o).digest(), {
|
|
1210
1210
|
cipherText: u.encrypt(n, r.subarray(32, 64)),
|
|
1211
1211
|
sharedSecret: r.subarray(0, 32)
|
|
1212
1212
|
};
|
|
1213
1213
|
} finally {
|
|
1214
|
-
r !== void 0 &&
|
|
1214
|
+
r !== void 0 && k(r.subarray(32)), t && k(n);
|
|
1215
1215
|
}
|
|
1216
1216
|
},
|
|
1217
1217
|
decapsulate: (e, r) => {
|
|
1218
|
-
|
|
1218
|
+
O(r, c.bytesLen, "secretKey"), O(e, s.cipherText, "cipherText");
|
|
1219
1219
|
let [l, d, f, p] = c.decode(r);
|
|
1220
|
-
if (!
|
|
1221
|
-
let m = n.decrypt(e, l), h = i.create().update(m).update(o).digest(), g = h.subarray(0, 32), _ = u.encrypt(m, h.subarray(32, 64)), v =
|
|
1222
|
-
return
|
|
1220
|
+
if (!gt(d, t) || !gt(f, o)) throw Error("ML-KEM.decapsulate: secretKey does not match prepared publicKey");
|
|
1221
|
+
let m = n.decrypt(e, l), h = i.create().update(m).update(o).digest(), g = h.subarray(0, 32), _ = u.encrypt(m, h.subarray(32, 64)), v = gt(e, _), y = a.create({ dkLen: 32 }).update(p).update(e).digest();
|
|
1222
|
+
return k(m, _, h.subarray(32), v ? y : g), v ? g : y;
|
|
1223
1223
|
},
|
|
1224
1224
|
clean: u.clean
|
|
1225
1225
|
});
|
|
1226
1226
|
}
|
|
1227
1227
|
});
|
|
1228
1228
|
}
|
|
1229
|
-
function
|
|
1230
|
-
return
|
|
1229
|
+
function It(e, t, n) {
|
|
1230
|
+
return at.create({ dkLen: e }).update(t).update(new Uint8Array([n])).digest();
|
|
1231
1231
|
}
|
|
1232
|
-
var
|
|
1233
|
-
HASH256:
|
|
1234
|
-
HASH512:
|
|
1235
|
-
KDF:
|
|
1236
|
-
XOF:
|
|
1237
|
-
PRF:
|
|
1238
|
-
},
|
|
1239
|
-
...
|
|
1232
|
+
var Lt = {
|
|
1233
|
+
HASH256: tt,
|
|
1234
|
+
HASH512: nt,
|
|
1235
|
+
KDF: at,
|
|
1236
|
+
XOF: St,
|
|
1237
|
+
PRF: It
|
|
1238
|
+
}, Rt = (e) => Ft({
|
|
1239
|
+
...Lt,
|
|
1240
1240
|
...e
|
|
1241
|
-
}),
|
|
1241
|
+
}), zt = /* @__PURE__ */ Rt(Ct[768]), Bt = {
|
|
1242
1242
|
1024: {
|
|
1243
|
-
kem: /* @__PURE__ */
|
|
1243
|
+
kem: /* @__PURE__ */ Rt(Ct[1024]),
|
|
1244
1244
|
pkBytes: 1568,
|
|
1245
1245
|
skBytes: 3168,
|
|
1246
1246
|
ctBytes: 1568
|
|
1247
1247
|
},
|
|
1248
1248
|
768: {
|
|
1249
|
-
kem:
|
|
1249
|
+
kem: zt,
|
|
1250
1250
|
pkBytes: 1184,
|
|
1251
1251
|
skBytes: 2400,
|
|
1252
1252
|
ctBytes: 1088
|
|
1253
1253
|
}
|
|
1254
|
-
},
|
|
1255
|
-
constructor({ secret: e = null, bundle: n = null, token: r = "USER", address: i = null, position: a = null, batchId: o = null, characters: s = null, mlKemParameterSet: c =
|
|
1254
|
+
}, Vt = 1024, N = class t {
|
|
1255
|
+
constructor({ secret: e = null, bundle: n = null, token: r = "USER", address: i = null, position: a = null, batchId: o = null, characters: s = null, mlKemParameterSet: c = Vt }) {
|
|
1256
1256
|
let l = Number(c);
|
|
1257
|
-
if (!
|
|
1258
|
-
this.mlKemParameterSet = l, this.token = r, this.balance = "0", this.molecules = {}, this.key = null, this.privkey = null, this.pubkey = null, this.tokenUnits = [], this.tradeRates = {}, this.address = i, this.position = a, this.bundle = n, this.batchId = o, this.characters = s, e && (this.bundle = this.bundle ||
|
|
1257
|
+
if (!Bt[l]) throw Error(`KnishIO: unsupported ML-KEM parameter set ${c}; expected 1024 or 768.`);
|
|
1258
|
+
this.mlKemParameterSet = l, this.token = r, this.balance = "0", this.molecules = {}, this.key = null, this.privkey = null, this.pubkey = null, this.tokenUnits = [], this.tradeRates = {}, this.address = i, this.position = a, this.bundle = n, this.batchId = o, this.characters = s, e && (this.bundle = this.bundle || se(e, "Wallet::constructor"), this.position = this.position || t.generatePosition(), this.key = t.generateKey({
|
|
1259
1259
|
secret: e,
|
|
1260
1260
|
token: this.token,
|
|
1261
1261
|
position: this.position
|
|
1262
1262
|
}), this.address = this.address || t.generateAddress(this.key), this.characters = this.characters || "BASE64", this.initializeMLKEM());
|
|
1263
1263
|
}
|
|
1264
|
-
static create({ secret: e = null, bundle: n = null, token: r, batchId: i = null, characters: a = null, mlKemParameterSet: o =
|
|
1264
|
+
static create({ secret: e = null, bundle: n = null, token: r, batchId: i = null, characters: a = null, mlKemParameterSet: o = Vt }) {
|
|
1265
1265
|
let s = null;
|
|
1266
|
-
if (!e && !n) throw new
|
|
1267
|
-
return e && !n && (s = t.generatePosition(), n =
|
|
1266
|
+
if (!e && !n) throw new de();
|
|
1267
|
+
return e && !n && (s = t.generatePosition(), n = se(e, "Wallet::create")), new t({
|
|
1268
1268
|
secret: e,
|
|
1269
1269
|
bundle: n,
|
|
1270
1270
|
token: r,
|
|
@@ -1280,13 +1280,13 @@ var Ft = {
|
|
|
1280
1280
|
static getTokenUnits(e) {
|
|
1281
1281
|
let t = [];
|
|
1282
1282
|
return e.forEach((e) => {
|
|
1283
|
-
t.push(
|
|
1283
|
+
t.push(ue.createFromDB(e));
|
|
1284
1284
|
}), t;
|
|
1285
1285
|
}
|
|
1286
1286
|
static generateKey({ secret: t, token: n, position: r }) {
|
|
1287
|
-
if (!t) throw new
|
|
1288
|
-
if (!r) throw new
|
|
1289
|
-
let i = v(t) ? t :
|
|
1287
|
+
if (!t) throw new de("Wallet::generateKey() - Secret is required!");
|
|
1288
|
+
if (!r) throw new de("Wallet::generateKey() - Position is required!");
|
|
1289
|
+
let i = v(t) ? t : ce(t, 1024), a = v(r) ? r : ce(r, 256), o = BigInt(`0x${i}`) + BigInt(`0x${a}`), s = new e("SHAKE256", "TEXT");
|
|
1290
1290
|
s.update(o.toString(16)), n && s.update(n);
|
|
1291
1291
|
let c = new e("SHAKE256", "TEXT");
|
|
1292
1292
|
return c.update(s.getHash("HEX", { outputLen: 8192 })), c.getHash("HEX", { outputLen: 8192 });
|
|
@@ -1308,7 +1308,7 @@ var Ft = {
|
|
|
1308
1308
|
return f(e, "abcdef0123456789");
|
|
1309
1309
|
}
|
|
1310
1310
|
_deriveMlKemKeypair(e) {
|
|
1311
|
-
let t =
|
|
1311
|
+
let t = Bt[e];
|
|
1312
1312
|
if (!t) throw Error(`KnishIO: unsupported ML-KEM parameter set ${e}; expected 1024 or 768.`);
|
|
1313
1313
|
if (!this.key) return null;
|
|
1314
1314
|
let n = oe(this.key, 128), r = /* @__PURE__ */ new Uint8Array(64);
|
|
@@ -1343,7 +1343,7 @@ var Ft = {
|
|
|
1343
1343
|
} catch {
|
|
1344
1344
|
return null;
|
|
1345
1345
|
}
|
|
1346
|
-
for (let [e, n] of Object.entries(
|
|
1346
|
+
for (let [e, n] of Object.entries(Bt)) if (n.pkBytes === t) return Number(e);
|
|
1347
1347
|
return null;
|
|
1348
1348
|
}
|
|
1349
1349
|
balanceAsNumber() {
|
|
@@ -1396,10 +1396,10 @@ var Ft = {
|
|
|
1396
1396
|
return (this.position === void 0 || this.position === null) && (this.address === void 0 || this.address === null);
|
|
1397
1397
|
}
|
|
1398
1398
|
initBatchId({ sourceWallet: e, isRemainder: t = !1 }) {
|
|
1399
|
-
e.batchId && (this.batchId = t ? e.batchId :
|
|
1399
|
+
e.batchId && (this.batchId = t ? e.batchId : le({}));
|
|
1400
1400
|
}
|
|
1401
1401
|
async encryptMessage(e, t) {
|
|
1402
|
-
let n = JSON.stringify(e), r = new TextEncoder().encode(n), i = this.deserializeKey(t), a =
|
|
1402
|
+
let n = JSON.stringify(e), r = new TextEncoder().encode(n), i = this.deserializeKey(t), a = Bt[this.mlKemParameterSet];
|
|
1403
1403
|
if (i.length !== a.pkBytes) throw Error(`KnishIO: cannot ML-KEM-encrypt — recipient public key is ${i.length} bytes, expected ${a.pkBytes} (ML-KEM-${this.mlKemParameterSet}). The peer is not running ML-KEM-${this.mlKemParameterSet}; upgrade the peer, or step this client back to the other parameter set.`);
|
|
1404
1404
|
let { cipherText: o, sharedSecret: s } = a.kem.encapsulate(i), c = await this.encryptWithSharedSecret(r, s);
|
|
1405
1405
|
return {
|
|
@@ -1412,9 +1412,9 @@ var Ft = {
|
|
|
1412
1412
|
return t === null ? null : JSON.parse(t);
|
|
1413
1413
|
}
|
|
1414
1414
|
async _mlkemDecryptToString(e) {
|
|
1415
|
-
let { cipherText: t, encryptedMessage: n } = e, r = this.deserializeKey(t), i =
|
|
1415
|
+
let { cipherText: t, encryptedMessage: n } = e, r = this.deserializeKey(t), i = Bt[this.mlKemParameterSet], a = this.mlKemParameterSet === 1024 ? 768 : 1024, o = i, s = this.privkey;
|
|
1416
1416
|
if (r.length !== i.ctBytes) {
|
|
1417
|
-
if (r.length !==
|
|
1417
|
+
if (r.length !== Bt[a].ctBytes) return console.error(`Wallet::decryptMessage() - Ciphertext length mismatch: got ${r.length}, expected ${i.ctBytes}`), null;
|
|
1418
1418
|
let e = this._deriveMlKemKeypair(a);
|
|
1419
1419
|
if (!e) return console.error(`Wallet::decryptMessage() - cannot derive the ML-KEM-${a} identity: wallet has no key`), null;
|
|
1420
1420
|
o = e.params, s = e.privkey;
|
|
@@ -1444,7 +1444,7 @@ var Ft = {
|
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
1446
|
hashShare(e) {
|
|
1447
|
-
let t =
|
|
1447
|
+
let t = ce(e, 64), n = Uint8Array.from(t.match(/.{2}/g).map((e) => parseInt(e, 16)));
|
|
1448
1448
|
return this.serializeKey(n);
|
|
1449
1449
|
}
|
|
1450
1450
|
async encryptStringML(e, t) {
|
|
@@ -1473,67 +1473,67 @@ var Ft = {
|
|
|
1473
1473
|
}, r = await crypto.subtle.importKey("raw", t, { name: "AES-GCM" }, !1, ["decrypt"]), i = await crypto.subtle.decrypt(n, r, e.slice(12));
|
|
1474
1474
|
return new Uint8Array(i);
|
|
1475
1475
|
}
|
|
1476
|
-
},
|
|
1476
|
+
}, Ht = class extends C {
|
|
1477
1477
|
constructor(e = "There is an atom without an index", t = null, n = null) {
|
|
1478
1478
|
super(e, t, n), this.name = "AtomIndexException";
|
|
1479
1479
|
}
|
|
1480
|
-
},
|
|
1480
|
+
}, Ut = class extends C {
|
|
1481
1481
|
constructor(e = "The molecular hash does not match", t = null, n = null) {
|
|
1482
1482
|
super(e, t, n), this.name = "MolecularHashMismatchException";
|
|
1483
1483
|
}
|
|
1484
|
-
},
|
|
1484
|
+
}, Wt = class extends C {
|
|
1485
1485
|
constructor(e = "The molecular hash is missing", t = null, n = null) {
|
|
1486
1486
|
super(e, t, n), this.name = "MolecularHashMissingException";
|
|
1487
1487
|
}
|
|
1488
|
-
},
|
|
1488
|
+
}, Gt = class extends C {
|
|
1489
1489
|
constructor(e = "", t = null, n = null) {
|
|
1490
1490
|
super(e, t, n), this.name = "PolicyInvalidException";
|
|
1491
1491
|
}
|
|
1492
|
-
},
|
|
1492
|
+
}, Kt = class extends C {
|
|
1493
1493
|
constructor(e = "OTS malformed", t = null, n = null) {
|
|
1494
1494
|
super(e, t, n), this.name = "SignatureMalformedException";
|
|
1495
1495
|
}
|
|
1496
|
-
},
|
|
1496
|
+
}, qt = class extends C {
|
|
1497
1497
|
constructor(e = "One-time signature (OTS) does not match!", t = null, n = null) {
|
|
1498
1498
|
super(e, t, n), this.name = "SignatureMismatchException";
|
|
1499
1499
|
}
|
|
1500
|
-
},
|
|
1500
|
+
}, P = class extends C {
|
|
1501
1501
|
constructor(e = "Insufficient balance to make transfer", t = null, n = null) {
|
|
1502
1502
|
super(e, t, n), this.name = "TransferBalanceException";
|
|
1503
1503
|
}
|
|
1504
|
-
},
|
|
1504
|
+
}, Jt = class extends C {
|
|
1505
1505
|
constructor(e = "Token transfer atoms are malformed", t = null, n = null) {
|
|
1506
1506
|
super(e, t, n), this.name = "TransferMalformedException";
|
|
1507
1507
|
}
|
|
1508
|
-
},
|
|
1508
|
+
}, Yt = class extends C {
|
|
1509
1509
|
constructor(e = "Token slugs for wallets in transfer do not match!", t = null, n = null) {
|
|
1510
1510
|
super(e, t, n), this.name = "TransferMismatchedException";
|
|
1511
1511
|
}
|
|
1512
|
-
},
|
|
1512
|
+
}, Xt = class extends C {
|
|
1513
1513
|
constructor(e = "Invalid remainder provided", t = null, n = null) {
|
|
1514
1514
|
super(e, t, n), this.name = "TransferRemainderException";
|
|
1515
1515
|
}
|
|
1516
|
-
},
|
|
1516
|
+
}, Zt = class extends C {
|
|
1517
1517
|
constructor(e = "Sender and recipient(s) cannot be the same", t = null, n = null) {
|
|
1518
1518
|
super(e, t, n), this.name = "TransferToSelfException";
|
|
1519
1519
|
}
|
|
1520
|
-
},
|
|
1520
|
+
}, Qt = class extends C {
|
|
1521
1521
|
constructor(e = "Token transfer atoms are unbalanced", t = null, n = null) {
|
|
1522
1522
|
super(e, t, n), this.name = "TransferUnbalancedException";
|
|
1523
1523
|
}
|
|
1524
|
-
},
|
|
1524
|
+
}, F = class extends C {
|
|
1525
1525
|
constructor(e = "Empty meta data.", t = null, n = null) {
|
|
1526
1526
|
super(e, t, n), this.name = "MetaMissingException";
|
|
1527
1527
|
}
|
|
1528
|
-
},
|
|
1528
|
+
}, I = class extends C {
|
|
1529
1529
|
constructor(e = "Wrong type of token for this isotope", t = null, n = null) {
|
|
1530
1530
|
super(e, t, n), this.name = "WrongTokenTypeException";
|
|
1531
1531
|
}
|
|
1532
|
-
},
|
|
1532
|
+
}, $t = class extends C {
|
|
1533
1533
|
constructor(e = "Incorrect BatchId", t = null, n = null) {
|
|
1534
1534
|
super(e, t, n), this.name = "BatchIdException";
|
|
1535
1535
|
}
|
|
1536
|
-
},
|
|
1536
|
+
}, en = class {
|
|
1537
1537
|
constructor(e = {}) {
|
|
1538
1538
|
for (let t in e) this[`__${t}`] = e[t];
|
|
1539
1539
|
}
|
|
@@ -1545,24 +1545,24 @@ var Ft = {
|
|
|
1545
1545
|
for (let t of Object.keys(this)) t.substring(0, 2) === "__" && (e[t.substring(2, t.length)] = this[t]);
|
|
1546
1546
|
return e;
|
|
1547
1547
|
}
|
|
1548
|
-
},
|
|
1548
|
+
}, tn = class extends C {
|
|
1549
1549
|
constructor(e = "An incorrect argument!", t = null, n = null) {
|
|
1550
1550
|
super(e, t, n), this.name = "RuleArgumentException";
|
|
1551
1551
|
}
|
|
1552
|
-
},
|
|
1552
|
+
}, L = class extends C {
|
|
1553
1553
|
constructor(e = "Code exception", t = null, n = null) {
|
|
1554
1554
|
super(e, t, n), this.name = "CodeException";
|
|
1555
1555
|
}
|
|
1556
|
-
},
|
|
1556
|
+
}, nn = class e {
|
|
1557
1557
|
constructor({ action: e, metaType: t = null, metaId: n = null, meta: r = null, address: i = null, token: a = null, amount: o = null, comparison: s = null }) {
|
|
1558
|
-
if (r && (this.meta = r), !e) throw new
|
|
1558
|
+
if (r && (this.meta = r), !e) throw new tn("Callback structure violated, missing mandatory \"action\" parameter.");
|
|
1559
1559
|
this.__metaId = n, this.__metaType = t, this.__action = e, this.__address = i, this.__token = a, this.__amount = o, this.__comparison = s;
|
|
1560
1560
|
}
|
|
1561
1561
|
set comparison(e) {
|
|
1562
1562
|
this.__comparison = e;
|
|
1563
1563
|
}
|
|
1564
1564
|
set amount(e) {
|
|
1565
|
-
if (!y(e)) throw new
|
|
1565
|
+
if (!y(e)) throw new L("Parameter amount should be a string containing numbers");
|
|
1566
1566
|
this.__amount = e;
|
|
1567
1567
|
}
|
|
1568
1568
|
set token(e) {
|
|
@@ -1572,7 +1572,7 @@ var Ft = {
|
|
|
1572
1572
|
this.__address = e;
|
|
1573
1573
|
}
|
|
1574
1574
|
set meta(e) {
|
|
1575
|
-
this.__meta = e instanceof
|
|
1575
|
+
this.__meta = e instanceof en ? e : en.toObject(e);
|
|
1576
1576
|
}
|
|
1577
1577
|
set metaType(e) {
|
|
1578
1578
|
this.__metaType = e;
|
|
@@ -1635,13 +1635,13 @@ var Ft = {
|
|
|
1635
1635
|
_is(e) {
|
|
1636
1636
|
return this.__action.toLowerCase() === e.toLowerCase();
|
|
1637
1637
|
}
|
|
1638
|
-
},
|
|
1638
|
+
}, rn = class {
|
|
1639
1639
|
constructor({ key: e, value: t, comparison: n }) {
|
|
1640
1640
|
if ([
|
|
1641
1641
|
e,
|
|
1642
1642
|
t,
|
|
1643
1643
|
n
|
|
1644
|
-
].some((e) => !e)) throw new
|
|
1644
|
+
].some((e) => !e)) throw new tn("Condition::constructor( { key, value, comparison } ) - not all class parameters are initialised!");
|
|
1645
1645
|
this.__key = e, this.__value = t, this.__comparison = n;
|
|
1646
1646
|
}
|
|
1647
1647
|
static toObject(e) {
|
|
@@ -1658,21 +1658,21 @@ var Ft = {
|
|
|
1658
1658
|
comparison: this.__comparison
|
|
1659
1659
|
};
|
|
1660
1660
|
}
|
|
1661
|
-
},
|
|
1661
|
+
}, an = class e {
|
|
1662
1662
|
constructor({ condition: e = [], callback: t = [] }) {
|
|
1663
|
-
for (let t of e) if (!(t instanceof
|
|
1664
|
-
for (let e of t) if (!(e instanceof
|
|
1663
|
+
for (let t of e) if (!(t instanceof rn)) throw new tn();
|
|
1664
|
+
for (let e of t) if (!(e instanceof nn)) throw new tn();
|
|
1665
1665
|
this.__condition = e, this.__callback = t;
|
|
1666
1666
|
}
|
|
1667
1667
|
set comparison(e) {
|
|
1668
|
-
this.__condition.push(e instanceof
|
|
1668
|
+
this.__condition.push(e instanceof rn ? e : rn.toObject(e));
|
|
1669
1669
|
}
|
|
1670
1670
|
set callback(e) {
|
|
1671
|
-
this.__callback.push(e instanceof
|
|
1671
|
+
this.__callback.push(e instanceof nn ? e : nn.toObject(e));
|
|
1672
1672
|
}
|
|
1673
1673
|
static toObject(t) {
|
|
1674
|
-
if (!t.condition) throw new
|
|
1675
|
-
if (!t.callback) throw new
|
|
1674
|
+
if (!t.condition) throw new F("Rule::toObject() - Incorrect rule format! There is no condition field.");
|
|
1675
|
+
if (!t.callback) throw new F("Rule::toObject() - Incorrect rule format! There is no callback field.");
|
|
1676
1676
|
let n = new e({});
|
|
1677
1677
|
for (let e of t.condition) n.comparison = e;
|
|
1678
1678
|
for (let e of t.callback) n.callback = e;
|
|
@@ -1684,7 +1684,7 @@ var Ft = {
|
|
|
1684
1684
|
callback: this.__callback
|
|
1685
1685
|
};
|
|
1686
1686
|
}
|
|
1687
|
-
},
|
|
1687
|
+
}, R = class {
|
|
1688
1688
|
static __init(e, t) {
|
|
1689
1689
|
this.arr = String(t).split("."), this.key = this.arr.shift();
|
|
1690
1690
|
let n = Number(this.key);
|
|
@@ -1708,11 +1708,11 @@ var Ft = {
|
|
|
1708
1708
|
let o = r[a], s = Number(o);
|
|
1709
1709
|
return i[Number.isInteger(s) ? s : o] = n, e;
|
|
1710
1710
|
}
|
|
1711
|
-
},
|
|
1711
|
+
}, on = class t {
|
|
1712
1712
|
constructor(e) {
|
|
1713
|
-
if (e.molecularHash === null) throw new
|
|
1713
|
+
if (e.molecularHash === null) throw new Wt();
|
|
1714
1714
|
if (!e.atoms.length) throw new w();
|
|
1715
|
-
for (let t of e.atoms) if (t.index === null) throw new
|
|
1715
|
+
for (let t of e.atoms) if (t.index === null) throw new Ht();
|
|
1716
1716
|
this.molecule = e;
|
|
1717
1717
|
}
|
|
1718
1718
|
verify(e) {
|
|
@@ -1727,40 +1727,40 @@ var Ft = {
|
|
|
1727
1727
|
let e = this.molecule.atoms[0];
|
|
1728
1728
|
if (e.isotope === "V" && e.batchId !== null) {
|
|
1729
1729
|
let t = this.molecule.getIsotopes("V"), n = t[t.length - 1];
|
|
1730
|
-
if (e.batchId !== n.batchId) throw new
|
|
1731
|
-
for (let e of t) if (e.batchId === null) throw new
|
|
1730
|
+
if (e.batchId !== n.batchId) throw new $t();
|
|
1731
|
+
for (let e of t) if (e.batchId === null) throw new $t();
|
|
1732
1732
|
}
|
|
1733
1733
|
return !0;
|
|
1734
1734
|
}
|
|
1735
|
-
throw new
|
|
1735
|
+
throw new $t();
|
|
1736
1736
|
}
|
|
1737
1737
|
isotopeI() {
|
|
1738
1738
|
for (let e of this.molecule.getIsotopes("I")) {
|
|
1739
|
-
if (e.token !== "USER") throw new
|
|
1740
|
-
if (e.index === 0) throw new
|
|
1739
|
+
if (e.token !== "USER") throw new I(`Check::isotopeI() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);
|
|
1740
|
+
if (e.index === 0) throw new Ht(`Check::isotopeI() - Isotope "${e.isotope}" Atoms must have a non-zero index!`);
|
|
1741
1741
|
}
|
|
1742
1742
|
return !0;
|
|
1743
1743
|
}
|
|
1744
1744
|
isotopeU() {
|
|
1745
1745
|
for (let e of this.molecule.getIsotopes("U")) {
|
|
1746
|
-
if (e.token !== "AUTH") throw new
|
|
1747
|
-
if (e.index !== 0) throw new
|
|
1746
|
+
if (e.token !== "AUTH") throw new I(`Check::isotopeU() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);
|
|
1747
|
+
if (e.index !== 0) throw new Ht(`Check::isotopeU() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`);
|
|
1748
1748
|
}
|
|
1749
1749
|
return !0;
|
|
1750
1750
|
}
|
|
1751
1751
|
isotopeM() {
|
|
1752
1752
|
let e = ["readPolicy", "writePolicy"];
|
|
1753
1753
|
for (let t of this.molecule.getIsotopes("M")) {
|
|
1754
|
-
if (t.meta.length < 1) throw new
|
|
1755
|
-
if (t.token !== "USER") throw new
|
|
1754
|
+
if (t.meta.length < 1) throw new F();
|
|
1755
|
+
if (t.token !== "USER") throw new I(`Check::isotopeM() - "${t.token}" is not a valid Token slug for "${t.isotope}" isotope Atoms!`);
|
|
1756
1756
|
let n = b.aggregateMeta(t.meta);
|
|
1757
1757
|
for (let t of e) {
|
|
1758
1758
|
let r = n[t];
|
|
1759
1759
|
if (r) {
|
|
1760
1760
|
r = JSON.parse(r);
|
|
1761
1761
|
for (let [t, i] of Object.entries(r)) if (!e.includes(t)) {
|
|
1762
|
-
if (!Object.keys(n).includes(t)) throw new
|
|
1763
|
-
for (let e of i) if (!
|
|
1762
|
+
if (!Object.keys(n).includes(t)) throw new Gt(`${t} is missing from the meta.`);
|
|
1763
|
+
for (let e of i) if (!N.isBundleHash(e) && !["all", "self"].includes(e)) throw new Gt(`${e} does not correspond to the format of the policy.`);
|
|
1764
1764
|
}
|
|
1765
1765
|
}
|
|
1766
1766
|
}
|
|
@@ -1769,8 +1769,8 @@ var Ft = {
|
|
|
1769
1769
|
}
|
|
1770
1770
|
isotopeC() {
|
|
1771
1771
|
for (let e of this.molecule.getIsotopes("C")) {
|
|
1772
|
-
if (e.token !== "USER") throw new
|
|
1773
|
-
if (e.index !== 0) throw new
|
|
1772
|
+
if (e.token !== "USER") throw new I(`Check::isotopeC() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);
|
|
1773
|
+
if (e.index !== 0) throw new Ht(`Check::isotopeC() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`);
|
|
1774
1774
|
}
|
|
1775
1775
|
return !0;
|
|
1776
1776
|
}
|
|
@@ -1778,11 +1778,11 @@ var Ft = {
|
|
|
1778
1778
|
for (let e of this.molecule.getIsotopes("T")) {
|
|
1779
1779
|
let t = e.aggregatedMeta();
|
|
1780
1780
|
if (String(e.metaType).toLowerCase() === "wallet") {
|
|
1781
|
-
for (let e of ["position", "bundle"]) if (!Object.prototype.hasOwnProperty.call(t, e) || !t[e]) throw new
|
|
1781
|
+
for (let e of ["position", "bundle"]) if (!Object.prototype.hasOwnProperty.call(t, e) || !t[e]) throw new F(`Check::isotopeT() - Required meta field "${e}" is missing!`);
|
|
1782
1782
|
}
|
|
1783
|
-
for (let e of ["token"]) if (!Object.prototype.hasOwnProperty.call(t, e) || !t[e]) throw new
|
|
1784
|
-
if (e.token !== "USER") throw new
|
|
1785
|
-
if (e.index !== 0) throw new
|
|
1783
|
+
for (let e of ["token"]) if (!Object.prototype.hasOwnProperty.call(t, e) || !t[e]) throw new F(`Check::isotopeT() - Required meta field "${e}" is missing!`);
|
|
1784
|
+
if (e.token !== "USER") throw new I(`Check::isotopeT() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);
|
|
1785
|
+
if (e.index !== 0) throw new Ht(`Check::isotopeT() - Isotope "${e.isotope}" Atoms must have an index equal to 0!`);
|
|
1786
1786
|
}
|
|
1787
1787
|
return !0;
|
|
1788
1788
|
}
|
|
@@ -1791,32 +1791,32 @@ var Ft = {
|
|
|
1791
1791
|
let t = e.aggregatedMeta();
|
|
1792
1792
|
if (t.policy) {
|
|
1793
1793
|
let e = JSON.parse(t.policy);
|
|
1794
|
-
if (!Object.keys(e).every((e) => ["read", "write"].includes(e))) throw new
|
|
1794
|
+
if (!Object.keys(e).every((e) => ["read", "write"].includes(e))) throw new F("Check::isotopeR() - Mixing rules with politics!");
|
|
1795
1795
|
}
|
|
1796
1796
|
if (t.rule) {
|
|
1797
1797
|
let e = JSON.parse(t.rule);
|
|
1798
|
-
if (!Array.isArray(e)) throw new
|
|
1799
|
-
for (let t of e)
|
|
1800
|
-
if (e.length < 1) throw new
|
|
1798
|
+
if (!Array.isArray(e)) throw new F("Check::isotopeR() - Incorrect rule format!");
|
|
1799
|
+
for (let t of e) an.toObject(t);
|
|
1800
|
+
if (e.length < 1) throw new F("Check::isotopeR() - No rules!");
|
|
1801
1801
|
}
|
|
1802
1802
|
}
|
|
1803
1803
|
return !0;
|
|
1804
1804
|
}
|
|
1805
1805
|
isotopeP() {
|
|
1806
1806
|
for (let e of this.molecule.getIsotopes("P")) {
|
|
1807
|
-
if (e.token !== "USER") throw new
|
|
1807
|
+
if (e.token !== "USER") throw new I(`Check::isotopeP() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);
|
|
1808
1808
|
let t = e.aggregatedMeta();
|
|
1809
|
-
if (!Object.prototype.hasOwnProperty.call(t, "peerHost") || !t.peerHost) throw new
|
|
1809
|
+
if (!Object.prototype.hasOwnProperty.call(t, "peerHost") || !t.peerHost) throw new F("Check::isotopeP() - Required meta field \"peerHost\" is missing!");
|
|
1810
1810
|
}
|
|
1811
1811
|
return !0;
|
|
1812
1812
|
}
|
|
1813
1813
|
isotopeA() {
|
|
1814
1814
|
for (let e of this.molecule.getIsotopes("A")) {
|
|
1815
|
-
if (e.token !== "USER") throw new
|
|
1816
|
-
if (!e.metaType) throw new
|
|
1817
|
-
if (!e.metaId) throw new
|
|
1815
|
+
if (e.token !== "USER") throw new I(`Check::isotopeA() - "${e.token}" is not a valid Token slug for "${e.isotope}" isotope Atoms!`);
|
|
1816
|
+
if (!e.metaType) throw new F("Check::isotopeA() - Required field \"metaType\" is missing!");
|
|
1817
|
+
if (!e.metaId) throw new F("Check::isotopeA() - Required field \"metaId\" is missing!");
|
|
1818
1818
|
let t = e.aggregatedMeta();
|
|
1819
|
-
if (!Object.prototype.hasOwnProperty.call(t, "action") || !t.action) throw new
|
|
1819
|
+
if (!Object.prototype.hasOwnProperty.call(t, "action") || !t.action) throw new F("Check::isotopeA() - Required meta field \"action\" is missing!");
|
|
1820
1820
|
}
|
|
1821
1821
|
return !0;
|
|
1822
1822
|
}
|
|
@@ -1824,10 +1824,10 @@ var Ft = {
|
|
|
1824
1824
|
let e = this.molecule.getIsotopes("B");
|
|
1825
1825
|
if (e.length === 0) return !0;
|
|
1826
1826
|
for (let t of e) {
|
|
1827
|
-
if (!t.metaType || t.metaType !== "walletBundle") throw new
|
|
1828
|
-
if (!t.metaId) throw new
|
|
1827
|
+
if (!t.metaType || t.metaType !== "walletBundle") throw new F("Check::isotopeB() - B-isotope atoms must have metaType \"walletBundle\"!");
|
|
1828
|
+
if (!t.metaId) throw new F("Check::isotopeB() - B-isotope atoms must have a metaId!");
|
|
1829
1829
|
let e = Number(t.value);
|
|
1830
|
-
if (Number.isNaN(e)) throw new
|
|
1830
|
+
if (Number.isNaN(e)) throw new Jt("Check::isotopeB() - B-isotope atom value is not a valid number!");
|
|
1831
1831
|
}
|
|
1832
1832
|
let t = this.molecule.getIsotopes("V");
|
|
1833
1833
|
if (t.length > 0) {
|
|
@@ -1836,7 +1836,7 @@ var Ft = {
|
|
|
1836
1836
|
let e = Number(r.value);
|
|
1837
1837
|
Number.isNaN(e) || (n += e);
|
|
1838
1838
|
}
|
|
1839
|
-
if (n !== 0) throw new
|
|
1839
|
+
if (n !== 0) throw new Qt("Check::isotopeB() - V+B atom values do not balance to zero!");
|
|
1840
1840
|
}
|
|
1841
1841
|
return !0;
|
|
1842
1842
|
}
|
|
@@ -1844,11 +1844,11 @@ var Ft = {
|
|
|
1844
1844
|
let e = this.molecule.getIsotopes("F");
|
|
1845
1845
|
if (e.length === 0) return !0;
|
|
1846
1846
|
for (let t of e) {
|
|
1847
|
-
if (!t.metaType || t.metaType !== "walletBundle") throw new
|
|
1848
|
-
if (!t.metaId) throw new
|
|
1847
|
+
if (!t.metaType || t.metaType !== "walletBundle") throw new F("Check::isotopeF() - F-isotope atoms must have metaType \"walletBundle\"!");
|
|
1848
|
+
if (!t.metaId) throw new F("Check::isotopeF() - F-isotope atoms must have a metaId!");
|
|
1849
1849
|
let e = Number(t.value);
|
|
1850
|
-
if (Number.isNaN(e)) throw new
|
|
1851
|
-
if (e < 0) throw new
|
|
1850
|
+
if (Number.isNaN(e)) throw new Jt("Check::isotopeF() - F-isotope atom value is not a valid number!");
|
|
1851
|
+
if (e < 0) throw new Jt("Check::isotopeF() - F-isotope atom value must not be negative!");
|
|
1852
1852
|
}
|
|
1853
1853
|
let t = this.molecule.getIsotopes("V");
|
|
1854
1854
|
if (t.length > 0) {
|
|
@@ -1857,7 +1857,7 @@ var Ft = {
|
|
|
1857
1857
|
let e = Number(r.value);
|
|
1858
1858
|
Number.isNaN(e) || (n += e);
|
|
1859
1859
|
}
|
|
1860
|
-
if (n !== 0) throw new
|
|
1860
|
+
if (n !== 0) throw new Qt("Check::isotopeF() - V+F atom values do not balance to zero!");
|
|
1861
1861
|
}
|
|
1862
1862
|
return !0;
|
|
1863
1863
|
}
|
|
@@ -1867,9 +1867,9 @@ var Ft = {
|
|
|
1867
1867
|
let n = this.molecule.getIsotopes("B").length > 0 || this.molecule.getIsotopes("F").length > 0, r = this.molecule.atoms[0];
|
|
1868
1868
|
if (!n && r.isotope === "V" && t.length === 2) {
|
|
1869
1869
|
let e = t[t.length - 1];
|
|
1870
|
-
if (r.token !== e.token) throw new
|
|
1871
|
-
if (e.value < 0) throw new
|
|
1872
|
-
if (Number(r.value) + Number(e.value) !== 0) throw new
|
|
1870
|
+
if (r.token !== e.token) throw new Yt();
|
|
1871
|
+
if (e.value < 0) throw new Jt();
|
|
1872
|
+
if (Number(r.value) + Number(e.value) !== 0) throw new Qt();
|
|
1873
1873
|
return !0;
|
|
1874
1874
|
}
|
|
1875
1875
|
let i = 0, a = 0;
|
|
@@ -1877,29 +1877,29 @@ var Ft = {
|
|
|
1877
1877
|
let t = this.molecule.atoms[e];
|
|
1878
1878
|
if (t.isotope !== "V") continue;
|
|
1879
1879
|
if (a = t.value * 1, Number.isNaN(a)) throw TypeError("Invalid isotope \"V\" values");
|
|
1880
|
-
if (t.token !== r.token) throw new
|
|
1880
|
+
if (t.token !== r.token) throw new Yt();
|
|
1881
1881
|
if (e > 0) {
|
|
1882
|
-
if (a < 0) throw new
|
|
1883
|
-
if (t.walletAddress === r.walletAddress) throw new
|
|
1882
|
+
if (a < 0) throw new Jt();
|
|
1883
|
+
if (t.walletAddress === r.walletAddress) throw new Zt();
|
|
1884
1884
|
}
|
|
1885
1885
|
i += a;
|
|
1886
1886
|
}
|
|
1887
|
-
if (!n && i !== 0) throw new
|
|
1887
|
+
if (!n && i !== 0) throw new Qt();
|
|
1888
1888
|
if (e) {
|
|
1889
1889
|
if (a = r.value * 1, Number.isNaN(a)) throw TypeError("Invalid isotope \"V\" values");
|
|
1890
1890
|
let t = Number(e.balance) + a;
|
|
1891
|
-
if (t < 0) throw new
|
|
1892
|
-
if (!n && t !== i) throw new
|
|
1893
|
-
} else if (a !== 0) throw new
|
|
1891
|
+
if (t < 0) throw new P();
|
|
1892
|
+
if (!n && t !== i) throw new Xt();
|
|
1893
|
+
} else if (a !== 0) throw new Xt();
|
|
1894
1894
|
return !0;
|
|
1895
1895
|
}
|
|
1896
1896
|
molecularHash() {
|
|
1897
|
-
if (this.molecule.molecularHash !== T.hashAtoms({ atoms: this.molecule.atoms })) throw new
|
|
1897
|
+
if (this.molecule.molecularHash !== T.hashAtoms({ atoms: this.molecule.atoms })) throw new Ut();
|
|
1898
1898
|
return !0;
|
|
1899
1899
|
}
|
|
1900
1900
|
ots() {
|
|
1901
1901
|
let t = this.molecule.normalizedHash(), n = this.molecule.atoms.map((e) => e.otsFragment).reduce((e, t) => e + t);
|
|
1902
|
-
if (n.length !== 2048 && (n = _(n), n.length !== 2048)) throw new
|
|
1902
|
+
if (n.length !== 2048 && (n = _(n), n.length !== 2048)) throw new Kt();
|
|
1903
1903
|
let r = d(n, 128), i = "";
|
|
1904
1904
|
for (let n in r) {
|
|
1905
1905
|
let a = r[n];
|
|
@@ -1910,8 +1910,8 @@ var Ft = {
|
|
|
1910
1910
|
a.update(i);
|
|
1911
1911
|
let o = a.getHash("HEX", { outputLen: 8192 }), s = new e("SHAKE256", "TEXT");
|
|
1912
1912
|
s.update(o);
|
|
1913
|
-
let c = s.getHash("HEX", { outputLen: 256 }), l = this.molecule.atoms[0], u = l.walletAddress, f =
|
|
1914
|
-
if (f && (u =
|
|
1913
|
+
let c = s.getHash("HEX", { outputLen: 256 }), l = this.molecule.atoms[0], u = l.walletAddress, f = R.get(l.aggregatedMeta(), "signingWallet");
|
|
1914
|
+
if (f && (u = R.get(JSON.parse(f), "address")), c !== u) throw new qt();
|
|
1915
1915
|
return !0;
|
|
1916
1916
|
}
|
|
1917
1917
|
static fromServerData({ molecularHash: e, bundleHash: t, cellSlug: n = null, status: r = null, createdAt: i = null, atoms: a = [] }) {
|
|
@@ -1941,7 +1941,7 @@ var Ft = {
|
|
|
1941
1941
|
createdAt: e.createdAt || null
|
|
1942
1942
|
};
|
|
1943
1943
|
});
|
|
1944
|
-
return
|
|
1944
|
+
return ln.fromJSON({
|
|
1945
1945
|
molecularHash: e,
|
|
1946
1946
|
bundle: t,
|
|
1947
1947
|
cellSlug: n,
|
|
@@ -1966,17 +1966,17 @@ var Ft = {
|
|
|
1966
1966
|
};
|
|
1967
1967
|
}
|
|
1968
1968
|
}
|
|
1969
|
-
},
|
|
1969
|
+
}, sn = class extends C {
|
|
1970
1970
|
constructor(e = "Insufficient balance for requested transfer", t = null, n = null) {
|
|
1971
1971
|
super(e, t, n), this.name = "BalanceInsufficientException";
|
|
1972
1972
|
}
|
|
1973
|
-
},
|
|
1973
|
+
}, cn = class extends C {
|
|
1974
1974
|
constructor(e = "Amount cannot be negative!", t = null, n = null) {
|
|
1975
1975
|
super(e, t, n), this.name = "NegativeAmountException";
|
|
1976
1976
|
}
|
|
1977
|
-
},
|
|
1977
|
+
}, ln = class t {
|
|
1978
1978
|
constructor({ secret: e = null, bundle: t = null, sourceWallet: n = null, remainderWallet: r = null, cellSlug: i = null, version: a = null, continuIdPosition: o = null, mlKemParameterSet: s = null }) {
|
|
1979
|
-
this.mlKemParameterSet = s || n && n.mlKemParameterSet || 1024, this.status = null, this.molecularHash = null, this.createdAt = String(+/* @__PURE__ */ new Date()), this.cellSlugOrigin = this.cellSlug = i, this.secret = e, this.bundle = t, this.sourceWallet = n, this.continuIdPosition = o, this.atoms = [], this.parentHashes = [], a !== null && Object.prototype.hasOwnProperty.call(ae, a) && (this.version = String(a)), (r || n) && (this.remainderWallet = r ||
|
|
1979
|
+
this.mlKemParameterSet = s || n && n.mlKemParameterSet || 1024, this.status = null, this.molecularHash = null, this.createdAt = String(+/* @__PURE__ */ new Date()), this.cellSlugOrigin = this.cellSlug = i, this.secret = e, this.bundle = t, this.sourceWallet = n, this.continuIdPosition = o, this.atoms = [], this.parentHashes = [], a !== null && Object.prototype.hasOwnProperty.call(ae, a) && (this.version = String(a)), (r || n) && (this.remainderWallet = r || N.create({
|
|
1980
1980
|
secret: e,
|
|
1981
1981
|
bundle: t,
|
|
1982
1982
|
token: n.token,
|
|
@@ -2055,7 +2055,7 @@ var Ft = {
|
|
|
2055
2055
|
return this.molecularHash = null, e.index = this.generateIndex(), e.version = this.version, this.atoms.push(e), this.atoms = T.sortAtoms(this.atoms), this;
|
|
2056
2056
|
}
|
|
2057
2057
|
addContinuIdAtom() {
|
|
2058
|
-
(!this.remainderWallet || this.remainderWallet.token !== "USER") && (this.remainderWallet =
|
|
2058
|
+
(!this.remainderWallet || this.remainderWallet.token !== "USER") && (this.remainderWallet = N.create({
|
|
2059
2059
|
secret: this.secret,
|
|
2060
2060
|
bundle: this.bundle,
|
|
2061
2061
|
mlKemParameterSet: this.mlKemParameterSet
|
|
@@ -2081,7 +2081,7 @@ var Ft = {
|
|
|
2081
2081
|
}
|
|
2082
2082
|
fuseToken(e, t) {
|
|
2083
2083
|
let n = e.length;
|
|
2084
|
-
if (this.sourceWallet.balance - n < 0) throw new
|
|
2084
|
+
if (this.sourceWallet.balance - n < 0) throw new sn();
|
|
2085
2085
|
return this.addAtom(T.create({
|
|
2086
2086
|
isotope: "V",
|
|
2087
2087
|
wallet: this.sourceWallet,
|
|
@@ -2101,9 +2101,9 @@ var Ft = {
|
|
|
2101
2101
|
})), this;
|
|
2102
2102
|
}
|
|
2103
2103
|
burnToken({ amount: e, walletBundle: t = null }) {
|
|
2104
|
-
if (e < 0) throw new
|
|
2105
|
-
if (this.sourceWallet.balance - e < 0) throw new
|
|
2106
|
-
let n = new
|
|
2104
|
+
if (e < 0) throw new cn("Molecule::burnToken() - Amount to burn must be positive!");
|
|
2105
|
+
if (this.sourceWallet.balance - e < 0) throw new sn();
|
|
2106
|
+
let n = new N({
|
|
2107
2107
|
bundle: "0000000000000000000000000000000000000000000000000000000000000000",
|
|
2108
2108
|
token: this.sourceWallet.token,
|
|
2109
2109
|
mlKemParameterSet: this.mlKemParameterSet
|
|
@@ -2127,9 +2127,9 @@ var Ft = {
|
|
|
2127
2127
|
})), this;
|
|
2128
2128
|
}
|
|
2129
2129
|
replenishToken({ amount: e, units: t = [] }) {
|
|
2130
|
-
if (e < 0) throw new
|
|
2130
|
+
if (e < 0) throw new cn("Molecule::replenishToken() - Amount to replenish must be positive!");
|
|
2131
2131
|
if (t.length) {
|
|
2132
|
-
t =
|
|
2132
|
+
t = N.getTokenUnits(t), this.remainderWallet.tokenUnits = this.sourceWallet.tokenUnits;
|
|
2133
2133
|
for (let e of t) this.remainderWallet.tokenUnits.push(e);
|
|
2134
2134
|
this.remainderWallet.balance = String(this.remainderWallet.tokenUnits.length), this.sourceWallet.tokenUnits = t, this.sourceWallet.balance = String(this.sourceWallet.tokenUnits.length);
|
|
2135
2135
|
} else this.remainderWallet.balance = String(Number(this.sourceWallet.balance) + e), this.sourceWallet.balance = String(e);
|
|
@@ -2146,7 +2146,7 @@ var Ft = {
|
|
|
2146
2146
|
})), this;
|
|
2147
2147
|
}
|
|
2148
2148
|
initValue({ recipientWallet: e, amount: t }) {
|
|
2149
|
-
if (this.sourceWallet.balance - t < 0) throw new
|
|
2149
|
+
if (this.sourceWallet.balance - t < 0) throw new sn();
|
|
2150
2150
|
return this.addAtom(T.create({
|
|
2151
2151
|
isotope: "V",
|
|
2152
2152
|
wallet: this.sourceWallet,
|
|
@@ -2167,7 +2167,7 @@ var Ft = {
|
|
|
2167
2167
|
}
|
|
2168
2168
|
initValues({ recipientWallets: e, amounts: t }) {
|
|
2169
2169
|
let n = t.reduce((e, t) => e + Number(t), 0);
|
|
2170
|
-
if (this.sourceWallet.balance - n < 0) throw new
|
|
2170
|
+
if (this.sourceWallet.balance - n < 0) throw new sn();
|
|
2171
2171
|
return this.addAtom(T.create({
|
|
2172
2172
|
isotope: "V",
|
|
2173
2173
|
wallet: this.sourceWallet,
|
|
@@ -2189,8 +2189,8 @@ var Ft = {
|
|
|
2189
2189
|
})), this;
|
|
2190
2190
|
}
|
|
2191
2191
|
initDepositBuffer({ amount: e, tradeRates: t }) {
|
|
2192
|
-
if (this.sourceWallet.balance - e < 0) throw new
|
|
2193
|
-
let n =
|
|
2192
|
+
if (this.sourceWallet.balance - e < 0) throw new sn();
|
|
2193
|
+
let n = N.create({
|
|
2194
2194
|
secret: this.secret,
|
|
2195
2195
|
bundle: this.bundle,
|
|
2196
2196
|
token: this.sourceWallet.token,
|
|
@@ -2218,7 +2218,7 @@ var Ft = {
|
|
|
2218
2218
|
initWithdrawBuffer({ recipients: e, signingWallet: t = null }) {
|
|
2219
2219
|
let n = 0;
|
|
2220
2220
|
for (let t of Object.values(e || {})) n += t;
|
|
2221
|
-
if (this.sourceWallet.balance - n < 0) throw new
|
|
2221
|
+
if (this.sourceWallet.balance - n < 0) throw new sn();
|
|
2222
2222
|
let r = new S();
|
|
2223
2223
|
t && r.setSigningWallet(t), this.addAtom(T.create({
|
|
2224
2224
|
isotope: "B",
|
|
@@ -2232,7 +2232,7 @@ var Ft = {
|
|
|
2232
2232
|
isotope: "V",
|
|
2233
2233
|
token: this.sourceWallet.token,
|
|
2234
2234
|
value: n,
|
|
2235
|
-
batchId: this.sourceWallet.batchId ?
|
|
2235
|
+
batchId: this.sourceWallet.batchId ? le({}) : null,
|
|
2236
2236
|
metaType: "walletBundle",
|
|
2237
2237
|
metaId: t
|
|
2238
2238
|
}));
|
|
@@ -2258,7 +2258,7 @@ var Ft = {
|
|
|
2258
2258
|
}
|
|
2259
2259
|
createRule({ metaType: e, metaId: t, rule: n, policy: r = {} }) {
|
|
2260
2260
|
let i = [];
|
|
2261
|
-
for (let e of n) i.push(e instanceof
|
|
2261
|
+
for (let e of n) i.push(e instanceof an ? e : an.toObject(e));
|
|
2262
2262
|
let a = new S({ rule: JSON.stringify(i) });
|
|
2263
2263
|
return a.addPolicy(r), this.addAtom(T.create({
|
|
2264
2264
|
isotope: "R",
|
|
@@ -2287,7 +2287,7 @@ var Ft = {
|
|
|
2287
2287
|
initIdentifierCreation({ type: e, contact: t, code: n }) {
|
|
2288
2288
|
let r = {
|
|
2289
2289
|
code: n,
|
|
2290
|
-
hash:
|
|
2290
|
+
hash: se(t.trim(), "Molecule::initIdentifierCreation")
|
|
2291
2291
|
};
|
|
2292
2292
|
return this.addAtom(T.create({
|
|
2293
2293
|
isotope: "C",
|
|
@@ -2352,10 +2352,10 @@ var Ft = {
|
|
|
2352
2352
|
}
|
|
2353
2353
|
sign({ bundle: t = null, anonymous: n = !1, compressed: r = !0 } = {}) {
|
|
2354
2354
|
if (this.atoms.length === 0 || this.atoms.filter((e) => !(e instanceof T)).length !== 0) throw new w();
|
|
2355
|
-
!n && !this.bundle && (this.bundle = t ||
|
|
2356
|
-
let i = this.atoms[0], a = i.position, o =
|
|
2357
|
-
if (o && (a =
|
|
2358
|
-
let s = d(
|
|
2355
|
+
!n && !this.bundle && (this.bundle = t || se(this.secret, "Molecule::sign")), this.molecularHash = T.hashAtoms({ atoms: this.atoms });
|
|
2356
|
+
let i = this.atoms[0], a = i.position, o = R.get(i.aggregatedMeta(), "signingWallet");
|
|
2357
|
+
if (o && (a = R.get(JSON.parse(o), "position")), !a) throw new Kt("Signing wallet must have a position!");
|
|
2358
|
+
let s = d(N.generateKey({
|
|
2359
2359
|
secret: this.secret,
|
|
2360
2360
|
token: i.token,
|
|
2361
2361
|
position: i.position
|
|
@@ -2433,7 +2433,7 @@ var Ft = {
|
|
|
2433
2433
|
} catch (e) {
|
|
2434
2434
|
throw Error(`Failed to reconstruct atom ${t}: ${e.message}`);
|
|
2435
2435
|
}
|
|
2436
|
-
})), r && (n.sourceWallet && (a.sourceWallet = new
|
|
2436
|
+
})), r && (n.sourceWallet && (a.sourceWallet = new N({
|
|
2437
2437
|
secret: null,
|
|
2438
2438
|
token: n.sourceWallet.token,
|
|
2439
2439
|
position: n.sourceWallet.position,
|
|
@@ -2441,7 +2441,7 @@ var Ft = {
|
|
|
2441
2441
|
batchId: n.sourceWallet.batchId,
|
|
2442
2442
|
characters: n.sourceWallet.characters,
|
|
2443
2443
|
mlKemParameterSet: a.mlKemParameterSet
|
|
2444
|
-
}), a.sourceWallet.balance = String(n.sourceWallet.balance == null ? 0 : n.sourceWallet.balance), a.sourceWallet.address = n.sourceWallet.address, n.sourceWallet.pubkey && (a.sourceWallet.pubkey = n.sourceWallet.pubkey), a.sourceWallet.tokenUnits = n.sourceWallet.tokenUnits || [], a.sourceWallet.tradeRates = n.sourceWallet.tradeRates || {}, a.sourceWallet.molecules = n.sourceWallet.molecules || {}), n.remainderWallet && (a.remainderWallet = new
|
|
2444
|
+
}), a.sourceWallet.balance = String(n.sourceWallet.balance == null ? 0 : n.sourceWallet.balance), a.sourceWallet.address = n.sourceWallet.address, n.sourceWallet.pubkey && (a.sourceWallet.pubkey = n.sourceWallet.pubkey), a.sourceWallet.tokenUnits = n.sourceWallet.tokenUnits || [], a.sourceWallet.tradeRates = n.sourceWallet.tradeRates || {}, a.sourceWallet.molecules = n.sourceWallet.molecules || {}), n.remainderWallet && (a.remainderWallet = new N({
|
|
2445
2445
|
secret: null,
|
|
2446
2446
|
token: n.remainderWallet.token,
|
|
2447
2447
|
position: n.remainderWallet.position,
|
|
@@ -2455,12 +2455,12 @@ var Ft = {
|
|
|
2455
2455
|
}
|
|
2456
2456
|
}
|
|
2457
2457
|
check(e = null) {
|
|
2458
|
-
return new
|
|
2458
|
+
return new on(this).verify(e);
|
|
2459
2459
|
}
|
|
2460
2460
|
normalizedHash() {
|
|
2461
2461
|
return t.normalize(t.enumerate(this.molecularHash));
|
|
2462
2462
|
}
|
|
2463
|
-
},
|
|
2463
|
+
}, un = class e {
|
|
2464
2464
|
constructor({ token: e, expiresAt: t, encrypt: n, pubkey: r }) {
|
|
2465
2465
|
this.$__token = e, this.$__expiresAt = t, this.$__pubkey = r, this.$__encrypt = n;
|
|
2466
2466
|
}
|
|
@@ -2470,10 +2470,10 @@ var Ft = {
|
|
|
2470
2470
|
}
|
|
2471
2471
|
static resolveMlKemParameterSet(e) {
|
|
2472
2472
|
let t = e.wallet && e.wallet.mlKemParameterSet;
|
|
2473
|
-
return t ? Number(t) :
|
|
2473
|
+
return t ? Number(t) : N.mlKemParameterSetFromPubkey(e.pubkey) || 768;
|
|
2474
2474
|
}
|
|
2475
2475
|
static restore(t, n) {
|
|
2476
|
-
let r = new
|
|
2476
|
+
let r = new N({
|
|
2477
2477
|
secret: n,
|
|
2478
2478
|
token: "AUTH",
|
|
2479
2479
|
position: t.wallet.position,
|
|
@@ -2525,7 +2525,7 @@ var Ft = {
|
|
|
2525
2525
|
wallet: this.getWallet()
|
|
2526
2526
|
};
|
|
2527
2527
|
}
|
|
2528
|
-
},
|
|
2528
|
+
}, z = class e extends C {
|
|
2529
2529
|
constructor(e = "Secret storage operation failed", t = null, n = null) {
|
|
2530
2530
|
super(e, t, n), this.name = "SecretStorageException";
|
|
2531
2531
|
}
|
|
@@ -2538,36 +2538,104 @@ var Ft = {
|
|
|
2538
2538
|
static unavailable(t, n = "Hardware or API not accessible") {
|
|
2539
2539
|
return new e(`Secret storage provider '${t}' is unavailable: ${n}`);
|
|
2540
2540
|
}
|
|
2541
|
-
|
|
2542
|
-
|
|
2541
|
+
static validationError(t) {
|
|
2542
|
+
return new e(t);
|
|
2543
|
+
}
|
|
2544
|
+
}, dn = new TextEncoder();
|
|
2545
|
+
function B(e) {
|
|
2543
2546
|
if (e instanceof Uint8Array) e.fill(0);
|
|
2544
2547
|
else if (Array.isArray(e)) for (let t = 0; t < e.length; t++) e[t] = 0;
|
|
2545
2548
|
}
|
|
2546
|
-
async function
|
|
2549
|
+
async function fn(e, t) {
|
|
2547
2550
|
try {
|
|
2548
2551
|
return await t(e);
|
|
2549
2552
|
} finally {
|
|
2550
|
-
|
|
2553
|
+
B(e);
|
|
2551
2554
|
}
|
|
2552
2555
|
}
|
|
2553
|
-
async function
|
|
2554
|
-
let n =
|
|
2556
|
+
async function pn(e, t) {
|
|
2557
|
+
let n = dn.encode(e);
|
|
2555
2558
|
try {
|
|
2556
2559
|
return await t(e);
|
|
2557
2560
|
} finally {
|
|
2558
|
-
|
|
2561
|
+
B(n);
|
|
2559
2562
|
}
|
|
2560
2563
|
}
|
|
2561
|
-
function
|
|
2562
|
-
let n = typeof e == "string" ?
|
|
2564
|
+
function mn(e, t) {
|
|
2565
|
+
let n = typeof e == "string" ? dn.encode(e) : e, r = typeof t == "string" ? dn.encode(t) : t, i = n.length === r.length ? 0 : 1, a = Math.min(n.length, r.length);
|
|
2563
2566
|
for (let e = 0; e < a; e++) i |= (n[e] ?? 0) ^ (r[e] ?? 0);
|
|
2564
|
-
return typeof e == "string" &&
|
|
2567
|
+
return typeof e == "string" && B(n), typeof t == "string" && B(r), i === 0;
|
|
2568
|
+
}
|
|
2569
|
+
//#endregion
|
|
2570
|
+
//#region src/storage/secretEnvelope.js
|
|
2571
|
+
var hn = "AES-GCM", gn = 1e5, _n = "knishio:secret:", V = "knishio:recovery:", vn = 12, yn = 16, bn = new TextEncoder();
|
|
2572
|
+
function H(e) {
|
|
2573
|
+
let t = "", n = e.byteLength;
|
|
2574
|
+
for (let r = 0; r < n; r++) {
|
|
2575
|
+
let n = e[r];
|
|
2576
|
+
n !== void 0 && (t += String.fromCharCode(n));
|
|
2577
|
+
}
|
|
2578
|
+
return btoa(t);
|
|
2579
|
+
}
|
|
2580
|
+
function U(e) {
|
|
2581
|
+
let t = atob(e), n = t.length, r = new Uint8Array(n);
|
|
2582
|
+
for (let e = 0; e < n; e++) r[e] = t.charCodeAt(e);
|
|
2583
|
+
return r;
|
|
2584
|
+
}
|
|
2585
|
+
async function xn(e, t, n = gn) {
|
|
2586
|
+
if (globalThis.crypto === void 0 || globalThis.crypto.subtle === void 0) throw new z("WebCrypto API is not available");
|
|
2587
|
+
let r = bn.encode(e);
|
|
2588
|
+
try {
|
|
2589
|
+
let e = await globalThis.crypto.subtle.importKey("raw", r, "PBKDF2", !1, ["deriveKey"]);
|
|
2590
|
+
return await globalThis.crypto.subtle.deriveKey({
|
|
2591
|
+
name: "PBKDF2",
|
|
2592
|
+
salt: t,
|
|
2593
|
+
iterations: n,
|
|
2594
|
+
hash: "SHA-256"
|
|
2595
|
+
}, e, {
|
|
2596
|
+
name: "AES-GCM",
|
|
2597
|
+
length: 256
|
|
2598
|
+
}, !1, ["encrypt", "decrypt"]);
|
|
2599
|
+
} finally {
|
|
2600
|
+
B(r);
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
async function W(e, t, n) {
|
|
2604
|
+
if (globalThis.crypto === void 0 || globalThis.crypto.subtle === void 0) throw new z("WebCrypto API is not available");
|
|
2605
|
+
let r = new Uint8Array(yn), i = new Uint8Array(vn);
|
|
2606
|
+
globalThis.crypto.getRandomValues(r), globalThis.crypto.getRandomValues(i);
|
|
2607
|
+
let a = await xn(t, r, gn), o = bn.encode(e);
|
|
2608
|
+
try {
|
|
2609
|
+
let e = await globalThis.crypto.subtle.encrypt({
|
|
2610
|
+
name: hn,
|
|
2611
|
+
iv: i
|
|
2612
|
+
}, a, o);
|
|
2613
|
+
return {
|
|
2614
|
+
version: 1,
|
|
2615
|
+
ciphertext: H(new Uint8Array(e)),
|
|
2616
|
+
iv: H(i),
|
|
2617
|
+
salt: H(r),
|
|
2618
|
+
algorithm: hn,
|
|
2619
|
+
iterations: gn,
|
|
2620
|
+
metadata: n
|
|
2621
|
+
};
|
|
2622
|
+
} finally {
|
|
2623
|
+
B(o);
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
async function G(e, t) {
|
|
2627
|
+
if (globalThis.crypto === void 0 || globalThis.crypto.subtle === void 0) throw new z("WebCrypto API is not available");
|
|
2628
|
+
let n = U(e.salt), r = U(e.iv), i = U(e.ciphertext), a = await xn(t, n, e.iterations ?? 1e5), o = await globalThis.crypto.subtle.decrypt({
|
|
2629
|
+
name: hn,
|
|
2630
|
+
iv: r
|
|
2631
|
+
}, a, i);
|
|
2632
|
+
return new Uint8Array(o);
|
|
2565
2633
|
}
|
|
2566
2634
|
//#endregion
|
|
2567
2635
|
//#region src/storage/MemorySecretStorageProvider.js
|
|
2568
|
-
var
|
|
2636
|
+
var Sn = class {
|
|
2569
2637
|
constructor() {
|
|
2570
|
-
this.providerType = "memory", this.secrets = /* @__PURE__ */ new Map();
|
|
2638
|
+
this.providerType = "memory", this.secrets = /* @__PURE__ */ new Map(), this.recoverySecrets = /* @__PURE__ */ new Map();
|
|
2571
2639
|
}
|
|
2572
2640
|
isHardwareBacked() {
|
|
2573
2641
|
return !1;
|
|
@@ -2576,8 +2644,8 @@ var fn = class {
|
|
|
2576
2644
|
return !0;
|
|
2577
2645
|
}
|
|
2578
2646
|
async storeSecret(e, t, n = {}) {
|
|
2579
|
-
if (!e) throw new
|
|
2580
|
-
if (!t) throw new
|
|
2647
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
2648
|
+
if (!t) throw new z("Secret cannot be empty");
|
|
2581
2649
|
let r = {
|
|
2582
2650
|
bundleHash: e,
|
|
2583
2651
|
label: n.label,
|
|
@@ -2585,17 +2653,26 @@ var fn = class {
|
|
|
2585
2653
|
hardwareBacked: !1,
|
|
2586
2654
|
providerType: this.providerType
|
|
2587
2655
|
};
|
|
2588
|
-
this.secrets.set(e, {
|
|
2656
|
+
if (this.secrets.set(e, {
|
|
2589
2657
|
secret: t,
|
|
2590
2658
|
metadata: r
|
|
2591
|
-
})
|
|
2659
|
+
}), n.recoveryPassphrase) {
|
|
2660
|
+
let r = {
|
|
2661
|
+
bundleHash: e,
|
|
2662
|
+
label: n.label,
|
|
2663
|
+
createdAt: Date.now(),
|
|
2664
|
+
hardwareBacked: !1,
|
|
2665
|
+
providerType: "webcrypto-aes-gcm"
|
|
2666
|
+
}, i = await W(t, n.recoveryPassphrase, r);
|
|
2667
|
+
this.recoverySecrets.set(e, JSON.stringify(i));
|
|
2668
|
+
}
|
|
2592
2669
|
}
|
|
2593
2670
|
async retrieveSecret(e) {
|
|
2594
2671
|
let t = this.secrets.get(e);
|
|
2595
2672
|
return t ? t.secret : null;
|
|
2596
2673
|
}
|
|
2597
2674
|
async deleteSecret(e) {
|
|
2598
|
-
return this.secrets.delete(e);
|
|
2675
|
+
return this.recoverySecrets.delete(e), this.secrets.delete(e);
|
|
2599
2676
|
}
|
|
2600
2677
|
async hasSecret(e) {
|
|
2601
2678
|
return this.secrets.has(e);
|
|
@@ -2605,50 +2682,80 @@ var fn = class {
|
|
|
2605
2682
|
}
|
|
2606
2683
|
async withSecret(e, t) {
|
|
2607
2684
|
let n = this.secrets.get(e);
|
|
2608
|
-
if (!n) throw
|
|
2609
|
-
return
|
|
2685
|
+
if (!n) throw z.notFound(e);
|
|
2686
|
+
return pn(n.secret, t);
|
|
2610
2687
|
}
|
|
2611
2688
|
clear() {
|
|
2612
|
-
this.secrets.clear();
|
|
2689
|
+
this.secrets.clear(), this.recoverySecrets.clear();
|
|
2613
2690
|
}
|
|
2614
|
-
|
|
2691
|
+
async recoverSecret(e, t, n = {}) {
|
|
2692
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
2693
|
+
if (!t) throw new z("Recovery passphrase cannot be empty");
|
|
2694
|
+
let r = this.recoverySecrets.get(e);
|
|
2695
|
+
if (!r) throw z.notFound(e);
|
|
2696
|
+
let i;
|
|
2697
|
+
try {
|
|
2698
|
+
i = JSON.parse(r);
|
|
2699
|
+
} catch {
|
|
2700
|
+
throw z.decryptionFailed("Corrupted recovery payload format");
|
|
2701
|
+
}
|
|
2702
|
+
let a;
|
|
2703
|
+
try {
|
|
2704
|
+
a = await G(i, t);
|
|
2705
|
+
} catch (e) {
|
|
2706
|
+
if (e instanceof z) throw e;
|
|
2707
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
2708
|
+
throw z.decryptionFailed(t);
|
|
2709
|
+
}
|
|
2710
|
+
let o;
|
|
2711
|
+
try {
|
|
2712
|
+
o = new TextDecoder().decode(a);
|
|
2713
|
+
} finally {
|
|
2714
|
+
B(a);
|
|
2715
|
+
}
|
|
2716
|
+
await this.storeSecret(e, o, {
|
|
2717
|
+
...n,
|
|
2718
|
+
recoveryPassphrase: t
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
}, Cn = 10 ** 18, wn = class e {
|
|
2615
2722
|
static val(e) {
|
|
2616
|
-
return Math.abs(e *
|
|
2723
|
+
return Math.abs(e * Cn) < 1 ? 0 : e;
|
|
2617
2724
|
}
|
|
2618
2725
|
static cmp(t, n, r = !1) {
|
|
2619
|
-
let i = e.val(t) *
|
|
2726
|
+
let i = e.val(t) * Cn, a = e.val(n) * Cn;
|
|
2620
2727
|
return Math.abs(i - a) < 1 ? 0 : i > a ? 1 : -1;
|
|
2621
2728
|
}
|
|
2622
2729
|
static equal(t, n) {
|
|
2623
2730
|
return e.cmp(t, n) === 0;
|
|
2624
2731
|
}
|
|
2625
|
-
},
|
|
2732
|
+
}, K = class extends C {
|
|
2626
2733
|
constructor(e = "GraphQL did not provide a valid response.", t = null, n = null) {
|
|
2627
2734
|
super(e, t, n), this.name = "InvalidResponseException";
|
|
2628
2735
|
}
|
|
2629
|
-
},
|
|
2736
|
+
}, Tn = class extends C {
|
|
2630
2737
|
constructor(e = "Authorization token missing or invalid.", t = null, n = null) {
|
|
2631
2738
|
super(e, t, n), this.name = "UnauthenticatedException";
|
|
2632
2739
|
}
|
|
2633
|
-
},
|
|
2740
|
+
}, q = class {
|
|
2634
2741
|
constructor({ query: e, json: t, dataKey: n = null }) {
|
|
2635
|
-
if (this.dataKey = n, this.errorKey = "exception", this.$__payload = null, this.$__query = e, this.$__originResponse = t, this.$__response = t, this.$__response === void 0 || this.$__response === null) throw new
|
|
2636
|
-
if (
|
|
2637
|
-
let e =
|
|
2638
|
-
throw String(e).includes("Unauthenticated") ? new
|
|
2742
|
+
if (this.dataKey = n, this.errorKey = "exception", this.$__payload = null, this.$__query = e, this.$__originResponse = t, this.$__response = t, this.$__response === void 0 || this.$__response === null) throw new K();
|
|
2743
|
+
if (R.has(this.$__response, this.errorKey)) {
|
|
2744
|
+
let e = R.get(this.$__response, this.errorKey);
|
|
2745
|
+
throw String(e).includes("Unauthenticated") ? new Tn() : new K();
|
|
2639
2746
|
}
|
|
2640
2747
|
if (this.$__response.errors && Array.isArray(this.$__response.errors) && this.$__response.errors.length > 0) {
|
|
2641
2748
|
let e = this.$__response.errors[0].message || "Unknown GraphQL error";
|
|
2642
|
-
throw e.includes("Unauthenticated") ? new
|
|
2749
|
+
throw e.includes("Unauthenticated") ? new Tn() : new K(`GraphQL Error: ${e}`);
|
|
2643
2750
|
}
|
|
2644
2751
|
this.init();
|
|
2645
2752
|
}
|
|
2646
2753
|
init() {}
|
|
2647
2754
|
data() {
|
|
2648
2755
|
if (!this.dataKey) return this.response();
|
|
2649
|
-
if (!this.response().data) throw new
|
|
2650
|
-
if (!
|
|
2651
|
-
return
|
|
2756
|
+
if (!this.response().data) throw new K("Response has no data field");
|
|
2757
|
+
if (!R.has(this.response(), this.dataKey)) throw new K(`Missing expected field: ${this.dataKey}`);
|
|
2758
|
+
return R.get(this.response(), this.dataKey);
|
|
2652
2759
|
}
|
|
2653
2760
|
response() {
|
|
2654
2761
|
return this.$__response;
|
|
@@ -2726,7 +2833,7 @@ var fn = class {
|
|
|
2726
2833
|
}
|
|
2727
2834
|
return this;
|
|
2728
2835
|
}
|
|
2729
|
-
},
|
|
2836
|
+
}, J = class {
|
|
2730
2837
|
constructor(e, t) {
|
|
2731
2838
|
this.client = e, this.knishIOClient = t, this.$__variables = null, this.$__query = null, this.$__response = null, this.$__request = null;
|
|
2732
2839
|
}
|
|
@@ -2737,14 +2844,14 @@ var fn = class {
|
|
|
2737
2844
|
return this.createResponse(e);
|
|
2738
2845
|
}
|
|
2739
2846
|
createResponse(e) {
|
|
2740
|
-
return new
|
|
2847
|
+
return new q({
|
|
2741
2848
|
query: this,
|
|
2742
2849
|
json: e
|
|
2743
2850
|
});
|
|
2744
2851
|
}
|
|
2745
2852
|
createQuery({ variables: e = null }) {
|
|
2746
|
-
if (this.$__variables = this.compiledVariables(e), !this.uri()) throw new
|
|
2747
|
-
if (this.$__query === null) throw new
|
|
2853
|
+
if (this.$__variables = this.compiledVariables(e), !this.uri()) throw new L("Query::createQuery() - Node URI was not initialized for this client instance!");
|
|
2854
|
+
if (this.$__query === null) throw new L("Query::createQuery() - GraphQL subscription was not initialized!");
|
|
2748
2855
|
return {
|
|
2749
2856
|
query: this.$__query,
|
|
2750
2857
|
variables: this.variables()
|
|
@@ -2763,7 +2870,7 @@ var fn = class {
|
|
|
2763
2870
|
});
|
|
2764
2871
|
return this.$__response = await this.createResponseRaw(e), this.$__response;
|
|
2765
2872
|
} catch (e) {
|
|
2766
|
-
if (e.name === "AbortError") return this.knishIOClient.log("warn", "Query was cancelled"), new
|
|
2873
|
+
if (e.name === "AbortError") return this.knishIOClient.log("warn", "Query was cancelled"), new q({
|
|
2767
2874
|
query: this,
|
|
2768
2875
|
json: {
|
|
2769
2876
|
data: null,
|
|
@@ -2785,7 +2892,7 @@ var fn = class {
|
|
|
2785
2892
|
createQueryContext() {
|
|
2786
2893
|
return {};
|
|
2787
2894
|
}
|
|
2788
|
-
},
|
|
2895
|
+
}, En = class extends q {
|
|
2789
2896
|
constructor({ query: e, json: t }) {
|
|
2790
2897
|
super({
|
|
2791
2898
|
query: e,
|
|
@@ -2795,12 +2902,12 @@ var fn = class {
|
|
|
2795
2902
|
}
|
|
2796
2903
|
payload() {
|
|
2797
2904
|
let e = null, t = this.data();
|
|
2798
|
-
return t && (e = new
|
|
2905
|
+
return t && (e = new N({
|
|
2799
2906
|
secret: null,
|
|
2800
2907
|
token: t.tokenSlug
|
|
2801
2908
|
}), e.address = t.address, e.position = t.position, e.bundle = t.bundleHash, e.batchId = t.batchId, e.characters = t.characters, e.pubkey = t.pubkey, e.balance = String(t.amount == null ? 0 : t.amount)), e;
|
|
2802
2909
|
}
|
|
2803
|
-
},
|
|
2910
|
+
}, Dn = class extends J {
|
|
2804
2911
|
constructor(e, t) {
|
|
2805
2912
|
super(e, t), this.$__query = i`query ($bundle: String!) {
|
|
2806
2913
|
ContinuId(bundle: $bundle) {
|
|
@@ -2820,12 +2927,12 @@ var fn = class {
|
|
|
2820
2927
|
return { requestPolicy: "network-only" };
|
|
2821
2928
|
}
|
|
2822
2929
|
createResponse(e) {
|
|
2823
|
-
return new
|
|
2930
|
+
return new En({
|
|
2824
2931
|
query: this,
|
|
2825
2932
|
json: e
|
|
2826
2933
|
});
|
|
2827
2934
|
}
|
|
2828
|
-
},
|
|
2935
|
+
}, On = class extends q {
|
|
2829
2936
|
constructor({ query: e, json: t }) {
|
|
2830
2937
|
super({
|
|
2831
2938
|
query: e,
|
|
@@ -2841,7 +2948,7 @@ var fn = class {
|
|
|
2841
2948
|
e.metas = b.aggregateMeta(e.metas), t[e.bundleHash] = e;
|
|
2842
2949
|
}), t;
|
|
2843
2950
|
}
|
|
2844
|
-
},
|
|
2951
|
+
}, kn = class extends J {
|
|
2845
2952
|
constructor(e, t) {
|
|
2846
2953
|
super(e, t), this.$__query = i`query( $bundleHashes: [ String! ] ) {
|
|
2847
2954
|
WalletBundle( bundleHashes: $bundleHashes ) {
|
|
@@ -2858,12 +2965,12 @@ var fn = class {
|
|
|
2858
2965
|
}`;
|
|
2859
2966
|
}
|
|
2860
2967
|
createResponse(e) {
|
|
2861
|
-
return new
|
|
2968
|
+
return new On({
|
|
2862
2969
|
query: this,
|
|
2863
2970
|
json: e
|
|
2864
2971
|
});
|
|
2865
2972
|
}
|
|
2866
|
-
},
|
|
2973
|
+
}, An = class e extends q {
|
|
2867
2974
|
constructor({ query: e, json: t }) {
|
|
2868
2975
|
super({
|
|
2869
2976
|
query: e,
|
|
@@ -2873,18 +2980,18 @@ var fn = class {
|
|
|
2873
2980
|
}
|
|
2874
2981
|
static toClientWallet({ data: e, secret: t = null }) {
|
|
2875
2982
|
let n;
|
|
2876
|
-
if (e.position === null || e.position === void 0 ? n =
|
|
2983
|
+
if (e.position === null || e.position === void 0 ? n = N.create({
|
|
2877
2984
|
bundle: e.bundleHash,
|
|
2878
2985
|
token: e.tokenSlug,
|
|
2879
2986
|
batchId: e.batchId,
|
|
2880
2987
|
characters: e.characters
|
|
2881
|
-
}) : (n = new
|
|
2988
|
+
}) : (n = new N({
|
|
2882
2989
|
secret: t,
|
|
2883
2990
|
token: e.tokenSlug,
|
|
2884
2991
|
position: e.position,
|
|
2885
2992
|
batchId: e.batchId,
|
|
2886
2993
|
characters: e.characters
|
|
2887
|
-
}), n.address = e.address, n.bundle = e.bundleHash), e.token && (n.tokenName = e.token.name, n.tokenAmount = e.token.amount, n.tokenSupply = e.token.supply, n.tokenFungibility = e.token.fungibility), e.tokenUnits.length) for (let t of e.tokenUnits) n.tokenUnits.push(
|
|
2994
|
+
}), n.address = e.address, n.bundle = e.bundleHash), e.token && (n.tokenName = e.token.name, n.tokenAmount = e.token.amount, n.tokenSupply = e.token.supply, n.tokenFungibility = e.token.fungibility), e.tokenUnits.length) for (let t of e.tokenUnits) n.tokenUnits.push(ue.createFromGraphQL(t));
|
|
2888
2995
|
if (e.tradeRates.length) for (let t of e.tradeRates) n.tradeRates[t.tokenSlug] = t.amount;
|
|
2889
2996
|
return n.balance = String(e.amount == null ? 0 : e.amount), n.pubkey = e.pubkey, n.createdAt = e.createdAt, n;
|
|
2890
2997
|
}
|
|
@@ -2901,7 +3008,7 @@ var fn = class {
|
|
|
2901
3008
|
payload() {
|
|
2902
3009
|
return this.getWallets();
|
|
2903
3010
|
}
|
|
2904
|
-
},
|
|
3011
|
+
}, jn = class extends J {
|
|
2905
3012
|
constructor(e, t) {
|
|
2906
3013
|
super(e, t), this.$__query = i`query( $bundleHash: String, $token: String ) {
|
|
2907
3014
|
Wallet( bundleHash: $bundleHash, token: $token ) {
|
|
@@ -2933,12 +3040,12 @@ var fn = class {
|
|
|
2933
3040
|
}`;
|
|
2934
3041
|
}
|
|
2935
3042
|
createResponse(e) {
|
|
2936
|
-
return new
|
|
3043
|
+
return new An({
|
|
2937
3044
|
query: this,
|
|
2938
3045
|
json: e
|
|
2939
3046
|
});
|
|
2940
3047
|
}
|
|
2941
|
-
},
|
|
3048
|
+
}, Mn = class extends q {
|
|
2942
3049
|
constructor({ query: e, json: t }) {
|
|
2943
3050
|
super({
|
|
2944
3051
|
query: e,
|
|
@@ -2948,9 +3055,9 @@ var fn = class {
|
|
|
2948
3055
|
}
|
|
2949
3056
|
payload() {
|
|
2950
3057
|
let e = this.data();
|
|
2951
|
-
return Array.isArray(e) && (e = e.length > 0 ? e[0] : null), !e || !e.bundleHash || !e.tokenSlug ? null :
|
|
3058
|
+
return Array.isArray(e) && (e = e.length > 0 ? e[0] : null), !e || !e.bundleHash || !e.tokenSlug ? null : An.toClientWallet({ data: e });
|
|
2952
3059
|
}
|
|
2953
|
-
},
|
|
3060
|
+
}, Nn = class extends J {
|
|
2954
3061
|
constructor(e, t) {
|
|
2955
3062
|
super(e, t), this.$__query = i`query( $address: String, $bundleHash: String, $type: String, $token: String, $position: String ) {
|
|
2956
3063
|
Balance( address: $address, bundleHash: $bundleHash, type: $type, token: $token, position: $position ) {
|
|
@@ -2977,12 +3084,12 @@ var fn = class {
|
|
|
2977
3084
|
}`;
|
|
2978
3085
|
}
|
|
2979
3086
|
createResponse(e) {
|
|
2980
|
-
return new
|
|
3087
|
+
return new Mn({
|
|
2981
3088
|
query: this,
|
|
2982
3089
|
json: e
|
|
2983
3090
|
});
|
|
2984
3091
|
}
|
|
2985
|
-
},
|
|
3092
|
+
}, Pn = class extends q {
|
|
2986
3093
|
constructor({ query: e, json: t }) {
|
|
2987
3094
|
super({
|
|
2988
3095
|
query: e,
|
|
@@ -3000,7 +3107,7 @@ var fn = class {
|
|
|
3000
3107
|
}, n = e.pop();
|
|
3001
3108
|
return n.instances && (t.instances = n.instances), n.instanceCount && (t.instanceCount = n.instanceCount), n.paginatorInfo && (t.paginatorInfo = n.paginatorInfo), t;
|
|
3002
3109
|
}
|
|
3003
|
-
},
|
|
3110
|
+
}, Fn = class extends J {
|
|
3004
3111
|
constructor(e, t) {
|
|
3005
3112
|
super(e, t), this.$__query = i`query( $metaType: String, $metaTypes: [ String! ], $metaId: String, $metaIds: [ String! ], $key: String, $keys: [ String! ], $value: String, $values: [ String! ], $count: String, $latest: Boolean, $filter: [ MetaFilter! ], $queryArgs: QueryArgs, $countBy: String, $cellSlug: String ) {
|
|
3006
3113
|
MetaType( metaType: $metaType, metaTypes: $metaTypes, metaId: $metaId, metaIds: $metaIds, key: $key, keys: $keys, value: $value, values: $values, count: $count, filter: $filter, queryArgs: $queryArgs, countBy: $countBy, cellSlug: $cellSlug ) {
|
|
@@ -3033,12 +3140,12 @@ var fn = class {
|
|
|
3033
3140
|
return e && (u[typeof e == "string" ? "metaType" : "metaTypes"] = e), t && (u[typeof t == "string" ? "metaId" : "metaIds"] = t), n && (u[typeof n == "string" ? "key" : "keys"] = n), r && (u[typeof r == "string" ? "value" : "values"] = r), u.latest = i === !0, a && (u.filter = a), o && ((o.limit === void 0 || o.limit === 0) && (o.limit = "*"), u.queryArgs = o), s && (u.count = s), c && (u.countBy = c), l && (u.cellSlug = l), u;
|
|
3034
3141
|
}
|
|
3035
3142
|
createResponse(e) {
|
|
3036
|
-
return new
|
|
3143
|
+
return new Pn({
|
|
3037
3144
|
query: this,
|
|
3038
3145
|
json: e
|
|
3039
3146
|
});
|
|
3040
3147
|
}
|
|
3041
|
-
},
|
|
3148
|
+
}, In = class e extends J {
|
|
3042
3149
|
constructor(t, n) {
|
|
3043
3150
|
super(t, n), this.$__query = i`query( $batchId: String ) {
|
|
3044
3151
|
Batch( batchId: $batchId ) {
|
|
@@ -3053,28 +3160,28 @@ var fn = class {
|
|
|
3053
3160
|
return "batchId,\n molecularHash,\n type,\n status,\n createdAt,\n wallet {\n address,\n bundleHash,\n amount,\n tokenSlug,\n token {\n name,\n amount\n },\n tokenUnits {\n id,\n name,\n metas\n }\n },\n fromWallet {\n address,\n bundleHash,\n amount,\n batchId\n },\n toWallet {\n address,\n bundleHash,\n amount,\n batchId\n },\n sourceTokenUnits {\n id,\n name,\n metas\n },\n transferTokenUnits {\n id,\n name,\n metas\n },\n metas {\n key,\n value,\n },\n throughMetas {\n key,\n value\n }";
|
|
3054
3161
|
}
|
|
3055
3162
|
createResponse(e) {
|
|
3056
|
-
let t = new
|
|
3163
|
+
let t = new q({
|
|
3057
3164
|
query: this,
|
|
3058
3165
|
json: e
|
|
3059
3166
|
});
|
|
3060
3167
|
return t.dataKey = "data.Batch", t;
|
|
3061
3168
|
}
|
|
3062
|
-
},
|
|
3169
|
+
}, Ln = class extends J {
|
|
3063
3170
|
constructor(e, t) {
|
|
3064
3171
|
super(e, t), this.$__query = i`query( $batchId: String ) {
|
|
3065
3172
|
BatchHistory( batchId: $batchId ) {
|
|
3066
|
-
${
|
|
3173
|
+
${In.getFields()}
|
|
3067
3174
|
}
|
|
3068
3175
|
}`;
|
|
3069
3176
|
}
|
|
3070
3177
|
createResponse(e) {
|
|
3071
|
-
let t = new
|
|
3178
|
+
let t = new q({
|
|
3072
3179
|
query: this,
|
|
3073
3180
|
json: e
|
|
3074
3181
|
});
|
|
3075
3182
|
return t.dataKey = "data.BatchHistory", t;
|
|
3076
3183
|
}
|
|
3077
|
-
},
|
|
3184
|
+
}, Y = class extends q {
|
|
3078
3185
|
constructor({ query: e, json: t }) {
|
|
3079
3186
|
super({
|
|
3080
3187
|
query: e,
|
|
@@ -3083,7 +3190,7 @@ var fn = class {
|
|
|
3083
3190
|
}), this.$__clientMolecule = e.molecule();
|
|
3084
3191
|
}
|
|
3085
3192
|
init() {
|
|
3086
|
-
let e =
|
|
3193
|
+
let e = R.get(this.data(), "payload");
|
|
3087
3194
|
try {
|
|
3088
3195
|
this.$__payload = Object.prototype.toString.call(e) === "[object String]" ? JSON.parse(e) : e;
|
|
3089
3196
|
} catch {
|
|
@@ -3096,22 +3203,22 @@ var fn = class {
|
|
|
3096
3203
|
molecule() {
|
|
3097
3204
|
let e = this.data();
|
|
3098
3205
|
if (!e) return null;
|
|
3099
|
-
let t = new
|
|
3100
|
-
return t.molecularHash =
|
|
3206
|
+
let t = new ln({});
|
|
3207
|
+
return t.molecularHash = R.get(e, "molecularHash"), t.status = R.get(e, "status"), t.createdAt = R.get(e, "createdAt"), t;
|
|
3101
3208
|
}
|
|
3102
3209
|
success() {
|
|
3103
3210
|
return this.status() === "accepted";
|
|
3104
3211
|
}
|
|
3105
3212
|
status() {
|
|
3106
|
-
return
|
|
3213
|
+
return R.get(this.data(), "status", "rejected");
|
|
3107
3214
|
}
|
|
3108
3215
|
reason() {
|
|
3109
|
-
return
|
|
3216
|
+
return R.get(this.data(), "reason", "Invalid response from server");
|
|
3110
3217
|
}
|
|
3111
3218
|
payload() {
|
|
3112
3219
|
return this.$__payload;
|
|
3113
3220
|
}
|
|
3114
|
-
},
|
|
3221
|
+
}, Rn = class extends J {
|
|
3115
3222
|
createQuery({ variables: e = null }) {
|
|
3116
3223
|
let t = super.createQuery({ variables: e });
|
|
3117
3224
|
return t.mutation = t.query, delete t.query, t;
|
|
@@ -3129,7 +3236,7 @@ var fn = class {
|
|
|
3129
3236
|
}, t = await this.client.mutate(e);
|
|
3130
3237
|
return this.$__response = await this.createResponseRaw(t), this.$__response;
|
|
3131
3238
|
} catch (e) {
|
|
3132
|
-
if (e.name === "AbortError") return this.knishIOClient.log("warn", "Mutation was cancelled"), new
|
|
3239
|
+
if (e.name === "AbortError") return this.knishIOClient.log("warn", "Mutation was cancelled"), new q({
|
|
3133
3240
|
query: this,
|
|
3134
3241
|
json: {
|
|
3135
3242
|
data: null,
|
|
@@ -3142,7 +3249,7 @@ var fn = class {
|
|
|
3142
3249
|
createQueryContext() {
|
|
3143
3250
|
return {};
|
|
3144
3251
|
}
|
|
3145
|
-
},
|
|
3252
|
+
}, X = class extends Rn {
|
|
3146
3253
|
constructor(e, t, n) {
|
|
3147
3254
|
super(e, t), this.$__molecule = n, this.$__remainderWallet = null, this.$__query = i`mutation( $molecule: MoleculeInput! ) {
|
|
3148
3255
|
ProposeMolecule( molecule: $molecule ) {
|
|
@@ -3166,7 +3273,7 @@ var fn = class {
|
|
|
3166
3273
|
};
|
|
3167
3274
|
}
|
|
3168
3275
|
createResponse(e) {
|
|
3169
|
-
return new
|
|
3276
|
+
return new Y({
|
|
3170
3277
|
query: this,
|
|
3171
3278
|
json: e
|
|
3172
3279
|
});
|
|
@@ -3180,10 +3287,10 @@ var fn = class {
|
|
|
3180
3287
|
molecule() {
|
|
3181
3288
|
return this.$__molecule;
|
|
3182
3289
|
}
|
|
3183
|
-
},
|
|
3290
|
+
}, zn = class extends Y {
|
|
3184
3291
|
payloadKey(e) {
|
|
3185
|
-
if (!
|
|
3186
|
-
return
|
|
3292
|
+
if (!R.has(this.payload(), e)) throw new K(`ResponseRequestAuthorization::payloadKey() - '${e}' key was not found in the payload!`);
|
|
3293
|
+
return R.get(this.payload(), e);
|
|
3187
3294
|
}
|
|
3188
3295
|
token() {
|
|
3189
3296
|
return this.payloadKey("token");
|
|
@@ -3205,17 +3312,17 @@ var fn = class {
|
|
|
3205
3312
|
pubKey() {
|
|
3206
3313
|
return this.payloadKey("key");
|
|
3207
3314
|
}
|
|
3208
|
-
},
|
|
3315
|
+
}, Bn = class extends X {
|
|
3209
3316
|
fillMolecule({ meta: e }) {
|
|
3210
3317
|
this.$__molecule.initAuthorization({ meta: e }), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3211
3318
|
}
|
|
3212
3319
|
createResponse(e) {
|
|
3213
|
-
return new
|
|
3320
|
+
return new zn({
|
|
3214
3321
|
query: this,
|
|
3215
3322
|
json: e
|
|
3216
3323
|
});
|
|
3217
3324
|
}
|
|
3218
|
-
},
|
|
3325
|
+
}, Vn = class extends Y {}, Hn = class extends X {
|
|
3219
3326
|
fillMolecule({ recipientWallet: e, amount: t, meta: n = null }) {
|
|
3220
3327
|
this.$__molecule.initTokenCreation({
|
|
3221
3328
|
recipientWallet: e,
|
|
@@ -3224,12 +3331,12 @@ var fn = class {
|
|
|
3224
3331
|
}), this.$__molecule.sign({ bundle: e.bundle }), this.$__molecule.check();
|
|
3225
3332
|
}
|
|
3226
3333
|
createResponse(e) {
|
|
3227
|
-
return new
|
|
3334
|
+
return new Vn({
|
|
3228
3335
|
query: this,
|
|
3229
3336
|
json: e
|
|
3230
3337
|
});
|
|
3231
3338
|
}
|
|
3232
|
-
},
|
|
3339
|
+
}, Un = class extends Y {}, Wn = class extends X {
|
|
3233
3340
|
fillMolecule({ token: e, amount: t, metaType: n, metaId: r, meta: i = null, batchId: a = null }) {
|
|
3234
3341
|
this.$__molecule.initTokenRequest({
|
|
3235
3342
|
token: e,
|
|
@@ -3241,12 +3348,12 @@ var fn = class {
|
|
|
3241
3348
|
}), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3242
3349
|
}
|
|
3243
3350
|
createResponse(e) {
|
|
3244
|
-
return new
|
|
3351
|
+
return new Un({
|
|
3245
3352
|
query: this,
|
|
3246
3353
|
json: e
|
|
3247
3354
|
});
|
|
3248
3355
|
}
|
|
3249
|
-
},
|
|
3356
|
+
}, Gn = class extends Y {
|
|
3250
3357
|
payload() {
|
|
3251
3358
|
let e = {
|
|
3252
3359
|
reason: null,
|
|
@@ -3254,7 +3361,7 @@ var fn = class {
|
|
|
3254
3361
|
}, t = this.data();
|
|
3255
3362
|
return e.reason = t.reason === void 0 ? "Invalid response from server" : t.reason, e.status = t.status === void 0 ? "rejected" : t.status, e;
|
|
3256
3363
|
}
|
|
3257
|
-
},
|
|
3364
|
+
}, Kn = class extends X {
|
|
3258
3365
|
fillMolecule({ recipientWallet: e, amount: t }) {
|
|
3259
3366
|
this.$__molecule.initValue({
|
|
3260
3367
|
recipientWallet: e,
|
|
@@ -3268,12 +3375,12 @@ var fn = class {
|
|
|
3268
3375
|
}), this.$__molecule.sign({}), this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
3269
3376
|
}
|
|
3270
3377
|
createResponse(e) {
|
|
3271
|
-
return new
|
|
3378
|
+
return new Gn({
|
|
3272
3379
|
query: this,
|
|
3273
3380
|
json: e
|
|
3274
3381
|
});
|
|
3275
3382
|
}
|
|
3276
|
-
},
|
|
3383
|
+
}, qn = class extends Y {}, Jn = class extends X {
|
|
3277
3384
|
fillMolecule({ type: e, contact: t, code: n }) {
|
|
3278
3385
|
this.$__molecule.initIdentifierCreation({
|
|
3279
3386
|
type: e,
|
|
@@ -3282,14 +3389,14 @@ var fn = class {
|
|
|
3282
3389
|
}), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3283
3390
|
}
|
|
3284
3391
|
createResponse(e) {
|
|
3285
|
-
return new
|
|
3392
|
+
return new qn({
|
|
3286
3393
|
query: this,
|
|
3287
3394
|
json: e
|
|
3288
3395
|
});
|
|
3289
3396
|
}
|
|
3290
|
-
},
|
|
3397
|
+
}, Yn = class extends Y {}, Xn = class extends X {
|
|
3291
3398
|
fillMolecule({ token: e, batchId: t = null }) {
|
|
3292
|
-
let n =
|
|
3399
|
+
let n = N.create({
|
|
3293
3400
|
secret: this.$__molecule.secret,
|
|
3294
3401
|
bundle: this.$__molecule.bundle,
|
|
3295
3402
|
token: e,
|
|
@@ -3298,12 +3405,12 @@ var fn = class {
|
|
|
3298
3405
|
this.$__molecule.initShadowWalletClaim(n), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3299
3406
|
}
|
|
3300
3407
|
createResponse(e) {
|
|
3301
|
-
return new
|
|
3408
|
+
return new Yn({
|
|
3302
3409
|
query: this,
|
|
3303
3410
|
json: e
|
|
3304
3411
|
});
|
|
3305
3412
|
}
|
|
3306
|
-
},
|
|
3413
|
+
}, Zn = class extends Y {}, Qn = class extends X {
|
|
3307
3414
|
fillMolecule({ metaType: e, metaId: t, meta: n, policy: r }) {
|
|
3308
3415
|
this.$__molecule.initMeta({
|
|
3309
3416
|
meta: n,
|
|
@@ -3313,22 +3420,22 @@ var fn = class {
|
|
|
3313
3420
|
}), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3314
3421
|
}
|
|
3315
3422
|
createResponse(e) {
|
|
3316
|
-
return new
|
|
3423
|
+
return new Zn({
|
|
3317
3424
|
query: this,
|
|
3318
3425
|
json: e
|
|
3319
3426
|
});
|
|
3320
3427
|
}
|
|
3321
|
-
},
|
|
3428
|
+
}, $n = class extends Y {}, er = class extends X {
|
|
3322
3429
|
fillMolecule({ host: e }) {
|
|
3323
3430
|
this.$__molecule.initPeering({ host: e }), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3324
3431
|
}
|
|
3325
3432
|
createResponse(e) {
|
|
3326
|
-
return new
|
|
3433
|
+
return new $n({
|
|
3327
3434
|
query: this,
|
|
3328
3435
|
json: e
|
|
3329
3436
|
});
|
|
3330
3437
|
}
|
|
3331
|
-
},
|
|
3438
|
+
}, tr = class extends Y {}, nr = class extends X {
|
|
3332
3439
|
fillMolecule({ metaType: e, metaId: t, action: n, meta: r = {} }) {
|
|
3333
3440
|
this.$__molecule.initAppendRequest({
|
|
3334
3441
|
metaType: e,
|
|
@@ -3338,12 +3445,12 @@ var fn = class {
|
|
|
3338
3445
|
}), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3339
3446
|
}
|
|
3340
3447
|
createResponse(e) {
|
|
3341
|
-
return new
|
|
3448
|
+
return new tr({
|
|
3342
3449
|
query: this,
|
|
3343
3450
|
json: e
|
|
3344
3451
|
});
|
|
3345
3452
|
}
|
|
3346
|
-
},
|
|
3453
|
+
}, rr = class extends q {
|
|
3347
3454
|
constructor({ query: e, json: t }) {
|
|
3348
3455
|
super({
|
|
3349
3456
|
query: e,
|
|
@@ -3352,12 +3459,12 @@ var fn = class {
|
|
|
3352
3459
|
});
|
|
3353
3460
|
}
|
|
3354
3461
|
success() {
|
|
3355
|
-
return
|
|
3462
|
+
return R.get(this.data(), "set");
|
|
3356
3463
|
}
|
|
3357
3464
|
message() {
|
|
3358
|
-
return
|
|
3465
|
+
return R.get(this.data(), "message");
|
|
3359
3466
|
}
|
|
3360
|
-
},
|
|
3467
|
+
}, ir = class extends Rn {
|
|
3361
3468
|
constructor(e, t) {
|
|
3362
3469
|
super(e, t), this.$__query = i`mutation( $bundle: String!, $type: String!, $content: String! ) {
|
|
3363
3470
|
LinkIdentifier( bundle: $bundle, type: $type, content: $content ) {
|
|
@@ -3370,22 +3477,22 @@ var fn = class {
|
|
|
3370
3477
|
}`;
|
|
3371
3478
|
}
|
|
3372
3479
|
createResponse(e) {
|
|
3373
|
-
return new
|
|
3480
|
+
return new rr({
|
|
3374
3481
|
query: this,
|
|
3375
3482
|
json: e
|
|
3376
3483
|
});
|
|
3377
3484
|
}
|
|
3378
|
-
},
|
|
3485
|
+
}, ar = class extends Y {}, or = class extends X {
|
|
3379
3486
|
fillMolecule(e) {
|
|
3380
3487
|
this.$__molecule.initWalletCreation(e), this.$__molecule.sign({}), this.$__molecule.check();
|
|
3381
3488
|
}
|
|
3382
3489
|
createResponse(e) {
|
|
3383
|
-
return new
|
|
3490
|
+
return new ar({
|
|
3384
3491
|
query: this,
|
|
3385
3492
|
json: e
|
|
3386
3493
|
});
|
|
3387
3494
|
}
|
|
3388
|
-
},
|
|
3495
|
+
}, sr = class extends q {
|
|
3389
3496
|
constructor({ query: e, json: t }) {
|
|
3390
3497
|
super({
|
|
3391
3498
|
query: e,
|
|
@@ -3403,8 +3510,8 @@ var fn = class {
|
|
|
3403
3510
|
return this.data();
|
|
3404
3511
|
}
|
|
3405
3512
|
payloadKey(e) {
|
|
3406
|
-
if (!
|
|
3407
|
-
return
|
|
3513
|
+
if (!R.has(this.payload(), e)) throw new K(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);
|
|
3514
|
+
return R.get(this.payload(), e);
|
|
3408
3515
|
}
|
|
3409
3516
|
token() {
|
|
3410
3517
|
return this.payloadKey("token");
|
|
@@ -3426,7 +3533,7 @@ var fn = class {
|
|
|
3426
3533
|
encrypt() {
|
|
3427
3534
|
return this.payloadKey("encrypt");
|
|
3428
3535
|
}
|
|
3429
|
-
},
|
|
3536
|
+
}, cr = class extends Rn {
|
|
3430
3537
|
constructor(e, t) {
|
|
3431
3538
|
super(e, t), this.$__query = i`mutation( $cellSlug: String, $pubkey: String, $encrypt: Boolean ) {
|
|
3432
3539
|
AccessToken( cellSlug: $cellSlug, pubkey: $pubkey, encrypt: $encrypt ) {
|
|
@@ -3437,30 +3544,30 @@ var fn = class {
|
|
|
3437
3544
|
}`;
|
|
3438
3545
|
}
|
|
3439
3546
|
createResponse(e) {
|
|
3440
|
-
return new
|
|
3547
|
+
return new sr({
|
|
3441
3548
|
query: this,
|
|
3442
3549
|
json: e
|
|
3443
3550
|
});
|
|
3444
3551
|
}
|
|
3445
|
-
},
|
|
3552
|
+
}, lr = class extends C {
|
|
3446
3553
|
constructor(e = "The shadow wallet does not exist", t = null, n = null) {
|
|
3447
3554
|
super(e, t, n), this.name = "WalletShadowException";
|
|
3448
3555
|
}
|
|
3449
|
-
},
|
|
3556
|
+
}, ur = class extends C {
|
|
3450
3557
|
constructor(e = "Stackable tokens with unit IDs cannot have decimal places!", t = null, n = null) {
|
|
3451
3558
|
super(e, t, n), this.name = "StackableUnitDecimalsException";
|
|
3452
3559
|
}
|
|
3453
|
-
},
|
|
3560
|
+
}, dr = class extends C {
|
|
3454
3561
|
constructor(e = "Stackable tokens with unit IDs cannot have an amount!", t = null, n = null) {
|
|
3455
3562
|
super(e, t, n), this.name = "StackableUnitAmountException";
|
|
3456
3563
|
}
|
|
3457
|
-
},
|
|
3564
|
+
}, fr = class {
|
|
3458
3565
|
constructor(e) {
|
|
3459
3566
|
this.client = e, this.$__variables = null, this.$__subscribe = null;
|
|
3460
3567
|
}
|
|
3461
3568
|
createSubscribe({ variables: e = null }) {
|
|
3462
|
-
if (this.$__variables = this.compiledVariables(e), !this.uri()) throw new
|
|
3463
|
-
if (this.$__subscribe === null) throw new
|
|
3569
|
+
if (this.$__variables = this.compiledVariables(e), !this.uri()) throw new L("Subscribe::createSubscribe() - Node URI was not initialized for this client instance!");
|
|
3570
|
+
if (this.$__subscribe === null) throw new L("Subscribe::createSubscribe() - GraphQL subscription was not initialized!");
|
|
3464
3571
|
return {
|
|
3465
3572
|
query: this.$__subscribe,
|
|
3466
3573
|
variables: this.variables(),
|
|
@@ -3468,7 +3575,7 @@ var fn = class {
|
|
|
3468
3575
|
};
|
|
3469
3576
|
}
|
|
3470
3577
|
async execute({ variables: e = null, closure: t }) {
|
|
3471
|
-
if (!t) throw new
|
|
3578
|
+
if (!t) throw new L(`${this.constructor.name}::execute() - closure parameter is required!`);
|
|
3472
3579
|
return this.$__request = this.createSubscribe({ variables: e }), this.client.subscribe(this.$__request, t);
|
|
3473
3580
|
}
|
|
3474
3581
|
compiledVariables(e = null) {
|
|
@@ -3480,7 +3587,7 @@ var fn = class {
|
|
|
3480
3587
|
variables() {
|
|
3481
3588
|
return this.$__variables;
|
|
3482
3589
|
}
|
|
3483
|
-
},
|
|
3590
|
+
}, pr = class extends fr {
|
|
3484
3591
|
constructor(e) {
|
|
3485
3592
|
super(e), this.$__subscribe = i`
|
|
3486
3593
|
subscription onCreateMolecule ( $bundle: String! ) {
|
|
@@ -3529,7 +3636,7 @@ var fn = class {
|
|
|
3529
3636
|
}
|
|
3530
3637
|
`;
|
|
3531
3638
|
}
|
|
3532
|
-
},
|
|
3639
|
+
}, mr = class extends fr {
|
|
3533
3640
|
constructor(e) {
|
|
3534
3641
|
super(e), this.$__subscribe = i`
|
|
3535
3642
|
subscription onWalletStatus ( $bundle: String!, $token: String! ) {
|
|
@@ -3542,7 +3649,7 @@ var fn = class {
|
|
|
3542
3649
|
}
|
|
3543
3650
|
`;
|
|
3544
3651
|
}
|
|
3545
|
-
},
|
|
3652
|
+
}, hr = class extends fr {
|
|
3546
3653
|
constructor(e) {
|
|
3547
3654
|
super(e), this.$__subscribe = i`
|
|
3548
3655
|
subscription onActiveWallet ( $bundle: String! ) {
|
|
@@ -3584,7 +3691,7 @@ var fn = class {
|
|
|
3584
3691
|
}
|
|
3585
3692
|
`;
|
|
3586
3693
|
}
|
|
3587
|
-
},
|
|
3694
|
+
}, gr = class extends fr {
|
|
3588
3695
|
constructor(e) {
|
|
3589
3696
|
super(e), this.$__subscribe = i`
|
|
3590
3697
|
subscription onActiveUser ( $metaType: String!, $metaId: String! ) {
|
|
@@ -3598,7 +3705,7 @@ var fn = class {
|
|
|
3598
3705
|
}
|
|
3599
3706
|
}`;
|
|
3600
3707
|
}
|
|
3601
|
-
},
|
|
3708
|
+
}, _r = class extends q {
|
|
3602
3709
|
constructor({ query: e, json: t }) {
|
|
3603
3710
|
super({
|
|
3604
3711
|
query: e,
|
|
@@ -3606,7 +3713,7 @@ var fn = class {
|
|
|
3606
3713
|
dataKey: "data.ActiveSession"
|
|
3607
3714
|
});
|
|
3608
3715
|
}
|
|
3609
|
-
},
|
|
3716
|
+
}, vr = class extends Rn {
|
|
3610
3717
|
constructor(e, t) {
|
|
3611
3718
|
super(e, t), this.$__query = i`mutation(
|
|
3612
3719
|
$bundleHash: String!,
|
|
@@ -3639,12 +3746,12 @@ var fn = class {
|
|
|
3639
3746
|
}`;
|
|
3640
3747
|
}
|
|
3641
3748
|
createResponse(e) {
|
|
3642
|
-
return new
|
|
3749
|
+
return new _r({
|
|
3643
3750
|
query: this,
|
|
3644
3751
|
json: e
|
|
3645
3752
|
});
|
|
3646
3753
|
}
|
|
3647
|
-
},
|
|
3754
|
+
}, yr = class extends q {
|
|
3648
3755
|
constructor({ query: e, json: t }) {
|
|
3649
3756
|
super({
|
|
3650
3757
|
query: e,
|
|
@@ -3662,7 +3769,7 @@ var fn = class {
|
|
|
3662
3769
|
}
|
|
3663
3770
|
return t;
|
|
3664
3771
|
}
|
|
3665
|
-
},
|
|
3772
|
+
}, br = class extends J {
|
|
3666
3773
|
constructor(e, t) {
|
|
3667
3774
|
super(e, t), this.$__query = i`query ActiveUserQuery ($bundleHash:String, $metaType: String, $metaId: String) {
|
|
3668
3775
|
ActiveUser (bundleHash: $bundleHash, metaType: $metaType, metaId: $metaId) {
|
|
@@ -3676,12 +3783,12 @@ var fn = class {
|
|
|
3676
3783
|
}`;
|
|
3677
3784
|
}
|
|
3678
3785
|
createResponse(e) {
|
|
3679
|
-
return new
|
|
3786
|
+
return new yr({
|
|
3680
3787
|
query: this,
|
|
3681
3788
|
json: e
|
|
3682
3789
|
});
|
|
3683
3790
|
}
|
|
3684
|
-
},
|
|
3791
|
+
}, xr = class extends J {
|
|
3685
3792
|
constructor(e, t) {
|
|
3686
3793
|
super(e, t), this.$__query = i`query( $slug: String, $slugs: [ String! ], $limit: Int, $order: String ) {
|
|
3687
3794
|
Token( slug: $slug, slugs: $slugs, limit: $limit, order: $order ) {
|
|
@@ -3696,17 +3803,17 @@ var fn = class {
|
|
|
3696
3803
|
}`;
|
|
3697
3804
|
}
|
|
3698
3805
|
createResponse(e) {
|
|
3699
|
-
return new
|
|
3806
|
+
return new q({
|
|
3700
3807
|
query: this,
|
|
3701
3808
|
json: e,
|
|
3702
3809
|
dataKey: "data.Token"
|
|
3703
3810
|
});
|
|
3704
3811
|
}
|
|
3705
|
-
},
|
|
3812
|
+
}, Sr = class extends C {
|
|
3706
3813
|
constructor(e = "Authorization attempt rejected by ledger.", t = null, n = null) {
|
|
3707
3814
|
super(e, t, n), this.name = "AuthorizationRejectedException";
|
|
3708
3815
|
}
|
|
3709
|
-
},
|
|
3816
|
+
}, Cr = class extends q {
|
|
3710
3817
|
constructor({ query: e, json: t }) {
|
|
3711
3818
|
super({
|
|
3712
3819
|
query: e,
|
|
@@ -3736,7 +3843,7 @@ var fn = class {
|
|
|
3736
3843
|
if (e && e.instances) for (let n of e.instances) n.metasJson && t.push(JSON.parse(n.metasJson));
|
|
3737
3844
|
return t;
|
|
3738
3845
|
}
|
|
3739
|
-
},
|
|
3846
|
+
}, wr = class extends J {
|
|
3740
3847
|
constructor(e, t) {
|
|
3741
3848
|
super(e, t), this.$__query = i`query(
|
|
3742
3849
|
$molecularHashes: [String!],
|
|
@@ -3816,12 +3923,12 @@ var fn = class {
|
|
|
3816
3923
|
};
|
|
3817
3924
|
}
|
|
3818
3925
|
createResponse(e) {
|
|
3819
|
-
return new
|
|
3926
|
+
return new Cr({
|
|
3820
3927
|
query: this,
|
|
3821
3928
|
json: e
|
|
3822
3929
|
});
|
|
3823
3930
|
}
|
|
3824
|
-
},
|
|
3931
|
+
}, Tr = class extends q {
|
|
3825
3932
|
constructor({ query: e, json: t }) {
|
|
3826
3933
|
super({
|
|
3827
3934
|
query: e,
|
|
@@ -3832,7 +3939,7 @@ var fn = class {
|
|
|
3832
3939
|
let e = this.data();
|
|
3833
3940
|
return e && e.callback ? JSON.parse(e.callback) : null;
|
|
3834
3941
|
}
|
|
3835
|
-
},
|
|
3942
|
+
}, Er = class extends J {
|
|
3836
3943
|
constructor(e, t) {
|
|
3837
3944
|
super(e, t), this.$__query = i`query( $metaType: String, $metaId: String, ) {
|
|
3838
3945
|
Policy( metaType: $metaType, metaId: $metaId ) {
|
|
@@ -3848,12 +3955,12 @@ var fn = class {
|
|
|
3848
3955
|
}`;
|
|
3849
3956
|
}
|
|
3850
3957
|
createResponse(e) {
|
|
3851
|
-
return new
|
|
3958
|
+
return new Tr({
|
|
3852
3959
|
query: this,
|
|
3853
3960
|
json: e
|
|
3854
3961
|
});
|
|
3855
3962
|
}
|
|
3856
|
-
},
|
|
3963
|
+
}, Dr = class extends q {
|
|
3857
3964
|
constructor({ query: e, json: t }) {
|
|
3858
3965
|
super({
|
|
3859
3966
|
query: e,
|
|
@@ -3871,7 +3978,7 @@ var fn = class {
|
|
|
3871
3978
|
}, n = e.pop();
|
|
3872
3979
|
return n.instances && (t.instances = n.instances), n.instanceCount && (t.instanceCount = n.instanceCount), n.paginatorInfo && (t.paginatorInfo = n.paginatorInfo), t;
|
|
3873
3980
|
}
|
|
3874
|
-
},
|
|
3981
|
+
}, Or = class extends J {
|
|
3875
3982
|
constructor(e, t) {
|
|
3876
3983
|
super(e, t), this.$__query = i`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
3877
3984
|
MetaTypeViaAtom(
|
|
@@ -3917,12 +4024,12 @@ var fn = class {
|
|
|
3917
4024
|
})), f.latest = s === !0, l && ((l.limit === void 0 || l.limit === 0) && (l.limit = "*"), f.queryArgs = l), f;
|
|
3918
4025
|
}
|
|
3919
4026
|
createResponse(e) {
|
|
3920
|
-
return new
|
|
4027
|
+
return new Dr({
|
|
3921
4028
|
query: this,
|
|
3922
4029
|
json: e
|
|
3923
4030
|
});
|
|
3924
4031
|
}
|
|
3925
|
-
},
|
|
4032
|
+
}, kr = class e extends q {
|
|
3926
4033
|
constructor({ query: e, json: t }) {
|
|
3927
4034
|
super({
|
|
3928
4035
|
query: e,
|
|
@@ -3974,13 +4081,13 @@ var fn = class {
|
|
|
3974
4081
|
molecules: e
|
|
3975
4082
|
};
|
|
3976
4083
|
let n = t[t.length - 1]?.instances || [];
|
|
3977
|
-
for (let t of n) t.molecule && e.push(
|
|
4084
|
+
for (let t of n) t.molecule && e.push(on.verifyFromServerData(t.molecule));
|
|
3978
4085
|
return {
|
|
3979
4086
|
verified: e.length === 0 || e.every((e) => e.verified),
|
|
3980
4087
|
molecules: e
|
|
3981
4088
|
};
|
|
3982
4089
|
}
|
|
3983
|
-
},
|
|
4090
|
+
}, Ar = class extends J {
|
|
3984
4091
|
constructor(e, t) {
|
|
3985
4092
|
super(e, t), this.$__query = i`query ($metaTypes: [String!], $metaIds: [String!], $values: [String!], $keys: [String!], $latest: Boolean, $filter: [MetaFilter!], $queryArgs: QueryArgs, $countBy: String, $atomValues: [String!], $cellSlugs: [String!] ) {
|
|
3986
4093
|
MetaTypeViaAtom(
|
|
@@ -4047,12 +4154,12 @@ var fn = class {
|
|
|
4047
4154
|
})), f.latest = s === !0, l && ((l.limit === void 0 || l.limit === 0) && (l.limit = "*"), f.queryArgs = l), f;
|
|
4048
4155
|
}
|
|
4049
4156
|
createResponse(e) {
|
|
4050
|
-
return new
|
|
4157
|
+
return new kr({
|
|
4051
4158
|
query: this,
|
|
4052
4159
|
json: e
|
|
4053
4160
|
});
|
|
4054
4161
|
}
|
|
4055
|
-
},
|
|
4162
|
+
}, jr = class extends q {
|
|
4056
4163
|
constructor({ query: e, json: t }) {
|
|
4057
4164
|
super({
|
|
4058
4165
|
query: e,
|
|
@@ -4064,7 +4171,7 @@ var fn = class {
|
|
|
4064
4171
|
let e = this.data();
|
|
4065
4172
|
return !e || !Array.isArray(e) || e.length === 0 ? null : e;
|
|
4066
4173
|
}
|
|
4067
|
-
},
|
|
4174
|
+
}, Mr = class extends J {
|
|
4068
4175
|
constructor(e, t) {
|
|
4069
4176
|
super(e, t), this.$__query = i`query( $metaType: String, $metaId: String, $instances: [EmbeddingStatusInput!] ) {
|
|
4070
4177
|
embeddingStatus( metaType: $metaType, metaId: $metaId, instances: $instances ) {
|
|
@@ -4083,12 +4190,12 @@ var fn = class {
|
|
|
4083
4190
|
return n && n.length > 0 && (r.instances = n), e && (r.metaType = e), t && (r.metaId = t), r;
|
|
4084
4191
|
}
|
|
4085
4192
|
createResponse(e) {
|
|
4086
|
-
return new
|
|
4193
|
+
return new jr({
|
|
4087
4194
|
query: this,
|
|
4088
4195
|
json: e
|
|
4089
4196
|
});
|
|
4090
4197
|
}
|
|
4091
|
-
},
|
|
4198
|
+
}, Nr = class extends Y {}, Pr = class extends X {
|
|
4092
4199
|
fillMolecule({ metaType: e, metaId: t, rule: n, policy: r }) {
|
|
4093
4200
|
this.$__molecule.createRule({
|
|
4094
4201
|
metaType: e,
|
|
@@ -4098,26 +4205,26 @@ var fn = class {
|
|
|
4098
4205
|
}), this.$__molecule.sign({}), this.$__molecule.check();
|
|
4099
4206
|
}
|
|
4100
4207
|
createResponse(e) {
|
|
4101
|
-
return new
|
|
4208
|
+
return new Nr({
|
|
4102
4209
|
query: this,
|
|
4103
4210
|
json: e
|
|
4104
4211
|
});
|
|
4105
4212
|
}
|
|
4106
|
-
},
|
|
4213
|
+
}, Fr = class extends X {
|
|
4107
4214
|
fillMolecule({ amount: e, tradeRates: t }) {
|
|
4108
4215
|
this.$__molecule.initDepositBuffer({
|
|
4109
4216
|
amount: e,
|
|
4110
4217
|
tradeRates: t
|
|
4111
4218
|
}), this.$__molecule.sign({}), this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
4112
4219
|
}
|
|
4113
|
-
},
|
|
4220
|
+
}, Ir = class extends X {
|
|
4114
4221
|
fillMolecule({ recipients: e, signingWallet: t }) {
|
|
4115
4222
|
this.$__molecule.initWithdrawBuffer({
|
|
4116
4223
|
recipients: e,
|
|
4117
4224
|
signingWallet: t
|
|
4118
4225
|
}), this.$__molecule.sign({}), this.$__molecule.check(this.$__molecule.sourceWallet);
|
|
4119
4226
|
}
|
|
4120
|
-
},
|
|
4227
|
+
}, Lr = 2592e5, Rr = "thumbmark", zr = "https://api.thumbmarkjs.com", Br = {
|
|
4121
4228
|
exclude: [],
|
|
4122
4229
|
include: [],
|
|
4123
4230
|
stabilize: ["private", "iframe"],
|
|
@@ -4128,8 +4235,8 @@ var fn = class {
|
|
|
4128
4235
|
performance: !1,
|
|
4129
4236
|
experimental: !1,
|
|
4130
4237
|
simple_request: !1,
|
|
4131
|
-
property_name_factory: (e) => `${
|
|
4132
|
-
},
|
|
4238
|
+
property_name_factory: (e) => `${Rr}_${e}`
|
|
4239
|
+
}, Vr = { ...Br }, Hr = {
|
|
4133
4240
|
private: [
|
|
4134
4241
|
{
|
|
4135
4242
|
exclude: ["canvas"],
|
|
@@ -4179,13 +4286,13 @@ var fn = class {
|
|
|
4179
4286
|
exclude: ["speech"],
|
|
4180
4287
|
browsers: ["brave", "firefox"]
|
|
4181
4288
|
}]
|
|
4182
|
-
},
|
|
4183
|
-
function
|
|
4289
|
+
}, Ur = typeof window < "u" ? window.OfflineAudioContext || window.webkitOfflineAudioContext : null;
|
|
4290
|
+
function Wr(e) {
|
|
4184
4291
|
let t = 0;
|
|
4185
4292
|
for (let n = 0; n < e.length; ++n) t += Math.abs(e[n]);
|
|
4186
4293
|
return t;
|
|
4187
4294
|
}
|
|
4188
|
-
function
|
|
4295
|
+
function Gr(e, t, n) {
|
|
4189
4296
|
if (e.length === 1) return e[0];
|
|
4190
4297
|
if (e.length === 3) {
|
|
4191
4298
|
let r = e[0].data, i = e[1].data, a = e[2].data, o = new Uint8ClampedArray(r.length);
|
|
@@ -4199,12 +4306,12 @@ function Fr(e, t, n) {
|
|
|
4199
4306
|
for (let t = 0; t < e[0].data.length; t++) {
|
|
4200
4307
|
let n = [];
|
|
4201
4308
|
for (let r = 0; r < e.length; r++) n.push(e[r].data[t]);
|
|
4202
|
-
r.push(
|
|
4309
|
+
r.push(Kr(n));
|
|
4203
4310
|
}
|
|
4204
4311
|
let i = new Uint8ClampedArray(r);
|
|
4205
4312
|
return new ImageData(i, t, n);
|
|
4206
4313
|
}
|
|
4207
|
-
function
|
|
4314
|
+
function Kr(e) {
|
|
4208
4315
|
if (e.length === 0) return 0;
|
|
4209
4316
|
let t = {};
|
|
4210
4317
|
for (let n of e) t[n] = (t[n] || 0) + 1;
|
|
@@ -4212,19 +4319,19 @@ function Ir(e) {
|
|
|
4212
4319
|
for (let e in t) t[e] > t[n] && (n = parseInt(e, 10));
|
|
4213
4320
|
return n;
|
|
4214
4321
|
}
|
|
4215
|
-
function
|
|
4322
|
+
function qr(e) {
|
|
4216
4323
|
return e ^= e >>> 16, e = Math.imul(e, 2246822507), e ^= e >>> 13, e = Math.imul(e, 3266489909), (e ^= e >>> 16) >>> 0;
|
|
4217
4324
|
}
|
|
4218
|
-
var
|
|
4325
|
+
var Z = new Uint32Array([
|
|
4219
4326
|
597399067,
|
|
4220
4327
|
2869860233,
|
|
4221
4328
|
951274213,
|
|
4222
4329
|
2716044179
|
|
4223
4330
|
]);
|
|
4224
|
-
function
|
|
4331
|
+
function Q(e, t) {
|
|
4225
4332
|
return e << t | e >>> 32 - t;
|
|
4226
4333
|
}
|
|
4227
|
-
function
|
|
4334
|
+
function $(e, t = 0) {
|
|
4228
4335
|
if (t = t ? 0 | t : 0, typeof e == "string" && (e = function(e) {
|
|
4229
4336
|
if (typeof TextEncoder < "u") return new TextEncoder().encode(e).buffer;
|
|
4230
4337
|
let t = [];
|
|
@@ -4244,46 +4351,46 @@ function Z(e, t = 0) {
|
|
|
4244
4351
|
let n = e.byteLength / 16 | 0, r = new Uint32Array(e, 0, 4 * n);
|
|
4245
4352
|
for (let e = 0; e < n; e++) {
|
|
4246
4353
|
let n = r.subarray(4 * e, 4 * (e + 1));
|
|
4247
|
-
n[0] = Math.imul(n[0],
|
|
4354
|
+
n[0] = Math.imul(n[0], Z[0]), n[0] = Q(n[0], 15), n[0] = Math.imul(n[0], Z[1]), t[0] ^= n[0], t[0] = Q(t[0], 19), t[0] += t[1], t[0] = Math.imul(t[0], 5) + 1444728091, n[1] = Math.imul(n[1], Z[1]), n[1] = Q(n[1], 16), n[1] = Math.imul(n[1], Z[2]), t[1] ^= n[1], t[1] = Q(t[1], 17), t[1] += t[2], t[1] = Math.imul(t[1], 5) + 197830471, n[2] = Math.imul(n[2], Z[2]), n[2] = Q(n[2], 17), n[2] = Math.imul(n[2], Z[3]), t[2] ^= n[2], t[2] = Q(t[2], 15), t[2] += t[3], t[2] = Math.imul(t[2], 5) + 2530024501, n[3] = Math.imul(n[3], Z[3]), n[3] = Q(n[3], 18), n[3] = Math.imul(n[3], Z[0]), t[3] ^= n[3], t[3] = Q(t[3], 13), t[3] += t[0], t[3] = Math.imul(t[3], 5) + 850148119;
|
|
4248
4355
|
}
|
|
4249
4356
|
})(e, n), function(e, t) {
|
|
4250
4357
|
let n = e.byteLength / 16 | 0, r = e.byteLength % 16, i = /* @__PURE__ */ new Uint32Array(4), a = new Uint8Array(e, 16 * n, r);
|
|
4251
4358
|
switch (r) {
|
|
4252
4359
|
case 15: i[3] ^= a[14] << 16;
|
|
4253
4360
|
case 14: i[3] ^= a[13] << 8;
|
|
4254
|
-
case 13: i[3] ^= a[12], i[3] = Math.imul(i[3],
|
|
4361
|
+
case 13: i[3] ^= a[12], i[3] = Math.imul(i[3], Z[3]), i[3] = Q(i[3], 18), i[3] = Math.imul(i[3], Z[0]), t[3] ^= i[3];
|
|
4255
4362
|
case 12: i[2] ^= a[11] << 24;
|
|
4256
4363
|
case 11: i[2] ^= a[10] << 16;
|
|
4257
4364
|
case 10: i[2] ^= a[9] << 8;
|
|
4258
|
-
case 9: i[2] ^= a[8], i[2] = Math.imul(i[2],
|
|
4365
|
+
case 9: i[2] ^= a[8], i[2] = Math.imul(i[2], Z[2]), i[2] = Q(i[2], 17), i[2] = Math.imul(i[2], Z[3]), t[2] ^= i[2];
|
|
4259
4366
|
case 8: i[1] ^= a[7] << 24;
|
|
4260
4367
|
case 7: i[1] ^= a[6] << 16;
|
|
4261
4368
|
case 6: i[1] ^= a[5] << 8;
|
|
4262
|
-
case 5: i[1] ^= a[4], i[1] = Math.imul(i[1],
|
|
4369
|
+
case 5: i[1] ^= a[4], i[1] = Math.imul(i[1], Z[1]), i[1] = Q(i[1], 16), i[1] = Math.imul(i[1], Z[2]), t[1] ^= i[1];
|
|
4263
4370
|
case 4: i[0] ^= a[3] << 24;
|
|
4264
4371
|
case 3: i[0] ^= a[2] << 16;
|
|
4265
4372
|
case 2: i[0] ^= a[1] << 8;
|
|
4266
|
-
case 1: i[0] ^= a[0], i[0] = Math.imul(i[0],
|
|
4373
|
+
case 1: i[0] ^= a[0], i[0] = Math.imul(i[0], Z[0]), i[0] = Q(i[0], 15), i[0] = Math.imul(i[0], Z[1]), t[0] ^= i[0];
|
|
4267
4374
|
}
|
|
4268
4375
|
}(e, n), function(e, t) {
|
|
4269
|
-
t[0] ^= e.byteLength, t[1] ^= e.byteLength, t[2] ^= e.byteLength, t[3] ^= e.byteLength, t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0, t[0] =
|
|
4376
|
+
t[0] ^= e.byteLength, t[1] ^= e.byteLength, t[2] ^= e.byteLength, t[3] ^= e.byteLength, t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0, t[0] = qr(t[0]), t[1] = qr(t[1]), t[2] = qr(t[2]), t[3] = qr(t[3]), t[0] = t[0] + t[1] | 0, t[0] = t[0] + t[2] | 0, t[0] = t[0] + t[3] | 0, t[1] = t[1] + t[0] | 0, t[2] = t[2] + t[0] | 0, t[3] = t[3] + t[0] | 0;
|
|
4270
4377
|
}(e, n);
|
|
4271
4378
|
let r = new Uint8Array(n.buffer);
|
|
4272
4379
|
return Array.from(r).map(((e) => e.toString(16).padStart(2, "0"))).join("");
|
|
4273
4380
|
}
|
|
4274
|
-
var
|
|
4275
|
-
function
|
|
4381
|
+
var Jr = 280;
|
|
4382
|
+
function Yr(e, t) {
|
|
4276
4383
|
return new Promise(((n) => setTimeout(n, e, t)));
|
|
4277
4384
|
}
|
|
4278
|
-
var
|
|
4385
|
+
var Xr = /* @__PURE__ */ "Arial.Arial Black.Arial Narrow.Arial Rounded MT.Arimo.Archivo.Barlow.Bebas Neue.Bitter.Bookman.Calibri.Cabin.Candara.Century.Century Gothic.Comic Sans MS.Constantia.Courier.Courier New.Crimson Text.DM Mono.DM Sans.DM Serif Display.DM Serif Text.Dosis.Droid Sans.Exo.Fira Code.Fira Sans.Franklin Gothic Medium.Garamond.Geneva.Georgia.Gill Sans.Helvetica.Impact.Inconsolata.Indie Flower.Inter.Josefin Sans.Karla.Lato.Lexend.Lucida Bright.Lucida Console.Lucida Sans Unicode.Manrope.Merriweather.Merriweather Sans.Montserrat.Myriad.Noto Sans.Nunito.Nunito Sans.Open Sans.Optima.Orbitron.Oswald.Pacifico.Palatino.Perpetua.PT Sans.PT Serif.Poppins.Prompt.Public Sans.Quicksand.Rajdhani.Recursive.Roboto.Roboto Condensed.Rockwell.Rubik.Segoe Print.Segoe Script.Segoe UI.Sora.Source Sans Pro.Space Mono.Tahoma.Taviraj.Times.Times New Roman.Titillium Web.Trebuchet MS.Ubuntu.Varela Round.Verdana.Work Sans".split("."), Zr = [
|
|
4279
4386
|
"monospace",
|
|
4280
4387
|
"sans-serif",
|
|
4281
4388
|
"serif"
|
|
4282
4389
|
];
|
|
4283
|
-
function
|
|
4390
|
+
function Qr(e, t) {
|
|
4284
4391
|
return e.font = `72px ${t}`, e.measureText("WwMmLli0Oo").width;
|
|
4285
4392
|
}
|
|
4286
|
-
function
|
|
4393
|
+
function $r() {
|
|
4287
4394
|
let e = document.createElement("canvas"), t = e.getContext("webgl") ?? e.getContext("experimental-webgl");
|
|
4288
4395
|
if (t && "getParameter" in t) try {
|
|
4289
4396
|
let e = (t.getParameter(t.VENDOR) || "").toString(), n = (t.getParameter(t.RENDERER) || "").toString(), r = {
|
|
@@ -4303,16 +4410,16 @@ function Ur() {
|
|
|
4303
4410
|
} catch {}
|
|
4304
4411
|
return "undefined";
|
|
4305
4412
|
}
|
|
4306
|
-
function
|
|
4413
|
+
function ei() {
|
|
4307
4414
|
let e = /* @__PURE__ */ new Float32Array(1), t = new Uint8Array(e.buffer);
|
|
4308
4415
|
return e[0] = 1 / 0, e[0] -= e[0], t[3];
|
|
4309
4416
|
}
|
|
4310
|
-
var
|
|
4417
|
+
var ti = (e, t, n, r) => {
|
|
4311
4418
|
let i = (n - t) / r, a = 0;
|
|
4312
4419
|
for (let n = 0; n < r; n++) a += e(t + (n + .5) * i);
|
|
4313
4420
|
return a * i;
|
|
4314
4421
|
};
|
|
4315
|
-
function
|
|
4422
|
+
function ni(e, t) {
|
|
4316
4423
|
let n = {};
|
|
4317
4424
|
return t.forEach(((t) => {
|
|
4318
4425
|
let r = function(e) {
|
|
@@ -4330,28 +4437,28 @@ function Kr(e, t) {
|
|
|
4330
4437
|
r && (n[t] = r);
|
|
4331
4438
|
})), n;
|
|
4332
4439
|
}
|
|
4333
|
-
var
|
|
4334
|
-
function
|
|
4440
|
+
var ri = /* @__PURE__ */ "accelerometer.accessibility.accessibility-events.ambient-light-sensor.background-fetch.background-sync.bluetooth.camera.clipboard-read.clipboard-write.device-info.display-capture.gyroscope.geolocation.local-fonts.magnetometer.microphone.midi.nfc.notifications.payment-handler.persistent-storage.push.speaker.storage-access.top-level-storage-access.window-management.query".split("."), ii = /* @__PURE__ */ new Map();
|
|
4441
|
+
function ai() {
|
|
4335
4442
|
if (typeof navigator > "u") return {
|
|
4336
4443
|
name: "unknown",
|
|
4337
4444
|
version: "unknown"
|
|
4338
4445
|
};
|
|
4339
|
-
let e = !!navigator.brave, t = (e ? "B|" : "N|") + navigator.userAgent, n =
|
|
4446
|
+
let e = !!navigator.brave, t = (e ? "B|" : "N|") + navigator.userAgent, n = ii.get(t);
|
|
4340
4447
|
if (n) return n;
|
|
4341
4448
|
let r = [{
|
|
4342
4449
|
name: "Brave",
|
|
4343
4450
|
detect: () => e
|
|
4344
4451
|
}], i;
|
|
4345
4452
|
for (let e of r) if (e.detect()) {
|
|
4346
|
-
let n =
|
|
4453
|
+
let n = oi(navigator.userAgent);
|
|
4347
4454
|
return i = {
|
|
4348
4455
|
name: e.name,
|
|
4349
4456
|
version: n.version
|
|
4350
|
-
},
|
|
4457
|
+
}, ii.set(t, i), i;
|
|
4351
4458
|
}
|
|
4352
|
-
return i =
|
|
4459
|
+
return i = oi(navigator.userAgent), ii.set(t, i), i;
|
|
4353
4460
|
}
|
|
4354
|
-
function
|
|
4461
|
+
function oi(e) {
|
|
4355
4462
|
var t, n;
|
|
4356
4463
|
let r = [
|
|
4357
4464
|
/(?<name>SamsungBrowser)\/(?<version>\d+(?:\.\d+)+)/,
|
|
@@ -4394,12 +4501,12 @@ function Xr(e) {
|
|
|
4394
4501
|
version: "unknown"
|
|
4395
4502
|
};
|
|
4396
4503
|
}
|
|
4397
|
-
function
|
|
4504
|
+
function si() {
|
|
4398
4505
|
if (typeof navigator > "u" || !navigator.userAgent) return !1;
|
|
4399
4506
|
let e = navigator.userAgent;
|
|
4400
4507
|
return /Mobi|Android|iPhone|iPod|IEMobile|Opera Mini|Opera Mobi|webOS|BlackBerry|Windows Phone/i.test(e) && !/iPad/i.test(e);
|
|
4401
4508
|
}
|
|
4402
|
-
function
|
|
4509
|
+
function ci() {
|
|
4403
4510
|
let e = [], t = {
|
|
4404
4511
|
"prefers-contrast": [
|
|
4405
4512
|
"high",
|
|
@@ -4438,7 +4545,7 @@ function Qr() {
|
|
|
4438
4545
|
}));
|
|
4439
4546
|
})), e;
|
|
4440
4547
|
}
|
|
4441
|
-
function
|
|
4548
|
+
function li() {
|
|
4442
4549
|
if (window.location.protocol === "https:" && typeof window.ApplePaySession == "function") try {
|
|
4443
4550
|
let e = window.ApplePaySession.supportsVersion;
|
|
4444
4551
|
for (let t = 15; t > 0; t--) if (e(t)) return t;
|
|
@@ -4447,15 +4554,15 @@ function $r() {
|
|
|
4447
4554
|
}
|
|
4448
4555
|
return 0;
|
|
4449
4556
|
}
|
|
4450
|
-
var
|
|
4451
|
-
let e = /* @__PURE__ */ new Float32Array(548), t = 2 * Math.PI /
|
|
4452
|
-
for (let n = 0; n <
|
|
4557
|
+
var ui = ai().name === "SamsungBrowser" ? 3 : 1, di = ai().name !== "Brave", fi = 137, pi = (() => {
|
|
4558
|
+
let e = /* @__PURE__ */ new Float32Array(548), t = 2 * Math.PI / fi;
|
|
4559
|
+
for (let n = 0; n < fi; n++) {
|
|
4453
4560
|
let r = n * t;
|
|
4454
4561
|
e[4 * n] = 0, e[4 * n + 1] = 0, e[4 * n + 2] = 100 * Math.cos(r), e[4 * n + 3] = 50 * Math.sin(r);
|
|
4455
4562
|
}
|
|
4456
4563
|
return e;
|
|
4457
|
-
})(),
|
|
4458
|
-
function
|
|
4564
|
+
})(), mi = null;
|
|
4565
|
+
function hi() {
|
|
4459
4566
|
try {
|
|
4460
4567
|
if (typeof document > "u") return null;
|
|
4461
4568
|
let e = document.createElement("canvas");
|
|
@@ -4463,14 +4570,14 @@ function ai() {
|
|
|
4463
4570
|
let t = e.getContext("webgl");
|
|
4464
4571
|
if (!t) return null;
|
|
4465
4572
|
e.addEventListener("webglcontextlost", ((e) => {
|
|
4466
|
-
e.preventDefault(),
|
|
4573
|
+
e.preventDefault(), mi = null;
|
|
4467
4574
|
}), { once: !0 });
|
|
4468
4575
|
let n = t.createShader(t.VERTEX_SHADER), r = t.createShader(t.FRAGMENT_SHADER);
|
|
4469
4576
|
if (!n || !r || (t.shaderSource(n, "\n attribute vec2 position;\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n }\n"), t.compileShader(n), !t.getShaderParameter(n, t.COMPILE_STATUS)) || (t.shaderSource(r, "\n precision mediump float;\n void main() {\n gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color\n }\n"), t.compileShader(r), !t.getShaderParameter(r, t.COMPILE_STATUS))) return null;
|
|
4470
4577
|
let i = t.createProgram();
|
|
4471
4578
|
if (!i || (t.attachShader(i, n), t.attachShader(i, r), t.linkProgram(i), !t.getProgramParameter(i, t.LINK_STATUS))) return null;
|
|
4472
4579
|
let a = t.createBuffer();
|
|
4473
|
-
return a ? (t.bindBuffer(t.ARRAY_BUFFER, a), t.bufferData(t.ARRAY_BUFFER,
|
|
4580
|
+
return a ? (t.bindBuffer(t.ARRAY_BUFFER, a), t.bufferData(t.ARRAY_BUFFER, pi, t.STATIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), {
|
|
4474
4581
|
canvas: e,
|
|
4475
4582
|
gl: t,
|
|
4476
4583
|
program: i,
|
|
@@ -4480,7 +4587,7 @@ function ai() {
|
|
|
4480
4587
|
return null;
|
|
4481
4588
|
}
|
|
4482
4589
|
}
|
|
4483
|
-
function
|
|
4590
|
+
function gi(e) {
|
|
4484
4591
|
let t = /* @__PURE__ */ new Set();
|
|
4485
4592
|
return function e(n) {
|
|
4486
4593
|
if (n && n.toJSON && typeof n.toJSON == "function" && (n = n.toJSON()), n === void 0) return;
|
|
@@ -4502,17 +4609,17 @@ function Q(e) {
|
|
|
4502
4609
|
return t.delete(n), "{" + i + "}";
|
|
4503
4610
|
}(e) || "";
|
|
4504
4611
|
}
|
|
4505
|
-
var
|
|
4612
|
+
var _i = {
|
|
4506
4613
|
audio: async function() {
|
|
4507
|
-
return
|
|
4614
|
+
return Ur ? async function() {
|
|
4508
4615
|
return new Promise(((e, t) => {
|
|
4509
4616
|
try {
|
|
4510
|
-
let t = new
|
|
4617
|
+
let t = new Ur(1, 5e3, 44100), n = t.createBufferSource(), r = t.createOscillator();
|
|
4511
4618
|
r.frequency.value = 1e3;
|
|
4512
4619
|
let i = t.createDynamicsCompressor(), a;
|
|
4513
4620
|
i.threshold.value = -50, i.knee.value = 40, i.ratio.value = 12, i.attack.value = 0, i.release.value = .2, r.connect(i), i.connect(t.destination), r.start(), t.oncomplete = (r) => {
|
|
4514
4621
|
a = r.renderedBuffer.getChannelData(0), e({
|
|
4515
|
-
sampleHash:
|
|
4622
|
+
sampleHash: Wr(a),
|
|
4516
4623
|
maxChannels: t.destination.maxChannelCount,
|
|
4517
4624
|
channelCountMode: n.channelCountMode
|
|
4518
4625
|
});
|
|
@@ -4528,20 +4635,20 @@ var oi = {
|
|
|
4528
4635
|
let t = Array.from({ length: 3 }, (() => function() {
|
|
4529
4636
|
let e = document.createElement("canvas"), t = e.getContext("2d");
|
|
4530
4637
|
if (!t) return null;
|
|
4531
|
-
e.width =
|
|
4638
|
+
e.width = Jr, e.height = 20;
|
|
4532
4639
|
let n = t.createLinearGradient(0, 0, e.width, e.height);
|
|
4533
4640
|
n.addColorStop(0, "red"), n.addColorStop(1 / 6, "orange"), n.addColorStop(2 / 6, "yellow"), n.addColorStop(.5, "green"), n.addColorStop(4 / 6, "blue"), n.addColorStop(5 / 6, "indigo"), n.addColorStop(1, "violet"), t.fillStyle = n, t.fillRect(0, 0, e.width, e.height);
|
|
4534
4641
|
let r = "Random Text WMwmil10Oo";
|
|
4535
4642
|
return t.font = "23.123px Arial", t.fillStyle = "black", t.fillText(r, -5, 15), t.fillStyle = "rgba(0, 0, 255, 0.5)", t.fillText(r, -3.3, 17.7), t.beginPath(), t.moveTo(0, 0), t.lineTo(2 * e.width / 7, e.height), t.strokeStyle = "white", t.lineWidth = 2, t.stroke(), t.getImageData(0, 0, e.width, e.height);
|
|
4536
4643
|
}())).filter(((e) => e !== null));
|
|
4537
|
-
t.length === 0 ? e(null) : e({ commonPixelsHash:
|
|
4644
|
+
t.length === 0 ? e(null) : e({ commonPixelsHash: $(Gr(t, Jr, 20).data.toString()).toString() });
|
|
4538
4645
|
}));
|
|
4539
4646
|
},
|
|
4540
4647
|
fonts: async function(e) {
|
|
4541
4648
|
return new Promise(((e) => {
|
|
4542
4649
|
try {
|
|
4543
4650
|
(async function(e) {
|
|
4544
|
-
for (; !document.body;) await
|
|
4651
|
+
for (; !document.body;) await Yr(50);
|
|
4545
4652
|
let t = document.createElement("iframe");
|
|
4546
4653
|
t.setAttribute("frameBorder", "0");
|
|
4547
4654
|
let n = t.style;
|
|
@@ -4554,9 +4661,9 @@ var oi = {
|
|
|
4554
4661
|
})((async ({ iframe: t }) => {
|
|
4555
4662
|
let n = t.createElement("canvas").getContext("2d");
|
|
4556
4663
|
if (!n) return void e(null);
|
|
4557
|
-
let r =
|
|
4558
|
-
|
|
4559
|
-
let t =
|
|
4664
|
+
let r = Zr.map(((e) => Qr(n, e))), i = {};
|
|
4665
|
+
Xr.forEach(((e) => {
|
|
4666
|
+
let t = Qr(n, e);
|
|
4560
4667
|
r.includes(t) || (i[e] = t);
|
|
4561
4668
|
})), e(i);
|
|
4562
4669
|
}));
|
|
@@ -4569,8 +4676,8 @@ var oi = {
|
|
|
4569
4676
|
return new Promise(((e, t) => {
|
|
4570
4677
|
let n = navigator.deviceMemory === void 0 ? 0 : navigator.deviceMemory, r = window.performance && window.performance.memory ? window.performance.memory : 0;
|
|
4571
4678
|
e({
|
|
4572
|
-
videocard:
|
|
4573
|
-
architecture:
|
|
4679
|
+
videocard: $r(),
|
|
4680
|
+
architecture: ei(),
|
|
4574
4681
|
deviceMemory: n.toString() || "undefined",
|
|
4575
4682
|
jsHeapSizeLimit: r.jsHeapSizeLimit || 0
|
|
4576
4683
|
});
|
|
@@ -4588,19 +4695,19 @@ var oi = {
|
|
|
4588
4695
|
return new Promise(((e) => {
|
|
4589
4696
|
e({
|
|
4590
4697
|
acos: Math.acos(.5),
|
|
4591
|
-
asin:
|
|
4592
|
-
cos:
|
|
4698
|
+
asin: ti(Math.asin, -1, 1, 97),
|
|
4699
|
+
cos: ti(Math.cos, 0, Math.PI, 97),
|
|
4593
4700
|
largeCos: Math.cos(0x56bc75e2d63100000),
|
|
4594
4701
|
largeSin: Math.sin(0x56bc75e2d63100000),
|
|
4595
4702
|
largeTan: Math.tan(0x56bc75e2d63100000),
|
|
4596
|
-
sin:
|
|
4597
|
-
tan:
|
|
4703
|
+
sin: ti(Math.sin, -Math.PI, Math.PI, 97),
|
|
4704
|
+
tan: ti(Math.tan, 0, 2 * Math.PI, 97)
|
|
4598
4705
|
});
|
|
4599
4706
|
}));
|
|
4600
4707
|
},
|
|
4601
4708
|
permissions: async function(e) {
|
|
4602
|
-
let t = e?.permissions_to_check ||
|
|
4603
|
-
return
|
|
4709
|
+
let t = e?.permissions_to_check || ri;
|
|
4710
|
+
return ni(await Promise.all(Array.from({ length: 3 }, (() => async function(e) {
|
|
4604
4711
|
let t = {};
|
|
4605
4712
|
for (let n of e) try {
|
|
4606
4713
|
t[n] = (await navigator.permissions.query({ name: n })).state.toString();
|
|
@@ -4629,9 +4736,9 @@ var oi = {
|
|
|
4629
4736
|
is_touchscreen: navigator.maxTouchPoints > 0,
|
|
4630
4737
|
maxTouchPoints: navigator.maxTouchPoints,
|
|
4631
4738
|
colorDepth: screen.colorDepth,
|
|
4632
|
-
mediaMatches:
|
|
4739
|
+
mediaMatches: ci()
|
|
4633
4740
|
};
|
|
4634
|
-
|
|
4741
|
+
si() && navigator.maxTouchPoints > 0 && (t.resolution = function() {
|
|
4635
4742
|
let e = window.screen.width, t = window.screen.height;
|
|
4636
4743
|
return `${Math.max(e, t).toString()}x${Math.min(e, t).toString()}`;
|
|
4637
4744
|
}()), e(t);
|
|
@@ -4639,7 +4746,7 @@ var oi = {
|
|
|
4639
4746
|
},
|
|
4640
4747
|
system: function() {
|
|
4641
4748
|
return new Promise(((e) => {
|
|
4642
|
-
let t =
|
|
4749
|
+
let t = ai();
|
|
4643
4750
|
e({
|
|
4644
4751
|
platform: window.navigator.platform,
|
|
4645
4752
|
productSub: navigator.productSub,
|
|
@@ -4650,17 +4757,17 @@ var oi = {
|
|
|
4650
4757
|
name: t.name,
|
|
4651
4758
|
version: t.version
|
|
4652
4759
|
},
|
|
4653
|
-
mobile:
|
|
4654
|
-
applePayVersion:
|
|
4760
|
+
mobile: si(),
|
|
4761
|
+
applePayVersion: li(),
|
|
4655
4762
|
cookieEnabled: window.navigator.cookieEnabled
|
|
4656
4763
|
});
|
|
4657
4764
|
}));
|
|
4658
4765
|
},
|
|
4659
4766
|
webgl: async function() {
|
|
4660
|
-
let e =
|
|
4767
|
+
let e = di ? (mi ||= hi(), mi) : hi();
|
|
4661
4768
|
if (!e) return { webgl: "unsupported" };
|
|
4662
4769
|
try {
|
|
4663
|
-
return { commonPixelsHash:
|
|
4770
|
+
return { commonPixelsHash: $(Gr(Array.from({ length: ui }, (() => function(e) {
|
|
4664
4771
|
let { canvas: t, gl: n, program: r, buffer: i } = e;
|
|
4665
4772
|
try {
|
|
4666
4773
|
n.useProgram(r), n.bindBuffer(n.ARRAY_BUFFER, i);
|
|
@@ -4669,7 +4776,7 @@ var oi = {
|
|
|
4669
4776
|
let a = new Uint8ClampedArray(t.width * t.height * 4);
|
|
4670
4777
|
return n.readPixels(0, 0, t.width, t.height, n.RGBA, n.UNSIGNED_BYTE, a), new ImageData(a, t.width, t.height);
|
|
4671
4778
|
} catch {
|
|
4672
|
-
return
|
|
4779
|
+
return mi = null, new ImageData(1, 1);
|
|
4673
4780
|
} finally {
|
|
4674
4781
|
n.bindBuffer(n.ARRAY_BUFFER, null), n.useProgram(null), n.viewport(0, 0, n.drawingBufferWidth, n.drawingBufferHeight), n.clearColor(0, 0, 0, 0);
|
|
4675
4782
|
}
|
|
@@ -4713,13 +4820,13 @@ var oi = {
|
|
|
4713
4820
|
})).filter(Boolean), s = o("audio", a("audio")), c = o("video", a("video")), l = {
|
|
4714
4821
|
audio: {
|
|
4715
4822
|
count: s.length,
|
|
4716
|
-
hash:
|
|
4823
|
+
hash: $(gi(s))
|
|
4717
4824
|
},
|
|
4718
4825
|
video: {
|
|
4719
4826
|
count: c.length,
|
|
4720
|
-
hash:
|
|
4827
|
+
hash: $(gi(c))
|
|
4721
4828
|
},
|
|
4722
|
-
extensionsHash:
|
|
4829
|
+
extensionsHash: $(gi(i))
|
|
4723
4830
|
};
|
|
4724
4831
|
r.close();
|
|
4725
4832
|
let u = {
|
|
@@ -4729,7 +4836,7 @@ var oi = {
|
|
|
4729
4836
|
};
|
|
4730
4837
|
e({
|
|
4731
4838
|
details: u,
|
|
4732
|
-
hash:
|
|
4839
|
+
hash: $(gi(u))
|
|
4733
4840
|
});
|
|
4734
4841
|
} catch (t) {
|
|
4735
4842
|
r.close(), e({
|
|
@@ -4770,11 +4877,11 @@ var oi = {
|
|
|
4770
4877
|
t.sort();
|
|
4771
4878
|
let n = {
|
|
4772
4879
|
voiceCount: r.length,
|
|
4773
|
-
voicesHash:
|
|
4880
|
+
voicesHash: $(gi(t))
|
|
4774
4881
|
};
|
|
4775
4882
|
e({
|
|
4776
4883
|
details: n,
|
|
4777
|
-
hash:
|
|
4884
|
+
hash: $(gi(n))
|
|
4778
4885
|
});
|
|
4779
4886
|
} catch (t) {
|
|
4780
4887
|
e({
|
|
@@ -4803,10 +4910,10 @@ var oi = {
|
|
|
4803
4910
|
}
|
|
4804
4911
|
}));
|
|
4805
4912
|
}
|
|
4806
|
-
},
|
|
4807
|
-
function
|
|
4913
|
+
}, vi = {}, yi = { timeout: "true" };
|
|
4914
|
+
function bi(e, t) {
|
|
4808
4915
|
var n;
|
|
4809
|
-
let r =
|
|
4916
|
+
let r = ai();
|
|
4810
4917
|
if (r.name === "unknown" && t) {
|
|
4811
4918
|
let e = t.system?.browser;
|
|
4812
4919
|
e != null && e.name && (r = {
|
|
@@ -4816,7 +4923,7 @@ function li(e, t) {
|
|
|
4816
4923
|
}
|
|
4817
4924
|
let i = r.name.toLowerCase(), a = parseInt(r.version.split(".")[0] || "0", 10), o = Array.isArray(e?.exclude) ? [...e.exclude] : [], s = [.../* @__PURE__ */ new Set([...e?.stabilize || [], "always"])];
|
|
4818
4925
|
for (let e of s) {
|
|
4819
|
-
let t =
|
|
4926
|
+
let t = Hr[e];
|
|
4820
4927
|
if (t) for (let e of t) "browsers" in e && !((n = e.browsers) != null && n.some(((e) => {
|
|
4821
4928
|
let t = e.match(/(.+?)(>=)(\d+)/);
|
|
4822
4929
|
return t ? i === t[1] && a >= +t[3] : i === e;
|
|
@@ -4824,8 +4931,8 @@ function li(e, t) {
|
|
|
4824
4931
|
}
|
|
4825
4932
|
return o;
|
|
4826
4933
|
}
|
|
4827
|
-
function
|
|
4828
|
-
let n =
|
|
4934
|
+
function xi(e, t) {
|
|
4935
|
+
let n = bi(t, e), r = Array.isArray(t?.include) ? t.include : [];
|
|
4829
4936
|
return function e(t, i = "") {
|
|
4830
4937
|
let a = {};
|
|
4831
4938
|
for (let [o, s] of Object.entries(t)) {
|
|
@@ -4841,8 +4948,8 @@ function ui(e, t) {
|
|
|
4841
4948
|
return a;
|
|
4842
4949
|
}(e);
|
|
4843
4950
|
}
|
|
4844
|
-
var
|
|
4845
|
-
function
|
|
4951
|
+
var Si = "https://experimental.thumbmarkjs.com/experimental.min.js", Ci = 131072;
|
|
4952
|
+
function wi(e, t) {
|
|
4846
4953
|
let n = {
|
|
4847
4954
|
target: "request",
|
|
4848
4955
|
type: e
|
|
@@ -4854,15 +4961,15 @@ function $(e, t) {
|
|
|
4854
4961
|
errors: [n]
|
|
4855
4962
|
};
|
|
4856
4963
|
}
|
|
4857
|
-
function
|
|
4964
|
+
function Ti(e) {
|
|
4858
4965
|
if (typeof e != "object" || !e || Array.isArray(e)) return !1;
|
|
4859
4966
|
let t = Object.getPrototypeOf(e);
|
|
4860
4967
|
return t === Object.prototype || t === null;
|
|
4861
4968
|
}
|
|
4862
|
-
function
|
|
4969
|
+
function Ei(e) {
|
|
4863
4970
|
return e instanceof Error ? e.message : void 0;
|
|
4864
4971
|
}
|
|
4865
|
-
async function
|
|
4972
|
+
async function Di() {
|
|
4866
4973
|
try {
|
|
4867
4974
|
return await function(e, t) {
|
|
4868
4975
|
let n, r = new Promise(((e) => {
|
|
@@ -4872,60 +4979,60 @@ async function hi() {
|
|
|
4872
4979
|
}(async function() {
|
|
4873
4980
|
let e, t;
|
|
4874
4981
|
try {
|
|
4875
|
-
let t = await fetch(
|
|
4876
|
-
if (!t.ok) return
|
|
4982
|
+
let t = await fetch(Si, { method: "GET" });
|
|
4983
|
+
if (!t.ok) return wi("http", `HTTP ${t.status}`);
|
|
4877
4984
|
e = await t.text();
|
|
4878
4985
|
} catch (e) {
|
|
4879
|
-
return
|
|
4986
|
+
return wi("fetch", Ei(e));
|
|
4880
4987
|
}
|
|
4881
|
-
if (!e) return
|
|
4882
|
-
if (e.length >
|
|
4988
|
+
if (!e) return wi("empty");
|
|
4989
|
+
if (e.length > Ci) return wi("oversized", `${e.length} chars`);
|
|
4883
4990
|
try {
|
|
4884
4991
|
let n = eval;
|
|
4885
4992
|
t = await Promise.resolve(n(e));
|
|
4886
4993
|
} catch (e) {
|
|
4887
|
-
return
|
|
4994
|
+
return wi(function(e) {
|
|
4888
4995
|
return e instanceof SyntaxError ? "syntax" : e instanceof EvalError ? "eval_blocked" : "threw";
|
|
4889
|
-
}(e),
|
|
4996
|
+
}(e), Ei(e));
|
|
4890
4997
|
}
|
|
4891
4998
|
return function(e) {
|
|
4892
|
-
return !!
|
|
4999
|
+
return !!Ti(e) && !(typeof e.schema != "number" || e.schema < 1) && typeof e.payload_id == "string" && Ti(e.signals);
|
|
4893
5000
|
}(t) ? {
|
|
4894
5001
|
...t,
|
|
4895
5002
|
errors: Array.isArray(t.errors) ? t.errors : []
|
|
4896
|
-
} :
|
|
4897
|
-
}(), 2e3) ??
|
|
5003
|
+
} : wi("malformed");
|
|
5004
|
+
}(), 2e3) ?? wi("timeout", "exceeded 2000ms");
|
|
4898
5005
|
} catch (e) {
|
|
4899
|
-
return
|
|
5006
|
+
return wi("threw", Ei(e));
|
|
4900
5007
|
}
|
|
4901
5008
|
}
|
|
4902
|
-
var
|
|
4903
|
-
function
|
|
4904
|
-
return e.storage_property_name ? e.storage_property_name : e.property_name_factory(
|
|
5009
|
+
var Oi = "visitor_id";
|
|
5010
|
+
function ki(e) {
|
|
5011
|
+
return e.storage_property_name ? e.storage_property_name : e.property_name_factory(Oi);
|
|
4905
5012
|
}
|
|
4906
|
-
var
|
|
4907
|
-
function
|
|
5013
|
+
var Ai = `${Rr}_${Oi}`;
|
|
5014
|
+
function ji(e, t) {
|
|
4908
5015
|
try {
|
|
4909
|
-
localStorage.setItem(
|
|
5016
|
+
localStorage.setItem(ki(t), e);
|
|
4910
5017
|
} catch {}
|
|
4911
5018
|
}
|
|
4912
|
-
var
|
|
4913
|
-
function
|
|
5019
|
+
var Mi = "cache";
|
|
5020
|
+
function Ni(e) {
|
|
4914
5021
|
try {
|
|
4915
|
-
let t = localStorage.getItem(e.property_name_factory(
|
|
5022
|
+
let t = localStorage.getItem(e.property_name_factory(Mi));
|
|
4916
5023
|
return JSON.parse(t) || {};
|
|
4917
5024
|
} catch {}
|
|
4918
5025
|
return {};
|
|
4919
5026
|
}
|
|
4920
|
-
function
|
|
4921
|
-
return e.cache_lifetime_in_ms >
|
|
5027
|
+
function Pi(e) {
|
|
5028
|
+
return e.cache_lifetime_in_ms > Lr ? Date.now() + Lr : Date.now() + e.cache_lifetime_in_ms;
|
|
4922
5029
|
}
|
|
4923
|
-
var
|
|
5030
|
+
var Fi = class extends Error {
|
|
4924
5031
|
constructor(e) {
|
|
4925
5032
|
super(`HTTP error! status: ${e}`), this.status = e;
|
|
4926
5033
|
}
|
|
4927
|
-
},
|
|
4928
|
-
async function
|
|
5034
|
+
}, Ii = null, Li = null;
|
|
5035
|
+
async function Ri(e, t, n, r) {
|
|
4929
5036
|
let i = n.simple_request ? { "Content-Type": "text/plain" } : {
|
|
4930
5037
|
"x-api-key": n.api_key,
|
|
4931
5038
|
Authorization: "custom-authorized",
|
|
@@ -4935,34 +5042,34 @@ async function Ei(e, t, n, r) {
|
|
|
4935
5042
|
headers: i,
|
|
4936
5043
|
body: JSON.stringify(t)
|
|
4937
5044
|
});
|
|
4938
|
-
if (!a.ok) throw new
|
|
5045
|
+
if (!a.ok) throw new Fi(a.status);
|
|
4939
5046
|
let o = await a.json();
|
|
4940
|
-
return o.visitorId && o.visitorId !== r &&
|
|
5047
|
+
return o.visitorId && o.visitorId !== r && ji(o.visitorId, n), Li = o, function(e, t) {
|
|
4941
5048
|
e.cache_api_call && e.cache_lifetime_in_ms && (function(e, t) {
|
|
4942
5049
|
let n = {
|
|
4943
|
-
...
|
|
5050
|
+
...Ni(e),
|
|
4944
5051
|
...t
|
|
4945
5052
|
};
|
|
4946
5053
|
try {
|
|
4947
|
-
localStorage.setItem(e.property_name_factory(
|
|
5054
|
+
localStorage.setItem(e.property_name_factory(Mi), JSON.stringify(n));
|
|
4948
5055
|
} catch {}
|
|
4949
5056
|
})(e, {
|
|
4950
|
-
apiResponseExpiry:
|
|
5057
|
+
apiResponseExpiry: Pi(e),
|
|
4951
5058
|
apiResponse: t
|
|
4952
5059
|
});
|
|
4953
5060
|
}(n, o), o;
|
|
4954
5061
|
}
|
|
4955
|
-
var
|
|
5062
|
+
var zi = (e, t) => {
|
|
4956
5063
|
if (e.cache_api_call) {
|
|
4957
|
-
if (
|
|
5064
|
+
if (Li) return Promise.resolve(Li);
|
|
4958
5065
|
let t = function(e) {
|
|
4959
|
-
let t =
|
|
5066
|
+
let t = Ni(e);
|
|
4960
5067
|
if (t && t.apiResponse && t.apiResponseExpiry && Date.now() <= t.apiResponseExpiry) return t.apiResponse;
|
|
4961
5068
|
}(e);
|
|
4962
5069
|
if (t) return Promise.resolve(t);
|
|
4963
|
-
if (
|
|
5070
|
+
if (Ii) return Ii;
|
|
4964
5071
|
}
|
|
4965
|
-
let n = e.api_endpoint ||
|
|
5072
|
+
let n = e.api_endpoint || zr, r;
|
|
4966
5073
|
try {
|
|
4967
5074
|
let e = new URL(n);
|
|
4968
5075
|
r = e.pathname !== "/" || n.endsWith("/") ? n : `${e.origin}/thumbmark`;
|
|
@@ -4971,15 +5078,15 @@ var Di = (e, t) => {
|
|
|
4971
5078
|
}
|
|
4972
5079
|
let i = function(e) {
|
|
4973
5080
|
try {
|
|
4974
|
-
let t =
|
|
4975
|
-
return n || t ===
|
|
5081
|
+
let t = ki(e), n = localStorage.getItem(t);
|
|
5082
|
+
return n || t === Ai || (n = localStorage.getItem(Ai), n && ji(n, e)), n;
|
|
4976
5083
|
} catch {
|
|
4977
5084
|
return null;
|
|
4978
5085
|
}
|
|
4979
5086
|
}(e), { api_key: a, ...o } = e, s = {
|
|
4980
5087
|
components: t,
|
|
4981
5088
|
options: o,
|
|
4982
|
-
clientHash:
|
|
5089
|
+
clientHash: $(gi(t)),
|
|
4983
5090
|
version: "1.11.0"
|
|
4984
5091
|
};
|
|
4985
5092
|
if (i && (s.visitorId = i), e.metadata) {
|
|
@@ -4990,25 +5097,25 @@ var Di = (e, t) => {
|
|
|
4990
5097
|
for (let i = 0; i < 3; i++) {
|
|
4991
5098
|
i > 0 && await new Promise(((e) => setTimeout(e, 200 * i)));
|
|
4992
5099
|
try {
|
|
4993
|
-
return await
|
|
5100
|
+
return await Ri(e, t, n, r);
|
|
4994
5101
|
} catch (e) {
|
|
4995
|
-
if (e instanceof
|
|
5102
|
+
if (e instanceof Fi || i === 2) throw e;
|
|
4996
5103
|
}
|
|
4997
5104
|
}
|
|
4998
5105
|
throw Error("Unreachable");
|
|
4999
5106
|
}(r, s, e, i).finally((() => {
|
|
5000
|
-
|
|
5107
|
+
Ii = null;
|
|
5001
5108
|
})), u = new Promise(((t) => {
|
|
5002
5109
|
setTimeout((() => {
|
|
5003
|
-
t(
|
|
5110
|
+
t(Ni(e)?.apiResponse || {
|
|
5004
5111
|
info: { timed_out: !0 },
|
|
5005
5112
|
...i && { visitorId: i }
|
|
5006
5113
|
});
|
|
5007
5114
|
}), c);
|
|
5008
5115
|
}));
|
|
5009
|
-
return
|
|
5116
|
+
return Ii = Promise.race([l, u]), Ii;
|
|
5010
5117
|
};
|
|
5011
|
-
async function
|
|
5118
|
+
async function Bi(e, t = {}) {
|
|
5012
5119
|
var n;
|
|
5013
5120
|
if (typeof document > "u" || typeof window > "u") return {
|
|
5014
5121
|
thumbmark: "",
|
|
@@ -5022,19 +5129,19 @@ async function Oi(e, t = {}) {
|
|
|
5022
5129
|
};
|
|
5023
5130
|
try {
|
|
5024
5131
|
let r = {
|
|
5025
|
-
...
|
|
5132
|
+
...Br,
|
|
5026
5133
|
...e
|
|
5027
|
-
}, i = [], a = r.logging && !sessionStorage.getItem("_tmjs_l") && Math.random() < 1e-4, { elapsed: o, resolvedComponents: s, errors: c, pipelineTimings: l } = await
|
|
5028
|
-
...
|
|
5029
|
-
...
|
|
5134
|
+
}, i = [], a = r.logging && !sessionStorage.getItem("_tmjs_l") && Math.random() < 1e-4, { elapsed: o, resolvedComponents: s, errors: c, pipelineTimings: l } = await Vi({
|
|
5135
|
+
..._i,
|
|
5136
|
+
...vi,
|
|
5030
5137
|
...t
|
|
5031
5138
|
}, r);
|
|
5032
5139
|
i.push(...c);
|
|
5033
|
-
let u = r.api_key || r.simple_request ?
|
|
5140
|
+
let u = r.api_key || r.simple_request ? zi(r, s) : null, d = null;
|
|
5034
5141
|
if (u) try {
|
|
5035
5142
|
d = await u;
|
|
5036
5143
|
} catch (e) {
|
|
5037
|
-
if (e instanceof
|
|
5144
|
+
if (e instanceof Fi && e.status === 403) return {
|
|
5038
5145
|
error: [{
|
|
5039
5146
|
type: "api_unauthorized",
|
|
5040
5147
|
message: "Invalid API key or quota exceeded"
|
|
@@ -5045,7 +5152,7 @@ async function Oi(e, t = {}) {
|
|
|
5045
5152
|
thumbmark: ""
|
|
5046
5153
|
};
|
|
5047
5154
|
i.push({
|
|
5048
|
-
type: e instanceof
|
|
5155
|
+
type: e instanceof Fi ? "api_error" : "network_error",
|
|
5049
5156
|
message: e instanceof Error ? e.message : String(e)
|
|
5050
5157
|
});
|
|
5051
5158
|
}
|
|
@@ -5053,24 +5160,24 @@ async function Oi(e, t = {}) {
|
|
|
5053
5160
|
type: "api_timeout",
|
|
5054
5161
|
message: "API request timed out"
|
|
5055
5162
|
});
|
|
5056
|
-
let f = performance.now(), p =
|
|
5163
|
+
let f = performance.now(), p = xi(d?.components || {}, r), m = performance.now() - f, h = {
|
|
5057
5164
|
...s,
|
|
5058
5165
|
...p
|
|
5059
5166
|
}, g = d?.info || { uniqueness: { score: "api only" } }, _, v = 0, y = 0;
|
|
5060
5167
|
if (d?.thumbmark) _ = d.thumbmark;
|
|
5061
5168
|
else {
|
|
5062
|
-
let e = performance.now(), t =
|
|
5169
|
+
let e = performance.now(), t = gi(h);
|
|
5063
5170
|
v = performance.now() - e;
|
|
5064
5171
|
let n = performance.now();
|
|
5065
|
-
_ =
|
|
5172
|
+
_ = $(t), y = performance.now() - n;
|
|
5066
5173
|
}
|
|
5067
5174
|
a && async function(e, t, n, r = []) {
|
|
5068
|
-
let i = `${
|
|
5175
|
+
let i = `${zr}/log`;
|
|
5069
5176
|
sessionStorage.setItem("_tmjs_l", "1");
|
|
5070
5177
|
let a = {
|
|
5071
5178
|
thumbmark: e,
|
|
5072
5179
|
components: t,
|
|
5073
|
-
experimental: await
|
|
5180
|
+
experimental: await Di(),
|
|
5074
5181
|
version: "1.11.0",
|
|
5075
5182
|
options: n,
|
|
5076
5183
|
path: (window == null ? void 0 : window.location)?.pathname,
|
|
@@ -5120,11 +5227,11 @@ async function Oi(e, t = {}) {
|
|
|
5120
5227
|
};
|
|
5121
5228
|
}
|
|
5122
5229
|
}
|
|
5123
|
-
async function
|
|
5230
|
+
async function Vi(e, t) {
|
|
5124
5231
|
let n = {
|
|
5125
|
-
...
|
|
5232
|
+
...Br,
|
|
5126
5233
|
...t
|
|
5127
|
-
}, r =
|
|
5234
|
+
}, r = bi(n).filter(((e) => !e.includes("."))), i = Object.entries(e).filter((([e]) => !(n?.exclude)?.includes(e))).filter((([e]) => !r.includes(e))).filter((([e]) => (n?.include)?.some(((e) => e.includes("."))) ? (n?.include)?.some(((t) => t.startsWith(e))) : n?.include?.length === 0 || (n?.include)?.includes(e))), a = i.map((([e]) => e)), o = {}, s = performance.now(), c = i.map((([e, n]) => {
|
|
5128
5235
|
let r = performance.now(), i = n(t);
|
|
5129
5236
|
return o[`_dispatch.${e}`] = performance.now() - r, i;
|
|
5130
5237
|
})), l = performance.now() - s, u = performance.now(), d = await function(e, t, n) {
|
|
@@ -5147,7 +5254,7 @@ async function ki(e, t) {
|
|
|
5147
5254
|
}));
|
|
5148
5255
|
return Promise.race([a, o]);
|
|
5149
5256
|
})));
|
|
5150
|
-
}(c, n?.timeout || 5e3,
|
|
5257
|
+
}(c, n?.timeout || 5e3, yi), f = performance.now() - u, p = {}, m = {}, h = [];
|
|
5151
5258
|
d.forEach(((e, t) => {
|
|
5152
5259
|
let n = a[t];
|
|
5153
5260
|
p[n] = e.elapsed ?? 0, e.error === "timeout" ? h.push({
|
|
@@ -5163,7 +5270,7 @@ async function ki(e, t) {
|
|
|
5163
5270
|
let g = performance.now();
|
|
5164
5271
|
return {
|
|
5165
5272
|
elapsed: p,
|
|
5166
|
-
resolvedComponents:
|
|
5273
|
+
resolvedComponents: xi(m, n),
|
|
5167
5274
|
errors: h,
|
|
5168
5275
|
pipelineTimings: {
|
|
5169
5276
|
"_pipeline.dispatch": l,
|
|
@@ -5173,12 +5280,12 @@ async function ki(e, t) {
|
|
|
5173
5280
|
}
|
|
5174
5281
|
};
|
|
5175
5282
|
}
|
|
5176
|
-
async function
|
|
5177
|
-
return (await
|
|
5283
|
+
async function Hi() {
|
|
5284
|
+
return (await Bi(Vr)).components;
|
|
5178
5285
|
}
|
|
5179
|
-
async function
|
|
5286
|
+
async function Ui(e) {
|
|
5180
5287
|
try {
|
|
5181
|
-
let t = await
|
|
5288
|
+
let t = await Bi(Vr);
|
|
5182
5289
|
return e ? {
|
|
5183
5290
|
hash: t.thumbmark.toString(),
|
|
5184
5291
|
data: t.components
|
|
@@ -5189,15 +5296,15 @@ async function ji(e) {
|
|
|
5189
5296
|
}
|
|
5190
5297
|
//#endregion
|
|
5191
5298
|
//#region src/libraries/urql/UrqlClientWrapper.js
|
|
5192
|
-
var
|
|
5193
|
-
function
|
|
5299
|
+
var Wi = "query ( $Hash: String! ) { CipherHash ( Hash: $Hash ) { hash } }";
|
|
5300
|
+
function Gi(e) {
|
|
5194
5301
|
let t = (e || "").match(/\b(query|mutation|subscription)\b/i), n = t ? t[1].toLowerCase() : "query", r = (e || "").indexOf("{"), i = r >= 0 ? e.slice(r + 1).match(/[A-Za-z_][A-Za-z0-9_]*/) : null;
|
|
5195
5302
|
return {
|
|
5196
5303
|
type: n,
|
|
5197
5304
|
name: i ? i[0] : ""
|
|
5198
5305
|
};
|
|
5199
5306
|
}
|
|
5200
|
-
var
|
|
5307
|
+
var Ki = class {
|
|
5201
5308
|
constructor({ serverUri: e, socket: t = null, encrypt: n = !1 }) {
|
|
5202
5309
|
this.$__client = this.createUrqlClient({
|
|
5203
5310
|
serverUri: e,
|
|
@@ -5232,7 +5339,7 @@ var Pi = class {
|
|
|
5232
5339
|
} catch {
|
|
5233
5340
|
return !1;
|
|
5234
5341
|
}
|
|
5235
|
-
let { type: n, name: r } =
|
|
5342
|
+
let { type: n, name: r } = Gi(t.query);
|
|
5236
5343
|
return !(n === "query" && (r === "__schema" || r === "ContinuId") || n === "mutation" && r === "AccessToken" || n === "mutation" && r === "ProposeMolecule" && (t.variables && t.variables.molecule && t.variables.molecule.atoms && t.variables.molecule.atoms[0] && t.variables.molecule.atoms[0].isotope) === "U");
|
|
5237
5344
|
}
|
|
5238
5345
|
async cipherFetch(e, t) {
|
|
@@ -5242,7 +5349,7 @@ var Pi = class {
|
|
|
5242
5349
|
a = {
|
|
5243
5350
|
...t,
|
|
5244
5351
|
body: JSON.stringify({
|
|
5245
|
-
query:
|
|
5352
|
+
query: Wi,
|
|
5246
5353
|
variables: { Hash: e }
|
|
5247
5354
|
})
|
|
5248
5355
|
}, i = !0;
|
|
@@ -5362,7 +5469,7 @@ var Pi = class {
|
|
|
5362
5469
|
encrypt: !!this.cipherLink
|
|
5363
5470
|
});
|
|
5364
5471
|
}
|
|
5365
|
-
},
|
|
5472
|
+
}, qi = class {
|
|
5366
5473
|
constructor({ uri: e, cellSlug: t = null, client: n = null, socket: r = null, serverSdkVersion: i = 3, logging: a = !1, defaultRequestPolicy: o = null, secretStorage: s = null, mlKemParameterSet: c = 1024 }) {
|
|
5367
5474
|
this.initialize({
|
|
5368
5475
|
uri: e,
|
|
@@ -5382,7 +5489,7 @@ var Pi = class {
|
|
|
5382
5489
|
let t = this.$__uris[e];
|
|
5383
5490
|
this.$__authTokenObjects[t] = null;
|
|
5384
5491
|
}
|
|
5385
|
-
this.log("info", `KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${i}...`), this.$__client = r || new
|
|
5492
|
+
this.log("info", `KnishIOClient::initialize() - Initializing new Knish.IO client session for SDK version ${i}...`), this.$__client = r || new Ki({
|
|
5386
5493
|
socket: {
|
|
5387
5494
|
socketUri: null,
|
|
5388
5495
|
appKey: "knishio",
|
|
@@ -5410,7 +5517,7 @@ var Pi = class {
|
|
|
5410
5517
|
this.log("info", "KnishIOClient::deinitialize() - Clearing the Knish.IO client session..."), this.reset();
|
|
5411
5518
|
}
|
|
5412
5519
|
subscribe() {
|
|
5413
|
-
if (!this.client().getSocketUri()) throw new
|
|
5520
|
+
if (!this.client().getSocketUri()) throw new L("KnishIOClient::subscribe() - Socket client not initialized!");
|
|
5414
5521
|
return this.client();
|
|
5415
5522
|
}
|
|
5416
5523
|
getServerSdkVersion() {
|
|
@@ -5467,15 +5574,15 @@ var Pi = class {
|
|
|
5467
5574
|
setSecret(e) {
|
|
5468
5575
|
if (this.$__secret = e, this.$__bundle = this.hashSecret(e, "setSecret"), this.$__secretStorage) this.$__secretStorage.storeSecret(this.$__bundle, e);
|
|
5469
5576
|
else {
|
|
5470
|
-
let t = new
|
|
5577
|
+
let t = new Sn();
|
|
5471
5578
|
t.storeSecret(this.$__bundle, e), this.$__secretStorage = t;
|
|
5472
5579
|
}
|
|
5473
5580
|
}
|
|
5474
5581
|
hashSecret(e, t = null) {
|
|
5475
|
-
return this.log("info", `KnishIOClient::hashSecret(${t ? `source: ${t}` : ""}) - Computing wallet bundle from secret...`),
|
|
5582
|
+
return this.log("info", `KnishIOClient::hashSecret(${t ? `source: ${t}` : ""}) - Computing wallet bundle from secret...`), se(e);
|
|
5476
5583
|
}
|
|
5477
5584
|
getSecret() {
|
|
5478
|
-
if (!this.hasSecret()) throw new
|
|
5585
|
+
if (!this.hasSecret()) throw new Tn("KnishIOClient::getSecret() - Unable to find a stored secret! Have you set a secret?");
|
|
5479
5586
|
return this.$__secret;
|
|
5480
5587
|
}
|
|
5481
5588
|
setSecretStorage(e, t = null) {
|
|
@@ -5491,22 +5598,22 @@ var Pi = class {
|
|
|
5491
5598
|
return !!this.$__bundle;
|
|
5492
5599
|
}
|
|
5493
5600
|
getBundle() {
|
|
5494
|
-
if (!this.hasBundle()) throw new
|
|
5601
|
+
if (!this.hasBundle()) throw new Tn("KnishIOClient::getBundle() - Unable to find a stored bundle! Have you set a secret?");
|
|
5495
5602
|
return this.$__bundle;
|
|
5496
5603
|
}
|
|
5497
5604
|
getFingerprint() {
|
|
5498
|
-
return
|
|
5605
|
+
return Ui();
|
|
5499
5606
|
}
|
|
5500
5607
|
getFingerprintData() {
|
|
5501
|
-
return
|
|
5608
|
+
return Hi();
|
|
5502
5609
|
}
|
|
5503
5610
|
async getSourceWallet() {
|
|
5504
5611
|
let e = (await this.queryContinuId({ bundle: this.getBundle() })).payload();
|
|
5505
|
-
return e ? e.key =
|
|
5612
|
+
return e ? e.key = N.generateKey({
|
|
5506
5613
|
secret: this.getSecret(),
|
|
5507
5614
|
token: e.token,
|
|
5508
5615
|
position: e.position
|
|
5509
|
-
}) : e = new
|
|
5616
|
+
}) : e = new N({
|
|
5510
5617
|
secret: this.getSecret(),
|
|
5511
5618
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
5512
5619
|
}), e;
|
|
@@ -5524,14 +5631,14 @@ var Pi = class {
|
|
|
5524
5631
|
i = e ? e.position : null;
|
|
5525
5632
|
}
|
|
5526
5633
|
}
|
|
5527
|
-
return !n && this.lastMoleculeQuery && this.getRemainderWallet().token === "USER" && this.lastMoleculeQuery.response() && this.lastMoleculeQuery.response().success() && (n = this.getRemainderWallet()), n === null && (n = await this.getSourceWallet()), this.remainderWallet = r ||
|
|
5634
|
+
return !n && this.lastMoleculeQuery && this.getRemainderWallet().token === "USER" && this.lastMoleculeQuery.response() && this.lastMoleculeQuery.response().success() && (n = this.getRemainderWallet()), n === null && (n = await this.getSourceWallet()), this.remainderWallet = r || N.create({
|
|
5528
5635
|
secret: e,
|
|
5529
5636
|
bundle: t,
|
|
5530
5637
|
token: "USER",
|
|
5531
5638
|
batchId: n.batchId,
|
|
5532
5639
|
characters: n.characters,
|
|
5533
5640
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
5534
|
-
}), new
|
|
5641
|
+
}), new ln({
|
|
5535
5642
|
secret: e,
|
|
5536
5643
|
bundle: t,
|
|
5537
5644
|
sourceWallet: n,
|
|
@@ -5551,7 +5658,7 @@ var Pi = class {
|
|
|
5551
5658
|
async createMoleculeMutation({ mutationClass: e, molecule: t = null }) {
|
|
5552
5659
|
this.log("info", `KnishIOClient::createMoleculeQuery() - Creating a new ${e.name} query...`);
|
|
5553
5660
|
let n = t || await this.createMolecule({}), r = new e(this.client(), this, n);
|
|
5554
|
-
if (!(r instanceof
|
|
5661
|
+
if (!(r instanceof X)) throw new L(`${this.constructor.name}::createMoleculeMutation() - This method only accepts MutationProposeMolecule!`);
|
|
5555
5662
|
return this.lastMoleculeQuery = r, r;
|
|
5556
5663
|
}
|
|
5557
5664
|
async executeQuery(e, t = null, n = {}) {
|
|
@@ -5597,7 +5704,7 @@ var Pi = class {
|
|
|
5597
5704
|
this.abortControllers.clear();
|
|
5598
5705
|
}
|
|
5599
5706
|
async queryBalance({ token: e, bundle: t = null, type: n = "regular" }) {
|
|
5600
|
-
let r = this.createQuery(
|
|
5707
|
+
let r = this.createQuery(Nn);
|
|
5601
5708
|
return this.executeQuery(r, {
|
|
5602
5709
|
bundleHash: t || this.getBundle(),
|
|
5603
5710
|
token: e,
|
|
@@ -5609,19 +5716,19 @@ var Pi = class {
|
|
|
5609
5716
|
token: e,
|
|
5610
5717
|
type: n
|
|
5611
5718
|
})).payload();
|
|
5612
|
-
if (r === null ||
|
|
5613
|
-
if (!r.position || !r.address) throw new
|
|
5719
|
+
if (r === null || wn.cmp(r.balance, t) < 0) throw new P();
|
|
5720
|
+
if (!r.position || !r.address) throw new P("Source wallet can not be a shadow wallet.");
|
|
5614
5721
|
return r;
|
|
5615
5722
|
}
|
|
5616
5723
|
async subscribeCreateMolecule({ bundle: e, closure: t }) {
|
|
5617
|
-
return await this.createSubscribe(
|
|
5724
|
+
return await this.createSubscribe(pr).execute({
|
|
5618
5725
|
variables: { bundle: e || this.getBundle() },
|
|
5619
5726
|
closure: t
|
|
5620
5727
|
});
|
|
5621
5728
|
}
|
|
5622
5729
|
subscribeWalletStatus({ bundle: e, token: t, closure: n }) {
|
|
5623
|
-
if (!t) throw new
|
|
5624
|
-
return this.createSubscribe(
|
|
5730
|
+
if (!t) throw new L(`${this.constructor.name}::subscribeWalletStatus() - Token parameter is required!`);
|
|
5731
|
+
return this.createSubscribe(mr).execute({
|
|
5625
5732
|
variables: {
|
|
5626
5733
|
bundle: e || this.getBundle(),
|
|
5627
5734
|
token: t
|
|
@@ -5630,13 +5737,13 @@ var Pi = class {
|
|
|
5630
5737
|
});
|
|
5631
5738
|
}
|
|
5632
5739
|
subscribeActiveWallet({ bundle: e, closure: t }) {
|
|
5633
|
-
return this.createSubscribe(
|
|
5740
|
+
return this.createSubscribe(hr).execute({
|
|
5634
5741
|
variables: { bundle: e || this.getBundle() },
|
|
5635
5742
|
closure: t
|
|
5636
5743
|
});
|
|
5637
5744
|
}
|
|
5638
5745
|
subscribeActiveSession({ metaType: e, metaId: t, closure: n }) {
|
|
5639
|
-
return this.createSubscribe(
|
|
5746
|
+
return this.createSubscribe(gr).execute({
|
|
5640
5747
|
variables: {
|
|
5641
5748
|
metaType: e,
|
|
5642
5749
|
metaId: t
|
|
@@ -5653,7 +5760,7 @@ var Pi = class {
|
|
|
5653
5760
|
queryMeta({ metaType: e, metaId: t = null, key: n = null, value: r = null, latest: i = !0, fields: a = null, filter: o = null, queryArgs: s = null, count: c = null, countBy: l = null, throughAtom: u = !0, throughMolecule: d = !1, values: f = null, keys: p = null, atomValues: m = null, requestPolicy: h = null }) {
|
|
5654
5761
|
this.log("info", `KnishIOClient::queryMeta() - Querying metaType: ${e}, metaId: ${t}...`);
|
|
5655
5762
|
let g, _;
|
|
5656
|
-
return d ? (g = this.createQuery(
|
|
5763
|
+
return d ? (g = this.createQuery(Ar), _ = Ar.createVariables({
|
|
5657
5764
|
metaType: e,
|
|
5658
5765
|
metaId: t,
|
|
5659
5766
|
key: n,
|
|
@@ -5666,7 +5773,7 @@ var Pi = class {
|
|
|
5666
5773
|
keys: p,
|
|
5667
5774
|
atomValues: m,
|
|
5668
5775
|
cellSlug: this.getCellSlug()
|
|
5669
|
-
})) : u ? (g = this.createQuery(
|
|
5776
|
+
})) : u ? (g = this.createQuery(Or), _ = Or.createVariables({
|
|
5670
5777
|
metaType: e,
|
|
5671
5778
|
metaId: t,
|
|
5672
5779
|
key: n,
|
|
@@ -5679,7 +5786,7 @@ var Pi = class {
|
|
|
5679
5786
|
keys: p,
|
|
5680
5787
|
atomValues: m,
|
|
5681
5788
|
cellSlug: this.getCellSlug()
|
|
5682
|
-
})) : (g = this.createQuery(
|
|
5789
|
+
})) : (g = this.createQuery(Fn), _ = Fn.createVariables({
|
|
5683
5790
|
metaType: e,
|
|
5684
5791
|
metaId: t,
|
|
5685
5792
|
key: n,
|
|
@@ -5711,7 +5818,7 @@ var Pi = class {
|
|
|
5711
5818
|
}
|
|
5712
5819
|
async queryEmbeddingStatus({ metaType: e = null, metaId: t = null, instances: n = null }) {
|
|
5713
5820
|
if (this.log("info", `KnishIOClient::queryEmbeddingStatus() - Checking embedding status for metaType: ${e || "(bulk)"}...`), !await this.hasQueryField("embeddingStatus")) return this.log("warn", "KnishIOClient::queryEmbeddingStatus() - Server does not support embeddingStatus query. Returning null."), null;
|
|
5714
|
-
let r = this.createQuery(
|
|
5821
|
+
let r = this.createQuery(Mr), i = Mr.createVariables({
|
|
5715
5822
|
metaType: e,
|
|
5716
5823
|
metaId: t,
|
|
5717
5824
|
instances: n
|
|
@@ -5720,12 +5827,12 @@ var Pi = class {
|
|
|
5720
5827
|
}
|
|
5721
5828
|
async queryBatch({ batchId: e }) {
|
|
5722
5829
|
this.log("info", `KnishIOClient::queryBatch() - Querying cascading meta instances for batchId: ${e}...`);
|
|
5723
|
-
let t = this.createQuery(
|
|
5830
|
+
let t = this.createQuery(In);
|
|
5724
5831
|
return await this.executeQuery(t, { batchId: e });
|
|
5725
5832
|
}
|
|
5726
5833
|
async queryBatchHistory({ batchId: e }) {
|
|
5727
5834
|
this.log("info", `KnishIOClient::queryBatchHistory() - Querying cascading meta instances for batchId: ${e}...`);
|
|
5728
|
-
let t = this.createQuery(
|
|
5835
|
+
let t = this.createQuery(Ln);
|
|
5729
5836
|
return await this.executeQuery(t, { batchId: e });
|
|
5730
5837
|
}
|
|
5731
5838
|
async queryAtom({ molecularHashes: e, molecularHash: t, bundleHashes: n, bundleHash: r, positions: i, position: a, walletAddresses: o, walletAddress: s, isotopes: c, isotope: l, tokenSlugs: u, tokenSlug: d, cellSlugs: f, cellSlug: p, batchIds: m, batchId: h, values: g, value: _, metaTypes: v, metaType: y, metaIds: b, metaId: ee, indexes: te, index: ne, filter: x, latest: re, queryArgs: S = {
|
|
@@ -5733,8 +5840,8 @@ var Pi = class {
|
|
|
5733
5840
|
offset: 1
|
|
5734
5841
|
} }) {
|
|
5735
5842
|
this.log("info", "KnishIOClient::queryAtom() - Querying atom instances");
|
|
5736
|
-
let C = this.createQuery(
|
|
5737
|
-
return await this.executeQuery(C,
|
|
5843
|
+
let C = this.createQuery(wr);
|
|
5844
|
+
return await this.executeQuery(C, wr.createVariables({
|
|
5738
5845
|
molecularHashes: e,
|
|
5739
5846
|
molecularHash: t,
|
|
5740
5847
|
bundleHashes: n,
|
|
@@ -5765,15 +5872,15 @@ var Pi = class {
|
|
|
5765
5872
|
}));
|
|
5766
5873
|
}
|
|
5767
5874
|
async createWallet({ token: e }) {
|
|
5768
|
-
let t = new
|
|
5875
|
+
let t = new N({
|
|
5769
5876
|
secret: this.getSecret(),
|
|
5770
5877
|
token: e,
|
|
5771
5878
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
5772
|
-
}), n = await this.createMoleculeMutation({ mutationClass:
|
|
5879
|
+
}), n = await this.createMoleculeMutation({ mutationClass: or });
|
|
5773
5880
|
return n.fillMolecule(t), await this.executeQuery(n);
|
|
5774
5881
|
}
|
|
5775
5882
|
async queryActiveSession({ bundleHash: e, metaType: t, metaId: n }) {
|
|
5776
|
-
let r = this.createQuery(
|
|
5883
|
+
let r = this.createQuery(br);
|
|
5777
5884
|
return await this.executeQuery(r, {
|
|
5778
5885
|
bundleHash: e,
|
|
5779
5886
|
metaType: t,
|
|
@@ -5781,7 +5888,7 @@ var Pi = class {
|
|
|
5781
5888
|
});
|
|
5782
5889
|
}
|
|
5783
5890
|
async activeSession({ bundle: e, metaType: t, metaId: n, ipAddress: r, browser: i, osCpu: a, resolution: o, timeZone: s, json: c = {} }) {
|
|
5784
|
-
let l = this.createQuery(
|
|
5891
|
+
let l = this.createQuery(vr);
|
|
5785
5892
|
return await this.executeQuery(l, {
|
|
5786
5893
|
bundleHash: e,
|
|
5787
5894
|
metaType: t,
|
|
@@ -5795,19 +5902,19 @@ var Pi = class {
|
|
|
5795
5902
|
});
|
|
5796
5903
|
}
|
|
5797
5904
|
async createToken({ token: e, amount: t = null, meta: n = null, batchId: r = null, units: i = [] }) {
|
|
5798
|
-
let a =
|
|
5799
|
-
if (a === "stackable" && (n.batchId = r ||
|
|
5800
|
-
if (
|
|
5801
|
-
if (t > 0) throw new
|
|
5905
|
+
let a = R.get(n || {}, "fungibility");
|
|
5906
|
+
if (a === "stackable" && (n.batchId = r || le({})), ["nonfungible", "stackable"].includes(a) && i.length > 0) {
|
|
5907
|
+
if (R.get(n || {}, "decimals") > 0) throw new ur();
|
|
5908
|
+
if (t > 0) throw new dr();
|
|
5802
5909
|
t = i.length, n.splittable = 1, n.decimals = 0, n.tokenUnits = JSON.stringify(i);
|
|
5803
5910
|
}
|
|
5804
|
-
let o = new
|
|
5911
|
+
let o = new N({
|
|
5805
5912
|
secret: this.getSecret(),
|
|
5806
5913
|
bundle: this.getBundle(),
|
|
5807
5914
|
token: e,
|
|
5808
5915
|
batchId: r,
|
|
5809
5916
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
5810
|
-
}), s = await this.createMoleculeMutation({ mutationClass:
|
|
5917
|
+
}), s = await this.createMoleculeMutation({ mutationClass: Hn });
|
|
5811
5918
|
return s.fillMolecule({
|
|
5812
5919
|
recipientWallet: o,
|
|
5813
5920
|
amount: t,
|
|
@@ -5816,7 +5923,7 @@ var Pi = class {
|
|
|
5816
5923
|
}
|
|
5817
5924
|
async createRule({ metaType: e, metaId: t, rule: n, policy: r = {} }) {
|
|
5818
5925
|
let i = await this.createMoleculeMutation({
|
|
5819
|
-
mutationClass:
|
|
5926
|
+
mutationClass: Pr,
|
|
5820
5927
|
molecule: await this.createMolecule({ secret: this.getSecret() })
|
|
5821
5928
|
});
|
|
5822
5929
|
return i.fillMolecule({
|
|
@@ -5828,7 +5935,7 @@ var Pi = class {
|
|
|
5828
5935
|
}
|
|
5829
5936
|
async createMeta({ metaType: e, metaId: t, meta: n = null, policy: r = {} }) {
|
|
5830
5937
|
let i = await this.createMoleculeMutation({
|
|
5831
|
-
mutationClass:
|
|
5938
|
+
mutationClass: Qn,
|
|
5832
5939
|
molecule: await this.createMolecule({ secret: this.getSecret() })
|
|
5833
5940
|
}), a = n || {};
|
|
5834
5941
|
return i.fillMolecule({
|
|
@@ -5840,14 +5947,14 @@ var Pi = class {
|
|
|
5840
5947
|
}
|
|
5841
5948
|
async registerPeer({ host: e }) {
|
|
5842
5949
|
let t = await this.createMoleculeMutation({
|
|
5843
|
-
mutationClass:
|
|
5950
|
+
mutationClass: er,
|
|
5844
5951
|
molecule: await this.createMolecule({ secret: this.getSecret() })
|
|
5845
5952
|
});
|
|
5846
5953
|
return t.fillMolecule({ host: e }), await this.executeQuery(t);
|
|
5847
5954
|
}
|
|
5848
5955
|
async appendRequest({ metaType: e, metaId: t, action: n, meta: r = {} }) {
|
|
5849
5956
|
let i = await this.createMoleculeMutation({
|
|
5850
|
-
mutationClass:
|
|
5957
|
+
mutationClass: nr,
|
|
5851
5958
|
molecule: await this.createMolecule({ secret: this.getSecret() })
|
|
5852
5959
|
});
|
|
5853
5960
|
return i.fillMolecule({
|
|
@@ -5858,7 +5965,7 @@ var Pi = class {
|
|
|
5858
5965
|
}), await this.executeQuery(i);
|
|
5859
5966
|
}
|
|
5860
5967
|
async createIdentifier({ type: e, contact: t, code: n }) {
|
|
5861
|
-
let r = await this.createMoleculeMutation({ mutationClass:
|
|
5968
|
+
let r = await this.createMoleculeMutation({ mutationClass: Jn });
|
|
5862
5969
|
return r.fillMolecule({
|
|
5863
5970
|
type: e,
|
|
5864
5971
|
contact: t,
|
|
@@ -5866,7 +5973,7 @@ var Pi = class {
|
|
|
5866
5973
|
}), await this.executeQuery(r);
|
|
5867
5974
|
}
|
|
5868
5975
|
async linkIdentifier({ type: e, contact: t }) {
|
|
5869
|
-
let n = this.createQuery(
|
|
5976
|
+
let n = this.createQuery(ir);
|
|
5870
5977
|
return await this.executeQuery(n, {
|
|
5871
5978
|
bundle: this.getBundle(),
|
|
5872
5979
|
type: e,
|
|
@@ -5882,13 +5989,13 @@ var Pi = class {
|
|
|
5882
5989
|
policy: n
|
|
5883
5990
|
}), r.addContinuIdAtom(), r.sign({ bundle: this.getBundle() }), r.check();
|
|
5884
5991
|
let i = await this.createMoleculeMutation({
|
|
5885
|
-
mutationClass:
|
|
5992
|
+
mutationClass: X,
|
|
5886
5993
|
molecule: r
|
|
5887
5994
|
});
|
|
5888
5995
|
return await this.executeQuery(i);
|
|
5889
5996
|
}
|
|
5890
5997
|
async queryPolicy({ metaType: e, metaId: t }) {
|
|
5891
|
-
let n = this.createQuery(
|
|
5998
|
+
let n = this.createQuery(Er);
|
|
5892
5999
|
return await this.executeQuery(n, {
|
|
5893
6000
|
metaType: e,
|
|
5894
6001
|
metaId: t
|
|
@@ -5896,7 +6003,7 @@ var Pi = class {
|
|
|
5896
6003
|
}
|
|
5897
6004
|
queryWallets({ bundle: e = null, token: t = null, unspent: n = !0 }) {
|
|
5898
6005
|
this.log("info", `KnishIOClient::queryWallets() - Querying wallets${e ? ` for ${e}` : ""}...`);
|
|
5899
|
-
let r = this.createQuery(
|
|
6006
|
+
let r = this.createQuery(jn);
|
|
5900
6007
|
return this.executeQuery(r, {
|
|
5901
6008
|
bundleHash: e || this.getBundle(),
|
|
5902
6009
|
token: t,
|
|
@@ -5905,28 +6012,28 @@ var Pi = class {
|
|
|
5905
6012
|
}
|
|
5906
6013
|
queryBundle({ bundle: e = null, fields: t = null, raw: n = !1 }) {
|
|
5907
6014
|
this.log("info", `KnishIOClient::queryBundle() - Querying wallet bundle metadata${e ? ` for ${e}` : ""}...`), e ||= this.getBundle(), typeof e == "string" && (e = [e]);
|
|
5908
|
-
let r = this.createQuery(
|
|
6015
|
+
let r = this.createQuery(kn);
|
|
5909
6016
|
return this.executeQuery(r, { bundleHashes: e }).then((e) => n ? e : e.payload());
|
|
5910
6017
|
}
|
|
5911
6018
|
async queryContinuId({ bundle: e }) {
|
|
5912
|
-
let t = this.createQuery(
|
|
6019
|
+
let t = this.createQuery(Dn);
|
|
5913
6020
|
return this.executeQuery(t, { bundle: e });
|
|
5914
6021
|
}
|
|
5915
6022
|
async requestTokens({ token: e, to: t, amount: n = null, units: r = [], meta: i = null, batchId: a = null }) {
|
|
5916
6023
|
let o, s;
|
|
5917
6024
|
i ||= {};
|
|
5918
|
-
let c = this.createQuery(
|
|
5919
|
-
if (!u && a !== null) throw new
|
|
5920
|
-
if (u && a === null && (a =
|
|
5921
|
-
if (n > 0) throw new
|
|
6025
|
+
let c = this.createQuery(xr), l = await this.executeQuery(c, { slug: e }), u = R.get(l.data(), "0.fungibility") === "stackable";
|
|
6026
|
+
if (!u && a !== null) throw new $t("Expected Batch ID = null for non-stackable tokens.");
|
|
6027
|
+
if (u && a === null && (a = le({})), r.length > 0) {
|
|
6028
|
+
if (n > 0) throw new dr();
|
|
5922
6029
|
n = r.length, i.tokenUnits = JSON.stringify(r);
|
|
5923
6030
|
}
|
|
5924
|
-
t ? (Object.prototype.toString.call(t) === "[object String]" && (
|
|
6031
|
+
t ? (Object.prototype.toString.call(t) === "[object String]" && (N.isBundleHash(t) ? (o = "walletBundle", s = t) : t = N.create({
|
|
5925
6032
|
secret: t,
|
|
5926
6033
|
token: e,
|
|
5927
6034
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
5928
|
-
})), t instanceof
|
|
5929
|
-
let d = await this.createMoleculeMutation({ mutationClass:
|
|
6035
|
+
})), t instanceof N && (o = "wallet", i.position = t.position, i.bundle = t.bundle, s = t.address)) : (o = "walletBundle", s = this.getBundle());
|
|
6036
|
+
let d = await this.createMoleculeMutation({ mutationClass: Wn });
|
|
5930
6037
|
return d.fillMolecule({
|
|
5931
6038
|
token: e,
|
|
5932
6039
|
amount: n,
|
|
@@ -5938,7 +6045,7 @@ var Pi = class {
|
|
|
5938
6045
|
}
|
|
5939
6046
|
async claimShadowWallet({ token: e, batchId: t = null, molecule: n = null }) {
|
|
5940
6047
|
let r = await this.createMoleculeMutation({
|
|
5941
|
-
mutationClass:
|
|
6048
|
+
mutationClass: Xn,
|
|
5942
6049
|
molecule: n
|
|
5943
6050
|
});
|
|
5944
6051
|
return r.fillMolecule({
|
|
@@ -5948,9 +6055,9 @@ var Pi = class {
|
|
|
5948
6055
|
}
|
|
5949
6056
|
async claimShadowWallets({ token: e }) {
|
|
5950
6057
|
let t = await this.queryWallets({ token: e });
|
|
5951
|
-
if (!t || !Array.isArray(t)) throw new
|
|
6058
|
+
if (!t || !Array.isArray(t)) throw new lr();
|
|
5952
6059
|
t.forEach((e) => {
|
|
5953
|
-
if (!e.isShadow()) throw new
|
|
6060
|
+
if (!e.isShadow()) throw new lr();
|
|
5954
6061
|
});
|
|
5955
6062
|
let n = [];
|
|
5956
6063
|
for (let r of t) n.push(await this.claimShadowWallet({
|
|
@@ -5961,14 +6068,14 @@ var Pi = class {
|
|
|
5961
6068
|
}
|
|
5962
6069
|
async transferToken({ bundleHash: e, token: t, amount: n = null, units: r = [], batchId: i = null, sourceWallet: a = null }) {
|
|
5963
6070
|
if (r.length > 0) {
|
|
5964
|
-
if (n > 0) throw new
|
|
6071
|
+
if (n > 0) throw new dr();
|
|
5965
6072
|
n = r.length;
|
|
5966
6073
|
}
|
|
5967
6074
|
if (a === null && (a = await this.querySourceWallet({
|
|
5968
6075
|
token: t,
|
|
5969
6076
|
amount: n
|
|
5970
|
-
})), a === null ||
|
|
5971
|
-
let o =
|
|
6077
|
+
})), a === null || wn.cmp(a.balance, n) < 0) throw new P();
|
|
6078
|
+
let o = N.create({
|
|
5972
6079
|
bundle: e,
|
|
5973
6080
|
token: t,
|
|
5974
6081
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
@@ -5980,7 +6087,7 @@ var Pi = class {
|
|
|
5980
6087
|
sourceWallet: a,
|
|
5981
6088
|
remainderWallet: s
|
|
5982
6089
|
}), l = await this.createMoleculeMutation({
|
|
5983
|
-
mutationClass:
|
|
6090
|
+
mutationClass: Kn,
|
|
5984
6091
|
molecule: c
|
|
5985
6092
|
});
|
|
5986
6093
|
return l.fillMolecule({
|
|
@@ -5992,7 +6099,7 @@ var Pi = class {
|
|
|
5992
6099
|
let r = t.map((e) => {
|
|
5993
6100
|
let t = e.units || [];
|
|
5994
6101
|
if (t.length > 0) {
|
|
5995
|
-
if (e.amount > 0) throw new
|
|
6102
|
+
if (e.amount > 0) throw new dr();
|
|
5996
6103
|
return t.length;
|
|
5997
6104
|
}
|
|
5998
6105
|
return e.amount || 0;
|
|
@@ -6000,9 +6107,9 @@ var Pi = class {
|
|
|
6000
6107
|
if (n === null && (n = await this.querySourceWallet({
|
|
6001
6108
|
token: e,
|
|
6002
6109
|
amount: i
|
|
6003
|
-
})), n === null ||
|
|
6110
|
+
})), n === null || wn.cmp(n.balance, i) < 0) throw new P();
|
|
6004
6111
|
let a = t.map((t) => {
|
|
6005
|
-
let r =
|
|
6112
|
+
let r = N.create({
|
|
6006
6113
|
bundle: t.bundleHash,
|
|
6007
6114
|
token: e,
|
|
6008
6115
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
@@ -6014,7 +6121,7 @@ var Pi = class {
|
|
|
6014
6121
|
sourceWallet: n,
|
|
6015
6122
|
remainderWallet: o
|
|
6016
6123
|
}), c = await this.createMoleculeMutation({
|
|
6017
|
-
mutationClass:
|
|
6124
|
+
mutationClass: Kn,
|
|
6018
6125
|
molecule: s
|
|
6019
6126
|
});
|
|
6020
6127
|
return c.fillMoleculeMulti({
|
|
@@ -6031,7 +6138,7 @@ var Pi = class {
|
|
|
6031
6138
|
sourceWallet: r,
|
|
6032
6139
|
remainderWallet: i
|
|
6033
6140
|
}), o = await this.createMoleculeMutation({
|
|
6034
|
-
mutationClass:
|
|
6141
|
+
mutationClass: Fr,
|
|
6035
6142
|
molecule: a
|
|
6036
6143
|
});
|
|
6037
6144
|
return o.fillMolecule({
|
|
@@ -6049,7 +6156,7 @@ var Pi = class {
|
|
|
6049
6156
|
sourceWallet: n,
|
|
6050
6157
|
remainderWallet: i
|
|
6051
6158
|
}), o = await this.createMoleculeMutation({
|
|
6052
|
-
mutationClass:
|
|
6159
|
+
mutationClass: Ir,
|
|
6053
6160
|
molecule: a
|
|
6054
6161
|
}), s = {};
|
|
6055
6162
|
return s[this.getBundle()] = t, o.fillMolecule({
|
|
@@ -6064,7 +6171,7 @@ var Pi = class {
|
|
|
6064
6171
|
}));
|
|
6065
6172
|
let i = r.createRemainder(this.getSecret());
|
|
6066
6173
|
if (n.length > 0) {
|
|
6067
|
-
if (t > 0) throw new
|
|
6174
|
+
if (t > 0) throw new dr();
|
|
6068
6175
|
t = n.length, r.splitUnits(n, i);
|
|
6069
6176
|
}
|
|
6070
6177
|
let a = await this.createMolecule({
|
|
@@ -6073,13 +6180,13 @@ var Pi = class {
|
|
|
6073
6180
|
});
|
|
6074
6181
|
a.burnToken({ amount: t }), a.sign({ bundle: this.getBundle() }), a.check(r);
|
|
6075
6182
|
let o = await this.createMoleculeMutation({
|
|
6076
|
-
mutationClass:
|
|
6183
|
+
mutationClass: X,
|
|
6077
6184
|
molecule: a
|
|
6078
6185
|
});
|
|
6079
6186
|
return this.executeQuery(o);
|
|
6080
6187
|
}
|
|
6081
6188
|
async replenishToken({ token: e, amount: t = null, units: n = [], sourceWallet: r = null }) {
|
|
6082
|
-
if (r === null && (r = (await this.queryBalance({ token: e })).payload()), !r) throw new
|
|
6189
|
+
if (r === null && (r = (await this.queryBalance({ token: e })).payload()), !r) throw new P("Source wallet is missing or invalid.");
|
|
6083
6190
|
let i = r.createRemainder(this.getSecret()), a = await this.createMolecule({
|
|
6084
6191
|
sourceWallet: r,
|
|
6085
6192
|
remainderWallet: i
|
|
@@ -6089,65 +6196,65 @@ var Pi = class {
|
|
|
6089
6196
|
units: n
|
|
6090
6197
|
}), a.sign({ bundle: this.getBundle() }), a.check();
|
|
6091
6198
|
let o = await this.createMoleculeMutation({
|
|
6092
|
-
mutationClass:
|
|
6199
|
+
mutationClass: X,
|
|
6093
6200
|
molecule: a
|
|
6094
6201
|
});
|
|
6095
6202
|
return this.executeQuery(o);
|
|
6096
6203
|
}
|
|
6097
6204
|
async fuseToken({ bundleHash: e, tokenSlug: t, newTokenUnit: n, fusedTokenUnitIds: r, sourceWallet: i = null }) {
|
|
6098
|
-
if (i === null && (i = (await this.queryBalance({ token: t })).payload()), i === null) throw new
|
|
6099
|
-
if (!i.tokenUnits || !i.tokenUnits.length) throw new
|
|
6100
|
-
if (!r.length) throw new
|
|
6205
|
+
if (i === null && (i = (await this.queryBalance({ token: t })).payload()), i === null) throw new P("Source wallet is missing or invalid.");
|
|
6206
|
+
if (!i.tokenUnits || !i.tokenUnits.length) throw new P("Source wallet does not have token units.");
|
|
6207
|
+
if (!r.length) throw new P("Fused token unit list is empty.");
|
|
6101
6208
|
let a = [];
|
|
6102
6209
|
i.tokenUnits.forEach((e) => {
|
|
6103
6210
|
a.push(e.id);
|
|
6104
6211
|
}), r.forEach((e) => {
|
|
6105
|
-
if (!a.includes(e)) throw new
|
|
6212
|
+
if (!a.includes(e)) throw new P(`Fused token unit ID = ${e} does not found in the source wallet.`);
|
|
6106
6213
|
});
|
|
6107
|
-
let o =
|
|
6214
|
+
let o = N.create({
|
|
6108
6215
|
bundle: e,
|
|
6109
6216
|
token: t,
|
|
6110
6217
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
6111
6218
|
});
|
|
6112
6219
|
o.initBatchId({ sourceWallet: i });
|
|
6113
6220
|
let s = i.createRemainder(this.getSecret());
|
|
6114
|
-
i.splitUnits(r, s), typeof n == "string" && (n = new
|
|
6221
|
+
i.splitUnits(r, s), typeof n == "string" && (n = new ue(n, n, {})), n.metas.fusedTokenUnits = i.getTokenUnitsData(), o.tokenUnits = [n];
|
|
6115
6222
|
let c = await this.createMolecule({
|
|
6116
6223
|
sourceWallet: i,
|
|
6117
6224
|
remainderWallet: s
|
|
6118
6225
|
});
|
|
6119
6226
|
c.fuseToken(i.tokenUnits, o), c.sign({ bundle: this.getBundle() }), c.check();
|
|
6120
6227
|
let l = await this.createMoleculeMutation({
|
|
6121
|
-
mutationClass:
|
|
6228
|
+
mutationClass: X,
|
|
6122
6229
|
molecule: c
|
|
6123
6230
|
});
|
|
6124
6231
|
return this.executeQuery(l);
|
|
6125
6232
|
}
|
|
6126
6233
|
async requestGuestAuthToken({ cellSlug: e, encrypt: t }) {
|
|
6127
6234
|
this.setCellSlug(e);
|
|
6128
|
-
let n = new
|
|
6235
|
+
let n = new N({
|
|
6129
6236
|
secret: oe(await this.getFingerprint()),
|
|
6130
6237
|
token: "AUTH",
|
|
6131
6238
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
6132
|
-
}), r = await this.createQuery(
|
|
6239
|
+
}), r = await this.createQuery(cr), i = {
|
|
6133
6240
|
cellSlug: e,
|
|
6134
6241
|
pubkey: n.pubkey,
|
|
6135
6242
|
encrypt: t
|
|
6136
6243
|
}, a = await r.execute({ variables: i });
|
|
6137
6244
|
if (a.success()) {
|
|
6138
|
-
let e =
|
|
6245
|
+
let e = un.create({
|
|
6139
6246
|
token: a.token(),
|
|
6140
6247
|
expiresAt: a.expiresAt(),
|
|
6141
6248
|
pubkey: a.pubKey(),
|
|
6142
6249
|
encrypt: a.encrypt()
|
|
6143
6250
|
}, n);
|
|
6144
6251
|
this.setAuthToken(e);
|
|
6145
|
-
} else throw new
|
|
6252
|
+
} else throw new Sr(`KnishIOClient::requestGuestAuthToken() - Authorization attempt rejected by ledger. Reason: ${a.reason()}`);
|
|
6146
6253
|
return a;
|
|
6147
6254
|
}
|
|
6148
6255
|
async requestProfileAuthToken({ secret: e, encrypt: t }) {
|
|
6149
6256
|
this.setSecret(e);
|
|
6150
|
-
let n = new
|
|
6257
|
+
let n = new N({
|
|
6151
6258
|
secret: e,
|
|
6152
6259
|
token: "AUTH",
|
|
6153
6260
|
mlKemParameterSet: this.getMlKemParameterSet()
|
|
@@ -6155,20 +6262,20 @@ var Pi = class {
|
|
|
6155
6262
|
secret: e,
|
|
6156
6263
|
sourceWallet: n
|
|
6157
6264
|
}), i = await this.createMoleculeMutation({
|
|
6158
|
-
mutationClass:
|
|
6265
|
+
mutationClass: Bn,
|
|
6159
6266
|
molecule: r
|
|
6160
6267
|
}), a = { encrypt: t ? "true" : "false" };
|
|
6161
6268
|
n.pubkey && (a.walletPubkey = n.pubkey), i.fillMolecule({ meta: a });
|
|
6162
6269
|
let o = await i.execute({});
|
|
6163
6270
|
if (o.success()) {
|
|
6164
|
-
let e =
|
|
6271
|
+
let e = un.create({
|
|
6165
6272
|
token: o.token(),
|
|
6166
6273
|
expiresAt: o.expiresAt(),
|
|
6167
6274
|
pubkey: o.pubKey(),
|
|
6168
6275
|
encrypt: o.encrypt()
|
|
6169
6276
|
}, n);
|
|
6170
6277
|
this.setAuthToken(e);
|
|
6171
|
-
} else throw new
|
|
6278
|
+
} else throw new Sr(`KnishIOClient::requestProfileAuthToken() - Authorization attempt rejected by ledger. Reason: ${o.reason()}`);
|
|
6172
6279
|
return o;
|
|
6173
6280
|
}
|
|
6174
6281
|
async requestAuthToken({ secret: e = null, seed: t = null, cellSlug: n = null, encrypt: r = !1 }) {
|
|
@@ -6207,7 +6314,7 @@ var Pi = class {
|
|
|
6207
6314
|
default: console.log(t);
|
|
6208
6315
|
}
|
|
6209
6316
|
}
|
|
6210
|
-
},
|
|
6317
|
+
}, Ji = class extends q {
|
|
6211
6318
|
constructor({ query: e, json: t }) {
|
|
6212
6319
|
super({
|
|
6213
6320
|
query: e,
|
|
@@ -6225,8 +6332,8 @@ var Pi = class {
|
|
|
6225
6332
|
return this.data();
|
|
6226
6333
|
}
|
|
6227
6334
|
payloadKey(e) {
|
|
6228
|
-
if (!
|
|
6229
|
-
return
|
|
6335
|
+
if (!R.has(this.payload(), e)) throw new K(`ResponseAuthorizationGuest::payloadKey() - '${e}' key is not found in the payload!`);
|
|
6336
|
+
return R.get(this.payload(), e);
|
|
6230
6337
|
}
|
|
6231
6338
|
token() {
|
|
6232
6339
|
return this.payloadKey("token");
|
|
@@ -6234,7 +6341,7 @@ var Pi = class {
|
|
|
6234
6341
|
time() {
|
|
6235
6342
|
return this.payloadKey("time");
|
|
6236
6343
|
}
|
|
6237
|
-
},
|
|
6344
|
+
}, Yi = class {
|
|
6238
6345
|
constructor() {
|
|
6239
6346
|
this.store = /* @__PURE__ */ new Map();
|
|
6240
6347
|
}
|
|
@@ -6250,118 +6357,82 @@ var Pi = class {
|
|
|
6250
6357
|
keys() {
|
|
6251
6358
|
return Array.from(this.store.keys());
|
|
6252
6359
|
}
|
|
6253
|
-
}
|
|
6254
|
-
function Ri(e) {
|
|
6255
|
-
let t = "", n = e.byteLength;
|
|
6256
|
-
for (let r = 0; r < n; r++) {
|
|
6257
|
-
let n = e[r];
|
|
6258
|
-
n !== void 0 && (t += String.fromCharCode(n));
|
|
6259
|
-
}
|
|
6260
|
-
return btoa(t);
|
|
6261
|
-
}
|
|
6262
|
-
function zi(e) {
|
|
6263
|
-
let t = atob(e), n = t.length, r = new Uint8Array(n);
|
|
6264
|
-
for (let e = 0; e < n; e++) r[e] = t.charCodeAt(e);
|
|
6265
|
-
return r;
|
|
6266
|
-
}
|
|
6267
|
-
var Bi = new TextEncoder(), Vi = new TextDecoder(), Hi = "knishio:secret:", Ui = 1e5, Wi = class {
|
|
6360
|
+
}, Xi = new TextDecoder(), Zi = _n, Qi = class {
|
|
6268
6361
|
constructor(e = {}) {
|
|
6269
|
-
this.providerType = "webcrypto-aes-gcm", this.backend = e.backend || new
|
|
6362
|
+
this.providerType = "webcrypto-aes-gcm", this.backend = e.backend || new Yi(), this.defaultPassphrase = e.defaultPassphrase;
|
|
6270
6363
|
}
|
|
6271
6364
|
isHardwareBacked() {
|
|
6272
|
-
return
|
|
6365
|
+
return !1;
|
|
6273
6366
|
}
|
|
6274
6367
|
async isAvailable() {
|
|
6275
6368
|
return globalThis.crypto !== void 0 && globalThis.crypto.subtle !== void 0;
|
|
6276
6369
|
}
|
|
6277
|
-
async deriveKey(e, t, n =
|
|
6278
|
-
if (!await this.isAvailable()) throw
|
|
6279
|
-
|
|
6280
|
-
try {
|
|
6281
|
-
let e = await globalThis.crypto.subtle.importKey("raw", r, "PBKDF2", !1, ["deriveKey"]);
|
|
6282
|
-
return await globalThis.crypto.subtle.deriveKey({
|
|
6283
|
-
name: "PBKDF2",
|
|
6284
|
-
salt: t,
|
|
6285
|
-
iterations: n,
|
|
6286
|
-
hash: "SHA-256"
|
|
6287
|
-
}, e, {
|
|
6288
|
-
name: "AES-GCM",
|
|
6289
|
-
length: 256
|
|
6290
|
-
}, !1, ["encrypt", "decrypt"]);
|
|
6291
|
-
} finally {
|
|
6292
|
-
U(r);
|
|
6293
|
-
}
|
|
6370
|
+
async deriveKey(e, t, n = gn) {
|
|
6371
|
+
if (!await this.isAvailable()) throw z.unavailable(this.providerType, "WebCrypto API is not available");
|
|
6372
|
+
return await xn(e, t, n);
|
|
6294
6373
|
}
|
|
6295
6374
|
async storeSecret(e, t, n = {}) {
|
|
6296
|
-
if (!e) throw new
|
|
6297
|
-
if (!t) throw new
|
|
6375
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
6376
|
+
if (!t) throw new z("Secret cannot be empty");
|
|
6298
6377
|
let r = n.passphrase || this.defaultPassphrase;
|
|
6299
|
-
if (!r) throw new
|
|
6300
|
-
|
|
6301
|
-
globalThis.crypto.getRandomValues(i), globalThis.crypto.getRandomValues(a);
|
|
6302
|
-
let o = await this.deriveKey(r, i, Ui), s = Bi.encode(t);
|
|
6378
|
+
if (!r) throw new z("Passphrase required for envelope encryption");
|
|
6379
|
+
if (!await this.isAvailable()) throw z.unavailable(this.providerType, "WebCrypto API is not available");
|
|
6303
6380
|
try {
|
|
6304
|
-
let
|
|
6305
|
-
name: "AES-GCM",
|
|
6306
|
-
iv: a
|
|
6307
|
-
}, o, s), r = Ri(new Uint8Array(t)), c = {
|
|
6381
|
+
let i = await W(t, r, {
|
|
6308
6382
|
bundleHash: e,
|
|
6309
6383
|
label: n.label,
|
|
6310
6384
|
createdAt: Date.now(),
|
|
6311
|
-
hardwareBacked:
|
|
6385
|
+
hardwareBacked: !1,
|
|
6312
6386
|
providerType: this.providerType
|
|
6313
|
-
}
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6387
|
+
});
|
|
6388
|
+
if (await this.backend.setItem(`${Zi}${e}`, JSON.stringify(i)), n.recoveryPassphrase) {
|
|
6389
|
+
let r = {
|
|
6390
|
+
bundleHash: e,
|
|
6391
|
+
label: n.label,
|
|
6392
|
+
createdAt: Date.now(),
|
|
6393
|
+
hardwareBacked: !1,
|
|
6394
|
+
providerType: "webcrypto-aes-gcm"
|
|
6395
|
+
}, i = await W(t, n.recoveryPassphrase, r);
|
|
6396
|
+
await this.backend.setItem(`${V}${e}`, JSON.stringify(i));
|
|
6397
|
+
}
|
|
6323
6398
|
} catch (e) {
|
|
6324
|
-
throw new
|
|
6325
|
-
} finally {
|
|
6326
|
-
U(s);
|
|
6399
|
+
throw e instanceof z ? e : new z(`Encryption failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
6327
6400
|
}
|
|
6328
6401
|
}
|
|
6329
6402
|
async retrieveSecret(e, t = {}) {
|
|
6330
|
-
let n = await this.backend.getItem(`${
|
|
6403
|
+
let n = await this.backend.getItem(`${Zi}${e}`);
|
|
6331
6404
|
if (!n) return null;
|
|
6332
6405
|
let r;
|
|
6333
6406
|
try {
|
|
6334
6407
|
r = JSON.parse(n);
|
|
6335
6408
|
} catch {
|
|
6336
|
-
throw
|
|
6409
|
+
throw z.decryptionFailed("Corrupted payload format");
|
|
6337
6410
|
}
|
|
6338
6411
|
let i = t.passphrase || this.defaultPassphrase;
|
|
6339
|
-
if (!i) throw new
|
|
6340
|
-
|
|
6412
|
+
if (!i) throw new z("Passphrase required for secret decryption");
|
|
6413
|
+
if (!await this.isAvailable()) throw z.unavailable(this.providerType, "WebCrypto API is not available");
|
|
6341
6414
|
try {
|
|
6342
|
-
let e = await
|
|
6343
|
-
name: "AES-GCM",
|
|
6344
|
-
iv: o
|
|
6345
|
-
}, e, s), n = new Uint8Array(t);
|
|
6415
|
+
let e = await G(r, i);
|
|
6346
6416
|
try {
|
|
6347
|
-
return
|
|
6417
|
+
return Xi.decode(e);
|
|
6348
6418
|
} finally {
|
|
6349
|
-
|
|
6419
|
+
B(e);
|
|
6350
6420
|
}
|
|
6351
6421
|
} catch (e) {
|
|
6422
|
+
if (e instanceof z) throw e;
|
|
6352
6423
|
let t = e instanceof Error ? e.message : String(e);
|
|
6353
|
-
throw
|
|
6424
|
+
throw z.decryptionFailed(t);
|
|
6354
6425
|
}
|
|
6355
6426
|
}
|
|
6356
6427
|
async deleteSecret(e) {
|
|
6357
|
-
let t = `${
|
|
6358
|
-
return await this.backend.removeItem(
|
|
6428
|
+
let t = `${Zi}${e}`, n = `${V}${e}`, r = await this.backend.removeItem(t);
|
|
6429
|
+
return await this.backend.removeItem(n), r !== !1;
|
|
6359
6430
|
}
|
|
6360
6431
|
async hasSecret(e) {
|
|
6361
|
-
return await this.backend.getItem(`${
|
|
6432
|
+
return await this.backend.getItem(`${Zi}${e}`) !== null;
|
|
6362
6433
|
}
|
|
6363
6434
|
async listSecrets() {
|
|
6364
|
-
let e = (await this.backend.keys()).filter((e) => e.startsWith(
|
|
6435
|
+
let e = (await this.backend.keys()).filter((e) => e.startsWith(Zi) && !e.startsWith("knishio:recovery:")), t = [];
|
|
6365
6436
|
for (let n of e) {
|
|
6366
6437
|
let e = await this.backend.getItem(n);
|
|
6367
6438
|
if (e) try {
|
|
@@ -6372,40 +6443,674 @@ var Bi = new TextEncoder(), Vi = new TextDecoder(), Hi = "knishio:secret:", Ui =
|
|
|
6372
6443
|
return t;
|
|
6373
6444
|
}
|
|
6374
6445
|
async withSecret(e, t, n = {}) {
|
|
6375
|
-
let r = await this.backend.getItem(`${
|
|
6376
|
-
if (!r) throw
|
|
6446
|
+
let r = await this.backend.getItem(`${Zi}${e}`);
|
|
6447
|
+
if (!r) throw z.notFound(e);
|
|
6377
6448
|
let i;
|
|
6378
6449
|
try {
|
|
6379
6450
|
i = JSON.parse(r);
|
|
6380
6451
|
} catch {
|
|
6381
|
-
throw
|
|
6452
|
+
throw z.decryptionFailed("Corrupted payload format");
|
|
6382
6453
|
}
|
|
6383
6454
|
let a = n.passphrase || this.defaultPassphrase;
|
|
6384
|
-
if (!a) throw new
|
|
6385
|
-
|
|
6455
|
+
if (!a) throw new z("Passphrase required for secret decryption");
|
|
6456
|
+
if (!await this.isAvailable()) throw z.unavailable(this.providerType, "WebCrypto API is not available");
|
|
6457
|
+
try {
|
|
6458
|
+
return await fn(await G(i, a), async (e) => await t(Xi.decode(e)));
|
|
6459
|
+
} catch (e) {
|
|
6460
|
+
if (e instanceof z) throw e;
|
|
6461
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
6462
|
+
throw z.decryptionFailed(t);
|
|
6463
|
+
}
|
|
6464
|
+
}
|
|
6465
|
+
async recoverSecret(e, t, n = {}) {
|
|
6466
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
6467
|
+
if (!t) throw new z("Recovery passphrase cannot be empty");
|
|
6468
|
+
let r = await this.backend.getItem(`${V}${e}`);
|
|
6469
|
+
if (!r) throw z.notFound(e);
|
|
6470
|
+
let i;
|
|
6471
|
+
try {
|
|
6472
|
+
i = JSON.parse(r);
|
|
6473
|
+
} catch {
|
|
6474
|
+
throw z.decryptionFailed("Corrupted recovery payload format");
|
|
6475
|
+
}
|
|
6476
|
+
let a;
|
|
6386
6477
|
try {
|
|
6387
|
-
|
|
6478
|
+
a = await G(i, t);
|
|
6479
|
+
} catch (e) {
|
|
6480
|
+
if (e instanceof z) throw e;
|
|
6481
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
6482
|
+
throw z.decryptionFailed(t);
|
|
6483
|
+
}
|
|
6484
|
+
let o;
|
|
6485
|
+
try {
|
|
6486
|
+
o = Xi.decode(a);
|
|
6487
|
+
} finally {
|
|
6488
|
+
B(a);
|
|
6489
|
+
}
|
|
6490
|
+
let s = n.passphrase || this.defaultPassphrase || t;
|
|
6491
|
+
await this.storeSecret(e, o, {
|
|
6492
|
+
...n,
|
|
6493
|
+
passphrase: s,
|
|
6494
|
+
recoveryPassphrase: t
|
|
6495
|
+
});
|
|
6496
|
+
}
|
|
6497
|
+
}, $i = class {
|
|
6498
|
+
constructor(e) {
|
|
6499
|
+
if (!e) throw new z("Storage file path cannot be empty");
|
|
6500
|
+
this.filePath = e, this.store = /* @__PURE__ */ new Map(), this.loaded = !1;
|
|
6501
|
+
}
|
|
6502
|
+
async getFs() {
|
|
6503
|
+
try {
|
|
6504
|
+
return {
|
|
6505
|
+
fs: await import("node:fs/promises"),
|
|
6506
|
+
path: await import("node:path")
|
|
6507
|
+
};
|
|
6508
|
+
} catch {
|
|
6509
|
+
throw z.unavailable("file-storage", "FileStorageBackend is only supported in Node.js environments with node:fs access");
|
|
6510
|
+
}
|
|
6511
|
+
}
|
|
6512
|
+
async ensureLoaded() {
|
|
6513
|
+
if (this.loaded) return this.store;
|
|
6514
|
+
let { fs: e } = await this.getFs();
|
|
6515
|
+
try {
|
|
6516
|
+
let t = await e.readFile(this.filePath, "utf8"), n;
|
|
6517
|
+
try {
|
|
6518
|
+
n = JSON.parse(t);
|
|
6519
|
+
} catch {
|
|
6520
|
+
throw z.decryptionFailed("Corrupted storage file format");
|
|
6521
|
+
}
|
|
6522
|
+
n && typeof n == "object" && (this.store = new Map(Object.entries(n).map(([e, t]) => [e, String(t)])));
|
|
6523
|
+
} catch (e) {
|
|
6524
|
+
if (e instanceof z) throw e;
|
|
6525
|
+
if (e?.code !== "ENOENT") throw new z(`Failed to read storage file: ${e instanceof Error ? e.message : String(e)}`);
|
|
6526
|
+
this.store = /* @__PURE__ */ new Map();
|
|
6527
|
+
}
|
|
6528
|
+
return this.loaded = !0, this.store;
|
|
6529
|
+
}
|
|
6530
|
+
async persist() {
|
|
6531
|
+
let { fs: e, path: t } = await this.getFs(), n = t.dirname(this.filePath);
|
|
6532
|
+
n && n !== "." && await e.mkdir(n, { recursive: !0 });
|
|
6533
|
+
let r = `${this.filePath}.tmp.${Date.now()}_${Math.random().toString(36).slice(2)}`, i = JSON.stringify(Object.fromEntries(this.store), null, 2);
|
|
6534
|
+
try {
|
|
6535
|
+
if (await e.writeFile(r, i, {
|
|
6536
|
+
mode: 384,
|
|
6537
|
+
encoding: "utf8"
|
|
6538
|
+
}), typeof process < "u" && process.platform !== "win32") try {
|
|
6539
|
+
await e.chmod(r, 384);
|
|
6540
|
+
} catch {}
|
|
6541
|
+
await e.rename(r, this.filePath);
|
|
6542
|
+
} catch (t) {
|
|
6543
|
+
try {
|
|
6544
|
+
await e.unlink(r);
|
|
6545
|
+
} catch {}
|
|
6546
|
+
throw new z(`Failed to persist storage file: ${t instanceof Error ? t.message : String(t)}`);
|
|
6547
|
+
}
|
|
6548
|
+
}
|
|
6549
|
+
async getItem(e) {
|
|
6550
|
+
return await this.ensureLoaded(), this.store.get(e) ?? null;
|
|
6551
|
+
}
|
|
6552
|
+
async setItem(e, t) {
|
|
6553
|
+
await this.ensureLoaded(), this.store.set(e, t), await this.persist();
|
|
6554
|
+
}
|
|
6555
|
+
async removeItem(e) {
|
|
6556
|
+
await this.ensureLoaded();
|
|
6557
|
+
let t = this.store.delete(e);
|
|
6558
|
+
return t && await this.persist(), t;
|
|
6559
|
+
}
|
|
6560
|
+
async keys() {
|
|
6561
|
+
return await this.ensureLoaded(), Array.from(this.store.keys());
|
|
6562
|
+
}
|
|
6563
|
+
}, ea = class {
|
|
6564
|
+
constructor(e, t = "knishio:") {
|
|
6565
|
+
if (e) this.storage = e;
|
|
6566
|
+
else if (typeof globalThis < "u" && globalThis.localStorage) this.storage = globalThis.localStorage;
|
|
6567
|
+
else throw z.unavailable("web-storage", "WebStorageBackend requires a Storage object or global localStorage");
|
|
6568
|
+
this.prefix = t;
|
|
6569
|
+
}
|
|
6570
|
+
getItem(e) {
|
|
6571
|
+
return this.storage.getItem(e);
|
|
6572
|
+
}
|
|
6573
|
+
setItem(e, t) {
|
|
6574
|
+
this.storage.setItem(e, t);
|
|
6575
|
+
}
|
|
6576
|
+
removeItem(e) {
|
|
6577
|
+
let t = this.storage.getItem(e) !== null;
|
|
6578
|
+
return this.storage.removeItem(e), t;
|
|
6579
|
+
}
|
|
6580
|
+
keys() {
|
|
6581
|
+
let e = [], t = this.storage.length;
|
|
6582
|
+
for (let n = 0; n < t; n++) {
|
|
6583
|
+
let t = this.storage.key(n);
|
|
6584
|
+
t !== null && (!this.prefix || t.startsWith(this.prefix)) && e.push(t);
|
|
6585
|
+
}
|
|
6586
|
+
return e;
|
|
6587
|
+
}
|
|
6588
|
+
}, ta = "knishio:secret-storage:webauthn-prf:v1", na = "knishio:secret-storage:kek:v1", ra = _n, ia = 12, aa = new TextEncoder(), oa = new TextDecoder();
|
|
6589
|
+
function sa(e) {
|
|
6590
|
+
return H(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
6591
|
+
}
|
|
6592
|
+
function ca(e) {
|
|
6593
|
+
let t = e.replace(/-/g, "+").replace(/_/g, "/");
|
|
6594
|
+
for (; t.length % 4 != 0;) t += "=";
|
|
6595
|
+
return U(t);
|
|
6596
|
+
}
|
|
6597
|
+
function la(e) {
|
|
6598
|
+
return e instanceof Uint8Array ? e : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e);
|
|
6599
|
+
}
|
|
6600
|
+
async function ua() {
|
|
6601
|
+
let e = await globalThis.crypto.subtle.digest("SHA-256", aa.encode(ta));
|
|
6602
|
+
return new Uint8Array(e);
|
|
6603
|
+
}
|
|
6604
|
+
async function da(e, t) {
|
|
6605
|
+
let n = await globalThis.crypto.subtle.importKey("raw", e, "HKDF", !1, ["deriveKey"]);
|
|
6606
|
+
return await globalThis.crypto.subtle.deriveKey({
|
|
6607
|
+
name: "HKDF",
|
|
6608
|
+
hash: "SHA-256",
|
|
6609
|
+
salt: t,
|
|
6610
|
+
info: aa.encode(na)
|
|
6611
|
+
}, n, {
|
|
6612
|
+
name: "AES-GCM",
|
|
6613
|
+
length: 256
|
|
6614
|
+
}, !1, ["encrypt", "decrypt"]);
|
|
6615
|
+
}
|
|
6616
|
+
var fa = class {
|
|
6617
|
+
constructor(e) {
|
|
6618
|
+
this.providerType = "webauthn-prf", this.backend = e.backend, this.rp = e.rp, this.user = e.user, this.credentialsContainer = e.credentials, this.alias = e.alias || "default", this.cachedPassphrase = void 0;
|
|
6619
|
+
}
|
|
6620
|
+
get credentials() {
|
|
6621
|
+
if (this.credentialsContainer) return this.credentialsContainer;
|
|
6622
|
+
if (globalThis.navigator !== void 0 && globalThis.navigator.credentials) return globalThis.navigator.credentials;
|
|
6623
|
+
throw z.unavailable(this.providerType, "WebAuthn credentials container is not available");
|
|
6624
|
+
}
|
|
6625
|
+
get recordKey() {
|
|
6626
|
+
return `knishio:webauthn-prf:${this.alias}`;
|
|
6627
|
+
}
|
|
6628
|
+
isHardwareBacked() {
|
|
6629
|
+
return !1;
|
|
6630
|
+
}
|
|
6631
|
+
async isAvailable() {
|
|
6632
|
+
let e = globalThis.crypto !== void 0 && globalThis.crypto.subtle !== void 0, t = !!(this.credentialsContainer || globalThis.navigator !== void 0 && globalThis.navigator.credentials && globalThis.PublicKeyCredential !== void 0);
|
|
6633
|
+
return e && t;
|
|
6634
|
+
}
|
|
6635
|
+
async enroll() {
|
|
6636
|
+
if (await this.backend.getItem(this.recordKey)) return;
|
|
6637
|
+
if (!await this.isAvailable()) throw z.unavailable(this.providerType, "WebAuthn PRF is not available");
|
|
6638
|
+
let e = /* @__PURE__ */ new Uint8Array(32);
|
|
6639
|
+
globalThis.crypto.getRandomValues(e);
|
|
6640
|
+
let t = await this.credentials.create({ publicKey: {
|
|
6641
|
+
rp: this.rp,
|
|
6642
|
+
user: {
|
|
6643
|
+
id: this.user.id,
|
|
6644
|
+
name: this.user.name,
|
|
6645
|
+
displayName: this.user.displayName
|
|
6646
|
+
},
|
|
6647
|
+
challenge: e,
|
|
6648
|
+
pubKeyCredParams: [{
|
|
6649
|
+
type: "public-key",
|
|
6650
|
+
alg: -7
|
|
6651
|
+
}, {
|
|
6652
|
+
type: "public-key",
|
|
6653
|
+
alg: -257
|
|
6654
|
+
}],
|
|
6655
|
+
authenticatorSelection: {
|
|
6656
|
+
residentKey: "required",
|
|
6657
|
+
userVerification: "required"
|
|
6658
|
+
},
|
|
6659
|
+
extensions: { prf: {} }
|
|
6660
|
+
} });
|
|
6661
|
+
if (!t) throw z.unavailable(this.providerType, "Authenticator creation returned null");
|
|
6662
|
+
if ((t.getClientExtensionResults?.())?.prf?.enabled !== !0) throw z.unavailable(this.providerType, "authenticator does not support the PRF extension");
|
|
6663
|
+
let n = new Uint8Array(t.rawId), r = await ua(), i = /* @__PURE__ */ new Uint8Array(32);
|
|
6664
|
+
globalThis.crypto.getRandomValues(i);
|
|
6665
|
+
let a;
|
|
6666
|
+
try {
|
|
6667
|
+
a = await this.credentials.get({ publicKey: {
|
|
6668
|
+
challenge: i,
|
|
6669
|
+
rpId: this.rp.id,
|
|
6670
|
+
allowCredentials: [{
|
|
6671
|
+
type: "public-key",
|
|
6672
|
+
id: n
|
|
6673
|
+
}],
|
|
6674
|
+
userVerification: "required",
|
|
6675
|
+
extensions: { prf: { eval: { first: r } } }
|
|
6676
|
+
} });
|
|
6677
|
+
} catch (e) {
|
|
6678
|
+
throw e?.name === "NotAllowedError" ? z.unavailable(this.providerType, "authenticator refused or credential missing") : e;
|
|
6679
|
+
}
|
|
6680
|
+
if (!a) throw z.unavailable(this.providerType, "authenticator refused or credential missing");
|
|
6681
|
+
let o = (a?.getClientExtensionResults?.())?.prf?.results?.first;
|
|
6682
|
+
if (!o) throw z.unavailable(this.providerType, "authenticator returned no PRF result");
|
|
6683
|
+
let s = await da(la(o), r), c = /* @__PURE__ */ new Uint8Array(32);
|
|
6684
|
+
globalThis.crypto.getRandomValues(c);
|
|
6685
|
+
let l = H(c), u = new Uint8Array(ia);
|
|
6686
|
+
globalThis.crypto.getRandomValues(u);
|
|
6687
|
+
let d = aa.encode(l);
|
|
6688
|
+
try {
|
|
6689
|
+
let e = await globalThis.crypto.subtle.encrypt({
|
|
6388
6690
|
name: "AES-GCM",
|
|
6389
|
-
iv:
|
|
6390
|
-
},
|
|
6391
|
-
|
|
6691
|
+
iv: u
|
|
6692
|
+
}, s, d), t = {
|
|
6693
|
+
version: 1,
|
|
6694
|
+
credentialId: sa(n),
|
|
6695
|
+
iv: H(u),
|
|
6696
|
+
ciphertext: H(new Uint8Array(e))
|
|
6697
|
+
};
|
|
6698
|
+
await this.backend.setItem(this.recordKey, JSON.stringify(t)), this.cachedPassphrase = l;
|
|
6699
|
+
} finally {
|
|
6700
|
+
B(d), B(c);
|
|
6701
|
+
}
|
|
6702
|
+
}
|
|
6703
|
+
async unlock() {
|
|
6704
|
+
if (this.cachedPassphrase) return this.cachedPassphrase;
|
|
6705
|
+
let e = await this.backend.getItem(this.recordKey);
|
|
6706
|
+
if (!e) throw z.unavailable(this.providerType, "no enrolled credential; call enroll() first");
|
|
6707
|
+
let t;
|
|
6708
|
+
try {
|
|
6709
|
+
t = JSON.parse(e);
|
|
6710
|
+
} catch {
|
|
6711
|
+
throw z.decryptionFailed("Corrupted PRF record format");
|
|
6712
|
+
}
|
|
6713
|
+
let n = ca(t.credentialId), r = await ua(), i = /* @__PURE__ */ new Uint8Array(32);
|
|
6714
|
+
globalThis.crypto.getRandomValues(i);
|
|
6715
|
+
let a;
|
|
6716
|
+
try {
|
|
6717
|
+
a = await this.credentials.get({ publicKey: {
|
|
6718
|
+
challenge: i,
|
|
6719
|
+
rpId: this.rp.id,
|
|
6720
|
+
allowCredentials: [{
|
|
6721
|
+
type: "public-key",
|
|
6722
|
+
id: n
|
|
6723
|
+
}],
|
|
6724
|
+
userVerification: "required",
|
|
6725
|
+
extensions: { prf: { eval: { first: r } } }
|
|
6726
|
+
} });
|
|
6727
|
+
} catch (e) {
|
|
6728
|
+
throw e?.name === "NotAllowedError" ? z.unavailable(this.providerType, "authenticator refused or credential missing") : e;
|
|
6729
|
+
}
|
|
6730
|
+
if (!a) throw z.unavailable(this.providerType, "authenticator refused or credential missing");
|
|
6731
|
+
let o = (a?.getClientExtensionResults?.())?.prf?.results?.first;
|
|
6732
|
+
if (!o) throw z.unavailable(this.providerType, "authenticator returned no PRF result");
|
|
6733
|
+
let s = await da(la(o), r), c = U(t.iv), l = U(t.ciphertext);
|
|
6734
|
+
try {
|
|
6735
|
+
let e = await globalThis.crypto.subtle.decrypt({
|
|
6736
|
+
name: "AES-GCM",
|
|
6737
|
+
iv: c
|
|
6738
|
+
}, s, l), t = new Uint8Array(e);
|
|
6739
|
+
try {
|
|
6740
|
+
return this.cachedPassphrase = oa.decode(t), this.cachedPassphrase;
|
|
6741
|
+
} finally {
|
|
6742
|
+
B(t);
|
|
6743
|
+
}
|
|
6744
|
+
} catch {
|
|
6745
|
+
throw z.decryptionFailed("wrapped device passphrase failed authentication under the enrolled credential");
|
|
6746
|
+
}
|
|
6747
|
+
}
|
|
6748
|
+
lock() {
|
|
6749
|
+
this.cachedPassphrase = void 0;
|
|
6750
|
+
}
|
|
6751
|
+
async unenroll() {
|
|
6752
|
+
this.lock(), await this.backend.removeItem(this.recordKey);
|
|
6753
|
+
}
|
|
6754
|
+
async storeSecret(e, t, n = {}) {
|
|
6755
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
6756
|
+
if (!t) throw new z("Secret cannot be empty");
|
|
6757
|
+
if (n.passphrase) throw new z("WebAuthnPrfSecretStorageProvider derives its passphrase from the authenticator; options.passphrase is not accepted");
|
|
6758
|
+
if (!n.recoveryPassphrase && !n.allowUnrecoverable) throw z.validationError("Recovery passphrase required for non-exportable hardware key unless allowUnrecoverable is true");
|
|
6759
|
+
let r = await W(t, await this.unlock(), {
|
|
6760
|
+
bundleHash: e,
|
|
6761
|
+
label: n.label,
|
|
6762
|
+
createdAt: Date.now(),
|
|
6763
|
+
hardwareBacked: !1,
|
|
6764
|
+
providerType: this.providerType
|
|
6765
|
+
});
|
|
6766
|
+
if (await this.backend.setItem(`${ra}${e}`, JSON.stringify(r)), n.recoveryPassphrase) {
|
|
6767
|
+
let r = {
|
|
6768
|
+
bundleHash: e,
|
|
6769
|
+
label: n.label,
|
|
6770
|
+
createdAt: Date.now(),
|
|
6771
|
+
hardwareBacked: !1,
|
|
6772
|
+
providerType: "webcrypto-aes-gcm"
|
|
6773
|
+
}, i = await W(t, n.recoveryPassphrase, r);
|
|
6774
|
+
await this.backend.setItem(`${V}${e}`, JSON.stringify(i));
|
|
6775
|
+
}
|
|
6776
|
+
}
|
|
6777
|
+
async retrieveSecret(e, t = {}) {
|
|
6778
|
+
if (t.passphrase) throw new z("WebAuthnPrfSecretStorageProvider derives its passphrase from the authenticator; options.passphrase is not accepted");
|
|
6779
|
+
let n = await this.backend.getItem(`${ra}${e}`);
|
|
6780
|
+
if (!n) return null;
|
|
6781
|
+
let r;
|
|
6782
|
+
try {
|
|
6783
|
+
r = JSON.parse(n);
|
|
6784
|
+
} catch {
|
|
6785
|
+
throw z.decryptionFailed("Corrupted payload format");
|
|
6786
|
+
}
|
|
6787
|
+
let i = await this.unlock();
|
|
6788
|
+
try {
|
|
6789
|
+
let e = await G(r, i);
|
|
6790
|
+
try {
|
|
6791
|
+
return oa.decode(e);
|
|
6792
|
+
} finally {
|
|
6793
|
+
B(e);
|
|
6794
|
+
}
|
|
6392
6795
|
} catch (e) {
|
|
6393
|
-
if (e instanceof
|
|
6796
|
+
if (e instanceof z) throw e;
|
|
6394
6797
|
let t = e instanceof Error ? e.message : String(e);
|
|
6395
|
-
throw
|
|
6798
|
+
throw z.decryptionFailed(t);
|
|
6799
|
+
}
|
|
6800
|
+
}
|
|
6801
|
+
async withSecret(e, t, n = {}) {
|
|
6802
|
+
if (n.passphrase) throw new z("WebAuthnPrfSecretStorageProvider derives its passphrase from the authenticator; options.passphrase is not accepted");
|
|
6803
|
+
let r = await this.backend.getItem(`${ra}${e}`);
|
|
6804
|
+
if (!r) throw z.notFound(e);
|
|
6805
|
+
let i;
|
|
6806
|
+
try {
|
|
6807
|
+
i = JSON.parse(r);
|
|
6808
|
+
} catch {
|
|
6809
|
+
throw z.decryptionFailed("Corrupted payload format");
|
|
6396
6810
|
}
|
|
6811
|
+
let a = await this.unlock();
|
|
6812
|
+
try {
|
|
6813
|
+
return await fn(await G(i, a), async (e) => await t(oa.decode(e)));
|
|
6814
|
+
} catch (e) {
|
|
6815
|
+
if (e instanceof z) throw e;
|
|
6816
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
6817
|
+
throw z.decryptionFailed(t);
|
|
6818
|
+
}
|
|
6819
|
+
}
|
|
6820
|
+
async deleteSecret(e) {
|
|
6821
|
+
let t = `${ra}${e}`, n = `${V}${e}`, r = await this.backend.removeItem(t);
|
|
6822
|
+
return await this.backend.removeItem(n), r !== !1;
|
|
6823
|
+
}
|
|
6824
|
+
async hasSecret(e) {
|
|
6825
|
+
return await this.backend.getItem(`${ra}${e}`) !== null;
|
|
6826
|
+
}
|
|
6827
|
+
async listSecrets() {
|
|
6828
|
+
let e = (await this.backend.keys()).filter((e) => e.startsWith(ra) && !e.startsWith("knishio:recovery:")), t = [];
|
|
6829
|
+
for (let n of e) {
|
|
6830
|
+
let e = await this.backend.getItem(n);
|
|
6831
|
+
if (e) try {
|
|
6832
|
+
let n = JSON.parse(e);
|
|
6833
|
+
n.metadata && t.push(n.metadata);
|
|
6834
|
+
} catch {}
|
|
6835
|
+
}
|
|
6836
|
+
return t;
|
|
6837
|
+
}
|
|
6838
|
+
async recoverSecret(e, t, n = {}) {
|
|
6839
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
6840
|
+
if (!t) throw new z("Recovery passphrase cannot be empty");
|
|
6841
|
+
let r = await this.backend.getItem(`${V}${e}`);
|
|
6842
|
+
if (!r) throw z.notFound(e);
|
|
6843
|
+
let i;
|
|
6844
|
+
try {
|
|
6845
|
+
i = JSON.parse(r);
|
|
6846
|
+
} catch {
|
|
6847
|
+
throw z.decryptionFailed("Corrupted recovery payload format");
|
|
6848
|
+
}
|
|
6849
|
+
let a;
|
|
6850
|
+
try {
|
|
6851
|
+
a = await G(i, t);
|
|
6852
|
+
} catch (e) {
|
|
6853
|
+
if (e instanceof z) throw e;
|
|
6854
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
6855
|
+
throw z.decryptionFailed(t);
|
|
6856
|
+
}
|
|
6857
|
+
let o;
|
|
6858
|
+
try {
|
|
6859
|
+
o = oa.decode(a);
|
|
6860
|
+
} finally {
|
|
6861
|
+
B(a);
|
|
6862
|
+
}
|
|
6863
|
+
await this.storeSecret(e, o, {
|
|
6864
|
+
...n,
|
|
6865
|
+
recoveryPassphrase: t
|
|
6866
|
+
});
|
|
6867
|
+
}
|
|
6868
|
+
}, pa = _n, ma = 12, ha = new TextEncoder(), ga = new TextDecoder(), _a = class {
|
|
6869
|
+
constructor() {
|
|
6870
|
+
this.keys = /* @__PURE__ */ new Map();
|
|
6871
|
+
}
|
|
6872
|
+
async get(e) {
|
|
6873
|
+
return this.keys.get(e);
|
|
6874
|
+
}
|
|
6875
|
+
async put(e, t) {
|
|
6876
|
+
this.keys.set(e, t);
|
|
6877
|
+
}
|
|
6878
|
+
async delete(e) {
|
|
6879
|
+
return this.keys.delete(e);
|
|
6880
|
+
}
|
|
6881
|
+
}, va = class {
|
|
6882
|
+
constructor(e = "knishio-secret-storage") {
|
|
6883
|
+
this.dbName = e, this.storeName = "keys";
|
|
6884
|
+
}
|
|
6885
|
+
async getDb() {
|
|
6886
|
+
if (globalThis.indexedDB === void 0) throw z.unavailable("webcrypto-nonextractable", "IndexedDB is not available");
|
|
6887
|
+
return new Promise((e, t) => {
|
|
6888
|
+
let n = globalThis.indexedDB.open(this.dbName, 1);
|
|
6889
|
+
n.onupgradeneeded = () => {
|
|
6890
|
+
let e = n.result;
|
|
6891
|
+
e.objectStoreNames.contains(this.storeName) || e.createObjectStore(this.storeName);
|
|
6892
|
+
}, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
|
|
6893
|
+
});
|
|
6894
|
+
}
|
|
6895
|
+
async get(e) {
|
|
6896
|
+
let t = await this.getDb();
|
|
6897
|
+
return new Promise((n, r) => {
|
|
6898
|
+
let i = t.transaction(this.storeName, "readonly").objectStore(this.storeName).get(e);
|
|
6899
|
+
i.onsuccess = () => n(i.result), i.onerror = () => r(i.error);
|
|
6900
|
+
});
|
|
6901
|
+
}
|
|
6902
|
+
async put(e, t) {
|
|
6903
|
+
let n = await this.getDb();
|
|
6904
|
+
return new Promise((r, i) => {
|
|
6905
|
+
let a = n.transaction(this.storeName, "readwrite").objectStore(this.storeName).put(t, e);
|
|
6906
|
+
a.onsuccess = () => r(), a.onerror = () => i(a.error);
|
|
6907
|
+
});
|
|
6908
|
+
}
|
|
6909
|
+
async delete(e) {
|
|
6910
|
+
let t = await this.getDb();
|
|
6911
|
+
return new Promise((n, r) => {
|
|
6912
|
+
let i = t.transaction(this.storeName, "readwrite").objectStore(this.storeName).delete(e);
|
|
6913
|
+
i.onsuccess = () => n(!0), i.onerror = () => r(i.error);
|
|
6914
|
+
});
|
|
6915
|
+
}
|
|
6916
|
+
}, ya = class {
|
|
6917
|
+
constructor(e) {
|
|
6918
|
+
this.providerType = "webcrypto-nonextractable", this.backend = e.backend, this.keyStore = e.keyStore || new va(), this.alias = e.alias || "default", this.cachedPassphrase = void 0;
|
|
6919
|
+
}
|
|
6920
|
+
get recordKey() {
|
|
6921
|
+
return `knishio:kek:webcrypto-nonextractable:${this.alias}`;
|
|
6922
|
+
}
|
|
6923
|
+
get kekStoreKey() {
|
|
6924
|
+
return `knishio:kek:${this.alias}`;
|
|
6925
|
+
}
|
|
6926
|
+
isHardwareBacked() {
|
|
6927
|
+
return !1;
|
|
6928
|
+
}
|
|
6929
|
+
async isAvailable() {
|
|
6930
|
+
return globalThis.crypto !== void 0 && globalThis.crypto.subtle !== void 0;
|
|
6931
|
+
}
|
|
6932
|
+
async unlock() {
|
|
6933
|
+
if (this.cachedPassphrase) return this.cachedPassphrase;
|
|
6934
|
+
if (!await this.isAvailable()) throw z.unavailable(this.providerType, "WebCrypto API is not available");
|
|
6935
|
+
let e = await this.backend.getItem(this.recordKey);
|
|
6936
|
+
if (!e) {
|
|
6937
|
+
let e = await this.keyStore.get(this.kekStoreKey);
|
|
6938
|
+
e || (e = await globalThis.crypto.subtle.generateKey({
|
|
6939
|
+
name: "AES-GCM",
|
|
6940
|
+
length: 256
|
|
6941
|
+
}, !1, ["encrypt", "decrypt"]), await this.keyStore.put(this.kekStoreKey, e));
|
|
6942
|
+
let t = /* @__PURE__ */ new Uint8Array(32);
|
|
6943
|
+
globalThis.crypto.getRandomValues(t);
|
|
6944
|
+
let n = H(t), r = new Uint8Array(ma);
|
|
6945
|
+
globalThis.crypto.getRandomValues(r);
|
|
6946
|
+
let i = ha.encode(n);
|
|
6947
|
+
try {
|
|
6948
|
+
let t = await globalThis.crypto.subtle.encrypt({
|
|
6949
|
+
name: "AES-GCM",
|
|
6950
|
+
iv: r
|
|
6951
|
+
}, e, i), a = {
|
|
6952
|
+
version: 1,
|
|
6953
|
+
iv: H(r),
|
|
6954
|
+
ciphertext: H(new Uint8Array(t))
|
|
6955
|
+
};
|
|
6956
|
+
return await this.backend.setItem(this.recordKey, JSON.stringify(a)), this.cachedPassphrase = n, n;
|
|
6957
|
+
} finally {
|
|
6958
|
+
B(i), B(t);
|
|
6959
|
+
}
|
|
6960
|
+
}
|
|
6961
|
+
let t;
|
|
6962
|
+
try {
|
|
6963
|
+
t = JSON.parse(e);
|
|
6964
|
+
} catch {
|
|
6965
|
+
throw z.decryptionFailed("Corrupted key record format");
|
|
6966
|
+
}
|
|
6967
|
+
let n = await this.keyStore.get(this.kekStoreKey);
|
|
6968
|
+
if (!n) throw z.unavailable(this.providerType, `no non-extractable key found for alias '${this.alias}'`);
|
|
6969
|
+
let r = U(t.iv), i = U(t.ciphertext);
|
|
6970
|
+
try {
|
|
6971
|
+
let e = await globalThis.crypto.subtle.decrypt({
|
|
6972
|
+
name: "AES-GCM",
|
|
6973
|
+
iv: r
|
|
6974
|
+
}, n, i), t = new Uint8Array(e);
|
|
6975
|
+
try {
|
|
6976
|
+
return this.cachedPassphrase = ga.decode(t), this.cachedPassphrase;
|
|
6977
|
+
} finally {
|
|
6978
|
+
B(t);
|
|
6979
|
+
}
|
|
6980
|
+
} catch {
|
|
6981
|
+
throw z.decryptionFailed("wrapped device passphrase failed authentication under non-extractable key");
|
|
6982
|
+
}
|
|
6983
|
+
}
|
|
6984
|
+
lock() {
|
|
6985
|
+
this.cachedPassphrase = void 0;
|
|
6986
|
+
}
|
|
6987
|
+
async unenroll() {
|
|
6988
|
+
this.lock(), await this.backend.removeItem(this.recordKey), await this.keyStore.delete(this.kekStoreKey);
|
|
6989
|
+
}
|
|
6990
|
+
async storeSecret(e, t, n = {}) {
|
|
6991
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
6992
|
+
if (!t) throw new z("Secret cannot be empty");
|
|
6993
|
+
if (n.passphrase) throw new z("NonExtractableKeySecretStorageProvider derives its passphrase from the non-extractable device key; options.passphrase is not accepted");
|
|
6994
|
+
if (!n.recoveryPassphrase && !n.allowUnrecoverable) throw z.validationError("Recovery passphrase required for non-exportable hardware key unless allowUnrecoverable is true");
|
|
6995
|
+
let r = await W(t, await this.unlock(), {
|
|
6996
|
+
bundleHash: e,
|
|
6997
|
+
label: n.label,
|
|
6998
|
+
createdAt: Date.now(),
|
|
6999
|
+
hardwareBacked: !1,
|
|
7000
|
+
providerType: this.providerType
|
|
7001
|
+
});
|
|
7002
|
+
if (await this.backend.setItem(`${pa}${e}`, JSON.stringify(r)), n.recoveryPassphrase) {
|
|
7003
|
+
let r = {
|
|
7004
|
+
bundleHash: e,
|
|
7005
|
+
label: n.label,
|
|
7006
|
+
createdAt: Date.now(),
|
|
7007
|
+
hardwareBacked: !1,
|
|
7008
|
+
providerType: "webcrypto-aes-gcm"
|
|
7009
|
+
}, i = await W(t, n.recoveryPassphrase, r);
|
|
7010
|
+
await this.backend.setItem(`${V}${e}`, JSON.stringify(i));
|
|
7011
|
+
}
|
|
7012
|
+
}
|
|
7013
|
+
async retrieveSecret(e, t = {}) {
|
|
7014
|
+
if (t.passphrase) throw new z("NonExtractableKeySecretStorageProvider derives its passphrase from the non-extractable device key; options.passphrase is not accepted");
|
|
7015
|
+
let n = await this.backend.getItem(`${pa}${e}`);
|
|
7016
|
+
if (!n) return null;
|
|
7017
|
+
let r;
|
|
7018
|
+
try {
|
|
7019
|
+
r = JSON.parse(n);
|
|
7020
|
+
} catch {
|
|
7021
|
+
throw z.decryptionFailed("Corrupted payload format");
|
|
7022
|
+
}
|
|
7023
|
+
let i = await this.unlock();
|
|
7024
|
+
try {
|
|
7025
|
+
let e = await G(r, i);
|
|
7026
|
+
try {
|
|
7027
|
+
return ga.decode(e);
|
|
7028
|
+
} finally {
|
|
7029
|
+
B(e);
|
|
7030
|
+
}
|
|
7031
|
+
} catch (e) {
|
|
7032
|
+
if (e instanceof z) throw e;
|
|
7033
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
7034
|
+
throw z.decryptionFailed(t);
|
|
7035
|
+
}
|
|
7036
|
+
}
|
|
7037
|
+
async withSecret(e, t, n = {}) {
|
|
7038
|
+
if (n.passphrase) throw new z("NonExtractableKeySecretStorageProvider derives its passphrase from the non-extractable device key; options.passphrase is not accepted");
|
|
7039
|
+
let r = await this.backend.getItem(`${pa}${e}`);
|
|
7040
|
+
if (!r) throw z.notFound(e);
|
|
7041
|
+
let i;
|
|
7042
|
+
try {
|
|
7043
|
+
i = JSON.parse(r);
|
|
7044
|
+
} catch {
|
|
7045
|
+
throw z.decryptionFailed("Corrupted payload format");
|
|
7046
|
+
}
|
|
7047
|
+
let a = await this.unlock();
|
|
7048
|
+
try {
|
|
7049
|
+
return await fn(await G(i, a), async (e) => await t(ga.decode(e)));
|
|
7050
|
+
} catch (e) {
|
|
7051
|
+
if (e instanceof z) throw e;
|
|
7052
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
7053
|
+
throw z.decryptionFailed(t);
|
|
7054
|
+
}
|
|
7055
|
+
}
|
|
7056
|
+
async deleteSecret(e) {
|
|
7057
|
+
let t = `${pa}${e}`, n = `${V}${e}`, r = await this.backend.removeItem(t);
|
|
7058
|
+
return await this.backend.removeItem(n), r !== !1;
|
|
7059
|
+
}
|
|
7060
|
+
async hasSecret(e) {
|
|
7061
|
+
return await this.backend.getItem(`${pa}${e}`) !== null;
|
|
7062
|
+
}
|
|
7063
|
+
async listSecrets() {
|
|
7064
|
+
let e = (await this.backend.keys()).filter((e) => e.startsWith(pa) && !e.startsWith("knishio:recovery:")), t = [];
|
|
7065
|
+
for (let n of e) {
|
|
7066
|
+
let e = await this.backend.getItem(n);
|
|
7067
|
+
if (e) try {
|
|
7068
|
+
let n = JSON.parse(e);
|
|
7069
|
+
n.metadata && t.push(n.metadata);
|
|
7070
|
+
} catch {}
|
|
7071
|
+
}
|
|
7072
|
+
return t;
|
|
7073
|
+
}
|
|
7074
|
+
async recoverSecret(e, t, n = {}) {
|
|
7075
|
+
if (!e) throw new z("Bundle hash cannot be empty");
|
|
7076
|
+
if (!t) throw new z("Recovery passphrase cannot be empty");
|
|
7077
|
+
let r = await this.backend.getItem(`${V}${e}`);
|
|
7078
|
+
if (!r) throw z.notFound(e);
|
|
7079
|
+
let i;
|
|
7080
|
+
try {
|
|
7081
|
+
i = JSON.parse(r);
|
|
7082
|
+
} catch {
|
|
7083
|
+
throw z.decryptionFailed("Corrupted recovery payload format");
|
|
7084
|
+
}
|
|
7085
|
+
let a;
|
|
7086
|
+
try {
|
|
7087
|
+
a = await G(i, t);
|
|
7088
|
+
} catch (e) {
|
|
7089
|
+
if (e instanceof z) throw e;
|
|
7090
|
+
let t = e instanceof Error ? e.message : String(e);
|
|
7091
|
+
throw z.decryptionFailed(t);
|
|
7092
|
+
}
|
|
7093
|
+
let o;
|
|
7094
|
+
try {
|
|
7095
|
+
o = ga.decode(a);
|
|
7096
|
+
} finally {
|
|
7097
|
+
B(a);
|
|
7098
|
+
}
|
|
7099
|
+
await this.storeSecret(e, o, {
|
|
7100
|
+
...n,
|
|
7101
|
+
recoveryPassphrase: t
|
|
7102
|
+
});
|
|
6397
7103
|
}
|
|
6398
7104
|
};
|
|
6399
7105
|
//#endregion
|
|
6400
7106
|
//#region src/storage/index.js
|
|
6401
|
-
function
|
|
6402
|
-
return e.type === "memory" ? new
|
|
7107
|
+
function ba(e = {}) {
|
|
7108
|
+
return e.type === "memory" ? new Sn() : globalThis.crypto !== void 0 && globalThis.crypto.subtle !== void 0 ? new Qi({
|
|
6403
7109
|
backend: e.backend,
|
|
6404
|
-
defaultPassphrase: e.defaultPassphrase
|
|
6405
|
-
|
|
6406
|
-
}) : new fn();
|
|
7110
|
+
defaultPassphrase: e.defaultPassphrase
|
|
7111
|
+
}) : new Sn();
|
|
6407
7112
|
}
|
|
6408
7113
|
//#endregion
|
|
6409
|
-
export { T as Atom,
|
|
7114
|
+
export { T as Atom, Ht as AtomIndexException, S as AtomMeta, w as AtomsMissingException, un as AuthToken, Sr as AuthorizationRejectedException, sn as BalanceInsufficientException, $t as BatchIdException, on as CheckMolecule, L as CodeException, wn as Decimal, R as Dot, $i as FileStorageBackend, va as IndexedDbKeyStore, K as InvalidResponseException, qi as KnishIOClient, _a as MemoryKeyStore, Sn as MemorySecretStorageProvider, Yi as MemoryStorageBackend, b as Meta, F as MetaMissingException, Ut as MolecularHashMismatchException, Wt as MolecularHashMissingException, ln as Molecule, Rn as Mutation, vr as MutationActiveSession, nr as MutationAppendRequest, Xn as MutationClaimShadowWallet, Jn as MutationCreateIdentifier, Qn as MutationCreateMeta, Pr as MutationCreateRule, Hn as MutationCreateToken, or as MutationCreateWallet, Fr as MutationDepositBufferToken, ir as MutationLinkIdentifier, er as MutationPeering, X as MutationProposeMolecule, Bn as MutationRequestAuthorization, cr as MutationRequestAuthorizationGuest, Wn as MutationRequestTokens, Kn as MutationTransferTokens, Ir as MutationWithdrawBufferToken, cn as NegativeAmountException, ya as NonExtractableKeySecretStorageProvider, Gt as PolicyInvalidException, re as PolicyMeta, J as Query, br as QueryActiveSession, wr as QueryAtom, Nn as QueryBalance, In as QueryBatch, Ln as QueryBatchHistory, Dn as QueryContinuId, Mr as QueryEmbeddingStatus, Fn as QueryMetaType, Or as QueryMetaTypeViaAtom, Ar as QueryMetaTypeViaMolecule, Er as QueryPolicy, xr as QueryToken, kn as QueryWalletBundle, jn as QueryWalletList, V as RECOVERY_KEY_PREFIX, q as Response, _r as ResponseActiveSession, tr as ResponseAppendRequest, Cr as ResponseAtom, Ji as ResponseAuthorizationGuest, Mn as ResponseBalance, Yn as ResponseClaimShadowWallet, En as ResponseContinuId, qn as ResponseCreateIdentifier, Zn as ResponseCreateMeta, Nr as ResponseCreateRule, Vn as ResponseCreateToken, ar as ResponseCreateWallet, jr as ResponseEmbeddingStatus, rr as ResponseLinkIdentifier, Pn as ResponseMetaType, Dr as ResponseMetaTypeViaAtom, kr as ResponseMetaTypeViaMolecule, $n as ResponsePeering, Tr as ResponsePolicy, Y as ResponseProposeMolecule, yr as ResponseQueryActiveSession, zn as ResponseRequestAuthorization, sr as ResponseRequestAuthorizationGuest, Un as ResponseRequestTokens, Gn as ResponseTransferTokens, On as ResponseWalletBundle, An as ResponseWalletList, _n as SECRET_KEY_PREFIX, z as SecretStorageException, Kt as SignatureMalformedException, qt as SignatureMismatchException, dr as StackableUnitAmountException, ur as StackableUnitDecimalsException, ue as TokenUnit, P as TransferBalanceException, Jt as TransferMalformedException, Yt as TransferMismatchedException, Xt as TransferRemainderException, Zt as TransferToSelfException, Qt as TransferUnbalancedException, Tn as UnauthenticatedException, N as Wallet, lr as WalletShadowException, fa as WebAuthnPrfSecretStorageProvider, Qi as WebCryptoSecretStorageProvider, ea as WebStorageBackend, I as WrongTokenTypeException, _ as base64ToHex, m as bufferToHexString, p as charsetBaseConvert, ee as chunkArray, d as chunkSubstr, mn as constantTimeCompare, ba as createDefaultSecretStorage, te as deepCloning, ne as diff, le as generateBatchId, se as generateBundleHash, oe as generateSecret, h as hexStringToBuffer, g as hexToBase64, x as intersect, v as isHex, y as isNumeric, G as openEnvelope, f as randomString, W as sealEnvelope, ce as shake256, fn as withSecureBytes, pn as withSecureString, B as zeroizeBytes };
|
|
6410
7115
|
|
|
6411
7116
|
//# sourceMappingURL=client.es.mjs.map
|