@vitia.ai/secure-api-client-vue 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -22,14 +22,14 @@ function ht(n) {
22
22
  e += Zr[n[t]];
23
23
  return e;
24
24
  }
25
- const H = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
25
+ const L = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
26
26
  function Ze(n) {
27
- if (n >= H._0 && n <= H._9)
28
- return n - H._0;
29
- if (n >= H.A && n <= H.F)
30
- return n - (H.A - 10);
31
- if (n >= H.a && n <= H.f)
32
- return n - (H.a - 10);
27
+ if (n >= L._0 && n <= L._9)
28
+ return n - L._0;
29
+ if (n >= L.A && n <= L.F)
30
+ return n - (L.A - 10);
31
+ if (n >= L.a && n <= L.f)
32
+ return n - (L.a - 10);
33
33
  }
34
34
  function ft(n) {
35
35
  if (typeof n != "string")
@@ -116,7 +116,7 @@ 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), p = BigInt(1), F = /* @__PURE__ */ BigInt(2), Bt = /* @__PURE__ */ BigInt(3), bt = /* @__PURE__ */ BigInt(4), vt = /* @__PURE__ */ BigInt(5), rs = /* @__PURE__ */ BigInt(7), kt = /* @__PURE__ */ BigInt(8), ss = /* @__PURE__ */ BigInt(9), mt = /* @__PURE__ */ BigInt(16);
119
+ const x = BigInt(0), p = BigInt(1), j = /* @__PURE__ */ BigInt(2), Bt = /* @__PURE__ */ BigInt(3), bt = /* @__PURE__ */ BigInt(4), vt = /* @__PURE__ */ BigInt(5), rs = /* @__PURE__ */ BigInt(7), kt = /* @__PURE__ */ BigInt(8), ss = /* @__PURE__ */ BigInt(9), mt = /* @__PURE__ */ BigInt(16);
120
120
  function I(n, e) {
121
121
  const t = n % e;
122
122
  return t >= x ? t : e + t;
@@ -150,11 +150,11 @@ function At(n, e) {
150
150
  return Te(n, r, e), r;
151
151
  }
152
152
  function ns(n, e) {
153
- const t = (n.ORDER - vt) / kt, r = n.mul(e, F), s = n.pow(r, t), i = n.mul(e, s), o = n.mul(n.mul(i, F), s), c = n.mul(i, n.sub(o, n.ONE));
153
+ const t = (n.ORDER - vt) / kt, r = n.mul(e, j), s = n.pow(r, t), i = n.mul(e, s), o = n.mul(n.mul(i, j), s), c = n.mul(i, n.sub(o, n.ONE));
154
154
  return Te(n, c, e), c;
155
155
  }
156
156
  function is(n) {
157
- const e = Ce(n), t = xt(n), r = t(e, e.neg(e.ONE)), s = t(e, r), i = t(e, e.neg(r)), o = (n + rs) / mt;
157
+ const e = _e(n), t = xt(n), r = t(e, e.neg(e.ONE)), s = t(e, r), i = t(e, e.neg(r)), o = (n + rs) / mt;
158
158
  return (c, a) => {
159
159
  let l = c.pow(a, o), f = c.mul(l, r);
160
160
  const h = c.mul(l, s), u = c.mul(l, i), g = c.eql(c.sqr(f), a), w = c.eql(c.sqr(h), a);
@@ -167,17 +167,17 @@ function xt(n) {
167
167
  if (n < Bt)
168
168
  throw new Error("sqrt is not defined for small field");
169
169
  let e = n - p, t = 0;
170
- for (; e % F === x; )
171
- e /= F, t++;
172
- let r = F;
173
- const s = Ce(n);
170
+ for (; e % j === x; )
171
+ e /= j, t++;
172
+ let r = j;
173
+ const s = _e(n);
174
174
  for (; tt(s, r) === 1; )
175
175
  if (r++ > 1e3)
176
176
  throw new Error("Cannot find square root: probably non-prime P");
177
177
  if (t === 1)
178
178
  return At;
179
179
  let i = s.pow(r, e);
180
- const o = (e + p) / F;
180
+ const o = (e + p) / j;
181
181
  return function(a, l) {
182
182
  if (a.is0(l))
183
183
  return l;
@@ -191,8 +191,8 @@ function xt(n) {
191
191
  for (; !a.eql(v, a.ONE); )
192
192
  if (w++, v = a.sqr(v), w === f)
193
193
  throw new Error("Cannot find square root");
194
- const y = p << BigInt(f - w - 1), C = a.pow(h, y);
195
- f = w, h = a.sqr(C), u = a.mul(u, h), g = a.mul(g, C);
194
+ const y = p << BigInt(f - w - 1), _ = a.pow(h, y);
195
+ f = w, h = a.sqr(_), u = a.mul(u, h), g = a.mul(g, _);
196
196
  }
197
197
  return g;
198
198
  };
@@ -217,7 +217,7 @@ function as(n, e, t = !1) {
217
217
  return e.reduceRight((o, c, a) => n.is0(c) ? o : (r[a] = n.mul(o, r[a]), n.mul(o, c)), i), r;
218
218
  }
219
219
  function tt(n, e) {
220
- const t = (n.ORDER - p) / F, r = n.pow(e, t), s = n.eql(r, n.ONE), i = n.eql(r, n.ZERO), o = n.eql(r, n.neg(n.ONE));
220
+ const t = (n.ORDER - p) / j, r = n.pow(e, t), s = n.eql(r, n.ONE), i = n.eql(r, n.ZERO), o = n.eql(r, n.neg(n.ONE));
221
221
  if (!s && !i && !o)
222
222
  throw new Error("invalid Legendre symbol result");
223
223
  return s ? 1 : i ? 0 : -1;
@@ -227,7 +227,7 @@ function ls(n, e) {
227
227
  const t = e !== void 0 ? e : n.toString(2).length, r = Math.ceil(t / 8);
228
228
  return { nBitLength: t, nByteLength: r };
229
229
  }
230
- function Ce(n, e, t = !1, r = {}) {
230
+ function _e(n, e, t = !1, r = {}) {
231
231
  if (n <= x)
232
232
  throw new Error("invalid field: expected ORDER > 0, got " + n);
233
233
  let s, i, o = !1, c;
@@ -300,7 +300,7 @@ function Ce(n, e, t = !1, r = {}) {
300
300
  return Object.freeze(h);
301
301
  }
302
302
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
303
- const ne = BigInt(0), z = BigInt(1), de = BigInt(2);
303
+ const ie = BigInt(0), z = BigInt(1), ge = BigInt(2);
304
304
  function us(n) {
305
305
  return ts(n, {
306
306
  adjustScalarBytes: "function",
@@ -311,65 +311,65 @@ function hs(n) {
311
311
  const e = us(n), { P: t, type: r, adjustScalarBytes: s, powPminus2: i, randomBytes: o } = e, c = r === "x25519";
312
312
  if (!c && r !== "x448")
313
313
  throw new Error("invalid type");
314
- const a = o || zr, l = c ? 255 : 448, f = c ? 32 : 56, h = BigInt(c ? 9 : 5), u = BigInt(c ? 121665 : 39081), g = c ? de ** BigInt(254) : de ** BigInt(447), w = c ? BigInt(8) * de ** BigInt(251) - z : BigInt(4) * de ** BigInt(445) - z, v = g + w + z, y = (b) => I(b, t), C = J(h);
315
- function J(b) {
314
+ const a = o || zr, l = c ? 255 : 448, f = c ? 32 : 56, h = BigInt(c ? 9 : 5), u = BigInt(c ? 121665 : 39081), g = c ? ge ** BigInt(254) : ge ** BigInt(447), w = c ? BigInt(8) * ge ** BigInt(251) - z : BigInt(4) * ge ** BigInt(445) - z, v = g + w + z, y = (b) => I(b, t), _ = C(h);
315
+ function C(b) {
316
316
  return yt(y(b), f);
317
317
  }
318
318
  function te(b) {
319
319
  const m = Ye("u coordinate", b, f);
320
320
  return c && (m[31] &= 127), y(pe(m));
321
321
  }
322
- function Be(b) {
322
+ function re(b) {
323
323
  return pe(s(Ye("scalar", b, f)));
324
324
  }
325
- function re(b, m) {
326
- const _ = be(te(m), Be(b));
327
- if (_ === ne)
325
+ function se(b, m) {
326
+ const H = be(te(m), re(b));
327
+ if (H === ie)
328
328
  throw new Error("invalid private or public key received");
329
- return J(_);
329
+ return C(H);
330
330
  }
331
331
  function K(b) {
332
- return re(b, C);
332
+ return se(b, _);
333
333
  }
334
- function W(b, m, _) {
335
- const fe = y(b * (m - _));
336
- return m = y(m - fe), _ = y(_ + fe), { x_2: m, x_3: _ };
334
+ function W(b, m, H) {
335
+ const de = y(b * (m - H));
336
+ return m = y(m - de), H = y(H + de), { x_2: m, x_3: H };
337
337
  }
338
338
  function be(b, m) {
339
- Qe("u", b, ne, t), Qe("scalar", m, g, v);
340
- const _ = m, fe = b;
341
- let M = z, O = ne, $ = b, P = z, X = ne;
342
- for (let ve = BigInt(l - 1); ve >= ne; ve--) {
343
- const je = _ >> ve & z;
344
- X ^= je, { x_2: M, x_3: $ } = W(X, M, $), { x_2: O, x_3: P } = W(X, O, P), X = je;
345
- const ke = M + O, me = y(ke * ke), Ae = M - O, qe = y(Ae * Ae), Ge = me - qe, Kr = $ + P, Wr = $ - P, Je = y(Wr * ke), Ke = y(Kr * Ae), We = Je + Ke, Xe = Je - Ke;
346
- $ = y(We * We), P = y(fe * y(Xe * Xe)), M = y(me * qe), O = y(Ge * (me + y(u * Ge)));
347
- }
348
- ({ x_2: M, x_3: $ } = W(X, M, $)), { x_2: O, x_3: P } = W(X, O, P);
349
- const Jr = i(O);
350
- return y(M * Jr);
351
- }
352
- const he = {
339
+ Qe("u", b, ie, t), Qe("scalar", m, g, v);
340
+ const H = m, de = b;
341
+ let O = z, D = ie, P = b, F = z, X = ie;
342
+ for (let ve = BigInt(l - 1); ve >= ie; ve--) {
343
+ const je = H >> ve & z;
344
+ X ^= je, { x_2: O, x_3: P } = W(X, O, P), { x_2: D, x_3: F } = W(X, D, F), X = je;
345
+ const ke = O + D, me = y(ke * ke), Ae = O - D, qe = y(Ae * Ae), Ge = me - qe, Kr = P + F, Wr = P - F, Je = y(Wr * ke), Ke = y(Kr * Ae), We = Je + Ke, Xe = Je - Ke;
346
+ P = y(We * We), F = y(de * y(Xe * Xe)), O = y(me * qe), D = y(Ge * (me + y(u * Ge)));
347
+ }
348
+ ({ x_2: O, x_3: P } = W(X, O, P)), { x_2: D, x_3: F } = W(X, D, F);
349
+ const Jr = i(D);
350
+ return y(O * Jr);
351
+ }
352
+ const fe = {
353
353
  secretKey: f,
354
354
  publicKey: f,
355
355
  seed: f
356
- }, se = (b = a(f)) => (Ve(b, he.seed), b);
356
+ }, ne = (b = a(f)) => (Ve(b, fe.seed), b);
357
357
  function Gr(b) {
358
- const m = se(b);
358
+ const m = ne(b);
359
359
  return { secretKey: m, publicKey: K(m) };
360
360
  }
361
361
  return {
362
362
  keygen: Gr,
363
- getSharedSecret: (b, m) => re(b, m),
363
+ getSharedSecret: (b, m) => se(b, m),
364
364
  getPublicKey: (b) => K(b),
365
- scalarMult: re,
365
+ scalarMult: se,
366
366
  scalarMultBase: K,
367
367
  utils: {
368
- randomSecretKey: se,
369
- randomPrivateKey: se
368
+ randomSecretKey: ne,
369
+ randomPrivateKey: ne
370
370
  },
371
- GuBytes: C.slice(),
372
- lengths: he
371
+ GuBytes: _.slice(),
372
+ lengths: fe
373
373
  };
374
374
  }
375
375
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
@@ -389,7 +389,7 @@ function Bs(n) {
389
389
  function bs(n) {
390
390
  return n[0] &= 248, n[31] &= 127, n[31] |= 64, n;
391
391
  }
392
- const vs = Ce(ys.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
392
+ const vs = _e(ys.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
393
393
  const n = vs.ORDER;
394
394
  return hs({
395
395
  P: n,
@@ -688,7 +688,7 @@ function Y(n, e) {
688
688
  t += n[n.length - 1 - r] * Math.pow(2, e * r);
689
689
  return t;
690
690
  }
691
- function j(n, e, t = -1) {
691
+ function q(n, e, t = -1) {
692
692
  const r = t;
693
693
  let s = n, i = 0, o = Math.pow(2, e);
694
694
  for (let c = 1; c < 8; c++) {
@@ -742,10 +742,10 @@ function Ss(n) {
742
742
  for (let r = 1; r < 8; r++) {
743
743
  if (e <= t) {
744
744
  if (n < 0) {
745
- const o = t - e, c = j(o, 8, r), a = new Uint8Array(c);
745
+ const o = t - e, c = q(o, 8, r), a = new Uint8Array(c);
746
746
  return a[0] |= 128, c;
747
747
  }
748
- let s = j(e, 8, r), i = new Uint8Array(s);
748
+ let s = q(e, 8, r), i = new Uint8Array(s);
749
749
  if (i[0] & 128) {
750
750
  const o = s.slice(0), c = new Uint8Array(o);
751
751
  s = new ArrayBuffer(s.byteLength + 1), i = new Uint8Array(s);
@@ -810,11 +810,11 @@ function E(n, e) {
810
810
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
811
811
  *
812
812
  */
813
- function ge() {
813
+ function we() {
814
814
  if (typeof BigInt > "u")
815
815
  throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.");
816
816
  }
817
- function _e(n) {
817
+ function Ce(n) {
818
818
  let e = 0, t = 0;
819
819
  for (let s = 0; s < n.length; s++) {
820
820
  const i = n[s];
@@ -827,7 +827,7 @@ function _e(n) {
827
827
  }
828
828
  return r.buffer;
829
829
  }
830
- function L(n, e, t, r) {
830
+ function R(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 {
@@ -838,11 +838,11 @@ class He {
838
838
  this.items.push(e);
839
839
  }
840
840
  final() {
841
- return _e(this.items);
841
+ return Ce(this.items);
842
842
  }
843
843
  }
844
- const ie = [new Uint8Array([1])], nt = "0123456789", Q = "", T = new ArrayBuffer(0), Le = new Uint8Array(0), ue = "EndOfContent", pt = "OCTET STRING", Nt = "BIT STRING";
845
- function R(n) {
844
+ const oe = [new Uint8Array([1])], nt = "0123456789", Q = "", T = new ArrayBuffer(0), Le = new Uint8Array(0), he = "EndOfContent", pt = "OCTET STRING", Nt = "BIT STRING";
845
+ function M(n) {
846
846
  var e;
847
847
  return e = class extends n {
848
848
  get valueHex() {
@@ -859,7 +859,7 @@ function R(n) {
859
859
  }
860
860
  fromBER(r, s, i) {
861
861
  const o = r instanceof ArrayBuffer ? new Uint8Array(r) : r;
862
- if (!L(this, o, s, i))
862
+ if (!R(this, o, s, i))
863
863
  return -1;
864
864
  const c = s + i;
865
865
  return this.valueHexView = o.subarray(s, c), this.valueHexView.length ? (this.blockLength = i, c) : (this.warnings.push("Zero buffer length"), s);
@@ -876,7 +876,7 @@ function R(n) {
876
876
  }
877
877
  }, e.NAME = "hexBlock", e;
878
878
  }
879
- class q {
879
+ class G {
880
880
  static blockName() {
881
881
  return this.NAME;
882
882
  }
@@ -899,8 +899,8 @@ class q {
899
899
  };
900
900
  }
901
901
  }
902
- q.NAME = "baseBlock";
903
- class S extends q {
902
+ G.NAME = "baseBlock";
903
+ class S extends G {
904
904
  fromBER(e, t, r) {
905
905
  throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'");
906
906
  }
@@ -909,7 +909,7 @@ class S extends q {
909
909
  }
910
910
  }
911
911
  S.NAME = "valueBlock";
912
- class It extends R(q) {
912
+ class It extends M(G) {
913
913
  constructor({ idBlock: e = {} } = {}) {
914
914
  var t, r, s, i;
915
915
  super(), e ? (this.isHexOnly = (t = e.isHexOnly) !== null && t !== void 0 ? t : !1, this.valueHexView = e.valueHex ? B.toUint8Array(e.valueHex) : Le, 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);
@@ -941,7 +941,7 @@ class It extends R(q) {
941
941
  return s.buffer;
942
942
  }
943
943
  if (!this.isHexOnly) {
944
- const s = j(this.tagNumber, 7), i = new Uint8Array(s), o = s.byteLength, c = new Uint8Array(o + 1);
944
+ const s = q(this.tagNumber, 7), i = new Uint8Array(s), o = s.byteLength, c = new Uint8Array(o + 1);
945
945
  if (c[0] = t | 31, !e) {
946
946
  for (let a = 0; a < o - 1; a++)
947
947
  c[a + 1] = i[a] | 128;
@@ -960,7 +960,7 @@ class It extends R(q) {
960
960
  }
961
961
  fromBER(e, t, r) {
962
962
  const s = B.toUint8Array(e);
963
- if (!L(this, s, t, r))
963
+ if (!R(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 R(q) {
1033
1033
  }
1034
1034
  }
1035
1035
  It.NAME = "identificationBlock";
1036
- class Ut extends q {
1036
+ class Ut extends G {
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 (!L(this, s, t, r))
1043
+ if (!R(this, s, t, r))
1044
1044
  return -1;
1045
1045
  const i = s.subarray(t, t + r);
1046
1046
  if (i.length === 0)
@@ -1064,7 +1064,7 @@ class Ut extends q {
1064
1064
  if (this.length > 127 && (this.longFormUsed = !0), this.isIndefiniteForm)
1065
1065
  return t = new ArrayBuffer(1), e === !1 && (r = new Uint8Array(t), r[0] = 128), t;
1066
1066
  if (this.longFormUsed) {
1067
- const s = j(this.length, 8);
1067
+ const s = q(this.length, 8);
1068
1068
  if (s.byteLength > 127)
1069
1069
  return this.error = "Too big length", T;
1070
1070
  if (t = new ArrayBuffer(s.byteLength + 1), e)
@@ -1088,7 +1088,7 @@ class Ut extends q {
1088
1088
  }
1089
1089
  Ut.NAME = "lengthBlock";
1090
1090
  const d = {};
1091
- class A extends q {
1091
+ class A extends G {
1092
1092
  constructor({ name: e = Q, optional: t = !1, primitiveSchema: r, ...s } = {}, i) {
1093
1093
  super(s), this.name = e, this.optional = t, r && (this.primitiveSchema = r), this.idBlock = new It(s), this.lenBlock = new Ut(s), this.valueBlock = i ? new i(s) : new S(s);
1094
1094
  }
@@ -1164,20 +1164,20 @@ class Tt extends A {
1164
1164
  }
1165
1165
  }
1166
1166
  Tt.NAME = "BaseStringBlock";
1167
- class Ct extends R(S) {
1167
+ class _t extends M(S) {
1168
1168
  constructor({ isHexOnly: e = !0, ...t } = {}) {
1169
1169
  super(t), this.isHexOnly = e;
1170
1170
  }
1171
1171
  }
1172
- Ct.NAME = "PrimitiveValueBlock";
1173
- var _t;
1172
+ _t.NAME = "PrimitiveValueBlock";
1173
+ var Ct;
1174
1174
  class Ht extends A {
1175
1175
  constructor(e = {}) {
1176
- super(e, Ct), this.idBlock.isConstructed = !1;
1176
+ super(e, _t), this.idBlock.isConstructed = !1;
1177
1177
  }
1178
1178
  }
1179
- _t = Ht;
1180
- d.Primitive = _t;
1179
+ Ct = Ht;
1180
+ d.Primitive = Ct;
1181
1181
  Ht.NAME = "PRIMITIVE";
1182
1182
  function ps(n, e) {
1183
1183
  if (n instanceof e)
@@ -1185,11 +1185,11 @@ function ps(n, e) {
1185
1185
  const t = new e();
1186
1186
  return t.idBlock = n.idBlock, t.lenBlock = n.lenBlock, t.warnings = n.warnings, t.valueBeforeDecodeView = n.valueBeforeDecodeView, t;
1187
1187
  }
1188
- function ye(n, e = 0, t = n.length) {
1188
+ function Be(n, e = 0, t = n.length) {
1189
1189
  const r = e;
1190
1190
  let s = new A({}, S);
1191
- const i = new q();
1192
- if (!L(i, n, e, t))
1191
+ const i = new G();
1192
+ if (!R(i, n, e, t))
1193
1193
  return s.error = i.error, {
1194
1194
  offset: -1,
1195
1195
  result: s
@@ -1349,30 +1349,30 @@ function Ns(n) {
1349
1349
  result: e
1350
1350
  };
1351
1351
  }
1352
- return ye(B.toUint8Array(n).slice(), 0, n.byteLength);
1352
+ return Be(B.toUint8Array(n).slice(), 0, n.byteLength);
1353
1353
  }
1354
1354
  function Is(n, e) {
1355
1355
  return n ? 1 : e;
1356
1356
  }
1357
- class D extends S {
1357
+ class $ extends S {
1358
1358
  constructor({ value: e = [], isIndefiniteForm: t = !1, ...r } = {}) {
1359
1359
  super(r), this.value = e, this.isIndefiniteForm = t;
1360
1360
  }
1361
1361
  fromBER(e, t, r) {
1362
1362
  const s = B.toUint8Array(e);
1363
- if (!L(this, s, t, r))
1363
+ if (!R(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;
1367
1367
  let i = t;
1368
1368
  for (; Is(this.isIndefiniteForm, r) > 0; ) {
1369
- const o = ye(s, i, r);
1369
+ const o = Be(s, i, r);
1370
1370
  if (o.offset === -1)
1371
1371
  return this.error = o.result.error, this.warnings.concat(o.result.warnings), -1;
1372
- if (i = o.offset, this.blockLength += o.result.blockLength, r -= o.result.blockLength, this.value.push(o.result), this.isIndefiniteForm && o.result.constructor.NAME === ue)
1372
+ if (i = o.offset, this.blockLength += o.result.blockLength, r -= o.result.blockLength, this.value.push(o.result), this.isIndefiniteForm && o.result.constructor.NAME === he)
1373
1373
  break;
1374
1374
  }
1375
- return this.isIndefiniteForm && (this.value[this.value.length - 1].constructor.NAME === ue ? this.value.pop() : this.warnings.push("No EndOfContent block encoded")), i;
1375
+ return this.isIndefiniteForm && (this.value[this.value.length - 1].constructor.NAME === he ? this.value.pop() : this.warnings.push("No EndOfContent block encoded")), i;
1376
1376
  }
1377
1377
  toBER(e, t) {
1378
1378
  const r = t || new He();
@@ -1391,11 +1391,11 @@ class D extends S {
1391
1391
  return e;
1392
1392
  }
1393
1393
  }
1394
- D.NAME = "ConstructedValueBlock";
1394
+ $.NAME = "ConstructedValueBlock";
1395
1395
  var Lt;
1396
1396
  class ee extends A {
1397
1397
  constructor(e = {}) {
1398
- super(e, D), this.idBlock.isConstructed = !0;
1398
+ super(e, $), this.idBlock.isConstructed = !0;
1399
1399
  }
1400
1400
  fromBER(e, t, r) {
1401
1401
  this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
@@ -1434,7 +1434,7 @@ class Ot extends A {
1434
1434
  }
1435
1435
  Mt = Ot;
1436
1436
  d.EndOfContent = Mt;
1437
- Ot.NAME = ue;
1437
+ Ot.NAME = he;
1438
1438
  var Dt;
1439
1439
  class $t extends A {
1440
1440
  constructor(e = {}) {
@@ -1458,7 +1458,7 @@ class $t extends A {
1458
1458
  Dt = $t;
1459
1459
  d.Null = Dt;
1460
1460
  $t.NAME = "NULL";
1461
- class Pt extends R(S) {
1461
+ class Pt extends M(S) {
1462
1462
  get value() {
1463
1463
  for (const e of this.valueHexView)
1464
1464
  if (e > 0)
@@ -1473,7 +1473,7 @@ class Pt extends R(S) {
1473
1473
  }
1474
1474
  fromBER(e, t, r) {
1475
1475
  const s = B.toUint8Array(e);
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, Et.call(this), this.blockLength = r, t + r) : -1;
1476
+ return R(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, Et.call(this), this.blockLength = r, t + r) : -1;
1477
1477
  }
1478
1478
  toBER() {
1479
1479
  return this.valueHexView.slice();
@@ -1504,18 +1504,18 @@ class jt extends A {
1504
1504
  Ft = jt;
1505
1505
  d.Boolean = Ft;
1506
1506
  jt.NAME = "BOOLEAN";
1507
- class qt extends R(D) {
1507
+ class qt extends M($) {
1508
1508
  constructor({ isConstructed: e = !1, ...t } = {}) {
1509
1509
  super(t), this.isConstructed = e;
1510
1510
  }
1511
1511
  fromBER(e, t, r) {
1512
1512
  let s = 0;
1513
1513
  if (this.isConstructed) {
1514
- if (this.isHexOnly = !1, s = D.prototype.fromBER.call(this, e, t, r), s === -1)
1514
+ if (this.isHexOnly = !1, s = $.prototype.fromBER.call(this, e, t, r), s === -1)
1515
1515
  return s;
1516
1516
  for (let i = 0; i < this.value.length; i++) {
1517
1517
  const o = this.value[i].constructor.NAME;
1518
- if (o === ue) {
1518
+ if (o === he) {
1519
1519
  if (this.isIndefiniteForm)
1520
1520
  break;
1521
1521
  return this.error = "EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only", -1;
@@ -1528,7 +1528,7 @@ class qt extends R(D) {
1528
1528
  return s;
1529
1529
  }
1530
1530
  toBER(e, t) {
1531
- return this.isConstructed ? D.prototype.toBER.call(this, e, t) : e ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.slice().buffer;
1531
+ return this.isConstructed ? $.prototype.toBER.call(this, e, t) : e ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.slice().buffer;
1532
1532
  }
1533
1533
  toJSON() {
1534
1534
  return {
@@ -1561,7 +1561,7 @@ class Gt extends A {
1561
1561
  const i = (e instanceof ArrayBuffer ? new Uint8Array(e) : e).subarray(t, t + r);
1562
1562
  try {
1563
1563
  if (i.byteLength) {
1564
- const o = ye(i, 0, i.byteLength);
1564
+ const o = Be(i, 0, i.byteLength);
1565
1565
  o.offset !== -1 && o.offset === r && (this.valueBlock.value = [o.result]);
1566
1566
  }
1567
1567
  } catch {
@@ -1587,7 +1587,7 @@ class Gt extends A {
1587
1587
  Re = Gt;
1588
1588
  d.OctetString = Re;
1589
1589
  Gt.NAME = pt;
1590
- class Jt extends R(D) {
1590
+ class Jt extends M($) {
1591
1591
  constructor({ unusedBits: e = 0, isConstructed: t = !1, ...r } = {}) {
1592
1592
  super(r), this.unusedBits = e, this.isConstructed = t, this.blockLength = this.valueHexView.byteLength;
1593
1593
  }
@@ -1596,11 +1596,11 @@ class Jt extends R(D) {
1596
1596
  return t;
1597
1597
  let s = -1;
1598
1598
  if (this.isConstructed) {
1599
- if (s = D.prototype.fromBER.call(this, e, t, r), s === -1)
1599
+ if (s = $.prototype.fromBER.call(this, e, t, r), s === -1)
1600
1600
  return s;
1601
1601
  for (const c of this.value) {
1602
1602
  const a = c.constructor.NAME;
1603
- if (a === ue) {
1603
+ if (a === he) {
1604
1604
  if (this.isIndefiniteForm)
1605
1605
  break;
1606
1606
  return this.error = "EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only", -1;
@@ -1615,7 +1615,7 @@ class Jt extends R(D) {
1615
1615
  return s;
1616
1616
  }
1617
1617
  const i = B.toUint8Array(e);
1618
- if (!L(this, i, t, r))
1618
+ if (!R(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)
@@ -1624,7 +1624,7 @@ class Jt extends R(D) {
1624
1624
  const c = o.subarray(1);
1625
1625
  try {
1626
1626
  if (c.byteLength) {
1627
- const a = ye(c, 0, c.byteLength);
1627
+ const a = Be(c, 0, c.byteLength);
1628
1628
  a.offset !== -1 && a.offset === r - 1 && (this.value = [a.result]);
1629
1629
  }
1630
1630
  } catch {
@@ -1634,7 +1634,7 @@ class Jt extends R(D) {
1634
1634
  }
1635
1635
  toBER(e, t) {
1636
1636
  if (this.isConstructed)
1637
- return D.prototype.toBER.call(this, e, t);
1637
+ return $.prototype.toBER.call(this, e, t);
1638
1638
  if (e)
1639
1639
  return new ArrayBuffer(this.valueHexView.byteLength + 1);
1640
1640
  if (!this.valueHexView.byteLength) {
@@ -1714,17 +1714,17 @@ function Us(n, e) {
1714
1714
  return t[0] > 0 && (i = Ne(t, i)), i;
1715
1715
  }
1716
1716
  function it(n) {
1717
- if (n >= ie.length)
1718
- for (let e = ie.length; e <= n; e++) {
1717
+ if (n >= oe.length)
1718
+ for (let e = oe.length; e <= n; e++) {
1719
1719
  const t = new Uint8Array([0]);
1720
- let r = ie[e - 1].slice(0);
1720
+ let r = oe[e - 1].slice(0);
1721
1721
  for (let s = r.length - 1; s >= 0; s--) {
1722
1722
  const i = new Uint8Array([(r[s] << 1) + t[0]]);
1723
1723
  t[0] = i[0] / 10, r[s] = i[0] % 10;
1724
1724
  }
1725
- t[0] > 0 && (r = Ne(t, r)), ie.push(r);
1725
+ t[0] > 0 && (r = Ne(t, r)), oe.push(r);
1726
1726
  }
1727
- return ie[n];
1727
+ return oe[n];
1728
1728
  }
1729
1729
  function Vs(n, e) {
1730
1730
  let t = 0;
@@ -1748,7 +1748,7 @@ function Vs(n, e) {
1748
1748
  }
1749
1749
  return i.slice();
1750
1750
  }
1751
- class Oe extends R(S) {
1751
+ class Oe extends M(S) {
1752
1752
  setValueHex() {
1753
1753
  this.valueHexView.length >= 4 ? (this.warnings.push("Too big Integer for decoding, hex only"), this.isHexOnly = !0, this._valueDec = 0) : (this.isHexOnly = !1, this.valueHexView.length > 0 && (this._valueDec = Et.call(this)));
1754
1754
  }
@@ -1830,16 +1830,16 @@ Object.defineProperty(Wt.prototype, "valueHex", {
1830
1830
  return this.valueHexView.slice().buffer;
1831
1831
  }
1832
1832
  });
1833
- var ae;
1833
+ var le;
1834
1834
  class De extends A {
1835
1835
  constructor(e = {}) {
1836
1836
  super(e, Oe), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 2;
1837
1837
  }
1838
1838
  toBigInt() {
1839
- return ge(), BigInt(this.valueBlock.toString());
1839
+ return we(), BigInt(this.valueBlock.toString());
1840
1840
  }
1841
1841
  static fromBigInt(e) {
1842
- ge();
1842
+ we();
1843
1843
  const t = BigInt(e), r = new He(), s = t.toString(16).replace(/^-/, ""), i = new Uint8Array(k.FromHex(s));
1844
1844
  if (t < 0) {
1845
1845
  const c = new Uint8Array(i.length + (i[0] & 128 ? 1 : 0));
@@ -1848,14 +1848,14 @@ class De extends A {
1848
1848
  f[0] |= 128, r.write(f);
1849
1849
  } else
1850
1850
  i[0] & 128 && r.write(new Uint8Array([0])), r.write(i);
1851
- return new ae({ valueHex: r.final() });
1851
+ return new le({ valueHex: r.final() });
1852
1852
  }
1853
1853
  convertToDER() {
1854
- const e = new ae({ valueHex: this.valueBlock.valueHexView });
1854
+ const e = new le({ valueHex: this.valueBlock.valueHexView });
1855
1855
  return e.valueBlock.toDER(), e;
1856
1856
  }
1857
1857
  convertFromDER() {
1858
- return new ae({
1858
+ return new le({
1859
1859
  valueHex: this.valueBlock.valueHexView[0] === 0 ? this.valueBlock.valueHexView.subarray(1) : this.valueBlock.valueHexView
1860
1860
  });
1861
1861
  }
@@ -1863,8 +1863,8 @@ class De extends A {
1863
1863
  return `${this.constructor.NAME} : ${this.valueBlock.toString()}`;
1864
1864
  }
1865
1865
  }
1866
- ae = De;
1867
- d.Integer = ae;
1866
+ le = De;
1867
+ d.Integer = le;
1868
1868
  De.NAME = "INTEGER";
1869
1869
  var Xt;
1870
1870
  class Zt extends De {
@@ -1875,7 +1875,7 @@ class Zt extends De {
1875
1875
  Xt = Zt;
1876
1876
  d.Enumerated = Xt;
1877
1877
  Zt.NAME = "ENUMERATED";
1878
- class Ie extends R(S) {
1878
+ class Ie extends M(S) {
1879
1879
  constructor({ valueDec: e = -1, isFirstSid: t = !1, ...r } = {}) {
1880
1880
  super(r), this.valueDec = e, this.isFirstSid = t;
1881
1881
  }
@@ -1883,7 +1883,7 @@ class Ie extends R(S) {
1883
1883
  if (!r)
1884
1884
  return t;
1885
1885
  const s = B.toUint8Array(e);
1886
- if (!L(this, s, t, r))
1886
+ if (!R(this, s, t, r))
1887
1887
  return -1;
1888
1888
  const i = s.subarray(t, t + r);
1889
1889
  this.valueHexView = new Uint8Array(r);
@@ -1895,7 +1895,7 @@ class Ie extends R(S) {
1895
1895
  return this.valueHexView = o, i[this.blockLength - 1] & 128 ? (this.error = "End of input reached before message was fully decoded", -1) : (this.valueHexView[0] === 0 && this.warnings.push("Needlessly long format of SID encoding"), this.blockLength <= 8 ? this.valueDec = Y(this.valueHexView, 7) : (this.isHexOnly = !0, this.warnings.push("Too big SID for decoding, hex only")), t + this.blockLength);
1896
1896
  }
1897
1897
  set valueBigInt(e) {
1898
- ge();
1898
+ we();
1899
1899
  let t = BigInt(e).toString(2);
1900
1900
  for (; t.length % 7; )
1901
1901
  t = "0" + t;
@@ -1913,7 +1913,7 @@ class Ie extends R(S) {
1913
1913
  i[o] = s[o] | 128;
1914
1914
  return i[this.blockLength - 1] = s[this.blockLength - 1], i.buffer;
1915
1915
  }
1916
- const t = j(this.valueDec, 7);
1916
+ const t = q(this.valueDec, 7);
1917
1917
  if (t.byteLength === 0)
1918
1918
  return this.error = "Error during encoding SID value", T;
1919
1919
  const r = new Uint8Array(t.byteLength);
@@ -1967,7 +1967,7 @@ class zt extends S {
1967
1967
  return this.error = this.value[r].error, T;
1968
1968
  t.push(s);
1969
1969
  }
1970
- return _e(t);
1970
+ return Ce(t);
1971
1971
  }
1972
1972
  fromString(e) {
1973
1973
  this.value = [];
@@ -1996,7 +1996,7 @@ class zt extends S {
1996
1996
  } else {
1997
1997
  const o = new Ie();
1998
1998
  if (s > Number.MAX_SAFE_INTEGER) {
1999
- ge();
1999
+ we();
2000
2000
  const c = BigInt(s);
2001
2001
  o.valueBigInt = c;
2002
2002
  } else if (o.valueDec = parseInt(s, 10), isNaN(o.valueDec))
@@ -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 Ue extends R(q) {
2053
+ class Ue extends M(G) {
2054
2054
  constructor({ valueDec: e = 0, ...t } = {}) {
2055
2055
  super(t), this.valueDec = e;
2056
2056
  }
@@ -2058,7 +2058,7 @@ class Ue extends R(q) {
2058
2058
  if (r === 0)
2059
2059
  return t;
2060
2060
  const s = B.toUint8Array(e);
2061
- if (!L(this, s, t, r))
2061
+ if (!R(this, s, t, r))
2062
2062
  return -1;
2063
2063
  const i = s.subarray(t, t + r);
2064
2064
  this.valueHexView = new Uint8Array(r);
@@ -2078,7 +2078,7 @@ class Ue extends R(q) {
2078
2078
  i[o] = s[o] | 128;
2079
2079
  return i[this.blockLength - 1] = s[this.blockLength - 1], i.buffer;
2080
2080
  }
2081
- const t = j(this.valueDec, 7);
2081
+ const t = q(this.valueDec, 7);
2082
2082
  if (t.byteLength === 0)
2083
2083
  return this.error = "Error during encoding SID value", T;
2084
2084
  const r = new Uint8Array(t.byteLength);
@@ -2124,7 +2124,7 @@ class Qt extends S {
2124
2124
  return this.error = this.value[s].error, T;
2125
2125
  r.push(i);
2126
2126
  }
2127
- return _e(r);
2127
+ return Ce(r);
2128
2128
  }
2129
2129
  fromString(e) {
2130
2130
  this.value = [];
@@ -2184,14 +2184,14 @@ er = tr;
2184
2184
  d.RelativeObjectIdentifier = er;
2185
2185
  tr.NAME = "RelativeObjectIdentifier";
2186
2186
  var rr;
2187
- class we extends ee {
2187
+ class ye extends ee {
2188
2188
  constructor(e = {}) {
2189
2189
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 16;
2190
2190
  }
2191
2191
  }
2192
- rr = we;
2192
+ rr = ye;
2193
2193
  d.Sequence = rr;
2194
- we.NAME = "SEQUENCE";
2194
+ ye.NAME = "SEQUENCE";
2195
2195
  var sr;
2196
2196
  class nr extends ee {
2197
2197
  constructor(e = {}) {
@@ -2201,7 +2201,7 @@ class nr extends ee {
2201
2201
  sr = nr;
2202
2202
  d.Set = sr;
2203
2203
  nr.NAME = "SET";
2204
- class ir extends R(S) {
2204
+ class ir extends M(S) {
2205
2205
  constructor({ ...e } = {}) {
2206
2206
  super(e), this.isHexOnly = !0, this.value = Q;
2207
2207
  }
@@ -2246,14 +2246,14 @@ class cr extends N {
2246
2246
  }
2247
2247
  cr.NAME = "Utf8StringValueBlock";
2248
2248
  var ar;
2249
- class G extends cr {
2249
+ class J extends cr {
2250
2250
  constructor(e = {}) {
2251
2251
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 12;
2252
2252
  }
2253
2253
  }
2254
- ar = G;
2254
+ ar = J;
2255
2255
  d.Utf8String = ar;
2256
- G.NAME = "UTF8String";
2256
+ J.NAME = "UTF8String";
2257
2257
  class lr extends N {
2258
2258
  fromBuffer(e) {
2259
2259
  this.valueBlock.value = k.ToUtf16String(e), this.valueBlock.valueHexView = B.toUint8Array(e);
@@ -2282,7 +2282,7 @@ class fr extends N {
2282
2282
  fromString(e) {
2283
2283
  const t = e.length, r = this.valueBlock.valueHexView = new Uint8Array(t * 4);
2284
2284
  for (let s = 0; s < t; s++) {
2285
- const i = j(e.charCodeAt(s), 8), o = new Uint8Array(i);
2285
+ const i = q(e.charCodeAt(s), 8), o = new Uint8Array(i);
2286
2286
  if (o.length > 4)
2287
2287
  continue;
2288
2288
  const c = 4 - o.length;
@@ -2383,7 +2383,7 @@ class Tr extends N {
2383
2383
  Vr = Tr;
2384
2384
  d.CharacterString = Vr;
2385
2385
  Tr.NAME = "CharacterString";
2386
- var Cr;
2386
+ var _r;
2387
2387
  class Fe extends Pe {
2388
2388
  constructor({ value: e, valueDate: t, ...r } = {}) {
2389
2389
  if (super(r), this.year = 0, this.month = 0, this.day = 0, this.hour = 0, this.minute = 0, this.second = 0, e) {
@@ -2439,10 +2439,10 @@ class Fe extends Pe {
2439
2439
  };
2440
2440
  }
2441
2441
  }
2442
- Cr = Fe;
2443
- d.UTCTime = Cr;
2442
+ _r = Fe;
2443
+ d.UTCTime = _r;
2444
2444
  Fe.NAME = "UTCTime";
2445
- var _r;
2445
+ var Cr;
2446
2446
  class Hr extends Fe {
2447
2447
  constructor(e = {}) {
2448
2448
  var t;
@@ -2564,11 +2564,11 @@ class Hr extends Fe {
2564
2564
  };
2565
2565
  }
2566
2566
  }
2567
- _r = Hr;
2568
- d.GeneralizedTime = _r;
2567
+ Cr = Hr;
2568
+ d.GeneralizedTime = Cr;
2569
2569
  Hr.NAME = "GeneralizedTime";
2570
2570
  var Lr;
2571
- class Rr extends G {
2571
+ class Rr extends J {
2572
2572
  constructor(e = {}) {
2573
2573
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 31;
2574
2574
  }
@@ -2577,7 +2577,7 @@ Lr = Rr;
2577
2577
  d.DATE = Lr;
2578
2578
  Rr.NAME = "DATE";
2579
2579
  var Mr;
2580
- class Or extends G {
2580
+ class Or extends J {
2581
2581
  constructor(e = {}) {
2582
2582
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 32;
2583
2583
  }
@@ -2586,7 +2586,7 @@ Mr = Or;
2586
2586
  d.TimeOfDay = Mr;
2587
2587
  Or.NAME = "TimeOfDay";
2588
2588
  var Dr;
2589
- class $r extends G {
2589
+ class $r extends J {
2590
2590
  constructor(e = {}) {
2591
2591
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 33;
2592
2592
  }
@@ -2595,7 +2595,7 @@ Dr = $r;
2595
2595
  d.DateTime = Dr;
2596
2596
  $r.NAME = "DateTime";
2597
2597
  var Pr;
2598
- class Fr extends G {
2598
+ class Fr extends J {
2599
2599
  constructor(e = {}) {
2600
2600
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 34;
2601
2601
  }
@@ -2604,7 +2604,7 @@ Pr = Fr;
2604
2604
  d.Duration = Pr;
2605
2605
  Fr.NAME = "Duration";
2606
2606
  var jr;
2607
- class qr extends G {
2607
+ class qr extends J {
2608
2608
  constructor(e = {}) {
2609
2609
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 14;
2610
2610
  }
@@ -2613,27 +2613,27 @@ jr = qr;
2613
2613
  d.TIME = jr;
2614
2614
  qr.NAME = "TIME";
2615
2615
  function Ts(n) {
2616
- const e = n.slice().buffer, t = new we({
2616
+ const e = n.slice().buffer, t = new ye({
2617
2617
  value: [new $e({ value: "1.3.101.110" })]
2618
2618
  // id-X25519
2619
2619
  }), r = new Me({
2620
2620
  valueHex: e
2621
- }), s = new we({
2621
+ }), s = new ye({
2622
2622
  value: [t, r]
2623
2623
  });
2624
2624
  return new Uint8Array(s.toBER());
2625
2625
  }
2626
- function Cs(n) {
2626
+ function _s(n) {
2627
2627
  const e = n.slice().buffer, s = Ns(e).result.valueBlock.value[1];
2628
2628
  return new Uint8Array(s.valueBlock.valueHex);
2629
2629
  }
2630
- function oe(n) {
2630
+ function ce(n) {
2631
2631
  let e = "";
2632
2632
  for (let t = 0; t < n.length; t++)
2633
2633
  e += String.fromCharCode(n[t]);
2634
2634
  return btoa(e);
2635
2635
  }
2636
- function ce(n) {
2636
+ function ae(n) {
2637
2637
  const e = n.replace(/\s+/g, ""), t = atob(e), r = new Uint8Array(t.length);
2638
2638
  for (let s = 0; s < t.length; s++) r[s] = t.charCodeAt(s);
2639
2639
  return r;
@@ -2647,13 +2647,13 @@ function ot(n) {
2647
2647
  const i = new Uint8Array(s);
2648
2648
  return i.set(new Uint8Array(t, r, s)), i.buffer;
2649
2649
  }
2650
- function le(n) {
2650
+ function ue(n) {
2651
2651
  return n.buffer;
2652
2652
  }
2653
- async function _s(n, e, t, r) {
2653
+ async function Cs(n, e, t, r) {
2654
2654
  const s = await crypto.subtle.importKey(
2655
2655
  "raw",
2656
- le(n),
2656
+ ue(n),
2657
2657
  "HKDF",
2658
2658
  !1,
2659
2659
  ["deriveBits"]
@@ -2661,8 +2661,8 @@ async function _s(n, e, t, r) {
2661
2661
  {
2662
2662
  name: "HKDF",
2663
2663
  hash: "SHA-256",
2664
- salt: le(e),
2665
- info: le(t)
2664
+ salt: ue(e),
2665
+ info: ue(t)
2666
2666
  },
2667
2667
  s,
2668
2668
  r * 8
@@ -2672,7 +2672,7 @@ async function _s(n, e, t, r) {
2672
2672
  async function Hs(n) {
2673
2673
  return crypto.subtle.importKey(
2674
2674
  "raw",
2675
- le(n),
2675
+ ue(n),
2676
2676
  {
2677
2677
  name: "HMAC",
2678
2678
  hash: "SHA-256"
@@ -2685,7 +2685,7 @@ async function Ls(n, e) {
2685
2685
  const t = await crypto.subtle.sign(
2686
2686
  "HMAC",
2687
2687
  n,
2688
- le(e)
2688
+ ue(e)
2689
2689
  );
2690
2690
  return new Uint8Array(t);
2691
2691
  }
@@ -2767,21 +2767,25 @@ class ct {
2767
2767
  try {
2768
2768
  const i = JSON.parse(s.data);
2769
2769
  if (!i.ciphertext) {
2770
- const { operation_id: h, iv: u, signature: g, topic: w, correlation_id: v, ...y } = i;
2770
+ const { operation_id: h, iv: u, signature: g, topic: w, correlation_id: v, content_type: y, ..._ } = i;
2771
2771
  if (!h)
2772
2772
  throw new Error("Claim check received but missing operation_id");
2773
- const C = await this.executeWithRetry(() => this.client.get(`/responses/${h}`, {}, !0)), J = {
2774
- ...y,
2773
+ const C = await this.executeWithRetry(() => this.client.get(`/responses/${h}`, {}, !0)), te = {
2774
+ ..._,
2775
+ content_type: y,
2775
2776
  topic: w,
2776
2777
  correlation_id: v,
2777
2778
  ciphertext: C.data,
2779
+ tot_pages: C.tot_pages,
2780
+ has_more: C.has_more,
2781
+ page_num: C.page_num,
2778
2782
  iv: u,
2779
2783
  signature: g
2780
- }, te = await this.client.decryptAndVerify(J);
2781
- this.distributeMessage(te);
2784
+ }, re = await this.client.decryptAndVerify(te);
2785
+ this.distributeMessage(re);
2782
2786
  return;
2783
2787
  }
2784
- const o = i.page_id, c = i.chunk_num, a = i.total_chunks;
2788
+ const o = i.page_num, c = i.chunk_num, a = i.total_chunks;
2785
2789
  let l = i;
2786
2790
  if (a > 1) {
2787
2791
  this.chunkBuffers[o] || (this.chunkBuffers[o] = {
@@ -2886,11 +2890,11 @@ class Os {
2886
2890
  }
2887
2891
  }
2888
2892
  async handshake() {
2889
- const e = await this.clientIdentityKeyPromise, t = Se.utils.randomSecretKey(), r = Se.getPublicKey(t), s = Ts(r), i = oe(s), o = await crypto.subtle.sign(
2893
+ const e = await this.clientIdentityKeyPromise, t = Se.utils.randomSecretKey(), r = Se.getPublicKey(t), s = Ts(r), i = ce(s), o = await crypto.subtle.sign(
2890
2894
  { name: "ECDSA", hash: "SHA-256" },
2891
2895
  e,
2892
2896
  Ps(s)
2893
- ), c = Fs(new Uint8Array(o)), a = oe(c), l = await fetch(`${this.baseUrl}/handshake`, {
2897
+ ), c = Fs(new Uint8Array(o)), a = ce(c), l = await fetch(`${this.baseUrl}/handshake`, {
2894
2898
  method: "POST",
2895
2899
  headers: {
2896
2900
  "Content-Type": "application/json"
@@ -2908,24 +2912,24 @@ class Os {
2908
2912
  const f = await l.json(), { session_id: h, server_pub: u, server_sig: g, session_expires_at: w } = f;
2909
2913
  if (window.__akv = { server_pub: u, server_sig: g }, !h || !u || !g)
2910
2914
  throw new Error("Handshake response missing fields");
2911
- const v = ce(u), y = ce(g);
2915
+ const v = ae(u), y = ae(g);
2912
2916
  if (!await Ms(
2913
2917
  this.serverPublicKeyPem,
2914
2918
  v,
2915
2919
  y
2916
2920
  ))
2917
2921
  throw new Error("Server signature verification failed");
2918
- const J = Cs(v), te = Se.getSharedSecret(t, J), Be = new Uint8Array(0), re = new TextEncoder().encode("health-api-v1"), K = await _s(te, Be, re, 64), W = K.slice(0, 32), be = K.slice(32, 64), he = await crypto.subtle.importKey(
2922
+ const C = _s(v), te = Se.getSharedSecret(t, C), re = new Uint8Array(0), se = new TextEncoder().encode("health-api-v1"), K = await Cs(te, re, se, 64), W = K.slice(0, 32), be = K.slice(32, 64), fe = await crypto.subtle.importKey(
2919
2923
  "raw",
2920
2924
  W,
2921
2925
  "AES-GCM",
2922
2926
  !1,
2923
2927
  ["encrypt", "decrypt"]
2924
- ), se = await Hs(be);
2928
+ ), ne = await Hs(be);
2925
2929
  this.updateSession({
2926
2930
  sessionId: h,
2927
- encKey: he,
2928
- macKey: se,
2931
+ encKey: fe,
2932
+ macKey: ne,
2929
2933
  sessionExpiresAt: w
2930
2934
  });
2931
2935
  }
@@ -2958,18 +2962,15 @@ class Os {
2958
2962
  s
2959
2963
  );
2960
2964
  return {
2961
- ciphertextB64: oe(new Uint8Array(i)),
2962
- ivB64: oe(r)
2965
+ ciphertextB64: ce(new Uint8Array(i)),
2966
+ ivB64: ce(r)
2963
2967
  };
2964
2968
  }
2965
2969
  async signRequest(e, t, r, s) {
2966
2970
  await this.ensureSession();
2967
- const { sessionId: i, macKey: o } = this.session, c = e.toUpperCase() === "GET" ? "" : { data: Array.isArray(r) ? r : [r] }, { ciphertextB64: a, ivB64: l } = await this.encryptBody(c), f = Math.floor(Date.now() / 1e3).toString();
2968
- let h = t;
2969
- h.includes("?") && (h = h.split("?")[0]);
2970
- const u = `${e.toUpperCase()} ${h}
2971
+ const { sessionId: i, macKey: o } = this.session, c = e.toUpperCase() === "GET" ? "" : { data: Array.isArray(r) ? r : [r] }, { ciphertextB64: a, ivB64: l } = await this.encryptBody(c), f = Math.floor(Date.now() / 1e3).toString(), h = t.split("?")[0], u = `${e.toUpperCase()} ${h}
2971
2972
  ${f}
2972
- ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = oe(g), v = new Headers({
2973
+ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers({
2973
2974
  ...s,
2974
2975
  "X-Session-Id": i,
2975
2976
  "X-Client-Id": this.clientId,
@@ -3010,22 +3011,35 @@ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = oe(g), v = new Headers(
3010
3011
  this.notifications.subscribe("request", i, async (c) => {
3011
3012
  const { data: a, ...l } = c;
3012
3013
  if (Object.keys(this.pagingBuffer).includes(i) || (this.pagingBuffer[i] = {
3013
- pages: new Array(l.pages),
3014
+ pages: new Array(l.tot_pages),
3014
3015
  count: 0,
3015
- total: l.pages
3016
- }), this.pagingBuffer[i].pages[l.page - 1] = l, this.pagingBuffer[i].count++, l.pages > l.page && l.next_page && this.pagingBuffer[i].count < this.pagingBuffer[i].total) {
3017
- this.get(`/signal/paging/${l.next_page}`, o);
3016
+ total: l.tot_pages,
3017
+ data: []
3018
+ }), this.pagingBuffer[i].pages[l.page_num - 1] = l, this.pagingBuffer[i].data.push(...a), this.pagingBuffer[i].count++, l.tot_pages > l.page_num && l.has_more && this.pagingBuffer[i].count < this.pagingBuffer[i].total) {
3019
+ let f = e.includes("?") ? "&" : "?";
3020
+ this.get(`${e}${f}page_num=${l.page_num + 1}`, o);
3018
3021
  return;
3019
3022
  }
3020
- if (t) return t(this.pagingBuffer[i].pages);
3023
+ if (t) return t({
3024
+ tot_pages: l.tot_pages,
3025
+ page_num: l.tot_pages,
3026
+ has_more: !1,
3027
+ status: l.status,
3028
+ topic: l.topic,
3029
+ correlation_id: l.correlation_id,
3030
+ content_type: l.content_type,
3031
+ data: this.pagingBuffer[i].data
3032
+ });
3021
3033
  }), await this.get(e, o);
3022
3034
  }
3023
3035
  async get_all_pages_sync(e, t = {}) {
3024
3036
  const r = t ? { ...t, "X-Force-Sync": !0 } : { "X-Force-Sync": !0 };
3025
3037
  let s = await this.get(e, r);
3026
3038
  const i = [s];
3027
- for (; s.pages > s.page && s.next_page; )
3028
- s = await this.get(`/signal/paging/${s.next_page}`, { ...t, "X-Force-Sync": !0 }), i.push(s);
3039
+ for (; s.tot_pages > s.page_num && s.has_more; ) {
3040
+ let o = e.includes("?") ? "&" : "?";
3041
+ s = await this.get(`${e}${o}page_num=${s.page_num + 1}`, { ...t, "X-Force-Sync": !0 }), i.push(s);
3042
+ }
3029
3043
  return i;
3030
3044
  }
3031
3045
  async ensureSession() {
@@ -3048,14 +3062,14 @@ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = oe(g), v = new Headers(
3048
3062
  const { ciphertext: t, iv: r, signature: s, ...i } = e;
3049
3063
  if (!t || !r || !s)
3050
3064
  throw new Error("Malformed notification");
3051
- const { encKey: o, macKey: c } = this.getSession(), a = ce(s), l = await crypto.subtle.sign(
3065
+ const { encKey: o, macKey: c } = this.getSession(), a = ae(s), l = await crypto.subtle.sign(
3052
3066
  "HMAC",
3053
3067
  c,
3054
3068
  new TextEncoder().encode(t)
3055
3069
  );
3056
3070
  if (!this.constantTimeEqual(a, new Uint8Array(l)))
3057
3071
  throw new Error("Invalid notification signature");
3058
- const f = Uint8Array.from(ce(r)), h = Uint8Array.from(ce(t)), u = await crypto.subtle.decrypt(
3072
+ const f = Uint8Array.from(ae(r)), h = Uint8Array.from(ae(t)), u = await crypto.subtle.decrypt(
3059
3073
  { name: "AES-GCM", iv: f },
3060
3074
  o,
3061
3075
  h