@vitia.ai/secure-api-client-vue 0.1.4 → 0.1.6

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
@@ -1,47 +1,47 @@
1
1
  const Z = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
2
2
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
- function at(n) {
3
+ function lt(n) {
4
4
  return n instanceof Uint8Array || ArrayBuffer.isView(n) && n.constructor.name === "Uint8Array";
5
5
  }
6
- function Wr(n) {
6
+ function Xr(n) {
7
7
  if (!Number.isSafeInteger(n) || n < 0)
8
8
  throw new Error("positive integer expected, got " + n);
9
9
  }
10
10
  function Ve(n, ...e) {
11
- if (!at(n))
11
+ if (!lt(n))
12
12
  throw new Error("Uint8Array expected");
13
13
  if (e.length > 0 && !e.includes(n.length))
14
14
  throw new Error("Uint8Array expected of length " + e + ", got length=" + n.length);
15
15
  }
16
- const lt = /* @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
- function ut(n) {
18
- if (Ve(n), lt)
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
+ function ht(n) {
18
+ if (Ve(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 _ = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
26
- function ze(n) {
27
- if (n >= _._0 && n <= _._9)
28
- return n - _._0;
29
- if (n >= _.A && n <= _.F)
30
- return n - (_.A - 10);
31
- if (n >= _.a && n <= _.f)
32
- return n - (_.a - 10);
25
+ const L = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
26
+ function Ze(n) {
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
- function ht(n) {
34
+ function ft(n) {
35
35
  if (typeof n != "string")
36
36
  throw new Error("hex string expected, got " + typeof n);
37
- if (lt)
37
+ if (ut)
38
38
  return Uint8Array.fromHex(n);
39
39
  const e = n.length, t = e / 2;
40
40
  if (e % 2)
41
41
  throw new Error("hex string expected, got unpadded hex of length " + e);
42
42
  const r = new Uint8Array(t);
43
43
  for (let s = 0, i = 0; s < t; s++, i += 2) {
44
- const o = ze(n.charCodeAt(i)), c = ze(n.charCodeAt(i + 1));
44
+ const o = Ze(n.charCodeAt(i)), c = Ze(n.charCodeAt(i + 1));
45
45
  if (o === void 0 || c === void 0) {
46
46
  const a = n[i] + n[i + 1];
47
47
  throw new Error('hex string expected, got non-hex character "' + a + '" at index ' + i);
@@ -58,33 +58,33 @@ function zr(n = 32) {
58
58
  throw new Error("crypto.getRandomValues must be defined");
59
59
  }
60
60
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
61
- const ft = /* @__PURE__ */ BigInt(0), Xe = /* @__PURE__ */ BigInt(1);
62
- function dt(n) {
61
+ const dt = /* @__PURE__ */ BigInt(0), ze = /* @__PURE__ */ BigInt(1);
62
+ function gt(n) {
63
63
  if (typeof n != "string")
64
64
  throw new Error("hex string expected, got " + typeof n);
65
- return n === "" ? ft : BigInt("0x" + n);
65
+ return n === "" ? dt : BigInt("0x" + n);
66
66
  }
67
- function Xr(n) {
68
- return dt(ut(n));
67
+ function Yr(n) {
68
+ return gt(ht(n));
69
69
  }
70
70
  function pe(n) {
71
- return Ve(n), dt(ut(Uint8Array.from(n).reverse()));
72
- }
73
- function gt(n, e) {
74
- return ht(n.toString(16).padStart(e * 2, "0"));
71
+ return Ve(n), gt(ht(Uint8Array.from(n).reverse()));
75
72
  }
76
73
  function wt(n, e) {
77
- return gt(n, e).reverse();
74
+ return ft(n.toString(16).padStart(e * 2, "0"));
75
+ }
76
+ function yt(n, e) {
77
+ return wt(n, e).reverse();
78
78
  }
79
79
  function Ye(n, e, t) {
80
80
  let r;
81
81
  if (typeof e == "string")
82
82
  try {
83
- r = ht(e);
83
+ r = ft(e);
84
84
  } catch (i) {
85
85
  throw new Error(n + " must be hex string or Uint8Array, cause: " + i);
86
86
  }
87
- else if (at(e))
87
+ else if (lt(e))
88
88
  r = Uint8Array.from(e);
89
89
  else
90
90
  throw new Error(n + " must be hex string or Uint8Array");
@@ -93,16 +93,16 @@ function Ye(n, e, t) {
93
93
  throw new Error(n + " of length " + t + " expected, got " + s);
94
94
  return r;
95
95
  }
96
- const xe = (n) => typeof n == "bigint" && ft <= n;
97
- function Yr(n, e, t) {
96
+ const xe = (n) => typeof n == "bigint" && dt <= n;
97
+ function Qr(n, e, t) {
98
98
  return xe(n) && xe(e) && xe(t) && e <= n && n < t;
99
99
  }
100
100
  function Qe(n, e, t, r) {
101
- if (!Yr(e, t, r))
101
+ if (!Qr(e, t, r))
102
102
  throw new Error("expected valid " + n + ": " + t + " <= n < " + r + ", got " + e);
103
103
  }
104
- const Qr = (n) => (Xe << BigInt(n)) - Xe;
105
- function es(n, e, t = {}) {
104
+ const es = (n) => (ze << BigInt(n)) - ze;
105
+ function ts(n, e, t = {}) {
106
106
  if (!n || typeof n != "object")
107
107
  throw new Error("expected valid options object");
108
108
  function r(s, i, o) {
@@ -116,7 +116,7 @@ function es(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), yt = /* @__PURE__ */ BigInt(4), bt = /* @__PURE__ */ BigInt(5), ts = /* @__PURE__ */ BigInt(7), vt = /* @__PURE__ */ BigInt(8), rs = /* @__PURE__ */ BigInt(9), kt = /* @__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;
@@ -134,8 +134,8 @@ function et(n, e) {
134
134
  throw new Error("invert: expected positive modulus, got " + e);
135
135
  let t = I(n, e), r = e, s = x, i = p;
136
136
  for (; t !== x; ) {
137
- const c = r / t, a = r % t, u = s - i * c;
138
- r = t, t = a, s = i, i = u;
137
+ const c = r / t, a = r % t, l = s - i * c;
138
+ r = t, t = a, s = i, i = l;
139
139
  }
140
140
  if (r !== p)
141
141
  throw new Error("invert: does not exist");
@@ -145,62 +145,62 @@ function Te(n, e, t) {
145
145
  if (!n.eql(n.sqr(e), t))
146
146
  throw new Error("Cannot find square root");
147
147
  }
148
- function mt(n, e) {
149
- const t = (n.ORDER + p) / yt, r = n.pow(e, t);
148
+ function At(n, e) {
149
+ const t = (n.ORDER + p) / bt, r = n.pow(e, t);
150
150
  return Te(n, r, e), r;
151
151
  }
152
- function ss(n, e) {
153
- const t = (n.ORDER - bt) / vt, 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));
152
+ function ns(n, e) {
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
- function ns(n) {
157
- const e = Ce(n), t = At(n), r = t(e, e.neg(e.ONE)), s = t(e, r), i = t(e, e.neg(r)), o = (n + ts) / kt;
156
+ function is(n) {
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
- let u = c.pow(a, o), f = c.mul(u, r);
160
- const h = c.mul(u, s), l = c.mul(u, i), g = c.eql(c.sqr(f), a), w = c.eql(c.sqr(h), a);
161
- u = c.cmov(u, f, g), f = c.cmov(l, h, w);
162
- const m = c.eql(c.sqr(f), a), b = c.cmov(u, f, m);
163
- return Te(c, b, a), b;
159
+ let l = c.pow(a, o), f = c.mul(l, r);
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);
161
+ l = c.cmov(l, f, g), f = c.cmov(u, h, w);
162
+ const v = c.eql(c.sqr(f), a), y = c.cmov(l, f, v);
163
+ return Te(c, y, a), y;
164
164
  };
165
165
  }
166
- function At(n) {
166
+ 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
- return mt;
178
+ return At;
179
179
  let i = s.pow(r, e);
180
- const o = (e + p) / F;
181
- return function(a, u) {
182
- if (a.is0(u))
183
- return u;
184
- if (tt(a, u) !== 1)
180
+ const o = (e + p) / j;
181
+ return function(a, l) {
182
+ if (a.is0(l))
183
+ return l;
184
+ if (tt(a, l) !== 1)
185
185
  throw new Error("Cannot find square root");
186
- let f = t, h = a.mul(a.ONE, i), l = a.pow(u, e), g = a.pow(u, o);
187
- for (; !a.eql(l, a.ONE); ) {
188
- if (a.is0(l))
186
+ let f = t, h = a.mul(a.ONE, i), u = a.pow(l, e), g = a.pow(l, o);
187
+ for (; !a.eql(u, a.ONE); ) {
188
+ if (a.is0(u))
189
189
  return a.ZERO;
190
- let w = 1, m = a.sqr(l);
191
- for (; !a.eql(m, a.ONE); )
192
- if (w++, m = a.sqr(m), w === f)
190
+ let w = 1, v = a.sqr(u);
191
+ for (; !a.eql(v, a.ONE); )
192
+ if (w++, v = a.sqr(v), w === f)
193
193
  throw new Error("Cannot find square root");
194
- const b = p << BigInt(f - w - 1), D = a.pow(h, b);
195
- f = w, h = a.sqr(D), l = a.mul(l, h), g = a.mul(g, D);
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
  };
199
199
  }
200
- function is(n) {
201
- return n % yt === Bt ? mt : n % vt === bt ? ss : n % kt === rs ? ns(n) : At(n);
200
+ function os(n) {
201
+ return n % bt === Bt ? At : n % kt === vt ? ns : n % mt === ss ? is(n) : xt(n);
202
202
  }
203
- function os(n, e, t) {
203
+ function cs(n, e, t) {
204
204
  if (t < x)
205
205
  throw new Error("invalid exponent, negatives unsupported");
206
206
  if (t === x)
@@ -212,193 +212,193 @@ function os(n, e, t) {
212
212
  t & p && (r = n.mul(r, s)), s = n.sqr(s), t >>= p;
213
213
  return r;
214
214
  }
215
- function cs(n, e, t = !1) {
215
+ function as(n, e, t = !1) {
216
216
  const r = new Array(e.length).fill(t ? n.ZERO : void 0), s = e.reduce((o, c, a) => n.is0(c) ? o : (r[a] = o, n.mul(o, c)), n.ONE), i = n.inv(s);
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;
224
224
  }
225
- function as(n, e) {
226
- e !== void 0 && Wr(e);
225
+ function ls(n, e) {
226
+ e !== void 0 && Xr(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;
234
234
  if (typeof e == "object" && e != null) {
235
235
  if (r.sqrt || t)
236
236
  throw new Error("cannot specify opts in two arguments");
237
- const l = e;
238
- l.BITS && (s = l.BITS), l.sqrt && (i = l.sqrt), typeof l.isLE == "boolean" && (t = l.isLE), typeof l.modFromBytes == "boolean" && (o = l.modFromBytes), c = l.allowedLengths;
237
+ const u = e;
238
+ u.BITS && (s = u.BITS), u.sqrt && (i = u.sqrt), typeof u.isLE == "boolean" && (t = u.isLE), typeof u.modFromBytes == "boolean" && (o = u.modFromBytes), c = u.allowedLengths;
239
239
  } else
240
240
  typeof e == "number" && (s = e), r.sqrt && (i = r.sqrt);
241
- const { nBitLength: a, nByteLength: u } = as(n, s);
242
- if (u > 2048)
241
+ const { nBitLength: a, nByteLength: l } = ls(n, s);
242
+ if (l > 2048)
243
243
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
244
244
  let f;
245
245
  const h = Object.freeze({
246
246
  ORDER: n,
247
247
  isLE: t,
248
248
  BITS: a,
249
- BYTES: u,
250
- MASK: Qr(a),
249
+ BYTES: l,
250
+ MASK: es(a),
251
251
  ZERO: x,
252
252
  ONE: p,
253
253
  allowedLengths: c,
254
- create: (l) => I(l, n),
255
- isValid: (l) => {
256
- if (typeof l != "bigint")
257
- throw new Error("invalid field element: expected bigint, got " + typeof l);
258
- return x <= l && l < n;
254
+ create: (u) => I(u, n),
255
+ isValid: (u) => {
256
+ if (typeof u != "bigint")
257
+ throw new Error("invalid field element: expected bigint, got " + typeof u);
258
+ return x <= u && u < n;
259
259
  },
260
- is0: (l) => l === x,
260
+ is0: (u) => u === x,
261
261
  // is valid and invertible
262
- isValidNot0: (l) => !h.is0(l) && h.isValid(l),
263
- isOdd: (l) => (l & p) === p,
264
- neg: (l) => I(-l, n),
265
- eql: (l, g) => l === g,
266
- sqr: (l) => I(l * l, n),
267
- add: (l, g) => I(l + g, n),
268
- sub: (l, g) => I(l - g, n),
269
- mul: (l, g) => I(l * g, n),
270
- pow: (l, g) => os(h, l, g),
271
- div: (l, g) => I(l * et(g, n), n),
262
+ isValidNot0: (u) => !h.is0(u) && h.isValid(u),
263
+ isOdd: (u) => (u & p) === p,
264
+ neg: (u) => I(-u, n),
265
+ eql: (u, g) => u === g,
266
+ sqr: (u) => I(u * u, n),
267
+ add: (u, g) => I(u + g, n),
268
+ sub: (u, g) => I(u - g, n),
269
+ mul: (u, g) => I(u * g, n),
270
+ pow: (u, g) => cs(h, u, g),
271
+ div: (u, g) => I(u * et(g, n), n),
272
272
  // Same as above, but doesn't normalize
273
- sqrN: (l) => l * l,
274
- addN: (l, g) => l + g,
275
- subN: (l, g) => l - g,
276
- mulN: (l, g) => l * g,
277
- inv: (l) => et(l, n),
278
- sqrt: i || ((l) => (f || (f = is(n)), f(h, l))),
279
- toBytes: (l) => t ? wt(l, u) : gt(l, u),
280
- fromBytes: (l, g = !0) => {
273
+ sqrN: (u) => u * u,
274
+ addN: (u, g) => u + g,
275
+ subN: (u, g) => u - g,
276
+ mulN: (u, g) => u * g,
277
+ inv: (u) => et(u, n),
278
+ sqrt: i || ((u) => (f || (f = os(n)), f(h, u))),
279
+ toBytes: (u) => t ? yt(u, l) : wt(u, l),
280
+ fromBytes: (u, g = !0) => {
281
281
  if (c) {
282
- if (!c.includes(l.length) || l.length > u)
283
- throw new Error("Field.fromBytes: expected " + c + " bytes, got " + l.length);
284
- const m = new Uint8Array(u);
285
- m.set(l, t ? 0 : m.length - l.length), l = m;
282
+ if (!c.includes(u.length) || u.length > l)
283
+ throw new Error("Field.fromBytes: expected " + c + " bytes, got " + u.length);
284
+ const v = new Uint8Array(l);
285
+ v.set(u, t ? 0 : v.length - u.length), u = v;
286
286
  }
287
- if (l.length !== u)
288
- throw new Error("Field.fromBytes: expected " + u + " bytes, got " + l.length);
289
- let w = t ? pe(l) : Xr(l);
287
+ if (u.length !== l)
288
+ throw new Error("Field.fromBytes: expected " + l + " bytes, got " + u.length);
289
+ let w = t ? pe(u) : Yr(u);
290
290
  if (o && (w = I(w, n)), !g && !h.isValid(w))
291
291
  throw new Error("invalid field element: outside of range 0..ORDER");
292
292
  return w;
293
293
  },
294
294
  // TODO: we don't need it here, move out to separate fn
295
- invertBatch: (l) => cs(h, l),
295
+ invertBatch: (u) => as(h, u),
296
296
  // We can't move this out because Fp6, Fp12 implement it
297
297
  // and it's unclear what to return in there.
298
- cmov: (l, g, w) => w ? g : l
298
+ cmov: (u, g, w) => w ? g : u
299
299
  });
300
300
  return Object.freeze(h);
301
301
  }
302
302
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
303
- const re = BigInt(0), z = BigInt(1), fe = BigInt(2);
304
- function ls(n) {
305
- return es(n, {
303
+ const ie = BigInt(0), z = BigInt(1), ge = BigInt(2);
304
+ function us(n) {
305
+ return ts(n, {
306
306
  adjustScalarBytes: "function",
307
307
  powPminus2: "function"
308
308
  }), Object.freeze({ ...n });
309
309
  }
310
- function us(n) {
311
- const e = ls(n), { P: t, type: r, adjustScalarBytes: s, powPminus2: i, randomBytes: o } = e, c = r === "x25519";
310
+ function hs(n) {
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, u = c ? 255 : 448, f = c ? 32 : 56, h = BigInt(c ? 9 : 5), l = BigInt(c ? 121665 : 39081), g = c ? fe ** BigInt(254) : fe ** BigInt(447), w = c ? BigInt(8) * fe ** BigInt(251) - z : BigInt(4) * fe ** BigInt(445) - z, m = g + w + z, b = (y) => I(y, t), D = le(h);
315
- function le(y) {
316
- return wt(b(y), f);
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
+ return yt(y(b), f);
317
317
  }
318
- function Be(y) {
319
- const k = Ye("u coordinate", y, f);
320
- return c && (k[31] &= 127), b(pe(k));
318
+ function te(b) {
319
+ const m = Ye("u coordinate", b, f);
320
+ return c && (m[31] &= 127), y(pe(m));
321
321
  }
322
- function ye(y) {
323
- return pe(s(Ye("scalar", y, f)));
322
+ function re(b) {
323
+ return pe(s(Ye("scalar", b, f)));
324
324
  }
325
- function ee(y, k) {
326
- const C = be(Be(k), ye(y));
327
- if (C === re)
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 le(C);
330
- }
331
- function J(y) {
332
- return ee(y, D);
333
- }
334
- function K(y, k, C) {
335
- const he = b(y * (k - C));
336
- return k = b(k - he), C = b(C + he), { x_2: k, x_3: C };
337
- }
338
- function be(y, k) {
339
- Qe("u", y, re, t), Qe("scalar", k, g, m);
340
- const C = k, he = y;
341
- let R = z, M = re, $ = y, P = z, W = re;
342
- for (let ve = BigInt(u - 1); ve >= re; ve--) {
343
- const je = C >> ve & z;
344
- W ^= je, { x_2: R, x_3: $ } = K(W, R, $), { x_2: M, x_3: P } = K(W, M, P), W = je;
345
- const ke = R + M, me = b(ke * ke), Ae = R - M, qe = b(Ae * Ae), Ge = me - qe, Jr = $ + P, Kr = $ - P, Je = b(Kr * ke), Ke = b(Jr * Ae), We = Je + Ke, Ze = Je - Ke;
346
- $ = b(We * We), P = b(he * b(Ze * Ze)), R = b(me * qe), M = b(Ge * (me + b(l * Ge)));
347
- }
348
- ({ x_2: R, x_3: $ } = K(W, R, $)), { x_2: M, x_3: P } = K(W, M, P);
349
- const Gr = i(M);
350
- return b(R * Gr);
351
- }
352
- const ue = {
329
+ return C(H);
330
+ }
331
+ function K(b) {
332
+ return se(b, _);
333
+ }
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
+ }
338
+ function be(b, m) {
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
- }, te = (y = a(f)) => (Ve(y, ue.seed), y);
357
- function qr(y) {
358
- const k = te(y);
359
- return { secretKey: k, publicKey: J(k) };
356
+ }, ne = (b = a(f)) => (Ve(b, fe.seed), b);
357
+ function Gr(b) {
358
+ const m = ne(b);
359
+ return { secretKey: m, publicKey: K(m) };
360
360
  }
361
361
  return {
362
- keygen: qr,
363
- getSharedSecret: (y, k) => ee(y, k),
364
- getPublicKey: (y) => J(y),
365
- scalarMult: ee,
366
- scalarMultBase: J,
362
+ keygen: Gr,
363
+ getSharedSecret: (b, m) => se(b, m),
364
+ getPublicKey: (b) => K(b),
365
+ scalarMult: se,
366
+ scalarMultBase: K,
367
367
  utils: {
368
- randomSecretKey: te,
369
- randomPrivateKey: te
368
+ randomSecretKey: ne,
369
+ randomPrivateKey: ne
370
370
  },
371
- GuBytes: D.slice(),
372
- lengths: ue
371
+ GuBytes: _.slice(),
372
+ lengths: fe
373
373
  };
374
374
  }
375
375
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
376
- const hs = BigInt(1), rt = BigInt(2), fs = BigInt(3), ds = BigInt(5), gs = BigInt(8), xt = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), ws = {
377
- p: xt,
376
+ const fs = BigInt(1), rt = BigInt(2), ds = BigInt(3), gs = BigInt(5), ws = BigInt(8), St = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), ys = {
377
+ p: St,
378
378
  n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
379
- h: gs,
379
+ h: ws,
380
380
  a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
381
381
  d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
382
382
  Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
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 = xt, c = n * n % i * n % i, a = U(c, rt, i) * c % i, u = U(a, hs, i) * n % i, f = U(u, ds, i) * u % i, h = U(f, e, i) * f % i, l = U(h, t, i) * h % i, g = U(l, r, i) * l % i, w = U(g, s, i) * g % i, m = U(w, s, i) * g % i, b = U(m, e, i) * f % i;
387
- return { pow_p_5_8: U(b, rt, i) * n % i, b2: c };
386
+ const e = BigInt(10), t = BigInt(20), r = BigInt(40), s = BigInt(80), i = St, c = n * n % i * n % i, a = U(c, rt, i) * c % i, l = U(a, fs, i) * n % i, f = U(l, gs, i) * l % i, h = U(f, e, i) * f % i, u = U(h, t, i) * h % i, g = U(u, r, i) * u % i, w = U(g, s, i) * g % i, v = U(w, s, i) * g % i, y = U(v, e, i) * f % i;
387
+ return { pow_p_5_8: U(y, rt, i) * n % i, b2: c };
388
388
  }
389
- function ys(n) {
389
+ function bs(n) {
390
390
  return n[0] &= 248, n[31] &= 127, n[31] |= 64, n;
391
391
  }
392
- const bs = Ce(ws.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
393
- const n = bs.ORDER;
394
- return us({
392
+ const vs = _e(ys.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
393
+ const n = vs.ORDER;
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(U(t, fs, n) * r, n);
399
+ return I(U(t, ds, n) * r, n);
400
400
  },
401
- adjustScalarBytes: ys
401
+ adjustScalarBytes: bs
402
402
  });
403
403
  })();
404
404
  /*!
@@ -425,10 +425,10 @@ const bs = Ce(ws.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
425
425
  * SOFTWARE.
426
426
  *
427
427
  */
428
- const vs = "[object ArrayBuffer]";
428
+ const ks = "[object ArrayBuffer]";
429
429
  class B {
430
430
  static isArrayBuffer(e) {
431
- return Object.prototype.toString.call(e) === vs;
431
+ return Object.prototype.toString.call(e) === ks;
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;
@@ -475,7 +475,7 @@ class B {
475
475
  return e[e.length - 1] instanceof Function ? this.toView(s, e[e.length - 1]) : s.buffer;
476
476
  }
477
477
  }
478
- const Ee = "string", ks = /^[0-9a-f\s]+$/i, ms = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/, As = /^[a-zA-Z0-9-_]+$/;
478
+ const Ee = "string", ms = /^[0-9a-f\s]+$/i, As = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/, xs = /^[a-zA-Z0-9-_]+$/;
479
479
  class st {
480
480
  static fromString(e) {
481
481
  const t = unescape(encodeURIComponent(e)), r = new Uint8Array(t.length);
@@ -508,15 +508,15 @@ class V {
508
508
  return r;
509
509
  }
510
510
  }
511
- class v {
511
+ class k {
512
512
  static isHex(e) {
513
- return typeof e === Ee && ks.test(e);
513
+ return typeof e === Ee && ms.test(e);
514
514
  }
515
515
  static isBase64(e) {
516
- return typeof e === Ee && ms.test(e);
516
+ return typeof e === Ee && As.test(e);
517
517
  }
518
518
  static isBase64Url(e) {
519
- return typeof e === Ee && As.test(e);
519
+ return typeof e === Ee && xs.test(e);
520
520
  }
521
521
  static ToString(e, t = "utf8") {
522
522
  const r = B.toUint8Array(e);
@@ -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 (!v.isBase64(t))
578
+ if (!k.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 (!v.isBase64Url(t))
586
+ if (!k.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 = v.DEFAULT_UTF8_ENCODING) {
593
+ static FromUtf8String(e, t = k.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 = v.DEFAULT_UTF8_ENCODING) {
609
+ static ToUtf8String(e, t = k.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 (!v.isHex(t))
652
+ if (!k.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,11 +676,11 @@ class v {
676
676
  return (e == null ? void 0 : e.replace(/[\n\r\t ]/g, "")) || "";
677
677
  }
678
678
  }
679
- v.DEFAULT_UTF8_ENCODING = "utf8";
679
+ k.DEFAULT_UTF8_ENCODING = "utf8";
680
680
  /*!
681
681
  Copyright (c) Peculiar Ventures, LLC
682
682
  */
683
- function X(n, e) {
683
+ function Y(n, e) {
684
684
  let t = 0;
685
685
  if (n.length === 1)
686
686
  return n[0];
@@ -688,7 +688,7 @@ function X(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++) {
@@ -701,10 +701,10 @@ function j(n, e, t = -1) {
701
701
  return new ArrayBuffer(0);
702
702
  a = new ArrayBuffer(r), i = r;
703
703
  }
704
- const u = new Uint8Array(a);
704
+ const l = new Uint8Array(a);
705
705
  for (let f = c - 1; f >= 0; f--) {
706
706
  const h = Math.pow(2, f * e);
707
- u[i - f - 1] = Math.floor(s / h), s -= u[i - f - 1] * h;
707
+ l[i - f - 1] = Math.floor(s / h), s -= l[i - f - 1] * h;
708
708
  }
709
709
  return a;
710
710
  }
@@ -721,7 +721,7 @@ function Ne(...n) {
721
721
  s.set(i, t), t += i.length;
722
722
  return s;
723
723
  }
724
- function St() {
724
+ function Et() {
725
725
  const n = new Uint8Array(this.valueHex);
726
726
  if (this.valueHex.byteLength >= 2) {
727
727
  const c = n[0] === 255 && n[1] & 128, a = n[0] === 0 && (n[1] & 128) === 0;
@@ -731,21 +731,21 @@ function St() {
731
731
  for (let c = 0; c < this.valueHex.byteLength; c++)
732
732
  t[c] = 0;
733
733
  t[0] = n[0] & 128;
734
- const r = X(t, 8), s = new ArrayBuffer(this.valueHex.byteLength), i = new Uint8Array(s);
734
+ const r = Y(t, 8), s = new ArrayBuffer(this.valueHex.byteLength), i = new Uint8Array(s);
735
735
  for (let c = 0; c < this.valueHex.byteLength; c++)
736
736
  i[c] = n[c];
737
- return i[0] &= 127, X(i, 8) - r;
737
+ return i[0] &= 127, Y(i, 8) - r;
738
738
  }
739
- function xs(n) {
739
+ function Ss(n) {
740
740
  const e = n < 0 ? n * -1 : n;
741
741
  let t = 128;
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);
@@ -759,7 +759,7 @@ function xs(n) {
759
759
  }
760
760
  return new ArrayBuffer(0);
761
761
  }
762
- function Ss(n, e) {
762
+ function Es(n, e) {
763
763
  if (n.byteLength !== e.byteLength)
764
764
  return !1;
765
765
  const t = new Uint8Array(n), r = new Uint8Array(e);
@@ -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 de() {
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 H(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 se = [new Uint8Array([1])], nt = "0123456789", Y = "", T = new ArrayBuffer(0), Le = new Uint8Array(0), ae = "EndOfContent", Et = "OCTET STRING", pt = "BIT STRING";
845
- function L(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 L(n) {
859
859
  }
860
860
  fromBER(r, s, i) {
861
861
  const o = r instanceof ArrayBuffer ? new Uint8Array(r) : r;
862
- if (!H(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);
@@ -871,12 +871,12 @@ function L(n) {
871
871
  return {
872
872
  ...super.toJSON(),
873
873
  isHexOnly: this.isHexOnly,
874
- valueHex: v.ToHex(this.valueHexView)
874
+ valueHex: k.ToHex(this.valueHexView)
875
875
  };
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
  }
@@ -886,7 +886,7 @@ class q {
886
886
  set valueBeforeDecode(e) {
887
887
  this.valueBeforeDecodeView = new Uint8Array(e);
888
888
  }
889
- constructor({ blockLength: e = 0, error: t = Y, warnings: r = [], valueBeforeDecode: s = Le } = {}) {
889
+ constructor({ blockLength: e = 0, error: t = Q, warnings: r = [], valueBeforeDecode: s = Le } = {}) {
890
890
  this.blockLength = e, this.error = t, this.warnings = r, this.valueBeforeDecodeView = B.toUint8Array(s);
891
891
  }
892
892
  toJSON() {
@@ -895,12 +895,12 @@ class q {
895
895
  blockLength: this.blockLength,
896
896
  error: this.error,
897
897
  warnings: this.warnings,
898
- valueBeforeDecode: v.ToHex(this.valueBeforeDecodeView)
898
+ valueBeforeDecode: k.ToHex(this.valueBeforeDecodeView)
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 Nt extends L(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 Nt extends L(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 Nt extends L(q) {
960
960
  }
961
961
  fromBER(e, t, r) {
962
962
  const s = B.toUint8Array(e);
963
- if (!H(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)
@@ -986,23 +986,23 @@ class Nt extends L(q) {
986
986
  if (c !== 31)
987
987
  this.tagNumber = c, this.blockLength = 1;
988
988
  else {
989
- let a = 1, u = this.valueHexView = new Uint8Array(255), f = 255;
989
+ let a = 1, l = this.valueHexView = new Uint8Array(255), f = 255;
990
990
  for (; i[a] & 128; ) {
991
- if (u[a - 1] = i[a] & 127, a++, a >= i.length)
991
+ if (l[a - 1] = i[a] & 127, a++, a >= i.length)
992
992
  return this.error = "End of input reached before message was fully decoded", -1;
993
993
  if (a === f) {
994
994
  f += 255;
995
- const l = new Uint8Array(f);
996
- for (let g = 0; g < u.length; g++)
997
- l[g] = u[g];
998
- u = this.valueHexView = new Uint8Array(f);
995
+ const u = new Uint8Array(f);
996
+ for (let g = 0; g < l.length; g++)
997
+ u[g] = l[g];
998
+ l = this.valueHexView = new Uint8Array(f);
999
999
  }
1000
1000
  }
1001
- this.blockLength = a + 1, u[a - 1] = i[a] & 127;
1001
+ this.blockLength = a + 1, l[a - 1] = i[a] & 127;
1002
1002
  const h = new Uint8Array(a);
1003
- for (let l = 0; l < a; l++)
1004
- h[l] = u[l];
1005
- u = this.valueHexView = new Uint8Array(a), u.set(h), this.blockLength <= 9 ? this.tagNumber = X(u, 7) : (this.isHexOnly = !0, this.warnings.push("Tag too long, represented as hex-coded"));
1003
+ for (let u = 0; u < a; u++)
1004
+ h[u] = l[u];
1005
+ l = this.valueHexView = new Uint8Array(a), l.set(h), this.blockLength <= 9 ? this.tagNumber = Y(l, 7) : (this.isHexOnly = !0, this.warnings.push("Tag too long, represented as hex-coded"));
1006
1006
  }
1007
1007
  if (this.tagClass === 1 && this.isConstructed)
1008
1008
  switch (this.tagNumber) {
@@ -1032,15 +1032,15 @@ class Nt extends L(q) {
1032
1032
  };
1033
1033
  }
1034
1034
  }
1035
- Nt.NAME = "identificationBlock";
1036
- class It extends q {
1035
+ It.NAME = "identificationBlock";
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 (!H(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)
@@ -1057,14 +1057,14 @@ class It extends q {
1057
1057
  if (o + 1 > i.length)
1058
1058
  return this.error = "End of input reached before message was fully decoded", -1;
1059
1059
  const c = t + 1, a = s.subarray(c, c + o);
1060
- return a[o - 1] === 0 && this.warnings.push("Needlessly long encoded length"), this.length = X(a, 8), this.longFormUsed && this.length <= 127 && this.warnings.push("Unnecessary usage of long length form"), this.blockLength = o + 1, t + this.blockLength;
1060
+ return a[o - 1] === 0 && this.warnings.push("Needlessly long encoded length"), this.length = Y(a, 8), this.longFormUsed && this.length <= 127 && this.warnings.push("Unnecessary usage of long length form"), this.blockLength = o + 1, t + this.blockLength;
1061
1061
  }
1062
1062
  toBER(e = !1) {
1063
1063
  let t, r;
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)
@@ -1086,11 +1086,11 @@ class It extends q {
1086
1086
  };
1087
1087
  }
1088
1088
  }
1089
- It.NAME = "lengthBlock";
1089
+ Ut.NAME = "lengthBlock";
1090
1090
  const d = {};
1091
- class A extends q {
1092
- constructor({ name: e = Y, optional: t = !1, primitiveSchema: r, ...s } = {}, i) {
1093
- super(s), this.name = e, this.optional = t, r && (this.primitiveSchema = r), this.idBlock = new Nt(s), this.lenBlock = new It(s), this.valueBlock = i ? new i(s) : new S(s);
1091
+ class A extends G {
1092
+ constructor({ name: e = Q, 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 Ut(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 q {
1098
1098
  }
1099
1099
  toBER(e, t) {
1100
1100
  const r = t || new He();
1101
- t || Ut(this);
1101
+ t || Vt(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 q {
1122
1122
  return this.primitiveSchema && (e.primitiveSchema = this.primitiveSchema.toJSON()), e;
1123
1123
  }
1124
1124
  toString(e = "ascii") {
1125
- return e === "ascii" ? this.onAsciiEncoding() : v.ToHex(this.toBER());
1125
+ return e === "ascii" ? this.onAsciiEncoding() : k.ToHex(this.toBER());
1126
1126
  }
1127
1127
  onAsciiEncoding() {
1128
- const e = this.constructor.NAME, t = v.ToHex(this.valueBlock.valueBeforeDecodeView);
1128
+ const e = this.constructor.NAME, t = k.ToHex(this.valueBlock.valueBeforeDecodeView);
1129
1129
  return `${e} : ${t}`;
1130
1130
  }
1131
1131
  isEqual(e) {
@@ -1134,25 +1134,25 @@ class A extends q {
1134
1134
  if (!(e instanceof this.constructor))
1135
1135
  return !1;
1136
1136
  const t = this.toBER(), r = e.toBER();
1137
- return Ss(t, r);
1137
+ return Es(t, r);
1138
1138
  }
1139
1139
  }
1140
1140
  A.NAME = "BaseBlock";
1141
- function Ut(n) {
1141
+ function Vt(n) {
1142
1142
  var e;
1143
1143
  if (n instanceof d.Constructed)
1144
1144
  for (const t of n.valueBlock.value)
1145
- Ut(t) && (n.lenBlock.isIndefiniteForm = !0);
1145
+ Vt(t) && (n.lenBlock.isIndefiniteForm = !0);
1146
1146
  return !!(!((e = n.lenBlock) === null || e === void 0) && e.isIndefiniteForm);
1147
1147
  }
1148
- class Vt extends A {
1148
+ class Tt extends A {
1149
1149
  getValue() {
1150
1150
  return this.valueBlock.value;
1151
1151
  }
1152
1152
  setValue(e) {
1153
1153
  this.valueBlock.value = e;
1154
1154
  }
1155
- constructor({ value: e = Y, ...t } = {}, r) {
1155
+ constructor({ value: e = Q, ...t } = {}, r) {
1156
1156
  super(t, r), e && this.fromString(e);
1157
1157
  }
1158
1158
  fromBER(e, t, r) {
@@ -1163,33 +1163,33 @@ class Vt extends A {
1163
1163
  return `${this.constructor.NAME} : '${this.valueBlock.value}'`;
1164
1164
  }
1165
1165
  }
1166
- Vt.NAME = "BaseStringBlock";
1167
- class Tt extends L(S) {
1166
+ Tt.NAME = "BaseStringBlock";
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
- Tt.NAME = "PrimitiveValueBlock";
1172
+ _t.NAME = "PrimitiveValueBlock";
1173
1173
  var Ct;
1174
- class _t extends A {
1174
+ class Ht extends A {
1175
1175
  constructor(e = {}) {
1176
- super(e, Tt), this.idBlock.isConstructed = !1;
1176
+ super(e, _t), this.idBlock.isConstructed = !1;
1177
1177
  }
1178
1178
  }
1179
- Ct = _t;
1179
+ Ct = Ht;
1180
1180
  d.Primitive = Ct;
1181
- _t.NAME = "PRIMITIVE";
1182
- function Es(n, e) {
1181
+ Ht.NAME = "PRIMITIVE";
1182
+ function ps(n, e) {
1183
1183
  if (n instanceof e)
1184
1184
  return n;
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 we(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 (!H(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
@@ -1325,8 +1325,8 @@ function we(n, e = 0, t = n.length) {
1325
1325
  a = d.Duration;
1326
1326
  break;
1327
1327
  default: {
1328
- const u = s.idBlock.isConstructed ? new d.Constructed() : new d.Primitive();
1329
- u.idBlock = s.idBlock, u.lenBlock = s.lenBlock, u.warnings = s.warnings, s = u;
1328
+ const l = s.idBlock.isConstructed ? new d.Constructed() : new d.Primitive();
1329
+ l.idBlock = s.idBlock, l.lenBlock = s.lenBlock, l.warnings = s.warnings, s = l;
1330
1330
  }
1331
1331
  }
1332
1332
  break;
@@ -1336,12 +1336,12 @@ function we(n, e = 0, t = n.length) {
1336
1336
  default:
1337
1337
  a = s.idBlock.isConstructed ? d.Constructed : d.Primitive;
1338
1338
  }
1339
- return s = Es(s, a), c = s.fromBER(n, e, s.lenBlock.isIndefiniteForm ? t : s.lenBlock.length), s.valueBeforeDecodeView = n.subarray(r, r + s.blockLength), {
1339
+ return s = ps(s, a), c = s.fromBER(n, e, s.lenBlock.isIndefiniteForm ? t : s.lenBlock.length), s.valueBeforeDecodeView = n.subarray(r, r + s.blockLength), {
1340
1340
  offset: c,
1341
1341
  result: s
1342
1342
  };
1343
1343
  }
1344
- function ps(n) {
1344
+ function Ns(n) {
1345
1345
  if (!n.byteLength) {
1346
1346
  const e = new A({}, S);
1347
1347
  return e.error = "Input buffer has zero length", {
@@ -1349,30 +1349,30 @@ function ps(n) {
1349
1349
  result: e
1350
1350
  };
1351
1351
  }
1352
- return we(B.toUint8Array(n).slice(), 0, n.byteLength);
1352
+ return Be(B.toUint8Array(n).slice(), 0, n.byteLength);
1353
1353
  }
1354
- function Ns(n, e) {
1354
+ function Is(n, e) {
1355
1355
  return n ? 1 : e;
1356
1356
  }
1357
- class O 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 (!H(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
- for (; Ns(this.isIndefiniteForm, r) > 0; ) {
1369
- const o = we(s, i, r);
1368
+ for (; Is(this.isIndefiniteForm, r) > 0; ) {
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 === ae)
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 === ae ? 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 O extends S {
1391
1391
  return e;
1392
1392
  }
1393
1393
  }
1394
- O.NAME = "ConstructedValueBlock";
1395
- var Ht;
1396
- class Q extends A {
1394
+ $.NAME = "ConstructedValueBlock";
1395
+ var Lt;
1396
+ class ee extends A {
1397
1397
  constructor(e = {}) {
1398
- super(e, O), 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;
@@ -1414,10 +1414,10 @@ ${e.join(`
1414
1414
  `)}` : `${t} :`;
1415
1415
  }
1416
1416
  }
1417
- Ht = Q;
1418
- d.Constructed = Ht;
1419
- Q.NAME = "CONSTRUCTED";
1420
- class Lt extends S {
1417
+ Lt = ee;
1418
+ d.Constructed = Lt;
1419
+ ee.NAME = "CONSTRUCTED";
1420
+ class Rt extends S {
1421
1421
  fromBER(e, t, r) {
1422
1422
  return t;
1423
1423
  }
@@ -1425,18 +1425,18 @@ class Lt extends S {
1425
1425
  return T;
1426
1426
  }
1427
1427
  }
1428
- Lt.override = "EndOfContentValueBlock";
1429
- var Rt;
1430
- class Mt extends A {
1428
+ Rt.override = "EndOfContentValueBlock";
1429
+ var Mt;
1430
+ class Ot extends A {
1431
1431
  constructor(e = {}) {
1432
- super(e, Lt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 0;
1432
+ super(e, Rt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 0;
1433
1433
  }
1434
1434
  }
1435
- Rt = Mt;
1436
- d.EndOfContent = Rt;
1437
- Mt.NAME = ae;
1438
- var Ot;
1439
- class Dt extends A {
1435
+ Mt = Ot;
1436
+ d.EndOfContent = Mt;
1437
+ Ot.NAME = he;
1438
+ var Dt;
1439
+ class $t extends A {
1440
1440
  constructor(e = {}) {
1441
1441
  super(e, S), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 5;
1442
1442
  }
@@ -1455,10 +1455,10 @@ class Dt extends A {
1455
1455
  return `${this.constructor.NAME}`;
1456
1456
  }
1457
1457
  }
1458
- Ot = Dt;
1459
- d.Null = Ot;
1460
- Dt.NAME = "NULL";
1461
- class $t extends L(S) {
1458
+ Dt = $t;
1459
+ d.Null = Dt;
1460
+ $t.NAME = "NULL";
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 $t extends L(S) {
1473
1473
  }
1474
1474
  fromBER(e, t, r) {
1475
1475
  const s = B.toUint8Array(e);
1476
- return H(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, St.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();
@@ -1485,9 +1485,9 @@ class $t extends L(S) {
1485
1485
  };
1486
1486
  }
1487
1487
  }
1488
- $t.NAME = "BooleanValueBlock";
1489
- var Pt;
1490
- class Ft extends A {
1488
+ Pt.NAME = "BooleanValueBlock";
1489
+ var Ft;
1490
+ class jt extends A {
1491
1491
  getValue() {
1492
1492
  return this.valueBlock.value;
1493
1493
  }
@@ -1495,32 +1495,32 @@ class Ft extends A {
1495
1495
  this.valueBlock.value = e;
1496
1496
  }
1497
1497
  constructor(e = {}) {
1498
- super(e, $t), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 1;
1498
+ super(e, Pt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 1;
1499
1499
  }
1500
1500
  onAsciiEncoding() {
1501
1501
  return `${this.constructor.NAME} : ${this.getValue}`;
1502
1502
  }
1503
1503
  }
1504
- Pt = Ft;
1505
- d.Boolean = Pt;
1506
- Ft.NAME = "BOOLEAN";
1507
- class jt extends L(O) {
1504
+ Ft = jt;
1505
+ d.Boolean = Ft;
1506
+ jt.NAME = "BOOLEAN";
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 = O.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 === ae) {
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;
1522
1522
  }
1523
- if (o !== Et)
1523
+ if (o !== pt)
1524
1524
  return this.error = "OCTET STRING may consists of OCTET STRINGs only", -1;
1525
1525
  }
1526
1526
  } else
@@ -1528,7 +1528,7 @@ class jt extends L(O) {
1528
1528
  return s;
1529
1529
  }
1530
1530
  toBER(e, t) {
1531
- return this.isConstructed ? O.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 {
@@ -1537,9 +1537,9 @@ class jt extends L(O) {
1537
1537
  };
1538
1538
  }
1539
1539
  }
1540
- jt.NAME = "OctetStringValueBlock";
1540
+ qt.NAME = "OctetStringValueBlock";
1541
1541
  var Re;
1542
- class qt extends A {
1542
+ class Gt extends A {
1543
1543
  constructor({ idBlock: e = {}, lenBlock: t = {}, ...r } = {}) {
1544
1544
  var s, i;
1545
1545
  (s = r.isConstructed) !== null && s !== void 0 || (r.isConstructed = !!(!((i = r.value) === null || i === void 0) && i.length)), super({
@@ -1552,7 +1552,7 @@ class qt extends A {
1552
1552
  isIndefiniteForm: !!r.isIndefiniteForm
1553
1553
  },
1554
1554
  ...r
1555
- }, jt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 4;
1555
+ }, qt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 4;
1556
1556
  }
1557
1557
  fromBER(e, t, r) {
1558
1558
  if (this.valueBlock.isConstructed = this.idBlock.isConstructed, this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm, r === 0)
@@ -1561,7 +1561,7 @@ class qt 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 = we(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 {
@@ -1571,8 +1571,8 @@ class qt extends A {
1571
1571
  }
1572
1572
  onAsciiEncoding() {
1573
1573
  if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length)
1574
- return Q.prototype.onAsciiEncoding.call(this);
1575
- const e = this.constructor.NAME, t = v.ToHex(this.valueBlock.valueHexView);
1574
+ return ee.prototype.onAsciiEncoding.call(this);
1575
+ const e = this.constructor.NAME, t = k.ToHex(this.valueBlock.valueHexView);
1576
1576
  return `${e} : ${t}`;
1577
1577
  }
1578
1578
  getValue() {
@@ -1584,10 +1584,10 @@ class qt extends A {
1584
1584
  return B.concat(e);
1585
1585
  }
1586
1586
  }
1587
- Re = qt;
1587
+ Re = Gt;
1588
1588
  d.OctetString = Re;
1589
- qt.NAME = Et;
1590
- class Gt extends L(O) {
1589
+ Gt.NAME = pt;
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,26 +1596,26 @@ class Gt extends L(O) {
1596
1596
  return t;
1597
1597
  let s = -1;
1598
1598
  if (this.isConstructed) {
1599
- if (s = O.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 === ae) {
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;
1607
1607
  }
1608
- if (a !== pt)
1608
+ if (a !== Nt)
1609
1609
  return this.error = "BIT STRING may consists of BIT STRINGs only", -1;
1610
- const u = c.valueBlock;
1611
- if (this.unusedBits > 0 && u.unusedBits > 0)
1610
+ const l = c.valueBlock;
1611
+ if (this.unusedBits > 0 && l.unusedBits > 0)
1612
1612
  return this.error = 'Using of "unused bits" inside constructive BIT STRING allowed for least one only', -1;
1613
- this.unusedBits = u.unusedBits;
1613
+ this.unusedBits = l.unusedBits;
1614
1614
  }
1615
1615
  return s;
1616
1616
  }
1617
1617
  const i = B.toUint8Array(e);
1618
- if (!H(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 Gt extends L(O) {
1624
1624
  const c = o.subarray(1);
1625
1625
  try {
1626
1626
  if (c.byteLength) {
1627
- const a = we(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 Gt extends L(O) {
1634
1634
  }
1635
1635
  toBER(e, t) {
1636
1636
  if (this.isConstructed)
1637
- return O.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) {
@@ -1652,8 +1652,8 @@ class Gt extends L(O) {
1652
1652
  };
1653
1653
  }
1654
1654
  }
1655
- Gt.NAME = "BitStringValueBlock";
1656
- var Jt;
1655
+ Jt.NAME = "BitStringValueBlock";
1656
+ var Kt;
1657
1657
  class Me extends A {
1658
1658
  constructor({ idBlock: e = {}, lenBlock: t = {}, ...r } = {}) {
1659
1659
  var s, i;
@@ -1667,14 +1667,14 @@ class Me extends A {
1667
1667
  isIndefiniteForm: !!r.isIndefiniteForm
1668
1668
  },
1669
1669
  ...r
1670
- }, Gt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 3;
1670
+ }, Jt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 3;
1671
1671
  }
1672
1672
  fromBER(e, t, r) {
1673
1673
  return this.valueBlock.isConstructed = this.idBlock.isConstructed, this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm, super.fromBER(e, t, r);
1674
1674
  }
1675
1675
  onAsciiEncoding() {
1676
1676
  if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length)
1677
- return Q.prototype.onAsciiEncoding.call(this);
1677
+ return ee.prototype.onAsciiEncoding.call(this);
1678
1678
  {
1679
1679
  const e = [], t = this.valueBlock.valueHexView;
1680
1680
  for (const o of t)
@@ -1684,79 +1684,79 @@ class Me extends A {
1684
1684
  }
1685
1685
  }
1686
1686
  }
1687
- Jt = Me;
1688
- d.BitString = Jt;
1689
- Me.NAME = pt;
1690
- var Kt;
1691
- function Is(n, e) {
1687
+ Kt = Me;
1688
+ d.BitString = Kt;
1689
+ Me.NAME = Nt;
1690
+ var Wt;
1691
+ function Us(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, c = s.slice(0), a = c.length - 1;
1695
- let u = 0;
1695
+ let l = 0;
1696
1696
  const f = a < o ? o : a;
1697
1697
  let h = 0;
1698
- for (let l = f; l >= 0; l--, h++) {
1698
+ for (let u = f; u >= 0; u--, h++) {
1699
1699
  switch (!0) {
1700
1700
  case h < c.length:
1701
- u = i[o - h] + c[a - h] + t[0];
1701
+ l = i[o - h] + c[a - h] + t[0];
1702
1702
  break;
1703
1703
  default:
1704
- u = i[o - h] + t[0];
1704
+ l = i[o - h] + t[0];
1705
1705
  }
1706
- switch (t[0] = u / 10, !0) {
1706
+ switch (t[0] = l / 10, !0) {
1707
1707
  case h >= i.length:
1708
- i = Ne(new Uint8Array([u % 10]), i);
1708
+ i = Ne(new Uint8Array([l % 10]), i);
1709
1709
  break;
1710
1710
  default:
1711
- i[o - h] = u % 10;
1711
+ i[o - h] = l % 10;
1712
1712
  }
1713
1713
  }
1714
1714
  return t[0] > 0 && (i = Ne(t, i)), i;
1715
1715
  }
1716
1716
  function it(n) {
1717
- if (n >= se.length)
1718
- for (let e = se.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 = se[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)), se.push(r);
1725
+ t[0] > 0 && (r = Ne(t, r)), oe.push(r);
1726
1726
  }
1727
- return se[n];
1727
+ return oe[n];
1728
1728
  }
1729
- function Us(n, e) {
1729
+ function Vs(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, c = s.slice(0), a = c.length - 1;
1732
- let u, f = 0;
1732
+ let l, f = 0;
1733
1733
  for (let h = a; h >= 0; h--, f++)
1734
- switch (u = i[o - f] - c[a - f] - t, !0) {
1735
- case u < 0:
1736
- t = 1, i[o - f] = u + 10;
1734
+ switch (l = i[o - f] - c[a - f] - t, !0) {
1735
+ case l < 0:
1736
+ t = 1, i[o - f] = l + 10;
1737
1737
  break;
1738
1738
  default:
1739
- t = 0, i[o - f] = u;
1739
+ t = 0, i[o - f] = l;
1740
1740
  }
1741
1741
  if (t > 0)
1742
1742
  for (let h = o - a + 1; h >= 0; h--, f++)
1743
- if (u = i[o - f] - t, u < 0)
1744
- t = 1, i[o - f] = u + 10;
1743
+ if (l = i[o - f] - t, l < 0)
1744
+ t = 1, i[o - f] = l + 10;
1745
1745
  else {
1746
- t = 0, i[o - f] = u;
1746
+ t = 0, i[o - f] = l;
1747
1747
  break;
1748
1748
  }
1749
1749
  return i.slice();
1750
1750
  }
1751
- class Oe extends L(S) {
1751
+ class Oe extends M(S) {
1752
1752
  setValueHex() {
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 = St.call(this)));
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
  }
1755
1755
  constructor({ value: e, ...t } = {}) {
1756
1756
  super(t), this._valueDec = 0, t.valueHex && this.setValueHex(), e !== void 0 && (this.valueDec = e);
1757
1757
  }
1758
1758
  set valueDec(e) {
1759
- this._valueDec = e, this.isHexOnly = !1, this.valueHexView = new Uint8Array(xs(e));
1759
+ this._valueDec = e, this.isHexOnly = !1, this.valueHexView = new Uint8Array(Ss(e));
1760
1760
  }
1761
1761
  get valueDec() {
1762
1762
  return this._valueDec;
@@ -1803,14 +1803,14 @@ class Oe extends L(S) {
1803
1803
  let o = "", c = !1;
1804
1804
  for (let a = i.byteLength - 1; a >= 0; a--) {
1805
1805
  s = i[a];
1806
- for (let u = 0; u < 8; u++) {
1806
+ for (let l = 0; l < 8; l++) {
1807
1807
  if ((s & 1) === 1)
1808
1808
  switch (r) {
1809
1809
  case e:
1810
- t = Us(it(r), t), o = "-";
1810
+ t = Vs(it(r), t), o = "-";
1811
1811
  break;
1812
1812
  default:
1813
- t = Is(t, it(r));
1813
+ t = Us(t, it(r));
1814
1814
  }
1815
1815
  r++, s >>= 1;
1816
1816
  }
@@ -1820,9 +1820,9 @@ class Oe extends L(S) {
1820
1820
  return c === !1 && (o += nt.charAt(0)), o;
1821
1821
  }
1822
1822
  }
1823
- Kt = Oe;
1823
+ Wt = Oe;
1824
1824
  Oe.NAME = "IntegerValueBlock";
1825
- Object.defineProperty(Kt.prototype, "valueHex", {
1825
+ Object.defineProperty(Wt.prototype, "valueHex", {
1826
1826
  set: function(n) {
1827
1827
  this.valueHexView = new Uint8Array(n), this.setValueHex();
1828
1828
  },
@@ -1830,32 +1830,32 @@ Object.defineProperty(Kt.prototype, "valueHex", {
1830
1830
  return this.valueHexView.slice().buffer;
1831
1831
  }
1832
1832
  });
1833
- var oe;
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 de(), BigInt(this.valueBlock.toString());
1839
+ return we(), BigInt(this.valueBlock.toString());
1840
1840
  }
1841
1841
  static fromBigInt(e) {
1842
- de();
1843
- const t = BigInt(e), r = new He(), s = t.toString(16).replace(/^-/, ""), i = new Uint8Array(v.FromHex(s));
1842
+ we();
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));
1846
1846
  c[0] |= 128;
1847
- const u = BigInt(`0x${v.ToHex(c)}`) + t, f = B.toUint8Array(v.FromHex(u.toString(16)));
1847
+ const l = BigInt(`0x${k.ToHex(c)}`) + t, f = B.toUint8Array(k.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);
1851
- return new oe({ valueHex: r.final() });
1851
+ return new le({ valueHex: r.final() });
1852
1852
  }
1853
1853
  convertToDER() {
1854
- const e = new oe({ 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 oe({
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,19 +1863,19 @@ class De extends A {
1863
1863
  return `${this.constructor.NAME} : ${this.valueBlock.toString()}`;
1864
1864
  }
1865
1865
  }
1866
- oe = De;
1867
- d.Integer = oe;
1866
+ le = De;
1867
+ d.Integer = le;
1868
1868
  De.NAME = "INTEGER";
1869
- var Wt;
1869
+ var Xt;
1870
1870
  class Zt extends De {
1871
1871
  constructor(e = {}) {
1872
1872
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 10;
1873
1873
  }
1874
1874
  }
1875
- Wt = Zt;
1876
- d.Enumerated = Wt;
1875
+ Xt = Zt;
1876
+ d.Enumerated = Xt;
1877
1877
  Zt.NAME = "ENUMERATED";
1878
- class Ie extends L(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 L(S) {
1883
1883
  if (!r)
1884
1884
  return t;
1885
1885
  const s = B.toUint8Array(e);
1886
- if (!H(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);
@@ -1892,10 +1892,10 @@ class Ie extends L(S) {
1892
1892
  const o = new Uint8Array(this.blockLength);
1893
1893
  for (let c = 0; c < this.blockLength; c++)
1894
1894
  o[c] = this.valueHexView[c];
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 = X(this.valueHexView, 7) : (this.isHexOnly = !0, this.warnings.push("Too big SID for decoding, hex only")), t + this.blockLength);
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
- de();
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 L(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);
@@ -1928,7 +1928,7 @@ class Ie extends L(S) {
1928
1928
  toString() {
1929
1929
  let e = "";
1930
1930
  if (this.isHexOnly)
1931
- e = v.ToHex(this.valueHexView);
1931
+ e = k.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();
@@ -1946,7 +1946,7 @@ class Ie extends L(S) {
1946
1946
  }
1947
1947
  Ie.NAME = "sidBlock";
1948
1948
  class zt extends S {
1949
- constructor({ value: e = Y, ...t } = {}) {
1949
+ constructor({ value: e = Q, ...t } = {}) {
1950
1950
  super(t), this.value = [], e && this.fromString(e);
1951
1951
  }
1952
1952
  fromBER(e, t, r) {
@@ -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
- de();
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))
@@ -2026,7 +2026,7 @@ class zt extends S {
2026
2026
  }
2027
2027
  }
2028
2028
  zt.NAME = "ObjectIdentifierValueBlock";
2029
- var Xt;
2029
+ var Yt;
2030
2030
  class $e extends A {
2031
2031
  getValue() {
2032
2032
  return this.valueBlock.toString();
@@ -2047,10 +2047,10 @@ class $e extends A {
2047
2047
  };
2048
2048
  }
2049
2049
  }
2050
- Xt = $e;
2051
- d.ObjectIdentifier = Xt;
2050
+ Yt = $e;
2051
+ d.ObjectIdentifier = Yt;
2052
2052
  $e.NAME = "OBJECT IDENTIFIER";
2053
- class Ue extends L(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 L(q) {
2058
2058
  if (r === 0)
2059
2059
  return t;
2060
2060
  const s = B.toUint8Array(e);
2061
- if (!H(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);
@@ -2067,7 +2067,7 @@ class Ue extends L(q) {
2067
2067
  const o = new Uint8Array(this.blockLength);
2068
2068
  for (let c = 0; c < this.blockLength; c++)
2069
2069
  o[c] = this.valueHexView[c];
2070
- 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 = X(this.valueHexView, 7) : (this.isHexOnly = !0, this.warnings.push("Too big SID for decoding, hex only")), t + this.blockLength);
2070
+ 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);
2071
2071
  }
2072
2072
  toBER(e) {
2073
2073
  if (this.isHexOnly) {
@@ -2078,7 +2078,7 @@ class Ue extends L(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);
@@ -2092,7 +2092,7 @@ class Ue extends L(q) {
2092
2092
  }
2093
2093
  toString() {
2094
2094
  let e = "";
2095
- return this.isHexOnly ? e = v.ToHex(this.valueHexView) : e = this.valueDec.toString(), e;
2095
+ return this.isHexOnly ? e = k.ToHex(this.valueHexView) : e = this.valueDec.toString(), e;
2096
2096
  }
2097
2097
  toJSON() {
2098
2098
  return {
@@ -2102,8 +2102,8 @@ class Ue extends L(q) {
2102
2102
  }
2103
2103
  }
2104
2104
  Ue.NAME = "relativeSidBlock";
2105
- class Yt extends S {
2106
- constructor({ value: e = Y, ...t } = {}) {
2105
+ class Qt extends S {
2106
+ constructor({ value: e = Q, ...t } = {}) {
2107
2107
  super(t), this.value = [], e && this.fromString(e);
2108
2108
  }
2109
2109
  fromBER(e, t, r) {
@@ -2124,7 +2124,7 @@ class Yt 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 = [];
@@ -2158,9 +2158,9 @@ class Yt extends S {
2158
2158
  return e;
2159
2159
  }
2160
2160
  }
2161
- Yt.NAME = "RelativeObjectIdentifierValueBlock";
2162
- var Qt;
2163
- class er extends A {
2161
+ Qt.NAME = "RelativeObjectIdentifierValueBlock";
2162
+ var er;
2163
+ class tr extends A {
2164
2164
  getValue() {
2165
2165
  return this.valueBlock.toString();
2166
2166
  }
@@ -2168,7 +2168,7 @@ class er extends A {
2168
2168
  this.valueBlock.fromString(e);
2169
2169
  }
2170
2170
  constructor(e = {}) {
2171
- super(e, Yt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 13;
2171
+ super(e, Qt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 13;
2172
2172
  }
2173
2173
  onAsciiEncoding() {
2174
2174
  return `${this.constructor.NAME} : ${this.valueBlock.toString() || "empty"}`;
@@ -2180,30 +2180,30 @@ class er extends A {
2180
2180
  };
2181
2181
  }
2182
2182
  }
2183
- Qt = er;
2184
- d.RelativeObjectIdentifier = Qt;
2185
- er.NAME = "RelativeObjectIdentifier";
2186
- var tr;
2187
- class ge extends Q {
2183
+ er = tr;
2184
+ d.RelativeObjectIdentifier = er;
2185
+ tr.NAME = "RelativeObjectIdentifier";
2186
+ var rr;
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
- tr = ge;
2193
- d.Sequence = tr;
2194
- ge.NAME = "SEQUENCE";
2195
- var rr;
2196
- class sr extends Q {
2192
+ rr = ye;
2193
+ d.Sequence = rr;
2194
+ ye.NAME = "SEQUENCE";
2195
+ var sr;
2196
+ class nr extends ee {
2197
2197
  constructor(e = {}) {
2198
2198
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 17;
2199
2199
  }
2200
2200
  }
2201
- rr = sr;
2202
- d.Set = rr;
2203
- sr.NAME = "SET";
2204
- class nr extends L(S) {
2201
+ sr = nr;
2202
+ d.Set = sr;
2203
+ nr.NAME = "SET";
2204
+ class ir extends M(S) {
2205
2205
  constructor({ ...e } = {}) {
2206
- super(e), this.isHexOnly = !0, this.value = Y;
2206
+ super(e), this.isHexOnly = !0, this.value = Q;
2207
2207
  }
2208
2208
  toJSON() {
2209
2209
  return {
@@ -2212,13 +2212,13 @@ class nr extends L(S) {
2212
2212
  };
2213
2213
  }
2214
2214
  }
2215
- nr.NAME = "StringValueBlock";
2216
- class ir extends nr {
2215
+ ir.NAME = "StringValueBlock";
2216
+ class or extends ir {
2217
2217
  }
2218
- ir.NAME = "SimpleStringValueBlock";
2219
- class N extends Vt {
2218
+ or.NAME = "SimpleStringValueBlock";
2219
+ class N extends Tt {
2220
2220
  constructor({ ...e } = {}) {
2221
- super(e, ir);
2221
+ super(e, or);
2222
2222
  }
2223
2223
  fromBuffer(e) {
2224
2224
  this.valueBlock.value = String.fromCharCode.apply(null, B.toUint8Array(e));
@@ -2231,48 +2231,48 @@ class N extends Vt {
2231
2231
  }
2232
2232
  }
2233
2233
  N.NAME = "SIMPLE STRING";
2234
- class or extends N {
2234
+ class cr extends N {
2235
2235
  fromBuffer(e) {
2236
2236
  this.valueBlock.valueHexView = B.toUint8Array(e);
2237
2237
  try {
2238
- this.valueBlock.value = v.ToUtf8String(e);
2238
+ this.valueBlock.value = k.ToUtf8String(e);
2239
2239
  } catch (t) {
2240
- this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`), this.valueBlock.value = v.ToBinary(e);
2240
+ this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`), this.valueBlock.value = k.ToBinary(e);
2241
2241
  }
2242
2242
  }
2243
2243
  fromString(e) {
2244
- this.valueBlock.valueHexView = new Uint8Array(v.FromUtf8String(e)), this.valueBlock.value = e;
2244
+ this.valueBlock.valueHexView = new Uint8Array(k.FromUtf8String(e)), this.valueBlock.value = e;
2245
2245
  }
2246
2246
  }
2247
- or.NAME = "Utf8StringValueBlock";
2248
- var cr;
2249
- class G extends or {
2247
+ cr.NAME = "Utf8StringValueBlock";
2248
+ var ar;
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
- cr = G;
2255
- d.Utf8String = cr;
2256
- G.NAME = "UTF8String";
2257
- class ar extends N {
2254
+ ar = J;
2255
+ d.Utf8String = ar;
2256
+ J.NAME = "UTF8String";
2257
+ class lr extends N {
2258
2258
  fromBuffer(e) {
2259
- this.valueBlock.value = v.ToUtf16String(e), this.valueBlock.valueHexView = B.toUint8Array(e);
2259
+ this.valueBlock.value = k.ToUtf16String(e), this.valueBlock.valueHexView = B.toUint8Array(e);
2260
2260
  }
2261
2261
  fromString(e) {
2262
- this.valueBlock.value = e, this.valueBlock.valueHexView = new Uint8Array(v.FromUtf16String(e));
2262
+ this.valueBlock.value = e, this.valueBlock.valueHexView = new Uint8Array(k.FromUtf16String(e));
2263
2263
  }
2264
2264
  }
2265
- ar.NAME = "BmpStringValueBlock";
2266
- var lr;
2267
- class ur extends ar {
2265
+ lr.NAME = "BmpStringValueBlock";
2266
+ var ur;
2267
+ class hr extends lr {
2268
2268
  constructor({ ...e } = {}) {
2269
2269
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 30;
2270
2270
  }
2271
2271
  }
2272
- lr = ur;
2273
- d.BmpString = lr;
2274
- ur.NAME = "BMPString";
2275
- class hr extends N {
2272
+ ur = hr;
2273
+ d.BmpString = ur;
2274
+ hr.NAME = "BMPString";
2275
+ class fr extends N {
2276
2276
  fromBuffer(e) {
2277
2277
  const t = ArrayBuffer.isView(e) ? e.slice().buffer : e.slice(0), r = new Uint8Array(t);
2278
2278
  for (let s = 0; s < r.length; s += 4)
@@ -2282,7 +2282,7 @@ class hr 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;
@@ -2292,98 +2292,98 @@ class hr extends N {
2292
2292
  this.valueBlock.value = e;
2293
2293
  }
2294
2294
  }
2295
- hr.NAME = "UniversalStringValueBlock";
2296
- var fr;
2297
- class dr extends hr {
2295
+ fr.NAME = "UniversalStringValueBlock";
2296
+ var dr;
2297
+ class gr extends fr {
2298
2298
  constructor({ ...e } = {}) {
2299
2299
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 28;
2300
2300
  }
2301
2301
  }
2302
- fr = dr;
2303
- d.UniversalString = fr;
2304
- dr.NAME = "UniversalString";
2305
- var gr;
2306
- class wr extends N {
2302
+ dr = gr;
2303
+ d.UniversalString = dr;
2304
+ gr.NAME = "UniversalString";
2305
+ var wr;
2306
+ class yr extends N {
2307
2307
  constructor(e = {}) {
2308
2308
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 18;
2309
2309
  }
2310
2310
  }
2311
- gr = wr;
2312
- d.NumericString = gr;
2313
- wr.NAME = "NumericString";
2311
+ wr = yr;
2312
+ d.NumericString = wr;
2313
+ yr.NAME = "NumericString";
2314
2314
  var Br;
2315
- class yr extends N {
2315
+ class br extends N {
2316
2316
  constructor(e = {}) {
2317
2317
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 19;
2318
2318
  }
2319
2319
  }
2320
- Br = yr;
2320
+ Br = br;
2321
2321
  d.PrintableString = Br;
2322
- yr.NAME = "PrintableString";
2323
- var br;
2324
- class vr extends N {
2322
+ br.NAME = "PrintableString";
2323
+ var vr;
2324
+ class kr extends N {
2325
2325
  constructor(e = {}) {
2326
2326
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 20;
2327
2327
  }
2328
2328
  }
2329
- br = vr;
2330
- d.TeletexString = br;
2331
- vr.NAME = "TeletexString";
2332
- var kr;
2333
- class mr extends N {
2329
+ vr = kr;
2330
+ d.TeletexString = vr;
2331
+ kr.NAME = "TeletexString";
2332
+ var mr;
2333
+ class Ar extends N {
2334
2334
  constructor(e = {}) {
2335
2335
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 21;
2336
2336
  }
2337
2337
  }
2338
- kr = mr;
2339
- d.VideotexString = kr;
2340
- mr.NAME = "VideotexString";
2341
- var Ar;
2342
- class xr extends N {
2338
+ mr = Ar;
2339
+ d.VideotexString = mr;
2340
+ Ar.NAME = "VideotexString";
2341
+ var xr;
2342
+ class Sr extends N {
2343
2343
  constructor(e = {}) {
2344
2344
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 22;
2345
2345
  }
2346
2346
  }
2347
- Ar = xr;
2348
- d.IA5String = Ar;
2349
- xr.NAME = "IA5String";
2350
- var Sr;
2351
- class Er extends N {
2347
+ xr = Sr;
2348
+ d.IA5String = xr;
2349
+ Sr.NAME = "IA5String";
2350
+ var Er;
2351
+ class pr extends N {
2352
2352
  constructor(e = {}) {
2353
2353
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 25;
2354
2354
  }
2355
2355
  }
2356
- Sr = Er;
2357
- d.GraphicString = Sr;
2358
- Er.NAME = "GraphicString";
2359
- var pr;
2356
+ Er = pr;
2357
+ d.GraphicString = Er;
2358
+ pr.NAME = "GraphicString";
2359
+ var Nr;
2360
2360
  class Pe extends N {
2361
2361
  constructor(e = {}) {
2362
2362
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 26;
2363
2363
  }
2364
2364
  }
2365
- pr = Pe;
2366
- d.VisibleString = pr;
2365
+ Nr = Pe;
2366
+ d.VisibleString = Nr;
2367
2367
  Pe.NAME = "VisibleString";
2368
- var Nr;
2369
- class Ir extends N {
2368
+ var Ir;
2369
+ class Ur extends N {
2370
2370
  constructor(e = {}) {
2371
2371
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 27;
2372
2372
  }
2373
2373
  }
2374
- Nr = Ir;
2375
- d.GeneralString = Nr;
2376
- Ir.NAME = "GeneralString";
2377
- var Ur;
2378
- class Vr extends N {
2374
+ Ir = Ur;
2375
+ d.GeneralString = Ir;
2376
+ Ur.NAME = "GeneralString";
2377
+ var Vr;
2378
+ class Tr extends N {
2379
2379
  constructor(e = {}) {
2380
2380
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 29;
2381
2381
  }
2382
2382
  }
2383
- Ur = Vr;
2384
- d.CharacterString = Ur;
2385
- Vr.NAME = "CharacterString";
2386
- var Tr;
2383
+ Vr = Tr;
2384
+ d.CharacterString = Vr;
2385
+ Tr.NAME = "CharacterString";
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,11 +2439,11 @@ class Fe extends Pe {
2439
2439
  };
2440
2440
  }
2441
2441
  }
2442
- Tr = Fe;
2443
- d.UTCTime = Tr;
2442
+ _r = Fe;
2443
+ d.UTCTime = _r;
2444
2444
  Fe.NAME = "UTCTime";
2445
2445
  var Cr;
2446
- class _r extends Fe {
2446
+ class Hr extends Fe {
2447
2447
  constructor(e = {}) {
2448
2448
  var t;
2449
2449
  super(e), (t = this.millisecond) !== null && t !== void 0 || (this.millisecond = 0), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 24;
@@ -2471,9 +2471,9 @@ class _r extends Fe {
2471
2471
  if (r.indexOf("-") !== -1)
2472
2472
  throw new Error("Wrong input string for conversion");
2473
2473
  } else {
2474
- let h = 1, l = r.indexOf("+"), g = "";
2475
- if (l === -1 && (l = r.indexOf("-"), h = -1), l !== -1) {
2476
- if (g = r.substring(l + 1), r = r.substring(0, l), g.length !== 2 && g.length !== 4)
2474
+ let h = 1, u = r.indexOf("+"), g = "";
2475
+ if (u === -1 && (u = r.indexOf("-"), h = -1), u !== -1) {
2476
+ if (g = r.substring(u + 1), r = r.substring(0, u), g.length !== 2 && g.length !== 4)
2477
2477
  throw new Error("Wrong input string for conversion");
2478
2478
  let w = parseInt(g.substring(0, 2), 10);
2479
2479
  if (isNaN(w.valueOf()))
@@ -2485,33 +2485,33 @@ class _r extends Fe {
2485
2485
  }
2486
2486
  }
2487
2487
  }
2488
- let u = r.indexOf(".");
2489
- if (u === -1 && (u = r.indexOf(",")), u !== -1) {
2490
- const h = new Number(`0${r.substring(u)}`);
2488
+ let l = r.indexOf(".");
2489
+ if (l === -1 && (l = r.indexOf(",")), l !== -1) {
2490
+ const h = new Number(`0${r.substring(l)}`);
2491
2491
  if (isNaN(h.valueOf()))
2492
2492
  throw new Error("Wrong input string for conversion");
2493
- i = h.valueOf(), s = r.substring(0, u);
2493
+ i = h.valueOf(), s = r.substring(0, l);
2494
2494
  } else
2495
2495
  s = r;
2496
2496
  switch (!0) {
2497
2497
  case s.length === 8:
2498
- if (o = /(\d{4})(\d{2})(\d{2})/ig, u !== -1)
2498
+ if (o = /(\d{4})(\d{2})(\d{2})/ig, l !== -1)
2499
2499
  throw new Error("Wrong input string for conversion");
2500
2500
  break;
2501
2501
  case s.length === 10:
2502
- if (o = /(\d{4})(\d{2})(\d{2})(\d{2})/ig, u !== -1) {
2502
+ if (o = /(\d{4})(\d{2})(\d{2})(\d{2})/ig, l !== -1) {
2503
2503
  let h = 60 * i;
2504
2504
  this.minute = Math.floor(h), h = 60 * (h - this.minute), this.second = Math.floor(h), h = 1e3 * (h - this.second), this.millisecond = Math.floor(h);
2505
2505
  }
2506
2506
  break;
2507
2507
  case s.length === 12:
2508
- if (o = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig, u !== -1) {
2508
+ if (o = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig, l !== -1) {
2509
2509
  let h = 60 * i;
2510
2510
  this.second = Math.floor(h), h = 1e3 * (h - this.second), this.millisecond = Math.floor(h);
2511
2511
  }
2512
2512
  break;
2513
2513
  case s.length === 14:
2514
- if (o = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig, u !== -1) {
2514
+ if (o = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig, l !== -1) {
2515
2515
  const h = 1e3 * i;
2516
2516
  this.millisecond = Math.floor(h);
2517
2517
  }
@@ -2564,76 +2564,76 @@ class _r extends Fe {
2564
2564
  };
2565
2565
  }
2566
2566
  }
2567
- Cr = _r;
2567
+ Cr = Hr;
2568
2568
  d.GeneralizedTime = Cr;
2569
- _r.NAME = "GeneralizedTime";
2570
- var Hr;
2571
- class Lr extends G {
2569
+ Hr.NAME = "GeneralizedTime";
2570
+ var Lr;
2571
+ class Rr extends J {
2572
2572
  constructor(e = {}) {
2573
2573
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 31;
2574
2574
  }
2575
2575
  }
2576
- Hr = Lr;
2577
- d.DATE = Hr;
2578
- Lr.NAME = "DATE";
2579
- var Rr;
2580
- class Mr extends G {
2576
+ Lr = Rr;
2577
+ d.DATE = Lr;
2578
+ Rr.NAME = "DATE";
2579
+ var Mr;
2580
+ class Or extends J {
2581
2581
  constructor(e = {}) {
2582
2582
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 32;
2583
2583
  }
2584
2584
  }
2585
- Rr = Mr;
2586
- d.TimeOfDay = Rr;
2587
- Mr.NAME = "TimeOfDay";
2588
- var Or;
2589
- class Dr extends G {
2585
+ Mr = Or;
2586
+ d.TimeOfDay = Mr;
2587
+ Or.NAME = "TimeOfDay";
2588
+ var Dr;
2589
+ class $r extends J {
2590
2590
  constructor(e = {}) {
2591
2591
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 33;
2592
2592
  }
2593
2593
  }
2594
- Or = Dr;
2595
- d.DateTime = Or;
2596
- Dr.NAME = "DateTime";
2597
- var $r;
2598
- class Pr extends G {
2594
+ Dr = $r;
2595
+ d.DateTime = Dr;
2596
+ $r.NAME = "DateTime";
2597
+ var Pr;
2598
+ class Fr extends J {
2599
2599
  constructor(e = {}) {
2600
2600
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 34;
2601
2601
  }
2602
2602
  }
2603
- $r = Pr;
2604
- d.Duration = $r;
2605
- Pr.NAME = "Duration";
2606
- var Fr;
2607
- class jr extends G {
2603
+ Pr = Fr;
2604
+ d.Duration = Pr;
2605
+ Fr.NAME = "Duration";
2606
+ var jr;
2607
+ class qr extends J {
2608
2608
  constructor(e = {}) {
2609
2609
  super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 14;
2610
2610
  }
2611
2611
  }
2612
- Fr = jr;
2613
- d.TIME = Fr;
2614
- jr.NAME = "TIME";
2615
- function Vs(n) {
2616
- const e = n.slice().buffer, t = new ge({
2612
+ jr = qr;
2613
+ d.TIME = jr;
2614
+ qr.NAME = "TIME";
2615
+ function Ts(n) {
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 ge({
2621
+ }), s = new ye({
2622
2622
  value: [t, r]
2623
2623
  });
2624
2624
  return new Uint8Array(s.toBER());
2625
2625
  }
2626
- function Ts(n) {
2627
- const e = n.slice().buffer, s = ps(e).result.valueBlock.value[1];
2626
+ function _s(n) {
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 ne(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 ie(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 ce(n) {
2650
+ function ue(n) {
2651
2651
  return n.buffer;
2652
2652
  }
2653
2653
  async function Cs(n, e, t, r) {
2654
2654
  const s = await crypto.subtle.importKey(
2655
2655
  "raw",
2656
- ce(n),
2656
+ ue(n),
2657
2657
  "HKDF",
2658
2658
  !1,
2659
2659
  ["deriveBits"]
@@ -2661,18 +2661,18 @@ async function Cs(n, e, t, r) {
2661
2661
  {
2662
2662
  name: "HKDF",
2663
2663
  hash: "SHA-256",
2664
- salt: ce(e),
2665
- info: ce(t)
2664
+ salt: ue(e),
2665
+ info: ue(t)
2666
2666
  },
2667
2667
  s,
2668
2668
  r * 8
2669
2669
  );
2670
2670
  return new Uint8Array(i);
2671
2671
  }
2672
- async function _s(n) {
2672
+ async function Hs(n) {
2673
2673
  return crypto.subtle.importKey(
2674
2674
  "raw",
2675
- ce(n),
2675
+ ue(n),
2676
2676
  {
2677
2677
  name: "HMAC",
2678
2678
  hash: "SHA-256"
@@ -2681,23 +2681,23 @@ async function _s(n) {
2681
2681
  ["sign"]
2682
2682
  );
2683
2683
  }
2684
- async function Hs(n, e) {
2684
+ async function Ls(n, e) {
2685
2685
  const t = await crypto.subtle.sign(
2686
2686
  "HMAC",
2687
2687
  n,
2688
- ce(e)
2688
+ ue(e)
2689
2689
  );
2690
2690
  return new Uint8Array(t);
2691
2691
  }
2692
- function Ls(n) {
2692
+ function Rs(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);
2696
2696
  for (let i = 0; i < r.length; i++) s[i] = r.charCodeAt(i);
2697
2697
  return s.buffer;
2698
2698
  }
2699
- async function Rs(n, e, t) {
2700
- const r = Ls(n), s = await crypto.subtle.importKey(
2699
+ async function Ms(n, e, t) {
2700
+ const r = Rs(n), s = await crypto.subtle.importKey(
2701
2701
  "spki",
2702
2702
  r,
2703
2703
  // SPKI "-----BEGIN PUBLIC KEY-----"
@@ -2714,15 +2714,33 @@ async function Rs(n, e, t) {
2714
2714
  // <= raw SPKI DER bytes the server says it signed
2715
2715
  );
2716
2716
  }
2717
- class Ms {
2717
+ class ct {
2718
2718
  constructor(e) {
2719
- this.ws = null, this.listeners = {}, this.subscriptions = { request: {}, status: {}, topic: {} }, this._shouldReconnect = !0, this._reconnectAttempt = 0, this.generateRandomString = (t) => {
2719
+ this.ws = null, this.listeners = {}, this.subscriptions = { request: {}, status: {}, topic: {} }, this._shouldReconnect = !0, this._reconnectAttempt = 0, this.chunkBuffers = {}, this.generateRandomString = (t) => {
2720
2720
  let r = "";
2721
2721
  for (; r.length < t; )
2722
2722
  r += Math.random().toString(36).substring(2, 2 + (t - r.length));
2723
2723
  return r;
2724
+ }, this.distributeMessage = (t) => {
2725
+ const { correlation_id: r, status: s, topic: i } = t || {}, o = this.subscriptions.request[r];
2726
+ o && Object.values(o).forEach((l) => l(t));
2727
+ const c = this.subscriptions.status[s];
2728
+ c && Object.values(c).forEach((l) => l(t));
2729
+ const a = this.subscriptions.topic[i];
2730
+ a && Object.values(a).forEach((l) => l(t)), Object.values(this.listeners).forEach((l) => l(t));
2724
2731
  }, this.client = e;
2725
2732
  }
2733
+ async executeWithRetry(e, t = 3) {
2734
+ let r = 0, s = 1e3;
2735
+ for (; r <= t; )
2736
+ try {
2737
+ return await e();
2738
+ } catch (i) {
2739
+ if (r++, r > t) throw i;
2740
+ console.warn(`[WPS] Claim check fetch failed. Retrying in ${s}ms...`), await new Promise((o) => setTimeout(o, s)), s *= 2;
2741
+ }
2742
+ throw new Error("Retry loop failed");
2743
+ }
2726
2744
  scheduleReconnect() {
2727
2745
  if (!this._shouldReconnect) return;
2728
2746
  const e = Math.min(3e4, 1e3 * 2 ** this._reconnectAttempt);
@@ -2737,22 +2755,53 @@ class Ms {
2737
2755
  }
2738
2756
  async connect() {
2739
2757
  var e;
2740
- if (await this.client.ensureSession(), !this.client.getAccessToken())
2758
+ if (!this.client.getAccessToken())
2741
2759
  throw new Error("Cannot connect to notifications: user is not logged in.");
2742
2760
  if (!(this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING))) {
2743
2761
  if (this._connectPromise) return this._connectPromise;
2744
2762
  this._connectPromise = (async () => {
2745
- const { ans: t } = await this.client.get("/url/notifications"), { url: r } = t.data[0];
2763
+ const t = await this.client.get("/url/notifications"), { url: r } = t.data[0];
2746
2764
  this.ws = new WebSocket(r), this.ws.onopen = () => {
2747
- this._reconnectAttempt = 0, console.log("Notifications connected");
2765
+ this._reconnectAttempt = 0;
2748
2766
  }, this.ws.onmessage = async (s) => {
2749
2767
  try {
2750
- const i = JSON.parse(s.data), o = await this.client.decryptAndVerify(i), c = this.subscriptions.request[o == null ? void 0 : o.correlation_id];
2751
- c && Object.values(c).length > 0 && Object.values(c).forEach((f) => f(o));
2752
- const a = this.subscriptions.status[o == null ? void 0 : o.status];
2753
- a && Object.values(a).length > 0 && Object.values(a).forEach((f) => f(o));
2754
- const u = this.subscriptions.topic[o == null ? void 0 : o.topic];
2755
- u && Object.values(u).length > 0 && Object.values(u).forEach((f) => f(o)), Object.values(this.listeners).forEach((f) => f(o));
2768
+ const i = JSON.parse(s.data);
2769
+ if (!i.ciphertext) {
2770
+ const { operation_id: h, iv: u, signature: g, topic: w, correlation_id: v, content_type: y, ..._ } = i;
2771
+ if (!h)
2772
+ throw new Error("Claim check received but missing operation_id");
2773
+ const C = await this.executeWithRetry(() => this.client.get(`/responses/${h}`, {}, !0)), te = {
2774
+ ..._,
2775
+ content_type: y,
2776
+ topic: w,
2777
+ correlation_id: v,
2778
+ ciphertext: C.data,
2779
+ tot_pages: C.tot_pages,
2780
+ has_more: C.has_more,
2781
+ page_num: C.page_num,
2782
+ iv: u,
2783
+ signature: g
2784
+ }, re = await this.client.decryptAndVerify(te);
2785
+ this.distributeMessage(re);
2786
+ return;
2787
+ }
2788
+ const o = i.page_num, c = i.chunk_num, a = i.total_chunks;
2789
+ let l = i;
2790
+ if (a > 1) {
2791
+ this.chunkBuffers[o] || (this.chunkBuffers[o] = {
2792
+ chunks: new Array(a),
2793
+ count: 0,
2794
+ total: a
2795
+ });
2796
+ const h = this.chunkBuffers[o];
2797
+ if (h.chunks[c] === void 0 && (h.chunks[c] = i.ciphertext, h.count++), h.count < h.total) return;
2798
+ l = {
2799
+ ...i,
2800
+ ciphertext: h.chunks.join("")
2801
+ }, delete this.chunkBuffers[o];
2802
+ }
2803
+ const f = await this.client.decryptAndVerify(l);
2804
+ this.distributeMessage(f);
2756
2805
  } catch (i) {
2757
2806
  console.warn("Failed to process notification:", i);
2758
2807
  }
@@ -2769,15 +2818,15 @@ class Ms {
2769
2818
  }
2770
2819
  }
2771
2820
  }
2772
- unsuscribe(e, t, r) {
2821
+ unsubscribe(e, t, r) {
2773
2822
  delete this.subscriptions[e][t][r];
2774
2823
  }
2775
2824
  unlisten(e) {
2776
2825
  delete this.listeners[e];
2777
2826
  }
2778
- suscribe(e, t, r, s) {
2827
+ subscribe(e, t, r, s) {
2779
2828
  let i = s;
2780
- return i == null && (i = this.generateRandomString(16)), this.subscriptions[e] || (this.subscriptions[e] = {}), this.subscriptions[e][t] || (this.subscriptions[e][t] = {}), this.subscriptions[e][t][i] = r, () => this.unsuscribe(e, t, i);
2829
+ return i == null && (i = this.generateRandomString(16)), this.subscriptions[e] || (this.subscriptions[e] = {}), this.subscriptions[e][t] || (this.subscriptions[e][t] = {}), this.subscriptions[e][t][i] = r, () => this.unsubscribe(e, t, i);
2781
2830
  }
2782
2831
  onMessage(e, t) {
2783
2832
  let r = t;
@@ -2788,16 +2837,16 @@ class Ms {
2788
2837
  (e = this.ws) == null || e.close(), this.ws = null;
2789
2838
  }
2790
2839
  }
2791
- const ct = "secure_api_session_v1";
2840
+ const at = "secure_api_session_v1";
2792
2841
  class Os {
2793
2842
  constructor(e) {
2794
- this.session = null, this.baseUrl = e.baseUrl, this.clientId = e.clientId, this.serverPublicKeyPem = e.serverPublicKeyPem, this.clientIdentityKeyPromise = $s(
2843
+ this.session = null, this.pagingBuffer = {}, this.baseUrl = e.baseUrl, this.clientId = e.clientId, this.serverPublicKeyPem = e.serverPublicKeyPem, this.clientIdentityKeyPromise = $s(
2795
2844
  e.clientIdentityPrivateKeyPem
2796
- ), this.loadPersistedSession(), this.notifications = new Ms(this);
2845
+ ), this.loadPersistedSession(), this.notifications = new ct(this), this.pagingBuffer = {};
2797
2846
  }
2798
2847
  loadPersistedSession() {
2799
2848
  try {
2800
- const e = localStorage.getItem(ct);
2849
+ const e = localStorage.getItem(at);
2801
2850
  if (!e) return;
2802
2851
  const t = JSON.parse(e);
2803
2852
  if (!t) return;
@@ -2836,16 +2885,16 @@ class Os {
2836
2885
  expiresAt: e.expiresAt,
2837
2886
  refreshToken: e.refreshToken
2838
2887
  } : {};
2839
- localStorage.setItem(ct, JSON.stringify(t));
2888
+ localStorage.setItem(at, JSON.stringify(t));
2840
2889
  } catch {
2841
2890
  }
2842
2891
  }
2843
2892
  async handshake() {
2844
- const e = await this.clientIdentityKeyPromise, t = Se.utils.randomSecretKey(), r = Se.getPublicKey(t), s = Vs(r), i = ne(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(
2845
2894
  { name: "ECDSA", hash: "SHA-256" },
2846
2895
  e,
2847
2896
  Ps(s)
2848
- ), c = Fs(new Uint8Array(o)), a = ne(c), u = await fetch(`${this.baseUrl}/handshake`, {
2897
+ ), c = Fs(new Uint8Array(o)), a = ce(c), l = await fetch(`${this.baseUrl}/handshake`, {
2849
2898
  method: "POST",
2850
2899
  headers: {
2851
2900
  "Content-Type": "application/json"
@@ -2858,29 +2907,29 @@ class Os {
2858
2907
  client_alg: "ES256"
2859
2908
  })
2860
2909
  });
2861
- if (!u.ok)
2862
- throw new Error(`Handshake failed: ${u.status} ${u.statusText}`);
2863
- const f = await u.json(), { session_id: h, server_pub: l, server_sig: g, session_expires_at: w } = f;
2864
- if (window.__akv = { server_pub: l, server_sig: g }, !h || !l || !g)
2910
+ if (!l.ok)
2911
+ throw new Error(`Handshake failed: ${l.status} ${l.statusText}`);
2912
+ const f = await l.json(), { session_id: h, server_pub: u, server_sig: g, session_expires_at: w } = f;
2913
+ if (window.__akv = { server_pub: u, server_sig: g }, !h || !u || !g)
2865
2914
  throw new Error("Handshake response missing fields");
2866
- const m = ie(l), b = ie(g);
2867
- if (!await Rs(
2915
+ const v = ae(u), y = ae(g);
2916
+ if (!await Ms(
2868
2917
  this.serverPublicKeyPem,
2869
- m,
2870
- b
2918
+ v,
2919
+ y
2871
2920
  ))
2872
2921
  throw new Error("Server signature verification failed");
2873
- const le = Ts(m), Be = Se.getSharedSecret(t, le), ye = new Uint8Array(0), ee = new TextEncoder().encode("health-api-v1"), J = await Cs(Be, ye, ee, 64), K = J.slice(0, 32), be = J.slice(32, 64), ue = 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(
2874
2923
  "raw",
2875
- K,
2924
+ W,
2876
2925
  "AES-GCM",
2877
2926
  !1,
2878
2927
  ["encrypt", "decrypt"]
2879
- ), te = await _s(be);
2928
+ ), ne = await Hs(be);
2880
2929
  this.updateSession({
2881
2930
  sessionId: h,
2882
- encKey: ue,
2883
- macKey: te,
2931
+ encKey: fe,
2932
+ macKey: ne,
2884
2933
  sessionExpiresAt: w
2885
2934
  });
2886
2935
  }
@@ -2913,50 +2962,84 @@ class Os {
2913
2962
  s
2914
2963
  );
2915
2964
  return {
2916
- ciphertextB64: ne(new Uint8Array(i)),
2917
- ivB64: ne(r)
2965
+ ciphertextB64: ce(new Uint8Array(i)),
2966
+ ivB64: ce(r)
2918
2967
  };
2919
2968
  }
2920
- async signRequest(e, t, r) {
2969
+ async signRequest(e, t, r, s) {
2921
2970
  await this.ensureSession();
2922
- const { sessionId: s, macKey: i } = this.session, o = e.toUpperCase() === "GET" ? "" : { data: Array.isArray(r) ? r : [r] }, { ciphertextB64: c, ivB64: a } = await this.encryptBody(o), u = Math.floor(Date.now() / 1e3).toString();
2923
- let f = t;
2924
- f.includes("?") && (f = f.split("?")[0]);
2925
- const h = `${e.toUpperCase()} ${f}
2926
- ${u}
2927
- ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers({
2928
- "X-Session-Id": s,
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}
2972
+ ${f}
2973
+ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers({
2974
+ ...s,
2975
+ "X-Session-Id": i,
2929
2976
  "X-Client-Id": this.clientId,
2930
- "X-Timestamp": u,
2931
- "X-Signature": g,
2977
+ "X-Timestamp": f,
2978
+ "X-Signature": w,
2932
2979
  "Content-Type": "application/json"
2933
2980
  });
2934
- return this.getUserId() && w.append("X-User-Id", this.getUserId()), this.getAccessToken() && !this.isTokenExpired() && w.append("Authorization", `Bearer ${this.getAccessToken()}`), {
2935
- headers: w,
2981
+ return this.getUserId() && v.append("X-User-Id", this.getUserId()), this.getAccessToken() && !this.isTokenExpired() && v.append("Authorization", `Bearer ${this.getAccessToken()}`), {
2982
+ headers: v,
2936
2983
  payload: {
2937
- content: c,
2938
- iv: a
2984
+ content: a,
2985
+ iv: l
2939
2986
  }
2940
2987
  };
2941
2988
  }
2942
- async get(e) {
2943
- const { headers: t } = await this.signRequest("GET", e, null), r = await fetch(`${this.baseUrl}${e}`, {
2989
+ async get(e, t, r) {
2990
+ const { headers: s } = await this.signRequest("GET", e, null, t), i = await fetch(`${this.baseUrl}${e}`, {
2944
2991
  method: "GET",
2945
- headers: t
2992
+ headers: s
2946
2993
  });
2947
- if (!r.ok)
2948
- throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);
2949
- return this.decryptAndVerify(await r.json());
2994
+ if (!i.ok)
2995
+ throw new Error(`GET ${e} failed: ${i.status} ${i.statusText}`);
2996
+ return r ? await i.json() : this.decryptAndVerify(await i.json());
2950
2997
  }
2951
- async post(e, t) {
2952
- const { headers: r, payload: s } = await this.signRequest("POST", e, t), i = await fetch(`${this.baseUrl}${e}`, {
2998
+ async post(e, t, r) {
2999
+ const { headers: s, payload: i } = await this.signRequest("POST", e, t, r), o = await fetch(`${this.baseUrl}${e}`, {
2953
3000
  method: "POST",
2954
- headers: r,
2955
- body: JSON.stringify(s)
3001
+ headers: s,
3002
+ body: JSON.stringify(i)
2956
3003
  });
2957
- if (!i.ok)
2958
- throw new Error(`POST ${e} failed: ${i.status} ${i.statusText}`);
2959
- return e.endsWith("/handshake") ? await i.json() : this.decryptAndVerify(await i.json());
3004
+ if (!o.ok)
3005
+ throw new Error(`POST ${e} failed: ${o.status} ${o.statusText}`);
3006
+ return e.endsWith("/handshake") ? await o.json() : this.decryptAndVerify(await o.json());
3007
+ }
3008
+ // --- Paging Methods ---
3009
+ async get_all_pages_async(e, t, r = {}) {
3010
+ const s = crypto.getRandomValues(new Uint8Array(10)), i = Array.from(s).join("-"), o = r ? { ...r, "X-Force-Sync": !1, "X-Request-Id": i } : { "X-Force-Sync": !1, "X-Request-Id": i };
3011
+ this.notifications.subscribe("request", i, async (c) => {
3012
+ const { data: a, ...l } = c;
3013
+ if (Object.keys(this.pagingBuffer).includes(i) || (this.pagingBuffer[i] = {
3014
+ pages: new Array(l.tot_pages),
3015
+ count: 0,
3016
+ total: l.tot_pages
3017
+ }), this.pagingBuffer[i].pages[l.page_num - 1] = l, this.pagingBuffer[i].count++, l.tot_pages > l.page_num && l.has_more && this.pagingBuffer[i].count < this.pagingBuffer[i].total) {
3018
+ let f = e.includes("?") ? "&" : "?";
3019
+ this.get(`${e}${f}page_num=${l.page_num + 1}`, o);
3020
+ return;
3021
+ }
3022
+ if (t) return t({
3023
+ tot_pages: l.tot_pages,
3024
+ page_num: l.tot_pages,
3025
+ has_more: !1,
3026
+ status: l.status,
3027
+ topic: l.topic,
3028
+ correlation_id: l.correlation_id,
3029
+ content_type: l.content_type,
3030
+ data: this.pagingBuffer[i].pages.map((f) => f.data).flat()
3031
+ });
3032
+ }), await this.get(e, o);
3033
+ }
3034
+ async get_all_pages_sync(e, t = {}) {
3035
+ const r = t ? { ...t, "X-Force-Sync": !0 } : { "X-Force-Sync": !0 };
3036
+ let s = await this.get(e, r);
3037
+ const i = [s];
3038
+ for (; s.tot_pages > s.page_num && s.has_more; ) {
3039
+ let o = e.includes("?") ? "&" : "?";
3040
+ s = await this.get(`${e}${o}page_num=${s.page_num + 1}`, { ...t, "X-Force-Sync": !0 }), i.push(s);
3041
+ }
3042
+ return i;
2960
3043
  }
2961
3044
  async ensureSession() {
2962
3045
  var t, r, s;
@@ -2978,18 +3061,18 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
2978
3061
  const { ciphertext: t, iv: r, signature: s, ...i } = e;
2979
3062
  if (!t || !r || !s)
2980
3063
  throw new Error("Malformed notification");
2981
- const { encKey: o, macKey: c } = this.getSession(), a = ie(s), u = await crypto.subtle.sign(
3064
+ const { encKey: o, macKey: c } = this.getSession(), a = ae(s), l = await crypto.subtle.sign(
2982
3065
  "HMAC",
2983
3066
  c,
2984
3067
  new TextEncoder().encode(t)
2985
3068
  );
2986
- if (!this.constantTimeEqual(a, new Uint8Array(u)))
3069
+ if (!this.constantTimeEqual(a, new Uint8Array(l)))
2987
3070
  throw new Error("Invalid notification signature");
2988
- const f = Uint8Array.from(ie(r)), h = Uint8Array.from(ie(t)), l = await crypto.subtle.decrypt(
3071
+ const f = Uint8Array.from(ae(r)), h = Uint8Array.from(ae(t)), u = await crypto.subtle.decrypt(
2989
3072
  { name: "AES-GCM", iv: f },
2990
3073
  o,
2991
3074
  h
2992
- ), g = new TextDecoder().decode(l);
3075
+ ), g = new TextDecoder().decode(u);
2993
3076
  return { ...JSON.parse(g), ...i };
2994
3077
  }
2995
3078
  constantTimeEqual(e, t) {
@@ -3023,6 +3106,14 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
3023
3106
  refreshToken: c
3024
3107
  };
3025
3108
  }
3109
+ async logout() {
3110
+ await this.post("/oauth/logout", {}), this.updateSession({
3111
+ accessToken: void 0,
3112
+ tokenType: void 0,
3113
+ expiresAt: void 0,
3114
+ refreshToken: void 0
3115
+ }), this.notifications = new ct(this), await this.handshake();
3116
+ }
3026
3117
  async refresh() {
3027
3118
  const e = this.getSession();
3028
3119
  if (!(e != null && e.refreshToken))
@@ -3068,14 +3159,14 @@ function Fs(n) {
3068
3159
  function s(f) {
3069
3160
  const h = r(f);
3070
3161
  if (h[0] & 128) {
3071
- const l = new Uint8Array(h.length + 1);
3072
- return l[0] = 0, l.set(h, 1), l;
3162
+ const u = new Uint8Array(h.length + 1);
3163
+ return u[0] = 0, u.set(h, 1), u;
3073
3164
  }
3074
3165
  return h;
3075
3166
  }
3076
3167
  const i = s(e), o = s(t), c = 2 + i.length + 2 + o.length, a = new Uint8Array(2 + c);
3077
- let u = 0;
3078
- return a[u++] = 48, a[u++] = c, a[u++] = 2, a[u++] = i.length, a.set(i, u), u += i.length, a[u++] = 2, a[u++] = o.length, a.set(o, u), a;
3168
+ let l = 0;
3169
+ return a[l++] = 48, a[l++] = c, a[l++] = 2, a[l++] = i.length, a.set(i, l), l += i.length, a[l++] = 2, a[l++] = o.length, a.set(o, l), a;
3079
3170
  }
3080
3171
  const js = Symbol("SDK_CLIENT"), Js = {
3081
3172
  install(n, e) {
@@ -3084,7 +3175,7 @@ const js = Symbol("SDK_CLIENT"), Js = {
3084
3175
  }
3085
3176
  };
3086
3177
  export {
3087
- Ms as Notifications,
3178
+ ct as Notifications,
3088
3179
  js as SDK_CLIENT,
3089
3180
  Js as SdkPlugin,
3090
3181
  Os as SecureApiClient