mp-front-cli 0.0.42 → 0.0.44
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/core/middleware/index.d.ts +7 -1
- package/dist/core/middleware/index.d.ts.map +1 -1
- package/dist/core/utils/api-request/fetch-service-fe.d.ts.map +1 -1
- package/dist/core/utils/custom-header.d.ts +0 -1
- package/dist/core/utils/custom-header.d.ts.map +1 -1
- package/dist/core/utils/custom-validator.d.ts +3 -3
- package/dist/core/utils/custom-validator.d.ts.map +1 -1
- package/dist/{custom-encrypter-53d456d5.js → custom-encrypter-8fbfd246.js} +175 -178
- package/dist/{custom-header-4f5b8f1b.js → custom-header-30dbd365.js} +248 -263
- package/dist/custom-validator-49426b3d.js +14293 -0
- package/dist/mp-front-cli-all.es.js +4 -4
- package/dist/mp-front-cli-core.es.js +85 -74
- package/dist/mp-front-cli-encrypter.es.js +2 -2
- package/dist/mp-front-cli-header.es.js +4 -4
- package/dist/mp-front-cli-validator.es.js +4 -3
- package/package.json +1 -1
- package/dist/custom-validator-8a042f7f.js +0 -4683
|
@@ -1,4683 +0,0 @@
|
|
|
1
|
-
import { g as ft, C as zr } from "./custom-encoder-70a77460.js";
|
|
2
|
-
import { t as qr } from "./index-df4e0539.js";
|
|
3
|
-
import { CustomLogger as Xr } from "./mp-front-cli-logger.es.js";
|
|
4
|
-
const Yr = {
|
|
5
|
-
type: "logger",
|
|
6
|
-
log(t) {
|
|
7
|
-
this.output("log", t);
|
|
8
|
-
},
|
|
9
|
-
warn(t) {
|
|
10
|
-
this.output("warn", t);
|
|
11
|
-
},
|
|
12
|
-
error(t) {
|
|
13
|
-
this.output("error", t);
|
|
14
|
-
},
|
|
15
|
-
output(t, e) {
|
|
16
|
-
console && console[t] && console[t].apply(console, e);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
class xe {
|
|
20
|
-
constructor(e) {
|
|
21
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
22
|
-
this.init(e, r);
|
|
23
|
-
}
|
|
24
|
-
init(e) {
|
|
25
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
26
|
-
this.prefix = r.prefix || "i18next:", this.logger = e || Yr, this.options = r, this.debug = r.debug;
|
|
27
|
-
}
|
|
28
|
-
log() {
|
|
29
|
-
for (var e = arguments.length, r = new Array(e), n = 0; n < e; n++)
|
|
30
|
-
r[n] = arguments[n];
|
|
31
|
-
return this.forward(r, "log", "", !0);
|
|
32
|
-
}
|
|
33
|
-
warn() {
|
|
34
|
-
for (var e = arguments.length, r = new Array(e), n = 0; n < e; n++)
|
|
35
|
-
r[n] = arguments[n];
|
|
36
|
-
return this.forward(r, "warn", "", !0);
|
|
37
|
-
}
|
|
38
|
-
error() {
|
|
39
|
-
for (var e = arguments.length, r = new Array(e), n = 0; n < e; n++)
|
|
40
|
-
r[n] = arguments[n];
|
|
41
|
-
return this.forward(r, "error", "");
|
|
42
|
-
}
|
|
43
|
-
deprecate() {
|
|
44
|
-
for (var e = arguments.length, r = new Array(e), n = 0; n < e; n++)
|
|
45
|
-
r[n] = arguments[n];
|
|
46
|
-
return this.forward(r, "warn", "WARNING DEPRECATED: ", !0);
|
|
47
|
-
}
|
|
48
|
-
forward(e, r, n, a) {
|
|
49
|
-
return a && !this.debug ? null : (typeof e[0] == "string" && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[r](e));
|
|
50
|
-
}
|
|
51
|
-
create(e) {
|
|
52
|
-
return new xe(this.logger, {
|
|
53
|
-
prefix: `${this.prefix}:${e}:`,
|
|
54
|
-
...this.options
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
clone(e) {
|
|
58
|
-
return e = e || this.options, e.prefix = e.prefix || this.prefix, new xe(this.logger, e);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
var Z = new xe();
|
|
62
|
-
class Ue {
|
|
63
|
-
constructor() {
|
|
64
|
-
this.observers = {};
|
|
65
|
-
}
|
|
66
|
-
on(e, r) {
|
|
67
|
-
return e.split(" ").forEach((n) => {
|
|
68
|
-
this.observers[n] = this.observers[n] || [], this.observers[n].push(r);
|
|
69
|
-
}), this;
|
|
70
|
-
}
|
|
71
|
-
off(e, r) {
|
|
72
|
-
if (this.observers[e]) {
|
|
73
|
-
if (!r) {
|
|
74
|
-
delete this.observers[e];
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
this.observers[e] = this.observers[e].filter((n) => n !== r);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
emit(e) {
|
|
81
|
-
for (var r = arguments.length, n = new Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++)
|
|
82
|
-
n[a - 1] = arguments[a];
|
|
83
|
-
this.observers[e] && [].concat(this.observers[e]).forEach((i) => {
|
|
84
|
-
i(...n);
|
|
85
|
-
}), this.observers["*"] && [].concat(this.observers["*"]).forEach((i) => {
|
|
86
|
-
i.apply(i, [e, ...n]);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function he() {
|
|
91
|
-
let t, e;
|
|
92
|
-
const r = new Promise((n, a) => {
|
|
93
|
-
t = n, e = a;
|
|
94
|
-
});
|
|
95
|
-
return r.resolve = t, r.reject = e, r;
|
|
96
|
-
}
|
|
97
|
-
function Kt(t) {
|
|
98
|
-
return t == null ? "" : "" + t;
|
|
99
|
-
}
|
|
100
|
-
function Zr(t, e, r) {
|
|
101
|
-
t.forEach((n) => {
|
|
102
|
-
e[n] && (r[n] = e[n]);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function ht(t, e, r) {
|
|
106
|
-
function n(i) {
|
|
107
|
-
return i && i.indexOf("###") > -1 ? i.replace(/###/g, ".") : i;
|
|
108
|
-
}
|
|
109
|
-
function a() {
|
|
110
|
-
return !t || typeof t == "string";
|
|
111
|
-
}
|
|
112
|
-
const s = typeof e != "string" ? [].concat(e) : e.split(".");
|
|
113
|
-
for (; s.length > 1; ) {
|
|
114
|
-
if (a())
|
|
115
|
-
return {};
|
|
116
|
-
const i = n(s.shift());
|
|
117
|
-
!t[i] && r && (t[i] = new r()), Object.prototype.hasOwnProperty.call(t, i) ? t = t[i] : t = {};
|
|
118
|
-
}
|
|
119
|
-
return a() ? {} : {
|
|
120
|
-
obj: t,
|
|
121
|
-
k: n(s.shift())
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function Rt(t, e, r) {
|
|
125
|
-
const {
|
|
126
|
-
obj: n,
|
|
127
|
-
k: a
|
|
128
|
-
} = ht(t, e, Object);
|
|
129
|
-
n[a] = r;
|
|
130
|
-
}
|
|
131
|
-
function Qr(t, e, r, n) {
|
|
132
|
-
const {
|
|
133
|
-
obj: a,
|
|
134
|
-
k: s
|
|
135
|
-
} = ht(t, e, Object);
|
|
136
|
-
a[s] = a[s] || [], n && (a[s] = a[s].concat(r)), n || a[s].push(r);
|
|
137
|
-
}
|
|
138
|
-
function Ce(t, e) {
|
|
139
|
-
const {
|
|
140
|
-
obj: r,
|
|
141
|
-
k: n
|
|
142
|
-
} = ht(t, e);
|
|
143
|
-
if (r)
|
|
144
|
-
return r[n];
|
|
145
|
-
}
|
|
146
|
-
function jr(t, e, r) {
|
|
147
|
-
const n = Ce(t, r);
|
|
148
|
-
return n !== void 0 ? n : Ce(e, r);
|
|
149
|
-
}
|
|
150
|
-
function Qt(t, e, r) {
|
|
151
|
-
for (const n in e)
|
|
152
|
-
n !== "__proto__" && n !== "constructor" && (n in t ? typeof t[n] == "string" || t[n] instanceof String || typeof e[n] == "string" || e[n] instanceof String ? r && (t[n] = e[n]) : Qt(t[n], e[n], r) : t[n] = e[n]);
|
|
153
|
-
return t;
|
|
154
|
-
}
|
|
155
|
-
function oe(t) {
|
|
156
|
-
return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
157
|
-
}
|
|
158
|
-
var en = {
|
|
159
|
-
"&": "&",
|
|
160
|
-
"<": "<",
|
|
161
|
-
">": ">",
|
|
162
|
-
'"': """,
|
|
163
|
-
"'": "'",
|
|
164
|
-
"/": "/"
|
|
165
|
-
};
|
|
166
|
-
function tn(t) {
|
|
167
|
-
return typeof t == "string" ? t.replace(/[&<>"'\/]/g, (e) => en[e]) : t;
|
|
168
|
-
}
|
|
169
|
-
const rn = [" ", ",", "?", "!", ";"];
|
|
170
|
-
function nn(t, e, r) {
|
|
171
|
-
e = e || "", r = r || "";
|
|
172
|
-
const n = rn.filter((i) => e.indexOf(i) < 0 && r.indexOf(i) < 0);
|
|
173
|
-
if (n.length === 0)
|
|
174
|
-
return !0;
|
|
175
|
-
const a = new RegExp(`(${n.map((i) => i === "?" ? "\\?" : i).join("|")})`);
|
|
176
|
-
let s = !a.test(t);
|
|
177
|
-
if (!s) {
|
|
178
|
-
const i = t.indexOf(r);
|
|
179
|
-
i > 0 && !a.test(t.substring(0, i)) && (s = !0);
|
|
180
|
-
}
|
|
181
|
-
return s;
|
|
182
|
-
}
|
|
183
|
-
function _e(t, e) {
|
|
184
|
-
let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
|
|
185
|
-
if (!t)
|
|
186
|
-
return;
|
|
187
|
-
if (t[e])
|
|
188
|
-
return t[e];
|
|
189
|
-
const n = e.split(r);
|
|
190
|
-
let a = t;
|
|
191
|
-
for (let s = 0; s < n.length; ++s) {
|
|
192
|
-
if (!a || typeof a[n[s]] == "string" && s + 1 < n.length)
|
|
193
|
-
return;
|
|
194
|
-
if (a[n[s]] === void 0) {
|
|
195
|
-
let i = 2, o = n.slice(s, s + i).join(r), c = a[o];
|
|
196
|
-
for (; c === void 0 && n.length > s + i; )
|
|
197
|
-
i++, o = n.slice(s, s + i).join(r), c = a[o];
|
|
198
|
-
if (c === void 0)
|
|
199
|
-
return;
|
|
200
|
-
if (c === null)
|
|
201
|
-
return null;
|
|
202
|
-
if (e.endsWith(o)) {
|
|
203
|
-
if (typeof c == "string")
|
|
204
|
-
return c;
|
|
205
|
-
if (o && typeof c[o] == "string")
|
|
206
|
-
return c[o];
|
|
207
|
-
}
|
|
208
|
-
const u = n.slice(s + i).join(r);
|
|
209
|
-
return u ? _e(c, u, r) : void 0;
|
|
210
|
-
}
|
|
211
|
-
a = a[n[s]];
|
|
212
|
-
}
|
|
213
|
-
return a;
|
|
214
|
-
}
|
|
215
|
-
function Pe(t) {
|
|
216
|
-
return t && t.indexOf("_") > 0 ? t.replace("_", "-") : t;
|
|
217
|
-
}
|
|
218
|
-
class Ot extends Ue {
|
|
219
|
-
constructor(e) {
|
|
220
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
221
|
-
ns: ["translation"],
|
|
222
|
-
defaultNS: "translation"
|
|
223
|
-
};
|
|
224
|
-
super(), this.data = e || {}, this.options = r, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
|
|
225
|
-
}
|
|
226
|
-
addNamespaces(e) {
|
|
227
|
-
this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
|
|
228
|
-
}
|
|
229
|
-
removeNamespaces(e) {
|
|
230
|
-
const r = this.options.ns.indexOf(e);
|
|
231
|
-
r > -1 && this.options.ns.splice(r, 1);
|
|
232
|
-
}
|
|
233
|
-
getResource(e, r, n) {
|
|
234
|
-
let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
235
|
-
const s = a.keySeparator !== void 0 ? a.keySeparator : this.options.keySeparator, i = a.ignoreJSONStructure !== void 0 ? a.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
236
|
-
let o = [e, r];
|
|
237
|
-
n && typeof n != "string" && (o = o.concat(n)), n && typeof n == "string" && (o = o.concat(s ? n.split(s) : n)), e.indexOf(".") > -1 && (o = e.split("."));
|
|
238
|
-
const c = Ce(this.data, o);
|
|
239
|
-
return c || !i || typeof n != "string" ? c : _e(this.data && this.data[e] && this.data[e][r], n, s);
|
|
240
|
-
}
|
|
241
|
-
addResource(e, r, n, a) {
|
|
242
|
-
let s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
|
|
243
|
-
silent: !1
|
|
244
|
-
};
|
|
245
|
-
const i = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator;
|
|
246
|
-
let o = [e, r];
|
|
247
|
-
n && (o = o.concat(i ? n.split(i) : n)), e.indexOf(".") > -1 && (o = e.split("."), a = r, r = o[1]), this.addNamespaces(r), Rt(this.data, o, a), s.silent || this.emit("added", e, r, n, a);
|
|
248
|
-
}
|
|
249
|
-
addResources(e, r, n) {
|
|
250
|
-
let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
|
|
251
|
-
silent: !1
|
|
252
|
-
};
|
|
253
|
-
for (const s in n)
|
|
254
|
-
(typeof n[s] == "string" || Object.prototype.toString.apply(n[s]) === "[object Array]") && this.addResource(e, r, s, n[s], {
|
|
255
|
-
silent: !0
|
|
256
|
-
});
|
|
257
|
-
a.silent || this.emit("added", e, r, n);
|
|
258
|
-
}
|
|
259
|
-
addResourceBundle(e, r, n, a, s) {
|
|
260
|
-
let i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
|
|
261
|
-
silent: !1
|
|
262
|
-
}, o = [e, r];
|
|
263
|
-
e.indexOf(".") > -1 && (o = e.split("."), a = n, n = r, r = o[1]), this.addNamespaces(r);
|
|
264
|
-
let c = Ce(this.data, o) || {};
|
|
265
|
-
a ? Qt(c, n, s) : c = {
|
|
266
|
-
...c,
|
|
267
|
-
...n
|
|
268
|
-
}, Rt(this.data, o, c), i.silent || this.emit("added", e, r, n);
|
|
269
|
-
}
|
|
270
|
-
removeResourceBundle(e, r) {
|
|
271
|
-
this.hasResourceBundle(e, r) && delete this.data[e][r], this.removeNamespaces(r), this.emit("removed", e, r);
|
|
272
|
-
}
|
|
273
|
-
hasResourceBundle(e, r) {
|
|
274
|
-
return this.getResource(e, r) !== void 0;
|
|
275
|
-
}
|
|
276
|
-
getResourceBundle(e, r) {
|
|
277
|
-
return r || (r = this.options.defaultNS), this.options.compatibilityAPI === "v1" ? {
|
|
278
|
-
...this.getResource(e, r)
|
|
279
|
-
} : this.getResource(e, r);
|
|
280
|
-
}
|
|
281
|
-
getDataByLanguage(e) {
|
|
282
|
-
return this.data[e];
|
|
283
|
-
}
|
|
284
|
-
hasLanguageSomeTranslations(e) {
|
|
285
|
-
const r = this.getDataByLanguage(e);
|
|
286
|
-
return !!(r && Object.keys(r) || []).find((a) => r[a] && Object.keys(r[a]).length > 0);
|
|
287
|
-
}
|
|
288
|
-
toJSON() {
|
|
289
|
-
return this.data;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
var jt = {
|
|
293
|
-
processors: {},
|
|
294
|
-
addPostProcessor(t) {
|
|
295
|
-
this.processors[t.name] = t;
|
|
296
|
-
},
|
|
297
|
-
handle(t, e, r, n, a) {
|
|
298
|
-
return t.forEach((s) => {
|
|
299
|
-
this.processors[s] && (e = this.processors[s].process(e, r, n, a));
|
|
300
|
-
}), e;
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
const Tt = {};
|
|
304
|
-
class He extends Ue {
|
|
305
|
-
constructor(e) {
|
|
306
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
307
|
-
super(), Zr(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = r, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = Z.create("translator");
|
|
308
|
-
}
|
|
309
|
-
changeLanguage(e) {
|
|
310
|
-
e && (this.language = e);
|
|
311
|
-
}
|
|
312
|
-
exists(e) {
|
|
313
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
314
|
-
interpolation: {}
|
|
315
|
-
};
|
|
316
|
-
if (e == null)
|
|
317
|
-
return !1;
|
|
318
|
-
const n = this.resolve(e, r);
|
|
319
|
-
return n && n.res !== void 0;
|
|
320
|
-
}
|
|
321
|
-
extractFromKey(e, r) {
|
|
322
|
-
let n = r.nsSeparator !== void 0 ? r.nsSeparator : this.options.nsSeparator;
|
|
323
|
-
n === void 0 && (n = ":");
|
|
324
|
-
const a = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
|
|
325
|
-
let s = r.ns || this.options.defaultNS || [];
|
|
326
|
-
const i = n && e.indexOf(n) > -1, o = !this.options.userDefinedKeySeparator && !r.keySeparator && !this.options.userDefinedNsSeparator && !r.nsSeparator && !nn(e, n, a);
|
|
327
|
-
if (i && !o) {
|
|
328
|
-
const c = e.match(this.interpolator.nestingRegexp);
|
|
329
|
-
if (c && c.length > 0)
|
|
330
|
-
return {
|
|
331
|
-
key: e,
|
|
332
|
-
namespaces: s
|
|
333
|
-
};
|
|
334
|
-
const u = e.split(n);
|
|
335
|
-
(n !== a || n === a && this.options.ns.indexOf(u[0]) > -1) && (s = u.shift()), e = u.join(a);
|
|
336
|
-
}
|
|
337
|
-
return typeof s == "string" && (s = [s]), {
|
|
338
|
-
key: e,
|
|
339
|
-
namespaces: s
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
translate(e, r, n) {
|
|
343
|
-
if (typeof r != "object" && this.options.overloadTranslationOptionHandler && (r = this.options.overloadTranslationOptionHandler(arguments)), typeof r == "object" && (r = {
|
|
344
|
-
...r
|
|
345
|
-
}), r || (r = {}), e == null)
|
|
346
|
-
return "";
|
|
347
|
-
Array.isArray(e) || (e = [String(e)]);
|
|
348
|
-
const a = r.returnDetails !== void 0 ? r.returnDetails : this.options.returnDetails, s = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator, {
|
|
349
|
-
key: i,
|
|
350
|
-
namespaces: o
|
|
351
|
-
} = this.extractFromKey(e[e.length - 1], r), c = o[o.length - 1], u = r.lng || this.language, l = r.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
352
|
-
if (u && u.toLowerCase() === "cimode") {
|
|
353
|
-
if (l) {
|
|
354
|
-
const m = r.nsSeparator || this.options.nsSeparator;
|
|
355
|
-
return a ? {
|
|
356
|
-
res: `${c}${m}${i}`,
|
|
357
|
-
usedKey: i,
|
|
358
|
-
exactUsedKey: i,
|
|
359
|
-
usedLng: u,
|
|
360
|
-
usedNS: c,
|
|
361
|
-
usedParams: this.getUsedParamsDetails(r)
|
|
362
|
-
} : `${c}${m}${i}`;
|
|
363
|
-
}
|
|
364
|
-
return a ? {
|
|
365
|
-
res: i,
|
|
366
|
-
usedKey: i,
|
|
367
|
-
exactUsedKey: i,
|
|
368
|
-
usedLng: u,
|
|
369
|
-
usedNS: c,
|
|
370
|
-
usedParams: this.getUsedParamsDetails(r)
|
|
371
|
-
} : i;
|
|
372
|
-
}
|
|
373
|
-
const f = this.resolve(e, r);
|
|
374
|
-
let d = f && f.res;
|
|
375
|
-
const p = f && f.usedKey || i, h = f && f.exactUsedKey || i, g = Object.prototype.toString.apply(d), S = ["[object Number]", "[object Function]", "[object RegExp]"], C = r.joinArrays !== void 0 ? r.joinArrays : this.options.joinArrays, v = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
376
|
-
if (v && d && (typeof d != "string" && typeof d != "boolean" && typeof d != "number") && S.indexOf(g) < 0 && !(typeof C == "string" && g === "[object Array]")) {
|
|
377
|
-
if (!r.returnObjects && !this.options.returnObjects) {
|
|
378
|
-
this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
|
|
379
|
-
const m = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(p, d, {
|
|
380
|
-
...r,
|
|
381
|
-
ns: o
|
|
382
|
-
}) : `key '${i} (${this.language})' returned an object instead of string.`;
|
|
383
|
-
return a ? (f.res = m, f.usedParams = this.getUsedParamsDetails(r), f) : m;
|
|
384
|
-
}
|
|
385
|
-
if (s) {
|
|
386
|
-
const m = g === "[object Array]", E = m ? [] : {}, _ = m ? h : p;
|
|
387
|
-
for (const A in d)
|
|
388
|
-
if (Object.prototype.hasOwnProperty.call(d, A)) {
|
|
389
|
-
const R = `${_}${s}${A}`;
|
|
390
|
-
E[A] = this.translate(R, {
|
|
391
|
-
...r,
|
|
392
|
-
joinArrays: !1,
|
|
393
|
-
ns: o
|
|
394
|
-
}), E[A] === R && (E[A] = d[A]);
|
|
395
|
-
}
|
|
396
|
-
d = E;
|
|
397
|
-
}
|
|
398
|
-
} else if (v && typeof C == "string" && g === "[object Array]")
|
|
399
|
-
d = d.join(C), d && (d = this.extendTranslation(d, e, r, n));
|
|
400
|
-
else {
|
|
401
|
-
let m = !1, E = !1;
|
|
402
|
-
const _ = r.count !== void 0 && typeof r.count != "string", A = He.hasDefaultValue(r), R = _ ? this.pluralResolver.getSuffix(u, r.count, r) : "", F = r.ordinal && _ ? this.pluralResolver.getSuffix(u, r.count, {
|
|
403
|
-
ordinal: !1
|
|
404
|
-
}) : "", q = _ && !r.ordinal && r.count === 0 && this.pluralResolver.shouldUseIntlApi(), Y = q && r[`defaultValue${this.options.pluralSeparator}zero`] || r[`defaultValue${R}`] || r[`defaultValue${F}`] || r.defaultValue;
|
|
405
|
-
!this.isValidLookup(d) && A && (m = !0, d = Y), this.isValidLookup(d) || (E = !0, d = i);
|
|
406
|
-
const Gr = (r.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && E ? void 0 : d, le = A && Y !== d && this.options.updateMissing;
|
|
407
|
-
if (E || m || le) {
|
|
408
|
-
if (this.logger.log(le ? "updateKey" : "missingKey", u, c, i, le ? Y : d), s) {
|
|
409
|
-
const z = this.resolve(i, {
|
|
410
|
-
...r,
|
|
411
|
-
keySeparator: !1
|
|
412
|
-
});
|
|
413
|
-
z && z.res && this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
|
|
414
|
-
}
|
|
415
|
-
let de = [];
|
|
416
|
-
const we = this.languageUtils.getFallbackCodes(this.options.fallbackLng, r.lng || this.language);
|
|
417
|
-
if (this.options.saveMissingTo === "fallback" && we && we[0])
|
|
418
|
-
for (let z = 0; z < we.length; z++)
|
|
419
|
-
de.push(we[z]);
|
|
420
|
-
else
|
|
421
|
-
this.options.saveMissingTo === "all" ? de = this.languageUtils.toResolveHierarchy(r.lng || this.language) : de.push(r.lng || this.language);
|
|
422
|
-
const Pt = (z, se, fe) => {
|
|
423
|
-
const Ht = A && fe !== d ? fe : Gr;
|
|
424
|
-
this.options.missingKeyHandler ? this.options.missingKeyHandler(z, c, se, Ht, le, r) : this.backendConnector && this.backendConnector.saveMissing && this.backendConnector.saveMissing(z, c, se, Ht, le, r), this.emit("missingKey", z, c, se, d);
|
|
425
|
-
};
|
|
426
|
-
this.options.saveMissing && (this.options.saveMissingPlurals && _ ? de.forEach((z) => {
|
|
427
|
-
const se = this.pluralResolver.getSuffixes(z, r);
|
|
428
|
-
q && r[`defaultValue${this.options.pluralSeparator}zero`] && se.indexOf(`${this.options.pluralSeparator}zero`) < 0 && se.push(`${this.options.pluralSeparator}zero`), se.forEach((fe) => {
|
|
429
|
-
Pt([z], i + fe, r[`defaultValue${fe}`] || Y);
|
|
430
|
-
});
|
|
431
|
-
}) : Pt(de, i, Y));
|
|
432
|
-
}
|
|
433
|
-
d = this.extendTranslation(d, e, r, f, n), E && d === i && this.options.appendNamespaceToMissingKey && (d = `${c}:${i}`), (E || m) && this.options.parseMissingKeyHandler && (this.options.compatibilityAPI !== "v1" ? d = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${c}:${i}` : i, m ? d : void 0) : d = this.options.parseMissingKeyHandler(d));
|
|
434
|
-
}
|
|
435
|
-
return a ? (f.res = d, f.usedParams = this.getUsedParamsDetails(r), f) : d;
|
|
436
|
-
}
|
|
437
|
-
extendTranslation(e, r, n, a, s) {
|
|
438
|
-
var i = this;
|
|
439
|
-
if (this.i18nFormat && this.i18nFormat.parse)
|
|
440
|
-
e = this.i18nFormat.parse(e, {
|
|
441
|
-
...this.options.interpolation.defaultVariables,
|
|
442
|
-
...n
|
|
443
|
-
}, n.lng || this.language || a.usedLng, a.usedNS, a.usedKey, {
|
|
444
|
-
resolved: a
|
|
445
|
-
});
|
|
446
|
-
else if (!n.skipInterpolation) {
|
|
447
|
-
n.interpolation && this.interpolator.init({
|
|
448
|
-
...n,
|
|
449
|
-
interpolation: {
|
|
450
|
-
...this.options.interpolation,
|
|
451
|
-
...n.interpolation
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
const u = typeof e == "string" && (n && n.interpolation && n.interpolation.skipOnVariables !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
455
|
-
let l;
|
|
456
|
-
if (u) {
|
|
457
|
-
const d = e.match(this.interpolator.nestingRegexp);
|
|
458
|
-
l = d && d.length;
|
|
459
|
-
}
|
|
460
|
-
let f = n.replace && typeof n.replace != "string" ? n.replace : n;
|
|
461
|
-
if (this.options.interpolation.defaultVariables && (f = {
|
|
462
|
-
...this.options.interpolation.defaultVariables,
|
|
463
|
-
...f
|
|
464
|
-
}), e = this.interpolator.interpolate(e, f, n.lng || this.language, n), u) {
|
|
465
|
-
const d = e.match(this.interpolator.nestingRegexp), p = d && d.length;
|
|
466
|
-
l < p && (n.nest = !1);
|
|
467
|
-
}
|
|
468
|
-
!n.lng && this.options.compatibilityAPI !== "v1" && a && a.res && (n.lng = a.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, function() {
|
|
469
|
-
for (var d = arguments.length, p = new Array(d), h = 0; h < d; h++)
|
|
470
|
-
p[h] = arguments[h];
|
|
471
|
-
return s && s[0] === p[0] && !n.context ? (i.logger.warn(`It seems you are nesting recursively key: ${p[0]} in key: ${r[0]}`), null) : i.translate(...p, r);
|
|
472
|
-
}, n)), n.interpolation && this.interpolator.reset();
|
|
473
|
-
}
|
|
474
|
-
const o = n.postProcess || this.options.postProcess, c = typeof o == "string" ? [o] : o;
|
|
475
|
-
return e != null && c && c.length && n.applyPostProcessor !== !1 && (e = jt.handle(c, e, r, this.options && this.options.postProcessPassResolved ? {
|
|
476
|
-
i18nResolved: {
|
|
477
|
-
...a,
|
|
478
|
-
usedParams: this.getUsedParamsDetails(n)
|
|
479
|
-
},
|
|
480
|
-
...n
|
|
481
|
-
} : n, this)), e;
|
|
482
|
-
}
|
|
483
|
-
resolve(e) {
|
|
484
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n, a, s, i, o;
|
|
485
|
-
return typeof e == "string" && (e = [e]), e.forEach((c) => {
|
|
486
|
-
if (this.isValidLookup(n))
|
|
487
|
-
return;
|
|
488
|
-
const u = this.extractFromKey(c, r), l = u.key;
|
|
489
|
-
a = l;
|
|
490
|
-
let f = u.namespaces;
|
|
491
|
-
this.options.fallbackNS && (f = f.concat(this.options.fallbackNS));
|
|
492
|
-
const d = r.count !== void 0 && typeof r.count != "string", p = d && !r.ordinal && r.count === 0 && this.pluralResolver.shouldUseIntlApi(), h = r.context !== void 0 && (typeof r.context == "string" || typeof r.context == "number") && r.context !== "", g = r.lngs ? r.lngs : this.languageUtils.toResolveHierarchy(r.lng || this.language, r.fallbackLng);
|
|
493
|
-
f.forEach((S) => {
|
|
494
|
-
this.isValidLookup(n) || (o = S, !Tt[`${g[0]}-${S}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(o) && (Tt[`${g[0]}-${S}`] = !0, this.logger.warn(`key "${a}" for languages "${g.join(", ")}" won't get resolved as namespace "${o}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")), g.forEach((C) => {
|
|
495
|
-
if (this.isValidLookup(n))
|
|
496
|
-
return;
|
|
497
|
-
i = C;
|
|
498
|
-
const v = [l];
|
|
499
|
-
if (this.i18nFormat && this.i18nFormat.addLookupKeys)
|
|
500
|
-
this.i18nFormat.addLookupKeys(v, l, C, S, r);
|
|
501
|
-
else {
|
|
502
|
-
let m;
|
|
503
|
-
d && (m = this.pluralResolver.getSuffix(C, r.count, r));
|
|
504
|
-
const E = `${this.options.pluralSeparator}zero`, _ = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
505
|
-
if (d && (v.push(l + m), r.ordinal && m.indexOf(_) === 0 && v.push(l + m.replace(_, this.options.pluralSeparator)), p && v.push(l + E)), h) {
|
|
506
|
-
const A = `${l}${this.options.contextSeparator}${r.context}`;
|
|
507
|
-
v.push(A), d && (v.push(A + m), r.ordinal && m.indexOf(_) === 0 && v.push(A + m.replace(_, this.options.pluralSeparator)), p && v.push(A + E));
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
let w;
|
|
511
|
-
for (; w = v.pop(); )
|
|
512
|
-
this.isValidLookup(n) || (s = w, n = this.getResource(C, S, w, r));
|
|
513
|
-
}));
|
|
514
|
-
});
|
|
515
|
-
}), {
|
|
516
|
-
res: n,
|
|
517
|
-
usedKey: a,
|
|
518
|
-
exactUsedKey: s,
|
|
519
|
-
usedLng: i,
|
|
520
|
-
usedNS: o
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
isValidLookup(e) {
|
|
524
|
-
return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
|
|
525
|
-
}
|
|
526
|
-
getResource(e, r, n) {
|
|
527
|
-
let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
528
|
-
return this.i18nFormat && this.i18nFormat.getResource ? this.i18nFormat.getResource(e, r, n, a) : this.resourceStore.getResource(e, r, n, a);
|
|
529
|
-
}
|
|
530
|
-
getUsedParamsDetails() {
|
|
531
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
532
|
-
const r = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], n = e.replace && typeof e.replace != "string";
|
|
533
|
-
let a = n ? e.replace : e;
|
|
534
|
-
if (n && typeof e.count < "u" && (a.count = e.count), this.options.interpolation.defaultVariables && (a = {
|
|
535
|
-
...this.options.interpolation.defaultVariables,
|
|
536
|
-
...a
|
|
537
|
-
}), !n) {
|
|
538
|
-
a = {
|
|
539
|
-
...a
|
|
540
|
-
};
|
|
541
|
-
for (const s of r)
|
|
542
|
-
delete a[s];
|
|
543
|
-
}
|
|
544
|
-
return a;
|
|
545
|
-
}
|
|
546
|
-
static hasDefaultValue(e) {
|
|
547
|
-
const r = "defaultValue";
|
|
548
|
-
for (const n in e)
|
|
549
|
-
if (Object.prototype.hasOwnProperty.call(e, n) && r === n.substring(0, r.length) && e[n] !== void 0)
|
|
550
|
-
return !0;
|
|
551
|
-
return !1;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
function Ge(t) {
|
|
555
|
-
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
556
|
-
}
|
|
557
|
-
class It {
|
|
558
|
-
constructor(e) {
|
|
559
|
-
this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = Z.create("languageUtils");
|
|
560
|
-
}
|
|
561
|
-
getScriptPartFromCode(e) {
|
|
562
|
-
if (e = Pe(e), !e || e.indexOf("-") < 0)
|
|
563
|
-
return null;
|
|
564
|
-
const r = e.split("-");
|
|
565
|
-
return r.length === 2 || (r.pop(), r[r.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(r.join("-"));
|
|
566
|
-
}
|
|
567
|
-
getLanguagePartFromCode(e) {
|
|
568
|
-
if (e = Pe(e), !e || e.indexOf("-") < 0)
|
|
569
|
-
return e;
|
|
570
|
-
const r = e.split("-");
|
|
571
|
-
return this.formatLanguageCode(r[0]);
|
|
572
|
-
}
|
|
573
|
-
formatLanguageCode(e) {
|
|
574
|
-
if (typeof e == "string" && e.indexOf("-") > -1) {
|
|
575
|
-
const r = ["hans", "hant", "latn", "cyrl", "cans", "mong", "arab"];
|
|
576
|
-
let n = e.split("-");
|
|
577
|
-
return this.options.lowerCaseLng ? n = n.map((a) => a.toLowerCase()) : n.length === 2 ? (n[0] = n[0].toLowerCase(), n[1] = n[1].toUpperCase(), r.indexOf(n[1].toLowerCase()) > -1 && (n[1] = Ge(n[1].toLowerCase()))) : n.length === 3 && (n[0] = n[0].toLowerCase(), n[1].length === 2 && (n[1] = n[1].toUpperCase()), n[0] !== "sgn" && n[2].length === 2 && (n[2] = n[2].toUpperCase()), r.indexOf(n[1].toLowerCase()) > -1 && (n[1] = Ge(n[1].toLowerCase())), r.indexOf(n[2].toLowerCase()) > -1 && (n[2] = Ge(n[2].toLowerCase()))), n.join("-");
|
|
578
|
-
}
|
|
579
|
-
return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
|
|
580
|
-
}
|
|
581
|
-
isSupportedCode(e) {
|
|
582
|
-
return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
|
|
583
|
-
}
|
|
584
|
-
getBestMatchFromCodes(e) {
|
|
585
|
-
if (!e)
|
|
586
|
-
return null;
|
|
587
|
-
let r;
|
|
588
|
-
return e.forEach((n) => {
|
|
589
|
-
if (r)
|
|
590
|
-
return;
|
|
591
|
-
const a = this.formatLanguageCode(n);
|
|
592
|
-
(!this.options.supportedLngs || this.isSupportedCode(a)) && (r = a);
|
|
593
|
-
}), !r && this.options.supportedLngs && e.forEach((n) => {
|
|
594
|
-
if (r)
|
|
595
|
-
return;
|
|
596
|
-
const a = this.getLanguagePartFromCode(n);
|
|
597
|
-
if (this.isSupportedCode(a))
|
|
598
|
-
return r = a;
|
|
599
|
-
r = this.options.supportedLngs.find((s) => {
|
|
600
|
-
if (s === a)
|
|
601
|
-
return s;
|
|
602
|
-
if (!(s.indexOf("-") < 0 && a.indexOf("-") < 0) && s.indexOf(a) === 0)
|
|
603
|
-
return s;
|
|
604
|
-
});
|
|
605
|
-
}), r || (r = this.getFallbackCodes(this.options.fallbackLng)[0]), r;
|
|
606
|
-
}
|
|
607
|
-
getFallbackCodes(e, r) {
|
|
608
|
-
if (!e)
|
|
609
|
-
return [];
|
|
610
|
-
if (typeof e == "function" && (e = e(r)), typeof e == "string" && (e = [e]), Object.prototype.toString.apply(e) === "[object Array]")
|
|
611
|
-
return e;
|
|
612
|
-
if (!r)
|
|
613
|
-
return e.default || [];
|
|
614
|
-
let n = e[r];
|
|
615
|
-
return n || (n = e[this.getScriptPartFromCode(r)]), n || (n = e[this.formatLanguageCode(r)]), n || (n = e[this.getLanguagePartFromCode(r)]), n || (n = e.default), n || [];
|
|
616
|
-
}
|
|
617
|
-
toResolveHierarchy(e, r) {
|
|
618
|
-
const n = this.getFallbackCodes(r || this.options.fallbackLng || [], e), a = [], s = (i) => {
|
|
619
|
-
i && (this.isSupportedCode(i) ? a.push(i) : this.logger.warn(`rejecting language code not found in supportedLngs: ${i}`));
|
|
620
|
-
};
|
|
621
|
-
return typeof e == "string" && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && s(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && s(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && s(this.getLanguagePartFromCode(e))) : typeof e == "string" && s(this.formatLanguageCode(e)), n.forEach((i) => {
|
|
622
|
-
a.indexOf(i) < 0 && s(this.formatLanguageCode(i));
|
|
623
|
-
}), a;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
let an = [{
|
|
627
|
-
lngs: ["ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "mi", "oc", "pt", "pt-BR", "tg", "tl", "ti", "tr", "uz", "wa"],
|
|
628
|
-
nr: [1, 2],
|
|
629
|
-
fc: 1
|
|
630
|
-
}, {
|
|
631
|
-
lngs: ["af", "an", "ast", "az", "bg", "bn", "ca", "da", "de", "dev", "el", "en", "eo", "es", "et", "eu", "fi", "fo", "fur", "fy", "gl", "gu", "ha", "hi", "hu", "hy", "ia", "it", "kk", "kn", "ku", "lb", "mai", "ml", "mn", "mr", "nah", "nap", "nb", "ne", "nl", "nn", "no", "nso", "pa", "pap", "pms", "ps", "pt-PT", "rm", "sco", "se", "si", "so", "son", "sq", "sv", "sw", "ta", "te", "tk", "ur", "yo"],
|
|
632
|
-
nr: [1, 2],
|
|
633
|
-
fc: 2
|
|
634
|
-
}, {
|
|
635
|
-
lngs: ["ay", "bo", "cgg", "fa", "ht", "id", "ja", "jbo", "ka", "km", "ko", "ky", "lo", "ms", "sah", "su", "th", "tt", "ug", "vi", "wo", "zh"],
|
|
636
|
-
nr: [1],
|
|
637
|
-
fc: 3
|
|
638
|
-
}, {
|
|
639
|
-
lngs: ["be", "bs", "cnr", "dz", "hr", "ru", "sr", "uk"],
|
|
640
|
-
nr: [1, 2, 5],
|
|
641
|
-
fc: 4
|
|
642
|
-
}, {
|
|
643
|
-
lngs: ["ar"],
|
|
644
|
-
nr: [0, 1, 2, 3, 11, 100],
|
|
645
|
-
fc: 5
|
|
646
|
-
}, {
|
|
647
|
-
lngs: ["cs", "sk"],
|
|
648
|
-
nr: [1, 2, 5],
|
|
649
|
-
fc: 6
|
|
650
|
-
}, {
|
|
651
|
-
lngs: ["csb", "pl"],
|
|
652
|
-
nr: [1, 2, 5],
|
|
653
|
-
fc: 7
|
|
654
|
-
}, {
|
|
655
|
-
lngs: ["cy"],
|
|
656
|
-
nr: [1, 2, 3, 8],
|
|
657
|
-
fc: 8
|
|
658
|
-
}, {
|
|
659
|
-
lngs: ["fr"],
|
|
660
|
-
nr: [1, 2],
|
|
661
|
-
fc: 9
|
|
662
|
-
}, {
|
|
663
|
-
lngs: ["ga"],
|
|
664
|
-
nr: [1, 2, 3, 7, 11],
|
|
665
|
-
fc: 10
|
|
666
|
-
}, {
|
|
667
|
-
lngs: ["gd"],
|
|
668
|
-
nr: [1, 2, 3, 20],
|
|
669
|
-
fc: 11
|
|
670
|
-
}, {
|
|
671
|
-
lngs: ["is"],
|
|
672
|
-
nr: [1, 2],
|
|
673
|
-
fc: 12
|
|
674
|
-
}, {
|
|
675
|
-
lngs: ["jv"],
|
|
676
|
-
nr: [0, 1],
|
|
677
|
-
fc: 13
|
|
678
|
-
}, {
|
|
679
|
-
lngs: ["kw"],
|
|
680
|
-
nr: [1, 2, 3, 4],
|
|
681
|
-
fc: 14
|
|
682
|
-
}, {
|
|
683
|
-
lngs: ["lt"],
|
|
684
|
-
nr: [1, 2, 10],
|
|
685
|
-
fc: 15
|
|
686
|
-
}, {
|
|
687
|
-
lngs: ["lv"],
|
|
688
|
-
nr: [1, 2, 0],
|
|
689
|
-
fc: 16
|
|
690
|
-
}, {
|
|
691
|
-
lngs: ["mk"],
|
|
692
|
-
nr: [1, 2],
|
|
693
|
-
fc: 17
|
|
694
|
-
}, {
|
|
695
|
-
lngs: ["mnk"],
|
|
696
|
-
nr: [0, 1, 2],
|
|
697
|
-
fc: 18
|
|
698
|
-
}, {
|
|
699
|
-
lngs: ["mt"],
|
|
700
|
-
nr: [1, 2, 11, 20],
|
|
701
|
-
fc: 19
|
|
702
|
-
}, {
|
|
703
|
-
lngs: ["or"],
|
|
704
|
-
nr: [2, 1],
|
|
705
|
-
fc: 2
|
|
706
|
-
}, {
|
|
707
|
-
lngs: ["ro"],
|
|
708
|
-
nr: [1, 2, 20],
|
|
709
|
-
fc: 20
|
|
710
|
-
}, {
|
|
711
|
-
lngs: ["sl"],
|
|
712
|
-
nr: [5, 1, 2, 3],
|
|
713
|
-
fc: 21
|
|
714
|
-
}, {
|
|
715
|
-
lngs: ["he", "iw"],
|
|
716
|
-
nr: [1, 2, 20, 21],
|
|
717
|
-
fc: 22
|
|
718
|
-
}], sn = {
|
|
719
|
-
1: function(t) {
|
|
720
|
-
return +(t > 1);
|
|
721
|
-
},
|
|
722
|
-
2: function(t) {
|
|
723
|
-
return +(t != 1);
|
|
724
|
-
},
|
|
725
|
-
3: function(t) {
|
|
726
|
-
return 0;
|
|
727
|
-
},
|
|
728
|
-
4: function(t) {
|
|
729
|
-
return t % 10 == 1 && t % 100 != 11 ? 0 : t % 10 >= 2 && t % 10 <= 4 && (t % 100 < 10 || t % 100 >= 20) ? 1 : 2;
|
|
730
|
-
},
|
|
731
|
-
5: function(t) {
|
|
732
|
-
return t == 0 ? 0 : t == 1 ? 1 : t == 2 ? 2 : t % 100 >= 3 && t % 100 <= 10 ? 3 : t % 100 >= 11 ? 4 : 5;
|
|
733
|
-
},
|
|
734
|
-
6: function(t) {
|
|
735
|
-
return t == 1 ? 0 : t >= 2 && t <= 4 ? 1 : 2;
|
|
736
|
-
},
|
|
737
|
-
7: function(t) {
|
|
738
|
-
return t == 1 ? 0 : t % 10 >= 2 && t % 10 <= 4 && (t % 100 < 10 || t % 100 >= 20) ? 1 : 2;
|
|
739
|
-
},
|
|
740
|
-
8: function(t) {
|
|
741
|
-
return t == 1 ? 0 : t == 2 ? 1 : t != 8 && t != 11 ? 2 : 3;
|
|
742
|
-
},
|
|
743
|
-
9: function(t) {
|
|
744
|
-
return +(t >= 2);
|
|
745
|
-
},
|
|
746
|
-
10: function(t) {
|
|
747
|
-
return t == 1 ? 0 : t == 2 ? 1 : t < 7 ? 2 : t < 11 ? 3 : 4;
|
|
748
|
-
},
|
|
749
|
-
11: function(t) {
|
|
750
|
-
return t == 1 || t == 11 ? 0 : t == 2 || t == 12 ? 1 : t > 2 && t < 20 ? 2 : 3;
|
|
751
|
-
},
|
|
752
|
-
12: function(t) {
|
|
753
|
-
return +(t % 10 != 1 || t % 100 == 11);
|
|
754
|
-
},
|
|
755
|
-
13: function(t) {
|
|
756
|
-
return +(t !== 0);
|
|
757
|
-
},
|
|
758
|
-
14: function(t) {
|
|
759
|
-
return t == 1 ? 0 : t == 2 ? 1 : t == 3 ? 2 : 3;
|
|
760
|
-
},
|
|
761
|
-
15: function(t) {
|
|
762
|
-
return t % 10 == 1 && t % 100 != 11 ? 0 : t % 10 >= 2 && (t % 100 < 10 || t % 100 >= 20) ? 1 : 2;
|
|
763
|
-
},
|
|
764
|
-
16: function(t) {
|
|
765
|
-
return t % 10 == 1 && t % 100 != 11 ? 0 : t !== 0 ? 1 : 2;
|
|
766
|
-
},
|
|
767
|
-
17: function(t) {
|
|
768
|
-
return t == 1 || t % 10 == 1 && t % 100 != 11 ? 0 : 1;
|
|
769
|
-
},
|
|
770
|
-
18: function(t) {
|
|
771
|
-
return t == 0 ? 0 : t == 1 ? 1 : 2;
|
|
772
|
-
},
|
|
773
|
-
19: function(t) {
|
|
774
|
-
return t == 1 ? 0 : t == 0 || t % 100 > 1 && t % 100 < 11 ? 1 : t % 100 > 10 && t % 100 < 20 ? 2 : 3;
|
|
775
|
-
},
|
|
776
|
-
20: function(t) {
|
|
777
|
-
return t == 1 ? 0 : t == 0 || t % 100 > 0 && t % 100 < 20 ? 1 : 2;
|
|
778
|
-
},
|
|
779
|
-
21: function(t) {
|
|
780
|
-
return t % 100 == 1 ? 1 : t % 100 == 2 ? 2 : t % 100 == 3 || t % 100 == 4 ? 3 : 0;
|
|
781
|
-
},
|
|
782
|
-
22: function(t) {
|
|
783
|
-
return t == 1 ? 0 : t == 2 ? 1 : (t < 0 || t > 10) && t % 10 == 0 ? 2 : 3;
|
|
784
|
-
}
|
|
785
|
-
};
|
|
786
|
-
const on = ["v1", "v2", "v3"], cn = ["v4"], Wt = {
|
|
787
|
-
zero: 0,
|
|
788
|
-
one: 1,
|
|
789
|
-
two: 2,
|
|
790
|
-
few: 3,
|
|
791
|
-
many: 4,
|
|
792
|
-
other: 5
|
|
793
|
-
};
|
|
794
|
-
function un() {
|
|
795
|
-
const t = {};
|
|
796
|
-
return an.forEach((e) => {
|
|
797
|
-
e.lngs.forEach((r) => {
|
|
798
|
-
t[r] = {
|
|
799
|
-
numbers: e.nr,
|
|
800
|
-
plurals: sn[e.fc]
|
|
801
|
-
};
|
|
802
|
-
});
|
|
803
|
-
}), t;
|
|
804
|
-
}
|
|
805
|
-
class ln {
|
|
806
|
-
constructor(e) {
|
|
807
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
808
|
-
this.languageUtils = e, this.options = r, this.logger = Z.create("pluralResolver"), (!this.options.compatibilityJSON || cn.includes(this.options.compatibilityJSON)) && (typeof Intl > "u" || !Intl.PluralRules) && (this.options.compatibilityJSON = "v3", this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")), this.rules = un();
|
|
809
|
-
}
|
|
810
|
-
addRule(e, r) {
|
|
811
|
-
this.rules[e] = r;
|
|
812
|
-
}
|
|
813
|
-
getRule(e) {
|
|
814
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
815
|
-
if (this.shouldUseIntlApi())
|
|
816
|
-
try {
|
|
817
|
-
return new Intl.PluralRules(Pe(e === "dev" ? "en" : e), {
|
|
818
|
-
type: r.ordinal ? "ordinal" : "cardinal"
|
|
819
|
-
});
|
|
820
|
-
} catch {
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
return this.rules[e] || this.rules[this.languageUtils.getLanguagePartFromCode(e)];
|
|
824
|
-
}
|
|
825
|
-
needsPlural(e) {
|
|
826
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
827
|
-
const n = this.getRule(e, r);
|
|
828
|
-
return this.shouldUseIntlApi() ? n && n.resolvedOptions().pluralCategories.length > 1 : n && n.numbers.length > 1;
|
|
829
|
-
}
|
|
830
|
-
getPluralFormsOfKey(e, r) {
|
|
831
|
-
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
832
|
-
return this.getSuffixes(e, n).map((a) => `${r}${a}`);
|
|
833
|
-
}
|
|
834
|
-
getSuffixes(e) {
|
|
835
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
836
|
-
const n = this.getRule(e, r);
|
|
837
|
-
return n ? this.shouldUseIntlApi() ? n.resolvedOptions().pluralCategories.sort((a, s) => Wt[a] - Wt[s]).map((a) => `${this.options.prepend}${r.ordinal ? `ordinal${this.options.prepend}` : ""}${a}`) : n.numbers.map((a) => this.getSuffix(e, a, r)) : [];
|
|
838
|
-
}
|
|
839
|
-
getSuffix(e, r) {
|
|
840
|
-
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
841
|
-
const a = this.getRule(e, n);
|
|
842
|
-
return a ? this.shouldUseIntlApi() ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${a.select(r)}` : this.getSuffixRetroCompatible(a, r) : (this.logger.warn(`no plural rule found for: ${e}`), "");
|
|
843
|
-
}
|
|
844
|
-
getSuffixRetroCompatible(e, r) {
|
|
845
|
-
const n = e.noAbs ? e.plurals(r) : e.plurals(Math.abs(r));
|
|
846
|
-
let a = e.numbers[n];
|
|
847
|
-
this.options.simplifyPluralSuffix && e.numbers.length === 2 && e.numbers[0] === 1 && (a === 2 ? a = "plural" : a === 1 && (a = ""));
|
|
848
|
-
const s = () => this.options.prepend && a.toString() ? this.options.prepend + a.toString() : a.toString();
|
|
849
|
-
return this.options.compatibilityJSON === "v1" ? a === 1 ? "" : typeof a == "number" ? `_plural_${a.toString()}` : s() : this.options.compatibilityJSON === "v2" || this.options.simplifyPluralSuffix && e.numbers.length === 2 && e.numbers[0] === 1 ? s() : this.options.prepend && n.toString() ? this.options.prepend + n.toString() : n.toString();
|
|
850
|
-
}
|
|
851
|
-
shouldUseIntlApi() {
|
|
852
|
-
return !on.includes(this.options.compatibilityJSON);
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
function Ut(t, e, r) {
|
|
856
|
-
let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", a = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, s = jr(t, e, r);
|
|
857
|
-
return !s && a && typeof r == "string" && (s = _e(t, r, n), s === void 0 && (s = _e(e, r, n))), s;
|
|
858
|
-
}
|
|
859
|
-
class dn {
|
|
860
|
-
constructor() {
|
|
861
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
862
|
-
this.logger = Z.create("interpolator"), this.options = e, this.format = e.interpolation && e.interpolation.format || ((r) => r), this.init(e);
|
|
863
|
-
}
|
|
864
|
-
init() {
|
|
865
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
866
|
-
e.interpolation || (e.interpolation = {
|
|
867
|
-
escapeValue: !0
|
|
868
|
-
});
|
|
869
|
-
const r = e.interpolation;
|
|
870
|
-
this.escape = r.escape !== void 0 ? r.escape : tn, this.escapeValue = r.escapeValue !== void 0 ? r.escapeValue : !0, this.useRawValueToEscape = r.useRawValueToEscape !== void 0 ? r.useRawValueToEscape : !1, this.prefix = r.prefix ? oe(r.prefix) : r.prefixEscaped || "{{", this.suffix = r.suffix ? oe(r.suffix) : r.suffixEscaped || "}}", this.formatSeparator = r.formatSeparator ? r.formatSeparator : r.formatSeparator || ",", this.unescapePrefix = r.unescapeSuffix ? "" : r.unescapePrefix || "-", this.unescapeSuffix = this.unescapePrefix ? "" : r.unescapeSuffix || "", this.nestingPrefix = r.nestingPrefix ? oe(r.nestingPrefix) : r.nestingPrefixEscaped || oe("$t("), this.nestingSuffix = r.nestingSuffix ? oe(r.nestingSuffix) : r.nestingSuffixEscaped || oe(")"), this.nestingOptionsSeparator = r.nestingOptionsSeparator ? r.nestingOptionsSeparator : r.nestingOptionsSeparator || ",", this.maxReplaces = r.maxReplaces ? r.maxReplaces : 1e3, this.alwaysFormat = r.alwaysFormat !== void 0 ? r.alwaysFormat : !1, this.resetRegExp();
|
|
871
|
-
}
|
|
872
|
-
reset() {
|
|
873
|
-
this.options && this.init(this.options);
|
|
874
|
-
}
|
|
875
|
-
resetRegExp() {
|
|
876
|
-
const e = `${this.prefix}(.+?)${this.suffix}`;
|
|
877
|
-
this.regexp = new RegExp(e, "g");
|
|
878
|
-
const r = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
|
|
879
|
-
this.regexpUnescape = new RegExp(r, "g");
|
|
880
|
-
const n = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
|
|
881
|
-
this.nestingRegexp = new RegExp(n, "g");
|
|
882
|
-
}
|
|
883
|
-
interpolate(e, r, n, a) {
|
|
884
|
-
let s, i, o;
|
|
885
|
-
const c = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
886
|
-
function u(h) {
|
|
887
|
-
return h.replace(/\$/g, "$$$$");
|
|
888
|
-
}
|
|
889
|
-
const l = (h) => {
|
|
890
|
-
if (h.indexOf(this.formatSeparator) < 0) {
|
|
891
|
-
const v = Ut(r, c, h, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
892
|
-
return this.alwaysFormat ? this.format(v, void 0, n, {
|
|
893
|
-
...a,
|
|
894
|
-
...r,
|
|
895
|
-
interpolationkey: h
|
|
896
|
-
}) : v;
|
|
897
|
-
}
|
|
898
|
-
const g = h.split(this.formatSeparator), S = g.shift().trim(), C = g.join(this.formatSeparator).trim();
|
|
899
|
-
return this.format(Ut(r, c, S, this.options.keySeparator, this.options.ignoreJSONStructure), C, n, {
|
|
900
|
-
...a,
|
|
901
|
-
...r,
|
|
902
|
-
interpolationkey: S
|
|
903
|
-
});
|
|
904
|
-
};
|
|
905
|
-
this.resetRegExp();
|
|
906
|
-
const f = a && a.missingInterpolationHandler || this.options.missingInterpolationHandler, d = a && a.interpolation && a.interpolation.skipOnVariables !== void 0 ? a.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
907
|
-
return [{
|
|
908
|
-
regex: this.regexpUnescape,
|
|
909
|
-
safeValue: (h) => u(h)
|
|
910
|
-
}, {
|
|
911
|
-
regex: this.regexp,
|
|
912
|
-
safeValue: (h) => this.escapeValue ? u(this.escape(h)) : u(h)
|
|
913
|
-
}].forEach((h) => {
|
|
914
|
-
for (o = 0; s = h.regex.exec(e); ) {
|
|
915
|
-
const g = s[1].trim();
|
|
916
|
-
if (i = l(g), i === void 0)
|
|
917
|
-
if (typeof f == "function") {
|
|
918
|
-
const C = f(e, s, a);
|
|
919
|
-
i = typeof C == "string" ? C : "";
|
|
920
|
-
} else if (a && Object.prototype.hasOwnProperty.call(a, g))
|
|
921
|
-
i = "";
|
|
922
|
-
else if (d) {
|
|
923
|
-
i = s[0];
|
|
924
|
-
continue;
|
|
925
|
-
} else
|
|
926
|
-
this.logger.warn(`missed to pass in variable ${g} for interpolating ${e}`), i = "";
|
|
927
|
-
else
|
|
928
|
-
typeof i != "string" && !this.useRawValueToEscape && (i = Kt(i));
|
|
929
|
-
const S = h.safeValue(i);
|
|
930
|
-
if (e = e.replace(s[0], S), d ? (h.regex.lastIndex += i.length, h.regex.lastIndex -= s[0].length) : h.regex.lastIndex = 0, o++, o >= this.maxReplaces)
|
|
931
|
-
break;
|
|
932
|
-
}
|
|
933
|
-
}), e;
|
|
934
|
-
}
|
|
935
|
-
nest(e, r) {
|
|
936
|
-
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, a, s, i;
|
|
937
|
-
function o(c, u) {
|
|
938
|
-
const l = this.nestingOptionsSeparator;
|
|
939
|
-
if (c.indexOf(l) < 0)
|
|
940
|
-
return c;
|
|
941
|
-
const f = c.split(new RegExp(`${l}[ ]*{`));
|
|
942
|
-
let d = `{${f[1]}`;
|
|
943
|
-
c = f[0], d = this.interpolate(d, i);
|
|
944
|
-
const p = d.match(/'/g), h = d.match(/"/g);
|
|
945
|
-
(p && p.length % 2 === 0 && !h || h.length % 2 !== 0) && (d = d.replace(/'/g, '"'));
|
|
946
|
-
try {
|
|
947
|
-
i = JSON.parse(d), u && (i = {
|
|
948
|
-
...u,
|
|
949
|
-
...i
|
|
950
|
-
});
|
|
951
|
-
} catch (g) {
|
|
952
|
-
return this.logger.warn(`failed parsing options string in nesting for key ${c}`, g), `${c}${l}${d}`;
|
|
953
|
-
}
|
|
954
|
-
return delete i.defaultValue, c;
|
|
955
|
-
}
|
|
956
|
-
for (; a = this.nestingRegexp.exec(e); ) {
|
|
957
|
-
let c = [];
|
|
958
|
-
i = {
|
|
959
|
-
...n
|
|
960
|
-
}, i = i.replace && typeof i.replace != "string" ? i.replace : i, i.applyPostProcessor = !1, delete i.defaultValue;
|
|
961
|
-
let u = !1;
|
|
962
|
-
if (a[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(a[1])) {
|
|
963
|
-
const l = a[1].split(this.formatSeparator).map((f) => f.trim());
|
|
964
|
-
a[1] = l.shift(), c = l, u = !0;
|
|
965
|
-
}
|
|
966
|
-
if (s = r(o.call(this, a[1].trim(), i), i), s && a[0] === e && typeof s != "string")
|
|
967
|
-
return s;
|
|
968
|
-
typeof s != "string" && (s = Kt(s)), s || (this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`), s = ""), u && (s = c.reduce((l, f) => this.format(l, f, n.lng, {
|
|
969
|
-
...n,
|
|
970
|
-
interpolationkey: a[1].trim()
|
|
971
|
-
}), s.trim())), e = e.replace(a[0], s), this.regexp.lastIndex = 0;
|
|
972
|
-
}
|
|
973
|
-
return e;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
function fn(t) {
|
|
977
|
-
let e = t.toLowerCase().trim();
|
|
978
|
-
const r = {};
|
|
979
|
-
if (t.indexOf("(") > -1) {
|
|
980
|
-
const n = t.split("(");
|
|
981
|
-
e = n[0].toLowerCase().trim();
|
|
982
|
-
const a = n[1].substring(0, n[1].length - 1);
|
|
983
|
-
e === "currency" && a.indexOf(":") < 0 ? r.currency || (r.currency = a.trim()) : e === "relativetime" && a.indexOf(":") < 0 ? r.range || (r.range = a.trim()) : a.split(";").forEach((i) => {
|
|
984
|
-
if (!i)
|
|
985
|
-
return;
|
|
986
|
-
const [o, ...c] = i.split(":"), u = c.join(":").trim().replace(/^'+|'+$/g, "");
|
|
987
|
-
r[o.trim()] || (r[o.trim()] = u), u === "false" && (r[o.trim()] = !1), u === "true" && (r[o.trim()] = !0), isNaN(u) || (r[o.trim()] = parseInt(u, 10));
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
return {
|
|
991
|
-
formatName: e,
|
|
992
|
-
formatOptions: r
|
|
993
|
-
};
|
|
994
|
-
}
|
|
995
|
-
function ce(t) {
|
|
996
|
-
const e = {};
|
|
997
|
-
return function(n, a, s) {
|
|
998
|
-
const i = a + JSON.stringify(s);
|
|
999
|
-
let o = e[i];
|
|
1000
|
-
return o || (o = t(Pe(a), s), e[i] = o), o(n);
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
class hn {
|
|
1004
|
-
constructor() {
|
|
1005
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
1006
|
-
this.logger = Z.create("formatter"), this.options = e, this.formats = {
|
|
1007
|
-
number: ce((r, n) => {
|
|
1008
|
-
const a = new Intl.NumberFormat(r, {
|
|
1009
|
-
...n
|
|
1010
|
-
});
|
|
1011
|
-
return (s) => a.format(s);
|
|
1012
|
-
}),
|
|
1013
|
-
currency: ce((r, n) => {
|
|
1014
|
-
const a = new Intl.NumberFormat(r, {
|
|
1015
|
-
...n,
|
|
1016
|
-
style: "currency"
|
|
1017
|
-
});
|
|
1018
|
-
return (s) => a.format(s);
|
|
1019
|
-
}),
|
|
1020
|
-
datetime: ce((r, n) => {
|
|
1021
|
-
const a = new Intl.DateTimeFormat(r, {
|
|
1022
|
-
...n
|
|
1023
|
-
});
|
|
1024
|
-
return (s) => a.format(s);
|
|
1025
|
-
}),
|
|
1026
|
-
relativetime: ce((r, n) => {
|
|
1027
|
-
const a = new Intl.RelativeTimeFormat(r, {
|
|
1028
|
-
...n
|
|
1029
|
-
});
|
|
1030
|
-
return (s) => a.format(s, n.range || "day");
|
|
1031
|
-
}),
|
|
1032
|
-
list: ce((r, n) => {
|
|
1033
|
-
const a = new Intl.ListFormat(r, {
|
|
1034
|
-
...n
|
|
1035
|
-
});
|
|
1036
|
-
return (s) => a.format(s);
|
|
1037
|
-
})
|
|
1038
|
-
}, this.init(e);
|
|
1039
|
-
}
|
|
1040
|
-
init(e) {
|
|
1041
|
-
const n = (arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
1042
|
-
interpolation: {}
|
|
1043
|
-
}).interpolation;
|
|
1044
|
-
this.formatSeparator = n.formatSeparator ? n.formatSeparator : n.formatSeparator || ",";
|
|
1045
|
-
}
|
|
1046
|
-
add(e, r) {
|
|
1047
|
-
this.formats[e.toLowerCase().trim()] = r;
|
|
1048
|
-
}
|
|
1049
|
-
addCached(e, r) {
|
|
1050
|
-
this.formats[e.toLowerCase().trim()] = ce(r);
|
|
1051
|
-
}
|
|
1052
|
-
format(e, r, n) {
|
|
1053
|
-
let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
1054
|
-
return r.split(this.formatSeparator).reduce((o, c) => {
|
|
1055
|
-
const {
|
|
1056
|
-
formatName: u,
|
|
1057
|
-
formatOptions: l
|
|
1058
|
-
} = fn(c);
|
|
1059
|
-
if (this.formats[u]) {
|
|
1060
|
-
let f = o;
|
|
1061
|
-
try {
|
|
1062
|
-
const d = a && a.formatParams && a.formatParams[a.interpolationkey] || {}, p = d.locale || d.lng || a.locale || a.lng || n;
|
|
1063
|
-
f = this.formats[u](o, p, {
|
|
1064
|
-
...l,
|
|
1065
|
-
...a,
|
|
1066
|
-
...d
|
|
1067
|
-
});
|
|
1068
|
-
} catch (d) {
|
|
1069
|
-
this.logger.warn(d);
|
|
1070
|
-
}
|
|
1071
|
-
return f;
|
|
1072
|
-
} else
|
|
1073
|
-
this.logger.warn(`there was no format function for ${u}`);
|
|
1074
|
-
return o;
|
|
1075
|
-
}, e);
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
function pn(t, e) {
|
|
1079
|
-
t.pending[e] !== void 0 && (delete t.pending[e], t.pendingCount--);
|
|
1080
|
-
}
|
|
1081
|
-
class gn extends Ue {
|
|
1082
|
-
constructor(e, r, n) {
|
|
1083
|
-
let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
|
|
1084
|
-
super(), this.backend = e, this.store = r, this.services = n, this.languageUtils = n.languageUtils, this.options = a, this.logger = Z.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = a.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = a.maxRetries >= 0 ? a.maxRetries : 5, this.retryTimeout = a.retryTimeout >= 1 ? a.retryTimeout : 350, this.state = {}, this.queue = [], this.backend && this.backend.init && this.backend.init(n, a.backend, a);
|
|
1085
|
-
}
|
|
1086
|
-
queueLoad(e, r, n, a) {
|
|
1087
|
-
const s = {}, i = {}, o = {}, c = {};
|
|
1088
|
-
return e.forEach((u) => {
|
|
1089
|
-
let l = !0;
|
|
1090
|
-
r.forEach((f) => {
|
|
1091
|
-
const d = `${u}|${f}`;
|
|
1092
|
-
!n.reload && this.store.hasResourceBundle(u, f) ? this.state[d] = 2 : this.state[d] < 0 || (this.state[d] === 1 ? i[d] === void 0 && (i[d] = !0) : (this.state[d] = 1, l = !1, i[d] === void 0 && (i[d] = !0), s[d] === void 0 && (s[d] = !0), c[f] === void 0 && (c[f] = !0)));
|
|
1093
|
-
}), l || (o[u] = !0);
|
|
1094
|
-
}), (Object.keys(s).length || Object.keys(i).length) && this.queue.push({
|
|
1095
|
-
pending: i,
|
|
1096
|
-
pendingCount: Object.keys(i).length,
|
|
1097
|
-
loaded: {},
|
|
1098
|
-
errors: [],
|
|
1099
|
-
callback: a
|
|
1100
|
-
}), {
|
|
1101
|
-
toLoad: Object.keys(s),
|
|
1102
|
-
pending: Object.keys(i),
|
|
1103
|
-
toLoadLanguages: Object.keys(o),
|
|
1104
|
-
toLoadNamespaces: Object.keys(c)
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
loaded(e, r, n) {
|
|
1108
|
-
const a = e.split("|"), s = a[0], i = a[1];
|
|
1109
|
-
r && this.emit("failedLoading", s, i, r), n && this.store.addResourceBundle(s, i, n), this.state[e] = r ? -1 : 2;
|
|
1110
|
-
const o = {};
|
|
1111
|
-
this.queue.forEach((c) => {
|
|
1112
|
-
Qr(c.loaded, [s], i), pn(c, e), r && c.errors.push(r), c.pendingCount === 0 && !c.done && (Object.keys(c.loaded).forEach((u) => {
|
|
1113
|
-
o[u] || (o[u] = {});
|
|
1114
|
-
const l = c.loaded[u];
|
|
1115
|
-
l.length && l.forEach((f) => {
|
|
1116
|
-
o[u][f] === void 0 && (o[u][f] = !0);
|
|
1117
|
-
});
|
|
1118
|
-
}), c.done = !0, c.errors.length ? c.callback(c.errors) : c.callback());
|
|
1119
|
-
}), this.emit("loaded", o), this.queue = this.queue.filter((c) => !c.done);
|
|
1120
|
-
}
|
|
1121
|
-
read(e, r, n) {
|
|
1122
|
-
let a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, s = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, i = arguments.length > 5 ? arguments[5] : void 0;
|
|
1123
|
-
if (!e.length)
|
|
1124
|
-
return i(null, {});
|
|
1125
|
-
if (this.readingCalls >= this.maxParallelReads) {
|
|
1126
|
-
this.waitingReads.push({
|
|
1127
|
-
lng: e,
|
|
1128
|
-
ns: r,
|
|
1129
|
-
fcName: n,
|
|
1130
|
-
tried: a,
|
|
1131
|
-
wait: s,
|
|
1132
|
-
callback: i
|
|
1133
|
-
});
|
|
1134
|
-
return;
|
|
1135
|
-
}
|
|
1136
|
-
this.readingCalls++;
|
|
1137
|
-
const o = (u, l) => {
|
|
1138
|
-
if (this.readingCalls--, this.waitingReads.length > 0) {
|
|
1139
|
-
const f = this.waitingReads.shift();
|
|
1140
|
-
this.read(f.lng, f.ns, f.fcName, f.tried, f.wait, f.callback);
|
|
1141
|
-
}
|
|
1142
|
-
if (u && l && a < this.maxRetries) {
|
|
1143
|
-
setTimeout(() => {
|
|
1144
|
-
this.read.call(this, e, r, n, a + 1, s * 2, i);
|
|
1145
|
-
}, s);
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
i(u, l);
|
|
1149
|
-
}, c = this.backend[n].bind(this.backend);
|
|
1150
|
-
if (c.length === 2) {
|
|
1151
|
-
try {
|
|
1152
|
-
const u = c(e, r);
|
|
1153
|
-
u && typeof u.then == "function" ? u.then((l) => o(null, l)).catch(o) : o(null, u);
|
|
1154
|
-
} catch (u) {
|
|
1155
|
-
o(u);
|
|
1156
|
-
}
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
return c(e, r, o);
|
|
1160
|
-
}
|
|
1161
|
-
prepareLoading(e, r) {
|
|
1162
|
-
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, a = arguments.length > 3 ? arguments[3] : void 0;
|
|
1163
|
-
if (!this.backend)
|
|
1164
|
-
return this.logger.warn("No backend was added via i18next.use. Will not load resources."), a && a();
|
|
1165
|
-
typeof e == "string" && (e = this.languageUtils.toResolveHierarchy(e)), typeof r == "string" && (r = [r]);
|
|
1166
|
-
const s = this.queueLoad(e, r, n, a);
|
|
1167
|
-
if (!s.toLoad.length)
|
|
1168
|
-
return s.pending.length || a(), null;
|
|
1169
|
-
s.toLoad.forEach((i) => {
|
|
1170
|
-
this.loadOne(i);
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
load(e, r, n) {
|
|
1174
|
-
this.prepareLoading(e, r, {}, n);
|
|
1175
|
-
}
|
|
1176
|
-
reload(e, r, n) {
|
|
1177
|
-
this.prepareLoading(e, r, {
|
|
1178
|
-
reload: !0
|
|
1179
|
-
}, n);
|
|
1180
|
-
}
|
|
1181
|
-
loadOne(e) {
|
|
1182
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
1183
|
-
const n = e.split("|"), a = n[0], s = n[1];
|
|
1184
|
-
this.read(a, s, "read", void 0, void 0, (i, o) => {
|
|
1185
|
-
i && this.logger.warn(`${r}loading namespace ${s} for language ${a} failed`, i), !i && o && this.logger.log(`${r}loaded namespace ${s} for language ${a}`, o), this.loaded(e, i, o);
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
|
-
saveMissing(e, r, n, a, s) {
|
|
1189
|
-
let i = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, o = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
|
|
1190
|
-
};
|
|
1191
|
-
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(r)) {
|
|
1192
|
-
this.logger.warn(`did not save key "${n}" as the namespace "${r}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
if (!(n == null || n === "")) {
|
|
1196
|
-
if (this.backend && this.backend.create) {
|
|
1197
|
-
const c = {
|
|
1198
|
-
...i,
|
|
1199
|
-
isUpdate: s
|
|
1200
|
-
}, u = this.backend.create.bind(this.backend);
|
|
1201
|
-
if (u.length < 6)
|
|
1202
|
-
try {
|
|
1203
|
-
let l;
|
|
1204
|
-
u.length === 5 ? l = u(e, r, n, a, c) : l = u(e, r, n, a), l && typeof l.then == "function" ? l.then((f) => o(null, f)).catch(o) : o(null, l);
|
|
1205
|
-
} catch (l) {
|
|
1206
|
-
o(l);
|
|
1207
|
-
}
|
|
1208
|
-
else
|
|
1209
|
-
u(e, r, n, a, o, c);
|
|
1210
|
-
}
|
|
1211
|
-
!e || !e[0] || this.store.addResource(e[0], r, n, a);
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
function Lt() {
|
|
1216
|
-
return {
|
|
1217
|
-
debug: !1,
|
|
1218
|
-
initImmediate: !0,
|
|
1219
|
-
ns: ["translation"],
|
|
1220
|
-
defaultNS: ["translation"],
|
|
1221
|
-
fallbackLng: ["dev"],
|
|
1222
|
-
fallbackNS: !1,
|
|
1223
|
-
supportedLngs: !1,
|
|
1224
|
-
nonExplicitSupportedLngs: !1,
|
|
1225
|
-
load: "all",
|
|
1226
|
-
preload: !1,
|
|
1227
|
-
simplifyPluralSuffix: !0,
|
|
1228
|
-
keySeparator: ".",
|
|
1229
|
-
nsSeparator: ":",
|
|
1230
|
-
pluralSeparator: "_",
|
|
1231
|
-
contextSeparator: "_",
|
|
1232
|
-
partialBundledLanguages: !1,
|
|
1233
|
-
saveMissing: !1,
|
|
1234
|
-
updateMissing: !1,
|
|
1235
|
-
saveMissingTo: "fallback",
|
|
1236
|
-
saveMissingPlurals: !0,
|
|
1237
|
-
missingKeyHandler: !1,
|
|
1238
|
-
missingInterpolationHandler: !1,
|
|
1239
|
-
postProcess: !1,
|
|
1240
|
-
postProcessPassResolved: !1,
|
|
1241
|
-
returnNull: !1,
|
|
1242
|
-
returnEmptyString: !0,
|
|
1243
|
-
returnObjects: !1,
|
|
1244
|
-
joinArrays: !1,
|
|
1245
|
-
returnedObjectHandler: !1,
|
|
1246
|
-
parseMissingKeyHandler: !1,
|
|
1247
|
-
appendNamespaceToMissingKey: !1,
|
|
1248
|
-
appendNamespaceToCIMode: !1,
|
|
1249
|
-
overloadTranslationOptionHandler: function(e) {
|
|
1250
|
-
let r = {};
|
|
1251
|
-
if (typeof e[1] == "object" && (r = e[1]), typeof e[1] == "string" && (r.defaultValue = e[1]), typeof e[2] == "string" && (r.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
|
|
1252
|
-
const n = e[3] || e[2];
|
|
1253
|
-
Object.keys(n).forEach((a) => {
|
|
1254
|
-
r[a] = n[a];
|
|
1255
|
-
});
|
|
1256
|
-
}
|
|
1257
|
-
return r;
|
|
1258
|
-
},
|
|
1259
|
-
interpolation: {
|
|
1260
|
-
escapeValue: !0,
|
|
1261
|
-
format: (t) => t,
|
|
1262
|
-
prefix: "{{",
|
|
1263
|
-
suffix: "}}",
|
|
1264
|
-
formatSeparator: ",",
|
|
1265
|
-
unescapePrefix: "-",
|
|
1266
|
-
nestingPrefix: "$t(",
|
|
1267
|
-
nestingSuffix: ")",
|
|
1268
|
-
nestingOptionsSeparator: ",",
|
|
1269
|
-
maxReplaces: 1e3,
|
|
1270
|
-
skipOnVariables: !0
|
|
1271
|
-
}
|
|
1272
|
-
};
|
|
1273
|
-
}
|
|
1274
|
-
function Dt(t) {
|
|
1275
|
-
return typeof t.ns == "string" && (t.ns = [t.ns]), typeof t.fallbackLng == "string" && (t.fallbackLng = [t.fallbackLng]), typeof t.fallbackNS == "string" && (t.fallbackNS = [t.fallbackNS]), t.supportedLngs && t.supportedLngs.indexOf("cimode") < 0 && (t.supportedLngs = t.supportedLngs.concat(["cimode"])), t;
|
|
1276
|
-
}
|
|
1277
|
-
function Se() {
|
|
1278
|
-
}
|
|
1279
|
-
function mn(t) {
|
|
1280
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach((r) => {
|
|
1281
|
-
typeof t[r] == "function" && (t[r] = t[r].bind(t));
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
|
-
class pe extends Ue {
|
|
1285
|
-
constructor() {
|
|
1286
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, r = arguments.length > 1 ? arguments[1] : void 0;
|
|
1287
|
-
if (super(), this.options = Dt(e), this.services = {}, this.logger = Z, this.modules = {
|
|
1288
|
-
external: []
|
|
1289
|
-
}, mn(this), r && !this.isInitialized && !e.isClone) {
|
|
1290
|
-
if (!this.options.initImmediate)
|
|
1291
|
-
return this.init(e, r), this;
|
|
1292
|
-
setTimeout(() => {
|
|
1293
|
-
this.init(e, r);
|
|
1294
|
-
}, 0);
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
init() {
|
|
1298
|
-
var e = this;
|
|
1299
|
-
let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = arguments.length > 1 ? arguments[1] : void 0;
|
|
1300
|
-
typeof r == "function" && (n = r, r = {}), !r.defaultNS && r.defaultNS !== !1 && r.ns && (typeof r.ns == "string" ? r.defaultNS = r.ns : r.ns.indexOf("translation") < 0 && (r.defaultNS = r.ns[0]));
|
|
1301
|
-
const a = Lt();
|
|
1302
|
-
this.options = {
|
|
1303
|
-
...a,
|
|
1304
|
-
...this.options,
|
|
1305
|
-
...Dt(r)
|
|
1306
|
-
}, this.options.compatibilityAPI !== "v1" && (this.options.interpolation = {
|
|
1307
|
-
...a.interpolation,
|
|
1308
|
-
...this.options.interpolation
|
|
1309
|
-
}), r.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = r.keySeparator), r.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = r.nsSeparator);
|
|
1310
|
-
function s(l) {
|
|
1311
|
-
return l ? typeof l == "function" ? new l() : l : null;
|
|
1312
|
-
}
|
|
1313
|
-
if (!this.options.isClone) {
|
|
1314
|
-
this.modules.logger ? Z.init(s(this.modules.logger), this.options) : Z.init(null, this.options);
|
|
1315
|
-
let l;
|
|
1316
|
-
this.modules.formatter ? l = this.modules.formatter : typeof Intl < "u" && (l = hn);
|
|
1317
|
-
const f = new It(this.options);
|
|
1318
|
-
this.store = new Ot(this.options.resources, this.options);
|
|
1319
|
-
const d = this.services;
|
|
1320
|
-
d.logger = Z, d.resourceStore = this.store, d.languageUtils = f, d.pluralResolver = new ln(f, {
|
|
1321
|
-
prepend: this.options.pluralSeparator,
|
|
1322
|
-
compatibilityJSON: this.options.compatibilityJSON,
|
|
1323
|
-
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1324
|
-
}), l && (!this.options.interpolation.format || this.options.interpolation.format === a.interpolation.format) && (d.formatter = s(l), d.formatter.init(d, this.options), this.options.interpolation.format = d.formatter.format.bind(d.formatter)), d.interpolator = new dn(this.options), d.utils = {
|
|
1325
|
-
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1326
|
-
}, d.backendConnector = new gn(s(this.modules.backend), d.resourceStore, d, this.options), d.backendConnector.on("*", function(p) {
|
|
1327
|
-
for (var h = arguments.length, g = new Array(h > 1 ? h - 1 : 0), S = 1; S < h; S++)
|
|
1328
|
-
g[S - 1] = arguments[S];
|
|
1329
|
-
e.emit(p, ...g);
|
|
1330
|
-
}), this.modules.languageDetector && (d.languageDetector = s(this.modules.languageDetector), d.languageDetector.init && d.languageDetector.init(d, this.options.detection, this.options)), this.modules.i18nFormat && (d.i18nFormat = s(this.modules.i18nFormat), d.i18nFormat.init && d.i18nFormat.init(this)), this.translator = new He(this.services, this.options), this.translator.on("*", function(p) {
|
|
1331
|
-
for (var h = arguments.length, g = new Array(h > 1 ? h - 1 : 0), S = 1; S < h; S++)
|
|
1332
|
-
g[S - 1] = arguments[S];
|
|
1333
|
-
e.emit(p, ...g);
|
|
1334
|
-
}), this.modules.external.forEach((p) => {
|
|
1335
|
-
p.init && p.init(this);
|
|
1336
|
-
});
|
|
1337
|
-
}
|
|
1338
|
-
if (this.format = this.options.interpolation.format, n || (n = Se), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
1339
|
-
const l = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
1340
|
-
l.length > 0 && l[0] !== "dev" && (this.options.lng = l[0]);
|
|
1341
|
-
}
|
|
1342
|
-
!this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((l) => {
|
|
1343
|
-
this[l] = function() {
|
|
1344
|
-
return e.store[l](...arguments);
|
|
1345
|
-
};
|
|
1346
|
-
}), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((l) => {
|
|
1347
|
-
this[l] = function() {
|
|
1348
|
-
return e.store[l](...arguments), e;
|
|
1349
|
-
};
|
|
1350
|
-
});
|
|
1351
|
-
const c = he(), u = () => {
|
|
1352
|
-
const l = (f, d) => {
|
|
1353
|
-
this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), c.resolve(d), n(f, d);
|
|
1354
|
-
};
|
|
1355
|
-
if (this.languages && this.options.compatibilityAPI !== "v1" && !this.isInitialized)
|
|
1356
|
-
return l(null, this.t.bind(this));
|
|
1357
|
-
this.changeLanguage(this.options.lng, l);
|
|
1358
|
-
};
|
|
1359
|
-
return this.options.resources || !this.options.initImmediate ? u() : setTimeout(u, 0), c;
|
|
1360
|
-
}
|
|
1361
|
-
loadResources(e) {
|
|
1362
|
-
let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Se;
|
|
1363
|
-
const a = typeof e == "string" ? e : this.language;
|
|
1364
|
-
if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
|
|
1365
|
-
if (a && a.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0))
|
|
1366
|
-
return n();
|
|
1367
|
-
const s = [], i = (o) => {
|
|
1368
|
-
if (!o || o === "cimode")
|
|
1369
|
-
return;
|
|
1370
|
-
this.services.languageUtils.toResolveHierarchy(o).forEach((u) => {
|
|
1371
|
-
u !== "cimode" && s.indexOf(u) < 0 && s.push(u);
|
|
1372
|
-
});
|
|
1373
|
-
};
|
|
1374
|
-
a ? i(a) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((c) => i(c)), this.options.preload && this.options.preload.forEach((o) => i(o)), this.services.backendConnector.load(s, this.options.ns, (o) => {
|
|
1375
|
-
!o && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(o);
|
|
1376
|
-
});
|
|
1377
|
-
} else
|
|
1378
|
-
n(null);
|
|
1379
|
-
}
|
|
1380
|
-
reloadResources(e, r, n) {
|
|
1381
|
-
const a = he();
|
|
1382
|
-
return e || (e = this.languages), r || (r = this.options.ns), n || (n = Se), this.services.backendConnector.reload(e, r, (s) => {
|
|
1383
|
-
a.resolve(), n(s);
|
|
1384
|
-
}), a;
|
|
1385
|
-
}
|
|
1386
|
-
use(e) {
|
|
1387
|
-
if (!e)
|
|
1388
|
-
throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
|
|
1389
|
-
if (!e.type)
|
|
1390
|
-
throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
|
|
1391
|
-
return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && jt.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
|
|
1392
|
-
}
|
|
1393
|
-
setResolvedLanguage(e) {
|
|
1394
|
-
if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1))
|
|
1395
|
-
for (let r = 0; r < this.languages.length; r++) {
|
|
1396
|
-
const n = this.languages[r];
|
|
1397
|
-
if (!(["cimode", "dev"].indexOf(n) > -1) && this.store.hasLanguageSomeTranslations(n)) {
|
|
1398
|
-
this.resolvedLanguage = n;
|
|
1399
|
-
break;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
changeLanguage(e, r) {
|
|
1404
|
-
var n = this;
|
|
1405
|
-
this.isLanguageChangingTo = e;
|
|
1406
|
-
const a = he();
|
|
1407
|
-
this.emit("languageChanging", e);
|
|
1408
|
-
const s = (c) => {
|
|
1409
|
-
this.language = c, this.languages = this.services.languageUtils.toResolveHierarchy(c), this.resolvedLanguage = void 0, this.setResolvedLanguage(c);
|
|
1410
|
-
}, i = (c, u) => {
|
|
1411
|
-
u ? (s(u), this.translator.changeLanguage(u), this.isLanguageChangingTo = void 0, this.emit("languageChanged", u), this.logger.log("languageChanged", u)) : this.isLanguageChangingTo = void 0, a.resolve(function() {
|
|
1412
|
-
return n.t(...arguments);
|
|
1413
|
-
}), r && r(c, function() {
|
|
1414
|
-
return n.t(...arguments);
|
|
1415
|
-
});
|
|
1416
|
-
}, o = (c) => {
|
|
1417
|
-
!e && !c && this.services.languageDetector && (c = []);
|
|
1418
|
-
const u = typeof c == "string" ? c : this.services.languageUtils.getBestMatchFromCodes(c);
|
|
1419
|
-
u && (this.language || s(u), this.translator.language || this.translator.changeLanguage(u), this.services.languageDetector && this.services.languageDetector.cacheUserLanguage && this.services.languageDetector.cacheUserLanguage(u)), this.loadResources(u, (l) => {
|
|
1420
|
-
i(l, u);
|
|
1421
|
-
});
|
|
1422
|
-
};
|
|
1423
|
-
return !e && this.services.languageDetector && !this.services.languageDetector.async ? o(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(o) : this.services.languageDetector.detect(o) : o(e), a;
|
|
1424
|
-
}
|
|
1425
|
-
getFixedT(e, r, n) {
|
|
1426
|
-
var a = this;
|
|
1427
|
-
const s = function(i, o) {
|
|
1428
|
-
let c;
|
|
1429
|
-
if (typeof o != "object") {
|
|
1430
|
-
for (var u = arguments.length, l = new Array(u > 2 ? u - 2 : 0), f = 2; f < u; f++)
|
|
1431
|
-
l[f - 2] = arguments[f];
|
|
1432
|
-
c = a.options.overloadTranslationOptionHandler([i, o].concat(l));
|
|
1433
|
-
} else
|
|
1434
|
-
c = {
|
|
1435
|
-
...o
|
|
1436
|
-
};
|
|
1437
|
-
c.lng = c.lng || s.lng, c.lngs = c.lngs || s.lngs, c.ns = c.ns || s.ns, c.keyPrefix = c.keyPrefix || n || s.keyPrefix;
|
|
1438
|
-
const d = a.options.keySeparator || ".";
|
|
1439
|
-
let p;
|
|
1440
|
-
return c.keyPrefix && Array.isArray(i) ? p = i.map((h) => `${c.keyPrefix}${d}${h}`) : p = c.keyPrefix ? `${c.keyPrefix}${d}${i}` : i, a.t(p, c);
|
|
1441
|
-
};
|
|
1442
|
-
return typeof e == "string" ? s.lng = e : s.lngs = e, s.ns = r, s.keyPrefix = n, s;
|
|
1443
|
-
}
|
|
1444
|
-
t() {
|
|
1445
|
-
return this.translator && this.translator.translate(...arguments);
|
|
1446
|
-
}
|
|
1447
|
-
exists() {
|
|
1448
|
-
return this.translator && this.translator.exists(...arguments);
|
|
1449
|
-
}
|
|
1450
|
-
setDefaultNamespace(e) {
|
|
1451
|
-
this.options.defaultNS = e;
|
|
1452
|
-
}
|
|
1453
|
-
hasLoadedNamespace(e) {
|
|
1454
|
-
let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
1455
|
-
if (!this.isInitialized)
|
|
1456
|
-
return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
|
|
1457
|
-
if (!this.languages || !this.languages.length)
|
|
1458
|
-
return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
|
|
1459
|
-
const n = r.lng || this.resolvedLanguage || this.languages[0], a = this.options ? this.options.fallbackLng : !1, s = this.languages[this.languages.length - 1];
|
|
1460
|
-
if (n.toLowerCase() === "cimode")
|
|
1461
|
-
return !0;
|
|
1462
|
-
const i = (o, c) => {
|
|
1463
|
-
const u = this.services.backendConnector.state[`${o}|${c}`];
|
|
1464
|
-
return u === -1 || u === 2;
|
|
1465
|
-
};
|
|
1466
|
-
if (r.precheck) {
|
|
1467
|
-
const o = r.precheck(this, i);
|
|
1468
|
-
if (o !== void 0)
|
|
1469
|
-
return o;
|
|
1470
|
-
}
|
|
1471
|
-
return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || i(n, e) && (!a || i(s, e)));
|
|
1472
|
-
}
|
|
1473
|
-
loadNamespaces(e, r) {
|
|
1474
|
-
const n = he();
|
|
1475
|
-
return this.options.ns ? (typeof e == "string" && (e = [e]), e.forEach((a) => {
|
|
1476
|
-
this.options.ns.indexOf(a) < 0 && this.options.ns.push(a);
|
|
1477
|
-
}), this.loadResources((a) => {
|
|
1478
|
-
n.resolve(), r && r(a);
|
|
1479
|
-
}), n) : (r && r(), Promise.resolve());
|
|
1480
|
-
}
|
|
1481
|
-
loadLanguages(e, r) {
|
|
1482
|
-
const n = he();
|
|
1483
|
-
typeof e == "string" && (e = [e]);
|
|
1484
|
-
const a = this.options.preload || [], s = e.filter((i) => a.indexOf(i) < 0);
|
|
1485
|
-
return s.length ? (this.options.preload = a.concat(s), this.loadResources((i) => {
|
|
1486
|
-
n.resolve(), r && r(i);
|
|
1487
|
-
}), n) : (r && r(), Promise.resolve());
|
|
1488
|
-
}
|
|
1489
|
-
dir(e) {
|
|
1490
|
-
if (e || (e = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language)), !e)
|
|
1491
|
-
return "rtl";
|
|
1492
|
-
const r = ["ar", "shu", "sqr", "ssh", "xaa", "yhd", "yud", "aao", "abh", "abv", "acm", "acq", "acw", "acx", "acy", "adf", "ads", "aeb", "aec", "afb", "ajp", "apc", "apd", "arb", "arq", "ars", "ary", "arz", "auz", "avl", "ayh", "ayl", "ayn", "ayp", "bbz", "pga", "he", "iw", "ps", "pbt", "pbu", "pst", "prp", "prd", "ug", "ur", "ydd", "yds", "yih", "ji", "yi", "hbo", "men", "xmn", "fa", "jpr", "peo", "pes", "prs", "dv", "sam", "ckb"], n = this.services && this.services.languageUtils || new It(Lt());
|
|
1493
|
-
return r.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
|
|
1494
|
-
}
|
|
1495
|
-
static createInstance() {
|
|
1496
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, r = arguments.length > 1 ? arguments[1] : void 0;
|
|
1497
|
-
return new pe(e, r);
|
|
1498
|
-
}
|
|
1499
|
-
cloneInstance() {
|
|
1500
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Se;
|
|
1501
|
-
const n = e.forkResourceStore;
|
|
1502
|
-
n && delete e.forkResourceStore;
|
|
1503
|
-
const a = {
|
|
1504
|
-
...this.options,
|
|
1505
|
-
...e,
|
|
1506
|
-
isClone: !0
|
|
1507
|
-
}, s = new pe(a);
|
|
1508
|
-
return (e.debug !== void 0 || e.prefix !== void 0) && (s.logger = s.logger.clone(e)), ["store", "services", "language"].forEach((o) => {
|
|
1509
|
-
s[o] = this[o];
|
|
1510
|
-
}), s.services = {
|
|
1511
|
-
...this.services
|
|
1512
|
-
}, s.services.utils = {
|
|
1513
|
-
hasLoadedNamespace: s.hasLoadedNamespace.bind(s)
|
|
1514
|
-
}, n && (s.store = new Ot(this.store.data, a), s.services.resourceStore = s.store), s.translator = new He(s.services, a), s.translator.on("*", function(o) {
|
|
1515
|
-
for (var c = arguments.length, u = new Array(c > 1 ? c - 1 : 0), l = 1; l < c; l++)
|
|
1516
|
-
u[l - 1] = arguments[l];
|
|
1517
|
-
s.emit(o, ...u);
|
|
1518
|
-
}), s.init(a, r), s.translator.options = a, s.translator.backendConnector.services.utils = {
|
|
1519
|
-
hasLoadedNamespace: s.hasLoadedNamespace.bind(s)
|
|
1520
|
-
}, s;
|
|
1521
|
-
}
|
|
1522
|
-
toJSON() {
|
|
1523
|
-
return {
|
|
1524
|
-
options: this.options,
|
|
1525
|
-
store: this.store,
|
|
1526
|
-
language: this.language,
|
|
1527
|
-
languages: this.languages,
|
|
1528
|
-
resolvedLanguage: this.resolvedLanguage
|
|
1529
|
-
};
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
const k = pe.createInstance();
|
|
1533
|
-
k.createInstance = pe.createInstance;
|
|
1534
|
-
k.createInstance;
|
|
1535
|
-
k.dir;
|
|
1536
|
-
k.init;
|
|
1537
|
-
k.loadResources;
|
|
1538
|
-
k.reloadResources;
|
|
1539
|
-
k.use;
|
|
1540
|
-
k.changeLanguage;
|
|
1541
|
-
k.getFixedT;
|
|
1542
|
-
const be = k.t;
|
|
1543
|
-
k.exists;
|
|
1544
|
-
k.setDefaultNamespace;
|
|
1545
|
-
k.hasLoadedNamespace;
|
|
1546
|
-
k.loadNamespaces;
|
|
1547
|
-
k.loadLanguages;
|
|
1548
|
-
const yn = {
|
|
1549
|
-
es: {
|
|
1550
|
-
translation: {
|
|
1551
|
-
...qr
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
};
|
|
1555
|
-
k.init({
|
|
1556
|
-
resources: yn,
|
|
1557
|
-
lng: "es",
|
|
1558
|
-
// language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
|
|
1559
|
-
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
|
|
1560
|
-
// if you're using a language detector, do not define the lng option
|
|
1561
|
-
supportedLngs: ["es", "en"],
|
|
1562
|
-
interpolation: {
|
|
1563
|
-
escapeValue: !1
|
|
1564
|
-
// react already safes from xss
|
|
1565
|
-
},
|
|
1566
|
-
debug: !1
|
|
1567
|
-
});
|
|
1568
|
-
const j = {
|
|
1569
|
-
// EXAMPLE ERROR
|
|
1570
|
-
"MP-001": {
|
|
1571
|
-
code: 400,
|
|
1572
|
-
type: "modal",
|
|
1573
|
-
message: "errors.MP-001.message",
|
|
1574
|
-
title: "errors.MP-001.title",
|
|
1575
|
-
level: "info"
|
|
1576
|
-
},
|
|
1577
|
-
UNAUTHORIZED: {
|
|
1578
|
-
level: "error",
|
|
1579
|
-
type: "modal",
|
|
1580
|
-
message: "errors.UnAuthorized.message",
|
|
1581
|
-
title: "errors.UnAuthorized.title",
|
|
1582
|
-
code: 310
|
|
1583
|
-
},
|
|
1584
|
-
"ERR-GENERAL-01": {
|
|
1585
|
-
level: "error",
|
|
1586
|
-
type: "modal",
|
|
1587
|
-
message: "errors.ERR-GENERAL-01.message",
|
|
1588
|
-
title: "errors.ERR-GENERAL-01.title",
|
|
1589
|
-
code: 400
|
|
1590
|
-
},
|
|
1591
|
-
internalError: {
|
|
1592
|
-
level: "error",
|
|
1593
|
-
type: "modal",
|
|
1594
|
-
message: "errors.internalError.message",
|
|
1595
|
-
title: "errors.internalError.title",
|
|
1596
|
-
code: 500
|
|
1597
|
-
},
|
|
1598
|
-
default: {
|
|
1599
|
-
code: 520,
|
|
1600
|
-
type: "modal",
|
|
1601
|
-
message: "errors.default.message",
|
|
1602
|
-
title: "errors.default.title",
|
|
1603
|
-
level: "warning"
|
|
1604
|
-
}
|
|
1605
|
-
};
|
|
1606
|
-
class wn extends Xr {
|
|
1607
|
-
get(e = "default", r) {
|
|
1608
|
-
var s, i;
|
|
1609
|
-
if (e instanceof Error)
|
|
1610
|
-
return this.logError(e.message), {
|
|
1611
|
-
...j.internalError,
|
|
1612
|
-
title: be(j.internalError.title),
|
|
1613
|
-
message: be(j.internalError.message),
|
|
1614
|
-
uuid: r
|
|
1615
|
-
};
|
|
1616
|
-
const n = typeof e == "string" ? e : e.code ?? e.errorType, a = typeof e == "string" ? {} : { ...e };
|
|
1617
|
-
return {
|
|
1618
|
-
...j[n] ?? j.default,
|
|
1619
|
-
title: be(
|
|
1620
|
-
((s = j[n]) == null ? void 0 : s.title) ?? j.default.title,
|
|
1621
|
-
a
|
|
1622
|
-
),
|
|
1623
|
-
message: be(
|
|
1624
|
-
((i = j[n]) == null ? void 0 : i.message) ?? j.default.message,
|
|
1625
|
-
a
|
|
1626
|
-
),
|
|
1627
|
-
uuid: r
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
var er = {}, tr = { exports: {} };
|
|
1632
|
-
(function(t) {
|
|
1633
|
-
function e(r) {
|
|
1634
|
-
return r && r.__esModule ? r : {
|
|
1635
|
-
default: r
|
|
1636
|
-
};
|
|
1637
|
-
}
|
|
1638
|
-
t.exports = e, t.exports.__esModule = !0, t.exports.default = t.exports;
|
|
1639
|
-
})(tr);
|
|
1640
|
-
var rr = tr.exports;
|
|
1641
|
-
const b = crypto, G = (t) => t instanceof CryptoKey, nr = async (t, e) => {
|
|
1642
|
-
const r = `SHA-${t.slice(-3)}`;
|
|
1643
|
-
return new Uint8Array(await b.subtle.digest(r, e));
|
|
1644
|
-
}, K = new TextEncoder(), X = new TextDecoder(), Ke = 2 ** 32;
|
|
1645
|
-
function Q(...t) {
|
|
1646
|
-
const e = t.reduce((a, { length: s }) => a + s, 0), r = new Uint8Array(e);
|
|
1647
|
-
let n = 0;
|
|
1648
|
-
return t.forEach((a) => {
|
|
1649
|
-
r.set(a, n), n += a.length;
|
|
1650
|
-
}), r;
|
|
1651
|
-
}
|
|
1652
|
-
function Sn(t, e) {
|
|
1653
|
-
return Q(K.encode(t), new Uint8Array([0]), e);
|
|
1654
|
-
}
|
|
1655
|
-
function it(t, e, r) {
|
|
1656
|
-
if (e < 0 || e >= Ke)
|
|
1657
|
-
throw new RangeError(`value must be >= 0 and <= ${Ke - 1}. Received ${e}`);
|
|
1658
|
-
t.set([e >>> 24, e >>> 16, e >>> 8, e & 255], r);
|
|
1659
|
-
}
|
|
1660
|
-
function ar(t) {
|
|
1661
|
-
const e = Math.floor(t / Ke), r = t % Ke, n = new Uint8Array(8);
|
|
1662
|
-
return it(n, e, 0), it(n, r, 4), n;
|
|
1663
|
-
}
|
|
1664
|
-
function pt(t) {
|
|
1665
|
-
const e = new Uint8Array(4);
|
|
1666
|
-
return it(e, t), e;
|
|
1667
|
-
}
|
|
1668
|
-
function ze(t) {
|
|
1669
|
-
return Q(pt(t.length), t);
|
|
1670
|
-
}
|
|
1671
|
-
async function bn(t, e, r) {
|
|
1672
|
-
const n = Math.ceil((e >> 3) / 32), a = new Uint8Array(n * 32);
|
|
1673
|
-
for (let s = 0; s < n; s++) {
|
|
1674
|
-
const i = new Uint8Array(4 + t.length + r.length);
|
|
1675
|
-
i.set(pt(s + 1)), i.set(t, 4), i.set(r, 4 + t.length), a.set(await nr("sha256", i), s * 32);
|
|
1676
|
-
}
|
|
1677
|
-
return a.slice(0, e >> 3);
|
|
1678
|
-
}
|
|
1679
|
-
const gt = (t) => {
|
|
1680
|
-
let e = t;
|
|
1681
|
-
typeof e == "string" && (e = K.encode(e));
|
|
1682
|
-
const r = 32768, n = [];
|
|
1683
|
-
for (let a = 0; a < e.length; a += r)
|
|
1684
|
-
n.push(String.fromCharCode.apply(null, e.subarray(a, a + r)));
|
|
1685
|
-
return btoa(n.join(""));
|
|
1686
|
-
}, O = (t) => gt(t).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"), sr = (t) => {
|
|
1687
|
-
const e = atob(t), r = new Uint8Array(e.length);
|
|
1688
|
-
for (let n = 0; n < e.length; n++)
|
|
1689
|
-
r[n] = e.charCodeAt(n);
|
|
1690
|
-
return r;
|
|
1691
|
-
}, T = (t) => {
|
|
1692
|
-
let e = t;
|
|
1693
|
-
e instanceof Uint8Array && (e = X.decode(e)), e = e.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
1694
|
-
try {
|
|
1695
|
-
return sr(e);
|
|
1696
|
-
} catch {
|
|
1697
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
1698
|
-
}
|
|
1699
|
-
};
|
|
1700
|
-
class L extends Error {
|
|
1701
|
-
static get code() {
|
|
1702
|
-
return "ERR_JOSE_GENERIC";
|
|
1703
|
-
}
|
|
1704
|
-
constructor(e) {
|
|
1705
|
-
var r;
|
|
1706
|
-
super(e), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (r = Error.captureStackTrace) === null || r === void 0 || r.call(Error, this, this.constructor);
|
|
1707
|
-
}
|
|
1708
|
-
}
|
|
1709
|
-
class V extends L {
|
|
1710
|
-
static get code() {
|
|
1711
|
-
return "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
1712
|
-
}
|
|
1713
|
-
constructor(e, r = "unspecified", n = "unspecified") {
|
|
1714
|
-
super(e), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = r, this.reason = n;
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
class ot extends L {
|
|
1718
|
-
static get code() {
|
|
1719
|
-
return "ERR_JWT_EXPIRED";
|
|
1720
|
-
}
|
|
1721
|
-
constructor(e, r = "unspecified", n = "unspecified") {
|
|
1722
|
-
super(e), this.code = "ERR_JWT_EXPIRED", this.claim = r, this.reason = n;
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
class Re extends L {
|
|
1726
|
-
constructor() {
|
|
1727
|
-
super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
1728
|
-
}
|
|
1729
|
-
static get code() {
|
|
1730
|
-
return "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
class x extends L {
|
|
1734
|
-
constructor() {
|
|
1735
|
-
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
1736
|
-
}
|
|
1737
|
-
static get code() {
|
|
1738
|
-
return "ERR_JOSE_NOT_SUPPORTED";
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
class ge extends L {
|
|
1742
|
-
constructor() {
|
|
1743
|
-
super(...arguments), this.code = "ERR_JWE_DECRYPTION_FAILED", this.message = "decryption operation failed";
|
|
1744
|
-
}
|
|
1745
|
-
static get code() {
|
|
1746
|
-
return "ERR_JWE_DECRYPTION_FAILED";
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
class y extends L {
|
|
1750
|
-
constructor() {
|
|
1751
|
-
super(...arguments), this.code = "ERR_JWE_INVALID";
|
|
1752
|
-
}
|
|
1753
|
-
static get code() {
|
|
1754
|
-
return "ERR_JWE_INVALID";
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
class P extends L {
|
|
1758
|
-
constructor() {
|
|
1759
|
-
super(...arguments), this.code = "ERR_JWS_INVALID";
|
|
1760
|
-
}
|
|
1761
|
-
static get code() {
|
|
1762
|
-
return "ERR_JWS_INVALID";
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
class B extends L {
|
|
1766
|
-
constructor() {
|
|
1767
|
-
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
1768
|
-
}
|
|
1769
|
-
static get code() {
|
|
1770
|
-
return "ERR_JWT_INVALID";
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
class ir extends L {
|
|
1774
|
-
constructor() {
|
|
1775
|
-
super(...arguments), this.code = "ERR_JWK_INVALID";
|
|
1776
|
-
}
|
|
1777
|
-
static get code() {
|
|
1778
|
-
return "ERR_JWK_INVALID";
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
class Le extends L {
|
|
1782
|
-
constructor() {
|
|
1783
|
-
super(...arguments), this.code = "ERR_JWKS_INVALID";
|
|
1784
|
-
}
|
|
1785
|
-
static get code() {
|
|
1786
|
-
return "ERR_JWKS_INVALID";
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
class mt extends L {
|
|
1790
|
-
constructor() {
|
|
1791
|
-
super(...arguments), this.code = "ERR_JWKS_NO_MATCHING_KEY", this.message = "no applicable key found in the JSON Web Key Set";
|
|
1792
|
-
}
|
|
1793
|
-
static get code() {
|
|
1794
|
-
return "ERR_JWKS_NO_MATCHING_KEY";
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
class or extends L {
|
|
1798
|
-
constructor() {
|
|
1799
|
-
super(...arguments), this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS", this.message = "multiple matching keys found in the JSON Web Key Set";
|
|
1800
|
-
}
|
|
1801
|
-
static get code() {
|
|
1802
|
-
return "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
class cr extends L {
|
|
1806
|
-
constructor() {
|
|
1807
|
-
super(...arguments), this.code = "ERR_JWKS_TIMEOUT", this.message = "request timed out";
|
|
1808
|
-
}
|
|
1809
|
-
static get code() {
|
|
1810
|
-
return "ERR_JWKS_TIMEOUT";
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
class yt extends L {
|
|
1814
|
-
constructor() {
|
|
1815
|
-
super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
|
|
1816
|
-
}
|
|
1817
|
-
static get code() {
|
|
1818
|
-
return "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
const vn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1822
|
-
__proto__: null,
|
|
1823
|
-
JOSEAlgNotAllowed: Re,
|
|
1824
|
-
JOSEError: L,
|
|
1825
|
-
JOSENotSupported: x,
|
|
1826
|
-
JWEDecryptionFailed: ge,
|
|
1827
|
-
JWEInvalid: y,
|
|
1828
|
-
JWKInvalid: ir,
|
|
1829
|
-
JWKSInvalid: Le,
|
|
1830
|
-
JWKSMultipleMatchingKeys: or,
|
|
1831
|
-
JWKSNoMatchingKey: mt,
|
|
1832
|
-
JWKSTimeout: cr,
|
|
1833
|
-
JWSInvalid: P,
|
|
1834
|
-
JWSSignatureVerificationFailed: yt,
|
|
1835
|
-
JWTClaimValidationFailed: V,
|
|
1836
|
-
JWTExpired: ot,
|
|
1837
|
-
JWTInvalid: B
|
|
1838
|
-
}, Symbol.toStringTag, { value: "Module" })), De = b.getRandomValues.bind(b);
|
|
1839
|
-
function ur(t) {
|
|
1840
|
-
switch (t) {
|
|
1841
|
-
case "A128GCM":
|
|
1842
|
-
case "A128GCMKW":
|
|
1843
|
-
case "A192GCM":
|
|
1844
|
-
case "A192GCMKW":
|
|
1845
|
-
case "A256GCM":
|
|
1846
|
-
case "A256GCMKW":
|
|
1847
|
-
return 96;
|
|
1848
|
-
case "A128CBC-HS256":
|
|
1849
|
-
case "A192CBC-HS384":
|
|
1850
|
-
case "A256CBC-HS512":
|
|
1851
|
-
return 128;
|
|
1852
|
-
default:
|
|
1853
|
-
throw new x(`Unsupported JWE Algorithm: ${t}`);
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
const lr = (t) => De(new Uint8Array(ur(t) >> 3)), dr = (t, e) => {
|
|
1857
|
-
if (e.length << 3 !== ur(t))
|
|
1858
|
-
throw new y("Invalid Initialization Vector length");
|
|
1859
|
-
}, Oe = (t, e) => {
|
|
1860
|
-
const r = t.byteLength << 3;
|
|
1861
|
-
if (r !== e)
|
|
1862
|
-
throw new y(`Invalid Content Encryption Key length. Expected ${e} bits, got ${r} bits`);
|
|
1863
|
-
}, En = (t, e) => {
|
|
1864
|
-
if (!(t instanceof Uint8Array))
|
|
1865
|
-
throw new TypeError("First argument must be a buffer");
|
|
1866
|
-
if (!(e instanceof Uint8Array))
|
|
1867
|
-
throw new TypeError("Second argument must be a buffer");
|
|
1868
|
-
if (t.length !== e.length)
|
|
1869
|
-
throw new TypeError("Input buffers must have the same length");
|
|
1870
|
-
const r = t.length;
|
|
1871
|
-
let n = 0, a = -1;
|
|
1872
|
-
for (; ++a < r; )
|
|
1873
|
-
n |= t[a] ^ e[a];
|
|
1874
|
-
return n === 0;
|
|
1875
|
-
};
|
|
1876
|
-
function U(t, e = "algorithm.name") {
|
|
1877
|
-
return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`);
|
|
1878
|
-
}
|
|
1879
|
-
function re(t, e) {
|
|
1880
|
-
return t.name === e;
|
|
1881
|
-
}
|
|
1882
|
-
function Ee(t) {
|
|
1883
|
-
return parseInt(t.name.slice(4), 10);
|
|
1884
|
-
}
|
|
1885
|
-
function An(t) {
|
|
1886
|
-
switch (t) {
|
|
1887
|
-
case "ES256":
|
|
1888
|
-
return "P-256";
|
|
1889
|
-
case "ES384":
|
|
1890
|
-
return "P-384";
|
|
1891
|
-
case "ES512":
|
|
1892
|
-
return "P-521";
|
|
1893
|
-
default:
|
|
1894
|
-
throw new Error("unreachable");
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
function fr(t, e) {
|
|
1898
|
-
if (e.length && !e.some((r) => t.usages.includes(r))) {
|
|
1899
|
-
let r = "CryptoKey does not support this operation, its usages must include ";
|
|
1900
|
-
if (e.length > 2) {
|
|
1901
|
-
const n = e.pop();
|
|
1902
|
-
r += `one of ${e.join(", ")}, or ${n}.`;
|
|
1903
|
-
} else
|
|
1904
|
-
e.length === 2 ? r += `one of ${e[0]} or ${e[1]}.` : r += `${e[0]}.`;
|
|
1905
|
-
throw new TypeError(r);
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
function xn(t, e, ...r) {
|
|
1909
|
-
switch (e) {
|
|
1910
|
-
case "HS256":
|
|
1911
|
-
case "HS384":
|
|
1912
|
-
case "HS512": {
|
|
1913
|
-
if (!re(t.algorithm, "HMAC"))
|
|
1914
|
-
throw U("HMAC");
|
|
1915
|
-
const n = parseInt(e.slice(2), 10);
|
|
1916
|
-
if (Ee(t.algorithm.hash) !== n)
|
|
1917
|
-
throw U(`SHA-${n}`, "algorithm.hash");
|
|
1918
|
-
break;
|
|
1919
|
-
}
|
|
1920
|
-
case "RS256":
|
|
1921
|
-
case "RS384":
|
|
1922
|
-
case "RS512": {
|
|
1923
|
-
if (!re(t.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
1924
|
-
throw U("RSASSA-PKCS1-v1_5");
|
|
1925
|
-
const n = parseInt(e.slice(2), 10);
|
|
1926
|
-
if (Ee(t.algorithm.hash) !== n)
|
|
1927
|
-
throw U(`SHA-${n}`, "algorithm.hash");
|
|
1928
|
-
break;
|
|
1929
|
-
}
|
|
1930
|
-
case "PS256":
|
|
1931
|
-
case "PS384":
|
|
1932
|
-
case "PS512": {
|
|
1933
|
-
if (!re(t.algorithm, "RSA-PSS"))
|
|
1934
|
-
throw U("RSA-PSS");
|
|
1935
|
-
const n = parseInt(e.slice(2), 10);
|
|
1936
|
-
if (Ee(t.algorithm.hash) !== n)
|
|
1937
|
-
throw U(`SHA-${n}`, "algorithm.hash");
|
|
1938
|
-
break;
|
|
1939
|
-
}
|
|
1940
|
-
case "EdDSA": {
|
|
1941
|
-
if (t.algorithm.name !== "Ed25519" && t.algorithm.name !== "Ed448")
|
|
1942
|
-
throw U("Ed25519 or Ed448");
|
|
1943
|
-
break;
|
|
1944
|
-
}
|
|
1945
|
-
case "ES256":
|
|
1946
|
-
case "ES384":
|
|
1947
|
-
case "ES512": {
|
|
1948
|
-
if (!re(t.algorithm, "ECDSA"))
|
|
1949
|
-
throw U("ECDSA");
|
|
1950
|
-
const n = An(e);
|
|
1951
|
-
if (t.algorithm.namedCurve !== n)
|
|
1952
|
-
throw U(n, "algorithm.namedCurve");
|
|
1953
|
-
break;
|
|
1954
|
-
}
|
|
1955
|
-
default:
|
|
1956
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
1957
|
-
}
|
|
1958
|
-
fr(t, r);
|
|
1959
|
-
}
|
|
1960
|
-
function ae(t, e, ...r) {
|
|
1961
|
-
switch (e) {
|
|
1962
|
-
case "A128GCM":
|
|
1963
|
-
case "A192GCM":
|
|
1964
|
-
case "A256GCM": {
|
|
1965
|
-
if (!re(t.algorithm, "AES-GCM"))
|
|
1966
|
-
throw U("AES-GCM");
|
|
1967
|
-
const n = parseInt(e.slice(1, 4), 10);
|
|
1968
|
-
if (t.algorithm.length !== n)
|
|
1969
|
-
throw U(n, "algorithm.length");
|
|
1970
|
-
break;
|
|
1971
|
-
}
|
|
1972
|
-
case "A128KW":
|
|
1973
|
-
case "A192KW":
|
|
1974
|
-
case "A256KW": {
|
|
1975
|
-
if (!re(t.algorithm, "AES-KW"))
|
|
1976
|
-
throw U("AES-KW");
|
|
1977
|
-
const n = parseInt(e.slice(1, 4), 10);
|
|
1978
|
-
if (t.algorithm.length !== n)
|
|
1979
|
-
throw U(n, "algorithm.length");
|
|
1980
|
-
break;
|
|
1981
|
-
}
|
|
1982
|
-
case "ECDH": {
|
|
1983
|
-
switch (t.algorithm.name) {
|
|
1984
|
-
case "ECDH":
|
|
1985
|
-
case "X25519":
|
|
1986
|
-
case "X448":
|
|
1987
|
-
break;
|
|
1988
|
-
default:
|
|
1989
|
-
throw U("ECDH, X25519, or X448");
|
|
1990
|
-
}
|
|
1991
|
-
break;
|
|
1992
|
-
}
|
|
1993
|
-
case "PBES2-HS256+A128KW":
|
|
1994
|
-
case "PBES2-HS384+A192KW":
|
|
1995
|
-
case "PBES2-HS512+A256KW":
|
|
1996
|
-
if (!re(t.algorithm, "PBKDF2"))
|
|
1997
|
-
throw U("PBKDF2");
|
|
1998
|
-
break;
|
|
1999
|
-
case "RSA-OAEP":
|
|
2000
|
-
case "RSA-OAEP-256":
|
|
2001
|
-
case "RSA-OAEP-384":
|
|
2002
|
-
case "RSA-OAEP-512": {
|
|
2003
|
-
if (!re(t.algorithm, "RSA-OAEP"))
|
|
2004
|
-
throw U("RSA-OAEP");
|
|
2005
|
-
const n = parseInt(e.slice(9), 10) || 1;
|
|
2006
|
-
if (Ee(t.algorithm.hash) !== n)
|
|
2007
|
-
throw U(`SHA-${n}`, "algorithm.hash");
|
|
2008
|
-
break;
|
|
2009
|
-
}
|
|
2010
|
-
default:
|
|
2011
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
2012
|
-
}
|
|
2013
|
-
fr(t, r);
|
|
2014
|
-
}
|
|
2015
|
-
function hr(t, e, ...r) {
|
|
2016
|
-
if (r.length > 2) {
|
|
2017
|
-
const n = r.pop();
|
|
2018
|
-
t += `one of type ${r.join(", ")}, or ${n}.`;
|
|
2019
|
-
} else
|
|
2020
|
-
r.length === 2 ? t += `one of type ${r[0]} or ${r[1]}.` : t += `of type ${r[0]}.`;
|
|
2021
|
-
return e == null ? t += ` Received ${e}` : typeof e == "function" && e.name ? t += ` Received function ${e.name}` : typeof e == "object" && e != null && e.constructor && e.constructor.name && (t += ` Received an instance of ${e.constructor.name}`), t;
|
|
2022
|
-
}
|
|
2023
|
-
const M = (t, ...e) => hr("Key must be ", t, ...e);
|
|
2024
|
-
function pr(t, e, ...r) {
|
|
2025
|
-
return hr(`Key for the ${t} algorithm must be `, e, ...r);
|
|
2026
|
-
}
|
|
2027
|
-
const gr = (t) => G(t), H = ["CryptoKey"];
|
|
2028
|
-
async function Cn(t, e, r, n, a, s) {
|
|
2029
|
-
if (!(e instanceof Uint8Array))
|
|
2030
|
-
throw new TypeError(M(e, "Uint8Array"));
|
|
2031
|
-
const i = parseInt(t.slice(1, 4), 10), o = await b.subtle.importKey("raw", e.subarray(i >> 3), "AES-CBC", !1, ["decrypt"]), c = await b.subtle.importKey("raw", e.subarray(0, i >> 3), {
|
|
2032
|
-
hash: `SHA-${i << 1}`,
|
|
2033
|
-
name: "HMAC"
|
|
2034
|
-
}, !1, ["sign"]), u = Q(s, n, r, ar(s.length << 3)), l = new Uint8Array((await b.subtle.sign("HMAC", c, u)).slice(0, i >> 3));
|
|
2035
|
-
let f;
|
|
2036
|
-
try {
|
|
2037
|
-
f = En(a, l);
|
|
2038
|
-
} catch {
|
|
2039
|
-
}
|
|
2040
|
-
if (!f)
|
|
2041
|
-
throw new ge();
|
|
2042
|
-
let d;
|
|
2043
|
-
try {
|
|
2044
|
-
d = new Uint8Array(await b.subtle.decrypt({ iv: n, name: "AES-CBC" }, o, r));
|
|
2045
|
-
} catch {
|
|
2046
|
-
}
|
|
2047
|
-
if (!d)
|
|
2048
|
-
throw new ge();
|
|
2049
|
-
return d;
|
|
2050
|
-
}
|
|
2051
|
-
async function _n(t, e, r, n, a, s) {
|
|
2052
|
-
let i;
|
|
2053
|
-
e instanceof Uint8Array ? i = await b.subtle.importKey("raw", e, "AES-GCM", !1, ["decrypt"]) : (ae(e, t, "decrypt"), i = e);
|
|
2054
|
-
try {
|
|
2055
|
-
return new Uint8Array(await b.subtle.decrypt({
|
|
2056
|
-
additionalData: s,
|
|
2057
|
-
iv: n,
|
|
2058
|
-
name: "AES-GCM",
|
|
2059
|
-
tagLength: 128
|
|
2060
|
-
}, i, Q(r, a)));
|
|
2061
|
-
} catch {
|
|
2062
|
-
throw new ge();
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
const mr = async (t, e, r, n, a, s) => {
|
|
2066
|
-
if (!G(e) && !(e instanceof Uint8Array))
|
|
2067
|
-
throw new TypeError(M(e, ...H, "Uint8Array"));
|
|
2068
|
-
switch (dr(t, n), t) {
|
|
2069
|
-
case "A128CBC-HS256":
|
|
2070
|
-
case "A192CBC-HS384":
|
|
2071
|
-
case "A256CBC-HS512":
|
|
2072
|
-
return e instanceof Uint8Array && Oe(e, parseInt(t.slice(-3), 10)), Cn(t, e, r, n, a, s);
|
|
2073
|
-
case "A128GCM":
|
|
2074
|
-
case "A192GCM":
|
|
2075
|
-
case "A256GCM":
|
|
2076
|
-
return e instanceof Uint8Array && Oe(e, parseInt(t.slice(1, 4), 10)), _n(t, e, r, n, a, s);
|
|
2077
|
-
default:
|
|
2078
|
-
throw new x("Unsupported JWE Content Encryption Algorithm");
|
|
2079
|
-
}
|
|
2080
|
-
}, Pn = async () => {
|
|
2081
|
-
throw new x('JWE "zip" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `inflateRaw` decrypt option to provide Inflate Raw implementation.');
|
|
2082
|
-
}, Hn = async () => {
|
|
2083
|
-
throw new x('JWE "zip" (Compression Algorithm) Header Parameter is not supported by your javascript runtime. You need to use the `deflateRaw` encrypt option to provide Deflate Raw implementation.');
|
|
2084
|
-
}, me = (...t) => {
|
|
2085
|
-
const e = t.filter(Boolean);
|
|
2086
|
-
if (e.length === 0 || e.length === 1)
|
|
2087
|
-
return !0;
|
|
2088
|
-
let r;
|
|
2089
|
-
for (const n of e) {
|
|
2090
|
-
const a = Object.keys(n);
|
|
2091
|
-
if (!r || r.size === 0) {
|
|
2092
|
-
r = new Set(a);
|
|
2093
|
-
continue;
|
|
2094
|
-
}
|
|
2095
|
-
for (const s of a) {
|
|
2096
|
-
if (r.has(s))
|
|
2097
|
-
return !1;
|
|
2098
|
-
r.add(s);
|
|
2099
|
-
}
|
|
2100
|
-
}
|
|
2101
|
-
return !0;
|
|
2102
|
-
};
|
|
2103
|
-
function Kn(t) {
|
|
2104
|
-
return typeof t == "object" && t !== null;
|
|
2105
|
-
}
|
|
2106
|
-
function I(t) {
|
|
2107
|
-
if (!Kn(t) || Object.prototype.toString.call(t) !== "[object Object]")
|
|
2108
|
-
return !1;
|
|
2109
|
-
if (Object.getPrototypeOf(t) === null)
|
|
2110
|
-
return !0;
|
|
2111
|
-
let e = t;
|
|
2112
|
-
for (; Object.getPrototypeOf(e) !== null; )
|
|
2113
|
-
e = Object.getPrototypeOf(e);
|
|
2114
|
-
return Object.getPrototypeOf(t) === e;
|
|
2115
|
-
}
|
|
2116
|
-
const Je = [
|
|
2117
|
-
{ hash: "SHA-256", name: "HMAC" },
|
|
2118
|
-
!0,
|
|
2119
|
-
["sign"]
|
|
2120
|
-
];
|
|
2121
|
-
function yr(t, e) {
|
|
2122
|
-
if (t.algorithm.length !== parseInt(e.slice(1, 4), 10))
|
|
2123
|
-
throw new TypeError(`Invalid key size for alg: ${e}`);
|
|
2124
|
-
}
|
|
2125
|
-
function wr(t, e, r) {
|
|
2126
|
-
if (G(t))
|
|
2127
|
-
return ae(t, e, r), t;
|
|
2128
|
-
if (t instanceof Uint8Array)
|
|
2129
|
-
return b.subtle.importKey("raw", t, "AES-KW", !0, [r]);
|
|
2130
|
-
throw new TypeError(M(t, ...H, "Uint8Array"));
|
|
2131
|
-
}
|
|
2132
|
-
const ct = async (t, e, r) => {
|
|
2133
|
-
const n = await wr(e, t, "wrapKey");
|
|
2134
|
-
yr(n, t);
|
|
2135
|
-
const a = await b.subtle.importKey("raw", r, ...Je);
|
|
2136
|
-
return new Uint8Array(await b.subtle.wrapKey("raw", a, n, "AES-KW"));
|
|
2137
|
-
}, ut = async (t, e, r) => {
|
|
2138
|
-
const n = await wr(e, t, "unwrapKey");
|
|
2139
|
-
yr(n, t);
|
|
2140
|
-
const a = await b.subtle.unwrapKey("raw", r, n, "AES-KW", ...Je);
|
|
2141
|
-
return new Uint8Array(await b.subtle.exportKey("raw", a));
|
|
2142
|
-
};
|
|
2143
|
-
async function Sr(t, e, r, n, a = new Uint8Array(0), s = new Uint8Array(0)) {
|
|
2144
|
-
if (!G(t))
|
|
2145
|
-
throw new TypeError(M(t, ...H));
|
|
2146
|
-
if (ae(t, "ECDH"), !G(e))
|
|
2147
|
-
throw new TypeError(M(e, ...H));
|
|
2148
|
-
ae(e, "ECDH", "deriveBits");
|
|
2149
|
-
const i = Q(ze(K.encode(r)), ze(a), ze(s), pt(n));
|
|
2150
|
-
let o;
|
|
2151
|
-
t.algorithm.name === "X25519" ? o = 256 : t.algorithm.name === "X448" ? o = 448 : o = Math.ceil(parseInt(t.algorithm.namedCurve.substr(-3), 10) / 8) << 3;
|
|
2152
|
-
const c = new Uint8Array(await b.subtle.deriveBits({
|
|
2153
|
-
name: t.algorithm.name,
|
|
2154
|
-
public: t
|
|
2155
|
-
}, e, o));
|
|
2156
|
-
return bn(c, n, i);
|
|
2157
|
-
}
|
|
2158
|
-
async function Rn(t) {
|
|
2159
|
-
if (!G(t))
|
|
2160
|
-
throw new TypeError(M(t, ...H));
|
|
2161
|
-
return b.subtle.generateKey(t.algorithm, !0, ["deriveBits"]);
|
|
2162
|
-
}
|
|
2163
|
-
function br(t) {
|
|
2164
|
-
if (!G(t))
|
|
2165
|
-
throw new TypeError(M(t, ...H));
|
|
2166
|
-
return ["P-256", "P-384", "P-521"].includes(t.algorithm.namedCurve) || t.algorithm.name === "X25519" || t.algorithm.name === "X448";
|
|
2167
|
-
}
|
|
2168
|
-
function On(t) {
|
|
2169
|
-
if (!(t instanceof Uint8Array) || t.length < 8)
|
|
2170
|
-
throw new y("PBES2 Salt Input must be 8 or more octets");
|
|
2171
|
-
}
|
|
2172
|
-
function Tn(t, e) {
|
|
2173
|
-
if (t instanceof Uint8Array)
|
|
2174
|
-
return b.subtle.importKey("raw", t, "PBKDF2", !1, ["deriveBits"]);
|
|
2175
|
-
if (G(t))
|
|
2176
|
-
return ae(t, e, "deriveBits", "deriveKey"), t;
|
|
2177
|
-
throw new TypeError(M(t, ...H, "Uint8Array"));
|
|
2178
|
-
}
|
|
2179
|
-
async function vr(t, e, r, n) {
|
|
2180
|
-
On(t);
|
|
2181
|
-
const a = Sn(e, t), s = parseInt(e.slice(13, 16), 10), i = {
|
|
2182
|
-
hash: `SHA-${e.slice(8, 11)}`,
|
|
2183
|
-
iterations: r,
|
|
2184
|
-
name: "PBKDF2",
|
|
2185
|
-
salt: a
|
|
2186
|
-
}, o = {
|
|
2187
|
-
length: s,
|
|
2188
|
-
name: "AES-KW"
|
|
2189
|
-
}, c = await Tn(n, e);
|
|
2190
|
-
if (c.usages.includes("deriveBits"))
|
|
2191
|
-
return new Uint8Array(await b.subtle.deriveBits(i, c, s));
|
|
2192
|
-
if (c.usages.includes("deriveKey"))
|
|
2193
|
-
return b.subtle.deriveKey(i, c, o, !1, ["wrapKey", "unwrapKey"]);
|
|
2194
|
-
throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"');
|
|
2195
|
-
}
|
|
2196
|
-
const In = async (t, e, r, n = 2048, a = De(new Uint8Array(16))) => {
|
|
2197
|
-
const s = await vr(a, t, n, e);
|
|
2198
|
-
return { encryptedKey: await ct(t.slice(-6), s, r), p2c: n, p2s: O(a) };
|
|
2199
|
-
}, Wn = async (t, e, r, n, a) => {
|
|
2200
|
-
const s = await vr(a, t, n, e);
|
|
2201
|
-
return ut(t.slice(-6), s, r);
|
|
2202
|
-
};
|
|
2203
|
-
function Te(t) {
|
|
2204
|
-
switch (t) {
|
|
2205
|
-
case "RSA-OAEP":
|
|
2206
|
-
case "RSA-OAEP-256":
|
|
2207
|
-
case "RSA-OAEP-384":
|
|
2208
|
-
case "RSA-OAEP-512":
|
|
2209
|
-
return "RSA-OAEP";
|
|
2210
|
-
default:
|
|
2211
|
-
throw new x(`alg ${t} is not supported either by JOSE or your javascript runtime`);
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
const Ne = (t, e) => {
|
|
2215
|
-
if (t.startsWith("RS") || t.startsWith("PS")) {
|
|
2216
|
-
const { modulusLength: r } = e.algorithm;
|
|
2217
|
-
if (typeof r != "number" || r < 2048)
|
|
2218
|
-
throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`);
|
|
2219
|
-
}
|
|
2220
|
-
}, Un = async (t, e, r) => {
|
|
2221
|
-
if (!G(e))
|
|
2222
|
-
throw new TypeError(M(e, ...H));
|
|
2223
|
-
if (ae(e, t, "encrypt", "wrapKey"), Ne(t, e), e.usages.includes("encrypt"))
|
|
2224
|
-
return new Uint8Array(await b.subtle.encrypt(Te(t), e, r));
|
|
2225
|
-
if (e.usages.includes("wrapKey")) {
|
|
2226
|
-
const n = await b.subtle.importKey("raw", r, ...Je);
|
|
2227
|
-
return new Uint8Array(await b.subtle.wrapKey("raw", n, e, Te(t)));
|
|
2228
|
-
}
|
|
2229
|
-
throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation');
|
|
2230
|
-
}, Ln = async (t, e, r) => {
|
|
2231
|
-
if (!G(e))
|
|
2232
|
-
throw new TypeError(M(e, ...H));
|
|
2233
|
-
if (ae(e, t, "decrypt", "unwrapKey"), Ne(t, e), e.usages.includes("decrypt"))
|
|
2234
|
-
return new Uint8Array(await b.subtle.decrypt(Te(t), e, r));
|
|
2235
|
-
if (e.usages.includes("unwrapKey")) {
|
|
2236
|
-
const n = await b.subtle.unwrapKey("raw", r, e, Te(t), ...Je);
|
|
2237
|
-
return new Uint8Array(await b.subtle.exportKey("raw", n));
|
|
2238
|
-
}
|
|
2239
|
-
throw new TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation');
|
|
2240
|
-
};
|
|
2241
|
-
function wt(t) {
|
|
2242
|
-
switch (t) {
|
|
2243
|
-
case "A128GCM":
|
|
2244
|
-
return 128;
|
|
2245
|
-
case "A192GCM":
|
|
2246
|
-
return 192;
|
|
2247
|
-
case "A256GCM":
|
|
2248
|
-
case "A128CBC-HS256":
|
|
2249
|
-
return 256;
|
|
2250
|
-
case "A192CBC-HS384":
|
|
2251
|
-
return 384;
|
|
2252
|
-
case "A256CBC-HS512":
|
|
2253
|
-
return 512;
|
|
2254
|
-
default:
|
|
2255
|
-
throw new x(`Unsupported JWE Algorithm: ${t}`);
|
|
2256
|
-
}
|
|
2257
|
-
}
|
|
2258
|
-
const ie = (t) => De(new Uint8Array(wt(t) >> 3)), Er = (t, e) => {
|
|
2259
|
-
const r = (t.match(/.{1,64}/g) || []).join(`
|
|
2260
|
-
`);
|
|
2261
|
-
return `-----BEGIN ${e}-----
|
|
2262
|
-
${r}
|
|
2263
|
-
-----END ${e}-----`;
|
|
2264
|
-
}, Ar = async (t, e, r) => {
|
|
2265
|
-
if (!G(r))
|
|
2266
|
-
throw new TypeError(M(r, ...H));
|
|
2267
|
-
if (!r.extractable)
|
|
2268
|
-
throw new TypeError("CryptoKey is not extractable");
|
|
2269
|
-
if (r.type !== t)
|
|
2270
|
-
throw new TypeError(`key is not a ${t} key`);
|
|
2271
|
-
return Er(gt(new Uint8Array(await b.subtle.exportKey(e, r))), `${t.toUpperCase()} KEY`);
|
|
2272
|
-
}, Dn = (t) => Ar("public", "spki", t), Jn = (t) => Ar("private", "pkcs8", t), te = (t, e, r = 0) => {
|
|
2273
|
-
r === 0 && (e.unshift(e.length), e.unshift(6));
|
|
2274
|
-
let n = t.indexOf(e[0], r);
|
|
2275
|
-
if (n === -1)
|
|
2276
|
-
return !1;
|
|
2277
|
-
const a = t.subarray(n, n + e.length);
|
|
2278
|
-
return a.length !== e.length ? !1 : a.every((s, i) => s === e[i]) || te(t, e, n + 1);
|
|
2279
|
-
}, Jt = (t) => {
|
|
2280
|
-
switch (!0) {
|
|
2281
|
-
case te(t, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
2282
|
-
return "P-256";
|
|
2283
|
-
case te(t, [43, 129, 4, 0, 34]):
|
|
2284
|
-
return "P-384";
|
|
2285
|
-
case te(t, [43, 129, 4, 0, 35]):
|
|
2286
|
-
return "P-521";
|
|
2287
|
-
case te(t, [43, 101, 110]):
|
|
2288
|
-
return "X25519";
|
|
2289
|
-
case te(t, [43, 101, 111]):
|
|
2290
|
-
return "X448";
|
|
2291
|
-
case te(t, [43, 101, 112]):
|
|
2292
|
-
return "Ed25519";
|
|
2293
|
-
case te(t, [43, 101, 113]):
|
|
2294
|
-
return "Ed448";
|
|
2295
|
-
default:
|
|
2296
|
-
throw new x("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
|
|
2297
|
-
}
|
|
2298
|
-
}, xr = async (t, e, r, n, a) => {
|
|
2299
|
-
var s;
|
|
2300
|
-
let i, o;
|
|
2301
|
-
const c = new Uint8Array(atob(r.replace(t, "")).split("").map((l) => l.charCodeAt(0))), u = e === "spki";
|
|
2302
|
-
switch (n) {
|
|
2303
|
-
case "PS256":
|
|
2304
|
-
case "PS384":
|
|
2305
|
-
case "PS512":
|
|
2306
|
-
i = { name: "RSA-PSS", hash: `SHA-${n.slice(-3)}` }, o = u ? ["verify"] : ["sign"];
|
|
2307
|
-
break;
|
|
2308
|
-
case "RS256":
|
|
2309
|
-
case "RS384":
|
|
2310
|
-
case "RS512":
|
|
2311
|
-
i = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${n.slice(-3)}` }, o = u ? ["verify"] : ["sign"];
|
|
2312
|
-
break;
|
|
2313
|
-
case "RSA-OAEP":
|
|
2314
|
-
case "RSA-OAEP-256":
|
|
2315
|
-
case "RSA-OAEP-384":
|
|
2316
|
-
case "RSA-OAEP-512":
|
|
2317
|
-
i = {
|
|
2318
|
-
name: "RSA-OAEP",
|
|
2319
|
-
hash: `SHA-${parseInt(n.slice(-3), 10) || 1}`
|
|
2320
|
-
}, o = u ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"];
|
|
2321
|
-
break;
|
|
2322
|
-
case "ES256":
|
|
2323
|
-
i = { name: "ECDSA", namedCurve: "P-256" }, o = u ? ["verify"] : ["sign"];
|
|
2324
|
-
break;
|
|
2325
|
-
case "ES384":
|
|
2326
|
-
i = { name: "ECDSA", namedCurve: "P-384" }, o = u ? ["verify"] : ["sign"];
|
|
2327
|
-
break;
|
|
2328
|
-
case "ES512":
|
|
2329
|
-
i = { name: "ECDSA", namedCurve: "P-521" }, o = u ? ["verify"] : ["sign"];
|
|
2330
|
-
break;
|
|
2331
|
-
case "ECDH-ES":
|
|
2332
|
-
case "ECDH-ES+A128KW":
|
|
2333
|
-
case "ECDH-ES+A192KW":
|
|
2334
|
-
case "ECDH-ES+A256KW": {
|
|
2335
|
-
const l = Jt(c);
|
|
2336
|
-
i = l.startsWith("P-") ? { name: "ECDH", namedCurve: l } : { name: l }, o = u ? [] : ["deriveBits"];
|
|
2337
|
-
break;
|
|
2338
|
-
}
|
|
2339
|
-
case "EdDSA":
|
|
2340
|
-
i = { name: Jt(c) }, o = u ? ["verify"] : ["sign"];
|
|
2341
|
-
break;
|
|
2342
|
-
default:
|
|
2343
|
-
throw new x('Invalid or unsupported "alg" (Algorithm) value');
|
|
2344
|
-
}
|
|
2345
|
-
return b.subtle.importKey(e, c, i, (s = a == null ? void 0 : a.extractable) !== null && s !== void 0 ? s : !1, o);
|
|
2346
|
-
}, Nn = (t, e, r) => xr(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, "pkcs8", t, e, r), Cr = (t, e, r) => xr(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", t, e, r);
|
|
2347
|
-
function Nt(t) {
|
|
2348
|
-
let e = [], r = 0;
|
|
2349
|
-
for (; r < t.length; ) {
|
|
2350
|
-
let n = _r(t.subarray(r));
|
|
2351
|
-
e.push(n), r += n.byteLength;
|
|
2352
|
-
}
|
|
2353
|
-
return e;
|
|
2354
|
-
}
|
|
2355
|
-
function _r(t) {
|
|
2356
|
-
let e = 0, r = t[0] & 31;
|
|
2357
|
-
if (e++, r === 31) {
|
|
2358
|
-
for (r = 0; t[e] >= 128; )
|
|
2359
|
-
r = r * 128 + t[e] - 128, e++;
|
|
2360
|
-
r = r * 128 + t[e] - 128, e++;
|
|
2361
|
-
}
|
|
2362
|
-
let n = 0;
|
|
2363
|
-
if (t[e] < 128)
|
|
2364
|
-
n = t[e], e++;
|
|
2365
|
-
else if (n === 128) {
|
|
2366
|
-
for (n = 0; t[e + n] !== 0 || t[e + n + 1] !== 0; ) {
|
|
2367
|
-
if (n > t.byteLength)
|
|
2368
|
-
throw new TypeError("invalid indefinite form length");
|
|
2369
|
-
n++;
|
|
2370
|
-
}
|
|
2371
|
-
const s = e + n + 2;
|
|
2372
|
-
return {
|
|
2373
|
-
byteLength: s,
|
|
2374
|
-
contents: t.subarray(e, e + n),
|
|
2375
|
-
raw: t.subarray(0, s)
|
|
2376
|
-
};
|
|
2377
|
-
} else {
|
|
2378
|
-
let s = t[e] & 127;
|
|
2379
|
-
e++, n = 0;
|
|
2380
|
-
for (let i = 0; i < s; i++)
|
|
2381
|
-
n = n * 256 + t[e], e++;
|
|
2382
|
-
}
|
|
2383
|
-
const a = e + n;
|
|
2384
|
-
return {
|
|
2385
|
-
byteLength: a,
|
|
2386
|
-
contents: t.subarray(e, a),
|
|
2387
|
-
raw: t.subarray(0, a)
|
|
2388
|
-
};
|
|
2389
|
-
}
|
|
2390
|
-
function $n(t) {
|
|
2391
|
-
const e = Nt(Nt(_r(t).contents)[0].contents);
|
|
2392
|
-
return gt(e[e[0].raw[0] === 160 ? 6 : 5].raw);
|
|
2393
|
-
}
|
|
2394
|
-
function Mn(t) {
|
|
2395
|
-
const e = t.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g, ""), r = sr(e);
|
|
2396
|
-
return Er($n(r), "PUBLIC KEY");
|
|
2397
|
-
}
|
|
2398
|
-
const kn = (t, e, r) => {
|
|
2399
|
-
let n;
|
|
2400
|
-
try {
|
|
2401
|
-
n = Mn(t);
|
|
2402
|
-
} catch (a) {
|
|
2403
|
-
throw new TypeError("Failed to parse the X.509 certificate", { cause: a });
|
|
2404
|
-
}
|
|
2405
|
-
return Cr(n, e, r);
|
|
2406
|
-
};
|
|
2407
|
-
function Fn(t) {
|
|
2408
|
-
let e, r;
|
|
2409
|
-
switch (t.kty) {
|
|
2410
|
-
case "oct": {
|
|
2411
|
-
switch (t.alg) {
|
|
2412
|
-
case "HS256":
|
|
2413
|
-
case "HS384":
|
|
2414
|
-
case "HS512":
|
|
2415
|
-
e = { name: "HMAC", hash: `SHA-${t.alg.slice(-3)}` }, r = ["sign", "verify"];
|
|
2416
|
-
break;
|
|
2417
|
-
case "A128CBC-HS256":
|
|
2418
|
-
case "A192CBC-HS384":
|
|
2419
|
-
case "A256CBC-HS512":
|
|
2420
|
-
throw new x(`${t.alg} keys cannot be imported as CryptoKey instances`);
|
|
2421
|
-
case "A128GCM":
|
|
2422
|
-
case "A192GCM":
|
|
2423
|
-
case "A256GCM":
|
|
2424
|
-
case "A128GCMKW":
|
|
2425
|
-
case "A192GCMKW":
|
|
2426
|
-
case "A256GCMKW":
|
|
2427
|
-
e = { name: "AES-GCM" }, r = ["encrypt", "decrypt"];
|
|
2428
|
-
break;
|
|
2429
|
-
case "A128KW":
|
|
2430
|
-
case "A192KW":
|
|
2431
|
-
case "A256KW":
|
|
2432
|
-
e = { name: "AES-KW" }, r = ["wrapKey", "unwrapKey"];
|
|
2433
|
-
break;
|
|
2434
|
-
case "PBES2-HS256+A128KW":
|
|
2435
|
-
case "PBES2-HS384+A192KW":
|
|
2436
|
-
case "PBES2-HS512+A256KW":
|
|
2437
|
-
e = { name: "PBKDF2" }, r = ["deriveBits"];
|
|
2438
|
-
break;
|
|
2439
|
-
default:
|
|
2440
|
-
throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2441
|
-
}
|
|
2442
|
-
break;
|
|
2443
|
-
}
|
|
2444
|
-
case "RSA": {
|
|
2445
|
-
switch (t.alg) {
|
|
2446
|
-
case "PS256":
|
|
2447
|
-
case "PS384":
|
|
2448
|
-
case "PS512":
|
|
2449
|
-
e = { name: "RSA-PSS", hash: `SHA-${t.alg.slice(-3)}` }, r = t.d ? ["sign"] : ["verify"];
|
|
2450
|
-
break;
|
|
2451
|
-
case "RS256":
|
|
2452
|
-
case "RS384":
|
|
2453
|
-
case "RS512":
|
|
2454
|
-
e = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${t.alg.slice(-3)}` }, r = t.d ? ["sign"] : ["verify"];
|
|
2455
|
-
break;
|
|
2456
|
-
case "RSA-OAEP":
|
|
2457
|
-
case "RSA-OAEP-256":
|
|
2458
|
-
case "RSA-OAEP-384":
|
|
2459
|
-
case "RSA-OAEP-512":
|
|
2460
|
-
e = {
|
|
2461
|
-
name: "RSA-OAEP",
|
|
2462
|
-
hash: `SHA-${parseInt(t.alg.slice(-3), 10) || 1}`
|
|
2463
|
-
}, r = t.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
2464
|
-
break;
|
|
2465
|
-
default:
|
|
2466
|
-
throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2467
|
-
}
|
|
2468
|
-
break;
|
|
2469
|
-
}
|
|
2470
|
-
case "EC": {
|
|
2471
|
-
switch (t.alg) {
|
|
2472
|
-
case "ES256":
|
|
2473
|
-
e = { name: "ECDSA", namedCurve: "P-256" }, r = t.d ? ["sign"] : ["verify"];
|
|
2474
|
-
break;
|
|
2475
|
-
case "ES384":
|
|
2476
|
-
e = { name: "ECDSA", namedCurve: "P-384" }, r = t.d ? ["sign"] : ["verify"];
|
|
2477
|
-
break;
|
|
2478
|
-
case "ES512":
|
|
2479
|
-
e = { name: "ECDSA", namedCurve: "P-521" }, r = t.d ? ["sign"] : ["verify"];
|
|
2480
|
-
break;
|
|
2481
|
-
case "ECDH-ES":
|
|
2482
|
-
case "ECDH-ES+A128KW":
|
|
2483
|
-
case "ECDH-ES+A192KW":
|
|
2484
|
-
case "ECDH-ES+A256KW":
|
|
2485
|
-
e = { name: "ECDH", namedCurve: t.crv }, r = t.d ? ["deriveBits"] : [];
|
|
2486
|
-
break;
|
|
2487
|
-
default:
|
|
2488
|
-
throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2489
|
-
}
|
|
2490
|
-
break;
|
|
2491
|
-
}
|
|
2492
|
-
case "OKP": {
|
|
2493
|
-
switch (t.alg) {
|
|
2494
|
-
case "EdDSA":
|
|
2495
|
-
e = { name: t.crv }, r = t.d ? ["sign"] : ["verify"];
|
|
2496
|
-
break;
|
|
2497
|
-
case "ECDH-ES":
|
|
2498
|
-
case "ECDH-ES+A128KW":
|
|
2499
|
-
case "ECDH-ES+A192KW":
|
|
2500
|
-
case "ECDH-ES+A256KW":
|
|
2501
|
-
e = { name: t.crv }, r = t.d ? ["deriveBits"] : [];
|
|
2502
|
-
break;
|
|
2503
|
-
default:
|
|
2504
|
-
throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2505
|
-
}
|
|
2506
|
-
break;
|
|
2507
|
-
}
|
|
2508
|
-
default:
|
|
2509
|
-
throw new x('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
2510
|
-
}
|
|
2511
|
-
return { algorithm: e, keyUsages: r };
|
|
2512
|
-
}
|
|
2513
|
-
const Vn = async (t) => {
|
|
2514
|
-
var e, r;
|
|
2515
|
-
if (!t.alg)
|
|
2516
|
-
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
2517
|
-
const { algorithm: n, keyUsages: a } = Fn(t), s = [
|
|
2518
|
-
n,
|
|
2519
|
-
(e = t.ext) !== null && e !== void 0 ? e : !1,
|
|
2520
|
-
(r = t.key_ops) !== null && r !== void 0 ? r : a
|
|
2521
|
-
];
|
|
2522
|
-
if (n.name === "PBKDF2")
|
|
2523
|
-
return b.subtle.importKey("raw", T(t.k), ...s);
|
|
2524
|
-
const i = { ...t };
|
|
2525
|
-
return delete i.alg, delete i.use, b.subtle.importKey("jwk", i, ...s);
|
|
2526
|
-
}, $t = Vn;
|
|
2527
|
-
async function Bn(t, e, r) {
|
|
2528
|
-
if (typeof t != "string" || t.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
2529
|
-
throw new TypeError('"spki" must be SPKI formatted string');
|
|
2530
|
-
return Cr(t, e, r);
|
|
2531
|
-
}
|
|
2532
|
-
async function Gn(t, e, r) {
|
|
2533
|
-
if (typeof t != "string" || t.indexOf("-----BEGIN CERTIFICATE-----") !== 0)
|
|
2534
|
-
throw new TypeError('"x509" must be X.509 formatted string');
|
|
2535
|
-
return kn(t, e, r);
|
|
2536
|
-
}
|
|
2537
|
-
async function zn(t, e, r) {
|
|
2538
|
-
if (typeof t != "string" || t.indexOf("-----BEGIN PRIVATE KEY-----") !== 0)
|
|
2539
|
-
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
2540
|
-
return Nn(t, e, r);
|
|
2541
|
-
}
|
|
2542
|
-
async function $e(t, e, r) {
|
|
2543
|
-
var n;
|
|
2544
|
-
if (!I(t))
|
|
2545
|
-
throw new TypeError("JWK must be an object");
|
|
2546
|
-
switch (e || (e = t.alg), t.kty) {
|
|
2547
|
-
case "oct":
|
|
2548
|
-
if (typeof t.k != "string" || !t.k)
|
|
2549
|
-
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
2550
|
-
return r ?? (r = t.ext !== !0), r ? $t({ ...t, alg: e, ext: (n = t.ext) !== null && n !== void 0 ? n : !1 }) : T(t.k);
|
|
2551
|
-
case "RSA":
|
|
2552
|
-
if (t.oth !== void 0)
|
|
2553
|
-
throw new x('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
2554
|
-
case "EC":
|
|
2555
|
-
case "OKP":
|
|
2556
|
-
return $t({ ...t, alg: e });
|
|
2557
|
-
default:
|
|
2558
|
-
throw new x('Unsupported "kty" (Key Type) Parameter value');
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
const qn = (t, e) => {
|
|
2562
|
-
if (!(e instanceof Uint8Array)) {
|
|
2563
|
-
if (!gr(e))
|
|
2564
|
-
throw new TypeError(pr(t, e, ...H, "Uint8Array"));
|
|
2565
|
-
if (e.type !== "secret")
|
|
2566
|
-
throw new TypeError(`${H.join(" or ")} instances for symmetric algorithms must be of type "secret"`);
|
|
2567
|
-
}
|
|
2568
|
-
}, Xn = (t, e, r) => {
|
|
2569
|
-
if (!gr(e))
|
|
2570
|
-
throw new TypeError(pr(t, e, ...H));
|
|
2571
|
-
if (e.type === "secret")
|
|
2572
|
-
throw new TypeError(`${H.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);
|
|
2573
|
-
if (r === "sign" && e.type === "public")
|
|
2574
|
-
throw new TypeError(`${H.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);
|
|
2575
|
-
if (r === "decrypt" && e.type === "public")
|
|
2576
|
-
throw new TypeError(`${H.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
2577
|
-
if (e.algorithm && r === "verify" && e.type === "private")
|
|
2578
|
-
throw new TypeError(`${H.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
2579
|
-
if (e.algorithm && r === "encrypt" && e.type === "private")
|
|
2580
|
-
throw new TypeError(`${H.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
2581
|
-
}, Me = (t, e, r) => {
|
|
2582
|
-
t.startsWith("HS") || t === "dir" || t.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(t) ? qn(t, e) : Xn(t, e, r);
|
|
2583
|
-
};
|
|
2584
|
-
async function Yn(t, e, r, n, a) {
|
|
2585
|
-
if (!(r instanceof Uint8Array))
|
|
2586
|
-
throw new TypeError(M(r, "Uint8Array"));
|
|
2587
|
-
const s = parseInt(t.slice(1, 4), 10), i = await b.subtle.importKey("raw", r.subarray(s >> 3), "AES-CBC", !1, ["encrypt"]), o = await b.subtle.importKey("raw", r.subarray(0, s >> 3), {
|
|
2588
|
-
hash: `SHA-${s << 1}`,
|
|
2589
|
-
name: "HMAC"
|
|
2590
|
-
}, !1, ["sign"]), c = new Uint8Array(await b.subtle.encrypt({
|
|
2591
|
-
iv: n,
|
|
2592
|
-
name: "AES-CBC"
|
|
2593
|
-
}, i, e)), u = Q(a, n, c, ar(a.length << 3)), l = new Uint8Array((await b.subtle.sign("HMAC", o, u)).slice(0, s >> 3));
|
|
2594
|
-
return { ciphertext: c, tag: l };
|
|
2595
|
-
}
|
|
2596
|
-
async function Zn(t, e, r, n, a) {
|
|
2597
|
-
let s;
|
|
2598
|
-
r instanceof Uint8Array ? s = await b.subtle.importKey("raw", r, "AES-GCM", !1, ["encrypt"]) : (ae(r, t, "encrypt"), s = r);
|
|
2599
|
-
const i = new Uint8Array(await b.subtle.encrypt({
|
|
2600
|
-
additionalData: a,
|
|
2601
|
-
iv: n,
|
|
2602
|
-
name: "AES-GCM",
|
|
2603
|
-
tagLength: 128
|
|
2604
|
-
}, s, e)), o = i.slice(-16);
|
|
2605
|
-
return { ciphertext: i.slice(0, -16), tag: o };
|
|
2606
|
-
}
|
|
2607
|
-
const lt = async (t, e, r, n, a) => {
|
|
2608
|
-
if (!G(r) && !(r instanceof Uint8Array))
|
|
2609
|
-
throw new TypeError(M(r, ...H, "Uint8Array"));
|
|
2610
|
-
switch (dr(t, n), t) {
|
|
2611
|
-
case "A128CBC-HS256":
|
|
2612
|
-
case "A192CBC-HS384":
|
|
2613
|
-
case "A256CBC-HS512":
|
|
2614
|
-
return r instanceof Uint8Array && Oe(r, parseInt(t.slice(-3), 10)), Yn(t, e, r, n, a);
|
|
2615
|
-
case "A128GCM":
|
|
2616
|
-
case "A192GCM":
|
|
2617
|
-
case "A256GCM":
|
|
2618
|
-
return r instanceof Uint8Array && Oe(r, parseInt(t.slice(1, 4), 10)), Zn(t, e, r, n, a);
|
|
2619
|
-
default:
|
|
2620
|
-
throw new x("Unsupported JWE Content Encryption Algorithm");
|
|
2621
|
-
}
|
|
2622
|
-
};
|
|
2623
|
-
async function Qn(t, e, r, n) {
|
|
2624
|
-
const a = t.slice(0, 7);
|
|
2625
|
-
n || (n = lr(a));
|
|
2626
|
-
const { ciphertext: s, tag: i } = await lt(a, r, e, n, new Uint8Array(0));
|
|
2627
|
-
return { encryptedKey: s, iv: O(n), tag: O(i) };
|
|
2628
|
-
}
|
|
2629
|
-
async function jn(t, e, r, n, a) {
|
|
2630
|
-
const s = t.slice(0, 7);
|
|
2631
|
-
return mr(s, e, r, n, a, new Uint8Array(0));
|
|
2632
|
-
}
|
|
2633
|
-
async function ea(t, e, r, n, a) {
|
|
2634
|
-
switch (Me(t, e, "decrypt"), t) {
|
|
2635
|
-
case "dir": {
|
|
2636
|
-
if (r !== void 0)
|
|
2637
|
-
throw new y("Encountered unexpected JWE Encrypted Key");
|
|
2638
|
-
return e;
|
|
2639
|
-
}
|
|
2640
|
-
case "ECDH-ES":
|
|
2641
|
-
if (r !== void 0)
|
|
2642
|
-
throw new y("Encountered unexpected JWE Encrypted Key");
|
|
2643
|
-
case "ECDH-ES+A128KW":
|
|
2644
|
-
case "ECDH-ES+A192KW":
|
|
2645
|
-
case "ECDH-ES+A256KW": {
|
|
2646
|
-
if (!I(n.epk))
|
|
2647
|
-
throw new y('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');
|
|
2648
|
-
if (!br(e))
|
|
2649
|
-
throw new x("ECDH with the provided key is not allowed or not supported by your javascript runtime");
|
|
2650
|
-
const s = await $e(n.epk, t);
|
|
2651
|
-
let i, o;
|
|
2652
|
-
if (n.apu !== void 0) {
|
|
2653
|
-
if (typeof n.apu != "string")
|
|
2654
|
-
throw new y('JOSE Header "apu" (Agreement PartyUInfo) invalid');
|
|
2655
|
-
try {
|
|
2656
|
-
i = T(n.apu);
|
|
2657
|
-
} catch {
|
|
2658
|
-
throw new y("Failed to base64url decode the apu");
|
|
2659
|
-
}
|
|
2660
|
-
}
|
|
2661
|
-
if (n.apv !== void 0) {
|
|
2662
|
-
if (typeof n.apv != "string")
|
|
2663
|
-
throw new y('JOSE Header "apv" (Agreement PartyVInfo) invalid');
|
|
2664
|
-
try {
|
|
2665
|
-
o = T(n.apv);
|
|
2666
|
-
} catch {
|
|
2667
|
-
throw new y("Failed to base64url decode the apv");
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
const c = await Sr(s, e, t === "ECDH-ES" ? n.enc : t, t === "ECDH-ES" ? wt(n.enc) : parseInt(t.slice(-5, -2), 10), i, o);
|
|
2671
|
-
if (t === "ECDH-ES")
|
|
2672
|
-
return c;
|
|
2673
|
-
if (r === void 0)
|
|
2674
|
-
throw new y("JWE Encrypted Key missing");
|
|
2675
|
-
return ut(t.slice(-6), c, r);
|
|
2676
|
-
}
|
|
2677
|
-
case "RSA1_5":
|
|
2678
|
-
case "RSA-OAEP":
|
|
2679
|
-
case "RSA-OAEP-256":
|
|
2680
|
-
case "RSA-OAEP-384":
|
|
2681
|
-
case "RSA-OAEP-512": {
|
|
2682
|
-
if (r === void 0)
|
|
2683
|
-
throw new y("JWE Encrypted Key missing");
|
|
2684
|
-
return Ln(t, e, r);
|
|
2685
|
-
}
|
|
2686
|
-
case "PBES2-HS256+A128KW":
|
|
2687
|
-
case "PBES2-HS384+A192KW":
|
|
2688
|
-
case "PBES2-HS512+A256KW": {
|
|
2689
|
-
if (r === void 0)
|
|
2690
|
-
throw new y("JWE Encrypted Key missing");
|
|
2691
|
-
if (typeof n.p2c != "number")
|
|
2692
|
-
throw new y('JOSE Header "p2c" (PBES2 Count) missing or invalid');
|
|
2693
|
-
const s = (a == null ? void 0 : a.maxPBES2Count) || 1e4;
|
|
2694
|
-
if (n.p2c > s)
|
|
2695
|
-
throw new y('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');
|
|
2696
|
-
if (typeof n.p2s != "string")
|
|
2697
|
-
throw new y('JOSE Header "p2s" (PBES2 Salt) missing or invalid');
|
|
2698
|
-
let i;
|
|
2699
|
-
try {
|
|
2700
|
-
i = T(n.p2s);
|
|
2701
|
-
} catch {
|
|
2702
|
-
throw new y("Failed to base64url decode the p2s");
|
|
2703
|
-
}
|
|
2704
|
-
return Wn(t, e, r, n.p2c, i);
|
|
2705
|
-
}
|
|
2706
|
-
case "A128KW":
|
|
2707
|
-
case "A192KW":
|
|
2708
|
-
case "A256KW": {
|
|
2709
|
-
if (r === void 0)
|
|
2710
|
-
throw new y("JWE Encrypted Key missing");
|
|
2711
|
-
return ut(t, e, r);
|
|
2712
|
-
}
|
|
2713
|
-
case "A128GCMKW":
|
|
2714
|
-
case "A192GCMKW":
|
|
2715
|
-
case "A256GCMKW": {
|
|
2716
|
-
if (r === void 0)
|
|
2717
|
-
throw new y("JWE Encrypted Key missing");
|
|
2718
|
-
if (typeof n.iv != "string")
|
|
2719
|
-
throw new y('JOSE Header "iv" (Initialization Vector) missing or invalid');
|
|
2720
|
-
if (typeof n.tag != "string")
|
|
2721
|
-
throw new y('JOSE Header "tag" (Authentication Tag) missing or invalid');
|
|
2722
|
-
let s;
|
|
2723
|
-
try {
|
|
2724
|
-
s = T(n.iv);
|
|
2725
|
-
} catch {
|
|
2726
|
-
throw new y("Failed to base64url decode the iv");
|
|
2727
|
-
}
|
|
2728
|
-
let i;
|
|
2729
|
-
try {
|
|
2730
|
-
i = T(n.tag);
|
|
2731
|
-
} catch {
|
|
2732
|
-
throw new y("Failed to base64url decode the tag");
|
|
2733
|
-
}
|
|
2734
|
-
return jn(t, e, r, s, i);
|
|
2735
|
-
}
|
|
2736
|
-
default:
|
|
2737
|
-
throw new x('Invalid or unsupported "alg" (JWE Algorithm) header value');
|
|
2738
|
-
}
|
|
2739
|
-
}
|
|
2740
|
-
function ye(t, e, r, n, a) {
|
|
2741
|
-
if (a.crit !== void 0 && n.crit === void 0)
|
|
2742
|
-
throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
2743
|
-
if (!n || n.crit === void 0)
|
|
2744
|
-
return /* @__PURE__ */ new Set();
|
|
2745
|
-
if (!Array.isArray(n.crit) || n.crit.length === 0 || n.crit.some((i) => typeof i != "string" || i.length === 0))
|
|
2746
|
-
throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
2747
|
-
let s;
|
|
2748
|
-
r !== void 0 ? s = new Map([...Object.entries(r), ...e.entries()]) : s = e;
|
|
2749
|
-
for (const i of n.crit) {
|
|
2750
|
-
if (!s.has(i))
|
|
2751
|
-
throw new x(`Extension Header Parameter "${i}" is not recognized`);
|
|
2752
|
-
if (a[i] === void 0)
|
|
2753
|
-
throw new t(`Extension Header Parameter "${i}" is missing`);
|
|
2754
|
-
if (s.get(i) && n[i] === void 0)
|
|
2755
|
-
throw new t(`Extension Header Parameter "${i}" MUST be integrity protected`);
|
|
2756
|
-
}
|
|
2757
|
-
return new Set(n.crit);
|
|
2758
|
-
}
|
|
2759
|
-
const dt = (t, e) => {
|
|
2760
|
-
if (e !== void 0 && (!Array.isArray(e) || e.some((r) => typeof r != "string")))
|
|
2761
|
-
throw new TypeError(`"${t}" option must be an array of strings`);
|
|
2762
|
-
if (e)
|
|
2763
|
-
return new Set(e);
|
|
2764
|
-
};
|
|
2765
|
-
async function St(t, e, r) {
|
|
2766
|
-
var n;
|
|
2767
|
-
if (!I(t))
|
|
2768
|
-
throw new y("Flattened JWE must be an object");
|
|
2769
|
-
if (t.protected === void 0 && t.header === void 0 && t.unprotected === void 0)
|
|
2770
|
-
throw new y("JOSE Header missing");
|
|
2771
|
-
if (typeof t.iv != "string")
|
|
2772
|
-
throw new y("JWE Initialization Vector missing or incorrect type");
|
|
2773
|
-
if (typeof t.ciphertext != "string")
|
|
2774
|
-
throw new y("JWE Ciphertext missing or incorrect type");
|
|
2775
|
-
if (typeof t.tag != "string")
|
|
2776
|
-
throw new y("JWE Authentication Tag missing or incorrect type");
|
|
2777
|
-
if (t.protected !== void 0 && typeof t.protected != "string")
|
|
2778
|
-
throw new y("JWE Protected Header incorrect type");
|
|
2779
|
-
if (t.encrypted_key !== void 0 && typeof t.encrypted_key != "string")
|
|
2780
|
-
throw new y("JWE Encrypted Key incorrect type");
|
|
2781
|
-
if (t.aad !== void 0 && typeof t.aad != "string")
|
|
2782
|
-
throw new y("JWE AAD incorrect type");
|
|
2783
|
-
if (t.header !== void 0 && !I(t.header))
|
|
2784
|
-
throw new y("JWE Shared Unprotected Header incorrect type");
|
|
2785
|
-
if (t.unprotected !== void 0 && !I(t.unprotected))
|
|
2786
|
-
throw new y("JWE Per-Recipient Unprotected Header incorrect type");
|
|
2787
|
-
let a;
|
|
2788
|
-
if (t.protected)
|
|
2789
|
-
try {
|
|
2790
|
-
const m = T(t.protected);
|
|
2791
|
-
a = JSON.parse(X.decode(m));
|
|
2792
|
-
} catch {
|
|
2793
|
-
throw new y("JWE Protected Header is invalid");
|
|
2794
|
-
}
|
|
2795
|
-
if (!me(a, t.header, t.unprotected))
|
|
2796
|
-
throw new y("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");
|
|
2797
|
-
const s = {
|
|
2798
|
-
...a,
|
|
2799
|
-
...t.header,
|
|
2800
|
-
...t.unprotected
|
|
2801
|
-
};
|
|
2802
|
-
if (ye(y, /* @__PURE__ */ new Map(), r == null ? void 0 : r.crit, a, s), s.zip !== void 0) {
|
|
2803
|
-
if (!a || !a.zip)
|
|
2804
|
-
throw new y('JWE "zip" (Compression Algorithm) Header MUST be integrity protected');
|
|
2805
|
-
if (s.zip !== "DEF")
|
|
2806
|
-
throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value');
|
|
2807
|
-
}
|
|
2808
|
-
const { alg: i, enc: o } = s;
|
|
2809
|
-
if (typeof i != "string" || !i)
|
|
2810
|
-
throw new y("missing JWE Algorithm (alg) in JWE Header");
|
|
2811
|
-
if (typeof o != "string" || !o)
|
|
2812
|
-
throw new y("missing JWE Encryption Algorithm (enc) in JWE Header");
|
|
2813
|
-
const c = r && dt("keyManagementAlgorithms", r.keyManagementAlgorithms), u = r && dt("contentEncryptionAlgorithms", r.contentEncryptionAlgorithms);
|
|
2814
|
-
if (c && !c.has(i))
|
|
2815
|
-
throw new Re('"alg" (Algorithm) Header Parameter not allowed');
|
|
2816
|
-
if (u && !u.has(o))
|
|
2817
|
-
throw new Re('"enc" (Encryption Algorithm) Header Parameter not allowed');
|
|
2818
|
-
let l;
|
|
2819
|
-
if (t.encrypted_key !== void 0)
|
|
2820
|
-
try {
|
|
2821
|
-
l = T(t.encrypted_key);
|
|
2822
|
-
} catch {
|
|
2823
|
-
throw new y("Failed to base64url decode the encrypted_key");
|
|
2824
|
-
}
|
|
2825
|
-
let f = !1;
|
|
2826
|
-
typeof e == "function" && (e = await e(a, t), f = !0);
|
|
2827
|
-
let d;
|
|
2828
|
-
try {
|
|
2829
|
-
d = await ea(i, e, l, s, r);
|
|
2830
|
-
} catch (m) {
|
|
2831
|
-
if (m instanceof TypeError || m instanceof y || m instanceof x)
|
|
2832
|
-
throw m;
|
|
2833
|
-
d = ie(o);
|
|
2834
|
-
}
|
|
2835
|
-
let p, h;
|
|
2836
|
-
try {
|
|
2837
|
-
p = T(t.iv);
|
|
2838
|
-
} catch {
|
|
2839
|
-
throw new y("Failed to base64url decode the iv");
|
|
2840
|
-
}
|
|
2841
|
-
try {
|
|
2842
|
-
h = T(t.tag);
|
|
2843
|
-
} catch {
|
|
2844
|
-
throw new y("Failed to base64url decode the tag");
|
|
2845
|
-
}
|
|
2846
|
-
const g = K.encode((n = t.protected) !== null && n !== void 0 ? n : "");
|
|
2847
|
-
let S;
|
|
2848
|
-
t.aad !== void 0 ? S = Q(g, K.encode("."), K.encode(t.aad)) : S = g;
|
|
2849
|
-
let C;
|
|
2850
|
-
try {
|
|
2851
|
-
C = T(t.ciphertext);
|
|
2852
|
-
} catch {
|
|
2853
|
-
throw new y("Failed to base64url decode the ciphertext");
|
|
2854
|
-
}
|
|
2855
|
-
let v = await mr(o, d, C, p, h, S);
|
|
2856
|
-
s.zip === "DEF" && (v = await ((r == null ? void 0 : r.inflateRaw) || Pn)(v));
|
|
2857
|
-
const w = { plaintext: v };
|
|
2858
|
-
if (t.protected !== void 0 && (w.protectedHeader = a), t.aad !== void 0)
|
|
2859
|
-
try {
|
|
2860
|
-
w.additionalAuthenticatedData = T(t.aad);
|
|
2861
|
-
} catch {
|
|
2862
|
-
throw new y("Failed to base64url decode the aad");
|
|
2863
|
-
}
|
|
2864
|
-
return t.unprotected !== void 0 && (w.sharedUnprotectedHeader = t.unprotected), t.header !== void 0 && (w.unprotectedHeader = t.header), f ? { ...w, key: e } : w;
|
|
2865
|
-
}
|
|
2866
|
-
async function Pr(t, e, r) {
|
|
2867
|
-
if (t instanceof Uint8Array && (t = X.decode(t)), typeof t != "string")
|
|
2868
|
-
throw new y("Compact JWE must be a string or Uint8Array");
|
|
2869
|
-
const { 0: n, 1: a, 2: s, 3: i, 4: o, length: c } = t.split(".");
|
|
2870
|
-
if (c !== 5)
|
|
2871
|
-
throw new y("Invalid Compact JWE");
|
|
2872
|
-
const u = await St({
|
|
2873
|
-
ciphertext: i,
|
|
2874
|
-
iv: s || void 0,
|
|
2875
|
-
protected: n || void 0,
|
|
2876
|
-
tag: o || void 0,
|
|
2877
|
-
encrypted_key: a || void 0
|
|
2878
|
-
}, e, r), l = { plaintext: u.plaintext, protectedHeader: u.protectedHeader };
|
|
2879
|
-
return typeof e == "function" ? { ...l, key: u.key } : l;
|
|
2880
|
-
}
|
|
2881
|
-
async function ta(t, e, r) {
|
|
2882
|
-
if (!I(t))
|
|
2883
|
-
throw new y("General JWE must be an object");
|
|
2884
|
-
if (!Array.isArray(t.recipients) || !t.recipients.every(I))
|
|
2885
|
-
throw new y("JWE Recipients missing or incorrect type");
|
|
2886
|
-
if (!t.recipients.length)
|
|
2887
|
-
throw new y("JWE Recipients has no members");
|
|
2888
|
-
for (const n of t.recipients)
|
|
2889
|
-
try {
|
|
2890
|
-
return await St({
|
|
2891
|
-
aad: t.aad,
|
|
2892
|
-
ciphertext: t.ciphertext,
|
|
2893
|
-
encrypted_key: n.encrypted_key,
|
|
2894
|
-
header: n.header,
|
|
2895
|
-
iv: t.iv,
|
|
2896
|
-
protected: t.protected,
|
|
2897
|
-
tag: t.tag,
|
|
2898
|
-
unprotected: t.unprotected
|
|
2899
|
-
}, e, r);
|
|
2900
|
-
} catch {
|
|
2901
|
-
}
|
|
2902
|
-
throw new ge();
|
|
2903
|
-
}
|
|
2904
|
-
const ra = async (t) => {
|
|
2905
|
-
if (t instanceof Uint8Array)
|
|
2906
|
-
return {
|
|
2907
|
-
kty: "oct",
|
|
2908
|
-
k: O(t)
|
|
2909
|
-
};
|
|
2910
|
-
if (!G(t))
|
|
2911
|
-
throw new TypeError(M(t, ...H, "Uint8Array"));
|
|
2912
|
-
if (!t.extractable)
|
|
2913
|
-
throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");
|
|
2914
|
-
const { ext: e, key_ops: r, alg: n, use: a, ...s } = await b.subtle.exportKey("jwk", t);
|
|
2915
|
-
return s;
|
|
2916
|
-
}, na = ra;
|
|
2917
|
-
async function aa(t) {
|
|
2918
|
-
return Dn(t);
|
|
2919
|
-
}
|
|
2920
|
-
async function sa(t) {
|
|
2921
|
-
return Jn(t);
|
|
2922
|
-
}
|
|
2923
|
-
async function Hr(t) {
|
|
2924
|
-
return na(t);
|
|
2925
|
-
}
|
|
2926
|
-
async function Kr(t, e, r, n, a = {}) {
|
|
2927
|
-
let s, i, o;
|
|
2928
|
-
switch (Me(t, r, "encrypt"), t) {
|
|
2929
|
-
case "dir": {
|
|
2930
|
-
o = r;
|
|
2931
|
-
break;
|
|
2932
|
-
}
|
|
2933
|
-
case "ECDH-ES":
|
|
2934
|
-
case "ECDH-ES+A128KW":
|
|
2935
|
-
case "ECDH-ES+A192KW":
|
|
2936
|
-
case "ECDH-ES+A256KW": {
|
|
2937
|
-
if (!br(r))
|
|
2938
|
-
throw new x("ECDH with the provided key is not allowed or not supported by your javascript runtime");
|
|
2939
|
-
const { apu: c, apv: u } = a;
|
|
2940
|
-
let { epk: l } = a;
|
|
2941
|
-
l || (l = (await Rn(r)).privateKey);
|
|
2942
|
-
const { x: f, y: d, crv: p, kty: h } = await Hr(l), g = await Sr(r, l, t === "ECDH-ES" ? e : t, t === "ECDH-ES" ? wt(e) : parseInt(t.slice(-5, -2), 10), c, u);
|
|
2943
|
-
if (i = { epk: { x: f, crv: p, kty: h } }, h === "EC" && (i.epk.y = d), c && (i.apu = O(c)), u && (i.apv = O(u)), t === "ECDH-ES") {
|
|
2944
|
-
o = g;
|
|
2945
|
-
break;
|
|
2946
|
-
}
|
|
2947
|
-
o = n || ie(e);
|
|
2948
|
-
const S = t.slice(-6);
|
|
2949
|
-
s = await ct(S, g, o);
|
|
2950
|
-
break;
|
|
2951
|
-
}
|
|
2952
|
-
case "RSA1_5":
|
|
2953
|
-
case "RSA-OAEP":
|
|
2954
|
-
case "RSA-OAEP-256":
|
|
2955
|
-
case "RSA-OAEP-384":
|
|
2956
|
-
case "RSA-OAEP-512": {
|
|
2957
|
-
o = n || ie(e), s = await Un(t, r, o);
|
|
2958
|
-
break;
|
|
2959
|
-
}
|
|
2960
|
-
case "PBES2-HS256+A128KW":
|
|
2961
|
-
case "PBES2-HS384+A192KW":
|
|
2962
|
-
case "PBES2-HS512+A256KW": {
|
|
2963
|
-
o = n || ie(e);
|
|
2964
|
-
const { p2c: c, p2s: u } = a;
|
|
2965
|
-
({ encryptedKey: s, ...i } = await In(t, r, o, c, u));
|
|
2966
|
-
break;
|
|
2967
|
-
}
|
|
2968
|
-
case "A128KW":
|
|
2969
|
-
case "A192KW":
|
|
2970
|
-
case "A256KW": {
|
|
2971
|
-
o = n || ie(e), s = await ct(t, r, o);
|
|
2972
|
-
break;
|
|
2973
|
-
}
|
|
2974
|
-
case "A128GCMKW":
|
|
2975
|
-
case "A192GCMKW":
|
|
2976
|
-
case "A256GCMKW": {
|
|
2977
|
-
o = n || ie(e);
|
|
2978
|
-
const { iv: c } = a;
|
|
2979
|
-
({ encryptedKey: s, ...i } = await Qn(t, r, o, c));
|
|
2980
|
-
break;
|
|
2981
|
-
}
|
|
2982
|
-
default:
|
|
2983
|
-
throw new x('Invalid or unsupported "alg" (JWE Algorithm) header value');
|
|
2984
|
-
}
|
|
2985
|
-
return { cek: o, encryptedKey: s, parameters: i };
|
|
2986
|
-
}
|
|
2987
|
-
const Rr = Symbol();
|
|
2988
|
-
class Ie {
|
|
2989
|
-
constructor(e) {
|
|
2990
|
-
if (!(e instanceof Uint8Array))
|
|
2991
|
-
throw new TypeError("plaintext must be an instance of Uint8Array");
|
|
2992
|
-
this._plaintext = e;
|
|
2993
|
-
}
|
|
2994
|
-
setKeyManagementParameters(e) {
|
|
2995
|
-
if (this._keyManagementParameters)
|
|
2996
|
-
throw new TypeError("setKeyManagementParameters can only be called once");
|
|
2997
|
-
return this._keyManagementParameters = e, this;
|
|
2998
|
-
}
|
|
2999
|
-
setProtectedHeader(e) {
|
|
3000
|
-
if (this._protectedHeader)
|
|
3001
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
3002
|
-
return this._protectedHeader = e, this;
|
|
3003
|
-
}
|
|
3004
|
-
setSharedUnprotectedHeader(e) {
|
|
3005
|
-
if (this._sharedUnprotectedHeader)
|
|
3006
|
-
throw new TypeError("setSharedUnprotectedHeader can only be called once");
|
|
3007
|
-
return this._sharedUnprotectedHeader = e, this;
|
|
3008
|
-
}
|
|
3009
|
-
setUnprotectedHeader(e) {
|
|
3010
|
-
if (this._unprotectedHeader)
|
|
3011
|
-
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
3012
|
-
return this._unprotectedHeader = e, this;
|
|
3013
|
-
}
|
|
3014
|
-
setAdditionalAuthenticatedData(e) {
|
|
3015
|
-
return this._aad = e, this;
|
|
3016
|
-
}
|
|
3017
|
-
setContentEncryptionKey(e) {
|
|
3018
|
-
if (this._cek)
|
|
3019
|
-
throw new TypeError("setContentEncryptionKey can only be called once");
|
|
3020
|
-
return this._cek = e, this;
|
|
3021
|
-
}
|
|
3022
|
-
setInitializationVector(e) {
|
|
3023
|
-
if (this._iv)
|
|
3024
|
-
throw new TypeError("setInitializationVector can only be called once");
|
|
3025
|
-
return this._iv = e, this;
|
|
3026
|
-
}
|
|
3027
|
-
async encrypt(e, r) {
|
|
3028
|
-
if (!this._protectedHeader && !this._unprotectedHeader && !this._sharedUnprotectedHeader)
|
|
3029
|
-
throw new y("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");
|
|
3030
|
-
if (!me(this._protectedHeader, this._unprotectedHeader, this._sharedUnprotectedHeader))
|
|
3031
|
-
throw new y("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");
|
|
3032
|
-
const n = {
|
|
3033
|
-
...this._protectedHeader,
|
|
3034
|
-
...this._unprotectedHeader,
|
|
3035
|
-
...this._sharedUnprotectedHeader
|
|
3036
|
-
};
|
|
3037
|
-
if (ye(y, /* @__PURE__ */ new Map(), r == null ? void 0 : r.crit, this._protectedHeader, n), n.zip !== void 0) {
|
|
3038
|
-
if (!this._protectedHeader || !this._protectedHeader.zip)
|
|
3039
|
-
throw new y('JWE "zip" (Compression Algorithm) Header MUST be integrity protected');
|
|
3040
|
-
if (n.zip !== "DEF")
|
|
3041
|
-
throw new x('Unsupported JWE "zip" (Compression Algorithm) Header Parameter value');
|
|
3042
|
-
}
|
|
3043
|
-
const { alg: a, enc: s } = n;
|
|
3044
|
-
if (typeof a != "string" || !a)
|
|
3045
|
-
throw new y('JWE "alg" (Algorithm) Header Parameter missing or invalid');
|
|
3046
|
-
if (typeof s != "string" || !s)
|
|
3047
|
-
throw new y('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
|
|
3048
|
-
let i;
|
|
3049
|
-
if (a === "dir") {
|
|
3050
|
-
if (this._cek)
|
|
3051
|
-
throw new TypeError("setContentEncryptionKey cannot be called when using Direct Encryption");
|
|
3052
|
-
} else if (a === "ECDH-ES" && this._cek)
|
|
3053
|
-
throw new TypeError("setContentEncryptionKey cannot be called when using Direct Key Agreement");
|
|
3054
|
-
let o;
|
|
3055
|
-
{
|
|
3056
|
-
let h;
|
|
3057
|
-
({ cek: o, encryptedKey: i, parameters: h } = await Kr(a, s, e, this._cek, this._keyManagementParameters)), h && (r && Rr in r ? this._unprotectedHeader ? this._unprotectedHeader = { ...this._unprotectedHeader, ...h } : this.setUnprotectedHeader(h) : this._protectedHeader ? this._protectedHeader = { ...this._protectedHeader, ...h } : this.setProtectedHeader(h));
|
|
3058
|
-
}
|
|
3059
|
-
this._iv || (this._iv = lr(s));
|
|
3060
|
-
let c, u, l;
|
|
3061
|
-
this._protectedHeader ? u = K.encode(O(JSON.stringify(this._protectedHeader))) : u = K.encode(""), this._aad ? (l = O(this._aad), c = Q(u, K.encode("."), K.encode(l))) : c = u;
|
|
3062
|
-
let f, d;
|
|
3063
|
-
if (n.zip === "DEF") {
|
|
3064
|
-
const h = await ((r == null ? void 0 : r.deflateRaw) || Hn)(this._plaintext);
|
|
3065
|
-
({ ciphertext: f, tag: d } = await lt(s, h, o, this._iv, c));
|
|
3066
|
-
} else
|
|
3067
|
-
({ ciphertext: f, tag: d } = await lt(s, this._plaintext, o, this._iv, c));
|
|
3068
|
-
const p = {
|
|
3069
|
-
ciphertext: O(f),
|
|
3070
|
-
iv: O(this._iv),
|
|
3071
|
-
tag: O(d)
|
|
3072
|
-
};
|
|
3073
|
-
return i && (p.encrypted_key = O(i)), l && (p.aad = l), this._protectedHeader && (p.protected = X.decode(u)), this._sharedUnprotectedHeader && (p.unprotected = this._sharedUnprotectedHeader), this._unprotectedHeader && (p.header = this._unprotectedHeader), p;
|
|
3074
|
-
}
|
|
3075
|
-
}
|
|
3076
|
-
class ia {
|
|
3077
|
-
constructor(e, r, n) {
|
|
3078
|
-
this.parent = e, this.key = r, this.options = n;
|
|
3079
|
-
}
|
|
3080
|
-
setUnprotectedHeader(e) {
|
|
3081
|
-
if (this.unprotectedHeader)
|
|
3082
|
-
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
3083
|
-
return this.unprotectedHeader = e, this;
|
|
3084
|
-
}
|
|
3085
|
-
addRecipient(...e) {
|
|
3086
|
-
return this.parent.addRecipient(...e);
|
|
3087
|
-
}
|
|
3088
|
-
encrypt(...e) {
|
|
3089
|
-
return this.parent.encrypt(...e);
|
|
3090
|
-
}
|
|
3091
|
-
done() {
|
|
3092
|
-
return this.parent;
|
|
3093
|
-
}
|
|
3094
|
-
}
|
|
3095
|
-
class oa {
|
|
3096
|
-
constructor(e) {
|
|
3097
|
-
this._recipients = [], this._plaintext = e;
|
|
3098
|
-
}
|
|
3099
|
-
addRecipient(e, r) {
|
|
3100
|
-
const n = new ia(this, e, { crit: r == null ? void 0 : r.crit });
|
|
3101
|
-
return this._recipients.push(n), n;
|
|
3102
|
-
}
|
|
3103
|
-
setProtectedHeader(e) {
|
|
3104
|
-
if (this._protectedHeader)
|
|
3105
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
3106
|
-
return this._protectedHeader = e, this;
|
|
3107
|
-
}
|
|
3108
|
-
setSharedUnprotectedHeader(e) {
|
|
3109
|
-
if (this._unprotectedHeader)
|
|
3110
|
-
throw new TypeError("setSharedUnprotectedHeader can only be called once");
|
|
3111
|
-
return this._unprotectedHeader = e, this;
|
|
3112
|
-
}
|
|
3113
|
-
setAdditionalAuthenticatedData(e) {
|
|
3114
|
-
return this._aad = e, this;
|
|
3115
|
-
}
|
|
3116
|
-
async encrypt(e) {
|
|
3117
|
-
var r, n, a;
|
|
3118
|
-
if (!this._recipients.length)
|
|
3119
|
-
throw new y("at least one recipient must be added");
|
|
3120
|
-
if (e = { deflateRaw: e == null ? void 0 : e.deflateRaw }, this._recipients.length === 1) {
|
|
3121
|
-
const [c] = this._recipients, u = await new Ie(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(c.unprotectedHeader).encrypt(c.key, { ...c.options, ...e });
|
|
3122
|
-
let l = {
|
|
3123
|
-
ciphertext: u.ciphertext,
|
|
3124
|
-
iv: u.iv,
|
|
3125
|
-
recipients: [{}],
|
|
3126
|
-
tag: u.tag
|
|
3127
|
-
};
|
|
3128
|
-
return u.aad && (l.aad = u.aad), u.protected && (l.protected = u.protected), u.unprotected && (l.unprotected = u.unprotected), u.encrypted_key && (l.recipients[0].encrypted_key = u.encrypted_key), u.header && (l.recipients[0].header = u.header), l;
|
|
3129
|
-
}
|
|
3130
|
-
let s;
|
|
3131
|
-
for (let c = 0; c < this._recipients.length; c++) {
|
|
3132
|
-
const u = this._recipients[c];
|
|
3133
|
-
if (!me(this._protectedHeader, this._unprotectedHeader, u.unprotectedHeader))
|
|
3134
|
-
throw new y("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");
|
|
3135
|
-
const l = {
|
|
3136
|
-
...this._protectedHeader,
|
|
3137
|
-
...this._unprotectedHeader,
|
|
3138
|
-
...u.unprotectedHeader
|
|
3139
|
-
}, { alg: f } = l;
|
|
3140
|
-
if (typeof f != "string" || !f)
|
|
3141
|
-
throw new y('JWE "alg" (Algorithm) Header Parameter missing or invalid');
|
|
3142
|
-
if (f === "dir" || f === "ECDH-ES")
|
|
3143
|
-
throw new y('"dir" and "ECDH-ES" alg may only be used with a single recipient');
|
|
3144
|
-
if (typeof l.enc != "string" || !l.enc)
|
|
3145
|
-
throw new y('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');
|
|
3146
|
-
if (!s)
|
|
3147
|
-
s = l.enc;
|
|
3148
|
-
else if (s !== l.enc)
|
|
3149
|
-
throw new y('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients');
|
|
3150
|
-
if (ye(y, /* @__PURE__ */ new Map(), u.options.crit, this._protectedHeader, l), l.zip !== void 0 && (!this._protectedHeader || !this._protectedHeader.zip))
|
|
3151
|
-
throw new y('JWE "zip" (Compression Algorithm) Header MUST be integrity protected');
|
|
3152
|
-
}
|
|
3153
|
-
const i = ie(s);
|
|
3154
|
-
let o = {
|
|
3155
|
-
ciphertext: "",
|
|
3156
|
-
iv: "",
|
|
3157
|
-
recipients: [],
|
|
3158
|
-
tag: ""
|
|
3159
|
-
};
|
|
3160
|
-
for (let c = 0; c < this._recipients.length; c++) {
|
|
3161
|
-
const u = this._recipients[c], l = {};
|
|
3162
|
-
o.recipients.push(l);
|
|
3163
|
-
const d = {
|
|
3164
|
-
...this._protectedHeader,
|
|
3165
|
-
...this._unprotectedHeader,
|
|
3166
|
-
...u.unprotectedHeader
|
|
3167
|
-
}.alg.startsWith("PBES2") ? 2048 + c : void 0;
|
|
3168
|
-
if (c === 0) {
|
|
3169
|
-
const g = await new Ie(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(i).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(u.unprotectedHeader).setKeyManagementParameters({ p2c: d }).encrypt(u.key, {
|
|
3170
|
-
...u.options,
|
|
3171
|
-
...e,
|
|
3172
|
-
[Rr]: !0
|
|
3173
|
-
});
|
|
3174
|
-
o.ciphertext = g.ciphertext, o.iv = g.iv, o.tag = g.tag, g.aad && (o.aad = g.aad), g.protected && (o.protected = g.protected), g.unprotected && (o.unprotected = g.unprotected), l.encrypted_key = g.encrypted_key, g.header && (l.header = g.header);
|
|
3175
|
-
continue;
|
|
3176
|
-
}
|
|
3177
|
-
const { encryptedKey: p, parameters: h } = await Kr(((r = u.unprotectedHeader) === null || r === void 0 ? void 0 : r.alg) || ((n = this._protectedHeader) === null || n === void 0 ? void 0 : n.alg) || ((a = this._unprotectedHeader) === null || a === void 0 ? void 0 : a.alg), s, u.key, i, { p2c: d });
|
|
3178
|
-
l.encrypted_key = O(p), (u.unprotectedHeader || h) && (l.header = { ...u.unprotectedHeader, ...h });
|
|
3179
|
-
}
|
|
3180
|
-
return o;
|
|
3181
|
-
}
|
|
3182
|
-
}
|
|
3183
|
-
function Or(t, e) {
|
|
3184
|
-
const r = `SHA-${t.slice(-3)}`;
|
|
3185
|
-
switch (t) {
|
|
3186
|
-
case "HS256":
|
|
3187
|
-
case "HS384":
|
|
3188
|
-
case "HS512":
|
|
3189
|
-
return { hash: r, name: "HMAC" };
|
|
3190
|
-
case "PS256":
|
|
3191
|
-
case "PS384":
|
|
3192
|
-
case "PS512":
|
|
3193
|
-
return { hash: r, name: "RSA-PSS", saltLength: t.slice(-3) >> 3 };
|
|
3194
|
-
case "RS256":
|
|
3195
|
-
case "RS384":
|
|
3196
|
-
case "RS512":
|
|
3197
|
-
return { hash: r, name: "RSASSA-PKCS1-v1_5" };
|
|
3198
|
-
case "ES256":
|
|
3199
|
-
case "ES384":
|
|
3200
|
-
case "ES512":
|
|
3201
|
-
return { hash: r, name: "ECDSA", namedCurve: e.namedCurve };
|
|
3202
|
-
case "EdDSA":
|
|
3203
|
-
return { name: e.name };
|
|
3204
|
-
default:
|
|
3205
|
-
throw new x(`alg ${t} is not supported either by JOSE or your javascript runtime`);
|
|
3206
|
-
}
|
|
3207
|
-
}
|
|
3208
|
-
function Tr(t, e, r) {
|
|
3209
|
-
if (G(e))
|
|
3210
|
-
return xn(e, t, r), e;
|
|
3211
|
-
if (e instanceof Uint8Array) {
|
|
3212
|
-
if (!t.startsWith("HS"))
|
|
3213
|
-
throw new TypeError(M(e, ...H));
|
|
3214
|
-
return b.subtle.importKey("raw", e, { hash: `SHA-${t.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
3215
|
-
}
|
|
3216
|
-
throw new TypeError(M(e, ...H, "Uint8Array"));
|
|
3217
|
-
}
|
|
3218
|
-
const ca = async (t, e, r, n) => {
|
|
3219
|
-
const a = await Tr(t, e, "verify");
|
|
3220
|
-
Ne(t, a);
|
|
3221
|
-
const s = Or(t, a.algorithm);
|
|
3222
|
-
try {
|
|
3223
|
-
return await b.subtle.verify(s, a, r, n);
|
|
3224
|
-
} catch {
|
|
3225
|
-
return !1;
|
|
3226
|
-
}
|
|
3227
|
-
};
|
|
3228
|
-
async function bt(t, e, r) {
|
|
3229
|
-
var n;
|
|
3230
|
-
if (!I(t))
|
|
3231
|
-
throw new P("Flattened JWS must be an object");
|
|
3232
|
-
if (t.protected === void 0 && t.header === void 0)
|
|
3233
|
-
throw new P('Flattened JWS must have either of the "protected" or "header" members');
|
|
3234
|
-
if (t.protected !== void 0 && typeof t.protected != "string")
|
|
3235
|
-
throw new P("JWS Protected Header incorrect type");
|
|
3236
|
-
if (t.payload === void 0)
|
|
3237
|
-
throw new P("JWS Payload missing");
|
|
3238
|
-
if (typeof t.signature != "string")
|
|
3239
|
-
throw new P("JWS Signature missing or incorrect type");
|
|
3240
|
-
if (t.header !== void 0 && !I(t.header))
|
|
3241
|
-
throw new P("JWS Unprotected Header incorrect type");
|
|
3242
|
-
let a = {};
|
|
3243
|
-
if (t.protected)
|
|
3244
|
-
try {
|
|
3245
|
-
const S = T(t.protected);
|
|
3246
|
-
a = JSON.parse(X.decode(S));
|
|
3247
|
-
} catch {
|
|
3248
|
-
throw new P("JWS Protected Header is invalid");
|
|
3249
|
-
}
|
|
3250
|
-
if (!me(a, t.header))
|
|
3251
|
-
throw new P("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
3252
|
-
const s = {
|
|
3253
|
-
...a,
|
|
3254
|
-
...t.header
|
|
3255
|
-
}, i = ye(P, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, a, s);
|
|
3256
|
-
let o = !0;
|
|
3257
|
-
if (i.has("b64") && (o = a.b64, typeof o != "boolean"))
|
|
3258
|
-
throw new P('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
3259
|
-
const { alg: c } = s;
|
|
3260
|
-
if (typeof c != "string" || !c)
|
|
3261
|
-
throw new P('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
3262
|
-
const u = r && dt("algorithms", r.algorithms);
|
|
3263
|
-
if (u && !u.has(c))
|
|
3264
|
-
throw new Re('"alg" (Algorithm) Header Parameter not allowed');
|
|
3265
|
-
if (o) {
|
|
3266
|
-
if (typeof t.payload != "string")
|
|
3267
|
-
throw new P("JWS Payload must be a string");
|
|
3268
|
-
} else if (typeof t.payload != "string" && !(t.payload instanceof Uint8Array))
|
|
3269
|
-
throw new P("JWS Payload must be a string or an Uint8Array instance");
|
|
3270
|
-
let l = !1;
|
|
3271
|
-
typeof e == "function" && (e = await e(a, t), l = !0), Me(c, e, "verify");
|
|
3272
|
-
const f = Q(K.encode((n = t.protected) !== null && n !== void 0 ? n : ""), K.encode("."), typeof t.payload == "string" ? K.encode(t.payload) : t.payload);
|
|
3273
|
-
let d;
|
|
3274
|
-
try {
|
|
3275
|
-
d = T(t.signature);
|
|
3276
|
-
} catch {
|
|
3277
|
-
throw new P("Failed to base64url decode the signature");
|
|
3278
|
-
}
|
|
3279
|
-
if (!await ca(c, e, d, f))
|
|
3280
|
-
throw new yt();
|
|
3281
|
-
let h;
|
|
3282
|
-
if (o)
|
|
3283
|
-
try {
|
|
3284
|
-
h = T(t.payload);
|
|
3285
|
-
} catch {
|
|
3286
|
-
throw new P("Failed to base64url decode the payload");
|
|
3287
|
-
}
|
|
3288
|
-
else
|
|
3289
|
-
typeof t.payload == "string" ? h = K.encode(t.payload) : h = t.payload;
|
|
3290
|
-
const g = { payload: h };
|
|
3291
|
-
return t.protected !== void 0 && (g.protectedHeader = a), t.header !== void 0 && (g.unprotectedHeader = t.header), l ? { ...g, key: e } : g;
|
|
3292
|
-
}
|
|
3293
|
-
async function Ir(t, e, r) {
|
|
3294
|
-
if (t instanceof Uint8Array && (t = X.decode(t)), typeof t != "string")
|
|
3295
|
-
throw new P("Compact JWS must be a string or Uint8Array");
|
|
3296
|
-
const { 0: n, 1: a, 2: s, length: i } = t.split(".");
|
|
3297
|
-
if (i !== 3)
|
|
3298
|
-
throw new P("Invalid Compact JWS");
|
|
3299
|
-
const o = await bt({ payload: a, protected: n, signature: s }, e, r), c = { payload: o.payload, protectedHeader: o.protectedHeader };
|
|
3300
|
-
return typeof e == "function" ? { ...c, key: o.key } : c;
|
|
3301
|
-
}
|
|
3302
|
-
async function ua(t, e, r) {
|
|
3303
|
-
if (!I(t))
|
|
3304
|
-
throw new P("General JWS must be an object");
|
|
3305
|
-
if (!Array.isArray(t.signatures) || !t.signatures.every(I))
|
|
3306
|
-
throw new P("JWS Signatures missing or incorrect type");
|
|
3307
|
-
for (const n of t.signatures)
|
|
3308
|
-
try {
|
|
3309
|
-
return await bt({
|
|
3310
|
-
header: n.header,
|
|
3311
|
-
payload: t.payload,
|
|
3312
|
-
protected: n.protected,
|
|
3313
|
-
signature: n.signature
|
|
3314
|
-
}, e, r);
|
|
3315
|
-
} catch {
|
|
3316
|
-
}
|
|
3317
|
-
throw new yt();
|
|
3318
|
-
}
|
|
3319
|
-
const Ae = (t) => Math.floor(t.getTime() / 1e3), Wr = 60, Ur = Wr * 60, vt = Ur * 24, la = vt * 7, da = vt * 365.25, fa = /^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i, We = (t) => {
|
|
3320
|
-
const e = fa.exec(t);
|
|
3321
|
-
if (!e)
|
|
3322
|
-
throw new TypeError("Invalid time period format");
|
|
3323
|
-
const r = parseFloat(e[1]);
|
|
3324
|
-
switch (e[2].toLowerCase()) {
|
|
3325
|
-
case "sec":
|
|
3326
|
-
case "secs":
|
|
3327
|
-
case "second":
|
|
3328
|
-
case "seconds":
|
|
3329
|
-
case "s":
|
|
3330
|
-
return Math.round(r);
|
|
3331
|
-
case "minute":
|
|
3332
|
-
case "minutes":
|
|
3333
|
-
case "min":
|
|
3334
|
-
case "mins":
|
|
3335
|
-
case "m":
|
|
3336
|
-
return Math.round(r * Wr);
|
|
3337
|
-
case "hour":
|
|
3338
|
-
case "hours":
|
|
3339
|
-
case "hr":
|
|
3340
|
-
case "hrs":
|
|
3341
|
-
case "h":
|
|
3342
|
-
return Math.round(r * Ur);
|
|
3343
|
-
case "day":
|
|
3344
|
-
case "days":
|
|
3345
|
-
case "d":
|
|
3346
|
-
return Math.round(r * vt);
|
|
3347
|
-
case "week":
|
|
3348
|
-
case "weeks":
|
|
3349
|
-
case "w":
|
|
3350
|
-
return Math.round(r * la);
|
|
3351
|
-
default:
|
|
3352
|
-
return Math.round(r * da);
|
|
3353
|
-
}
|
|
3354
|
-
}, Mt = (t) => t.toLowerCase().replace(/^application\//, ""), ha = (t, e) => typeof t == "string" ? e.includes(t) : Array.isArray(t) ? e.some(Set.prototype.has.bind(new Set(t))) : !1, Et = (t, e, r = {}) => {
|
|
3355
|
-
const { typ: n } = r;
|
|
3356
|
-
if (n && (typeof t.typ != "string" || Mt(t.typ) !== Mt(n)))
|
|
3357
|
-
throw new V('unexpected "typ" JWT header value', "typ", "check_failed");
|
|
3358
|
-
let a;
|
|
3359
|
-
try {
|
|
3360
|
-
a = JSON.parse(X.decode(e));
|
|
3361
|
-
} catch {
|
|
3362
|
-
}
|
|
3363
|
-
if (!I(a))
|
|
3364
|
-
throw new B("JWT Claims Set must be a top-level JSON object");
|
|
3365
|
-
const { requiredClaims: s = [], issuer: i, subject: o, audience: c, maxTokenAge: u } = r;
|
|
3366
|
-
u !== void 0 && s.push("iat"), c !== void 0 && s.push("aud"), o !== void 0 && s.push("sub"), i !== void 0 && s.push("iss");
|
|
3367
|
-
for (const p of new Set(s.reverse()))
|
|
3368
|
-
if (!(p in a))
|
|
3369
|
-
throw new V(`missing required "${p}" claim`, p, "missing");
|
|
3370
|
-
if (i && !(Array.isArray(i) ? i : [i]).includes(a.iss))
|
|
3371
|
-
throw new V('unexpected "iss" claim value', "iss", "check_failed");
|
|
3372
|
-
if (o && a.sub !== o)
|
|
3373
|
-
throw new V('unexpected "sub" claim value', "sub", "check_failed");
|
|
3374
|
-
if (c && !ha(a.aud, typeof c == "string" ? [c] : c))
|
|
3375
|
-
throw new V('unexpected "aud" claim value', "aud", "check_failed");
|
|
3376
|
-
let l;
|
|
3377
|
-
switch (typeof r.clockTolerance) {
|
|
3378
|
-
case "string":
|
|
3379
|
-
l = We(r.clockTolerance);
|
|
3380
|
-
break;
|
|
3381
|
-
case "number":
|
|
3382
|
-
l = r.clockTolerance;
|
|
3383
|
-
break;
|
|
3384
|
-
case "undefined":
|
|
3385
|
-
l = 0;
|
|
3386
|
-
break;
|
|
3387
|
-
default:
|
|
3388
|
-
throw new TypeError("Invalid clockTolerance option type");
|
|
3389
|
-
}
|
|
3390
|
-
const { currentDate: f } = r, d = Ae(f || /* @__PURE__ */ new Date());
|
|
3391
|
-
if ((a.iat !== void 0 || u) && typeof a.iat != "number")
|
|
3392
|
-
throw new V('"iat" claim must be a number', "iat", "invalid");
|
|
3393
|
-
if (a.nbf !== void 0) {
|
|
3394
|
-
if (typeof a.nbf != "number")
|
|
3395
|
-
throw new V('"nbf" claim must be a number', "nbf", "invalid");
|
|
3396
|
-
if (a.nbf > d + l)
|
|
3397
|
-
throw new V('"nbf" claim timestamp check failed', "nbf", "check_failed");
|
|
3398
|
-
}
|
|
3399
|
-
if (a.exp !== void 0) {
|
|
3400
|
-
if (typeof a.exp != "number")
|
|
3401
|
-
throw new V('"exp" claim must be a number', "exp", "invalid");
|
|
3402
|
-
if (a.exp <= d - l)
|
|
3403
|
-
throw new ot('"exp" claim timestamp check failed', "exp", "check_failed");
|
|
3404
|
-
}
|
|
3405
|
-
if (u) {
|
|
3406
|
-
const p = d - a.iat, h = typeof u == "number" ? u : We(u);
|
|
3407
|
-
if (p - l > h)
|
|
3408
|
-
throw new ot('"iat" claim timestamp check failed (too far in the past)', "iat", "check_failed");
|
|
3409
|
-
if (p < 0 - l)
|
|
3410
|
-
throw new V('"iat" claim timestamp check failed (it should be in the past)', "iat", "check_failed");
|
|
3411
|
-
}
|
|
3412
|
-
return a;
|
|
3413
|
-
};
|
|
3414
|
-
async function pa(t, e, r) {
|
|
3415
|
-
var n;
|
|
3416
|
-
const a = await Ir(t, e, r);
|
|
3417
|
-
if (!((n = a.protectedHeader.crit) === null || n === void 0) && n.includes("b64") && a.protectedHeader.b64 === !1)
|
|
3418
|
-
throw new B("JWTs MUST NOT use unencoded payload");
|
|
3419
|
-
const i = { payload: Et(a.protectedHeader, a.payload, r), protectedHeader: a.protectedHeader };
|
|
3420
|
-
return typeof e == "function" ? { ...i, key: a.key } : i;
|
|
3421
|
-
}
|
|
3422
|
-
async function ga(t, e, r) {
|
|
3423
|
-
const n = await Pr(t, e, r), a = Et(n.protectedHeader, n.plaintext, r), { protectedHeader: s } = n;
|
|
3424
|
-
if (s.iss !== void 0 && s.iss !== a.iss)
|
|
3425
|
-
throw new V('replicated "iss" claim header parameter mismatch', "iss", "mismatch");
|
|
3426
|
-
if (s.sub !== void 0 && s.sub !== a.sub)
|
|
3427
|
-
throw new V('replicated "sub" claim header parameter mismatch', "sub", "mismatch");
|
|
3428
|
-
if (s.aud !== void 0 && JSON.stringify(s.aud) !== JSON.stringify(a.aud))
|
|
3429
|
-
throw new V('replicated "aud" claim header parameter mismatch', "aud", "mismatch");
|
|
3430
|
-
const i = { payload: a, protectedHeader: s };
|
|
3431
|
-
return typeof e == "function" ? { ...i, key: n.key } : i;
|
|
3432
|
-
}
|
|
3433
|
-
class Lr {
|
|
3434
|
-
constructor(e) {
|
|
3435
|
-
this._flattened = new Ie(e);
|
|
3436
|
-
}
|
|
3437
|
-
setContentEncryptionKey(e) {
|
|
3438
|
-
return this._flattened.setContentEncryptionKey(e), this;
|
|
3439
|
-
}
|
|
3440
|
-
setInitializationVector(e) {
|
|
3441
|
-
return this._flattened.setInitializationVector(e), this;
|
|
3442
|
-
}
|
|
3443
|
-
setProtectedHeader(e) {
|
|
3444
|
-
return this._flattened.setProtectedHeader(e), this;
|
|
3445
|
-
}
|
|
3446
|
-
setKeyManagementParameters(e) {
|
|
3447
|
-
return this._flattened.setKeyManagementParameters(e), this;
|
|
3448
|
-
}
|
|
3449
|
-
async encrypt(e, r) {
|
|
3450
|
-
const n = await this._flattened.encrypt(e, r);
|
|
3451
|
-
return [n.protected, n.encrypted_key, n.iv, n.ciphertext, n.tag].join(".");
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3454
|
-
const ma = async (t, e, r) => {
|
|
3455
|
-
const n = await Tr(t, e, "sign");
|
|
3456
|
-
Ne(t, n);
|
|
3457
|
-
const a = await b.subtle.sign(Or(t, n.algorithm), n, r);
|
|
3458
|
-
return new Uint8Array(a);
|
|
3459
|
-
};
|
|
3460
|
-
class At {
|
|
3461
|
-
constructor(e) {
|
|
3462
|
-
if (!(e instanceof Uint8Array))
|
|
3463
|
-
throw new TypeError("payload must be an instance of Uint8Array");
|
|
3464
|
-
this._payload = e;
|
|
3465
|
-
}
|
|
3466
|
-
setProtectedHeader(e) {
|
|
3467
|
-
if (this._protectedHeader)
|
|
3468
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
3469
|
-
return this._protectedHeader = e, this;
|
|
3470
|
-
}
|
|
3471
|
-
setUnprotectedHeader(e) {
|
|
3472
|
-
if (this._unprotectedHeader)
|
|
3473
|
-
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
3474
|
-
return this._unprotectedHeader = e, this;
|
|
3475
|
-
}
|
|
3476
|
-
async sign(e, r) {
|
|
3477
|
-
if (!this._protectedHeader && !this._unprotectedHeader)
|
|
3478
|
-
throw new P("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
3479
|
-
if (!me(this._protectedHeader, this._unprotectedHeader))
|
|
3480
|
-
throw new P("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
3481
|
-
const n = {
|
|
3482
|
-
...this._protectedHeader,
|
|
3483
|
-
...this._unprotectedHeader
|
|
3484
|
-
}, a = ye(P, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, this._protectedHeader, n);
|
|
3485
|
-
let s = !0;
|
|
3486
|
-
if (a.has("b64") && (s = this._protectedHeader.b64, typeof s != "boolean"))
|
|
3487
|
-
throw new P('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
3488
|
-
const { alg: i } = n;
|
|
3489
|
-
if (typeof i != "string" || !i)
|
|
3490
|
-
throw new P('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
3491
|
-
Me(i, e, "sign");
|
|
3492
|
-
let o = this._payload;
|
|
3493
|
-
s && (o = K.encode(O(o)));
|
|
3494
|
-
let c;
|
|
3495
|
-
this._protectedHeader ? c = K.encode(O(JSON.stringify(this._protectedHeader))) : c = K.encode("");
|
|
3496
|
-
const u = Q(c, K.encode("."), o), l = await ma(i, e, u), f = {
|
|
3497
|
-
signature: O(l),
|
|
3498
|
-
payload: ""
|
|
3499
|
-
};
|
|
3500
|
-
return s && (f.payload = X.decode(o)), this._unprotectedHeader && (f.header = this._unprotectedHeader), this._protectedHeader && (f.protected = X.decode(c)), f;
|
|
3501
|
-
}
|
|
3502
|
-
}
|
|
3503
|
-
class Dr {
|
|
3504
|
-
constructor(e) {
|
|
3505
|
-
this._flattened = new At(e);
|
|
3506
|
-
}
|
|
3507
|
-
setProtectedHeader(e) {
|
|
3508
|
-
return this._flattened.setProtectedHeader(e), this;
|
|
3509
|
-
}
|
|
3510
|
-
async sign(e, r) {
|
|
3511
|
-
const n = await this._flattened.sign(e, r);
|
|
3512
|
-
if (n.payload === void 0)
|
|
3513
|
-
throw new TypeError("use the flattened module for creating JWS with b64: false");
|
|
3514
|
-
return `${n.protected}.${n.payload}.${n.signature}`;
|
|
3515
|
-
}
|
|
3516
|
-
}
|
|
3517
|
-
class ya {
|
|
3518
|
-
constructor(e, r, n) {
|
|
3519
|
-
this.parent = e, this.key = r, this.options = n;
|
|
3520
|
-
}
|
|
3521
|
-
setProtectedHeader(e) {
|
|
3522
|
-
if (this.protectedHeader)
|
|
3523
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
3524
|
-
return this.protectedHeader = e, this;
|
|
3525
|
-
}
|
|
3526
|
-
setUnprotectedHeader(e) {
|
|
3527
|
-
if (this.unprotectedHeader)
|
|
3528
|
-
throw new TypeError("setUnprotectedHeader can only be called once");
|
|
3529
|
-
return this.unprotectedHeader = e, this;
|
|
3530
|
-
}
|
|
3531
|
-
addSignature(...e) {
|
|
3532
|
-
return this.parent.addSignature(...e);
|
|
3533
|
-
}
|
|
3534
|
-
sign(...e) {
|
|
3535
|
-
return this.parent.sign(...e);
|
|
3536
|
-
}
|
|
3537
|
-
done() {
|
|
3538
|
-
return this.parent;
|
|
3539
|
-
}
|
|
3540
|
-
}
|
|
3541
|
-
class wa {
|
|
3542
|
-
constructor(e) {
|
|
3543
|
-
this._signatures = [], this._payload = e;
|
|
3544
|
-
}
|
|
3545
|
-
addSignature(e, r) {
|
|
3546
|
-
const n = new ya(this, e, r);
|
|
3547
|
-
return this._signatures.push(n), n;
|
|
3548
|
-
}
|
|
3549
|
-
async sign() {
|
|
3550
|
-
if (!this._signatures.length)
|
|
3551
|
-
throw new P("at least one signature must be added");
|
|
3552
|
-
const e = {
|
|
3553
|
-
signatures: [],
|
|
3554
|
-
payload: ""
|
|
3555
|
-
};
|
|
3556
|
-
for (let r = 0; r < this._signatures.length; r++) {
|
|
3557
|
-
const n = this._signatures[r], a = new At(this._payload);
|
|
3558
|
-
a.setProtectedHeader(n.protectedHeader), a.setUnprotectedHeader(n.unprotectedHeader);
|
|
3559
|
-
const { payload: s, ...i } = await a.sign(n.key, n.options);
|
|
3560
|
-
if (r === 0)
|
|
3561
|
-
e.payload = s;
|
|
3562
|
-
else if (e.payload !== s)
|
|
3563
|
-
throw new P("inconsistent use of JWS Unencoded Payload (RFC7797)");
|
|
3564
|
-
e.signatures.push(i);
|
|
3565
|
-
}
|
|
3566
|
-
return e;
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
class xt {
|
|
3570
|
-
constructor(e) {
|
|
3571
|
-
if (!I(e))
|
|
3572
|
-
throw new TypeError("JWT Claims Set MUST be an object");
|
|
3573
|
-
this._payload = e;
|
|
3574
|
-
}
|
|
3575
|
-
setIssuer(e) {
|
|
3576
|
-
return this._payload = { ...this._payload, iss: e }, this;
|
|
3577
|
-
}
|
|
3578
|
-
setSubject(e) {
|
|
3579
|
-
return this._payload = { ...this._payload, sub: e }, this;
|
|
3580
|
-
}
|
|
3581
|
-
setAudience(e) {
|
|
3582
|
-
return this._payload = { ...this._payload, aud: e }, this;
|
|
3583
|
-
}
|
|
3584
|
-
setJti(e) {
|
|
3585
|
-
return this._payload = { ...this._payload, jti: e }, this;
|
|
3586
|
-
}
|
|
3587
|
-
setNotBefore(e) {
|
|
3588
|
-
return typeof e == "number" ? this._payload = { ...this._payload, nbf: e } : this._payload = { ...this._payload, nbf: Ae(/* @__PURE__ */ new Date()) + We(e) }, this;
|
|
3589
|
-
}
|
|
3590
|
-
setExpirationTime(e) {
|
|
3591
|
-
return typeof e == "number" ? this._payload = { ...this._payload, exp: e } : this._payload = { ...this._payload, exp: Ae(/* @__PURE__ */ new Date()) + We(e) }, this;
|
|
3592
|
-
}
|
|
3593
|
-
setIssuedAt(e) {
|
|
3594
|
-
return typeof e > "u" ? this._payload = { ...this._payload, iat: Ae(/* @__PURE__ */ new Date()) } : this._payload = { ...this._payload, iat: e }, this;
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
class Sa extends xt {
|
|
3598
|
-
setProtectedHeader(e) {
|
|
3599
|
-
return this._protectedHeader = e, this;
|
|
3600
|
-
}
|
|
3601
|
-
async sign(e, r) {
|
|
3602
|
-
var n;
|
|
3603
|
-
const a = new Dr(K.encode(JSON.stringify(this._payload)));
|
|
3604
|
-
if (a.setProtectedHeader(this._protectedHeader), Array.isArray((n = this._protectedHeader) === null || n === void 0 ? void 0 : n.crit) && this._protectedHeader.crit.includes("b64") && this._protectedHeader.b64 === !1)
|
|
3605
|
-
throw new B("JWTs MUST NOT use unencoded payload");
|
|
3606
|
-
return a.sign(e, r);
|
|
3607
|
-
}
|
|
3608
|
-
}
|
|
3609
|
-
class ba extends xt {
|
|
3610
|
-
setProtectedHeader(e) {
|
|
3611
|
-
if (this._protectedHeader)
|
|
3612
|
-
throw new TypeError("setProtectedHeader can only be called once");
|
|
3613
|
-
return this._protectedHeader = e, this;
|
|
3614
|
-
}
|
|
3615
|
-
setKeyManagementParameters(e) {
|
|
3616
|
-
if (this._keyManagementParameters)
|
|
3617
|
-
throw new TypeError("setKeyManagementParameters can only be called once");
|
|
3618
|
-
return this._keyManagementParameters = e, this;
|
|
3619
|
-
}
|
|
3620
|
-
setContentEncryptionKey(e) {
|
|
3621
|
-
if (this._cek)
|
|
3622
|
-
throw new TypeError("setContentEncryptionKey can only be called once");
|
|
3623
|
-
return this._cek = e, this;
|
|
3624
|
-
}
|
|
3625
|
-
setInitializationVector(e) {
|
|
3626
|
-
if (this._iv)
|
|
3627
|
-
throw new TypeError("setInitializationVector can only be called once");
|
|
3628
|
-
return this._iv = e, this;
|
|
3629
|
-
}
|
|
3630
|
-
replicateIssuerAsHeader() {
|
|
3631
|
-
return this._replicateIssuerAsHeader = !0, this;
|
|
3632
|
-
}
|
|
3633
|
-
replicateSubjectAsHeader() {
|
|
3634
|
-
return this._replicateSubjectAsHeader = !0, this;
|
|
3635
|
-
}
|
|
3636
|
-
replicateAudienceAsHeader() {
|
|
3637
|
-
return this._replicateAudienceAsHeader = !0, this;
|
|
3638
|
-
}
|
|
3639
|
-
async encrypt(e, r) {
|
|
3640
|
-
const n = new Lr(K.encode(JSON.stringify(this._payload)));
|
|
3641
|
-
return this._replicateIssuerAsHeader && (this._protectedHeader = { ...this._protectedHeader, iss: this._payload.iss }), this._replicateSubjectAsHeader && (this._protectedHeader = { ...this._protectedHeader, sub: this._payload.sub }), this._replicateAudienceAsHeader && (this._protectedHeader = { ...this._protectedHeader, aud: this._payload.aud }), n.setProtectedHeader(this._protectedHeader), this._iv && n.setInitializationVector(this._iv), this._cek && n.setContentEncryptionKey(this._cek), this._keyManagementParameters && n.setKeyManagementParameters(this._keyManagementParameters), n.encrypt(e, r);
|
|
3642
|
-
}
|
|
3643
|
-
}
|
|
3644
|
-
const ee = (t, e) => {
|
|
3645
|
-
if (typeof t != "string" || !t)
|
|
3646
|
-
throw new ir(`${e} missing or invalid`);
|
|
3647
|
-
};
|
|
3648
|
-
async function Jr(t, e) {
|
|
3649
|
-
if (!I(t))
|
|
3650
|
-
throw new TypeError("JWK must be an object");
|
|
3651
|
-
if (e ?? (e = "sha256"), e !== "sha256" && e !== "sha384" && e !== "sha512")
|
|
3652
|
-
throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');
|
|
3653
|
-
let r;
|
|
3654
|
-
switch (t.kty) {
|
|
3655
|
-
case "EC":
|
|
3656
|
-
ee(t.crv, '"crv" (Curve) Parameter'), ee(t.x, '"x" (X Coordinate) Parameter'), ee(t.y, '"y" (Y Coordinate) Parameter'), r = { crv: t.crv, kty: t.kty, x: t.x, y: t.y };
|
|
3657
|
-
break;
|
|
3658
|
-
case "OKP":
|
|
3659
|
-
ee(t.crv, '"crv" (Subtype of Key Pair) Parameter'), ee(t.x, '"x" (Public Key) Parameter'), r = { crv: t.crv, kty: t.kty, x: t.x };
|
|
3660
|
-
break;
|
|
3661
|
-
case "RSA":
|
|
3662
|
-
ee(t.e, '"e" (Exponent) Parameter'), ee(t.n, '"n" (Modulus) Parameter'), r = { e: t.e, kty: t.kty, n: t.n };
|
|
3663
|
-
break;
|
|
3664
|
-
case "oct":
|
|
3665
|
-
ee(t.k, '"k" (Key Value) Parameter'), r = { k: t.k, kty: t.kty };
|
|
3666
|
-
break;
|
|
3667
|
-
default:
|
|
3668
|
-
throw new x('"kty" (Key Type) Parameter missing or unsupported');
|
|
3669
|
-
}
|
|
3670
|
-
const n = K.encode(JSON.stringify(r));
|
|
3671
|
-
return O(await nr(e, n));
|
|
3672
|
-
}
|
|
3673
|
-
async function va(t, e) {
|
|
3674
|
-
e ?? (e = "sha256");
|
|
3675
|
-
const r = await Jr(t, e);
|
|
3676
|
-
return `urn:ietf:params:oauth:jwk-thumbprint:sha-${e.slice(-3)}:${r}`;
|
|
3677
|
-
}
|
|
3678
|
-
async function Ea(t, e) {
|
|
3679
|
-
const r = {
|
|
3680
|
-
...t,
|
|
3681
|
-
...e == null ? void 0 : e.header
|
|
3682
|
-
};
|
|
3683
|
-
if (!I(r.jwk))
|
|
3684
|
-
throw new P('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
|
|
3685
|
-
const n = await $e({ ...r.jwk, ext: !0 }, r.alg, !0);
|
|
3686
|
-
if (n instanceof Uint8Array || n.type !== "public")
|
|
3687
|
-
throw new P('"jwk" (JSON Web Key) Header Parameter must be a public key');
|
|
3688
|
-
return n;
|
|
3689
|
-
}
|
|
3690
|
-
function Aa(t) {
|
|
3691
|
-
switch (typeof t == "string" && t.slice(0, 2)) {
|
|
3692
|
-
case "RS":
|
|
3693
|
-
case "PS":
|
|
3694
|
-
return "RSA";
|
|
3695
|
-
case "ES":
|
|
3696
|
-
return "EC";
|
|
3697
|
-
case "Ed":
|
|
3698
|
-
return "OKP";
|
|
3699
|
-
default:
|
|
3700
|
-
throw new x('Unsupported "alg" value for a JSON Web Key Set');
|
|
3701
|
-
}
|
|
3702
|
-
}
|
|
3703
|
-
function Nr(t) {
|
|
3704
|
-
return t && typeof t == "object" && Array.isArray(t.keys) && t.keys.every(xa);
|
|
3705
|
-
}
|
|
3706
|
-
function xa(t) {
|
|
3707
|
-
return I(t);
|
|
3708
|
-
}
|
|
3709
|
-
function Ca(t) {
|
|
3710
|
-
return typeof structuredClone == "function" ? structuredClone(t) : JSON.parse(JSON.stringify(t));
|
|
3711
|
-
}
|
|
3712
|
-
class $r {
|
|
3713
|
-
constructor(e) {
|
|
3714
|
-
if (this._cached = /* @__PURE__ */ new WeakMap(), !Nr(e))
|
|
3715
|
-
throw new Le("JSON Web Key Set malformed");
|
|
3716
|
-
this._jwks = Ca(e);
|
|
3717
|
-
}
|
|
3718
|
-
async getKey(e, r) {
|
|
3719
|
-
const { alg: n, kid: a } = { ...e, ...r == null ? void 0 : r.header }, s = Aa(n), i = this._jwks.keys.filter((u) => {
|
|
3720
|
-
let l = s === u.kty;
|
|
3721
|
-
if (l && typeof a == "string" && (l = a === u.kid), l && typeof u.alg == "string" && (l = n === u.alg), l && typeof u.use == "string" && (l = u.use === "sig"), l && Array.isArray(u.key_ops) && (l = u.key_ops.includes("verify")), l && n === "EdDSA" && (l = u.crv === "Ed25519" || u.crv === "Ed448"), l)
|
|
3722
|
-
switch (n) {
|
|
3723
|
-
case "ES256":
|
|
3724
|
-
l = u.crv === "P-256";
|
|
3725
|
-
break;
|
|
3726
|
-
case "ES256K":
|
|
3727
|
-
l = u.crv === "secp256k1";
|
|
3728
|
-
break;
|
|
3729
|
-
case "ES384":
|
|
3730
|
-
l = u.crv === "P-384";
|
|
3731
|
-
break;
|
|
3732
|
-
case "ES512":
|
|
3733
|
-
l = u.crv === "P-521";
|
|
3734
|
-
break;
|
|
3735
|
-
}
|
|
3736
|
-
return l;
|
|
3737
|
-
}), { 0: o, length: c } = i;
|
|
3738
|
-
if (c === 0)
|
|
3739
|
-
throw new mt();
|
|
3740
|
-
if (c !== 1) {
|
|
3741
|
-
const u = new or(), { _cached: l } = this;
|
|
3742
|
-
throw u[Symbol.asyncIterator] = async function* () {
|
|
3743
|
-
for (const f of i)
|
|
3744
|
-
try {
|
|
3745
|
-
yield await kt(l, f, n);
|
|
3746
|
-
} catch {
|
|
3747
|
-
continue;
|
|
3748
|
-
}
|
|
3749
|
-
}, u;
|
|
3750
|
-
}
|
|
3751
|
-
return kt(this._cached, o, n);
|
|
3752
|
-
}
|
|
3753
|
-
}
|
|
3754
|
-
async function kt(t, e, r) {
|
|
3755
|
-
const n = t.get(e) || t.set(e, {}).get(e);
|
|
3756
|
-
if (n[r] === void 0) {
|
|
3757
|
-
const a = await $e({ ...e, ext: !0 }, r);
|
|
3758
|
-
if (a instanceof Uint8Array || a.type !== "public")
|
|
3759
|
-
throw new Le("JSON Web Key Set members must be public keys");
|
|
3760
|
-
n[r] = a;
|
|
3761
|
-
}
|
|
3762
|
-
return n[r];
|
|
3763
|
-
}
|
|
3764
|
-
function _a(t) {
|
|
3765
|
-
const e = new $r(t);
|
|
3766
|
-
return async function(r, n) {
|
|
3767
|
-
return e.getKey(r, n);
|
|
3768
|
-
};
|
|
3769
|
-
}
|
|
3770
|
-
const Pa = async (t, e, r) => {
|
|
3771
|
-
let n, a, s = !1;
|
|
3772
|
-
typeof AbortController == "function" && (n = new AbortController(), a = setTimeout(() => {
|
|
3773
|
-
s = !0, n.abort();
|
|
3774
|
-
}, e));
|
|
3775
|
-
const i = await fetch(t.href, {
|
|
3776
|
-
signal: n ? n.signal : void 0,
|
|
3777
|
-
redirect: "manual",
|
|
3778
|
-
headers: r.headers
|
|
3779
|
-
}).catch((o) => {
|
|
3780
|
-
throw s ? new cr() : o;
|
|
3781
|
-
});
|
|
3782
|
-
if (a !== void 0 && clearTimeout(a), i.status !== 200)
|
|
3783
|
-
throw new L("Expected 200 OK from the JSON Web Key Set HTTP response");
|
|
3784
|
-
try {
|
|
3785
|
-
return await i.json();
|
|
3786
|
-
} catch {
|
|
3787
|
-
throw new L("Failed to parse the JSON Web Key Set HTTP response as JSON");
|
|
3788
|
-
}
|
|
3789
|
-
};
|
|
3790
|
-
function Ha() {
|
|
3791
|
-
return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
|
|
3792
|
-
}
|
|
3793
|
-
class Ka extends $r {
|
|
3794
|
-
constructor(e, r) {
|
|
3795
|
-
if (super({ keys: [] }), this._jwks = void 0, !(e instanceof URL))
|
|
3796
|
-
throw new TypeError("url must be an instance of URL");
|
|
3797
|
-
this._url = new URL(e.href), this._options = { agent: r == null ? void 0 : r.agent, headers: r == null ? void 0 : r.headers }, this._timeoutDuration = typeof (r == null ? void 0 : r.timeoutDuration) == "number" ? r == null ? void 0 : r.timeoutDuration : 5e3, this._cooldownDuration = typeof (r == null ? void 0 : r.cooldownDuration) == "number" ? r == null ? void 0 : r.cooldownDuration : 3e4, this._cacheMaxAge = typeof (r == null ? void 0 : r.cacheMaxAge) == "number" ? r == null ? void 0 : r.cacheMaxAge : 6e5;
|
|
3798
|
-
}
|
|
3799
|
-
coolingDown() {
|
|
3800
|
-
return typeof this._jwksTimestamp == "number" ? Date.now() < this._jwksTimestamp + this._cooldownDuration : !1;
|
|
3801
|
-
}
|
|
3802
|
-
fresh() {
|
|
3803
|
-
return typeof this._jwksTimestamp == "number" ? Date.now() < this._jwksTimestamp + this._cacheMaxAge : !1;
|
|
3804
|
-
}
|
|
3805
|
-
async getKey(e, r) {
|
|
3806
|
-
(!this._jwks || !this.fresh()) && await this.reload();
|
|
3807
|
-
try {
|
|
3808
|
-
return await super.getKey(e, r);
|
|
3809
|
-
} catch (n) {
|
|
3810
|
-
if (n instanceof mt && this.coolingDown() === !1)
|
|
3811
|
-
return await this.reload(), super.getKey(e, r);
|
|
3812
|
-
throw n;
|
|
3813
|
-
}
|
|
3814
|
-
}
|
|
3815
|
-
async reload() {
|
|
3816
|
-
this._pendingFetch && Ha() && (this._pendingFetch = void 0), this._pendingFetch || (this._pendingFetch = Pa(this._url, this._timeoutDuration, this._options).then((e) => {
|
|
3817
|
-
if (!Nr(e))
|
|
3818
|
-
throw new Le("JSON Web Key Set malformed");
|
|
3819
|
-
this._jwks = { keys: e.keys }, this._jwksTimestamp = Date.now(), this._pendingFetch = void 0;
|
|
3820
|
-
}).catch((e) => {
|
|
3821
|
-
throw this._pendingFetch = void 0, e;
|
|
3822
|
-
})), await this._pendingFetch;
|
|
3823
|
-
}
|
|
3824
|
-
}
|
|
3825
|
-
function Ra(t, e) {
|
|
3826
|
-
const r = new Ka(t, e);
|
|
3827
|
-
return async function(n, a) {
|
|
3828
|
-
return r.getKey(n, a);
|
|
3829
|
-
};
|
|
3830
|
-
}
|
|
3831
|
-
class Oa extends xt {
|
|
3832
|
-
encode() {
|
|
3833
|
-
const e = O(JSON.stringify({ alg: "none" })), r = O(JSON.stringify(this._payload));
|
|
3834
|
-
return `${e}.${r}.`;
|
|
3835
|
-
}
|
|
3836
|
-
static decode(e, r) {
|
|
3837
|
-
if (typeof e != "string")
|
|
3838
|
-
throw new B("Unsecured JWT must be a string");
|
|
3839
|
-
const { 0: n, 1: a, 2: s, length: i } = e.split(".");
|
|
3840
|
-
if (i !== 3 || s !== "")
|
|
3841
|
-
throw new B("Invalid Unsecured JWT");
|
|
3842
|
-
let o;
|
|
3843
|
-
try {
|
|
3844
|
-
if (o = JSON.parse(X.decode(T(n))), o.alg !== "none")
|
|
3845
|
-
throw new Error();
|
|
3846
|
-
} catch {
|
|
3847
|
-
throw new B("Invalid Unsecured JWT");
|
|
3848
|
-
}
|
|
3849
|
-
return { payload: Et(o, T(a), r), header: o };
|
|
3850
|
-
}
|
|
3851
|
-
}
|
|
3852
|
-
const Ta = O, Ct = T, Ia = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3853
|
-
__proto__: null,
|
|
3854
|
-
decode: Ct,
|
|
3855
|
-
encode: Ta
|
|
3856
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
3857
|
-
function Wa(t) {
|
|
3858
|
-
let e;
|
|
3859
|
-
if (typeof t == "string") {
|
|
3860
|
-
const r = t.split(".");
|
|
3861
|
-
(r.length === 3 || r.length === 5) && ([e] = r);
|
|
3862
|
-
} else if (typeof t == "object" && t)
|
|
3863
|
-
if ("protected" in t)
|
|
3864
|
-
e = t.protected;
|
|
3865
|
-
else
|
|
3866
|
-
throw new TypeError("Token does not contain a Protected Header");
|
|
3867
|
-
try {
|
|
3868
|
-
if (typeof e != "string" || !e)
|
|
3869
|
-
throw new Error();
|
|
3870
|
-
const r = JSON.parse(X.decode(Ct(e)));
|
|
3871
|
-
if (!I(r))
|
|
3872
|
-
throw new Error();
|
|
3873
|
-
return r;
|
|
3874
|
-
} catch {
|
|
3875
|
-
throw new TypeError("Invalid Token or Protected Header formatting");
|
|
3876
|
-
}
|
|
3877
|
-
}
|
|
3878
|
-
function Ua(t) {
|
|
3879
|
-
if (typeof t != "string")
|
|
3880
|
-
throw new B("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
3881
|
-
const { 1: e, length: r } = t.split(".");
|
|
3882
|
-
if (r === 5)
|
|
3883
|
-
throw new B("Only JWTs using Compact JWS serialization can be decoded");
|
|
3884
|
-
if (r !== 3)
|
|
3885
|
-
throw new B("Invalid JWT");
|
|
3886
|
-
if (!e)
|
|
3887
|
-
throw new B("JWTs must contain a payload");
|
|
3888
|
-
let n;
|
|
3889
|
-
try {
|
|
3890
|
-
n = Ct(e);
|
|
3891
|
-
} catch {
|
|
3892
|
-
throw new B("Failed to base64url decode the payload");
|
|
3893
|
-
}
|
|
3894
|
-
let a;
|
|
3895
|
-
try {
|
|
3896
|
-
a = JSON.parse(X.decode(n));
|
|
3897
|
-
} catch {
|
|
3898
|
-
throw new B("Failed to parse the decoded payload as JSON");
|
|
3899
|
-
}
|
|
3900
|
-
if (!I(a))
|
|
3901
|
-
throw new B("Invalid JWT Claims Set");
|
|
3902
|
-
return a;
|
|
3903
|
-
}
|
|
3904
|
-
async function La(t, e) {
|
|
3905
|
-
var r;
|
|
3906
|
-
let n, a, s;
|
|
3907
|
-
switch (t) {
|
|
3908
|
-
case "HS256":
|
|
3909
|
-
case "HS384":
|
|
3910
|
-
case "HS512":
|
|
3911
|
-
n = parseInt(t.slice(-3), 10), a = { name: "HMAC", hash: `SHA-${n}`, length: n }, s = ["sign", "verify"];
|
|
3912
|
-
break;
|
|
3913
|
-
case "A128CBC-HS256":
|
|
3914
|
-
case "A192CBC-HS384":
|
|
3915
|
-
case "A256CBC-HS512":
|
|
3916
|
-
return n = parseInt(t.slice(-3), 10), De(new Uint8Array(n >> 3));
|
|
3917
|
-
case "A128KW":
|
|
3918
|
-
case "A192KW":
|
|
3919
|
-
case "A256KW":
|
|
3920
|
-
n = parseInt(t.slice(1, 4), 10), a = { name: "AES-KW", length: n }, s = ["wrapKey", "unwrapKey"];
|
|
3921
|
-
break;
|
|
3922
|
-
case "A128GCMKW":
|
|
3923
|
-
case "A192GCMKW":
|
|
3924
|
-
case "A256GCMKW":
|
|
3925
|
-
case "A128GCM":
|
|
3926
|
-
case "A192GCM":
|
|
3927
|
-
case "A256GCM":
|
|
3928
|
-
n = parseInt(t.slice(1, 4), 10), a = { name: "AES-GCM", length: n }, s = ["encrypt", "decrypt"];
|
|
3929
|
-
break;
|
|
3930
|
-
default:
|
|
3931
|
-
throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
3932
|
-
}
|
|
3933
|
-
return b.subtle.generateKey(a, (r = e == null ? void 0 : e.extractable) !== null && r !== void 0 ? r : !1, s);
|
|
3934
|
-
}
|
|
3935
|
-
function qe(t) {
|
|
3936
|
-
var e;
|
|
3937
|
-
const r = (e = t == null ? void 0 : t.modulusLength) !== null && e !== void 0 ? e : 2048;
|
|
3938
|
-
if (typeof r != "number" || r < 2048)
|
|
3939
|
-
throw new x("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");
|
|
3940
|
-
return r;
|
|
3941
|
-
}
|
|
3942
|
-
async function Da(t, e) {
|
|
3943
|
-
var r, n, a;
|
|
3944
|
-
let s, i;
|
|
3945
|
-
switch (t) {
|
|
3946
|
-
case "PS256":
|
|
3947
|
-
case "PS384":
|
|
3948
|
-
case "PS512":
|
|
3949
|
-
s = {
|
|
3950
|
-
name: "RSA-PSS",
|
|
3951
|
-
hash: `SHA-${t.slice(-3)}`,
|
|
3952
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
|
3953
|
-
modulusLength: qe(e)
|
|
3954
|
-
}, i = ["sign", "verify"];
|
|
3955
|
-
break;
|
|
3956
|
-
case "RS256":
|
|
3957
|
-
case "RS384":
|
|
3958
|
-
case "RS512":
|
|
3959
|
-
s = {
|
|
3960
|
-
name: "RSASSA-PKCS1-v1_5",
|
|
3961
|
-
hash: `SHA-${t.slice(-3)}`,
|
|
3962
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
|
3963
|
-
modulusLength: qe(e)
|
|
3964
|
-
}, i = ["sign", "verify"];
|
|
3965
|
-
break;
|
|
3966
|
-
case "RSA-OAEP":
|
|
3967
|
-
case "RSA-OAEP-256":
|
|
3968
|
-
case "RSA-OAEP-384":
|
|
3969
|
-
case "RSA-OAEP-512":
|
|
3970
|
-
s = {
|
|
3971
|
-
name: "RSA-OAEP",
|
|
3972
|
-
hash: `SHA-${parseInt(t.slice(-3), 10) || 1}`,
|
|
3973
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
|
3974
|
-
modulusLength: qe(e)
|
|
3975
|
-
}, i = ["decrypt", "unwrapKey", "encrypt", "wrapKey"];
|
|
3976
|
-
break;
|
|
3977
|
-
case "ES256":
|
|
3978
|
-
s = { name: "ECDSA", namedCurve: "P-256" }, i = ["sign", "verify"];
|
|
3979
|
-
break;
|
|
3980
|
-
case "ES384":
|
|
3981
|
-
s = { name: "ECDSA", namedCurve: "P-384" }, i = ["sign", "verify"];
|
|
3982
|
-
break;
|
|
3983
|
-
case "ES512":
|
|
3984
|
-
s = { name: "ECDSA", namedCurve: "P-521" }, i = ["sign", "verify"];
|
|
3985
|
-
break;
|
|
3986
|
-
case "EdDSA":
|
|
3987
|
-
i = ["sign", "verify"];
|
|
3988
|
-
const o = (r = e == null ? void 0 : e.crv) !== null && r !== void 0 ? r : "Ed25519";
|
|
3989
|
-
switch (o) {
|
|
3990
|
-
case "Ed25519":
|
|
3991
|
-
case "Ed448":
|
|
3992
|
-
s = { name: o };
|
|
3993
|
-
break;
|
|
3994
|
-
default:
|
|
3995
|
-
throw new x("Invalid or unsupported crv option provided");
|
|
3996
|
-
}
|
|
3997
|
-
break;
|
|
3998
|
-
case "ECDH-ES":
|
|
3999
|
-
case "ECDH-ES+A128KW":
|
|
4000
|
-
case "ECDH-ES+A192KW":
|
|
4001
|
-
case "ECDH-ES+A256KW": {
|
|
4002
|
-
i = ["deriveKey", "deriveBits"];
|
|
4003
|
-
const c = (n = e == null ? void 0 : e.crv) !== null && n !== void 0 ? n : "P-256";
|
|
4004
|
-
switch (c) {
|
|
4005
|
-
case "P-256":
|
|
4006
|
-
case "P-384":
|
|
4007
|
-
case "P-521": {
|
|
4008
|
-
s = { name: "ECDH", namedCurve: c };
|
|
4009
|
-
break;
|
|
4010
|
-
}
|
|
4011
|
-
case "X25519":
|
|
4012
|
-
case "X448":
|
|
4013
|
-
s = { name: c };
|
|
4014
|
-
break;
|
|
4015
|
-
default:
|
|
4016
|
-
throw new x("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448");
|
|
4017
|
-
}
|
|
4018
|
-
break;
|
|
4019
|
-
}
|
|
4020
|
-
default:
|
|
4021
|
-
throw new x('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
4022
|
-
}
|
|
4023
|
-
return b.subtle.generateKey(s, (a = e == null ? void 0 : e.extractable) !== null && a !== void 0 ? a : !1, i);
|
|
4024
|
-
}
|
|
4025
|
-
async function Ja(t, e) {
|
|
4026
|
-
return Da(t, e);
|
|
4027
|
-
}
|
|
4028
|
-
async function Na(t, e) {
|
|
4029
|
-
return La(t, e);
|
|
4030
|
-
}
|
|
4031
|
-
const $a = "WebCryptoAPI", Ma = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4032
|
-
__proto__: null,
|
|
4033
|
-
CompactEncrypt: Lr,
|
|
4034
|
-
CompactSign: Dr,
|
|
4035
|
-
EmbeddedJWK: Ea,
|
|
4036
|
-
EncryptJWT: ba,
|
|
4037
|
-
FlattenedEncrypt: Ie,
|
|
4038
|
-
FlattenedSign: At,
|
|
4039
|
-
GeneralEncrypt: oa,
|
|
4040
|
-
GeneralSign: wa,
|
|
4041
|
-
SignJWT: Sa,
|
|
4042
|
-
UnsecuredJWT: Oa,
|
|
4043
|
-
base64url: Ia,
|
|
4044
|
-
calculateJwkThumbprint: Jr,
|
|
4045
|
-
calculateJwkThumbprintUri: va,
|
|
4046
|
-
compactDecrypt: Pr,
|
|
4047
|
-
compactVerify: Ir,
|
|
4048
|
-
createLocalJWKSet: _a,
|
|
4049
|
-
createRemoteJWKSet: Ra,
|
|
4050
|
-
cryptoRuntime: $a,
|
|
4051
|
-
decodeJwt: Ua,
|
|
4052
|
-
decodeProtectedHeader: Wa,
|
|
4053
|
-
errors: vn,
|
|
4054
|
-
exportJWK: Hr,
|
|
4055
|
-
exportPKCS8: sa,
|
|
4056
|
-
exportSPKI: aa,
|
|
4057
|
-
flattenedDecrypt: St,
|
|
4058
|
-
flattenedVerify: bt,
|
|
4059
|
-
generalDecrypt: ta,
|
|
4060
|
-
generalVerify: ua,
|
|
4061
|
-
generateKeyPair: Ja,
|
|
4062
|
-
generateSecret: Na,
|
|
4063
|
-
importJWK: $e,
|
|
4064
|
-
importPKCS8: zn,
|
|
4065
|
-
importSPKI: Bn,
|
|
4066
|
-
importX509: Gn,
|
|
4067
|
-
jwtDecrypt: ga,
|
|
4068
|
-
jwtVerify: pa
|
|
4069
|
-
}, Symbol.toStringTag, { value: "Module" })), ka = /* @__PURE__ */ ft(Ma), Fa = () => {
|
|
4070
|
-
if (typeof globalThis < "u")
|
|
4071
|
-
return globalThis;
|
|
4072
|
-
if (typeof self < "u")
|
|
4073
|
-
return self;
|
|
4074
|
-
if (typeof window < "u")
|
|
4075
|
-
return window;
|
|
4076
|
-
throw new Error("unable to locate global object");
|
|
4077
|
-
}, Va = async (t, e, r, n, a) => {
|
|
4078
|
-
const { crypto: { subtle: s } } = Fa();
|
|
4079
|
-
return new Uint8Array(await s.deriveBits({
|
|
4080
|
-
name: "HKDF",
|
|
4081
|
-
hash: `SHA-${t.substr(3)}`,
|
|
4082
|
-
salt: r,
|
|
4083
|
-
info: n
|
|
4084
|
-
}, await s.importKey("raw", e, "HKDF", !1, ["deriveBits"]), a << 3));
|
|
4085
|
-
};
|
|
4086
|
-
function Ba(t) {
|
|
4087
|
-
switch (t) {
|
|
4088
|
-
case "sha256":
|
|
4089
|
-
case "sha384":
|
|
4090
|
-
case "sha512":
|
|
4091
|
-
case "sha1":
|
|
4092
|
-
return t;
|
|
4093
|
-
default:
|
|
4094
|
-
throw new TypeError('unsupported "digest" value');
|
|
4095
|
-
}
|
|
4096
|
-
}
|
|
4097
|
-
function _t(t, e) {
|
|
4098
|
-
if (typeof t == "string")
|
|
4099
|
-
return new TextEncoder().encode(t);
|
|
4100
|
-
if (!(t instanceof Uint8Array))
|
|
4101
|
-
throw new TypeError(`"${e}"" must be an instance of Uint8Array or a string`);
|
|
4102
|
-
return t;
|
|
4103
|
-
}
|
|
4104
|
-
function Ga(t) {
|
|
4105
|
-
const e = _t(t, "ikm");
|
|
4106
|
-
if (!e.byteLength)
|
|
4107
|
-
throw new TypeError('"ikm" must be at least one byte in length');
|
|
4108
|
-
return e;
|
|
4109
|
-
}
|
|
4110
|
-
function za(t) {
|
|
4111
|
-
const e = _t(t, "info");
|
|
4112
|
-
if (e.byteLength > 1024)
|
|
4113
|
-
throw TypeError('"info" must not contain more than 1024 bytes');
|
|
4114
|
-
return e;
|
|
4115
|
-
}
|
|
4116
|
-
function qa(t, e) {
|
|
4117
|
-
if (typeof t != "number" || !Number.isInteger(t) || t < 1)
|
|
4118
|
-
throw new TypeError('"keylen" must be a positive integer');
|
|
4119
|
-
const r = parseInt(e.substr(3), 10) >> 3 || 20;
|
|
4120
|
-
if (t > 255 * r)
|
|
4121
|
-
throw new TypeError('"keylen" too large');
|
|
4122
|
-
return t;
|
|
4123
|
-
}
|
|
4124
|
-
async function Ft(t, e, r, n, a) {
|
|
4125
|
-
return Va(Ba(t), Ga(e), _t(r, "salt"), za(n), qa(a, t));
|
|
4126
|
-
}
|
|
4127
|
-
const Xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4128
|
-
__proto__: null,
|
|
4129
|
-
default: Ft,
|
|
4130
|
-
hkdf: Ft
|
|
4131
|
-
}, Symbol.toStringTag, { value: "Module" })), Ya = /* @__PURE__ */ ft(Xa);
|
|
4132
|
-
var ve, Za = new Uint8Array(16);
|
|
4133
|
-
function Mr() {
|
|
4134
|
-
if (!ve && (ve = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), !ve))
|
|
4135
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
4136
|
-
return ve(Za);
|
|
4137
|
-
}
|
|
4138
|
-
const Qa = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
4139
|
-
function ke(t) {
|
|
4140
|
-
return typeof t == "string" && Qa.test(t);
|
|
4141
|
-
}
|
|
4142
|
-
var W = [];
|
|
4143
|
-
for (var Xe = 0; Xe < 256; ++Xe)
|
|
4144
|
-
W.push((Xe + 256).toString(16).substr(1));
|
|
4145
|
-
function Fe(t) {
|
|
4146
|
-
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, r = (W[t[e + 0]] + W[t[e + 1]] + W[t[e + 2]] + W[t[e + 3]] + "-" + W[t[e + 4]] + W[t[e + 5]] + "-" + W[t[e + 6]] + W[t[e + 7]] + "-" + W[t[e + 8]] + W[t[e + 9]] + "-" + W[t[e + 10]] + W[t[e + 11]] + W[t[e + 12]] + W[t[e + 13]] + W[t[e + 14]] + W[t[e + 15]]).toLowerCase();
|
|
4147
|
-
if (!ke(r))
|
|
4148
|
-
throw TypeError("Stringified UUID is invalid");
|
|
4149
|
-
return r;
|
|
4150
|
-
}
|
|
4151
|
-
var Vt, Ye, Ze = 0, Qe = 0;
|
|
4152
|
-
function ja(t, e, r) {
|
|
4153
|
-
var n = e && r || 0, a = e || new Array(16);
|
|
4154
|
-
t = t || {};
|
|
4155
|
-
var s = t.node || Vt, i = t.clockseq !== void 0 ? t.clockseq : Ye;
|
|
4156
|
-
if (s == null || i == null) {
|
|
4157
|
-
var o = t.random || (t.rng || Mr)();
|
|
4158
|
-
s == null && (s = Vt = [o[0] | 1, o[1], o[2], o[3], o[4], o[5]]), i == null && (i = Ye = (o[6] << 8 | o[7]) & 16383);
|
|
4159
|
-
}
|
|
4160
|
-
var c = t.msecs !== void 0 ? t.msecs : Date.now(), u = t.nsecs !== void 0 ? t.nsecs : Qe + 1, l = c - Ze + (u - Qe) / 1e4;
|
|
4161
|
-
if (l < 0 && t.clockseq === void 0 && (i = i + 1 & 16383), (l < 0 || c > Ze) && t.nsecs === void 0 && (u = 0), u >= 1e4)
|
|
4162
|
-
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
|
4163
|
-
Ze = c, Qe = u, Ye = i, c += 122192928e5;
|
|
4164
|
-
var f = ((c & 268435455) * 1e4 + u) % 4294967296;
|
|
4165
|
-
a[n++] = f >>> 24 & 255, a[n++] = f >>> 16 & 255, a[n++] = f >>> 8 & 255, a[n++] = f & 255;
|
|
4166
|
-
var d = c / 4294967296 * 1e4 & 268435455;
|
|
4167
|
-
a[n++] = d >>> 8 & 255, a[n++] = d & 255, a[n++] = d >>> 24 & 15 | 16, a[n++] = d >>> 16 & 255, a[n++] = i >>> 8 | 128, a[n++] = i & 255;
|
|
4168
|
-
for (var p = 0; p < 6; ++p)
|
|
4169
|
-
a[n + p] = s[p];
|
|
4170
|
-
return e || Fe(a);
|
|
4171
|
-
}
|
|
4172
|
-
function kr(t) {
|
|
4173
|
-
if (!ke(t))
|
|
4174
|
-
throw TypeError("Invalid UUID");
|
|
4175
|
-
var e, r = new Uint8Array(16);
|
|
4176
|
-
return r[0] = (e = parseInt(t.slice(0, 8), 16)) >>> 24, r[1] = e >>> 16 & 255, r[2] = e >>> 8 & 255, r[3] = e & 255, r[4] = (e = parseInt(t.slice(9, 13), 16)) >>> 8, r[5] = e & 255, r[6] = (e = parseInt(t.slice(14, 18), 16)) >>> 8, r[7] = e & 255, r[8] = (e = parseInt(t.slice(19, 23), 16)) >>> 8, r[9] = e & 255, r[10] = (e = parseInt(t.slice(24, 36), 16)) / 1099511627776 & 255, r[11] = e / 4294967296 & 255, r[12] = e >>> 24 & 255, r[13] = e >>> 16 & 255, r[14] = e >>> 8 & 255, r[15] = e & 255, r;
|
|
4177
|
-
}
|
|
4178
|
-
function es(t) {
|
|
4179
|
-
t = unescape(encodeURIComponent(t));
|
|
4180
|
-
for (var e = [], r = 0; r < t.length; ++r)
|
|
4181
|
-
e.push(t.charCodeAt(r));
|
|
4182
|
-
return e;
|
|
4183
|
-
}
|
|
4184
|
-
var ts = "6ba7b810-9dad-11d1-80b4-00c04fd430c8", rs = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
4185
|
-
function Fr(t, e, r) {
|
|
4186
|
-
function n(a, s, i, o) {
|
|
4187
|
-
if (typeof a == "string" && (a = es(a)), typeof s == "string" && (s = kr(s)), s.length !== 16)
|
|
4188
|
-
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
|
4189
|
-
var c = new Uint8Array(16 + a.length);
|
|
4190
|
-
if (c.set(s), c.set(a, s.length), c = r(c), c[6] = c[6] & 15 | e, c[8] = c[8] & 63 | 128, i) {
|
|
4191
|
-
o = o || 0;
|
|
4192
|
-
for (var u = 0; u < 16; ++u)
|
|
4193
|
-
i[o + u] = c[u];
|
|
4194
|
-
return i;
|
|
4195
|
-
}
|
|
4196
|
-
return Fe(c);
|
|
4197
|
-
}
|
|
4198
|
-
try {
|
|
4199
|
-
n.name = t;
|
|
4200
|
-
} catch {
|
|
4201
|
-
}
|
|
4202
|
-
return n.DNS = ts, n.URL = rs, n;
|
|
4203
|
-
}
|
|
4204
|
-
function ns(t) {
|
|
4205
|
-
if (typeof t == "string") {
|
|
4206
|
-
var e = unescape(encodeURIComponent(t));
|
|
4207
|
-
t = new Uint8Array(e.length);
|
|
4208
|
-
for (var r = 0; r < e.length; ++r)
|
|
4209
|
-
t[r] = e.charCodeAt(r);
|
|
4210
|
-
}
|
|
4211
|
-
return as(ss(is(t), t.length * 8));
|
|
4212
|
-
}
|
|
4213
|
-
function as(t) {
|
|
4214
|
-
for (var e = [], r = t.length * 32, n = "0123456789abcdef", a = 0; a < r; a += 8) {
|
|
4215
|
-
var s = t[a >> 5] >>> a % 32 & 255, i = parseInt(n.charAt(s >>> 4 & 15) + n.charAt(s & 15), 16);
|
|
4216
|
-
e.push(i);
|
|
4217
|
-
}
|
|
4218
|
-
return e;
|
|
4219
|
-
}
|
|
4220
|
-
function Vr(t) {
|
|
4221
|
-
return (t + 64 >>> 9 << 4) + 14 + 1;
|
|
4222
|
-
}
|
|
4223
|
-
function ss(t, e) {
|
|
4224
|
-
t[e >> 5] |= 128 << e % 32, t[Vr(e) - 1] = e;
|
|
4225
|
-
for (var r = 1732584193, n = -271733879, a = -1732584194, s = 271733878, i = 0; i < t.length; i += 16) {
|
|
4226
|
-
var o = r, c = n, u = a, l = s;
|
|
4227
|
-
r = D(r, n, a, s, t[i], 7, -680876936), s = D(s, r, n, a, t[i + 1], 12, -389564586), a = D(a, s, r, n, t[i + 2], 17, 606105819), n = D(n, a, s, r, t[i + 3], 22, -1044525330), r = D(r, n, a, s, t[i + 4], 7, -176418897), s = D(s, r, n, a, t[i + 5], 12, 1200080426), a = D(a, s, r, n, t[i + 6], 17, -1473231341), n = D(n, a, s, r, t[i + 7], 22, -45705983), r = D(r, n, a, s, t[i + 8], 7, 1770035416), s = D(s, r, n, a, t[i + 9], 12, -1958414417), a = D(a, s, r, n, t[i + 10], 17, -42063), n = D(n, a, s, r, t[i + 11], 22, -1990404162), r = D(r, n, a, s, t[i + 12], 7, 1804603682), s = D(s, r, n, a, t[i + 13], 12, -40341101), a = D(a, s, r, n, t[i + 14], 17, -1502002290), n = D(n, a, s, r, t[i + 15], 22, 1236535329), r = J(r, n, a, s, t[i + 1], 5, -165796510), s = J(s, r, n, a, t[i + 6], 9, -1069501632), a = J(a, s, r, n, t[i + 11], 14, 643717713), n = J(n, a, s, r, t[i], 20, -373897302), r = J(r, n, a, s, t[i + 5], 5, -701558691), s = J(s, r, n, a, t[i + 10], 9, 38016083), a = J(a, s, r, n, t[i + 15], 14, -660478335), n = J(n, a, s, r, t[i + 4], 20, -405537848), r = J(r, n, a, s, t[i + 9], 5, 568446438), s = J(s, r, n, a, t[i + 14], 9, -1019803690), a = J(a, s, r, n, t[i + 3], 14, -187363961), n = J(n, a, s, r, t[i + 8], 20, 1163531501), r = J(r, n, a, s, t[i + 13], 5, -1444681467), s = J(s, r, n, a, t[i + 2], 9, -51403784), a = J(a, s, r, n, t[i + 7], 14, 1735328473), n = J(n, a, s, r, t[i + 12], 20, -1926607734), r = N(r, n, a, s, t[i + 5], 4, -378558), s = N(s, r, n, a, t[i + 8], 11, -2022574463), a = N(a, s, r, n, t[i + 11], 16, 1839030562), n = N(n, a, s, r, t[i + 14], 23, -35309556), r = N(r, n, a, s, t[i + 1], 4, -1530992060), s = N(s, r, n, a, t[i + 4], 11, 1272893353), a = N(a, s, r, n, t[i + 7], 16, -155497632), n = N(n, a, s, r, t[i + 10], 23, -1094730640), r = N(r, n, a, s, t[i + 13], 4, 681279174), s = N(s, r, n, a, t[i], 11, -358537222), a = N(a, s, r, n, t[i + 3], 16, -722521979), n = N(n, a, s, r, t[i + 6], 23, 76029189), r = N(r, n, a, s, t[i + 9], 4, -640364487), s = N(s, r, n, a, t[i + 12], 11, -421815835), a = N(a, s, r, n, t[i + 15], 16, 530742520), n = N(n, a, s, r, t[i + 2], 23, -995338651), r = $(r, n, a, s, t[i], 6, -198630844), s = $(s, r, n, a, t[i + 7], 10, 1126891415), a = $(a, s, r, n, t[i + 14], 15, -1416354905), n = $(n, a, s, r, t[i + 5], 21, -57434055), r = $(r, n, a, s, t[i + 12], 6, 1700485571), s = $(s, r, n, a, t[i + 3], 10, -1894986606), a = $(a, s, r, n, t[i + 10], 15, -1051523), n = $(n, a, s, r, t[i + 1], 21, -2054922799), r = $(r, n, a, s, t[i + 8], 6, 1873313359), s = $(s, r, n, a, t[i + 15], 10, -30611744), a = $(a, s, r, n, t[i + 6], 15, -1560198380), n = $(n, a, s, r, t[i + 13], 21, 1309151649), r = $(r, n, a, s, t[i + 4], 6, -145523070), s = $(s, r, n, a, t[i + 11], 10, -1120210379), a = $(a, s, r, n, t[i + 2], 15, 718787259), n = $(n, a, s, r, t[i + 9], 21, -343485551), r = ne(r, o), n = ne(n, c), a = ne(a, u), s = ne(s, l);
|
|
4228
|
-
}
|
|
4229
|
-
return [r, n, a, s];
|
|
4230
|
-
}
|
|
4231
|
-
function is(t) {
|
|
4232
|
-
if (t.length === 0)
|
|
4233
|
-
return [];
|
|
4234
|
-
for (var e = t.length * 8, r = new Uint32Array(Vr(e)), n = 0; n < e; n += 8)
|
|
4235
|
-
r[n >> 5] |= (t[n / 8] & 255) << n % 32;
|
|
4236
|
-
return r;
|
|
4237
|
-
}
|
|
4238
|
-
function ne(t, e) {
|
|
4239
|
-
var r = (t & 65535) + (e & 65535), n = (t >> 16) + (e >> 16) + (r >> 16);
|
|
4240
|
-
return n << 16 | r & 65535;
|
|
4241
|
-
}
|
|
4242
|
-
function os(t, e) {
|
|
4243
|
-
return t << e | t >>> 32 - e;
|
|
4244
|
-
}
|
|
4245
|
-
function Ve(t, e, r, n, a, s) {
|
|
4246
|
-
return ne(os(ne(ne(e, t), ne(n, s)), a), r);
|
|
4247
|
-
}
|
|
4248
|
-
function D(t, e, r, n, a, s, i) {
|
|
4249
|
-
return Ve(e & r | ~e & n, t, e, a, s, i);
|
|
4250
|
-
}
|
|
4251
|
-
function J(t, e, r, n, a, s, i) {
|
|
4252
|
-
return Ve(e & n | r & ~n, t, e, a, s, i);
|
|
4253
|
-
}
|
|
4254
|
-
function N(t, e, r, n, a, s, i) {
|
|
4255
|
-
return Ve(e ^ r ^ n, t, e, a, s, i);
|
|
4256
|
-
}
|
|
4257
|
-
function $(t, e, r, n, a, s, i) {
|
|
4258
|
-
return Ve(r ^ (e | ~n), t, e, a, s, i);
|
|
4259
|
-
}
|
|
4260
|
-
var cs = Fr("v3", 48, ns);
|
|
4261
|
-
const us = cs;
|
|
4262
|
-
function ls(t, e, r) {
|
|
4263
|
-
t = t || {};
|
|
4264
|
-
var n = t.random || (t.rng || Mr)();
|
|
4265
|
-
if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, e) {
|
|
4266
|
-
r = r || 0;
|
|
4267
|
-
for (var a = 0; a < 16; ++a)
|
|
4268
|
-
e[r + a] = n[a];
|
|
4269
|
-
return e;
|
|
4270
|
-
}
|
|
4271
|
-
return Fe(n);
|
|
4272
|
-
}
|
|
4273
|
-
function ds(t, e, r, n) {
|
|
4274
|
-
switch (t) {
|
|
4275
|
-
case 0:
|
|
4276
|
-
return e & r ^ ~e & n;
|
|
4277
|
-
case 1:
|
|
4278
|
-
return e ^ r ^ n;
|
|
4279
|
-
case 2:
|
|
4280
|
-
return e & r ^ e & n ^ r & n;
|
|
4281
|
-
case 3:
|
|
4282
|
-
return e ^ r ^ n;
|
|
4283
|
-
}
|
|
4284
|
-
}
|
|
4285
|
-
function je(t, e) {
|
|
4286
|
-
return t << e | t >>> 32 - e;
|
|
4287
|
-
}
|
|
4288
|
-
function fs(t) {
|
|
4289
|
-
var e = [1518500249, 1859775393, 2400959708, 3395469782], r = [1732584193, 4023233417, 2562383102, 271733878, 3285377520];
|
|
4290
|
-
if (typeof t == "string") {
|
|
4291
|
-
var n = unescape(encodeURIComponent(t));
|
|
4292
|
-
t = [];
|
|
4293
|
-
for (var a = 0; a < n.length; ++a)
|
|
4294
|
-
t.push(n.charCodeAt(a));
|
|
4295
|
-
} else
|
|
4296
|
-
Array.isArray(t) || (t = Array.prototype.slice.call(t));
|
|
4297
|
-
t.push(128);
|
|
4298
|
-
for (var s = t.length / 4 + 2, i = Math.ceil(s / 16), o = new Array(i), c = 0; c < i; ++c) {
|
|
4299
|
-
for (var u = new Uint32Array(16), l = 0; l < 16; ++l)
|
|
4300
|
-
u[l] = t[c * 64 + l * 4] << 24 | t[c * 64 + l * 4 + 1] << 16 | t[c * 64 + l * 4 + 2] << 8 | t[c * 64 + l * 4 + 3];
|
|
4301
|
-
o[c] = u;
|
|
4302
|
-
}
|
|
4303
|
-
o[i - 1][14] = (t.length - 1) * 8 / Math.pow(2, 32), o[i - 1][14] = Math.floor(o[i - 1][14]), o[i - 1][15] = (t.length - 1) * 8 & 4294967295;
|
|
4304
|
-
for (var f = 0; f < i; ++f) {
|
|
4305
|
-
for (var d = new Uint32Array(80), p = 0; p < 16; ++p)
|
|
4306
|
-
d[p] = o[f][p];
|
|
4307
|
-
for (var h = 16; h < 80; ++h)
|
|
4308
|
-
d[h] = je(d[h - 3] ^ d[h - 8] ^ d[h - 14] ^ d[h - 16], 1);
|
|
4309
|
-
for (var g = r[0], S = r[1], C = r[2], v = r[3], w = r[4], m = 0; m < 80; ++m) {
|
|
4310
|
-
var E = Math.floor(m / 20), _ = je(g, 5) + ds(E, S, C, v) + w + e[E] + d[m] >>> 0;
|
|
4311
|
-
w = v, v = C, C = je(S, 30) >>> 0, S = g, g = _;
|
|
4312
|
-
}
|
|
4313
|
-
r[0] = r[0] + g >>> 0, r[1] = r[1] + S >>> 0, r[2] = r[2] + C >>> 0, r[3] = r[3] + v >>> 0, r[4] = r[4] + w >>> 0;
|
|
4314
|
-
}
|
|
4315
|
-
return [r[0] >> 24 & 255, r[0] >> 16 & 255, r[0] >> 8 & 255, r[0] & 255, r[1] >> 24 & 255, r[1] >> 16 & 255, r[1] >> 8 & 255, r[1] & 255, r[2] >> 24 & 255, r[2] >> 16 & 255, r[2] >> 8 & 255, r[2] & 255, r[3] >> 24 & 255, r[3] >> 16 & 255, r[3] >> 8 & 255, r[3] & 255, r[4] >> 24 & 255, r[4] >> 16 & 255, r[4] >> 8 & 255, r[4] & 255];
|
|
4316
|
-
}
|
|
4317
|
-
var hs = Fr("v5", 80, fs);
|
|
4318
|
-
const ps = hs, gs = "00000000-0000-0000-0000-000000000000";
|
|
4319
|
-
function ms(t) {
|
|
4320
|
-
if (!ke(t))
|
|
4321
|
-
throw TypeError("Invalid UUID");
|
|
4322
|
-
return parseInt(t.substr(14, 1), 16);
|
|
4323
|
-
}
|
|
4324
|
-
const ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4325
|
-
__proto__: null,
|
|
4326
|
-
NIL: gs,
|
|
4327
|
-
parse: kr,
|
|
4328
|
-
stringify: Fe,
|
|
4329
|
-
v1: ja,
|
|
4330
|
-
v3: us,
|
|
4331
|
-
v4: ls,
|
|
4332
|
-
v5: ps,
|
|
4333
|
-
validate: ke,
|
|
4334
|
-
version: ms
|
|
4335
|
-
}, Symbol.toStringTag, { value: "Module" })), ws = /* @__PURE__ */ ft(ys);
|
|
4336
|
-
var ue = {}, et = { exports: {} }, tt = { exports: {} }, Bt;
|
|
4337
|
-
function Ss() {
|
|
4338
|
-
return Bt || (Bt = 1, function(t) {
|
|
4339
|
-
function e(r, n) {
|
|
4340
|
-
return n.get ? n.get.call(r) : n.value;
|
|
4341
|
-
}
|
|
4342
|
-
t.exports = e, t.exports.__esModule = !0, t.exports.default = t.exports;
|
|
4343
|
-
}(tt)), tt.exports;
|
|
4344
|
-
}
|
|
4345
|
-
var rt = { exports: {} }, Gt;
|
|
4346
|
-
function Br() {
|
|
4347
|
-
return Gt || (Gt = 1, function(t) {
|
|
4348
|
-
function e(r, n, a) {
|
|
4349
|
-
if (!n.has(r))
|
|
4350
|
-
throw new TypeError("attempted to " + a + " private field on non-instance");
|
|
4351
|
-
return n.get(r);
|
|
4352
|
-
}
|
|
4353
|
-
t.exports = e, t.exports.__esModule = !0, t.exports.default = t.exports;
|
|
4354
|
-
}(rt)), rt.exports;
|
|
4355
|
-
}
|
|
4356
|
-
var zt;
|
|
4357
|
-
function bs() {
|
|
4358
|
-
return zt || (zt = 1, function(t) {
|
|
4359
|
-
var e = Ss(), r = Br();
|
|
4360
|
-
function n(a, s) {
|
|
4361
|
-
var i = r(a, s, "get");
|
|
4362
|
-
return e(a, i);
|
|
4363
|
-
}
|
|
4364
|
-
t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
|
|
4365
|
-
}(et)), et.exports;
|
|
4366
|
-
}
|
|
4367
|
-
var nt = { exports: {} }, at = { exports: {} }, qt;
|
|
4368
|
-
function vs() {
|
|
4369
|
-
return qt || (qt = 1, function(t) {
|
|
4370
|
-
function e(r, n, a) {
|
|
4371
|
-
if (n.set)
|
|
4372
|
-
n.set.call(r, a);
|
|
4373
|
-
else {
|
|
4374
|
-
if (!n.writable)
|
|
4375
|
-
throw new TypeError("attempted to set read only private field");
|
|
4376
|
-
n.value = a;
|
|
4377
|
-
}
|
|
4378
|
-
}
|
|
4379
|
-
t.exports = e, t.exports.__esModule = !0, t.exports.default = t.exports;
|
|
4380
|
-
}(at)), at.exports;
|
|
4381
|
-
}
|
|
4382
|
-
var Xt;
|
|
4383
|
-
function Es() {
|
|
4384
|
-
return Xt || (Xt = 1, function(t) {
|
|
4385
|
-
var e = vs(), r = Br();
|
|
4386
|
-
function n(a, s, i) {
|
|
4387
|
-
var o = r(a, s, "set");
|
|
4388
|
-
return e(a, o, i), i;
|
|
4389
|
-
}
|
|
4390
|
-
t.exports = n, t.exports.__esModule = !0, t.exports.default = t.exports;
|
|
4391
|
-
}(nt)), nt.exports;
|
|
4392
|
-
}
|
|
4393
|
-
var Yt;
|
|
4394
|
-
function As() {
|
|
4395
|
-
if (Yt)
|
|
4396
|
-
return ue;
|
|
4397
|
-
Yt = 1;
|
|
4398
|
-
var t = rr;
|
|
4399
|
-
Object.defineProperty(ue, "__esModule", {
|
|
4400
|
-
value: !0
|
|
4401
|
-
}), ue.SessionStore = void 0, ue.defaultCookies = l;
|
|
4402
|
-
var e = t(bs()), r = t(Es());
|
|
4403
|
-
function n(w, m) {
|
|
4404
|
-
s(w, m), m.add(w);
|
|
4405
|
-
}
|
|
4406
|
-
function a(w, m, E) {
|
|
4407
|
-
s(w, m), m.set(w, E);
|
|
4408
|
-
}
|
|
4409
|
-
function s(w, m) {
|
|
4410
|
-
if (m.has(w))
|
|
4411
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4412
|
-
}
|
|
4413
|
-
function i(w, m, E) {
|
|
4414
|
-
if (!m.has(w))
|
|
4415
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
4416
|
-
return E;
|
|
4417
|
-
}
|
|
4418
|
-
const o = 4096, c = 163, u = o - c;
|
|
4419
|
-
function l(w) {
|
|
4420
|
-
const m = w ? "__Secure-" : "";
|
|
4421
|
-
return {
|
|
4422
|
-
sessionToken: {
|
|
4423
|
-
name: `${m}next-auth.session-token`,
|
|
4424
|
-
options: {
|
|
4425
|
-
httpOnly: !0,
|
|
4426
|
-
sameSite: "lax",
|
|
4427
|
-
path: "/",
|
|
4428
|
-
secure: w
|
|
4429
|
-
}
|
|
4430
|
-
},
|
|
4431
|
-
callbackUrl: {
|
|
4432
|
-
name: `${m}next-auth.callback-url`,
|
|
4433
|
-
options: {
|
|
4434
|
-
httpOnly: !0,
|
|
4435
|
-
sameSite: "lax",
|
|
4436
|
-
path: "/",
|
|
4437
|
-
secure: w
|
|
4438
|
-
}
|
|
4439
|
-
},
|
|
4440
|
-
csrfToken: {
|
|
4441
|
-
name: `${w ? "__Host-" : ""}next-auth.csrf-token`,
|
|
4442
|
-
options: {
|
|
4443
|
-
httpOnly: !0,
|
|
4444
|
-
sameSite: "lax",
|
|
4445
|
-
path: "/",
|
|
4446
|
-
secure: w
|
|
4447
|
-
}
|
|
4448
|
-
},
|
|
4449
|
-
pkceCodeVerifier: {
|
|
4450
|
-
name: `${m}next-auth.pkce.code_verifier`,
|
|
4451
|
-
options: {
|
|
4452
|
-
httpOnly: !0,
|
|
4453
|
-
sameSite: "lax",
|
|
4454
|
-
path: "/",
|
|
4455
|
-
secure: w,
|
|
4456
|
-
maxAge: 60 * 15
|
|
4457
|
-
}
|
|
4458
|
-
},
|
|
4459
|
-
state: {
|
|
4460
|
-
name: `${m}next-auth.state`,
|
|
4461
|
-
options: {
|
|
4462
|
-
httpOnly: !0,
|
|
4463
|
-
sameSite: "lax",
|
|
4464
|
-
path: "/",
|
|
4465
|
-
secure: w,
|
|
4466
|
-
maxAge: 60 * 15
|
|
4467
|
-
}
|
|
4468
|
-
},
|
|
4469
|
-
nonce: {
|
|
4470
|
-
name: `${m}next-auth.nonce`,
|
|
4471
|
-
options: {
|
|
4472
|
-
httpOnly: !0,
|
|
4473
|
-
sameSite: "lax",
|
|
4474
|
-
path: "/",
|
|
4475
|
-
secure: w
|
|
4476
|
-
}
|
|
4477
|
-
}
|
|
4478
|
-
};
|
|
4479
|
-
}
|
|
4480
|
-
var f = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet();
|
|
4481
|
-
class S {
|
|
4482
|
-
constructor(m, E, _) {
|
|
4483
|
-
n(this, g), n(this, h), a(this, f, {
|
|
4484
|
-
writable: !0,
|
|
4485
|
-
value: {}
|
|
4486
|
-
}), a(this, d, {
|
|
4487
|
-
writable: !0,
|
|
4488
|
-
value: void 0
|
|
4489
|
-
}), a(this, p, {
|
|
4490
|
-
writable: !0,
|
|
4491
|
-
value: void 0
|
|
4492
|
-
}), (0, r.default)(this, p, _), (0, r.default)(this, d, m);
|
|
4493
|
-
const {
|
|
4494
|
-
cookies: A
|
|
4495
|
-
} = E, {
|
|
4496
|
-
name: R
|
|
4497
|
-
} = m;
|
|
4498
|
-
if (typeof (A == null ? void 0 : A.getAll) == "function")
|
|
4499
|
-
for (const {
|
|
4500
|
-
name: F,
|
|
4501
|
-
value: q
|
|
4502
|
-
} of A.getAll())
|
|
4503
|
-
F.startsWith(R) && ((0, e.default)(this, f)[F] = q);
|
|
4504
|
-
else if (A instanceof Map)
|
|
4505
|
-
for (const F of A.keys())
|
|
4506
|
-
F.startsWith(R) && ((0, e.default)(this, f)[F] = A.get(F));
|
|
4507
|
-
else
|
|
4508
|
-
for (const F in A)
|
|
4509
|
-
F.startsWith(R) && ((0, e.default)(this, f)[F] = A[F]);
|
|
4510
|
-
}
|
|
4511
|
-
get value() {
|
|
4512
|
-
return Object.keys((0, e.default)(this, f)).sort((E, _) => {
|
|
4513
|
-
var A, R;
|
|
4514
|
-
const F = parseInt((A = E.split(".").pop()) !== null && A !== void 0 ? A : "0"), q = parseInt((R = _.split(".").pop()) !== null && R !== void 0 ? R : "0");
|
|
4515
|
-
return F - q;
|
|
4516
|
-
}).map((E) => (0, e.default)(this, f)[E]).join("");
|
|
4517
|
-
}
|
|
4518
|
-
chunk(m, E) {
|
|
4519
|
-
const _ = i(this, g, v).call(this), A = i(this, h, C).call(this, {
|
|
4520
|
-
name: (0, e.default)(this, d).name,
|
|
4521
|
-
value: m,
|
|
4522
|
-
options: {
|
|
4523
|
-
...(0, e.default)(this, d).options,
|
|
4524
|
-
...E
|
|
4525
|
-
}
|
|
4526
|
-
});
|
|
4527
|
-
for (const R of A)
|
|
4528
|
-
_[R.name] = R;
|
|
4529
|
-
return Object.values(_);
|
|
4530
|
-
}
|
|
4531
|
-
clean() {
|
|
4532
|
-
return Object.values(i(this, g, v).call(this));
|
|
4533
|
-
}
|
|
4534
|
-
}
|
|
4535
|
-
ue.SessionStore = S;
|
|
4536
|
-
function C(w) {
|
|
4537
|
-
const m = Math.ceil(w.value.length / u);
|
|
4538
|
-
if (m === 1)
|
|
4539
|
-
return (0, e.default)(this, f)[w.name] = w.value, [w];
|
|
4540
|
-
const E = [];
|
|
4541
|
-
for (let _ = 0; _ < m; _++) {
|
|
4542
|
-
const A = `${w.name}.${_}`, R = w.value.substr(_ * u, u);
|
|
4543
|
-
E.push({
|
|
4544
|
-
...w,
|
|
4545
|
-
name: A,
|
|
4546
|
-
value: R
|
|
4547
|
-
}), (0, e.default)(this, f)[A] = R;
|
|
4548
|
-
}
|
|
4549
|
-
return (0, e.default)(this, p).debug("CHUNKING_SESSION_COOKIE", {
|
|
4550
|
-
message: `Session cookie exceeds allowed ${o} bytes.`,
|
|
4551
|
-
emptyCookieSize: c,
|
|
4552
|
-
valueSize: w.value.length,
|
|
4553
|
-
chunks: E.map((_) => _.value.length + c)
|
|
4554
|
-
}), E;
|
|
4555
|
-
}
|
|
4556
|
-
function v() {
|
|
4557
|
-
const w = {};
|
|
4558
|
-
for (const E in (0, e.default)(this, f)) {
|
|
4559
|
-
var m;
|
|
4560
|
-
(m = (0, e.default)(this, f)) === null || m === void 0 || delete m[E], w[E] = {
|
|
4561
|
-
name: E,
|
|
4562
|
-
value: "",
|
|
4563
|
-
options: {
|
|
4564
|
-
...(0, e.default)(this, d).options,
|
|
4565
|
-
maxAge: 0
|
|
4566
|
-
}
|
|
4567
|
-
};
|
|
4568
|
-
}
|
|
4569
|
-
return w;
|
|
4570
|
-
}
|
|
4571
|
-
return ue;
|
|
4572
|
-
}
|
|
4573
|
-
var st = {}, Zt;
|
|
4574
|
-
function xs() {
|
|
4575
|
-
return Zt || (Zt = 1, Object.defineProperty(st, "__esModule", {
|
|
4576
|
-
value: !0
|
|
4577
|
-
})), st;
|
|
4578
|
-
}
|
|
4579
|
-
(function(t) {
|
|
4580
|
-
var e = rr;
|
|
4581
|
-
Object.defineProperty(t, "__esModule", {
|
|
4582
|
-
value: !0
|
|
4583
|
-
});
|
|
4584
|
-
var r = {
|
|
4585
|
-
encode: !0,
|
|
4586
|
-
decode: !0,
|
|
4587
|
-
getToken: !0
|
|
4588
|
-
};
|
|
4589
|
-
t.decode = f, t.encode = l, t.getToken = d;
|
|
4590
|
-
var n = ka, a = e(Ya), s = ws, i = As(), o = xs();
|
|
4591
|
-
Object.keys(o).forEach(function(h) {
|
|
4592
|
-
h === "default" || h === "__esModule" || Object.prototype.hasOwnProperty.call(r, h) || h in t && t[h] === o[h] || Object.defineProperty(t, h, {
|
|
4593
|
-
enumerable: !0,
|
|
4594
|
-
get: function() {
|
|
4595
|
-
return o[h];
|
|
4596
|
-
}
|
|
4597
|
-
});
|
|
4598
|
-
});
|
|
4599
|
-
const c = 30 * 24 * 60 * 60, u = () => Date.now() / 1e3 | 0;
|
|
4600
|
-
async function l(h) {
|
|
4601
|
-
const {
|
|
4602
|
-
token: g = {},
|
|
4603
|
-
secret: S,
|
|
4604
|
-
maxAge: C = c,
|
|
4605
|
-
salt: v = ""
|
|
4606
|
-
} = h, w = await p(S, v);
|
|
4607
|
-
return await new n.EncryptJWT(g).setProtectedHeader({
|
|
4608
|
-
alg: "dir",
|
|
4609
|
-
enc: "A256GCM"
|
|
4610
|
-
}).setIssuedAt().setExpirationTime(u() + C).setJti((0, s.v4)()).encrypt(w);
|
|
4611
|
-
}
|
|
4612
|
-
async function f(h) {
|
|
4613
|
-
const {
|
|
4614
|
-
token: g,
|
|
4615
|
-
secret: S,
|
|
4616
|
-
salt: C = ""
|
|
4617
|
-
} = h;
|
|
4618
|
-
if (!g)
|
|
4619
|
-
return null;
|
|
4620
|
-
const v = await p(S, C), {
|
|
4621
|
-
payload: w
|
|
4622
|
-
} = await (0, n.jwtDecrypt)(g, v, {
|
|
4623
|
-
clockTolerance: 15
|
|
4624
|
-
});
|
|
4625
|
-
return w;
|
|
4626
|
-
}
|
|
4627
|
-
async function d(h) {
|
|
4628
|
-
var g, S, C;
|
|
4629
|
-
const {
|
|
4630
|
-
req: v,
|
|
4631
|
-
secureCookie: w = (g = (S = process.env.NEXTAUTH_URL) === null || S === void 0 ? void 0 : S.startsWith("https://")) !== null && g !== void 0 ? g : !!process.env.VERCEL,
|
|
4632
|
-
cookieName: m = w ? "__Secure-next-auth.session-token" : "next-auth.session-token",
|
|
4633
|
-
raw: E,
|
|
4634
|
-
decode: _ = f,
|
|
4635
|
-
logger: A = console,
|
|
4636
|
-
secret: R = process.env.NEXTAUTH_SECRET
|
|
4637
|
-
} = h;
|
|
4638
|
-
if (!v)
|
|
4639
|
-
throw new Error("Must pass `req` to JWT getToken()");
|
|
4640
|
-
let q = new i.SessionStore({
|
|
4641
|
-
name: m,
|
|
4642
|
-
options: {
|
|
4643
|
-
secure: w
|
|
4644
|
-
}
|
|
4645
|
-
}, {
|
|
4646
|
-
cookies: v.cookies,
|
|
4647
|
-
headers: v.headers
|
|
4648
|
-
}, A).value;
|
|
4649
|
-
const Y = v.headers instanceof Headers ? v.headers.get("authorization") : (C = v.headers) === null || C === void 0 ? void 0 : C.authorization;
|
|
4650
|
-
if (!q && (Y == null ? void 0 : Y.split(" ")[0]) === "Bearer") {
|
|
4651
|
-
const Be = Y.split(" ")[1];
|
|
4652
|
-
q = decodeURIComponent(Be);
|
|
4653
|
-
}
|
|
4654
|
-
if (!q)
|
|
4655
|
-
return null;
|
|
4656
|
-
if (E)
|
|
4657
|
-
return q;
|
|
4658
|
-
try {
|
|
4659
|
-
return await _({
|
|
4660
|
-
token: q,
|
|
4661
|
-
secret: R
|
|
4662
|
-
});
|
|
4663
|
-
} catch {
|
|
4664
|
-
return null;
|
|
4665
|
-
}
|
|
4666
|
-
}
|
|
4667
|
-
async function p(h, g) {
|
|
4668
|
-
return await (0, a.default)("sha256", h, g, `NextAuth.js Generated Encryption Key${g ? ` (${g})` : ""}`, 32);
|
|
4669
|
-
}
|
|
4670
|
-
})(er);
|
|
4671
|
-
class Hs extends zr {
|
|
4672
|
-
async validateTokenFront(e) {
|
|
4673
|
-
this.logDebug("entra validate Token Front");
|
|
4674
|
-
const r = await er.getToken({ req: e });
|
|
4675
|
-
if (this.logDebug("Token Front", JSON.stringify(r)), !r)
|
|
4676
|
-
throw new wn().get("UNAUTHORIZED");
|
|
4677
|
-
return e;
|
|
4678
|
-
}
|
|
4679
|
-
}
|
|
4680
|
-
export {
|
|
4681
|
-
Hs as C,
|
|
4682
|
-
wn as E
|
|
4683
|
-
};
|