@vitia.ai/secure-api-client-vue 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +130 -130
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ function Xr(n) {
|
|
|
7
7
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
8
8
|
throw new Error("positive integer expected, got " + n);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function Ue(n, ...e) {
|
|
11
11
|
if (!lt(n))
|
|
12
12
|
throw new Error("Uint8Array expected");
|
|
13
13
|
if (e.length > 0 && !e.includes(n.length))
|
|
@@ -15,21 +15,21 @@ function Te(n, ...e) {
|
|
|
15
15
|
}
|
|
16
16
|
const ut = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Zr = /* @__PURE__ */ Array.from({ length: 256 }, (n, e) => e.toString(16).padStart(2, "0"));
|
|
17
17
|
function ht(n) {
|
|
18
|
-
if (
|
|
18
|
+
if (Ue(n), ut)
|
|
19
19
|
return n.toHex();
|
|
20
20
|
let e = "";
|
|
21
21
|
for (let t = 0; t < n.length; t++)
|
|
22
22
|
e += Zr[n[t]];
|
|
23
23
|
return e;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const R = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
26
26
|
function Ze(n) {
|
|
27
|
-
if (n >=
|
|
28
|
-
return n -
|
|
29
|
-
if (n >=
|
|
30
|
-
return n - (
|
|
31
|
-
if (n >=
|
|
32
|
-
return n - (
|
|
27
|
+
if (n >= R._0 && n <= R._9)
|
|
28
|
+
return n - R._0;
|
|
29
|
+
if (n >= R.A && n <= R.F)
|
|
30
|
+
return n - (R.A - 10);
|
|
31
|
+
if (n >= R.a && n <= R.f)
|
|
32
|
+
return n - (R.a - 10);
|
|
33
33
|
}
|
|
34
34
|
function ft(n) {
|
|
35
35
|
if (typeof n != "string")
|
|
@@ -68,7 +68,7 @@ function Yr(n) {
|
|
|
68
68
|
return gt(ht(n));
|
|
69
69
|
}
|
|
70
70
|
function Ee(n) {
|
|
71
|
-
return
|
|
71
|
+
return Ue(n), gt(ht(Uint8Array.from(n).reverse()));
|
|
72
72
|
}
|
|
73
73
|
function wt(n, e) {
|
|
74
74
|
return ft(n.toString(16).padStart(e * 2, "0"));
|
|
@@ -116,12 +116,12 @@ function ts(n, e, t = {}) {
|
|
|
116
116
|
Object.entries(e).forEach(([s, i]) => r(s, i, !1)), Object.entries(t).forEach(([s, i]) => r(s, i, !0));
|
|
117
117
|
}
|
|
118
118
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
119
|
-
const x = BigInt(0), E = BigInt(1), G = /* @__PURE__ */ BigInt(2), Bt = /* @__PURE__ */ BigInt(3), bt = /* @__PURE__ */ BigInt(4),
|
|
119
|
+
const x = BigInt(0), E = BigInt(1), G = /* @__PURE__ */ BigInt(2), Bt = /* @__PURE__ */ BigInt(3), bt = /* @__PURE__ */ BigInt(4), vt = /* @__PURE__ */ BigInt(5), rs = /* @__PURE__ */ BigInt(7), mt = /* @__PURE__ */ BigInt(8), ss = /* @__PURE__ */ BigInt(9), kt = /* @__PURE__ */ BigInt(16);
|
|
120
120
|
function I(n, e) {
|
|
121
121
|
const t = n % e;
|
|
122
122
|
return t >= x ? t : e + t;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function T(n, e, t) {
|
|
125
125
|
let r = n;
|
|
126
126
|
for (; e-- > x; )
|
|
127
127
|
r *= r, r %= t;
|
|
@@ -150,7 +150,7 @@ function At(n, e) {
|
|
|
150
150
|
return Ve(n, r, e), r;
|
|
151
151
|
}
|
|
152
152
|
function ns(n, e) {
|
|
153
|
-
const t = (n.ORDER -
|
|
153
|
+
const t = (n.ORDER - vt) / mt, r = n.mul(e, G), s = n.pow(r, t), i = n.mul(e, s), o = n.mul(n.mul(i, G), s), a = n.mul(i, n.sub(o, n.ONE));
|
|
154
154
|
return Ve(n, a, e), a;
|
|
155
155
|
}
|
|
156
156
|
function is(n) {
|
|
@@ -159,7 +159,7 @@ function is(n) {
|
|
|
159
159
|
let l = a.pow(c, o), f = a.mul(l, r);
|
|
160
160
|
const h = a.mul(l, s), u = a.mul(l, i), g = a.eql(a.sqr(f), c), w = a.eql(a.sqr(h), c);
|
|
161
161
|
l = a.cmov(l, f, g), f = a.cmov(u, h, w);
|
|
162
|
-
const
|
|
162
|
+
const v = a.eql(a.sqr(f), c), y = a.cmov(l, f, v);
|
|
163
163
|
return Ve(a, y, c), y;
|
|
164
164
|
};
|
|
165
165
|
}
|
|
@@ -187,9 +187,9 @@ function xt(n) {
|
|
|
187
187
|
for (; !c.eql(u, c.ONE); ) {
|
|
188
188
|
if (c.is0(u))
|
|
189
189
|
return c.ZERO;
|
|
190
|
-
let w = 1,
|
|
191
|
-
for (; !c.eql(
|
|
192
|
-
if (w++,
|
|
190
|
+
let w = 1, v = c.sqr(u);
|
|
191
|
+
for (; !c.eql(v, c.ONE); )
|
|
192
|
+
if (w++, v = c.sqr(v), w === f)
|
|
193
193
|
throw new Error("Cannot find square root");
|
|
194
194
|
const y = E << BigInt(f - w - 1), C = c.pow(h, y);
|
|
195
195
|
f = w, h = c.sqr(C), u = c.mul(u, h), g = c.mul(g, C);
|
|
@@ -198,7 +198,7 @@ function xt(n) {
|
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
200
|
function os(n) {
|
|
201
|
-
return n % bt === Bt ? At : n %
|
|
201
|
+
return n % bt === Bt ? At : n % mt === vt ? ns : n % kt === ss ? is(n) : xt(n);
|
|
202
202
|
}
|
|
203
203
|
function cs(n, e, t) {
|
|
204
204
|
if (t < x)
|
|
@@ -281,8 +281,8 @@ function _e(n, e, t = !1, r = {}) {
|
|
|
281
281
|
if (a) {
|
|
282
282
|
if (!a.includes(u.length) || u.length > l)
|
|
283
283
|
throw new Error("Field.fromBytes: expected " + a + " bytes, got " + u.length);
|
|
284
|
-
const
|
|
285
|
-
|
|
284
|
+
const v = new Uint8Array(l);
|
|
285
|
+
v.set(u, t ? 0 : v.length - u.length), u = v;
|
|
286
286
|
}
|
|
287
287
|
if (u.length !== l)
|
|
288
288
|
throw new Error("Field.fromBytes: expected " + l + " bytes, got " + u.length);
|
|
@@ -311,7 +311,7 @@ function hs(n) {
|
|
|
311
311
|
const e = us(n), { P: t, type: r, adjustScalarBytes: s, powPminus2: i, randomBytes: o } = e, a = r === "x25519";
|
|
312
312
|
if (!a && r !== "x448")
|
|
313
313
|
throw new Error("invalid type");
|
|
314
|
-
const c = o || zr, l = a ? 255 : 448, f = a ? 32 : 56, h = BigInt(a ? 9 : 5), u = BigInt(a ? 121665 : 39081), g = a ? ge ** BigInt(254) : ge ** BigInt(447), w = a ? BigInt(8) * ge ** BigInt(251) - Y : BigInt(4) * ge ** BigInt(445) - Y,
|
|
314
|
+
const c = o || zr, l = a ? 255 : 448, f = a ? 32 : 56, h = BigInt(a ? 9 : 5), u = BigInt(a ? 121665 : 39081), g = a ? ge ** BigInt(254) : ge ** BigInt(447), w = a ? BigInt(8) * ge ** BigInt(251) - Y : BigInt(4) * ge ** BigInt(445) - Y, v = g + w + Y, y = (b) => I(b, t), C = X(h);
|
|
315
315
|
function X(b) {
|
|
316
316
|
return yt(y(b), f);
|
|
317
317
|
}
|
|
@@ -322,27 +322,27 @@ function hs(n) {
|
|
|
322
322
|
function se(b) {
|
|
323
323
|
return Ee(s(Ye("scalar", b, f)));
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function U(b, k) {
|
|
326
326
|
const H = be(re(k), se(b));
|
|
327
327
|
if (H === ie)
|
|
328
328
|
throw new Error("invalid private or public key received");
|
|
329
329
|
return X(H);
|
|
330
330
|
}
|
|
331
331
|
function O(b) {
|
|
332
|
-
return
|
|
332
|
+
return U(b, C);
|
|
333
333
|
}
|
|
334
334
|
function D(b, k, H) {
|
|
335
335
|
const de = y(b * (k - H));
|
|
336
336
|
return k = y(k - de), H = y(H + de), { x_2: k, x_3: H };
|
|
337
337
|
}
|
|
338
338
|
function be(b, k) {
|
|
339
|
-
Qe("u", b, ie, t), Qe("scalar", k, g,
|
|
339
|
+
Qe("u", b, ie, t), Qe("scalar", k, g, v);
|
|
340
340
|
const H = k, de = b;
|
|
341
341
|
let $ = Y, P = ie, j = b, q = Y, Z = ie;
|
|
342
|
-
for (let
|
|
343
|
-
const je = H >>
|
|
342
|
+
for (let ve = BigInt(l - 1); ve >= ie; ve--) {
|
|
343
|
+
const je = H >> ve & Y;
|
|
344
344
|
Z ^= je, { x_2: $, x_3: j } = D(Z, $, j), { x_2: P, x_3: q } = D(Z, P, q), Z = je;
|
|
345
|
-
const
|
|
345
|
+
const me = $ + P, ke = y(me * me), Ae = $ - P, qe = y(Ae * Ae), Ge = ke - qe, Kr = j + q, Wr = j - q, Je = y(Wr * me), Ke = y(Kr * Ae), We = Je + Ke, Xe = Je - Ke;
|
|
346
346
|
j = y(We * We), q = y(de * y(Xe * Xe)), $ = y(ke * qe), P = y(Ge * (ke + y(u * Ge)));
|
|
347
347
|
}
|
|
348
348
|
({ x_2: $, x_3: j } = D(Z, $, j)), { x_2: P, x_3: q } = D(Z, P, q);
|
|
@@ -353,16 +353,16 @@ function hs(n) {
|
|
|
353
353
|
secretKey: f,
|
|
354
354
|
publicKey: f,
|
|
355
355
|
seed: f
|
|
356
|
-
}, ne = (b = c(f)) => (
|
|
356
|
+
}, ne = (b = c(f)) => (Ue(b, fe.seed), b);
|
|
357
357
|
function Gr(b) {
|
|
358
358
|
const k = ne(b);
|
|
359
359
|
return { secretKey: k, publicKey: O(k) };
|
|
360
360
|
}
|
|
361
361
|
return {
|
|
362
362
|
keygen: Gr,
|
|
363
|
-
getSharedSecret: (b, k) =>
|
|
363
|
+
getSharedSecret: (b, k) => U(b, k),
|
|
364
364
|
getPublicKey: (b) => O(b),
|
|
365
|
-
scalarMult:
|
|
365
|
+
scalarMult: U,
|
|
366
366
|
scalarMultBase: O,
|
|
367
367
|
utils: {
|
|
368
368
|
randomSecretKey: ne,
|
|
@@ -383,20 +383,20 @@ const fs = BigInt(1), rt = BigInt(2), ds = BigInt(3), gs = BigInt(5), ws = BigIn
|
|
|
383
383
|
Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
|
|
384
384
|
};
|
|
385
385
|
function Bs(n) {
|
|
386
|
-
const e = BigInt(10), t = BigInt(20), r = BigInt(40), s = BigInt(80), i = St, a = n * n % i * n % i, c =
|
|
387
|
-
return { pow_p_5_8:
|
|
386
|
+
const e = BigInt(10), t = BigInt(20), r = BigInt(40), s = BigInt(80), i = St, a = n * n % i * n % i, c = T(a, rt, i) * a % i, l = T(c, fs, i) * n % i, f = T(l, gs, i) * l % i, h = T(f, e, i) * f % i, u = T(h, t, i) * h % i, g = T(u, r, i) * u % i, w = T(g, s, i) * g % i, v = T(w, s, i) * g % i, y = T(v, e, i) * f % i;
|
|
387
|
+
return { pow_p_5_8: T(y, rt, i) * n % i, b2: a };
|
|
388
388
|
}
|
|
389
389
|
function bs(n) {
|
|
390
390
|
return n[0] &= 248, n[31] &= 127, n[31] |= 64, n;
|
|
391
391
|
}
|
|
392
|
-
const
|
|
393
|
-
const n =
|
|
392
|
+
const vs = _e(ys.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
|
|
393
|
+
const n = vs.ORDER;
|
|
394
394
|
return hs({
|
|
395
395
|
P: n,
|
|
396
396
|
type: "x25519",
|
|
397
397
|
powPminus2: (e) => {
|
|
398
398
|
const { pow_p_5_8: t, b2: r } = Bs(e);
|
|
399
|
-
return I(
|
|
399
|
+
return I(T(t, ds, n) * r, n);
|
|
400
400
|
},
|
|
401
401
|
adjustScalarBytes: bs
|
|
402
402
|
});
|
|
@@ -425,10 +425,10 @@ const ms = _e(ys.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
|
|
|
425
425
|
* SOFTWARE.
|
|
426
426
|
*
|
|
427
427
|
*/
|
|
428
|
-
const
|
|
428
|
+
const ms = "[object ArrayBuffer]";
|
|
429
429
|
class B {
|
|
430
430
|
static isArrayBuffer(e) {
|
|
431
|
-
return Object.prototype.toString.call(e) ===
|
|
431
|
+
return Object.prototype.toString.call(e) === ms;
|
|
432
432
|
}
|
|
433
433
|
static toArrayBuffer(e) {
|
|
434
434
|
return this.isArrayBuffer(e) ? e : e.byteLength === e.buffer.byteLength || e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : this.toUint8Array(e.buffer).slice(e.byteOffset, e.byteOffset + e.byteLength).buffer;
|
|
@@ -508,7 +508,7 @@ class V {
|
|
|
508
508
|
return r;
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
class
|
|
511
|
+
class m {
|
|
512
512
|
static isHex(e) {
|
|
513
513
|
return typeof e === pe && ks.test(e);
|
|
514
514
|
}
|
|
@@ -575,7 +575,7 @@ class v {
|
|
|
575
575
|
const t = this.formatString(e);
|
|
576
576
|
if (!t)
|
|
577
577
|
return new ArrayBuffer(0);
|
|
578
|
-
if (!
|
|
578
|
+
if (!m.isBase64(t))
|
|
579
579
|
throw new TypeError("Argument 'base64Text' is not Base64 encoded");
|
|
580
580
|
return typeof atob < "u" ? this.FromBinary(atob(t)) : new Uint8Array(Buffer.from(t, "base64")).buffer;
|
|
581
581
|
}
|
|
@@ -583,14 +583,14 @@ class v {
|
|
|
583
583
|
const t = this.formatString(e);
|
|
584
584
|
if (!t)
|
|
585
585
|
return new ArrayBuffer(0);
|
|
586
|
-
if (!
|
|
586
|
+
if (!m.isBase64Url(t))
|
|
587
587
|
throw new TypeError("Argument 'base64url' is not Base64Url encoded");
|
|
588
588
|
return this.FromBase64(this.Base64Padding(t.replace(/\-/g, "+").replace(/\_/g, "/")));
|
|
589
589
|
}
|
|
590
590
|
static ToBase64Url(e) {
|
|
591
591
|
return this.ToBase64(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
|
|
592
592
|
}
|
|
593
|
-
static FromUtf8String(e, t =
|
|
593
|
+
static FromUtf8String(e, t = m.DEFAULT_UTF8_ENCODING) {
|
|
594
594
|
switch (t) {
|
|
595
595
|
case "ascii":
|
|
596
596
|
return this.FromBinary(e);
|
|
@@ -606,7 +606,7 @@ class v {
|
|
|
606
606
|
throw new Error(`Unknown type of encoding '${t}'`);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
static ToUtf8String(e, t =
|
|
609
|
+
static ToUtf8String(e, t = m.DEFAULT_UTF8_ENCODING) {
|
|
610
610
|
switch (t) {
|
|
611
611
|
case "ascii":
|
|
612
612
|
return this.ToBinary(e);
|
|
@@ -649,7 +649,7 @@ class v {
|
|
|
649
649
|
let t = this.formatString(e);
|
|
650
650
|
if (!t)
|
|
651
651
|
return new ArrayBuffer(0);
|
|
652
|
-
if (!
|
|
652
|
+
if (!m.isHex(t))
|
|
653
653
|
throw new TypeError("Argument 'hexString' is not HEX encoded");
|
|
654
654
|
t.length % 2 && (t = `0${t}`);
|
|
655
655
|
const r = new Uint8Array(t.length / 2);
|
|
@@ -676,7 +676,7 @@ class v {
|
|
|
676
676
|
return (e == null ? void 0 : e.replace(/[\n\r\t ]/g, "")) || "";
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
|
|
679
|
+
m.DEFAULT_UTF8_ENCODING = "utf8";
|
|
680
680
|
/*!
|
|
681
681
|
Copyright (c) Peculiar Ventures, LLC
|
|
682
682
|
*/
|
|
@@ -827,7 +827,7 @@ function Ce(n) {
|
|
|
827
827
|
}
|
|
828
828
|
return r.buffer;
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function L(n, e, t, r) {
|
|
831
831
|
return e instanceof Uint8Array ? e.byteLength ? t < 0 ? (n.error = "Wrong parameter: inputOffset less than zero", !1) : r < 0 ? (n.error = "Wrong parameter: inputLength less than zero", !1) : e.byteLength - t - r < 0 ? (n.error = "End of input reached before message was fully decoded (inconsistent offset and length values)", !1) : !0 : (n.error = "Wrong parameter: inputBuffer has zero length", !1) : (n.error = "Wrong parameter: inputBuffer must be 'Uint8Array'", !1);
|
|
832
832
|
}
|
|
833
833
|
class He {
|
|
@@ -841,7 +841,7 @@ class He {
|
|
|
841
841
|
return Ce(this.items);
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
|
-
const oe = [new Uint8Array([1])], nt = "0123456789", ee = "", _ = new ArrayBuffer(0),
|
|
844
|
+
const oe = [new Uint8Array([1])], nt = "0123456789", ee = "", _ = new ArrayBuffer(0), Re = new Uint8Array(0), he = "EndOfContent", Et = "OCTET STRING", Nt = "BIT STRING";
|
|
845
845
|
function M(n) {
|
|
846
846
|
var e;
|
|
847
847
|
return e = class extends n {
|
|
@@ -855,11 +855,11 @@ function M(n) {
|
|
|
855
855
|
var s;
|
|
856
856
|
super(...r);
|
|
857
857
|
const i = r[0] || {};
|
|
858
|
-
this.isHexOnly = (s = i.isHexOnly) !== null && s !== void 0 ? s : !1, this.valueHexView = i.valueHex ? B.toUint8Array(i.valueHex) :
|
|
858
|
+
this.isHexOnly = (s = i.isHexOnly) !== null && s !== void 0 ? s : !1, this.valueHexView = i.valueHex ? B.toUint8Array(i.valueHex) : Re;
|
|
859
859
|
}
|
|
860
860
|
fromBER(r, s, i) {
|
|
861
861
|
const o = r instanceof ArrayBuffer ? new Uint8Array(r) : r;
|
|
862
|
-
if (!
|
|
862
|
+
if (!L(this, o, s, i))
|
|
863
863
|
return -1;
|
|
864
864
|
const a = s + i;
|
|
865
865
|
return this.valueHexView = o.subarray(s, a), this.valueHexView.length ? (this.blockLength = i, a) : (this.warnings.push("Zero buffer length"), s);
|
|
@@ -871,7 +871,7 @@ function M(n) {
|
|
|
871
871
|
return {
|
|
872
872
|
...super.toJSON(),
|
|
873
873
|
isHexOnly: this.isHexOnly,
|
|
874
|
-
valueHex:
|
|
874
|
+
valueHex: m.ToHex(this.valueHexView)
|
|
875
875
|
};
|
|
876
876
|
}
|
|
877
877
|
}, e.NAME = "hexBlock", e;
|
|
@@ -886,7 +886,7 @@ class K {
|
|
|
886
886
|
set valueBeforeDecode(e) {
|
|
887
887
|
this.valueBeforeDecodeView = new Uint8Array(e);
|
|
888
888
|
}
|
|
889
|
-
constructor({ blockLength: e = 0, error: t = ee, warnings: r = [], valueBeforeDecode: s =
|
|
889
|
+
constructor({ blockLength: e = 0, error: t = ee, warnings: r = [], valueBeforeDecode: s = Re } = {}) {
|
|
890
890
|
this.blockLength = e, this.error = t, this.warnings = r, this.valueBeforeDecodeView = B.toUint8Array(s);
|
|
891
891
|
}
|
|
892
892
|
toJSON() {
|
|
@@ -895,7 +895,7 @@ class K {
|
|
|
895
895
|
blockLength: this.blockLength,
|
|
896
896
|
error: this.error,
|
|
897
897
|
warnings: this.warnings,
|
|
898
|
-
valueBeforeDecode:
|
|
898
|
+
valueBeforeDecode: m.ToHex(this.valueBeforeDecodeView)
|
|
899
899
|
};
|
|
900
900
|
}
|
|
901
901
|
}
|
|
@@ -912,7 +912,7 @@ S.NAME = "valueBlock";
|
|
|
912
912
|
class It extends M(K) {
|
|
913
913
|
constructor({ idBlock: e = {} } = {}) {
|
|
914
914
|
var t, r, s, i;
|
|
915
|
-
super(), e ? (this.isHexOnly = (t = e.isHexOnly) !== null && t !== void 0 ? t : !1, this.valueHexView = e.valueHex ? B.toUint8Array(e.valueHex) :
|
|
915
|
+
super(), e ? (this.isHexOnly = (t = e.isHexOnly) !== null && t !== void 0 ? t : !1, this.valueHexView = e.valueHex ? B.toUint8Array(e.valueHex) : Re, this.tagClass = (r = e.tagClass) !== null && r !== void 0 ? r : -1, this.tagNumber = (s = e.tagNumber) !== null && s !== void 0 ? s : -1, this.isConstructed = (i = e.isConstructed) !== null && i !== void 0 ? i : !1) : (this.tagClass = -1, this.tagNumber = -1, this.isConstructed = !1);
|
|
916
916
|
}
|
|
917
917
|
toBER(e = !1) {
|
|
918
918
|
let t = 0;
|
|
@@ -960,7 +960,7 @@ class It extends M(K) {
|
|
|
960
960
|
}
|
|
961
961
|
fromBER(e, t, r) {
|
|
962
962
|
const s = B.toUint8Array(e);
|
|
963
|
-
if (!
|
|
963
|
+
if (!L(this, s, t, r))
|
|
964
964
|
return -1;
|
|
965
965
|
const i = s.subarray(t, t + r);
|
|
966
966
|
if (i.length === 0)
|
|
@@ -1033,14 +1033,14 @@ class It extends M(K) {
|
|
|
1033
1033
|
}
|
|
1034
1034
|
}
|
|
1035
1035
|
It.NAME = "identificationBlock";
|
|
1036
|
-
class
|
|
1036
|
+
class Tt extends K {
|
|
1037
1037
|
constructor({ lenBlock: e = {} } = {}) {
|
|
1038
1038
|
var t, r, s;
|
|
1039
1039
|
super(), this.isIndefiniteForm = (t = e.isIndefiniteForm) !== null && t !== void 0 ? t : !1, this.longFormUsed = (r = e.longFormUsed) !== null && r !== void 0 ? r : !1, this.length = (s = e.length) !== null && s !== void 0 ? s : 0;
|
|
1040
1040
|
}
|
|
1041
1041
|
fromBER(e, t, r) {
|
|
1042
1042
|
const s = B.toUint8Array(e);
|
|
1043
|
-
if (!
|
|
1043
|
+
if (!L(this, s, t, r))
|
|
1044
1044
|
return -1;
|
|
1045
1045
|
const i = s.subarray(t, t + r);
|
|
1046
1046
|
if (i.length === 0)
|
|
@@ -1086,11 +1086,11 @@ class Ut extends K {
|
|
|
1086
1086
|
};
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
|
-
|
|
1089
|
+
Tt.NAME = "lengthBlock";
|
|
1090
1090
|
const d = {};
|
|
1091
1091
|
class A extends K {
|
|
1092
1092
|
constructor({ name: e = ee, optional: t = !1, primitiveSchema: r, ...s } = {}, i) {
|
|
1093
|
-
super(s), this.name = e, this.optional = t, r && (this.primitiveSchema = r), this.idBlock = new It(s), this.lenBlock = new
|
|
1093
|
+
super(s), this.name = e, this.optional = t, r && (this.primitiveSchema = r), this.idBlock = new It(s), this.lenBlock = new Tt(s), this.valueBlock = i ? new i(s) : new S(s);
|
|
1094
1094
|
}
|
|
1095
1095
|
fromBER(e, t, r) {
|
|
1096
1096
|
const s = this.valueBlock.fromBER(e, t, this.lenBlock.isIndefiniteForm ? r : this.lenBlock.length);
|
|
@@ -1098,7 +1098,7 @@ class A extends K {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
toBER(e, t) {
|
|
1100
1100
|
const r = t || new He();
|
|
1101
|
-
t ||
|
|
1101
|
+
t || Ut(this);
|
|
1102
1102
|
const s = this.idBlock.toBER(e);
|
|
1103
1103
|
if (r.write(s), this.lenBlock.isIndefiniteForm)
|
|
1104
1104
|
r.write(new Uint8Array([128]).buffer), this.valueBlock.toBER(e, r), r.write(new ArrayBuffer(2));
|
|
@@ -1122,10 +1122,10 @@ class A extends K {
|
|
|
1122
1122
|
return this.primitiveSchema && (e.primitiveSchema = this.primitiveSchema.toJSON()), e;
|
|
1123
1123
|
}
|
|
1124
1124
|
toString(e = "ascii") {
|
|
1125
|
-
return e === "ascii" ? this.onAsciiEncoding() :
|
|
1125
|
+
return e === "ascii" ? this.onAsciiEncoding() : m.ToHex(this.toBER());
|
|
1126
1126
|
}
|
|
1127
1127
|
onAsciiEncoding() {
|
|
1128
|
-
const e = this.constructor.NAME, t =
|
|
1128
|
+
const e = this.constructor.NAME, t = m.ToHex(this.valueBlock.valueBeforeDecodeView);
|
|
1129
1129
|
return `${e} : ${t}`;
|
|
1130
1130
|
}
|
|
1131
1131
|
isEqual(e) {
|
|
@@ -1138,11 +1138,11 @@ class A extends K {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
1140
|
A.NAME = "BaseBlock";
|
|
1141
|
-
function
|
|
1141
|
+
function Ut(n) {
|
|
1142
1142
|
var e;
|
|
1143
1143
|
if (n instanceof d.Constructed)
|
|
1144
1144
|
for (const t of n.valueBlock.value)
|
|
1145
|
-
|
|
1145
|
+
Ut(t) && (n.lenBlock.isIndefiniteForm = !0);
|
|
1146
1146
|
return !!(!((e = n.lenBlock) === null || e === void 0) && e.isIndefiniteForm);
|
|
1147
1147
|
}
|
|
1148
1148
|
class Vt extends A {
|
|
@@ -1189,7 +1189,7 @@ function Be(n, e = 0, t = n.length) {
|
|
|
1189
1189
|
const r = e;
|
|
1190
1190
|
let s = new A({}, S);
|
|
1191
1191
|
const i = new K();
|
|
1192
|
-
if (!
|
|
1192
|
+
if (!L(i, n, e, t))
|
|
1193
1193
|
return s.error = i.error, {
|
|
1194
1194
|
offset: -1,
|
|
1195
1195
|
result: s
|
|
@@ -1360,7 +1360,7 @@ class F extends S {
|
|
|
1360
1360
|
}
|
|
1361
1361
|
fromBER(e, t, r) {
|
|
1362
1362
|
const s = B.toUint8Array(e);
|
|
1363
|
-
if (!
|
|
1363
|
+
if (!L(this, s, t, r))
|
|
1364
1364
|
return -1;
|
|
1365
1365
|
if (this.valueBeforeDecodeView = s.subarray(t, t + r), this.valueBeforeDecodeView.length === 0)
|
|
1366
1366
|
return this.warnings.push("Zero buffer length"), t;
|
|
@@ -1392,7 +1392,7 @@ class F extends S {
|
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
1394
|
F.NAME = "ConstructedValueBlock";
|
|
1395
|
-
var
|
|
1395
|
+
var Rt;
|
|
1396
1396
|
class te extends A {
|
|
1397
1397
|
constructor(e = {}) {
|
|
1398
1398
|
super(e, F), this.idBlock.isConstructed = !0;
|
|
@@ -1414,10 +1414,10 @@ ${e.join(`
|
|
|
1414
1414
|
`)}` : `${t} :`;
|
|
1415
1415
|
}
|
|
1416
1416
|
}
|
|
1417
|
-
|
|
1418
|
-
d.Constructed =
|
|
1417
|
+
Rt = te;
|
|
1418
|
+
d.Constructed = Rt;
|
|
1419
1419
|
te.NAME = "CONSTRUCTED";
|
|
1420
|
-
class
|
|
1420
|
+
class Lt extends S {
|
|
1421
1421
|
fromBER(e, t, r) {
|
|
1422
1422
|
return t;
|
|
1423
1423
|
}
|
|
@@ -1425,11 +1425,11 @@ class Rt extends S {
|
|
|
1425
1425
|
return _;
|
|
1426
1426
|
}
|
|
1427
1427
|
}
|
|
1428
|
-
|
|
1428
|
+
Lt.override = "EndOfContentValueBlock";
|
|
1429
1429
|
var Mt;
|
|
1430
1430
|
class Ot extends A {
|
|
1431
1431
|
constructor(e = {}) {
|
|
1432
|
-
super(e,
|
|
1432
|
+
super(e, Lt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 0;
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
1435
|
Mt = Ot;
|
|
@@ -1473,7 +1473,7 @@ class Pt extends M(S) {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
fromBER(e, t, r) {
|
|
1475
1475
|
const s = B.toUint8Array(e);
|
|
1476
|
-
return
|
|
1476
|
+
return L(this, s, t, r) ? (this.valueHexView = s.subarray(t, t + r), r > 1 && this.warnings.push("Boolean value encoded in more then 1 octet"), this.isHexOnly = !0, pt.call(this), this.blockLength = r, t + r) : -1;
|
|
1477
1477
|
}
|
|
1478
1478
|
toBER() {
|
|
1479
1479
|
return this.valueHexView.slice();
|
|
@@ -1538,7 +1538,7 @@ class qt extends M(F) {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
1540
|
qt.NAME = "OctetStringValueBlock";
|
|
1541
|
-
var
|
|
1541
|
+
var Le;
|
|
1542
1542
|
class Gt extends A {
|
|
1543
1543
|
constructor({ idBlock: e = {}, lenBlock: t = {}, ...r } = {}) {
|
|
1544
1544
|
var s, i;
|
|
@@ -1572,7 +1572,7 @@ class Gt extends A {
|
|
|
1572
1572
|
onAsciiEncoding() {
|
|
1573
1573
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length)
|
|
1574
1574
|
return te.prototype.onAsciiEncoding.call(this);
|
|
1575
|
-
const e = this.constructor.NAME, t =
|
|
1575
|
+
const e = this.constructor.NAME, t = m.ToHex(this.valueBlock.valueHexView);
|
|
1576
1576
|
return `${e} : ${t}`;
|
|
1577
1577
|
}
|
|
1578
1578
|
getValue() {
|
|
@@ -1580,12 +1580,12 @@ class Gt extends A {
|
|
|
1580
1580
|
return this.valueBlock.valueHexView.slice().buffer;
|
|
1581
1581
|
const e = [];
|
|
1582
1582
|
for (const t of this.valueBlock.value)
|
|
1583
|
-
t instanceof
|
|
1583
|
+
t instanceof Le && e.push(t.valueBlock.valueHexView);
|
|
1584
1584
|
return B.concat(e);
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
1587
|
-
|
|
1588
|
-
d.OctetString =
|
|
1587
|
+
Le = Gt;
|
|
1588
|
+
d.OctetString = Le;
|
|
1589
1589
|
Gt.NAME = Et;
|
|
1590
1590
|
class Jt extends M(F) {
|
|
1591
1591
|
constructor({ unusedBits: e = 0, isConstructed: t = !1, ...r } = {}) {
|
|
@@ -1615,7 +1615,7 @@ class Jt extends M(F) {
|
|
|
1615
1615
|
return s;
|
|
1616
1616
|
}
|
|
1617
1617
|
const i = B.toUint8Array(e);
|
|
1618
|
-
if (!
|
|
1618
|
+
if (!L(this, i, t, r))
|
|
1619
1619
|
return -1;
|
|
1620
1620
|
const o = i.subarray(t, t + r);
|
|
1621
1621
|
if (this.unusedBits = o[0], this.unusedBits > 7)
|
|
@@ -1688,7 +1688,7 @@ Kt = Me;
|
|
|
1688
1688
|
d.BitString = Kt;
|
|
1689
1689
|
Me.NAME = Nt;
|
|
1690
1690
|
var Wt;
|
|
1691
|
-
function
|
|
1691
|
+
function Ts(n, e) {
|
|
1692
1692
|
const t = new Uint8Array([0]), r = new Uint8Array(n), s = new Uint8Array(e);
|
|
1693
1693
|
let i = r.slice(0);
|
|
1694
1694
|
const o = i.length - 1, a = s.slice(0), c = a.length - 1;
|
|
@@ -1726,7 +1726,7 @@ function it(n) {
|
|
|
1726
1726
|
}
|
|
1727
1727
|
return oe[n];
|
|
1728
1728
|
}
|
|
1729
|
-
function
|
|
1729
|
+
function Us(n, e) {
|
|
1730
1730
|
let t = 0;
|
|
1731
1731
|
const r = new Uint8Array(n), s = new Uint8Array(e), i = r.slice(0), o = i.length - 1, a = s.slice(0), c = a.length - 1;
|
|
1732
1732
|
let l, f = 0;
|
|
@@ -1807,10 +1807,10 @@ class Oe extends M(S) {
|
|
|
1807
1807
|
if ((s & 1) === 1)
|
|
1808
1808
|
switch (r) {
|
|
1809
1809
|
case e:
|
|
1810
|
-
t =
|
|
1810
|
+
t = Us(it(r), t), o = "-";
|
|
1811
1811
|
break;
|
|
1812
1812
|
default:
|
|
1813
|
-
t =
|
|
1813
|
+
t = Ts(t, it(r));
|
|
1814
1814
|
}
|
|
1815
1815
|
r++, s >>= 1;
|
|
1816
1816
|
}
|
|
@@ -1840,11 +1840,11 @@ class De extends A {
|
|
|
1840
1840
|
}
|
|
1841
1841
|
static fromBigInt(e) {
|
|
1842
1842
|
we();
|
|
1843
|
-
const t = BigInt(e), r = new He(), s = t.toString(16).replace(/^-/, ""), i = new Uint8Array(
|
|
1843
|
+
const t = BigInt(e), r = new He(), s = t.toString(16).replace(/^-/, ""), i = new Uint8Array(m.FromHex(s));
|
|
1844
1844
|
if (t < 0) {
|
|
1845
1845
|
const a = new Uint8Array(i.length + (i[0] & 128 ? 1 : 0));
|
|
1846
1846
|
a[0] |= 128;
|
|
1847
|
-
const l = BigInt(`0x${
|
|
1847
|
+
const l = BigInt(`0x${m.ToHex(a)}`) + t, f = B.toUint8Array(m.FromHex(l.toString(16)));
|
|
1848
1848
|
f[0] |= 128, r.write(f);
|
|
1849
1849
|
} else
|
|
1850
1850
|
i[0] & 128 && r.write(new Uint8Array([0])), r.write(i);
|
|
@@ -1883,7 +1883,7 @@ class Ie extends M(S) {
|
|
|
1883
1883
|
if (!r)
|
|
1884
1884
|
return t;
|
|
1885
1885
|
const s = B.toUint8Array(e);
|
|
1886
|
-
if (!
|
|
1886
|
+
if (!L(this, s, t, r))
|
|
1887
1887
|
return -1;
|
|
1888
1888
|
const i = s.subarray(t, t + r);
|
|
1889
1889
|
this.valueHexView = new Uint8Array(r);
|
|
@@ -1928,7 +1928,7 @@ class Ie extends M(S) {
|
|
|
1928
1928
|
toString() {
|
|
1929
1929
|
let e = "";
|
|
1930
1930
|
if (this.isHexOnly)
|
|
1931
|
-
e =
|
|
1931
|
+
e = m.ToHex(this.valueHexView);
|
|
1932
1932
|
else if (this.isFirstSid) {
|
|
1933
1933
|
let t = this.valueDec;
|
|
1934
1934
|
this.valueDec <= 39 ? e = "0." : this.valueDec <= 79 ? (e = "1.", t -= 40) : (e = "2.", t -= 80), e += t.toString();
|
|
@@ -2050,7 +2050,7 @@ class $e extends A {
|
|
|
2050
2050
|
Yt = $e;
|
|
2051
2051
|
d.ObjectIdentifier = Yt;
|
|
2052
2052
|
$e.NAME = "OBJECT IDENTIFIER";
|
|
2053
|
-
class
|
|
2053
|
+
class Te extends M(K) {
|
|
2054
2054
|
constructor({ valueDec: e = 0, ...t } = {}) {
|
|
2055
2055
|
super(t), this.valueDec = e;
|
|
2056
2056
|
}
|
|
@@ -2058,7 +2058,7 @@ class Ue extends M(K) {
|
|
|
2058
2058
|
if (r === 0)
|
|
2059
2059
|
return t;
|
|
2060
2060
|
const s = B.toUint8Array(e);
|
|
2061
|
-
if (!
|
|
2061
|
+
if (!L(this, s, t, r))
|
|
2062
2062
|
return -1;
|
|
2063
2063
|
const i = s.subarray(t, t + r);
|
|
2064
2064
|
this.valueHexView = new Uint8Array(r);
|
|
@@ -2092,7 +2092,7 @@ class Ue extends M(K) {
|
|
|
2092
2092
|
}
|
|
2093
2093
|
toString() {
|
|
2094
2094
|
let e = "";
|
|
2095
|
-
return this.isHexOnly ? e =
|
|
2095
|
+
return this.isHexOnly ? e = m.ToHex(this.valueHexView) : e = this.valueDec.toString(), e;
|
|
2096
2096
|
}
|
|
2097
2097
|
toJSON() {
|
|
2098
2098
|
return {
|
|
@@ -2101,7 +2101,7 @@ class Ue extends M(K) {
|
|
|
2101
2101
|
};
|
|
2102
2102
|
}
|
|
2103
2103
|
}
|
|
2104
|
-
|
|
2104
|
+
Te.NAME = "relativeSidBlock";
|
|
2105
2105
|
class Qt extends S {
|
|
2106
2106
|
constructor({ value: e = ee, ...t } = {}) {
|
|
2107
2107
|
super(t), this.value = [], e && this.fromString(e);
|
|
@@ -2109,7 +2109,7 @@ class Qt extends S {
|
|
|
2109
2109
|
fromBER(e, t, r) {
|
|
2110
2110
|
let s = t;
|
|
2111
2111
|
for (; r > 0; ) {
|
|
2112
|
-
const i = new
|
|
2112
|
+
const i = new Te();
|
|
2113
2113
|
if (s = i.fromBER(e, s, r), s === -1)
|
|
2114
2114
|
return this.blockLength = 0, this.error = i.error, s;
|
|
2115
2115
|
this.blockLength += i.blockLength, r -= i.blockLength, this.value.push(i);
|
|
@@ -2131,7 +2131,7 @@ class Qt extends S {
|
|
|
2131
2131
|
let t = 0, r = 0, s = "";
|
|
2132
2132
|
do {
|
|
2133
2133
|
r = e.indexOf(".", t), r === -1 ? s = e.substring(t) : s = e.substring(t, r), t = r + 1;
|
|
2134
|
-
const i = new
|
|
2134
|
+
const i = new Te();
|
|
2135
2135
|
if (i.valueDec = parseInt(s, 10), isNaN(i.valueDec))
|
|
2136
2136
|
return !0;
|
|
2137
2137
|
this.value.push(i);
|
|
@@ -2235,13 +2235,13 @@ class cr extends N {
|
|
|
2235
2235
|
fromBuffer(e) {
|
|
2236
2236
|
this.valueBlock.valueHexView = B.toUint8Array(e);
|
|
2237
2237
|
try {
|
|
2238
|
-
this.valueBlock.value =
|
|
2238
|
+
this.valueBlock.value = m.ToUtf8String(e);
|
|
2239
2239
|
} catch (t) {
|
|
2240
|
-
this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`), this.valueBlock.value =
|
|
2240
|
+
this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`), this.valueBlock.value = m.ToBinary(e);
|
|
2241
2241
|
}
|
|
2242
2242
|
}
|
|
2243
2243
|
fromString(e) {
|
|
2244
|
-
this.valueBlock.valueHexView = new Uint8Array(
|
|
2244
|
+
this.valueBlock.valueHexView = new Uint8Array(m.FromUtf8String(e)), this.valueBlock.value = e;
|
|
2245
2245
|
}
|
|
2246
2246
|
}
|
|
2247
2247
|
cr.NAME = "Utf8StringValueBlock";
|
|
@@ -2256,10 +2256,10 @@ d.Utf8String = ar;
|
|
|
2256
2256
|
W.NAME = "UTF8String";
|
|
2257
2257
|
class lr extends N {
|
|
2258
2258
|
fromBuffer(e) {
|
|
2259
|
-
this.valueBlock.value =
|
|
2259
|
+
this.valueBlock.value = m.ToUtf16String(e), this.valueBlock.valueHexView = B.toUint8Array(e);
|
|
2260
2260
|
}
|
|
2261
2261
|
fromString(e) {
|
|
2262
|
-
this.valueBlock.value = e, this.valueBlock.valueHexView = new Uint8Array(
|
|
2262
|
+
this.valueBlock.value = e, this.valueBlock.valueHexView = new Uint8Array(m.FromUtf16String(e));
|
|
2263
2263
|
}
|
|
2264
2264
|
}
|
|
2265
2265
|
lr.NAME = "BmpStringValueBlock";
|
|
@@ -2320,15 +2320,15 @@ class br extends N {
|
|
|
2320
2320
|
Br = br;
|
|
2321
2321
|
d.PrintableString = Br;
|
|
2322
2322
|
br.NAME = "PrintableString";
|
|
2323
|
-
var
|
|
2324
|
-
class
|
|
2323
|
+
var vr;
|
|
2324
|
+
class mr extends N {
|
|
2325
2325
|
constructor(e = {}) {
|
|
2326
2326
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 20;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
|
|
2330
|
-
d.TeletexString =
|
|
2331
|
-
|
|
2329
|
+
vr = mr;
|
|
2330
|
+
d.TeletexString = vr;
|
|
2331
|
+
mr.NAME = "TeletexString";
|
|
2332
2332
|
var kr;
|
|
2333
2333
|
class Ar extends N {
|
|
2334
2334
|
constructor(e = {}) {
|
|
@@ -2366,22 +2366,22 @@ Nr = Pe;
|
|
|
2366
2366
|
d.VisibleString = Nr;
|
|
2367
2367
|
Pe.NAME = "VisibleString";
|
|
2368
2368
|
var Ir;
|
|
2369
|
-
class
|
|
2369
|
+
class Tr extends N {
|
|
2370
2370
|
constructor(e = {}) {
|
|
2371
2371
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 27;
|
|
2372
2372
|
}
|
|
2373
2373
|
}
|
|
2374
|
-
Ir =
|
|
2374
|
+
Ir = Tr;
|
|
2375
2375
|
d.GeneralString = Ir;
|
|
2376
|
-
|
|
2377
|
-
var
|
|
2376
|
+
Tr.NAME = "GeneralString";
|
|
2377
|
+
var Ur;
|
|
2378
2378
|
class Vr extends N {
|
|
2379
2379
|
constructor(e = {}) {
|
|
2380
2380
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 29;
|
|
2381
2381
|
}
|
|
2382
2382
|
}
|
|
2383
|
-
|
|
2384
|
-
d.CharacterString =
|
|
2383
|
+
Ur = Vr;
|
|
2384
|
+
d.CharacterString = Ur;
|
|
2385
2385
|
Vr.NAME = "CharacterString";
|
|
2386
2386
|
var _r;
|
|
2387
2387
|
class Fe extends Pe {
|
|
@@ -2567,15 +2567,15 @@ class Hr extends Fe {
|
|
|
2567
2567
|
Cr = Hr;
|
|
2568
2568
|
d.GeneralizedTime = Cr;
|
|
2569
2569
|
Hr.NAME = "GeneralizedTime";
|
|
2570
|
-
var
|
|
2571
|
-
class
|
|
2570
|
+
var Rr;
|
|
2571
|
+
class Lr extends W {
|
|
2572
2572
|
constructor(e = {}) {
|
|
2573
2573
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 31;
|
|
2574
2574
|
}
|
|
2575
2575
|
}
|
|
2576
|
-
|
|
2577
|
-
d.DATE =
|
|
2578
|
-
|
|
2576
|
+
Rr = Lr;
|
|
2577
|
+
d.DATE = Rr;
|
|
2578
|
+
Lr.NAME = "DATE";
|
|
2579
2579
|
var Mr;
|
|
2580
2580
|
class Or extends W {
|
|
2581
2581
|
constructor(e = {}) {
|
|
@@ -2681,7 +2681,7 @@ async function Hs(n) {
|
|
|
2681
2681
|
["sign"]
|
|
2682
2682
|
);
|
|
2683
2683
|
}
|
|
2684
|
-
async function
|
|
2684
|
+
async function Rs(n, e) {
|
|
2685
2685
|
const t = await crypto.subtle.sign(
|
|
2686
2686
|
"HMAC",
|
|
2687
2687
|
n,
|
|
@@ -2689,7 +2689,7 @@ async function Ls(n, e) {
|
|
|
2689
2689
|
);
|
|
2690
2690
|
return new Uint8Array(t);
|
|
2691
2691
|
}
|
|
2692
|
-
function
|
|
2692
|
+
function Ls(n) {
|
|
2693
2693
|
const e = n.replace(/\r/g, "").match(/-----BEGIN [^-]+-----([\s\S]*?)-----END [^-]+-----/);
|
|
2694
2694
|
if (!e) throw new Error("Invalid PEM");
|
|
2695
2695
|
const t = e[1].replace(/[\n\r\s]/g, ""), r = atob(t), s = new Uint8Array(r.length);
|
|
@@ -2697,7 +2697,7 @@ function Rs(n) {
|
|
|
2697
2697
|
return s.buffer;
|
|
2698
2698
|
}
|
|
2699
2699
|
async function Ms(n, e, t) {
|
|
2700
|
-
const r =
|
|
2700
|
+
const r = Ls(n), s = await crypto.subtle.importKey(
|
|
2701
2701
|
"spki",
|
|
2702
2702
|
r,
|
|
2703
2703
|
// SPKI "-----BEGIN PUBLIC KEY-----"
|
|
@@ -2776,19 +2776,19 @@ class ct {
|
|
|
2776
2776
|
try {
|
|
2777
2777
|
const c = JSON.parse(a.data);
|
|
2778
2778
|
if (!c.ciphertext) {
|
|
2779
|
-
const { operation_id: w, iv:
|
|
2779
|
+
const { operation_id: w, iv: v, signature: y, topic: C, correlation_id: X, content_type: re, ...se } = c;
|
|
2780
2780
|
if (!w)
|
|
2781
2781
|
throw new Error("Claim check received but missing operation_id");
|
|
2782
|
-
const
|
|
2782
|
+
const U = await this.executeWithRetry(() => this.client.get(`/responses/${w}`, {}, !0)), O = {
|
|
2783
2783
|
...se,
|
|
2784
2784
|
content_type: re,
|
|
2785
2785
|
topic: C,
|
|
2786
2786
|
correlation_id: X,
|
|
2787
|
-
ciphertext:
|
|
2788
|
-
tot_pages:
|
|
2789
|
-
has_more:
|
|
2790
|
-
page_num:
|
|
2791
|
-
iv:
|
|
2787
|
+
ciphertext: U.data,
|
|
2788
|
+
tot_pages: U.tot_pages,
|
|
2789
|
+
has_more: U.has_more,
|
|
2790
|
+
page_num: U.page_num,
|
|
2791
|
+
iv: v,
|
|
2792
2792
|
signature: y
|
|
2793
2793
|
}, D = await this.client.decryptAndVerify(O);
|
|
2794
2794
|
this.distributeMessage(D);
|
|
@@ -2918,14 +2918,14 @@ class Os {
|
|
|
2918
2918
|
const f = await l.json(), { session_id: h, server_pub: u, server_sig: g, session_expires_at: w } = f;
|
|
2919
2919
|
if (window.__akv = { server_pub: u, server_sig: g }, !h || !u || !g)
|
|
2920
2920
|
throw new Error("Handshake response missing fields");
|
|
2921
|
-
const
|
|
2921
|
+
const v = ae(u), y = ae(g);
|
|
2922
2922
|
if (!await Ms(
|
|
2923
2923
|
this.serverPublicKeyPem,
|
|
2924
|
-
|
|
2924
|
+
v,
|
|
2925
2925
|
y
|
|
2926
2926
|
))
|
|
2927
2927
|
throw new Error("Server signature verification failed");
|
|
2928
|
-
const X = _s(
|
|
2928
|
+
const X = _s(v), re = Se.getSharedSecret(t, X), se = new Uint8Array(0), U = new TextEncoder().encode("health-api-v1"), O = await Cs(re, se, U, 64), D = O.slice(0, 32), be = O.slice(32, 64), fe = await crypto.subtle.importKey(
|
|
2929
2929
|
"raw",
|
|
2930
2930
|
D,
|
|
2931
2931
|
"AES-GCM",
|
|
@@ -2976,7 +2976,7 @@ class Os {
|
|
|
2976
2976
|
await this.ensureSession();
|
|
2977
2977
|
const { sessionId: i, macKey: o } = this.session, a = e.toUpperCase() === "GET" ? "" : { data: Array.isArray(r) ? r : [r] }, { ciphertextB64: c, ivB64: l } = await this.encryptBody(a), f = Math.floor(Date.now() / 1e3).toString(), h = t.split("?")[0], u = `${e.toUpperCase()} ${h}
|
|
2978
2978
|
${f}
|
|
2979
|
-
${c}`, g = await
|
|
2979
|
+
${c}`, g = await Rs(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers({
|
|
2980
2980
|
...s,
|
|
2981
2981
|
"X-Session-Id": i,
|
|
2982
2982
|
"X-Client-Id": this.clientId,
|
|
@@ -2984,8 +2984,8 @@ ${c}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), m = new Headers(
|
|
|
2984
2984
|
"X-Signature": w,
|
|
2985
2985
|
"Content-Type": "application/json"
|
|
2986
2986
|
});
|
|
2987
|
-
return this.getUserId() &&
|
|
2988
|
-
headers:
|
|
2987
|
+
return this.getUserId() && v.append("X-User-Id", this.getUserId()), this.getAccessToken() && !this.isTokenExpired() && v.append("Authorization", `Bearer ${this.getAccessToken()}`), {
|
|
2988
|
+
headers: v,
|
|
2989
2989
|
payload: {
|
|
2990
2990
|
content: c,
|
|
2991
2991
|
iv: l
|
|
@@ -3008,7 +3008,7 @@ ${c}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), m = new Headers(
|
|
|
3008
3008
|
body: JSON.stringify(i)
|
|
3009
3009
|
});
|
|
3010
3010
|
if (!o.ok)
|
|
3011
|
-
throw new Error(`POST ${e} failed: ${o.status} ${o.statusText}
|
|
3011
|
+
throw new Error(`POST ${e} failed: ${o.status} ${o.statusText}`, { cause: o.status });
|
|
3012
3012
|
return e.endsWith("/handshake") ? await o.json() : this.decryptAndVerify(await o.json());
|
|
3013
3013
|
}
|
|
3014
3014
|
// --- Paging Methods ---
|
|
@@ -3096,7 +3096,7 @@ ${c}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), m = new Headers(
|
|
|
3096
3096
|
refreshToken: void 0
|
|
3097
3097
|
});
|
|
3098
3098
|
const t = {};
|
|
3099
|
-
"username" in e && "password" in e && (t.username = e.username, t.password = e.password, t.scope = e.scope, t.oauth_session = e.oauthSession), "username" in e && "otp" in e && (t.username = e.username, t.otp = e.otp, t.scope = e.scope, t.oauth_session = e.oauthSession, t.oauth_flow_id = e.oauthFlowId), "email" in e && "
|
|
3099
|
+
"username" in e && "password" in e && (t.username = e.username, t.password = e.password, t.scope = e.scope, t.oauth_session = e.oauthSession), "username" in e && "otp" in e && (t.username = e.username, t.otp = e.otp, t.scope = e.scope, t.oauth_session = e.oauthSession, t.oauth_flow_id = e.oauthFlowId), "email" in e && "socialToken" in e && "socialProvider" in e && (t.email = e.email, t.social_token = e.socialToken, t.social_provider = e.socialProvider, t.scope = e.scope, t.oauth_session = e.oauthSession), "jwt" in e && this.updateSession({
|
|
3100
3100
|
accessToken: e.jwt,
|
|
3101
3101
|
tokenType: "Bearer"
|
|
3102
3102
|
}), "refreshToken" in e && (t.refresh_token = e.refreshToken);
|