@vitia.ai/secure-api-client-vue 0.1.7 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +473 -467
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
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
3
|
function lt(n) {
|
|
4
4
|
return n instanceof Uint8Array || ArrayBuffer.isView(n) && n.constructor.name === "Uint8Array";
|
|
@@ -7,7 +7,7 @@ function Xr(n) {
|
|
|
7
7
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
8
8
|
throw new Error("positive integer expected, got " + n);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function Te(n, ...e) {
|
|
11
11
|
if (!lt(n))
|
|
12
12
|
throw new Error("Uint8Array expected");
|
|
13
13
|
if (e.length > 0 && !e.includes(n.length))
|
|
@@ -15,7 +15,7 @@ function Ve(n, ...e) {
|
|
|
15
15
|
}
|
|
16
16
|
const ut = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Zr = /* @__PURE__ */ Array.from({ length: 256 }, (n, e) => e.toString(16).padStart(2, "0"));
|
|
17
17
|
function ht(n) {
|
|
18
|
-
if (
|
|
18
|
+
if (Te(n), ut)
|
|
19
19
|
return n.toHex();
|
|
20
20
|
let e = "";
|
|
21
21
|
for (let t = 0; t < n.length; t++)
|
|
@@ -41,20 +41,20 @@ function ft(n) {
|
|
|
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)),
|
|
45
|
-
if (o === void 0 ||
|
|
46
|
-
const
|
|
47
|
-
throw new Error('hex string expected, got non-hex character "' +
|
|
44
|
+
const o = Ze(n.charCodeAt(i)), a = Ze(n.charCodeAt(i + 1));
|
|
45
|
+
if (o === void 0 || a === void 0) {
|
|
46
|
+
const c = n[i] + n[i + 1];
|
|
47
|
+
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + i);
|
|
48
48
|
}
|
|
49
|
-
r[s] = o * 16 +
|
|
49
|
+
r[s] = o * 16 + a;
|
|
50
50
|
}
|
|
51
51
|
return r;
|
|
52
52
|
}
|
|
53
53
|
function zr(n = 32) {
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
56
|
-
if (
|
|
57
|
-
return Uint8Array.from(
|
|
54
|
+
if (z && typeof z.getRandomValues == "function")
|
|
55
|
+
return z.getRandomValues(new Uint8Array(n));
|
|
56
|
+
if (z && typeof z.randomBytes == "function")
|
|
57
|
+
return Uint8Array.from(z.randomBytes(n));
|
|
58
58
|
throw new Error("crypto.getRandomValues must be defined");
|
|
59
59
|
}
|
|
60
60
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
@@ -67,8 +67,8 @@ function gt(n) {
|
|
|
67
67
|
function Yr(n) {
|
|
68
68
|
return gt(ht(n));
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
70
|
+
function Ee(n) {
|
|
71
|
+
return Te(n), gt(ht(Uint8Array.from(n).reverse()));
|
|
72
72
|
}
|
|
73
73
|
function wt(n, e) {
|
|
74
74
|
return ft(n.toString(16).padStart(e * 2, "0"));
|
|
@@ -106,17 +106,17 @@ 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) {
|
|
109
|
-
const
|
|
110
|
-
if (o &&
|
|
109
|
+
const a = n[s];
|
|
110
|
+
if (o && a === void 0)
|
|
111
111
|
return;
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
throw new Error(`param "${s}" is invalid: expected ${i}, got ${
|
|
112
|
+
const c = typeof a;
|
|
113
|
+
if (c !== i || a === null)
|
|
114
|
+
throw new Error(`param "${s}" is invalid: expected ${i}, got ${c}`);
|
|
115
115
|
}
|
|
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),
|
|
119
|
+
const x = BigInt(0), E = BigInt(1), G = /* @__PURE__ */ BigInt(2), Bt = /* @__PURE__ */ BigInt(3), bt = /* @__PURE__ */ BigInt(4), mt = /* @__PURE__ */ BigInt(5), rs = /* @__PURE__ */ BigInt(7), vt = /* @__PURE__ */ BigInt(8), ss = /* @__PURE__ */ BigInt(9), kt = /* @__PURE__ */ BigInt(16);
|
|
120
120
|
function I(n, e) {
|
|
121
121
|
const t = n % e;
|
|
122
122
|
return t >= x ? t : e + t;
|
|
@@ -132,44 +132,44 @@ function et(n, e) {
|
|
|
132
132
|
throw new Error("invert: expected non-zero number");
|
|
133
133
|
if (e <= x)
|
|
134
134
|
throw new Error("invert: expected positive modulus, got " + e);
|
|
135
|
-
let t = I(n, e), r = e, s = x, i =
|
|
135
|
+
let t = I(n, e), r = e, s = x, i = E;
|
|
136
136
|
for (; t !== x; ) {
|
|
137
|
-
const
|
|
138
|
-
r = t, t =
|
|
137
|
+
const a = r / t, c = r % t, l = s - i * a;
|
|
138
|
+
r = t, t = c, s = i, i = l;
|
|
139
139
|
}
|
|
140
|
-
if (r !==
|
|
140
|
+
if (r !== E)
|
|
141
141
|
throw new Error("invert: does not exist");
|
|
142
142
|
return I(s, e);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function Ve(n, e, t) {
|
|
145
145
|
if (!n.eql(n.sqr(e), t))
|
|
146
146
|
throw new Error("Cannot find square root");
|
|
147
147
|
}
|
|
148
148
|
function At(n, e) {
|
|
149
|
-
const t = (n.ORDER +
|
|
150
|
-
return
|
|
149
|
+
const t = (n.ORDER + E) / bt, r = n.pow(e, t);
|
|
150
|
+
return Ve(n, r, e), r;
|
|
151
151
|
}
|
|
152
152
|
function ns(n, e) {
|
|
153
|
-
const t = (n.ORDER -
|
|
154
|
-
return
|
|
153
|
+
const t = (n.ORDER - mt) / vt, r = n.mul(e, G), s = n.pow(r, t), i = n.mul(e, s), o = n.mul(n.mul(i, G), s), a = n.mul(i, n.sub(o, n.ONE));
|
|
154
|
+
return Ve(n, a, e), a;
|
|
155
155
|
}
|
|
156
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) /
|
|
158
|
-
return (
|
|
159
|
-
let l =
|
|
160
|
-
const h =
|
|
161
|
-
l =
|
|
162
|
-
const
|
|
163
|
-
return
|
|
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) / kt;
|
|
158
|
+
return (a, c) => {
|
|
159
|
+
let l = a.pow(c, o), f = a.mul(l, r);
|
|
160
|
+
const h = a.mul(l, s), u = a.mul(l, i), g = a.eql(a.sqr(f), c), w = a.eql(a.sqr(h), c);
|
|
161
|
+
l = a.cmov(l, f, g), f = a.cmov(u, h, w);
|
|
162
|
+
const m = a.eql(a.sqr(f), c), y = a.cmov(l, f, m);
|
|
163
|
+
return Ve(a, y, c), y;
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
function xt(n) {
|
|
167
167
|
if (n < Bt)
|
|
168
168
|
throw new Error("sqrt is not defined for small field");
|
|
169
|
-
let e = n -
|
|
170
|
-
for (; e %
|
|
171
|
-
e /=
|
|
172
|
-
let r =
|
|
169
|
+
let e = n - E, t = 0;
|
|
170
|
+
for (; e % G === x; )
|
|
171
|
+
e /= G, t++;
|
|
172
|
+
let r = G;
|
|
173
173
|
const s = _e(n);
|
|
174
174
|
for (; tt(s, r) === 1; )
|
|
175
175
|
if (r++ > 1e3)
|
|
@@ -177,47 +177,47 @@ function xt(n) {
|
|
|
177
177
|
if (t === 1)
|
|
178
178
|
return At;
|
|
179
179
|
let i = s.pow(r, e);
|
|
180
|
-
const o = (e +
|
|
181
|
-
return function(
|
|
182
|
-
if (
|
|
180
|
+
const o = (e + E) / G;
|
|
181
|
+
return function(c, l) {
|
|
182
|
+
if (c.is0(l))
|
|
183
183
|
return l;
|
|
184
|
-
if (tt(
|
|
184
|
+
if (tt(c, l) !== 1)
|
|
185
185
|
throw new Error("Cannot find square root");
|
|
186
|
-
let f = t, h =
|
|
187
|
-
for (; !
|
|
188
|
-
if (
|
|
189
|
-
return
|
|
190
|
-
let w = 1,
|
|
191
|
-
for (; !
|
|
192
|
-
if (w++,
|
|
186
|
+
let f = t, h = c.mul(c.ONE, i), u = c.pow(l, e), g = c.pow(l, o);
|
|
187
|
+
for (; !c.eql(u, c.ONE); ) {
|
|
188
|
+
if (c.is0(u))
|
|
189
|
+
return c.ZERO;
|
|
190
|
+
let w = 1, m = c.sqr(u);
|
|
191
|
+
for (; !c.eql(m, c.ONE); )
|
|
192
|
+
if (w++, m = c.sqr(m), w === f)
|
|
193
193
|
throw new Error("Cannot find square root");
|
|
194
|
-
const y =
|
|
195
|
-
f = w, h =
|
|
194
|
+
const y = E << BigInt(f - w - 1), C = c.pow(h, y);
|
|
195
|
+
f = w, h = c.sqr(C), u = c.mul(u, h), g = c.mul(g, C);
|
|
196
196
|
}
|
|
197
197
|
return g;
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
200
|
function os(n) {
|
|
201
|
-
return n % bt === Bt ? At : n %
|
|
201
|
+
return n % bt === Bt ? At : n % vt === mt ? ns : n % kt === ss ? is(n) : xt(n);
|
|
202
202
|
}
|
|
203
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)
|
|
207
207
|
return n.ONE;
|
|
208
|
-
if (t ===
|
|
208
|
+
if (t === E)
|
|
209
209
|
return e;
|
|
210
210
|
let r = n.ONE, s = e;
|
|
211
211
|
for (; t > x; )
|
|
212
|
-
t &
|
|
212
|
+
t & E && (r = n.mul(r, s)), s = n.sqr(s), t >>= E;
|
|
213
213
|
return r;
|
|
214
214
|
}
|
|
215
215
|
function as(n, e, t = !1) {
|
|
216
|
-
const r = new Array(e.length).fill(t ? n.ZERO : void 0), s = e.reduce((o,
|
|
217
|
-
return e.reduceRight((o,
|
|
216
|
+
const r = new Array(e.length).fill(t ? n.ZERO : void 0), s = e.reduce((o, a, c) => n.is0(a) ? o : (r[c] = o, n.mul(o, a)), n.ONE), i = n.inv(s);
|
|
217
|
+
return e.reduceRight((o, a, c) => n.is0(a) ? o : (r[c] = n.mul(o, r[c]), n.mul(o, a)), i), r;
|
|
218
218
|
}
|
|
219
219
|
function tt(n, e) {
|
|
220
|
-
const t = (n.ORDER -
|
|
220
|
+
const t = (n.ORDER - E) / G, 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;
|
|
@@ -230,27 +230,27 @@ function ls(n, e) {
|
|
|
230
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
|
-
let s, i, o = !1,
|
|
233
|
+
let s, i, o = !1, a;
|
|
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
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),
|
|
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), a = u.allowedLengths;
|
|
239
239
|
} else
|
|
240
240
|
typeof e == "number" && (s = e), r.sqrt && (i = r.sqrt);
|
|
241
|
-
const { nBitLength:
|
|
241
|
+
const { nBitLength: c, nByteLength: l } = ls(n, s);
|
|
242
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
|
-
BITS:
|
|
248
|
+
BITS: c,
|
|
249
249
|
BYTES: l,
|
|
250
|
-
MASK: es(
|
|
250
|
+
MASK: es(c),
|
|
251
251
|
ZERO: x,
|
|
252
|
-
ONE:
|
|
253
|
-
allowedLengths:
|
|
252
|
+
ONE: E,
|
|
253
|
+
allowedLengths: a,
|
|
254
254
|
create: (u) => I(u, n),
|
|
255
255
|
isValid: (u) => {
|
|
256
256
|
if (typeof u != "bigint")
|
|
@@ -260,7 +260,7 @@ function _e(n, e, t = !1, r = {}) {
|
|
|
260
260
|
is0: (u) => u === x,
|
|
261
261
|
// is valid and invertible
|
|
262
262
|
isValidNot0: (u) => !h.is0(u) && h.isValid(u),
|
|
263
|
-
isOdd: (u) => (u &
|
|
263
|
+
isOdd: (u) => (u & E) === E,
|
|
264
264
|
neg: (u) => I(-u, n),
|
|
265
265
|
eql: (u, g) => u === g,
|
|
266
266
|
sqr: (u) => I(u * u, n),
|
|
@@ -278,15 +278,15 @@ function _e(n, e, t = !1, r = {}) {
|
|
|
278
278
|
sqrt: i || ((u) => (f || (f = os(n)), f(h, u))),
|
|
279
279
|
toBytes: (u) => t ? yt(u, l) : wt(u, l),
|
|
280
280
|
fromBytes: (u, g = !0) => {
|
|
281
|
-
if (
|
|
282
|
-
if (!
|
|
283
|
-
throw new Error("Field.fromBytes: expected " +
|
|
284
|
-
const
|
|
285
|
-
|
|
281
|
+
if (a) {
|
|
282
|
+
if (!a.includes(u.length) || u.length > l)
|
|
283
|
+
throw new Error("Field.fromBytes: expected " + a + " bytes, got " + u.length);
|
|
284
|
+
const m = new Uint8Array(l);
|
|
285
|
+
m.set(u, t ? 0 : m.length - u.length), u = m;
|
|
286
286
|
}
|
|
287
287
|
if (u.length !== l)
|
|
288
288
|
throw new Error("Field.fromBytes: expected " + l + " bytes, got " + u.length);
|
|
289
|
-
let w = t ?
|
|
289
|
+
let w = t ? Ee(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;
|
|
@@ -300,7 +300,7 @@ function _e(n, e, t = !1, r = {}) {
|
|
|
300
300
|
return Object.freeze(h);
|
|
301
301
|
}
|
|
302
302
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
303
|
-
const ie = BigInt(0),
|
|
303
|
+
const ie = BigInt(0), Y = BigInt(1), ge = BigInt(2);
|
|
304
304
|
function us(n) {
|
|
305
305
|
return ts(n, {
|
|
306
306
|
adjustScalarBytes: "function",
|
|
@@ -308,67 +308,67 @@ function us(n) {
|
|
|
308
308
|
}), Object.freeze({ ...n });
|
|
309
309
|
}
|
|
310
310
|
function hs(n) {
|
|
311
|
-
const e = us(n), { P: t, type: r, adjustScalarBytes: s, powPminus2: i, randomBytes: o } = e,
|
|
312
|
-
if (!
|
|
311
|
+
const e = us(n), { P: t, type: r, adjustScalarBytes: s, powPminus2: i, randomBytes: o } = e, a = r === "x25519";
|
|
312
|
+
if (!a && r !== "x448")
|
|
313
313
|
throw new Error("invalid type");
|
|
314
|
-
const
|
|
315
|
-
function
|
|
314
|
+
const c = o || zr, l = a ? 255 : 448, f = a ? 32 : 56, h = BigInt(a ? 9 : 5), u = BigInt(a ? 121665 : 39081), g = a ? ge ** BigInt(254) : ge ** BigInt(447), w = a ? BigInt(8) * ge ** BigInt(251) - Y : BigInt(4) * ge ** BigInt(445) - Y, m = g + w + Y, y = (b) => I(b, t), C = X(h);
|
|
315
|
+
function X(b) {
|
|
316
316
|
return yt(y(b), f);
|
|
317
317
|
}
|
|
318
|
-
function te(b) {
|
|
319
|
-
const m = Ye("u coordinate", b, f);
|
|
320
|
-
return c && (m[31] &= 127), y(pe(m));
|
|
321
|
-
}
|
|
322
318
|
function re(b) {
|
|
323
|
-
|
|
319
|
+
const k = Ye("u coordinate", b, f);
|
|
320
|
+
return a && (k[31] &= 127), y(Ee(k));
|
|
321
|
+
}
|
|
322
|
+
function se(b) {
|
|
323
|
+
return Ee(s(Ye("scalar", b, f)));
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
const H = be(
|
|
325
|
+
function T(b, k) {
|
|
326
|
+
const H = be(re(k), se(b));
|
|
327
327
|
if (H === ie)
|
|
328
328
|
throw new Error("invalid private or public key received");
|
|
329
|
-
return
|
|
329
|
+
return X(H);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
return
|
|
331
|
+
function O(b) {
|
|
332
|
+
return T(b, C);
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
const de = y(b * (
|
|
336
|
-
return
|
|
334
|
+
function D(b, k, H) {
|
|
335
|
+
const de = y(b * (k - H));
|
|
336
|
+
return k = y(k - de), H = y(H + de), { x_2: k, x_3: H };
|
|
337
337
|
}
|
|
338
|
-
function be(b,
|
|
339
|
-
Qe("u", b, ie, t), Qe("scalar",
|
|
340
|
-
const H =
|
|
341
|
-
let
|
|
342
|
-
for (let
|
|
343
|
-
const je = H >>
|
|
344
|
-
|
|
345
|
-
const
|
|
346
|
-
|
|
338
|
+
function be(b, k) {
|
|
339
|
+
Qe("u", b, ie, t), Qe("scalar", k, g, m);
|
|
340
|
+
const H = k, de = b;
|
|
341
|
+
let $ = Y, P = ie, j = b, q = Y, Z = ie;
|
|
342
|
+
for (let me = BigInt(l - 1); me >= ie; me--) {
|
|
343
|
+
const je = H >> me & Y;
|
|
344
|
+
Z ^= je, { x_2: $, x_3: j } = D(Z, $, j), { x_2: P, x_3: q } = D(Z, P, q), Z = je;
|
|
345
|
+
const ve = $ + P, ke = y(ve * ve), Ae = $ - P, qe = y(Ae * Ae), Ge = ke - qe, Kr = j + q, Wr = j - q, Je = y(Wr * ve), Ke = y(Kr * Ae), We = Je + Ke, Xe = Je - Ke;
|
|
346
|
+
j = y(We * We), q = y(de * y(Xe * Xe)), $ = y(ke * qe), P = y(Ge * (ke + y(u * Ge)));
|
|
347
347
|
}
|
|
348
|
-
({ x_2:
|
|
349
|
-
const Jr = i(
|
|
350
|
-
return y(
|
|
348
|
+
({ x_2: $, x_3: j } = D(Z, $, j)), { x_2: P, x_3: q } = D(Z, P, q);
|
|
349
|
+
const Jr = i(P);
|
|
350
|
+
return y($ * Jr);
|
|
351
351
|
}
|
|
352
352
|
const fe = {
|
|
353
353
|
secretKey: f,
|
|
354
354
|
publicKey: f,
|
|
355
355
|
seed: f
|
|
356
|
-
}, ne = (b =
|
|
356
|
+
}, ne = (b = c(f)) => (Te(b, fe.seed), b);
|
|
357
357
|
function Gr(b) {
|
|
358
|
-
const
|
|
359
|
-
return { secretKey:
|
|
358
|
+
const k = ne(b);
|
|
359
|
+
return { secretKey: k, publicKey: O(k) };
|
|
360
360
|
}
|
|
361
361
|
return {
|
|
362
362
|
keygen: Gr,
|
|
363
|
-
getSharedSecret: (b,
|
|
364
|
-
getPublicKey: (b) =>
|
|
365
|
-
scalarMult:
|
|
366
|
-
scalarMultBase:
|
|
363
|
+
getSharedSecret: (b, k) => T(b, k),
|
|
364
|
+
getPublicKey: (b) => O(b),
|
|
365
|
+
scalarMult: T,
|
|
366
|
+
scalarMultBase: O,
|
|
367
367
|
utils: {
|
|
368
368
|
randomSecretKey: ne,
|
|
369
369
|
randomPrivateKey: ne
|
|
370
370
|
},
|
|
371
|
-
GuBytes:
|
|
371
|
+
GuBytes: C.slice(),
|
|
372
372
|
lengths: fe
|
|
373
373
|
};
|
|
374
374
|
}
|
|
@@ -383,14 +383,14 @@ const fs = BigInt(1), rt = BigInt(2), ds = BigInt(3), gs = BigInt(5), ws = BigIn
|
|
|
383
383
|
Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
|
|
384
384
|
};
|
|
385
385
|
function Bs(n) {
|
|
386
|
-
const e = BigInt(10), t = BigInt(20), r = BigInt(40), s = BigInt(80), i = St,
|
|
387
|
-
return { pow_p_5_8: U(y, rt, i) * n % i, b2:
|
|
386
|
+
const e = BigInt(10), t = BigInt(20), r = BigInt(40), s = BigInt(80), i = St, a = n * n % i * n % i, c = U(a, rt, i) * a % i, l = U(c, 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, m = U(w, s, i) * g % i, y = U(m, e, i) * f % i;
|
|
387
|
+
return { pow_p_5_8: U(y, rt, i) * n % i, b2: a };
|
|
388
388
|
}
|
|
389
389
|
function bs(n) {
|
|
390
390
|
return n[0] &= 248, n[31] &= 127, n[31] |= 64, n;
|
|
391
391
|
}
|
|
392
|
-
const
|
|
393
|
-
const n =
|
|
392
|
+
const ms = _e(ys.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
|
|
393
|
+
const n = ms.ORDER;
|
|
394
394
|
return hs({
|
|
395
395
|
P: n,
|
|
396
396
|
type: "x25519",
|
|
@@ -425,10 +425,10 @@ const vs = _e(ys.p, { isLE: !0 }), Se = /* @__PURE__ */ (() => {
|
|
|
425
425
|
* SOFTWARE.
|
|
426
426
|
*
|
|
427
427
|
*/
|
|
428
|
-
const
|
|
428
|
+
const vs = "[object ArrayBuffer]";
|
|
429
429
|
class B {
|
|
430
430
|
static isArrayBuffer(e) {
|
|
431
|
-
return Object.prototype.toString.call(e) ===
|
|
431
|
+
return Object.prototype.toString.call(e) === vs;
|
|
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;
|
|
@@ -469,13 +469,13 @@ class B {
|
|
|
469
469
|
const s = new Uint8Array(r);
|
|
470
470
|
let i = 0;
|
|
471
471
|
for (const o of t) {
|
|
472
|
-
const
|
|
473
|
-
s.set(
|
|
472
|
+
const a = this.toUint8Array(o);
|
|
473
|
+
s.set(a, i), i += a.length;
|
|
474
474
|
}
|
|
475
475
|
return e[e.length - 1] instanceof Function ? this.toView(s, e[e.length - 1]) : s.buffer;
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
const
|
|
478
|
+
const pe = "string", ks = /^[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);
|
|
@@ -496,8 +496,8 @@ class V {
|
|
|
496
496
|
const r = B.toArrayBuffer(e), s = new DataView(r);
|
|
497
497
|
let i = "";
|
|
498
498
|
for (let o = 0; o < r.byteLength; o += 2) {
|
|
499
|
-
const
|
|
500
|
-
i += String.fromCharCode(
|
|
499
|
+
const a = s.getUint16(o, t);
|
|
500
|
+
i += String.fromCharCode(a);
|
|
501
501
|
}
|
|
502
502
|
return i;
|
|
503
503
|
}
|
|
@@ -508,15 +508,15 @@ class V {
|
|
|
508
508
|
return r;
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
class
|
|
511
|
+
class v {
|
|
512
512
|
static isHex(e) {
|
|
513
|
-
return typeof e ===
|
|
513
|
+
return typeof e === pe && ks.test(e);
|
|
514
514
|
}
|
|
515
515
|
static isBase64(e) {
|
|
516
|
-
return typeof e ===
|
|
516
|
+
return typeof e === pe && As.test(e);
|
|
517
517
|
}
|
|
518
518
|
static isBase64Url(e) {
|
|
519
|
-
return typeof e ===
|
|
519
|
+
return typeof e === pe && xs.test(e);
|
|
520
520
|
}
|
|
521
521
|
static ToString(e, t = "utf8") {
|
|
522
522
|
const r = B.toUint8Array(e);
|
|
@@ -575,7 +575,7 @@ class k {
|
|
|
575
575
|
const t = this.formatString(e);
|
|
576
576
|
if (!t)
|
|
577
577
|
return new ArrayBuffer(0);
|
|
578
|
-
if (!
|
|
578
|
+
if (!v.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 k {
|
|
|
583
583
|
const t = this.formatString(e);
|
|
584
584
|
if (!t)
|
|
585
585
|
return new ArrayBuffer(0);
|
|
586
|
-
if (!
|
|
586
|
+
if (!v.isBase64Url(t))
|
|
587
587
|
throw new TypeError("Argument 'base64url' is not Base64Url encoded");
|
|
588
588
|
return this.FromBase64(this.Base64Padding(t.replace(/\-/g, "+").replace(/\_/g, "/")));
|
|
589
589
|
}
|
|
590
590
|
static ToBase64Url(e) {
|
|
591
591
|
return this.ToBase64(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
|
|
592
592
|
}
|
|
593
|
-
static FromUtf8String(e, t =
|
|
593
|
+
static FromUtf8String(e, t = v.DEFAULT_UTF8_ENCODING) {
|
|
594
594
|
switch (t) {
|
|
595
595
|
case "ascii":
|
|
596
596
|
return this.FromBinary(e);
|
|
@@ -606,7 +606,7 @@ class k {
|
|
|
606
606
|
throw new Error(`Unknown type of encoding '${t}'`);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
static ToUtf8String(e, t =
|
|
609
|
+
static ToUtf8String(e, t = v.DEFAULT_UTF8_ENCODING) {
|
|
610
610
|
switch (t) {
|
|
611
611
|
case "ascii":
|
|
612
612
|
return this.ToBinary(e);
|
|
@@ -649,7 +649,7 @@ class k {
|
|
|
649
649
|
let t = this.formatString(e);
|
|
650
650
|
if (!t)
|
|
651
651
|
return new ArrayBuffer(0);
|
|
652
|
-
if (!
|
|
652
|
+
if (!v.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 k {
|
|
|
676
676
|
return (e == null ? void 0 : e.replace(/[\n\r\t ]/g, "")) || "";
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
|
|
679
|
+
v.DEFAULT_UTF8_ENCODING = "utf8";
|
|
680
680
|
/*!
|
|
681
681
|
Copyright (c) Peculiar Ventures, LLC
|
|
682
682
|
*/
|
|
683
|
-
function
|
|
683
|
+
function Q(n, e) {
|
|
684
684
|
let t = 0;
|
|
685
685
|
if (n.length === 1)
|
|
686
686
|
return n[0];
|
|
@@ -688,25 +688,25 @@ function Y(n, e) {
|
|
|
688
688
|
t += n[n.length - 1 - r] * Math.pow(2, e * r);
|
|
689
689
|
return t;
|
|
690
690
|
}
|
|
691
|
-
function
|
|
691
|
+
function J(n, e, t = -1) {
|
|
692
692
|
const r = t;
|
|
693
693
|
let s = n, i = 0, o = Math.pow(2, e);
|
|
694
|
-
for (let
|
|
694
|
+
for (let a = 1; a < 8; a++) {
|
|
695
695
|
if (n < o) {
|
|
696
|
-
let
|
|
696
|
+
let c;
|
|
697
697
|
if (r < 0)
|
|
698
|
-
|
|
698
|
+
c = new ArrayBuffer(a), i = a;
|
|
699
699
|
else {
|
|
700
|
-
if (r <
|
|
700
|
+
if (r < a)
|
|
701
701
|
return new ArrayBuffer(0);
|
|
702
|
-
|
|
702
|
+
c = new ArrayBuffer(r), i = r;
|
|
703
703
|
}
|
|
704
|
-
const l = new Uint8Array(
|
|
705
|
-
for (let f =
|
|
704
|
+
const l = new Uint8Array(c);
|
|
705
|
+
for (let f = a - 1; f >= 0; f--) {
|
|
706
706
|
const h = Math.pow(2, f * e);
|
|
707
707
|
l[i - f - 1] = Math.floor(s / h), s -= l[i - f - 1] * h;
|
|
708
708
|
}
|
|
709
|
-
return
|
|
709
|
+
return c;
|
|
710
710
|
}
|
|
711
711
|
o *= Math.pow(2, e);
|
|
712
712
|
}
|
|
@@ -721,20 +721,20 @@ function Ne(...n) {
|
|
|
721
721
|
s.set(i, t), t += i.length;
|
|
722
722
|
return s;
|
|
723
723
|
}
|
|
724
|
-
function
|
|
724
|
+
function pt() {
|
|
725
725
|
const n = new Uint8Array(this.valueHex);
|
|
726
726
|
if (this.valueHex.byteLength >= 2) {
|
|
727
|
-
const
|
|
728
|
-
(
|
|
727
|
+
const a = n[0] === 255 && n[1] & 128, c = n[0] === 0 && (n[1] & 128) === 0;
|
|
728
|
+
(a || c) && this.warnings.push("Needlessly long format");
|
|
729
729
|
}
|
|
730
730
|
const e = new ArrayBuffer(this.valueHex.byteLength), t = new Uint8Array(e);
|
|
731
|
-
for (let
|
|
732
|
-
t[
|
|
731
|
+
for (let a = 0; a < this.valueHex.byteLength; a++)
|
|
732
|
+
t[a] = 0;
|
|
733
733
|
t[0] = n[0] & 128;
|
|
734
|
-
const r =
|
|
735
|
-
for (let
|
|
736
|
-
i[
|
|
737
|
-
return i[0] &= 127,
|
|
734
|
+
const r = Q(t, 8), s = new ArrayBuffer(this.valueHex.byteLength), i = new Uint8Array(s);
|
|
735
|
+
for (let a = 0; a < this.valueHex.byteLength; a++)
|
|
736
|
+
i[a] = n[a];
|
|
737
|
+
return i[0] &= 127, Q(i, 8) - r;
|
|
738
738
|
}
|
|
739
739
|
function Ss(n) {
|
|
740
740
|
const e = n < 0 ? n * -1 : n;
|
|
@@ -742,15 +742,15 @@ function Ss(n) {
|
|
|
742
742
|
for (let r = 1; r < 8; r++) {
|
|
743
743
|
if (e <= t) {
|
|
744
744
|
if (n < 0) {
|
|
745
|
-
const o = t - e,
|
|
746
|
-
return
|
|
745
|
+
const o = t - e, a = J(o, 8, r), c = new Uint8Array(a);
|
|
746
|
+
return c[0] |= 128, a;
|
|
747
747
|
}
|
|
748
|
-
let s =
|
|
748
|
+
let s = J(e, 8, r), i = new Uint8Array(s);
|
|
749
749
|
if (i[0] & 128) {
|
|
750
|
-
const o = s.slice(0),
|
|
750
|
+
const o = s.slice(0), a = new Uint8Array(o);
|
|
751
751
|
s = new ArrayBuffer(s.byteLength + 1), i = new Uint8Array(s);
|
|
752
|
-
for (let
|
|
753
|
-
i[
|
|
752
|
+
for (let c = 0; c < o.byteLength; c++)
|
|
753
|
+
i[c + 1] = a[c];
|
|
754
754
|
i[0] = 0;
|
|
755
755
|
}
|
|
756
756
|
return s;
|
|
@@ -759,7 +759,7 @@ function Ss(n) {
|
|
|
759
759
|
}
|
|
760
760
|
return new ArrayBuffer(0);
|
|
761
761
|
}
|
|
762
|
-
function
|
|
762
|
+
function ps(n, e) {
|
|
763
763
|
if (n.byteLength !== e.byteLength)
|
|
764
764
|
return !1;
|
|
765
765
|
const t = new Uint8Array(n), r = new Uint8Array(e);
|
|
@@ -768,7 +768,7 @@ function Es(n, e) {
|
|
|
768
768
|
return !1;
|
|
769
769
|
return !0;
|
|
770
770
|
}
|
|
771
|
-
function
|
|
771
|
+
function p(n, e) {
|
|
772
772
|
const t = n.toString(10);
|
|
773
773
|
if (e < t.length)
|
|
774
774
|
return "";
|
|
@@ -841,7 +841,7 @@ class He {
|
|
|
841
841
|
return Ce(this.items);
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
|
-
const oe = [new Uint8Array([1])], nt = "0123456789",
|
|
844
|
+
const oe = [new Uint8Array([1])], nt = "0123456789", ee = "", _ = new ArrayBuffer(0), Le = new Uint8Array(0), he = "EndOfContent", Et = "OCTET STRING", Nt = "BIT STRING";
|
|
845
845
|
function M(n) {
|
|
846
846
|
var e;
|
|
847
847
|
return e = class extends n {
|
|
@@ -861,22 +861,22 @@ function M(n) {
|
|
|
861
861
|
const o = r instanceof ArrayBuffer ? new Uint8Array(r) : r;
|
|
862
862
|
if (!R(this, o, s, i))
|
|
863
863
|
return -1;
|
|
864
|
-
const
|
|
865
|
-
return this.valueHexView = o.subarray(s,
|
|
864
|
+
const a = s + i;
|
|
865
|
+
return this.valueHexView = o.subarray(s, a), this.valueHexView.length ? (this.blockLength = i, a) : (this.warnings.push("Zero buffer length"), s);
|
|
866
866
|
}
|
|
867
867
|
toBER(r = !1) {
|
|
868
|
-
return this.isHexOnly ? r ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.byteLength === this.valueHexView.buffer.byteLength ? this.valueHexView.buffer : this.valueHexView.slice().buffer : (this.error = "Flag 'isHexOnly' is not set, abort",
|
|
868
|
+
return this.isHexOnly ? r ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.byteLength === this.valueHexView.buffer.byteLength ? this.valueHexView.buffer : this.valueHexView.slice().buffer : (this.error = "Flag 'isHexOnly' is not set, abort", _);
|
|
869
869
|
}
|
|
870
870
|
toJSON() {
|
|
871
871
|
return {
|
|
872
872
|
...super.toJSON(),
|
|
873
873
|
isHexOnly: this.isHexOnly,
|
|
874
|
-
valueHex:
|
|
874
|
+
valueHex: v.ToHex(this.valueHexView)
|
|
875
875
|
};
|
|
876
876
|
}
|
|
877
877
|
}, e.NAME = "hexBlock", e;
|
|
878
878
|
}
|
|
879
|
-
class
|
|
879
|
+
class K {
|
|
880
880
|
static blockName() {
|
|
881
881
|
return this.NAME;
|
|
882
882
|
}
|
|
@@ -886,7 +886,7 @@ class G {
|
|
|
886
886
|
set valueBeforeDecode(e) {
|
|
887
887
|
this.valueBeforeDecodeView = new Uint8Array(e);
|
|
888
888
|
}
|
|
889
|
-
constructor({ blockLength: e = 0, error: t =
|
|
889
|
+
constructor({ blockLength: e = 0, error: t = ee, 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 G {
|
|
|
895
895
|
blockLength: this.blockLength,
|
|
896
896
|
error: this.error,
|
|
897
897
|
warnings: this.warnings,
|
|
898
|
-
valueBeforeDecode:
|
|
898
|
+
valueBeforeDecode: v.ToHex(this.valueBeforeDecodeView)
|
|
899
899
|
};
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
|
-
|
|
903
|
-
class S extends
|
|
902
|
+
K.NAME = "baseBlock";
|
|
903
|
+
class S extends K {
|
|
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 G {
|
|
|
909
909
|
}
|
|
910
910
|
}
|
|
911
911
|
S.NAME = "valueBlock";
|
|
912
|
-
class It extends M(
|
|
912
|
+
class It extends M(K) {
|
|
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);
|
|
@@ -930,7 +930,7 @@ class It extends M(G) {
|
|
|
930
930
|
t |= 192;
|
|
931
931
|
break;
|
|
932
932
|
default:
|
|
933
|
-
return this.error = "Unknown tag class",
|
|
933
|
+
return this.error = "Unknown tag class", _;
|
|
934
934
|
}
|
|
935
935
|
if (this.isConstructed && (t |= 32), this.tagNumber < 31 && !this.isHexOnly) {
|
|
936
936
|
const s = new Uint8Array(1);
|
|
@@ -941,13 +941,13 @@ class It extends M(G) {
|
|
|
941
941
|
return s.buffer;
|
|
942
942
|
}
|
|
943
943
|
if (!this.isHexOnly) {
|
|
944
|
-
const s =
|
|
945
|
-
if (
|
|
946
|
-
for (let
|
|
947
|
-
c
|
|
948
|
-
|
|
944
|
+
const s = J(this.tagNumber, 7), i = new Uint8Array(s), o = s.byteLength, a = new Uint8Array(o + 1);
|
|
945
|
+
if (a[0] = t | 31, !e) {
|
|
946
|
+
for (let c = 0; c < o - 1; c++)
|
|
947
|
+
a[c + 1] = i[c] | 128;
|
|
948
|
+
a[o] = i[o - 1];
|
|
949
949
|
}
|
|
950
|
-
return
|
|
950
|
+
return a.buffer;
|
|
951
951
|
}
|
|
952
952
|
const r = new Uint8Array(this.valueHexView.byteLength + 1);
|
|
953
953
|
if (r[0] = t | 31, !e) {
|
|
@@ -982,15 +982,15 @@ class It extends M(G) {
|
|
|
982
982
|
return this.error = "Unknown tag class", -1;
|
|
983
983
|
}
|
|
984
984
|
this.isConstructed = (i[0] & 32) === 32, this.isHexOnly = !1;
|
|
985
|
-
const
|
|
986
|
-
if (
|
|
987
|
-
this.tagNumber =
|
|
985
|
+
const a = i[0] & 31;
|
|
986
|
+
if (a !== 31)
|
|
987
|
+
this.tagNumber = a, this.blockLength = 1;
|
|
988
988
|
else {
|
|
989
|
-
let
|
|
990
|
-
for (; i[
|
|
991
|
-
if (l[
|
|
989
|
+
let c = 1, l = this.valueHexView = new Uint8Array(255), f = 255;
|
|
990
|
+
for (; i[c] & 128; ) {
|
|
991
|
+
if (l[c - 1] = i[c] & 127, c++, c >= i.length)
|
|
992
992
|
return this.error = "End of input reached before message was fully decoded", -1;
|
|
993
|
-
if (
|
|
993
|
+
if (c === f) {
|
|
994
994
|
f += 255;
|
|
995
995
|
const u = new Uint8Array(f);
|
|
996
996
|
for (let g = 0; g < l.length; g++)
|
|
@@ -998,11 +998,11 @@ class It extends M(G) {
|
|
|
998
998
|
l = this.valueHexView = new Uint8Array(f);
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
|
-
this.blockLength =
|
|
1002
|
-
const h = new Uint8Array(
|
|
1003
|
-
for (let u = 0; u <
|
|
1001
|
+
this.blockLength = c + 1, l[c - 1] = i[c] & 127;
|
|
1002
|
+
const h = new Uint8Array(c);
|
|
1003
|
+
for (let u = 0; u < c; u++)
|
|
1004
1004
|
h[u] = l[u];
|
|
1005
|
-
l = this.valueHexView = new Uint8Array(
|
|
1005
|
+
l = this.valueHexView = new Uint8Array(c), l.set(h), this.blockLength <= 9 ? this.tagNumber = Q(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) {
|
|
@@ -1033,7 +1033,7 @@ class It extends M(G) {
|
|
|
1033
1033
|
}
|
|
1034
1034
|
}
|
|
1035
1035
|
It.NAME = "identificationBlock";
|
|
1036
|
-
class Ut extends
|
|
1036
|
+
class Ut extends K {
|
|
1037
1037
|
constructor({ lenBlock: e = {} } = {}) {
|
|
1038
1038
|
var t, r, s;
|
|
1039
1039
|
super(), this.isIndefiniteForm = (t = e.isIndefiniteForm) !== null && t !== void 0 ? t : !1, this.longFormUsed = (r = e.longFormUsed) !== null && r !== void 0 ? r : !1, this.length = (s = e.length) !== null && s !== void 0 ? s : 0;
|
|
@@ -1056,17 +1056,17 @@ class Ut extends G {
|
|
|
1056
1056
|
return this.error = "Too big integer", -1;
|
|
1057
1057
|
if (o + 1 > i.length)
|
|
1058
1058
|
return this.error = "End of input reached before message was fully decoded", -1;
|
|
1059
|
-
const
|
|
1060
|
-
return
|
|
1059
|
+
const a = t + 1, c = s.subarray(a, a + o);
|
|
1060
|
+
return c[o - 1] === 0 && this.warnings.push("Needlessly long encoded length"), this.length = Q(c, 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 =
|
|
1067
|
+
const s = J(this.length, 8);
|
|
1068
1068
|
if (s.byteLength > 127)
|
|
1069
|
-
return this.error = "Too big length",
|
|
1069
|
+
return this.error = "Too big length", _;
|
|
1070
1070
|
if (t = new ArrayBuffer(s.byteLength + 1), e)
|
|
1071
1071
|
return t;
|
|
1072
1072
|
const i = new Uint8Array(s);
|
|
@@ -1088,8 +1088,8 @@ class Ut extends G {
|
|
|
1088
1088
|
}
|
|
1089
1089
|
Ut.NAME = "lengthBlock";
|
|
1090
1090
|
const d = {};
|
|
1091
|
-
class A extends
|
|
1092
|
-
constructor({ name: e =
|
|
1091
|
+
class A extends K {
|
|
1092
|
+
constructor({ name: e = ee, optional: t = !1, primitiveSchema: r, ...s } = {}, i) {
|
|
1093
1093
|
super(s), this.name = e, this.optional = t, r && (this.primitiveSchema = r), this.idBlock = new It(s), this.lenBlock = new Ut(s), this.valueBlock = i ? new i(s) : new S(s);
|
|
1094
1094
|
}
|
|
1095
1095
|
fromBER(e, t, r) {
|
|
@@ -1098,7 +1098,7 @@ class A extends G {
|
|
|
1098
1098
|
}
|
|
1099
1099
|
toBER(e, t) {
|
|
1100
1100
|
const r = t || new He();
|
|
1101
|
-
t ||
|
|
1101
|
+
t || Tt(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));
|
|
@@ -1108,7 +1108,7 @@ class A extends G {
|
|
|
1108
1108
|
const o = this.lenBlock.toBER(e);
|
|
1109
1109
|
r.write(o), r.write(i);
|
|
1110
1110
|
}
|
|
1111
|
-
return t ?
|
|
1111
|
+
return t ? _ : r.final();
|
|
1112
1112
|
}
|
|
1113
1113
|
toJSON() {
|
|
1114
1114
|
const e = {
|
|
@@ -1122,10 +1122,10 @@ class A extends G {
|
|
|
1122
1122
|
return this.primitiveSchema && (e.primitiveSchema = this.primitiveSchema.toJSON()), e;
|
|
1123
1123
|
}
|
|
1124
1124
|
toString(e = "ascii") {
|
|
1125
|
-
return e === "ascii" ? this.onAsciiEncoding() :
|
|
1125
|
+
return e === "ascii" ? this.onAsciiEncoding() : v.ToHex(this.toBER());
|
|
1126
1126
|
}
|
|
1127
1127
|
onAsciiEncoding() {
|
|
1128
|
-
const e = this.constructor.NAME, t =
|
|
1128
|
+
const e = this.constructor.NAME, t = v.ToHex(this.valueBlock.valueBeforeDecodeView);
|
|
1129
1129
|
return `${e} : ${t}`;
|
|
1130
1130
|
}
|
|
1131
1131
|
isEqual(e) {
|
|
@@ -1134,25 +1134,25 @@ class A extends G {
|
|
|
1134
1134
|
if (!(e instanceof this.constructor))
|
|
1135
1135
|
return !1;
|
|
1136
1136
|
const t = this.toBER(), r = e.toBER();
|
|
1137
|
-
return
|
|
1137
|
+
return ps(t, r);
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
1140
|
A.NAME = "BaseBlock";
|
|
1141
|
-
function
|
|
1141
|
+
function Tt(n) {
|
|
1142
1142
|
var e;
|
|
1143
1143
|
if (n instanceof d.Constructed)
|
|
1144
1144
|
for (const t of n.valueBlock.value)
|
|
1145
|
-
|
|
1145
|
+
Tt(t) && (n.lenBlock.isIndefiniteForm = !0);
|
|
1146
1146
|
return !!(!((e = n.lenBlock) === null || e === void 0) && e.isIndefiniteForm);
|
|
1147
1147
|
}
|
|
1148
|
-
class
|
|
1148
|
+
class Vt 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 =
|
|
1155
|
+
constructor({ value: e = ee, ...t } = {}, r) {
|
|
1156
1156
|
super(t, r), e && this.fromString(e);
|
|
1157
1157
|
}
|
|
1158
1158
|
fromBER(e, t, r) {
|
|
@@ -1163,7 +1163,7 @@ class Tt extends A {
|
|
|
1163
1163
|
return `${this.constructor.NAME} : '${this.valueBlock.value}'`;
|
|
1164
1164
|
}
|
|
1165
1165
|
}
|
|
1166
|
-
|
|
1166
|
+
Vt.NAME = "BaseStringBlock";
|
|
1167
1167
|
class _t extends M(S) {
|
|
1168
1168
|
constructor({ isHexOnly: e = !0, ...t } = {}) {
|
|
1169
1169
|
super(t), this.isHexOnly = e;
|
|
@@ -1179,7 +1179,7 @@ class Ht extends A {
|
|
|
1179
1179
|
Ct = Ht;
|
|
1180
1180
|
d.Primitive = Ct;
|
|
1181
1181
|
Ht.NAME = "PRIMITIVE";
|
|
1182
|
-
function
|
|
1182
|
+
function Es(n, e) {
|
|
1183
1183
|
if (n instanceof e)
|
|
1184
1184
|
return n;
|
|
1185
1185
|
const t = new e();
|
|
@@ -1188,7 +1188,7 @@ function ps(n, e) {
|
|
|
1188
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
|
|
1191
|
+
const i = new K();
|
|
1192
1192
|
if (!R(i, n, e, t))
|
|
1193
1193
|
return s.error = i.error, {
|
|
1194
1194
|
offset: -1,
|
|
@@ -1199,23 +1199,23 @@ function Be(n, e = 0, t = n.length) {
|
|
|
1199
1199
|
offset: -1,
|
|
1200
1200
|
result: s
|
|
1201
1201
|
};
|
|
1202
|
-
let
|
|
1203
|
-
if (s.idBlock.warnings.length && s.warnings.concat(s.idBlock.warnings),
|
|
1202
|
+
let a = s.idBlock.fromBER(n, e, t);
|
|
1203
|
+
if (s.idBlock.warnings.length && s.warnings.concat(s.idBlock.warnings), a === -1)
|
|
1204
1204
|
return s.error = s.idBlock.error, {
|
|
1205
1205
|
offset: -1,
|
|
1206
1206
|
result: s
|
|
1207
1207
|
};
|
|
1208
|
-
if (e =
|
|
1208
|
+
if (e = a, t -= s.idBlock.blockLength, a = s.lenBlock.fromBER(n, e, t), s.lenBlock.warnings.length && s.warnings.concat(s.lenBlock.warnings), a === -1)
|
|
1209
1209
|
return s.error = s.lenBlock.error, {
|
|
1210
1210
|
offset: -1,
|
|
1211
1211
|
result: s
|
|
1212
1212
|
};
|
|
1213
|
-
if (e =
|
|
1213
|
+
if (e = a, t -= s.lenBlock.blockLength, !s.idBlock.isConstructed && s.lenBlock.isIndefiniteForm)
|
|
1214
1214
|
return s.error = "Indefinite length form used for primitive encoding form", {
|
|
1215
1215
|
offset: -1,
|
|
1216
1216
|
result: s
|
|
1217
1217
|
};
|
|
1218
|
-
let
|
|
1218
|
+
let c = A;
|
|
1219
1219
|
switch (s.idBlock.tagClass) {
|
|
1220
1220
|
case 1:
|
|
1221
1221
|
if (s.idBlock.tagNumber >= 37 && s.idBlock.isHexOnly === !1)
|
|
@@ -1230,37 +1230,37 @@ function Be(n, e = 0, t = n.length) {
|
|
|
1230
1230
|
offset: -1,
|
|
1231
1231
|
result: s
|
|
1232
1232
|
};
|
|
1233
|
-
|
|
1233
|
+
c = d.EndOfContent;
|
|
1234
1234
|
break;
|
|
1235
1235
|
case 1:
|
|
1236
|
-
|
|
1236
|
+
c = d.Boolean;
|
|
1237
1237
|
break;
|
|
1238
1238
|
case 2:
|
|
1239
|
-
|
|
1239
|
+
c = d.Integer;
|
|
1240
1240
|
break;
|
|
1241
1241
|
case 3:
|
|
1242
|
-
|
|
1242
|
+
c = d.BitString;
|
|
1243
1243
|
break;
|
|
1244
1244
|
case 4:
|
|
1245
|
-
|
|
1245
|
+
c = d.OctetString;
|
|
1246
1246
|
break;
|
|
1247
1247
|
case 5:
|
|
1248
|
-
|
|
1248
|
+
c = d.Null;
|
|
1249
1249
|
break;
|
|
1250
1250
|
case 6:
|
|
1251
|
-
|
|
1251
|
+
c = d.ObjectIdentifier;
|
|
1252
1252
|
break;
|
|
1253
1253
|
case 10:
|
|
1254
|
-
|
|
1254
|
+
c = d.Enumerated;
|
|
1255
1255
|
break;
|
|
1256
1256
|
case 12:
|
|
1257
|
-
|
|
1257
|
+
c = d.Utf8String;
|
|
1258
1258
|
break;
|
|
1259
1259
|
case 13:
|
|
1260
|
-
|
|
1260
|
+
c = d.RelativeObjectIdentifier;
|
|
1261
1261
|
break;
|
|
1262
1262
|
case 14:
|
|
1263
|
-
|
|
1263
|
+
c = d.TIME;
|
|
1264
1264
|
break;
|
|
1265
1265
|
case 15:
|
|
1266
1266
|
return s.error = "[UNIVERSAL 15] is reserved by ASN.1 standard", {
|
|
@@ -1268,61 +1268,61 @@ function Be(n, e = 0, t = n.length) {
|
|
|
1268
1268
|
result: s
|
|
1269
1269
|
};
|
|
1270
1270
|
case 16:
|
|
1271
|
-
|
|
1271
|
+
c = d.Sequence;
|
|
1272
1272
|
break;
|
|
1273
1273
|
case 17:
|
|
1274
|
-
|
|
1274
|
+
c = d.Set;
|
|
1275
1275
|
break;
|
|
1276
1276
|
case 18:
|
|
1277
|
-
|
|
1277
|
+
c = d.NumericString;
|
|
1278
1278
|
break;
|
|
1279
1279
|
case 19:
|
|
1280
|
-
|
|
1280
|
+
c = d.PrintableString;
|
|
1281
1281
|
break;
|
|
1282
1282
|
case 20:
|
|
1283
|
-
|
|
1283
|
+
c = d.TeletexString;
|
|
1284
1284
|
break;
|
|
1285
1285
|
case 21:
|
|
1286
|
-
|
|
1286
|
+
c = d.VideotexString;
|
|
1287
1287
|
break;
|
|
1288
1288
|
case 22:
|
|
1289
|
-
|
|
1289
|
+
c = d.IA5String;
|
|
1290
1290
|
break;
|
|
1291
1291
|
case 23:
|
|
1292
|
-
|
|
1292
|
+
c = d.UTCTime;
|
|
1293
1293
|
break;
|
|
1294
1294
|
case 24:
|
|
1295
|
-
|
|
1295
|
+
c = d.GeneralizedTime;
|
|
1296
1296
|
break;
|
|
1297
1297
|
case 25:
|
|
1298
|
-
|
|
1298
|
+
c = d.GraphicString;
|
|
1299
1299
|
break;
|
|
1300
1300
|
case 26:
|
|
1301
|
-
|
|
1301
|
+
c = d.VisibleString;
|
|
1302
1302
|
break;
|
|
1303
1303
|
case 27:
|
|
1304
|
-
|
|
1304
|
+
c = d.GeneralString;
|
|
1305
1305
|
break;
|
|
1306
1306
|
case 28:
|
|
1307
|
-
|
|
1307
|
+
c = d.UniversalString;
|
|
1308
1308
|
break;
|
|
1309
1309
|
case 29:
|
|
1310
|
-
|
|
1310
|
+
c = d.CharacterString;
|
|
1311
1311
|
break;
|
|
1312
1312
|
case 30:
|
|
1313
|
-
|
|
1313
|
+
c = d.BmpString;
|
|
1314
1314
|
break;
|
|
1315
1315
|
case 31:
|
|
1316
|
-
|
|
1316
|
+
c = d.DATE;
|
|
1317
1317
|
break;
|
|
1318
1318
|
case 32:
|
|
1319
|
-
|
|
1319
|
+
c = d.TimeOfDay;
|
|
1320
1320
|
break;
|
|
1321
1321
|
case 33:
|
|
1322
|
-
|
|
1322
|
+
c = d.DateTime;
|
|
1323
1323
|
break;
|
|
1324
1324
|
case 34:
|
|
1325
|
-
|
|
1325
|
+
c = d.Duration;
|
|
1326
1326
|
break;
|
|
1327
1327
|
default: {
|
|
1328
1328
|
const l = s.idBlock.isConstructed ? new d.Constructed() : new d.Primitive();
|
|
@@ -1334,10 +1334,10 @@ function Be(n, e = 0, t = n.length) {
|
|
|
1334
1334
|
case 3:
|
|
1335
1335
|
case 4:
|
|
1336
1336
|
default:
|
|
1337
|
-
|
|
1337
|
+
c = s.idBlock.isConstructed ? d.Constructed : d.Primitive;
|
|
1338
1338
|
}
|
|
1339
|
-
return s =
|
|
1340
|
-
offset:
|
|
1339
|
+
return s = Es(s, c), a = s.fromBER(n, e, s.lenBlock.isIndefiniteForm ? t : s.lenBlock.length), s.valueBeforeDecodeView = n.subarray(r, r + s.blockLength), {
|
|
1340
|
+
offset: a,
|
|
1341
1341
|
result: s
|
|
1342
1342
|
};
|
|
1343
1343
|
}
|
|
@@ -1354,7 +1354,7 @@ function Ns(n) {
|
|
|
1354
1354
|
function Is(n, e) {
|
|
1355
1355
|
return n ? 1 : e;
|
|
1356
1356
|
}
|
|
1357
|
-
class
|
|
1357
|
+
class F extends S {
|
|
1358
1358
|
constructor({ value: e = [], isIndefiniteForm: t = !1, ...r } = {}) {
|
|
1359
1359
|
super(r), this.value = e, this.isIndefiniteForm = t;
|
|
1360
1360
|
}
|
|
@@ -1378,7 +1378,7 @@ class $ extends S {
|
|
|
1378
1378
|
const r = t || new He();
|
|
1379
1379
|
for (let s = 0; s < this.value.length; s++)
|
|
1380
1380
|
this.value[s].toBER(e, r);
|
|
1381
|
-
return t ?
|
|
1381
|
+
return t ? _ : r.final();
|
|
1382
1382
|
}
|
|
1383
1383
|
toJSON() {
|
|
1384
1384
|
const e = {
|
|
@@ -1391,11 +1391,11 @@ class $ extends S {
|
|
|
1391
1391
|
return e;
|
|
1392
1392
|
}
|
|
1393
1393
|
}
|
|
1394
|
-
|
|
1394
|
+
F.NAME = "ConstructedValueBlock";
|
|
1395
1395
|
var Lt;
|
|
1396
|
-
class
|
|
1396
|
+
class te extends A {
|
|
1397
1397
|
constructor(e = {}) {
|
|
1398
|
-
super(e,
|
|
1398
|
+
super(e, F), this.idBlock.isConstructed = !0;
|
|
1399
1399
|
}
|
|
1400
1400
|
fromBER(e, t, r) {
|
|
1401
1401
|
this.valueBlock.isIndefiniteForm = this.lenBlock.isIndefiniteForm;
|
|
@@ -1414,15 +1414,15 @@ ${e.join(`
|
|
|
1414
1414
|
`)}` : `${t} :`;
|
|
1415
1415
|
}
|
|
1416
1416
|
}
|
|
1417
|
-
Lt =
|
|
1417
|
+
Lt = te;
|
|
1418
1418
|
d.Constructed = Lt;
|
|
1419
|
-
|
|
1419
|
+
te.NAME = "CONSTRUCTED";
|
|
1420
1420
|
class Rt extends S {
|
|
1421
1421
|
fromBER(e, t, r) {
|
|
1422
1422
|
return t;
|
|
1423
1423
|
}
|
|
1424
1424
|
toBER(e) {
|
|
1425
|
-
return
|
|
1425
|
+
return _;
|
|
1426
1426
|
}
|
|
1427
1427
|
}
|
|
1428
1428
|
Rt.override = "EndOfContentValueBlock";
|
|
@@ -1473,7 +1473,7 @@ class Pt extends M(S) {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
fromBER(e, t, r) {
|
|
1475
1475
|
const s = B.toUint8Array(e);
|
|
1476
|
-
return 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,
|
|
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, pt.call(this), this.blockLength = r, t + r) : -1;
|
|
1477
1477
|
}
|
|
1478
1478
|
toBER() {
|
|
1479
1479
|
return this.valueHexView.slice();
|
|
@@ -1504,14 +1504,14 @@ class jt extends A {
|
|
|
1504
1504
|
Ft = jt;
|
|
1505
1505
|
d.Boolean = Ft;
|
|
1506
1506
|
jt.NAME = "BOOLEAN";
|
|
1507
|
-
class qt extends M(
|
|
1507
|
+
class qt extends M(F) {
|
|
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 =
|
|
1514
|
+
if (this.isHexOnly = !1, s = F.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;
|
|
@@ -1520,7 +1520,7 @@ class qt extends M($) {
|
|
|
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 !==
|
|
1523
|
+
if (o !== Et)
|
|
1524
1524
|
return this.error = "OCTET STRING may consists of OCTET STRINGs only", -1;
|
|
1525
1525
|
}
|
|
1526
1526
|
} else
|
|
@@ -1528,7 +1528,7 @@ class qt extends M($) {
|
|
|
1528
1528
|
return s;
|
|
1529
1529
|
}
|
|
1530
1530
|
toBER(e, t) {
|
|
1531
|
-
return this.isConstructed ?
|
|
1531
|
+
return this.isConstructed ? F.prototype.toBER.call(this, e, t) : e ? new ArrayBuffer(this.valueHexView.byteLength) : this.valueHexView.slice().buffer;
|
|
1532
1532
|
}
|
|
1533
1533
|
toJSON() {
|
|
1534
1534
|
return {
|
|
@@ -1571,8 +1571,8 @@ class Gt extends A {
|
|
|
1571
1571
|
}
|
|
1572
1572
|
onAsciiEncoding() {
|
|
1573
1573
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length)
|
|
1574
|
-
return
|
|
1575
|
-
const e = this.constructor.NAME, t =
|
|
1574
|
+
return te.prototype.onAsciiEncoding.call(this);
|
|
1575
|
+
const e = this.constructor.NAME, t = v.ToHex(this.valueBlock.valueHexView);
|
|
1576
1576
|
return `${e} : ${t}`;
|
|
1577
1577
|
}
|
|
1578
1578
|
getValue() {
|
|
@@ -1586,8 +1586,8 @@ class Gt extends A {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
Re = Gt;
|
|
1588
1588
|
d.OctetString = Re;
|
|
1589
|
-
Gt.NAME =
|
|
1590
|
-
class Jt extends M(
|
|
1589
|
+
Gt.NAME = Et;
|
|
1590
|
+
class Jt extends M(F) {
|
|
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,18 +1596,18 @@ class Jt extends M($) {
|
|
|
1596
1596
|
return t;
|
|
1597
1597
|
let s = -1;
|
|
1598
1598
|
if (this.isConstructed) {
|
|
1599
|
-
if (s =
|
|
1599
|
+
if (s = F.prototype.fromBER.call(this, e, t, r), s === -1)
|
|
1600
1600
|
return s;
|
|
1601
|
-
for (const
|
|
1602
|
-
const
|
|
1603
|
-
if (
|
|
1601
|
+
for (const a of this.value) {
|
|
1602
|
+
const c = a.constructor.NAME;
|
|
1603
|
+
if (c === 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 (
|
|
1608
|
+
if (c !== Nt)
|
|
1609
1609
|
return this.error = "BIT STRING may consists of BIT STRINGs only", -1;
|
|
1610
|
-
const l =
|
|
1610
|
+
const l = a.valueBlock;
|
|
1611
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
1613
|
this.unusedBits = l.unusedBits;
|
|
@@ -1621,11 +1621,11 @@ class Jt extends M($) {
|
|
|
1621
1621
|
if (this.unusedBits = o[0], this.unusedBits > 7)
|
|
1622
1622
|
return this.error = "Unused bits for BitString must be in range 0-7", -1;
|
|
1623
1623
|
if (!this.unusedBits) {
|
|
1624
|
-
const
|
|
1624
|
+
const a = o.subarray(1);
|
|
1625
1625
|
try {
|
|
1626
|
-
if (
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1626
|
+
if (a.byteLength) {
|
|
1627
|
+
const c = Be(a, 0, a.byteLength);
|
|
1628
|
+
c.offset !== -1 && c.offset === r - 1 && (this.value = [c.result]);
|
|
1629
1629
|
}
|
|
1630
1630
|
} catch {
|
|
1631
1631
|
}
|
|
@@ -1634,7 +1634,7 @@ class Jt extends M($) {
|
|
|
1634
1634
|
}
|
|
1635
1635
|
toBER(e, t) {
|
|
1636
1636
|
if (this.isConstructed)
|
|
1637
|
-
return
|
|
1637
|
+
return F.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) {
|
|
@@ -1674,7 +1674,7 @@ class Me extends A {
|
|
|
1674
1674
|
}
|
|
1675
1675
|
onAsciiEncoding() {
|
|
1676
1676
|
if (this.valueBlock.isConstructed || this.valueBlock.value && this.valueBlock.value.length)
|
|
1677
|
-
return
|
|
1677
|
+
return te.prototype.onAsciiEncoding.call(this);
|
|
1678
1678
|
{
|
|
1679
1679
|
const e = [], t = this.valueBlock.valueHexView;
|
|
1680
1680
|
for (const o of t)
|
|
@@ -1691,14 +1691,14 @@ var Wt;
|
|
|
1691
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
|
-
const o = i.length - 1,
|
|
1694
|
+
const o = i.length - 1, a = s.slice(0), c = a.length - 1;
|
|
1695
1695
|
let l = 0;
|
|
1696
|
-
const f =
|
|
1696
|
+
const f = c < o ? o : c;
|
|
1697
1697
|
let h = 0;
|
|
1698
1698
|
for (let u = f; u >= 0; u--, h++) {
|
|
1699
1699
|
switch (!0) {
|
|
1700
|
-
case h <
|
|
1701
|
-
l = i[o - h] + c
|
|
1700
|
+
case h < a.length:
|
|
1701
|
+
l = i[o - h] + a[c - h] + t[0];
|
|
1702
1702
|
break;
|
|
1703
1703
|
default:
|
|
1704
1704
|
l = i[o - h] + t[0];
|
|
@@ -1726,12 +1726,12 @@ function it(n) {
|
|
|
1726
1726
|
}
|
|
1727
1727
|
return oe[n];
|
|
1728
1728
|
}
|
|
1729
|
-
function
|
|
1729
|
+
function Ts(n, e) {
|
|
1730
1730
|
let t = 0;
|
|
1731
|
-
const r = new Uint8Array(n), s = new Uint8Array(e), i = r.slice(0), o = i.length - 1,
|
|
1731
|
+
const r = new Uint8Array(n), s = new Uint8Array(e), i = r.slice(0), o = i.length - 1, a = s.slice(0), c = a.length - 1;
|
|
1732
1732
|
let l, f = 0;
|
|
1733
|
-
for (let h =
|
|
1734
|
-
switch (l = i[o - f] - c
|
|
1733
|
+
for (let h = c; h >= 0; h--, f++)
|
|
1734
|
+
switch (l = i[o - f] - a[c - f] - t, !0) {
|
|
1735
1735
|
case l < 0:
|
|
1736
1736
|
t = 1, i[o - f] = l + 10;
|
|
1737
1737
|
break;
|
|
@@ -1739,7 +1739,7 @@ function Vs(n, e) {
|
|
|
1739
1739
|
t = 0, i[o - f] = l;
|
|
1740
1740
|
}
|
|
1741
1741
|
if (t > 0)
|
|
1742
|
-
for (let h = o -
|
|
1742
|
+
for (let h = o - c + 1; h >= 0; h--, f++)
|
|
1743
1743
|
if (l = i[o - f] - t, l < 0)
|
|
1744
1744
|
t = 1, i[o - f] = l + 10;
|
|
1745
1745
|
else {
|
|
@@ -1750,7 +1750,7 @@ function Vs(n, e) {
|
|
|
1750
1750
|
}
|
|
1751
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 =
|
|
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 = pt.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);
|
|
@@ -1800,14 +1800,14 @@ class Oe extends M(S) {
|
|
|
1800
1800
|
const e = this.valueHexView.length * 8 - 1;
|
|
1801
1801
|
let t = new Uint8Array(this.valueHexView.length * 8 / 3), r = 0, s;
|
|
1802
1802
|
const i = this.valueHexView;
|
|
1803
|
-
let o = "",
|
|
1804
|
-
for (let
|
|
1805
|
-
s = i[
|
|
1803
|
+
let o = "", a = !1;
|
|
1804
|
+
for (let c = i.byteLength - 1; c >= 0; c--) {
|
|
1805
|
+
s = i[c];
|
|
1806
1806
|
for (let l = 0; l < 8; l++) {
|
|
1807
1807
|
if ((s & 1) === 1)
|
|
1808
1808
|
switch (r) {
|
|
1809
1809
|
case e:
|
|
1810
|
-
t =
|
|
1810
|
+
t = Ts(it(r), t), o = "-";
|
|
1811
1811
|
break;
|
|
1812
1812
|
default:
|
|
1813
1813
|
t = Us(t, it(r));
|
|
@@ -1815,9 +1815,9 @@ class Oe extends M(S) {
|
|
|
1815
1815
|
r++, s >>= 1;
|
|
1816
1816
|
}
|
|
1817
1817
|
}
|
|
1818
|
-
for (let
|
|
1819
|
-
t[
|
|
1820
|
-
return
|
|
1818
|
+
for (let c = 0; c < t.length; c++)
|
|
1819
|
+
t[c] && (a = !0), a && (o += nt.charAt(t[c]));
|
|
1820
|
+
return a === !1 && (o += nt.charAt(0)), o;
|
|
1821
1821
|
}
|
|
1822
1822
|
}
|
|
1823
1823
|
Wt = Oe;
|
|
@@ -1840,11 +1840,11 @@ class De extends A {
|
|
|
1840
1840
|
}
|
|
1841
1841
|
static fromBigInt(e) {
|
|
1842
1842
|
we();
|
|
1843
|
-
const t = BigInt(e), r = new He(), s = t.toString(16).replace(/^-/, ""), i = new Uint8Array(
|
|
1843
|
+
const t = BigInt(e), r = new He(), s = t.toString(16).replace(/^-/, ""), i = new Uint8Array(v.FromHex(s));
|
|
1844
1844
|
if (t < 0) {
|
|
1845
|
-
const
|
|
1846
|
-
|
|
1847
|
-
const l = BigInt(`0x${
|
|
1845
|
+
const a = new Uint8Array(i.length + (i[0] & 128 ? 1 : 0));
|
|
1846
|
+
a[0] |= 128;
|
|
1847
|
+
const l = BigInt(`0x${v.ToHex(a)}`) + t, f = B.toUint8Array(v.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);
|
|
@@ -1887,12 +1887,12 @@ class Ie extends M(S) {
|
|
|
1887
1887
|
return -1;
|
|
1888
1888
|
const i = s.subarray(t, t + r);
|
|
1889
1889
|
this.valueHexView = new Uint8Array(r);
|
|
1890
|
-
for (let
|
|
1890
|
+
for (let a = 0; a < r && (this.valueHexView[a] = i[a] & 127, this.blockLength++, !!(i[a] & 128)); a++)
|
|
1891
1891
|
;
|
|
1892
1892
|
const o = new Uint8Array(this.blockLength);
|
|
1893
|
-
for (let
|
|
1894
|
-
o[
|
|
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 =
|
|
1893
|
+
for (let a = 0; a < this.blockLength; a++)
|
|
1894
|
+
o[a] = this.valueHexView[a];
|
|
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 = Q(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
1898
|
we();
|
|
@@ -1913,9 +1913,9 @@ class Ie extends M(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 =
|
|
1916
|
+
const t = J(this.valueDec, 7);
|
|
1917
1917
|
if (t.byteLength === 0)
|
|
1918
|
-
return this.error = "Error during encoding SID value",
|
|
1918
|
+
return this.error = "Error during encoding SID value", _;
|
|
1919
1919
|
const r = new Uint8Array(t.byteLength);
|
|
1920
1920
|
if (!e) {
|
|
1921
1921
|
const s = new Uint8Array(t), i = t.byteLength - 1;
|
|
@@ -1928,7 +1928,7 @@ class Ie extends M(S) {
|
|
|
1928
1928
|
toString() {
|
|
1929
1929
|
let e = "";
|
|
1930
1930
|
if (this.isHexOnly)
|
|
1931
|
-
e =
|
|
1931
|
+
e = v.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 M(S) {
|
|
|
1946
1946
|
}
|
|
1947
1947
|
Ie.NAME = "sidBlock";
|
|
1948
1948
|
class zt extends S {
|
|
1949
|
-
constructor({ value: e =
|
|
1949
|
+
constructor({ value: e = ee, ...t } = {}) {
|
|
1950
1950
|
super(t), this.value = [], e && this.fromString(e);
|
|
1951
1951
|
}
|
|
1952
1952
|
fromBER(e, t, r) {
|
|
@@ -1964,7 +1964,7 @@ class zt extends S {
|
|
|
1964
1964
|
for (let r = 0; r < this.value.length; r++) {
|
|
1965
1965
|
const s = this.value[r].toBER(e);
|
|
1966
1966
|
if (s.byteLength === 0)
|
|
1967
|
-
return this.error = this.value[r].error,
|
|
1967
|
+
return this.error = this.value[r].error, _;
|
|
1968
1968
|
t.push(s);
|
|
1969
1969
|
}
|
|
1970
1970
|
return Ce(t);
|
|
@@ -1975,30 +1975,30 @@ class zt extends S {
|
|
|
1975
1975
|
do
|
|
1976
1976
|
if (r = e.indexOf(".", t), r === -1 ? s = e.substring(t) : s = e.substring(t, r), t = r + 1, i) {
|
|
1977
1977
|
const o = this.value[0];
|
|
1978
|
-
let
|
|
1978
|
+
let a = 0;
|
|
1979
1979
|
switch (o.valueDec) {
|
|
1980
1980
|
case 0:
|
|
1981
1981
|
break;
|
|
1982
1982
|
case 1:
|
|
1983
|
-
|
|
1983
|
+
a = 40;
|
|
1984
1984
|
break;
|
|
1985
1985
|
case 2:
|
|
1986
|
-
|
|
1986
|
+
a = 80;
|
|
1987
1987
|
break;
|
|
1988
1988
|
default:
|
|
1989
1989
|
this.value = [];
|
|
1990
1990
|
return;
|
|
1991
1991
|
}
|
|
1992
|
-
const
|
|
1993
|
-
if (isNaN(
|
|
1992
|
+
const c = parseInt(s, 10);
|
|
1993
|
+
if (isNaN(c))
|
|
1994
1994
|
return;
|
|
1995
|
-
o.valueDec =
|
|
1995
|
+
o.valueDec = c + a, i = !1;
|
|
1996
1996
|
} else {
|
|
1997
1997
|
const o = new Ie();
|
|
1998
1998
|
if (s > Number.MAX_SAFE_INTEGER) {
|
|
1999
1999
|
we();
|
|
2000
|
-
const
|
|
2001
|
-
o.valueBigInt =
|
|
2000
|
+
const a = BigInt(s);
|
|
2001
|
+
o.valueBigInt = a;
|
|
2002
2002
|
} else if (o.valueDec = parseInt(s, 10), isNaN(o.valueDec))
|
|
2003
2003
|
return;
|
|
2004
2004
|
this.value.length || (o.isFirstSid = !0, i = !0), this.value.push(o);
|
|
@@ -2050,7 +2050,7 @@ class $e extends A {
|
|
|
2050
2050
|
Yt = $e;
|
|
2051
2051
|
d.ObjectIdentifier = Yt;
|
|
2052
2052
|
$e.NAME = "OBJECT IDENTIFIER";
|
|
2053
|
-
class Ue extends M(
|
|
2053
|
+
class Ue extends M(K) {
|
|
2054
2054
|
constructor({ valueDec: e = 0, ...t } = {}) {
|
|
2055
2055
|
super(t), this.valueDec = e;
|
|
2056
2056
|
}
|
|
@@ -2062,12 +2062,12 @@ class Ue extends M(G) {
|
|
|
2062
2062
|
return -1;
|
|
2063
2063
|
const i = s.subarray(t, t + r);
|
|
2064
2064
|
this.valueHexView = new Uint8Array(r);
|
|
2065
|
-
for (let
|
|
2065
|
+
for (let a = 0; a < r && (this.valueHexView[a] = i[a] & 127, this.blockLength++, !!(i[a] & 128)); a++)
|
|
2066
2066
|
;
|
|
2067
2067
|
const o = new Uint8Array(this.blockLength);
|
|
2068
|
-
for (let
|
|
2069
|
-
o[
|
|
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 =
|
|
2068
|
+
for (let a = 0; a < this.blockLength; a++)
|
|
2069
|
+
o[a] = this.valueHexView[a];
|
|
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 = Q(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,9 +2078,9 @@ class Ue extends M(G) {
|
|
|
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 =
|
|
2081
|
+
const t = J(this.valueDec, 7);
|
|
2082
2082
|
if (t.byteLength === 0)
|
|
2083
|
-
return this.error = "Error during encoding SID value",
|
|
2083
|
+
return this.error = "Error during encoding SID value", _;
|
|
2084
2084
|
const r = new Uint8Array(t.byteLength);
|
|
2085
2085
|
if (!e) {
|
|
2086
2086
|
const s = new Uint8Array(t), i = t.byteLength - 1;
|
|
@@ -2092,7 +2092,7 @@ class Ue extends M(G) {
|
|
|
2092
2092
|
}
|
|
2093
2093
|
toString() {
|
|
2094
2094
|
let e = "";
|
|
2095
|
-
return this.isHexOnly ? e =
|
|
2095
|
+
return this.isHexOnly ? e = v.ToHex(this.valueHexView) : e = this.valueDec.toString(), e;
|
|
2096
2096
|
}
|
|
2097
2097
|
toJSON() {
|
|
2098
2098
|
return {
|
|
@@ -2103,7 +2103,7 @@ class Ue extends M(G) {
|
|
|
2103
2103
|
}
|
|
2104
2104
|
Ue.NAME = "relativeSidBlock";
|
|
2105
2105
|
class Qt extends S {
|
|
2106
|
-
constructor({ value: e =
|
|
2106
|
+
constructor({ value: e = ee, ...t } = {}) {
|
|
2107
2107
|
super(t), this.value = [], e && this.fromString(e);
|
|
2108
2108
|
}
|
|
2109
2109
|
fromBER(e, t, r) {
|
|
@@ -2121,7 +2121,7 @@ class Qt extends S {
|
|
|
2121
2121
|
for (let s = 0; s < this.value.length; s++) {
|
|
2122
2122
|
const i = this.value[s].toBER(e);
|
|
2123
2123
|
if (i.byteLength === 0)
|
|
2124
|
-
return this.error = this.value[s].error,
|
|
2124
|
+
return this.error = this.value[s].error, _;
|
|
2125
2125
|
r.push(i);
|
|
2126
2126
|
}
|
|
2127
2127
|
return Ce(r);
|
|
@@ -2184,7 +2184,7 @@ er = tr;
|
|
|
2184
2184
|
d.RelativeObjectIdentifier = er;
|
|
2185
2185
|
tr.NAME = "RelativeObjectIdentifier";
|
|
2186
2186
|
var rr;
|
|
2187
|
-
class ye extends
|
|
2187
|
+
class ye extends te {
|
|
2188
2188
|
constructor(e = {}) {
|
|
2189
2189
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 16;
|
|
2190
2190
|
}
|
|
@@ -2193,7 +2193,7 @@ rr = ye;
|
|
|
2193
2193
|
d.Sequence = rr;
|
|
2194
2194
|
ye.NAME = "SEQUENCE";
|
|
2195
2195
|
var sr;
|
|
2196
|
-
class nr extends
|
|
2196
|
+
class nr extends te {
|
|
2197
2197
|
constructor(e = {}) {
|
|
2198
2198
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 17;
|
|
2199
2199
|
}
|
|
@@ -2203,7 +2203,7 @@ d.Set = sr;
|
|
|
2203
2203
|
nr.NAME = "SET";
|
|
2204
2204
|
class ir extends M(S) {
|
|
2205
2205
|
constructor({ ...e } = {}) {
|
|
2206
|
-
super(e), this.isHexOnly = !0, this.value =
|
|
2206
|
+
super(e), this.isHexOnly = !0, this.value = ee;
|
|
2207
2207
|
}
|
|
2208
2208
|
toJSON() {
|
|
2209
2209
|
return {
|
|
@@ -2216,7 +2216,7 @@ ir.NAME = "StringValueBlock";
|
|
|
2216
2216
|
class or extends ir {
|
|
2217
2217
|
}
|
|
2218
2218
|
or.NAME = "SimpleStringValueBlock";
|
|
2219
|
-
class N extends
|
|
2219
|
+
class N extends Vt {
|
|
2220
2220
|
constructor({ ...e } = {}) {
|
|
2221
2221
|
super(e, or);
|
|
2222
2222
|
}
|
|
@@ -2235,31 +2235,31 @@ class cr extends N {
|
|
|
2235
2235
|
fromBuffer(e) {
|
|
2236
2236
|
this.valueBlock.valueHexView = B.toUint8Array(e);
|
|
2237
2237
|
try {
|
|
2238
|
-
this.valueBlock.value =
|
|
2238
|
+
this.valueBlock.value = v.ToUtf8String(e);
|
|
2239
2239
|
} catch (t) {
|
|
2240
|
-
this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`), this.valueBlock.value =
|
|
2240
|
+
this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`), this.valueBlock.value = v.ToBinary(e);
|
|
2241
2241
|
}
|
|
2242
2242
|
}
|
|
2243
2243
|
fromString(e) {
|
|
2244
|
-
this.valueBlock.valueHexView = new Uint8Array(
|
|
2244
|
+
this.valueBlock.valueHexView = new Uint8Array(v.FromUtf8String(e)), this.valueBlock.value = e;
|
|
2245
2245
|
}
|
|
2246
2246
|
}
|
|
2247
2247
|
cr.NAME = "Utf8StringValueBlock";
|
|
2248
2248
|
var ar;
|
|
2249
|
-
class
|
|
2249
|
+
class W extends cr {
|
|
2250
2250
|
constructor(e = {}) {
|
|
2251
2251
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 12;
|
|
2252
2252
|
}
|
|
2253
2253
|
}
|
|
2254
|
-
ar =
|
|
2254
|
+
ar = W;
|
|
2255
2255
|
d.Utf8String = ar;
|
|
2256
|
-
|
|
2256
|
+
W.NAME = "UTF8String";
|
|
2257
2257
|
class lr extends N {
|
|
2258
2258
|
fromBuffer(e) {
|
|
2259
|
-
this.valueBlock.value =
|
|
2259
|
+
this.valueBlock.value = v.ToUtf16String(e), this.valueBlock.valueHexView = B.toUint8Array(e);
|
|
2260
2260
|
}
|
|
2261
2261
|
fromString(e) {
|
|
2262
|
-
this.valueBlock.value = e, this.valueBlock.valueHexView = new Uint8Array(
|
|
2262
|
+
this.valueBlock.value = e, this.valueBlock.valueHexView = new Uint8Array(v.FromUtf16String(e));
|
|
2263
2263
|
}
|
|
2264
2264
|
}
|
|
2265
2265
|
lr.NAME = "BmpStringValueBlock";
|
|
@@ -2282,12 +2282,12 @@ class fr extends N {
|
|
|
2282
2282
|
fromString(e) {
|
|
2283
2283
|
const t = e.length, r = this.valueBlock.valueHexView = new Uint8Array(t * 4);
|
|
2284
2284
|
for (let s = 0; s < t; s++) {
|
|
2285
|
-
const i =
|
|
2285
|
+
const i = J(e.charCodeAt(s), 8), o = new Uint8Array(i);
|
|
2286
2286
|
if (o.length > 4)
|
|
2287
2287
|
continue;
|
|
2288
|
-
const
|
|
2289
|
-
for (let
|
|
2290
|
-
r[s * 4 +
|
|
2288
|
+
const a = 4 - o.length;
|
|
2289
|
+
for (let c = o.length - 1; c >= 0; c--)
|
|
2290
|
+
r[s * 4 + c + a] = o[c];
|
|
2291
2291
|
}
|
|
2292
2292
|
this.valueBlock.value = e;
|
|
2293
2293
|
}
|
|
@@ -2320,23 +2320,23 @@ class br extends N {
|
|
|
2320
2320
|
Br = br;
|
|
2321
2321
|
d.PrintableString = Br;
|
|
2322
2322
|
br.NAME = "PrintableString";
|
|
2323
|
-
var
|
|
2324
|
-
class
|
|
2323
|
+
var mr;
|
|
2324
|
+
class vr extends N {
|
|
2325
2325
|
constructor(e = {}) {
|
|
2326
2326
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 20;
|
|
2327
2327
|
}
|
|
2328
2328
|
}
|
|
2329
|
-
|
|
2330
|
-
d.TeletexString =
|
|
2331
|
-
|
|
2332
|
-
var
|
|
2329
|
+
mr = vr;
|
|
2330
|
+
d.TeletexString = mr;
|
|
2331
|
+
vr.NAME = "TeletexString";
|
|
2332
|
+
var kr;
|
|
2333
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
|
-
|
|
2339
|
-
d.VideotexString =
|
|
2338
|
+
kr = Ar;
|
|
2339
|
+
d.VideotexString = kr;
|
|
2340
2340
|
Ar.NAME = "VideotexString";
|
|
2341
2341
|
var xr;
|
|
2342
2342
|
class Sr extends N {
|
|
@@ -2347,15 +2347,15 @@ class Sr extends N {
|
|
|
2347
2347
|
xr = Sr;
|
|
2348
2348
|
d.IA5String = xr;
|
|
2349
2349
|
Sr.NAME = "IA5String";
|
|
2350
|
-
var
|
|
2351
|
-
class
|
|
2350
|
+
var pr;
|
|
2351
|
+
class Er extends N {
|
|
2352
2352
|
constructor(e = {}) {
|
|
2353
2353
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 25;
|
|
2354
2354
|
}
|
|
2355
2355
|
}
|
|
2356
|
-
|
|
2357
|
-
d.GraphicString =
|
|
2358
|
-
|
|
2356
|
+
pr = Er;
|
|
2357
|
+
d.GraphicString = pr;
|
|
2358
|
+
Er.NAME = "GraphicString";
|
|
2359
2359
|
var Nr;
|
|
2360
2360
|
class Pe extends N {
|
|
2361
2361
|
constructor(e = {}) {
|
|
@@ -2374,15 +2374,15 @@ class Ur extends N {
|
|
|
2374
2374
|
Ir = Ur;
|
|
2375
2375
|
d.GeneralString = Ir;
|
|
2376
2376
|
Ur.NAME = "GeneralString";
|
|
2377
|
-
var
|
|
2378
|
-
class
|
|
2377
|
+
var Tr;
|
|
2378
|
+
class Vr extends N {
|
|
2379
2379
|
constructor(e = {}) {
|
|
2380
2380
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 29;
|
|
2381
2381
|
}
|
|
2382
2382
|
}
|
|
2383
|
-
|
|
2384
|
-
d.CharacterString =
|
|
2385
|
-
|
|
2383
|
+
Tr = Vr;
|
|
2384
|
+
d.CharacterString = Tr;
|
|
2385
|
+
Vr.NAME = "CharacterString";
|
|
2386
2386
|
var _r;
|
|
2387
2387
|
class Fe extends Pe {
|
|
2388
2388
|
constructor({ value: e, valueDate: t, ...r } = {}) {
|
|
@@ -2420,7 +2420,7 @@ class Fe extends Pe {
|
|
|
2420
2420
|
toString(e = "iso") {
|
|
2421
2421
|
if (e === "iso") {
|
|
2422
2422
|
const t = new Array(7);
|
|
2423
|
-
return t[0] =
|
|
2423
|
+
return t[0] = p(this.year < 2e3 ? this.year - 1900 : this.year - 2e3, 2), t[1] = p(this.month, 2), t[2] = p(this.day, 2), t[3] = p(this.hour, 2), t[4] = p(this.minute, 2), t[5] = p(this.second, 2), t[6] = "Z", t.join("");
|
|
2424
2424
|
}
|
|
2425
2425
|
return super.toString(e);
|
|
2426
2426
|
}
|
|
@@ -2456,7 +2456,7 @@ class Hr extends Fe {
|
|
|
2456
2456
|
return new Date(e);
|
|
2457
2457
|
}
|
|
2458
2458
|
fromString(e) {
|
|
2459
|
-
let t = !1, r = "", s = "", i = 0, o,
|
|
2459
|
+
let t = !1, r = "", s = "", i = 0, o, a = 0, c = 0;
|
|
2460
2460
|
if (e[e.length - 1] === "Z")
|
|
2461
2461
|
r = e.substring(0, e.length - 1), t = !0;
|
|
2462
2462
|
else {
|
|
@@ -2478,10 +2478,10 @@ class Hr extends Fe {
|
|
|
2478
2478
|
let w = parseInt(g.substring(0, 2), 10);
|
|
2479
2479
|
if (isNaN(w.valueOf()))
|
|
2480
2480
|
throw new Error("Wrong input string for conversion");
|
|
2481
|
-
if (
|
|
2481
|
+
if (a = h * w, g.length === 4) {
|
|
2482
2482
|
if (w = parseInt(g.substring(2, 4), 10), isNaN(w.valueOf()))
|
|
2483
2483
|
throw new Error("Wrong input string for conversion");
|
|
2484
|
-
|
|
2484
|
+
c = h * w;
|
|
2485
2485
|
}
|
|
2486
2486
|
}
|
|
2487
2487
|
}
|
|
@@ -2534,10 +2534,10 @@ class Hr extends Fe {
|
|
|
2534
2534
|
this.day = parseInt(f[h], 10);
|
|
2535
2535
|
break;
|
|
2536
2536
|
case 4:
|
|
2537
|
-
this.hour = parseInt(f[h], 10) +
|
|
2537
|
+
this.hour = parseInt(f[h], 10) + a;
|
|
2538
2538
|
break;
|
|
2539
2539
|
case 5:
|
|
2540
|
-
this.minute = parseInt(f[h], 10) +
|
|
2540
|
+
this.minute = parseInt(f[h], 10) + c;
|
|
2541
2541
|
break;
|
|
2542
2542
|
case 6:
|
|
2543
2543
|
this.second = parseInt(f[h], 10);
|
|
@@ -2553,7 +2553,7 @@ class Hr extends Fe {
|
|
|
2553
2553
|
toString(e = "iso") {
|
|
2554
2554
|
if (e === "iso") {
|
|
2555
2555
|
const t = [];
|
|
2556
|
-
return t.push(
|
|
2556
|
+
return t.push(p(this.year, 4)), t.push(p(this.month, 2)), t.push(p(this.day, 2)), t.push(p(this.hour, 2)), t.push(p(this.minute, 2)), t.push(p(this.second, 2)), this.millisecond !== 0 && (t.push("."), t.push(p(this.millisecond, 3))), t.push("Z"), t.join("");
|
|
2557
2557
|
}
|
|
2558
2558
|
return super.toString(e);
|
|
2559
2559
|
}
|
|
@@ -2568,7 +2568,7 @@ Cr = Hr;
|
|
|
2568
2568
|
d.GeneralizedTime = Cr;
|
|
2569
2569
|
Hr.NAME = "GeneralizedTime";
|
|
2570
2570
|
var Lr;
|
|
2571
|
-
class Rr extends
|
|
2571
|
+
class Rr extends W {
|
|
2572
2572
|
constructor(e = {}) {
|
|
2573
2573
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 31;
|
|
2574
2574
|
}
|
|
@@ -2577,7 +2577,7 @@ Lr = Rr;
|
|
|
2577
2577
|
d.DATE = Lr;
|
|
2578
2578
|
Rr.NAME = "DATE";
|
|
2579
2579
|
var Mr;
|
|
2580
|
-
class Or extends
|
|
2580
|
+
class Or extends W {
|
|
2581
2581
|
constructor(e = {}) {
|
|
2582
2582
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 32;
|
|
2583
2583
|
}
|
|
@@ -2586,7 +2586,7 @@ Mr = Or;
|
|
|
2586
2586
|
d.TimeOfDay = Mr;
|
|
2587
2587
|
Or.NAME = "TimeOfDay";
|
|
2588
2588
|
var Dr;
|
|
2589
|
-
class $r extends
|
|
2589
|
+
class $r extends W {
|
|
2590
2590
|
constructor(e = {}) {
|
|
2591
2591
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 33;
|
|
2592
2592
|
}
|
|
@@ -2595,7 +2595,7 @@ Dr = $r;
|
|
|
2595
2595
|
d.DateTime = Dr;
|
|
2596
2596
|
$r.NAME = "DateTime";
|
|
2597
2597
|
var Pr;
|
|
2598
|
-
class Fr extends
|
|
2598
|
+
class Fr extends W {
|
|
2599
2599
|
constructor(e = {}) {
|
|
2600
2600
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 34;
|
|
2601
2601
|
}
|
|
@@ -2604,7 +2604,7 @@ Pr = Fr;
|
|
|
2604
2604
|
d.Duration = Pr;
|
|
2605
2605
|
Fr.NAME = "Duration";
|
|
2606
2606
|
var jr;
|
|
2607
|
-
class qr extends
|
|
2607
|
+
class qr extends W {
|
|
2608
2608
|
constructor(e = {}) {
|
|
2609
2609
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 14;
|
|
2610
2610
|
}
|
|
@@ -2612,7 +2612,7 @@ class qr extends J {
|
|
|
2612
2612
|
jr = qr;
|
|
2613
2613
|
d.TIME = jr;
|
|
2614
2614
|
qr.NAME = "TIME";
|
|
2615
|
-
function
|
|
2615
|
+
function Vs(n) {
|
|
2616
2616
|
const e = n.slice().buffer, t = new ye({
|
|
2617
2617
|
value: [new $e({ value: "1.3.101.110" })]
|
|
2618
2618
|
// id-X25519
|
|
@@ -2716,7 +2716,7 @@ async function Ms(n, e, t) {
|
|
|
2716
2716
|
}
|
|
2717
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.chunkBuffers = {}, this.generateRandomString = (t) => {
|
|
2719
|
+
this.ws = null, this.listeners = {}, this.subscriptions = { request: {}, status: {}, topic: {} }, this._shouldReconnect = !0, this._reconnectAttempt = 0, this._reconnectTimeoutId = null, 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));
|
|
@@ -2724,10 +2724,10 @@ class ct {
|
|
|
2724
2724
|
}, this.distributeMessage = (t) => {
|
|
2725
2725
|
const { correlation_id: r, status: s, topic: i } = t || {}, o = this.subscriptions.request[r];
|
|
2726
2726
|
o && Object.values(o).forEach((l) => l(t));
|
|
2727
|
-
const
|
|
2728
|
-
|
|
2729
|
-
const
|
|
2730
|
-
|
|
2727
|
+
const a = this.subscriptions.status[s];
|
|
2728
|
+
a && Object.values(a).forEach((l) => l(t));
|
|
2729
|
+
const c = this.subscriptions.topic[i];
|
|
2730
|
+
c && Object.values(c).forEach((l) => l(t)), Object.values(this.listeners).forEach((l) => l(t));
|
|
2731
2731
|
}, this.client = e;
|
|
2732
2732
|
}
|
|
2733
2733
|
async executeWithRetry(e, t = 3) {
|
|
@@ -2742,81 +2742,87 @@ class ct {
|
|
|
2742
2742
|
throw new Error("Retry loop failed");
|
|
2743
2743
|
}
|
|
2744
2744
|
scheduleReconnect() {
|
|
2745
|
-
if (!this._shouldReconnect) return;
|
|
2745
|
+
if (!this._shouldReconnect || this._reconnectTimeoutId) return;
|
|
2746
2746
|
const e = Math.min(3e4, 1e3 * 2 ** this._reconnectAttempt);
|
|
2747
|
-
this._reconnectAttempt++, setTimeout(() => {
|
|
2748
|
-
this.
|
|
2749
|
-
|
|
2747
|
+
this._reconnectAttempt++, console.log(`[WPS] Reconnecting in ${e}ms (Attempt ${this._reconnectAttempt})`), this._reconnectTimeoutId = setTimeout(async () => {
|
|
2748
|
+
this._reconnectTimeoutId = null;
|
|
2749
|
+
try {
|
|
2750
|
+
await this.connect();
|
|
2751
|
+
} catch (t) {
|
|
2752
|
+
console.warn("[WPS] Reconnection loop failed to fetch endpoint. Retrying...", t), this.scheduleReconnect();
|
|
2753
|
+
}
|
|
2750
2754
|
}, e);
|
|
2751
2755
|
}
|
|
2752
2756
|
close() {
|
|
2753
2757
|
var e;
|
|
2754
|
-
this._shouldReconnect = !1, this._connectPromise = void 0, (e = this.ws) == null || e.close(), this.ws = null;
|
|
2758
|
+
this._shouldReconnect = !1, this._connectPromise = void 0, this._reconnectTimeoutId && (clearTimeout(this._reconnectTimeoutId), this._reconnectTimeoutId = null), (e = this.ws) == null || e.close(), this.ws = null;
|
|
2755
2759
|
}
|
|
2756
2760
|
async connect() {
|
|
2757
|
-
var e;
|
|
2758
2761
|
if (!this.client.getAccessToken())
|
|
2759
2762
|
throw new Error("Cannot connect to notifications: user is not logged in.");
|
|
2760
|
-
if (!(this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)))
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
this.
|
|
2766
|
-
|
|
2767
|
-
|
|
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);
|
|
2805
|
-
} catch (i) {
|
|
2806
|
-
console.warn("Failed to process notification:", i);
|
|
2763
|
+
if (!(this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)))
|
|
2764
|
+
return this._connectPromise ? this._connectPromise : (this._connectPromise = new Promise(async (e, t) => {
|
|
2765
|
+
let r = !1;
|
|
2766
|
+
try {
|
|
2767
|
+
const s = await this.client.get("/url/notifications"), { url: i } = s.data[0];
|
|
2768
|
+
if (!this._shouldReconnect) {
|
|
2769
|
+
this._connectPromise = void 0, t(new Error("Connection aborted during token generation."));
|
|
2770
|
+
return;
|
|
2807
2771
|
}
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2772
|
+
const o = new WebSocket(i);
|
|
2773
|
+
this.ws = o, o.onopen = () => {
|
|
2774
|
+
this._reconnectAttempt = 0, this._connectPromise = void 0, r = !0, e(), console.log("[WPS] Notification stream successfully connected.");
|
|
2775
|
+
}, o.onmessage = async (a) => {
|
|
2776
|
+
try {
|
|
2777
|
+
const c = JSON.parse(a.data);
|
|
2778
|
+
if (!c.ciphertext) {
|
|
2779
|
+
const { operation_id: w, iv: m, signature: y, topic: C, correlation_id: X, content_type: re, ...se } = c;
|
|
2780
|
+
if (!w)
|
|
2781
|
+
throw new Error("Claim check received but missing operation_id");
|
|
2782
|
+
const T = await this.executeWithRetry(() => this.client.get(`/responses/${w}`, {}, !0)), O = {
|
|
2783
|
+
...se,
|
|
2784
|
+
content_type: re,
|
|
2785
|
+
topic: C,
|
|
2786
|
+
correlation_id: X,
|
|
2787
|
+
ciphertext: T.data,
|
|
2788
|
+
tot_pages: T.tot_pages,
|
|
2789
|
+
has_more: T.has_more,
|
|
2790
|
+
page_num: T.page_num,
|
|
2791
|
+
iv: m,
|
|
2792
|
+
signature: y
|
|
2793
|
+
}, D = await this.client.decryptAndVerify(O);
|
|
2794
|
+
this.distributeMessage(D);
|
|
2795
|
+
return;
|
|
2796
|
+
}
|
|
2797
|
+
const l = c.page_num, f = c.chunk_num, h = c.total_chunks;
|
|
2798
|
+
let u = c;
|
|
2799
|
+
if (h > 1) {
|
|
2800
|
+
this.chunkBuffers[l] || (this.chunkBuffers[l] = {
|
|
2801
|
+
chunks: new Array(h),
|
|
2802
|
+
count: 0,
|
|
2803
|
+
total: h
|
|
2804
|
+
});
|
|
2805
|
+
const w = this.chunkBuffers[l];
|
|
2806
|
+
if (w.chunks[f] === void 0 && (w.chunks[f] = c.ciphertext, w.count++), w.count < w.total) return;
|
|
2807
|
+
u = {
|
|
2808
|
+
...c,
|
|
2809
|
+
ciphertext: w.chunks.join("")
|
|
2810
|
+
}, delete this.chunkBuffers[l];
|
|
2811
|
+
}
|
|
2812
|
+
const g = await this.client.decryptAndVerify(u);
|
|
2813
|
+
this.distributeMessage(g);
|
|
2814
|
+
} catch (c) {
|
|
2815
|
+
console.warn("Failed to process notification:", c);
|
|
2816
|
+
}
|
|
2817
|
+
}, o.onerror = (a) => {
|
|
2818
|
+
console.error("Notifications connection error", a);
|
|
2819
|
+
}, o.onclose = () => {
|
|
2820
|
+
console.log("Notifications socket disconnected"), r || (this._connectPromise = void 0, r = !0, t(new Error("WebSocket disconnected during handshake."))), this.ws === o && (this.ws = null, this.scheduleReconnect());
|
|
2821
|
+
};
|
|
2822
|
+
} catch (s) {
|
|
2823
|
+
this._connectPromise = void 0, r = !0, t(s);
|
|
2824
|
+
}
|
|
2825
|
+
}), this._connectPromise);
|
|
2820
2826
|
}
|
|
2821
2827
|
unsubscribe(e, t, r) {
|
|
2822
2828
|
delete this.subscriptions[e][t][r];
|
|
@@ -2825,12 +2831,12 @@ class ct {
|
|
|
2825
2831
|
delete this.listeners[e];
|
|
2826
2832
|
}
|
|
2827
2833
|
subscribe(e, t, r, s) {
|
|
2828
|
-
let i = s;
|
|
2829
|
-
return
|
|
2834
|
+
let i = s ?? this.generateRandomString(16);
|
|
2835
|
+
return 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);
|
|
2830
2836
|
}
|
|
2831
2837
|
onMessage(e, t) {
|
|
2832
|
-
let r = t;
|
|
2833
|
-
return
|
|
2838
|
+
let r = t ?? this.generateRandomString(16);
|
|
2839
|
+
return this.listeners[r] = e, () => this.unlisten(r);
|
|
2834
2840
|
}
|
|
2835
2841
|
disconnect() {
|
|
2836
2842
|
var e;
|
|
@@ -2890,11 +2896,11 @@ class Os {
|
|
|
2890
2896
|
}
|
|
2891
2897
|
}
|
|
2892
2898
|
async handshake() {
|
|
2893
|
-
const e = await this.clientIdentityKeyPromise, t = Se.utils.randomSecretKey(), r = Se.getPublicKey(t), s =
|
|
2899
|
+
const e = await this.clientIdentityKeyPromise, t = Se.utils.randomSecretKey(), r = Se.getPublicKey(t), s = Vs(r), i = ce(s), o = await crypto.subtle.sign(
|
|
2894
2900
|
{ name: "ECDSA", hash: "SHA-256" },
|
|
2895
2901
|
e,
|
|
2896
2902
|
Ps(s)
|
|
2897
|
-
),
|
|
2903
|
+
), a = Fs(new Uint8Array(o)), c = ce(a), l = await fetch(`${this.baseUrl}/handshake`, {
|
|
2898
2904
|
method: "POST",
|
|
2899
2905
|
headers: {
|
|
2900
2906
|
"Content-Type": "application/json"
|
|
@@ -2903,7 +2909,7 @@ class Os {
|
|
|
2903
2909
|
client_id: this.clientId,
|
|
2904
2910
|
user_id: this.getUserId(),
|
|
2905
2911
|
client_pub: i,
|
|
2906
|
-
client_sig:
|
|
2912
|
+
client_sig: c,
|
|
2907
2913
|
client_alg: "ES256"
|
|
2908
2914
|
})
|
|
2909
2915
|
});
|
|
@@ -2912,16 +2918,16 @@ class Os {
|
|
|
2912
2918
|
const f = await l.json(), { session_id: h, server_pub: u, server_sig: g, session_expires_at: w } = f;
|
|
2913
2919
|
if (window.__akv = { server_pub: u, server_sig: g }, !h || !u || !g)
|
|
2914
2920
|
throw new Error("Handshake response missing fields");
|
|
2915
|
-
const
|
|
2921
|
+
const m = ae(u), y = ae(g);
|
|
2916
2922
|
if (!await Ms(
|
|
2917
2923
|
this.serverPublicKeyPem,
|
|
2918
|
-
|
|
2924
|
+
m,
|
|
2919
2925
|
y
|
|
2920
2926
|
))
|
|
2921
2927
|
throw new Error("Server signature verification failed");
|
|
2922
|
-
const
|
|
2928
|
+
const X = _s(m), re = Se.getSharedSecret(t, X), se = new Uint8Array(0), T = new TextEncoder().encode("health-api-v1"), O = await Cs(re, se, T, 64), D = O.slice(0, 32), be = O.slice(32, 64), fe = await crypto.subtle.importKey(
|
|
2923
2929
|
"raw",
|
|
2924
|
-
|
|
2930
|
+
D,
|
|
2925
2931
|
"AES-GCM",
|
|
2926
2932
|
!1,
|
|
2927
2933
|
["encrypt", "decrypt"]
|
|
@@ -2968,9 +2974,9 @@ class Os {
|
|
|
2968
2974
|
}
|
|
2969
2975
|
async signRequest(e, t, r, s) {
|
|
2970
2976
|
await this.ensureSession();
|
|
2971
|
-
const { sessionId: i, macKey: o } = this.session,
|
|
2977
|
+
const { sessionId: i, macKey: o } = this.session, a = e.toUpperCase() === "GET" ? "" : { data: Array.isArray(r) ? r : [r] }, { ciphertextB64: c, ivB64: l } = await this.encryptBody(a), f = Math.floor(Date.now() / 1e3).toString(), h = t.split("?")[0], u = `${e.toUpperCase()} ${h}
|
|
2972
2978
|
${f}
|
|
2973
|
-
${
|
|
2979
|
+
${c}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), m = new Headers({
|
|
2974
2980
|
...s,
|
|
2975
2981
|
"X-Session-Id": i,
|
|
2976
2982
|
"X-Client-Id": this.clientId,
|
|
@@ -2978,10 +2984,10 @@ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers(
|
|
|
2978
2984
|
"X-Signature": w,
|
|
2979
2985
|
"Content-Type": "application/json"
|
|
2980
2986
|
});
|
|
2981
|
-
return this.getUserId() &&
|
|
2982
|
-
headers:
|
|
2987
|
+
return this.getUserId() && m.append("X-User-Id", this.getUserId()), this.getAccessToken() && !this.isTokenExpired() && m.append("Authorization", `Bearer ${this.getAccessToken()}`), {
|
|
2988
|
+
headers: m,
|
|
2983
2989
|
payload: {
|
|
2984
|
-
content:
|
|
2990
|
+
content: c,
|
|
2985
2991
|
iv: l
|
|
2986
2992
|
}
|
|
2987
2993
|
};
|
|
@@ -3008,14 +3014,14 @@ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers(
|
|
|
3008
3014
|
// --- Paging Methods ---
|
|
3009
3015
|
async get_all_pages_async(e, t, r = {}) {
|
|
3010
3016
|
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 (
|
|
3012
|
-
const { data:
|
|
3017
|
+
this.notifications.subscribe("request", i, async (a) => {
|
|
3018
|
+
const { data: c, ...l } = a;
|
|
3013
3019
|
if (Object.keys(this.pagingBuffer).includes(i) || (this.pagingBuffer[i] = {
|
|
3014
3020
|
pages: new Array(l.tot_pages),
|
|
3015
3021
|
count: 0,
|
|
3016
3022
|
total: l.tot_pages,
|
|
3017
3023
|
data: []
|
|
3018
|
-
}), this.pagingBuffer[i].pages[l.page_num - 1] = l, this.pagingBuffer[i].data.push(...
|
|
3024
|
+
}), this.pagingBuffer[i].pages[l.page_num - 1] = l, this.pagingBuffer[i].data.push(...c), this.pagingBuffer[i].count++, l.tot_pages > l.page_num && l.has_more && this.pagingBuffer[i].count < this.pagingBuffer[i].total) {
|
|
3019
3025
|
let f = e.includes("?") ? "&" : "?";
|
|
3020
3026
|
this.get(`${e}${f}page_num=${l.page_num + 1}`, o);
|
|
3021
3027
|
return;
|
|
@@ -3062,12 +3068,12 @@ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers(
|
|
|
3062
3068
|
const { ciphertext: t, iv: r, signature: s, ...i } = e;
|
|
3063
3069
|
if (!t || !r || !s)
|
|
3064
3070
|
throw new Error("Malformed notification");
|
|
3065
|
-
const { encKey: o, macKey:
|
|
3071
|
+
const { encKey: o, macKey: a } = this.getSession(), c = ae(s), l = await crypto.subtle.sign(
|
|
3066
3072
|
"HMAC",
|
|
3067
|
-
|
|
3073
|
+
a,
|
|
3068
3074
|
new TextEncoder().encode(t)
|
|
3069
3075
|
);
|
|
3070
|
-
if (!this.constantTimeEqual(
|
|
3076
|
+
if (!this.constantTimeEqual(c, new Uint8Array(l)))
|
|
3071
3077
|
throw new Error("Invalid notification signature");
|
|
3072
3078
|
const f = Uint8Array.from(ae(r)), h = Uint8Array.from(ae(t)), u = await crypto.subtle.decrypt(
|
|
3073
3079
|
{ name: "AES-GCM", iv: f },
|
|
@@ -3090,7 +3096,7 @@ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers(
|
|
|
3090
3096
|
refreshToken: void 0
|
|
3091
3097
|
});
|
|
3092
3098
|
const t = {};
|
|
3093
|
-
"username" in e && "password" in e && (t.username = e.username, t.password = e.password, t.scope = e.scope, t.oauth_session = e.oauthSession), "email" in e && "socialLoginId" in e && (t.email = e.email, t.social_login_id = e.socialLoginId, t.scope = e.scope, t.oauth_session = e.oauthSession), "jwt" in e && this.updateSession({
|
|
3099
|
+
"username" in e && "password" in e && (t.username = e.username, t.password = e.password, t.scope = e.scope, t.oauth_session = e.oauthSession), "username" in e && "otp" in e && (t.username = e.username, t.otp = e.otp, t.scope = e.scope, t.oauth_session = e.oauthSession, t.oauth_flow_id = e.oauthFlowId), "email" in e && "socialLoginId" in e && (t.email = e.email, t.social_login_id = e.socialLoginId, t.scope = e.scope, t.oauth_session = e.oauthSession), "jwt" in e && this.updateSession({
|
|
3094
3100
|
accessToken: e.jwt,
|
|
3095
3101
|
tokenType: "Bearer"
|
|
3096
3102
|
}), "refreshToken" in e && (t.refresh_token = e.refreshToken);
|
|
@@ -3098,13 +3104,13 @@ ${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = ce(g), v = new Headers(
|
|
|
3098
3104
|
access_token: s,
|
|
3099
3105
|
token_type: i,
|
|
3100
3106
|
expires_at: o,
|
|
3101
|
-
refresh_token:
|
|
3107
|
+
refresh_token: a
|
|
3102
3108
|
} = r.data[0];
|
|
3103
|
-
return s && this.updateSession({ accessToken: s }), i && this.updateSession({ tokenType: i }), o && this.updateSession({ expiresAt: o }),
|
|
3109
|
+
return s && this.updateSession({ accessToken: s }), i && this.updateSession({ tokenType: i }), o && this.updateSession({ expiresAt: o }), a && this.updateSession({ refreshToken: a }), {
|
|
3104
3110
|
accessToken: s,
|
|
3105
3111
|
tokenType: i,
|
|
3106
3112
|
expiresAt: o,
|
|
3107
|
-
refreshToken:
|
|
3113
|
+
refreshToken: a
|
|
3108
3114
|
};
|
|
3109
3115
|
}
|
|
3110
3116
|
async logout() {
|
|
@@ -3165,9 +3171,9 @@ function Fs(n) {
|
|
|
3165
3171
|
}
|
|
3166
3172
|
return h;
|
|
3167
3173
|
}
|
|
3168
|
-
const i = s(e), o = s(t),
|
|
3174
|
+
const i = s(e), o = s(t), a = 2 + i.length + 2 + o.length, c = new Uint8Array(2 + a);
|
|
3169
3175
|
let l = 0;
|
|
3170
|
-
return
|
|
3176
|
+
return c[l++] = 48, c[l++] = a, c[l++] = 2, c[l++] = i.length, c.set(i, l), l += i.length, c[l++] = 2, c[l++] = o.length, c.set(o, l), c;
|
|
3171
3177
|
}
|
|
3172
3178
|
const js = Symbol("SDK_CLIENT"), Js = {
|
|
3173
3179
|
install(n, e) {
|