@vitia.ai/secure-api-client-vue 0.1.3 → 0.1.5
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 +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -4
- package/dist/index.mjs +674 -596
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
|
3
|
+
function lt(n) {
|
|
4
4
|
return n instanceof Uint8Array || ArrayBuffer.isView(n) && n.constructor.name === "Uint8Array";
|
|
5
5
|
}
|
|
6
|
-
function
|
|
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 (!
|
|
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
|
|
17
|
-
function
|
|
18
|
-
if (Ve(n),
|
|
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
|
|
26
|
-
function
|
|
27
|
-
if (n >=
|
|
28
|
-
return n -
|
|
29
|
-
if (n >=
|
|
30
|
-
return n - (
|
|
31
|
-
if (n >=
|
|
32
|
-
return n - (
|
|
25
|
+
const H = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
26
|
+
function Ze(n) {
|
|
27
|
+
if (n >= H._0 && n <= H._9)
|
|
28
|
+
return n - H._0;
|
|
29
|
+
if (n >= H.A && n <= H.F)
|
|
30
|
+
return n - (H.A - 10);
|
|
31
|
+
if (n >= H.a && n <= H.f)
|
|
32
|
+
return n - (H.a - 10);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function ft(n) {
|
|
35
35
|
if (typeof n != "string")
|
|
36
36
|
throw new Error("hex string expected, got " + typeof n);
|
|
37
|
-
if (
|
|
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 =
|
|
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
|
|
62
|
-
function
|
|
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 === "" ?
|
|
65
|
+
return n === "" ? dt : BigInt("0x" + n);
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
67
|
+
function Yr(n) {
|
|
68
|
+
return gt(ht(n));
|
|
69
69
|
}
|
|
70
70
|
function pe(n) {
|
|
71
|
-
return Ve(n),
|
|
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
|
|
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 =
|
|
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 (
|
|
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" &&
|
|
97
|
-
function
|
|
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 (!
|
|
101
|
+
if (!Qr(e, t, r))
|
|
102
102
|
throw new Error("expected valid " + n + ": " + t + " <= n < " + r + ", got " + e);
|
|
103
103
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
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),
|
|
119
|
+
const x = BigInt(0), p = BigInt(1), F = /* @__PURE__ */ BigInt(2), Bt = /* @__PURE__ */ BigInt(3), bt = /* @__PURE__ */ BigInt(4), vt = /* @__PURE__ */ BigInt(5), rs = /* @__PURE__ */ BigInt(7), kt = /* @__PURE__ */ BigInt(8), ss = /* @__PURE__ */ BigInt(9), mt = /* @__PURE__ */ BigInt(16);
|
|
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,
|
|
138
|
-
r = t, t = a, s = i, i =
|
|
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,25 +145,25 @@ 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
|
|
149
|
-
const t = (n.ORDER + p) /
|
|
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
|
|
153
|
-
const t = (n.ORDER -
|
|
152
|
+
function ns(n, e) {
|
|
153
|
+
const t = (n.ORDER - vt) / kt, r = n.mul(e, F), s = n.pow(r, t), i = n.mul(e, s), o = n.mul(n.mul(i, F), s), c = n.mul(i, n.sub(o, n.ONE));
|
|
154
154
|
return Te(n, c, e), c;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
const e = Ce(n), t =
|
|
156
|
+
function is(n) {
|
|
157
|
+
const e = Ce(n), t = xt(n), r = t(e, e.neg(e.ONE)), s = t(e, r), i = t(e, e.neg(r)), o = (n + rs) / mt;
|
|
158
158
|
return (c, a) => {
|
|
159
|
-
let
|
|
160
|
-
const h = c.mul(
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
return Te(c,
|
|
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
|
|
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;
|
|
@@ -175,32 +175,32 @@ function At(n) {
|
|
|
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
|
|
178
|
+
return At;
|
|
179
179
|
let i = s.pow(r, e);
|
|
180
180
|
const o = (e + p) / F;
|
|
181
|
-
return function(a,
|
|
182
|
-
if (a.is0(
|
|
183
|
-
return
|
|
184
|
-
if (tt(a,
|
|
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),
|
|
187
|
-
for (; !a.eql(
|
|
188
|
-
if (a.is0(
|
|
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,
|
|
191
|
-
for (; !a.eql(
|
|
192
|
-
if (w++,
|
|
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
|
|
195
|
-
f = w, h = a.sqr(
|
|
194
|
+
const y = p << BigInt(f - w - 1), C = a.pow(h, y);
|
|
195
|
+
f = w, h = a.sqr(C), u = a.mul(u, h), g = a.mul(g, C);
|
|
196
196
|
}
|
|
197
197
|
return g;
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
return 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
|
|
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,7 +212,7 @@ 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
|
|
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
|
}
|
|
@@ -222,8 +222,8 @@ function tt(n, e) {
|
|
|
222
222
|
throw new Error("invalid Legendre symbol result");
|
|
223
223
|
return s ? 1 : i ? 0 : -1;
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
e !== void 0 &&
|
|
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
|
}
|
|
@@ -234,171 +234,171 @@ function Ce(n, e, t = !1, r = {}) {
|
|
|
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
|
|
238
|
-
|
|
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:
|
|
242
|
-
if (
|
|
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:
|
|
250
|
-
MASK:
|
|
249
|
+
BYTES: l,
|
|
250
|
+
MASK: es(a),
|
|
251
251
|
ZERO: x,
|
|
252
252
|
ONE: p,
|
|
253
253
|
allowedLengths: c,
|
|
254
|
-
create: (
|
|
255
|
-
isValid: (
|
|
256
|
-
if (typeof
|
|
257
|
-
throw new Error("invalid field element: expected bigint, got " + typeof
|
|
258
|
-
return x <=
|
|
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: (
|
|
260
|
+
is0: (u) => u === x,
|
|
261
261
|
// is valid and invertible
|
|
262
|
-
isValidNot0: (
|
|
263
|
-
isOdd: (
|
|
264
|
-
neg: (
|
|
265
|
-
eql: (
|
|
266
|
-
sqr: (
|
|
267
|
-
add: (
|
|
268
|
-
sub: (
|
|
269
|
-
mul: (
|
|
270
|
-
pow: (
|
|
271
|
-
div: (
|
|
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: (
|
|
274
|
-
addN: (
|
|
275
|
-
subN: (
|
|
276
|
-
mulN: (
|
|
277
|
-
inv: (
|
|
278
|
-
sqrt: i || ((
|
|
279
|
-
toBytes: (
|
|
280
|
-
fromBytes: (
|
|
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(
|
|
283
|
-
throw new Error("Field.fromBytes: expected " + c + " bytes, got " +
|
|
284
|
-
const
|
|
285
|
-
|
|
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 (
|
|
288
|
-
throw new Error("Field.fromBytes: expected " +
|
|
289
|
-
let w = t ? pe(
|
|
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: (
|
|
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: (
|
|
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
|
|
304
|
-
function
|
|
305
|
-
return
|
|
303
|
+
const ne = BigInt(0), z = BigInt(1), de = 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
|
|
311
|
-
const e =
|
|
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,
|
|
315
|
-
function
|
|
316
|
-
return
|
|
314
|
+
const a = o || zr, l = c ? 255 : 448, f = c ? 32 : 56, h = BigInt(c ? 9 : 5), u = BigInt(c ? 121665 : 39081), g = c ? de ** BigInt(254) : de ** BigInt(447), w = c ? BigInt(8) * de ** BigInt(251) - z : BigInt(4) * de ** BigInt(445) - z, v = g + w + z, y = (b) => I(b, t), C = J(h);
|
|
315
|
+
function J(b) {
|
|
316
|
+
return yt(y(b), f);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
const
|
|
320
|
-
return c && (
|
|
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
|
|
323
|
-
return pe(s(Ye("scalar",
|
|
322
|
+
function Be(b) {
|
|
323
|
+
return pe(s(Ye("scalar", b, f)));
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
325
|
+
function re(b, m) {
|
|
326
|
+
const _ = be(te(m), Be(b));
|
|
327
|
+
if (_ === ne)
|
|
328
328
|
throw new Error("invalid private or public key received");
|
|
329
|
-
return
|
|
330
|
-
}
|
|
331
|
-
function
|
|
332
|
-
return
|
|
333
|
-
}
|
|
334
|
-
function
|
|
335
|
-
const
|
|
336
|
-
return
|
|
337
|
-
}
|
|
338
|
-
function be(
|
|
339
|
-
Qe("u",
|
|
340
|
-
const
|
|
341
|
-
let
|
|
342
|
-
for (let ve = BigInt(
|
|
343
|
-
const je =
|
|
344
|
-
|
|
345
|
-
const ke =
|
|
346
|
-
$ =
|
|
347
|
-
}
|
|
348
|
-
({ x_2:
|
|
349
|
-
const
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
const
|
|
329
|
+
return J(_);
|
|
330
|
+
}
|
|
331
|
+
function K(b) {
|
|
332
|
+
return re(b, C);
|
|
333
|
+
}
|
|
334
|
+
function W(b, m, _) {
|
|
335
|
+
const fe = y(b * (m - _));
|
|
336
|
+
return m = y(m - fe), _ = y(_ + fe), { x_2: m, x_3: _ };
|
|
337
|
+
}
|
|
338
|
+
function be(b, m) {
|
|
339
|
+
Qe("u", b, ne, t), Qe("scalar", m, g, v);
|
|
340
|
+
const _ = m, fe = b;
|
|
341
|
+
let M = z, O = ne, $ = b, P = z, X = ne;
|
|
342
|
+
for (let ve = BigInt(l - 1); ve >= ne; ve--) {
|
|
343
|
+
const je = _ >> ve & z;
|
|
344
|
+
X ^= je, { x_2: M, x_3: $ } = W(X, M, $), { x_2: O, x_3: P } = W(X, O, P), X = je;
|
|
345
|
+
const ke = M + O, me = y(ke * ke), Ae = M - O, qe = y(Ae * Ae), Ge = me - qe, Kr = $ + P, Wr = $ - P, Je = y(Wr * ke), Ke = y(Kr * Ae), We = Je + Ke, Xe = Je - Ke;
|
|
346
|
+
$ = y(We * We), P = y(fe * y(Xe * Xe)), M = y(me * qe), O = y(Ge * (me + y(u * Ge)));
|
|
347
|
+
}
|
|
348
|
+
({ x_2: M, x_3: $ } = W(X, M, $)), { x_2: O, x_3: P } = W(X, O, P);
|
|
349
|
+
const Jr = i(O);
|
|
350
|
+
return y(M * Jr);
|
|
351
|
+
}
|
|
352
|
+
const he = {
|
|
353
353
|
secretKey: f,
|
|
354
354
|
publicKey: f,
|
|
355
355
|
seed: f
|
|
356
|
-
},
|
|
357
|
-
function
|
|
358
|
-
const
|
|
359
|
-
return { secretKey:
|
|
356
|
+
}, se = (b = a(f)) => (Ve(b, he.seed), b);
|
|
357
|
+
function Gr(b) {
|
|
358
|
+
const m = se(b);
|
|
359
|
+
return { secretKey: m, publicKey: K(m) };
|
|
360
360
|
}
|
|
361
361
|
return {
|
|
362
|
-
keygen:
|
|
363
|
-
getSharedSecret: (
|
|
364
|
-
getPublicKey: (
|
|
365
|
-
scalarMult:
|
|
366
|
-
scalarMultBase:
|
|
362
|
+
keygen: Gr,
|
|
363
|
+
getSharedSecret: (b, m) => re(b, m),
|
|
364
|
+
getPublicKey: (b) => K(b),
|
|
365
|
+
scalarMult: re,
|
|
366
|
+
scalarMultBase: K,
|
|
367
367
|
utils: {
|
|
368
|
-
randomSecretKey:
|
|
369
|
-
randomPrivateKey:
|
|
368
|
+
randomSecretKey: se,
|
|
369
|
+
randomPrivateKey: se
|
|
370
370
|
},
|
|
371
|
-
GuBytes:
|
|
372
|
-
lengths:
|
|
371
|
+
GuBytes: C.slice(),
|
|
372
|
+
lengths: he
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
375
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
376
|
-
const
|
|
377
|
-
p:
|
|
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:
|
|
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 =
|
|
387
|
-
return { pow_p_5_8: U(
|
|
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
|
|
389
|
+
function bs(n) {
|
|
390
390
|
return n[0] &= 248, n[31] &= 127, n[31] |= 64, n;
|
|
391
391
|
}
|
|
392
|
-
const
|
|
393
|
-
const n =
|
|
394
|
-
return
|
|
392
|
+
const vs = Ce(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,
|
|
399
|
+
return I(U(t, ds, n) * r, n);
|
|
400
400
|
},
|
|
401
|
-
adjustScalarBytes:
|
|
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
|
|
428
|
+
const ks = "[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) === 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",
|
|
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
|
|
511
|
+
class k {
|
|
512
512
|
static isHex(e) {
|
|
513
|
-
return typeof e === Ee &&
|
|
513
|
+
return typeof e === Ee && ms.test(e);
|
|
514
514
|
}
|
|
515
515
|
static isBase64(e) {
|
|
516
|
-
return typeof e === Ee &&
|
|
516
|
+
return typeof e === Ee && As.test(e);
|
|
517
517
|
}
|
|
518
518
|
static isBase64Url(e) {
|
|
519
|
-
return typeof e === Ee &&
|
|
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 (!
|
|
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 (!
|
|
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 =
|
|
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 =
|
|
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 (!
|
|
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
|
-
|
|
679
|
+
k.DEFAULT_UTF8_ENCODING = "utf8";
|
|
680
680
|
/*!
|
|
681
681
|
Copyright (c) Peculiar Ventures, LLC
|
|
682
682
|
*/
|
|
683
|
-
function
|
|
683
|
+
function Y(n, e) {
|
|
684
684
|
let t = 0;
|
|
685
685
|
if (n.length === 1)
|
|
686
686
|
return n[0];
|
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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,12 +731,12 @@ 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 =
|
|
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,
|
|
737
|
+
return i[0] &= 127, Y(i, 8) - r;
|
|
738
738
|
}
|
|
739
|
-
function
|
|
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++) {
|
|
@@ -759,7 +759,7 @@ function xs(n) {
|
|
|
759
759
|
}
|
|
760
760
|
return new ArrayBuffer(0);
|
|
761
761
|
}
|
|
762
|
-
function
|
|
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,7 +810,7 @@ function E(n, e) {
|
|
|
810
810
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
811
811
|
*
|
|
812
812
|
*/
|
|
813
|
-
function
|
|
813
|
+
function ge() {
|
|
814
814
|
if (typeof BigInt > "u")
|
|
815
815
|
throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.");
|
|
816
816
|
}
|
|
@@ -827,7 +827,7 @@ function _e(n) {
|
|
|
827
827
|
}
|
|
828
828
|
return r.buffer;
|
|
829
829
|
}
|
|
830
|
-
function
|
|
830
|
+
function L(n, e, t, r) {
|
|
831
831
|
return e instanceof Uint8Array ? e.byteLength ? t < 0 ? (n.error = "Wrong parameter: inputOffset less than zero", !1) : r < 0 ? (n.error = "Wrong parameter: inputLength less than zero", !1) : e.byteLength - t - r < 0 ? (n.error = "End of input reached before message was fully decoded (inconsistent offset and length values)", !1) : !0 : (n.error = "Wrong parameter: inputBuffer has zero length", !1) : (n.error = "Wrong parameter: inputBuffer must be 'Uint8Array'", !1);
|
|
832
832
|
}
|
|
833
833
|
class He {
|
|
@@ -841,8 +841,8 @@ class He {
|
|
|
841
841
|
return _e(this.items);
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
|
-
const
|
|
845
|
-
function
|
|
844
|
+
const ie = [new Uint8Array([1])], nt = "0123456789", Q = "", T = new ArrayBuffer(0), Le = new Uint8Array(0), ue = "EndOfContent", pt = "OCTET STRING", Nt = "BIT STRING";
|
|
845
|
+
function R(n) {
|
|
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 (!
|
|
862
|
+
if (!L(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,7 +871,7 @@ function L(n) {
|
|
|
871
871
|
return {
|
|
872
872
|
...super.toJSON(),
|
|
873
873
|
isHexOnly: this.isHexOnly,
|
|
874
|
-
valueHex:
|
|
874
|
+
valueHex: k.ToHex(this.valueHexView)
|
|
875
875
|
};
|
|
876
876
|
}
|
|
877
877
|
}, e.NAME = "hexBlock", e;
|
|
@@ -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 =
|
|
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,7 +895,7 @@ class q {
|
|
|
895
895
|
blockLength: this.blockLength,
|
|
896
896
|
error: this.error,
|
|
897
897
|
warnings: this.warnings,
|
|
898
|
-
valueBeforeDecode:
|
|
898
|
+
valueBeforeDecode: k.ToHex(this.valueBeforeDecodeView)
|
|
899
899
|
};
|
|
900
900
|
}
|
|
901
901
|
}
|
|
@@ -909,7 +909,7 @@ class S extends q {
|
|
|
909
909
|
}
|
|
910
910
|
}
|
|
911
911
|
S.NAME = "valueBlock";
|
|
912
|
-
class
|
|
912
|
+
class It extends R(q) {
|
|
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);
|
|
@@ -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 (!
|
|
963
|
+
if (!L(this, s, t, r))
|
|
964
964
|
return -1;
|
|
965
965
|
const i = s.subarray(t, t + r);
|
|
966
966
|
if (i.length === 0)
|
|
@@ -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,
|
|
989
|
+
let a = 1, l = this.valueHexView = new Uint8Array(255), f = 255;
|
|
990
990
|
for (; i[a] & 128; ) {
|
|
991
|
-
if (
|
|
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
|
|
996
|
-
for (let g = 0; g <
|
|
997
|
-
|
|
998
|
-
|
|
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,
|
|
1001
|
+
this.blockLength = a + 1, l[a - 1] = i[a] & 127;
|
|
1002
1002
|
const h = new Uint8Array(a);
|
|
1003
|
-
for (let
|
|
1004
|
-
h[
|
|
1005
|
-
|
|
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
|
-
|
|
1036
|
-
class
|
|
1035
|
+
It.NAME = "identificationBlock";
|
|
1036
|
+
class Ut extends q {
|
|
1037
1037
|
constructor({ lenBlock: e = {} } = {}) {
|
|
1038
1038
|
var t, r, s;
|
|
1039
1039
|
super(), this.isIndefiniteForm = (t = e.isIndefiniteForm) !== null && t !== void 0 ? t : !1, this.longFormUsed = (r = e.longFormUsed) !== null && r !== void 0 ? r : !1, this.length = (s = e.length) !== null && s !== void 0 ? s : 0;
|
|
1040
1040
|
}
|
|
1041
1041
|
fromBER(e, t, r) {
|
|
1042
1042
|
const s = B.toUint8Array(e);
|
|
1043
|
-
if (!
|
|
1043
|
+
if (!L(this, s, t, r))
|
|
1044
1044
|
return -1;
|
|
1045
1045
|
const i = s.subarray(t, t + r);
|
|
1046
1046
|
if (i.length === 0)
|
|
@@ -1057,7 +1057,7 @@ 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 =
|
|
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;
|
|
@@ -1086,11 +1086,11 @@ class It extends q {
|
|
|
1086
1086
|
};
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
|
-
|
|
1089
|
+
Ut.NAME = "lengthBlock";
|
|
1090
1090
|
const d = {};
|
|
1091
1091
|
class A extends q {
|
|
1092
|
-
constructor({ name: e =
|
|
1093
|
-
super(s), this.name = e, this.optional = t, r && (this.primitiveSchema = r), this.idBlock = new
|
|
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 ||
|
|
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() :
|
|
1125
|
+
return e === "ascii" ? this.onAsciiEncoding() : k.ToHex(this.toBER());
|
|
1126
1126
|
}
|
|
1127
1127
|
onAsciiEncoding() {
|
|
1128
|
-
const e = this.constructor.NAME, t =
|
|
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
|
|
1137
|
+
return Es(t, r);
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
1140
|
A.NAME = "BaseBlock";
|
|
1141
|
-
function
|
|
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
|
-
|
|
1145
|
+
Vt(t) && (n.lenBlock.isIndefiniteForm = !0);
|
|
1146
1146
|
return !!(!((e = n.lenBlock) === null || e === void 0) && e.isIndefiniteForm);
|
|
1147
1147
|
}
|
|
1148
|
-
class
|
|
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 =
|
|
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
|
-
|
|
1167
|
-
class
|
|
1166
|
+
Tt.NAME = "BaseStringBlock";
|
|
1167
|
+
class Ct extends R(S) {
|
|
1168
1168
|
constructor({ isHexOnly: e = !0, ...t } = {}) {
|
|
1169
1169
|
super(t), this.isHexOnly = e;
|
|
1170
1170
|
}
|
|
1171
1171
|
}
|
|
1172
|
-
|
|
1173
|
-
var
|
|
1174
|
-
class
|
|
1172
|
+
Ct.NAME = "PrimitiveValueBlock";
|
|
1173
|
+
var _t;
|
|
1174
|
+
class Ht extends A {
|
|
1175
1175
|
constructor(e = {}) {
|
|
1176
|
-
super(e,
|
|
1176
|
+
super(e, Ct), this.idBlock.isConstructed = !1;
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
|
-
|
|
1180
|
-
d.Primitive =
|
|
1181
|
-
|
|
1182
|
-
function
|
|
1179
|
+
_t = Ht;
|
|
1180
|
+
d.Primitive = _t;
|
|
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
|
|
1188
|
+
function ye(n, e = 0, t = n.length) {
|
|
1189
1189
|
const r = e;
|
|
1190
1190
|
let s = new A({}, S);
|
|
1191
1191
|
const i = new q();
|
|
1192
|
-
if (!
|
|
1192
|
+
if (!L(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
|
|
1329
|
-
|
|
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 =
|
|
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
|
|
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
|
|
1352
|
+
return ye(B.toUint8Array(n).slice(), 0, n.byteLength);
|
|
1353
1353
|
}
|
|
1354
|
-
function
|
|
1354
|
+
function Is(n, e) {
|
|
1355
1355
|
return n ? 1 : e;
|
|
1356
1356
|
}
|
|
1357
|
-
class
|
|
1357
|
+
class D 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 (!
|
|
1363
|
+
if (!L(this, s, t, r))
|
|
1364
1364
|
return -1;
|
|
1365
1365
|
if (this.valueBeforeDecodeView = s.subarray(t, t + r), this.valueBeforeDecodeView.length === 0)
|
|
1366
1366
|
return this.warnings.push("Zero buffer length"), t;
|
|
1367
1367
|
let i = t;
|
|
1368
|
-
for (;
|
|
1369
|
-
const o =
|
|
1368
|
+
for (; Is(this.isIndefiniteForm, r) > 0; ) {
|
|
1369
|
+
const o = ye(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 ===
|
|
1372
|
+
if (i = o.offset, this.blockLength += o.result.blockLength, r -= o.result.blockLength, this.value.push(o.result), this.isIndefiniteForm && o.result.constructor.NAME === ue)
|
|
1373
1373
|
break;
|
|
1374
1374
|
}
|
|
1375
|
-
return this.isIndefiniteForm && (this.value[this.value.length - 1].constructor.NAME ===
|
|
1375
|
+
return this.isIndefiniteForm && (this.value[this.value.length - 1].constructor.NAME === ue ? 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
|
-
|
|
1395
|
-
var
|
|
1396
|
-
class
|
|
1394
|
+
D.NAME = "ConstructedValueBlock";
|
|
1395
|
+
var Lt;
|
|
1396
|
+
class ee extends A {
|
|
1397
1397
|
constructor(e = {}) {
|
|
1398
|
-
super(e,
|
|
1398
|
+
super(e, D), 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
|
-
|
|
1418
|
-
d.Constructed =
|
|
1419
|
-
|
|
1420
|
-
class
|
|
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
|
-
|
|
1429
|
-
var
|
|
1430
|
-
class
|
|
1428
|
+
Rt.override = "EndOfContentValueBlock";
|
|
1429
|
+
var Mt;
|
|
1430
|
+
class Ot extends A {
|
|
1431
1431
|
constructor(e = {}) {
|
|
1432
|
-
super(e,
|
|
1432
|
+
super(e, Rt), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 0;
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
|
-
|
|
1436
|
-
d.EndOfContent =
|
|
1437
|
-
|
|
1438
|
-
var
|
|
1439
|
-
class
|
|
1435
|
+
Mt = Ot;
|
|
1436
|
+
d.EndOfContent = Mt;
|
|
1437
|
+
Ot.NAME = ue;
|
|
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
|
-
|
|
1459
|
-
d.Null =
|
|
1460
|
-
|
|
1461
|
-
class
|
|
1458
|
+
Dt = $t;
|
|
1459
|
+
d.Null = Dt;
|
|
1460
|
+
$t.NAME = "NULL";
|
|
1461
|
+
class Pt extends R(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
|
|
1476
|
+
return L(this, s, t, r) ? (this.valueHexView = s.subarray(t, t + r), r > 1 && this.warnings.push("Boolean value encoded in more then 1 octet"), this.isHexOnly = !0, Et.call(this), this.blockLength = r, t + r) : -1;
|
|
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
|
-
|
|
1489
|
-
var
|
|
1490
|
-
class
|
|
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,
|
|
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
|
-
|
|
1505
|
-
d.Boolean =
|
|
1506
|
-
|
|
1507
|
-
class
|
|
1504
|
+
Ft = jt;
|
|
1505
|
+
d.Boolean = Ft;
|
|
1506
|
+
jt.NAME = "BOOLEAN";
|
|
1507
|
+
class qt extends R(D) {
|
|
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 = D.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 ===
|
|
1518
|
+
if (o === ue) {
|
|
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 !==
|
|
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 ?
|
|
1531
|
+
return this.isConstructed ? D.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
|
-
|
|
1540
|
+
qt.NAME = "OctetStringValueBlock";
|
|
1541
1541
|
var Re;
|
|
1542
|
-
class
|
|
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
|
-
},
|
|
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 =
|
|
1564
|
+
const o = ye(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
|
|
1575
|
-
const e = this.constructor.NAME, t =
|
|
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 =
|
|
1587
|
+
Re = Gt;
|
|
1588
1588
|
d.OctetString = Re;
|
|
1589
|
-
|
|
1590
|
-
class
|
|
1589
|
+
Gt.NAME = pt;
|
|
1590
|
+
class Jt extends R(D) {
|
|
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 =
|
|
1599
|
+
if (s = D.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 ===
|
|
1603
|
+
if (a === ue) {
|
|
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 !==
|
|
1608
|
+
if (a !== Nt)
|
|
1609
1609
|
return this.error = "BIT STRING may consists of BIT STRINGs only", -1;
|
|
1610
|
-
const
|
|
1611
|
-
if (this.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 =
|
|
1613
|
+
this.unusedBits = l.unusedBits;
|
|
1614
1614
|
}
|
|
1615
1615
|
return s;
|
|
1616
1616
|
}
|
|
1617
1617
|
const i = B.toUint8Array(e);
|
|
1618
|
-
if (!
|
|
1618
|
+
if (!L(this, i, t, r))
|
|
1619
1619
|
return -1;
|
|
1620
1620
|
const o = i.subarray(t, t + r);
|
|
1621
1621
|
if (this.unusedBits = o[0], this.unusedBits > 7)
|
|
@@ -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 =
|
|
1627
|
+
const a = ye(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
|
|
1637
|
+
return D.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
|
-
|
|
1656
|
-
var
|
|
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
|
-
},
|
|
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
|
|
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
|
-
|
|
1688
|
-
d.BitString =
|
|
1689
|
-
Me.NAME =
|
|
1690
|
-
var
|
|
1691
|
-
function
|
|
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
|
|
1695
|
+
let l = 0;
|
|
1696
1696
|
const f = a < o ? o : a;
|
|
1697
1697
|
let h = 0;
|
|
1698
|
-
for (let
|
|
1698
|
+
for (let u = f; u >= 0; u--, h++) {
|
|
1699
1699
|
switch (!0) {
|
|
1700
1700
|
case h < c.length:
|
|
1701
|
-
|
|
1701
|
+
l = i[o - h] + c[a - h] + t[0];
|
|
1702
1702
|
break;
|
|
1703
1703
|
default:
|
|
1704
|
-
|
|
1704
|
+
l = i[o - h] + t[0];
|
|
1705
1705
|
}
|
|
1706
|
-
switch (t[0] =
|
|
1706
|
+
switch (t[0] = l / 10, !0) {
|
|
1707
1707
|
case h >= i.length:
|
|
1708
|
-
i = Ne(new Uint8Array([
|
|
1708
|
+
i = Ne(new Uint8Array([l % 10]), i);
|
|
1709
1709
|
break;
|
|
1710
1710
|
default:
|
|
1711
|
-
i[o - h] =
|
|
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 >=
|
|
1718
|
-
for (let e =
|
|
1717
|
+
if (n >= ie.length)
|
|
1718
|
+
for (let e = ie.length; e <= n; e++) {
|
|
1719
1719
|
const t = new Uint8Array([0]);
|
|
1720
|
-
let r =
|
|
1720
|
+
let r = ie[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)),
|
|
1725
|
+
t[0] > 0 && (r = Ne(t, r)), ie.push(r);
|
|
1726
1726
|
}
|
|
1727
|
-
return
|
|
1727
|
+
return ie[n];
|
|
1728
1728
|
}
|
|
1729
|
-
function
|
|
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
|
|
1732
|
+
let l, f = 0;
|
|
1733
1733
|
for (let h = a; h >= 0; h--, f++)
|
|
1734
|
-
switch (
|
|
1735
|
-
case
|
|
1736
|
-
t = 1, i[o - f] =
|
|
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] =
|
|
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 (
|
|
1744
|
-
t = 1, i[o - f] =
|
|
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] =
|
|
1746
|
+
t = 0, i[o - f] = l;
|
|
1747
1747
|
break;
|
|
1748
1748
|
}
|
|
1749
1749
|
return i.slice();
|
|
1750
1750
|
}
|
|
1751
|
-
class Oe extends
|
|
1751
|
+
class Oe extends R(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 = 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(
|
|
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
|
|
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 = Vs(it(r), t), o = "-";
|
|
1811
1811
|
break;
|
|
1812
1812
|
default:
|
|
1813
|
-
t =
|
|
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
|
-
|
|
1823
|
+
Wt = Oe;
|
|
1824
1824
|
Oe.NAME = "IntegerValueBlock";
|
|
1825
|
-
Object.defineProperty(
|
|
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
|
|
1833
|
+
var ae;
|
|
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
|
|
1839
|
+
return ge(), BigInt(this.valueBlock.toString());
|
|
1840
1840
|
}
|
|
1841
1841
|
static fromBigInt(e) {
|
|
1842
|
-
|
|
1843
|
-
const t = BigInt(e), r = new He(), s = t.toString(16).replace(/^-/, ""), i = new Uint8Array(
|
|
1842
|
+
ge();
|
|
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
|
|
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
|
|
1851
|
+
return new ae({ valueHex: r.final() });
|
|
1852
1852
|
}
|
|
1853
1853
|
convertToDER() {
|
|
1854
|
-
const e = new
|
|
1854
|
+
const e = new ae({ valueHex: this.valueBlock.valueHexView });
|
|
1855
1855
|
return e.valueBlock.toDER(), e;
|
|
1856
1856
|
}
|
|
1857
1857
|
convertFromDER() {
|
|
1858
|
-
return new
|
|
1858
|
+
return new ae({
|
|
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
|
-
|
|
1867
|
-
d.Integer =
|
|
1866
|
+
ae = De;
|
|
1867
|
+
d.Integer = ae;
|
|
1868
1868
|
De.NAME = "INTEGER";
|
|
1869
|
-
var
|
|
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
|
-
|
|
1876
|
-
d.Enumerated =
|
|
1875
|
+
Xt = Zt;
|
|
1876
|
+
d.Enumerated = Xt;
|
|
1877
1877
|
Zt.NAME = "ENUMERATED";
|
|
1878
|
-
class Ie extends
|
|
1878
|
+
class Ie extends R(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 (!
|
|
1886
|
+
if (!L(this, s, t, r))
|
|
1887
1887
|
return -1;
|
|
1888
1888
|
const i = s.subarray(t, t + r);
|
|
1889
1889
|
this.valueHexView = new Uint8Array(r);
|
|
@@ -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 =
|
|
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
|
-
|
|
1898
|
+
ge();
|
|
1899
1899
|
let t = BigInt(e).toString(2);
|
|
1900
1900
|
for (; t.length % 7; )
|
|
1901
1901
|
t = "0" + t;
|
|
@@ -1928,7 +1928,7 @@ class Ie extends L(S) {
|
|
|
1928
1928
|
toString() {
|
|
1929
1929
|
let e = "";
|
|
1930
1930
|
if (this.isHexOnly)
|
|
1931
|
-
e =
|
|
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 =
|
|
1949
|
+
constructor({ value: e = Q, ...t } = {}) {
|
|
1950
1950
|
super(t), this.value = [], e && this.fromString(e);
|
|
1951
1951
|
}
|
|
1952
1952
|
fromBER(e, t, r) {
|
|
@@ -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
|
-
|
|
1999
|
+
ge();
|
|
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
|
|
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
|
-
|
|
2051
|
-
d.ObjectIdentifier =
|
|
2050
|
+
Yt = $e;
|
|
2051
|
+
d.ObjectIdentifier = Yt;
|
|
2052
2052
|
$e.NAME = "OBJECT IDENTIFIER";
|
|
2053
|
-
class Ue extends
|
|
2053
|
+
class Ue extends R(q) {
|
|
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 (!
|
|
2061
|
+
if (!L(this, s, t, r))
|
|
2062
2062
|
return -1;
|
|
2063
2063
|
const i = s.subarray(t, t + r);
|
|
2064
2064
|
this.valueHexView = new Uint8Array(r);
|
|
@@ -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 =
|
|
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) {
|
|
@@ -2092,7 +2092,7 @@ class Ue extends L(q) {
|
|
|
2092
2092
|
}
|
|
2093
2093
|
toString() {
|
|
2094
2094
|
let e = "";
|
|
2095
|
-
return this.isHexOnly ? 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
|
|
2106
|
-
constructor({ value: e =
|
|
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) {
|
|
@@ -2158,9 +2158,9 @@ class Yt extends S {
|
|
|
2158
2158
|
return e;
|
|
2159
2159
|
}
|
|
2160
2160
|
}
|
|
2161
|
-
|
|
2162
|
-
var
|
|
2163
|
-
class
|
|
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,
|
|
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
|
-
|
|
2184
|
-
d.RelativeObjectIdentifier =
|
|
2185
|
-
|
|
2186
|
-
var
|
|
2187
|
-
class
|
|
2183
|
+
er = tr;
|
|
2184
|
+
d.RelativeObjectIdentifier = er;
|
|
2185
|
+
tr.NAME = "RelativeObjectIdentifier";
|
|
2186
|
+
var rr;
|
|
2187
|
+
class we extends ee {
|
|
2188
2188
|
constructor(e = {}) {
|
|
2189
2189
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 16;
|
|
2190
2190
|
}
|
|
2191
2191
|
}
|
|
2192
|
-
|
|
2193
|
-
d.Sequence =
|
|
2194
|
-
|
|
2195
|
-
var
|
|
2196
|
-
class
|
|
2192
|
+
rr = we;
|
|
2193
|
+
d.Sequence = rr;
|
|
2194
|
+
we.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
|
-
|
|
2202
|
-
d.Set =
|
|
2203
|
-
|
|
2204
|
-
class
|
|
2201
|
+
sr = nr;
|
|
2202
|
+
d.Set = sr;
|
|
2203
|
+
nr.NAME = "SET";
|
|
2204
|
+
class ir extends R(S) {
|
|
2205
2205
|
constructor({ ...e } = {}) {
|
|
2206
|
-
super(e), this.isHexOnly = !0, this.value =
|
|
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
|
-
|
|
2216
|
-
class
|
|
2215
|
+
ir.NAME = "StringValueBlock";
|
|
2216
|
+
class or extends ir {
|
|
2217
2217
|
}
|
|
2218
|
-
|
|
2219
|
-
class N extends
|
|
2218
|
+
or.NAME = "SimpleStringValueBlock";
|
|
2219
|
+
class N extends Tt {
|
|
2220
2220
|
constructor({ ...e } = {}) {
|
|
2221
|
-
super(e,
|
|
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
|
|
2234
|
+
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 = k.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 = k.ToBinary(e);
|
|
2241
2241
|
}
|
|
2242
2242
|
}
|
|
2243
2243
|
fromString(e) {
|
|
2244
|
-
this.valueBlock.valueHexView = new Uint8Array(
|
|
2244
|
+
this.valueBlock.valueHexView = new Uint8Array(k.FromUtf8String(e)), this.valueBlock.value = e;
|
|
2245
2245
|
}
|
|
2246
2246
|
}
|
|
2247
|
-
|
|
2248
|
-
var
|
|
2249
|
-
class G extends
|
|
2247
|
+
cr.NAME = "Utf8StringValueBlock";
|
|
2248
|
+
var ar;
|
|
2249
|
+
class G extends cr {
|
|
2250
2250
|
constructor(e = {}) {
|
|
2251
2251
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 12;
|
|
2252
2252
|
}
|
|
2253
2253
|
}
|
|
2254
|
-
|
|
2255
|
-
d.Utf8String =
|
|
2254
|
+
ar = G;
|
|
2255
|
+
d.Utf8String = ar;
|
|
2256
2256
|
G.NAME = "UTF8String";
|
|
2257
|
-
class
|
|
2257
|
+
class lr extends N {
|
|
2258
2258
|
fromBuffer(e) {
|
|
2259
|
-
this.valueBlock.value =
|
|
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(
|
|
2262
|
+
this.valueBlock.value = e, this.valueBlock.valueHexView = new Uint8Array(k.FromUtf16String(e));
|
|
2263
2263
|
}
|
|
2264
2264
|
}
|
|
2265
|
-
|
|
2266
|
-
var
|
|
2267
|
-
class
|
|
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
|
-
|
|
2273
|
-
d.BmpString =
|
|
2274
|
-
|
|
2275
|
-
class
|
|
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)
|
|
@@ -2292,98 +2292,98 @@ class hr extends N {
|
|
|
2292
2292
|
this.valueBlock.value = e;
|
|
2293
2293
|
}
|
|
2294
2294
|
}
|
|
2295
|
-
|
|
2296
|
-
var
|
|
2297
|
-
class
|
|
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
|
-
|
|
2303
|
-
d.UniversalString =
|
|
2304
|
-
|
|
2305
|
-
var
|
|
2306
|
-
class
|
|
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
|
-
|
|
2312
|
-
d.NumericString =
|
|
2313
|
-
|
|
2311
|
+
wr = yr;
|
|
2312
|
+
d.NumericString = wr;
|
|
2313
|
+
yr.NAME = "NumericString";
|
|
2314
2314
|
var Br;
|
|
2315
|
-
class
|
|
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 =
|
|
2320
|
+
Br = br;
|
|
2321
2321
|
d.PrintableString = Br;
|
|
2322
|
-
|
|
2323
|
-
var
|
|
2324
|
-
class
|
|
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
|
-
|
|
2330
|
-
d.TeletexString =
|
|
2331
|
-
|
|
2332
|
-
var
|
|
2333
|
-
class
|
|
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
|
-
|
|
2339
|
-
d.VideotexString =
|
|
2340
|
-
|
|
2341
|
-
var
|
|
2342
|
-
class
|
|
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
|
-
|
|
2348
|
-
d.IA5String =
|
|
2349
|
-
|
|
2350
|
-
var
|
|
2351
|
-
class
|
|
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
|
-
|
|
2357
|
-
d.GraphicString =
|
|
2358
|
-
|
|
2359
|
-
var
|
|
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
|
-
|
|
2366
|
-
d.VisibleString =
|
|
2365
|
+
Nr = Pe;
|
|
2366
|
+
d.VisibleString = Nr;
|
|
2367
2367
|
Pe.NAME = "VisibleString";
|
|
2368
|
-
var
|
|
2369
|
-
class
|
|
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
|
-
|
|
2375
|
-
d.GeneralString =
|
|
2376
|
-
|
|
2377
|
-
var
|
|
2378
|
-
class
|
|
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
|
-
|
|
2384
|
-
d.CharacterString =
|
|
2385
|
-
|
|
2386
|
-
var
|
|
2383
|
+
Vr = Tr;
|
|
2384
|
+
d.CharacterString = Vr;
|
|
2385
|
+
Tr.NAME = "CharacterString";
|
|
2386
|
+
var Cr;
|
|
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
|
-
|
|
2443
|
-
d.UTCTime =
|
|
2442
|
+
Cr = Fe;
|
|
2443
|
+
d.UTCTime = Cr;
|
|
2444
2444
|
Fe.NAME = "UTCTime";
|
|
2445
|
-
var
|
|
2446
|
-
class
|
|
2445
|
+
var _r;
|
|
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,
|
|
2475
|
-
if (
|
|
2476
|
-
if (g = r.substring(
|
|
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
|
|
2489
|
-
if (
|
|
2490
|
-
const h = new Number(`0${r.substring(
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
2568
|
-
d.GeneralizedTime =
|
|
2569
|
-
|
|
2570
|
-
var
|
|
2571
|
-
class
|
|
2567
|
+
_r = Hr;
|
|
2568
|
+
d.GeneralizedTime = _r;
|
|
2569
|
+
Hr.NAME = "GeneralizedTime";
|
|
2570
|
+
var Lr;
|
|
2571
|
+
class Rr extends G {
|
|
2572
2572
|
constructor(e = {}) {
|
|
2573
2573
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 31;
|
|
2574
2574
|
}
|
|
2575
2575
|
}
|
|
2576
|
-
|
|
2577
|
-
d.DATE =
|
|
2578
|
-
|
|
2579
|
-
var
|
|
2580
|
-
class
|
|
2576
|
+
Lr = Rr;
|
|
2577
|
+
d.DATE = Lr;
|
|
2578
|
+
Rr.NAME = "DATE";
|
|
2579
|
+
var Mr;
|
|
2580
|
+
class Or extends G {
|
|
2581
2581
|
constructor(e = {}) {
|
|
2582
2582
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 32;
|
|
2583
2583
|
}
|
|
2584
2584
|
}
|
|
2585
|
-
|
|
2586
|
-
d.TimeOfDay =
|
|
2587
|
-
|
|
2588
|
-
var
|
|
2589
|
-
class
|
|
2585
|
+
Mr = Or;
|
|
2586
|
+
d.TimeOfDay = Mr;
|
|
2587
|
+
Or.NAME = "TimeOfDay";
|
|
2588
|
+
var Dr;
|
|
2589
|
+
class $r extends G {
|
|
2590
2590
|
constructor(e = {}) {
|
|
2591
2591
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 33;
|
|
2592
2592
|
}
|
|
2593
2593
|
}
|
|
2594
|
-
|
|
2595
|
-
d.DateTime =
|
|
2596
|
-
|
|
2597
|
-
var
|
|
2598
|
-
class
|
|
2594
|
+
Dr = $r;
|
|
2595
|
+
d.DateTime = Dr;
|
|
2596
|
+
$r.NAME = "DateTime";
|
|
2597
|
+
var Pr;
|
|
2598
|
+
class Fr extends G {
|
|
2599
2599
|
constructor(e = {}) {
|
|
2600
2600
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 34;
|
|
2601
2601
|
}
|
|
2602
2602
|
}
|
|
2603
|
-
|
|
2604
|
-
d.Duration =
|
|
2605
|
-
|
|
2606
|
-
var
|
|
2607
|
-
class
|
|
2603
|
+
Pr = Fr;
|
|
2604
|
+
d.Duration = Pr;
|
|
2605
|
+
Fr.NAME = "Duration";
|
|
2606
|
+
var jr;
|
|
2607
|
+
class qr extends G {
|
|
2608
2608
|
constructor(e = {}) {
|
|
2609
2609
|
super(e), this.idBlock.tagClass = 1, this.idBlock.tagNumber = 14;
|
|
2610
2610
|
}
|
|
2611
2611
|
}
|
|
2612
|
-
|
|
2613
|
-
d.TIME =
|
|
2614
|
-
|
|
2615
|
-
function
|
|
2616
|
-
const e = n.slice().buffer, t = new
|
|
2612
|
+
jr = qr;
|
|
2613
|
+
d.TIME = jr;
|
|
2614
|
+
qr.NAME = "TIME";
|
|
2615
|
+
function Ts(n) {
|
|
2616
|
+
const e = n.slice().buffer, t = new we({
|
|
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
|
|
2621
|
+
}), s = new we({
|
|
2622
2622
|
value: [t, r]
|
|
2623
2623
|
});
|
|
2624
2624
|
return new Uint8Array(s.toBER());
|
|
2625
2625
|
}
|
|
2626
|
-
function
|
|
2627
|
-
const e = n.slice().buffer, s =
|
|
2626
|
+
function Cs(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
|
|
2630
|
+
function oe(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
|
|
2636
|
+
function ce(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
|
|
2650
|
+
function le(n) {
|
|
2651
2651
|
return n.buffer;
|
|
2652
2652
|
}
|
|
2653
|
-
async function
|
|
2653
|
+
async function _s(n, e, t, r) {
|
|
2654
2654
|
const s = await crypto.subtle.importKey(
|
|
2655
2655
|
"raw",
|
|
2656
|
-
|
|
2656
|
+
le(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:
|
|
2665
|
-
info:
|
|
2664
|
+
salt: le(e),
|
|
2665
|
+
info: le(t)
|
|
2666
2666
|
},
|
|
2667
2667
|
s,
|
|
2668
2668
|
r * 8
|
|
2669
2669
|
);
|
|
2670
2670
|
return new Uint8Array(i);
|
|
2671
2671
|
}
|
|
2672
|
-
async function
|
|
2672
|
+
async function Hs(n) {
|
|
2673
2673
|
return crypto.subtle.importKey(
|
|
2674
2674
|
"raw",
|
|
2675
|
-
|
|
2675
|
+
le(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
|
|
2684
|
+
async function Ls(n, e) {
|
|
2685
2685
|
const t = await crypto.subtle.sign(
|
|
2686
2686
|
"HMAC",
|
|
2687
2687
|
n,
|
|
2688
|
-
|
|
2688
|
+
le(e)
|
|
2689
2689
|
);
|
|
2690
2690
|
return new Uint8Array(t);
|
|
2691
2691
|
}
|
|
2692
|
-
function
|
|
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
|
|
2700
|
-
const r =
|
|
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
|
|
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,49 @@ class Ms {
|
|
|
2737
2755
|
}
|
|
2738
2756
|
async connect() {
|
|
2739
2757
|
var e;
|
|
2740
|
-
if (
|
|
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
|
|
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
|
|
2765
|
+
this._reconnectAttempt = 0;
|
|
2748
2766
|
}, this.ws.onmessage = async (s) => {
|
|
2749
2767
|
try {
|
|
2750
|
-
const i = JSON.parse(s.data)
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
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, ...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)), J = {
|
|
2774
|
+
...y,
|
|
2775
|
+
topic: w,
|
|
2776
|
+
correlation_id: v,
|
|
2777
|
+
ciphertext: C.data,
|
|
2778
|
+
iv: u,
|
|
2779
|
+
signature: g
|
|
2780
|
+
}, te = await this.client.decryptAndVerify(J);
|
|
2781
|
+
this.distributeMessage(te);
|
|
2782
|
+
return;
|
|
2783
|
+
}
|
|
2784
|
+
const o = i.page_id, c = i.chunk_num, a = i.total_chunks;
|
|
2785
|
+
let l = i;
|
|
2786
|
+
if (a > 1) {
|
|
2787
|
+
this.chunkBuffers[o] || (this.chunkBuffers[o] = {
|
|
2788
|
+
chunks: new Array(a),
|
|
2789
|
+
count: 0,
|
|
2790
|
+
total: a
|
|
2791
|
+
});
|
|
2792
|
+
const h = this.chunkBuffers[o];
|
|
2793
|
+
if (h.chunks[c] === void 0 && (h.chunks[c] = i.ciphertext, h.count++), h.count < h.total) return;
|
|
2794
|
+
l = {
|
|
2795
|
+
...i,
|
|
2796
|
+
ciphertext: h.chunks.join("")
|
|
2797
|
+
}, delete this.chunkBuffers[o];
|
|
2798
|
+
}
|
|
2799
|
+
const f = await this.client.decryptAndVerify(l);
|
|
2800
|
+
this.distributeMessage(f);
|
|
2756
2801
|
} catch (i) {
|
|
2757
2802
|
console.warn("Failed to process notification:", i);
|
|
2758
2803
|
}
|
|
@@ -2769,15 +2814,15 @@ class Ms {
|
|
|
2769
2814
|
}
|
|
2770
2815
|
}
|
|
2771
2816
|
}
|
|
2772
|
-
|
|
2817
|
+
unsubscribe(e, t, r) {
|
|
2773
2818
|
delete this.subscriptions[e][t][r];
|
|
2774
2819
|
}
|
|
2775
2820
|
unlisten(e) {
|
|
2776
2821
|
delete this.listeners[e];
|
|
2777
2822
|
}
|
|
2778
|
-
|
|
2823
|
+
subscribe(e, t, r, s) {
|
|
2779
2824
|
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.
|
|
2825
|
+
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
2826
|
}
|
|
2782
2827
|
onMessage(e, t) {
|
|
2783
2828
|
let r = t;
|
|
@@ -2788,16 +2833,16 @@ class Ms {
|
|
|
2788
2833
|
(e = this.ws) == null || e.close(), this.ws = null;
|
|
2789
2834
|
}
|
|
2790
2835
|
}
|
|
2791
|
-
const
|
|
2836
|
+
const at = "secure_api_session_v1";
|
|
2792
2837
|
class Os {
|
|
2793
2838
|
constructor(e) {
|
|
2794
|
-
this.session = null, this.baseUrl = e.baseUrl, this.clientId = e.clientId, this.serverPublicKeyPem = e.serverPublicKeyPem, this.clientIdentityKeyPromise = $s(
|
|
2839
|
+
this.session = null, this.pagingBuffer = {}, this.baseUrl = e.baseUrl, this.clientId = e.clientId, this.serverPublicKeyPem = e.serverPublicKeyPem, this.clientIdentityKeyPromise = $s(
|
|
2795
2840
|
e.clientIdentityPrivateKeyPem
|
|
2796
|
-
), this.loadPersistedSession(), this.notifications = new
|
|
2841
|
+
), this.loadPersistedSession(), this.notifications = new ct(this), this.pagingBuffer = {};
|
|
2797
2842
|
}
|
|
2798
2843
|
loadPersistedSession() {
|
|
2799
2844
|
try {
|
|
2800
|
-
const e = localStorage.getItem(
|
|
2845
|
+
const e = localStorage.getItem(at);
|
|
2801
2846
|
if (!e) return;
|
|
2802
2847
|
const t = JSON.parse(e);
|
|
2803
2848
|
if (!t) return;
|
|
@@ -2836,16 +2881,16 @@ class Os {
|
|
|
2836
2881
|
expiresAt: e.expiresAt,
|
|
2837
2882
|
refreshToken: e.refreshToken
|
|
2838
2883
|
} : {};
|
|
2839
|
-
localStorage.setItem(
|
|
2884
|
+
localStorage.setItem(at, JSON.stringify(t));
|
|
2840
2885
|
} catch {
|
|
2841
2886
|
}
|
|
2842
2887
|
}
|
|
2843
2888
|
async handshake() {
|
|
2844
|
-
const e = await this.clientIdentityKeyPromise, t = Se.utils.randomSecretKey(), r = Se.getPublicKey(t), s =
|
|
2889
|
+
const e = await this.clientIdentityKeyPromise, t = Se.utils.randomSecretKey(), r = Se.getPublicKey(t), s = Ts(r), i = oe(s), o = await crypto.subtle.sign(
|
|
2845
2890
|
{ name: "ECDSA", hash: "SHA-256" },
|
|
2846
2891
|
e,
|
|
2847
2892
|
Ps(s)
|
|
2848
|
-
), c = Fs(new Uint8Array(o)), a =
|
|
2893
|
+
), c = Fs(new Uint8Array(o)), a = oe(c), l = await fetch(`${this.baseUrl}/handshake`, {
|
|
2849
2894
|
method: "POST",
|
|
2850
2895
|
headers: {
|
|
2851
2896
|
"Content-Type": "application/json"
|
|
@@ -2858,29 +2903,29 @@ class Os {
|
|
|
2858
2903
|
client_alg: "ES256"
|
|
2859
2904
|
})
|
|
2860
2905
|
});
|
|
2861
|
-
if (!
|
|
2862
|
-
throw new Error(`Handshake failed: ${
|
|
2863
|
-
const f = await
|
|
2864
|
-
if (window.__akv = { server_pub:
|
|
2906
|
+
if (!l.ok)
|
|
2907
|
+
throw new Error(`Handshake failed: ${l.status} ${l.statusText}`);
|
|
2908
|
+
const f = await l.json(), { session_id: h, server_pub: u, server_sig: g, session_expires_at: w } = f;
|
|
2909
|
+
if (window.__akv = { server_pub: u, server_sig: g }, !h || !u || !g)
|
|
2865
2910
|
throw new Error("Handshake response missing fields");
|
|
2866
|
-
const
|
|
2867
|
-
if (!await
|
|
2911
|
+
const v = ce(u), y = ce(g);
|
|
2912
|
+
if (!await Ms(
|
|
2868
2913
|
this.serverPublicKeyPem,
|
|
2869
|
-
|
|
2870
|
-
|
|
2914
|
+
v,
|
|
2915
|
+
y
|
|
2871
2916
|
))
|
|
2872
2917
|
throw new Error("Server signature verification failed");
|
|
2873
|
-
const
|
|
2918
|
+
const J = Cs(v), te = Se.getSharedSecret(t, J), Be = new Uint8Array(0), re = new TextEncoder().encode("health-api-v1"), K = await _s(te, Be, re, 64), W = K.slice(0, 32), be = K.slice(32, 64), he = await crypto.subtle.importKey(
|
|
2874
2919
|
"raw",
|
|
2875
|
-
|
|
2920
|
+
W,
|
|
2876
2921
|
"AES-GCM",
|
|
2877
2922
|
!1,
|
|
2878
2923
|
["encrypt", "decrypt"]
|
|
2879
|
-
),
|
|
2924
|
+
), se = await Hs(be);
|
|
2880
2925
|
this.updateSession({
|
|
2881
2926
|
sessionId: h,
|
|
2882
|
-
encKey:
|
|
2883
|
-
macKey:
|
|
2927
|
+
encKey: he,
|
|
2928
|
+
macKey: se,
|
|
2884
2929
|
sessionExpiresAt: w
|
|
2885
2930
|
});
|
|
2886
2931
|
}
|
|
@@ -2913,50 +2958,75 @@ class Os {
|
|
|
2913
2958
|
s
|
|
2914
2959
|
);
|
|
2915
2960
|
return {
|
|
2916
|
-
ciphertextB64:
|
|
2917
|
-
ivB64:
|
|
2961
|
+
ciphertextB64: oe(new Uint8Array(i)),
|
|
2962
|
+
ivB64: oe(r)
|
|
2918
2963
|
};
|
|
2919
2964
|
}
|
|
2920
|
-
async signRequest(e, t, r) {
|
|
2965
|
+
async signRequest(e, t, r, s) {
|
|
2921
2966
|
await this.ensureSession();
|
|
2922
|
-
const { sessionId:
|
|
2923
|
-
let
|
|
2924
|
-
|
|
2925
|
-
const
|
|
2926
|
-
${
|
|
2927
|
-
${
|
|
2928
|
-
|
|
2967
|
+
const { sessionId: i, macKey: o } = this.session, c = e.toUpperCase() === "GET" ? "" : { data: Array.isArray(r) ? r : [r] }, { ciphertextB64: a, ivB64: l } = await this.encryptBody(c), f = Math.floor(Date.now() / 1e3).toString();
|
|
2968
|
+
let h = t;
|
|
2969
|
+
h.includes("?") && (h = h.split("?")[0]);
|
|
2970
|
+
const u = `${e.toUpperCase()} ${h}
|
|
2971
|
+
${f}
|
|
2972
|
+
${a}`, g = await Ls(o, new TextEncoder().encode(u)), w = oe(g), v = new Headers({
|
|
2973
|
+
...s,
|
|
2974
|
+
"X-Session-Id": i,
|
|
2929
2975
|
"X-Client-Id": this.clientId,
|
|
2930
|
-
"X-Timestamp":
|
|
2931
|
-
"X-Signature":
|
|
2976
|
+
"X-Timestamp": f,
|
|
2977
|
+
"X-Signature": w,
|
|
2932
2978
|
"Content-Type": "application/json"
|
|
2933
2979
|
});
|
|
2934
|
-
return this.getUserId() &&
|
|
2935
|
-
headers:
|
|
2980
|
+
return this.getUserId() && v.append("X-User-Id", this.getUserId()), this.getAccessToken() && !this.isTokenExpired() && v.append("Authorization", `Bearer ${this.getAccessToken()}`), {
|
|
2981
|
+
headers: v,
|
|
2936
2982
|
payload: {
|
|
2937
|
-
content:
|
|
2938
|
-
iv:
|
|
2983
|
+
content: a,
|
|
2984
|
+
iv: l
|
|
2939
2985
|
}
|
|
2940
2986
|
};
|
|
2941
2987
|
}
|
|
2942
|
-
async get(e) {
|
|
2943
|
-
const { headers:
|
|
2988
|
+
async get(e, t, r) {
|
|
2989
|
+
const { headers: s } = await this.signRequest("GET", e, null, t), i = await fetch(`${this.baseUrl}${e}`, {
|
|
2944
2990
|
method: "GET",
|
|
2945
|
-
headers:
|
|
2991
|
+
headers: s
|
|
2946
2992
|
});
|
|
2947
|
-
if (!
|
|
2948
|
-
throw new Error(`GET ${e} failed: ${
|
|
2949
|
-
return this.decryptAndVerify(await
|
|
2993
|
+
if (!i.ok)
|
|
2994
|
+
throw new Error(`GET ${e} failed: ${i.status} ${i.statusText}`);
|
|
2995
|
+
return r ? await i.json() : this.decryptAndVerify(await i.json());
|
|
2950
2996
|
}
|
|
2951
|
-
async post(e, t) {
|
|
2952
|
-
const { headers:
|
|
2997
|
+
async post(e, t, r) {
|
|
2998
|
+
const { headers: s, payload: i } = await this.signRequest("POST", e, t, r), o = await fetch(`${this.baseUrl}${e}`, {
|
|
2953
2999
|
method: "POST",
|
|
2954
|
-
headers:
|
|
2955
|
-
body: JSON.stringify(
|
|
3000
|
+
headers: s,
|
|
3001
|
+
body: JSON.stringify(i)
|
|
2956
3002
|
});
|
|
2957
|
-
if (!
|
|
2958
|
-
throw new Error(`POST ${e} failed: ${
|
|
2959
|
-
return e.endsWith("/handshake") ? await
|
|
3003
|
+
if (!o.ok)
|
|
3004
|
+
throw new Error(`POST ${e} failed: ${o.status} ${o.statusText}`);
|
|
3005
|
+
return e.endsWith("/handshake") ? await o.json() : this.decryptAndVerify(await o.json());
|
|
3006
|
+
}
|
|
3007
|
+
// --- Paging Methods ---
|
|
3008
|
+
async get_all_pages_async(e, t, r = {}) {
|
|
3009
|
+
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 };
|
|
3010
|
+
this.notifications.subscribe("request", i, async (c) => {
|
|
3011
|
+
const { data: a, ...l } = c;
|
|
3012
|
+
if (Object.keys(this.pagingBuffer).includes(i) || (this.pagingBuffer[i] = {
|
|
3013
|
+
pages: new Array(l.pages),
|
|
3014
|
+
count: 0,
|
|
3015
|
+
total: l.pages
|
|
3016
|
+
}), this.pagingBuffer[i].pages[l.page - 1] = l, this.pagingBuffer[i].count++, l.pages > l.page && l.next_page && this.pagingBuffer[i].count < this.pagingBuffer[i].total) {
|
|
3017
|
+
this.get(`/signal/paging/${l.next_page}`, o);
|
|
3018
|
+
return;
|
|
3019
|
+
}
|
|
3020
|
+
if (t) return t(this.pagingBuffer[i].pages);
|
|
3021
|
+
}), await this.get(e, o);
|
|
3022
|
+
}
|
|
3023
|
+
async get_all_pages_sync(e, t = {}) {
|
|
3024
|
+
const r = t ? { ...t, "X-Force-Sync": !0 } : { "X-Force-Sync": !0 };
|
|
3025
|
+
let s = await this.get(e, r);
|
|
3026
|
+
const i = [s];
|
|
3027
|
+
for (; s.pages > s.page && s.next_page; )
|
|
3028
|
+
s = await this.get(`/signal/paging/${s.next_page}`, { ...t, "X-Force-Sync": !0 }), i.push(s);
|
|
3029
|
+
return i;
|
|
2960
3030
|
}
|
|
2961
3031
|
async ensureSession() {
|
|
2962
3032
|
var t, r, s;
|
|
@@ -2968,7 +3038,7 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
|
|
|
2968
3038
|
await this.post("/handshake/extend", {}).then(async (e) => {
|
|
2969
3039
|
var t;
|
|
2970
3040
|
e && (e.session_id !== ((t = this.session) == null ? void 0 : t.sessionId) ? await this.handshake() : this.updateSession({
|
|
2971
|
-
sessionExpiresAt: e.session_expires_at
|
|
3041
|
+
sessionExpiresAt: e.data[0].session_expires_at
|
|
2972
3042
|
}));
|
|
2973
3043
|
}).catch(async (e) => {
|
|
2974
3044
|
await this.handshake();
|
|
@@ -2978,18 +3048,18 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
|
|
|
2978
3048
|
const { ciphertext: t, iv: r, signature: s, ...i } = e;
|
|
2979
3049
|
if (!t || !r || !s)
|
|
2980
3050
|
throw new Error("Malformed notification");
|
|
2981
|
-
const { encKey: o, macKey: c } = this.getSession(), a =
|
|
3051
|
+
const { encKey: o, macKey: c } = this.getSession(), a = ce(s), l = await crypto.subtle.sign(
|
|
2982
3052
|
"HMAC",
|
|
2983
3053
|
c,
|
|
2984
3054
|
new TextEncoder().encode(t)
|
|
2985
3055
|
);
|
|
2986
|
-
if (!this.constantTimeEqual(a, new Uint8Array(
|
|
3056
|
+
if (!this.constantTimeEqual(a, new Uint8Array(l)))
|
|
2987
3057
|
throw new Error("Invalid notification signature");
|
|
2988
|
-
const f = Uint8Array.from(
|
|
3058
|
+
const f = Uint8Array.from(ce(r)), h = Uint8Array.from(ce(t)), u = await crypto.subtle.decrypt(
|
|
2989
3059
|
{ name: "AES-GCM", iv: f },
|
|
2990
3060
|
o,
|
|
2991
3061
|
h
|
|
2992
|
-
), g = new TextDecoder().decode(
|
|
3062
|
+
), g = new TextDecoder().decode(u);
|
|
2993
3063
|
return { ...JSON.parse(g), ...i };
|
|
2994
3064
|
}
|
|
2995
3065
|
constantTimeEqual(e, t) {
|
|
@@ -3023,6 +3093,14 @@ ${c}`, l = await Hs(i, new TextEncoder().encode(h)), g = ne(l), w = new Headers(
|
|
|
3023
3093
|
refreshToken: c
|
|
3024
3094
|
};
|
|
3025
3095
|
}
|
|
3096
|
+
async logout() {
|
|
3097
|
+
await this.post("/oauth/logout", {}), this.updateSession({
|
|
3098
|
+
accessToken: void 0,
|
|
3099
|
+
tokenType: void 0,
|
|
3100
|
+
expiresAt: void 0,
|
|
3101
|
+
refreshToken: void 0
|
|
3102
|
+
}), this.notifications = new ct(this), await this.handshake();
|
|
3103
|
+
}
|
|
3026
3104
|
async refresh() {
|
|
3027
3105
|
const e = this.getSession();
|
|
3028
3106
|
if (!(e != null && e.refreshToken))
|
|
@@ -3068,14 +3146,14 @@ function Fs(n) {
|
|
|
3068
3146
|
function s(f) {
|
|
3069
3147
|
const h = r(f);
|
|
3070
3148
|
if (h[0] & 128) {
|
|
3071
|
-
const
|
|
3072
|
-
return
|
|
3149
|
+
const u = new Uint8Array(h.length + 1);
|
|
3150
|
+
return u[0] = 0, u.set(h, 1), u;
|
|
3073
3151
|
}
|
|
3074
3152
|
return h;
|
|
3075
3153
|
}
|
|
3076
3154
|
const i = s(e), o = s(t), c = 2 + i.length + 2 + o.length, a = new Uint8Array(2 + c);
|
|
3077
|
-
let
|
|
3078
|
-
return a[
|
|
3155
|
+
let l = 0;
|
|
3156
|
+
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
3157
|
}
|
|
3080
3158
|
const js = Symbol("SDK_CLIENT"), Js = {
|
|
3081
3159
|
install(n, e) {
|
|
@@ -3084,7 +3162,7 @@ const js = Symbol("SDK_CLIENT"), Js = {
|
|
|
3084
3162
|
}
|
|
3085
3163
|
};
|
|
3086
3164
|
export {
|
|
3087
|
-
|
|
3165
|
+
ct as Notifications,
|
|
3088
3166
|
js as SDK_CLIENT,
|
|
3089
3167
|
Js as SdkPlugin,
|
|
3090
3168
|
Os as SecureApiClient
|