@hot-updater/js 0.33.0 → 0.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +448 -381
- package/dist/index.mjs +448 -381
- package/package.json +9 -6
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
}) : target, mod));
|
|
24
24
|
//#endregion
|
|
25
25
|
let _hot_updater_core = require("@hot-updater/core");
|
|
26
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
26
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/constants.js
|
|
27
27
|
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
28
28
|
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
29
29
|
const MAX_LENGTH = 256;
|
|
@@ -48,12 +48,12 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
48
48
|
};
|
|
49
49
|
}));
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
51
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/debug.js
|
|
52
52
|
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
53
53
|
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
54
54
|
}));
|
|
55
55
|
//#endregion
|
|
56
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
56
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/re.js
|
|
57
57
|
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
58
58
|
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
59
59
|
const debug = require_debug();
|
|
@@ -132,7 +132,7 @@ var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
132
132
|
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
133
133
|
}));
|
|
134
134
|
//#endregion
|
|
135
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
135
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/parse-options.js
|
|
136
136
|
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
137
137
|
const looseOption = Object.freeze({ loose: true });
|
|
138
138
|
const emptyOpts = Object.freeze({});
|
|
@@ -144,10 +144,11 @@ var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
144
144
|
module.exports = parseOptions;
|
|
145
145
|
}));
|
|
146
146
|
//#endregion
|
|
147
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
147
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/identifiers.js
|
|
148
148
|
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
149
149
|
const numeric = /^[0-9]+$/;
|
|
150
150
|
const compareIdentifiers = (a, b) => {
|
|
151
|
+
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
151
152
|
const anum = numeric.test(a);
|
|
152
153
|
const bnum = numeric.test(b);
|
|
153
154
|
if (anum && bnum) {
|
|
@@ -163,13 +164,19 @@ var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
163
164
|
};
|
|
164
165
|
}));
|
|
165
166
|
//#endregion
|
|
166
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
167
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/classes/semver.js
|
|
167
168
|
var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
168
169
|
const debug = require_debug();
|
|
169
170
|
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
170
171
|
const { safeRe: re, t } = require_re();
|
|
171
172
|
const parseOptions = require_parse_options();
|
|
172
173
|
const { compareIdentifiers } = require_identifiers();
|
|
174
|
+
const isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
175
|
+
const identifiers = identifier.split(".");
|
|
176
|
+
if (identifiers.length > prerelease.length) return false;
|
|
177
|
+
for (let i = 0; i < identifiers.length; i++) if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) return false;
|
|
178
|
+
return true;
|
|
179
|
+
};
|
|
173
180
|
module.exports = class SemVer {
|
|
174
181
|
constructor(version, options) {
|
|
175
182
|
options = parseOptions(options);
|
|
@@ -220,7 +227,13 @@ var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
220
227
|
}
|
|
221
228
|
compareMain(other) {
|
|
222
229
|
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
223
|
-
|
|
230
|
+
if (this.major < other.major) return -1;
|
|
231
|
+
if (this.major > other.major) return 1;
|
|
232
|
+
if (this.minor < other.minor) return -1;
|
|
233
|
+
if (this.minor > other.minor) return 1;
|
|
234
|
+
if (this.patch < other.patch) return -1;
|
|
235
|
+
if (this.patch > other.patch) return 1;
|
|
236
|
+
return 0;
|
|
224
237
|
}
|
|
225
238
|
comparePre(other) {
|
|
226
239
|
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
@@ -320,8 +333,9 @@ var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
320
333
|
if (identifier) {
|
|
321
334
|
let prerelease = [identifier, base];
|
|
322
335
|
if (identifierBase === false) prerelease = [identifier];
|
|
323
|
-
if (
|
|
324
|
-
|
|
336
|
+
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
337
|
+
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
338
|
+
if (isNaN(prereleaseBase)) this.prerelease = prerelease;
|
|
325
339
|
} else this.prerelease = prerelease;
|
|
326
340
|
}
|
|
327
341
|
break;
|
|
@@ -335,7 +349,7 @@ var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
335
349
|
};
|
|
336
350
|
}));
|
|
337
351
|
//#endregion
|
|
338
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
352
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/parse.js
|
|
339
353
|
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
340
354
|
const SemVer = require_semver$1();
|
|
341
355
|
const parse = (version, options, throwErrors = false) => {
|
|
@@ -350,7 +364,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
350
364
|
module.exports = parse;
|
|
351
365
|
}));
|
|
352
366
|
//#endregion
|
|
353
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
367
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/valid.js
|
|
354
368
|
var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
355
369
|
const parse = require_parse();
|
|
356
370
|
const valid = (version, options) => {
|
|
@@ -360,7 +374,7 @@ var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
360
374
|
module.exports = valid;
|
|
361
375
|
}));
|
|
362
376
|
//#endregion
|
|
363
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
377
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/clean.js
|
|
364
378
|
var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
365
379
|
const parse = require_parse();
|
|
366
380
|
const clean = (version, options) => {
|
|
@@ -370,7 +384,7 @@ var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
370
384
|
module.exports = clean;
|
|
371
385
|
}));
|
|
372
386
|
//#endregion
|
|
373
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
387
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/inc.js
|
|
374
388
|
var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
375
389
|
const SemVer = require_semver$1();
|
|
376
390
|
const inc = (version, release, options, identifier, identifierBase) => {
|
|
@@ -388,7 +402,7 @@ var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
388
402
|
module.exports = inc;
|
|
389
403
|
}));
|
|
390
404
|
//#endregion
|
|
391
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
405
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/diff.js
|
|
392
406
|
var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
393
407
|
const parse = require_parse();
|
|
394
408
|
const diff = (version1, version2) => {
|
|
@@ -416,28 +430,28 @@ var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
416
430
|
module.exports = diff;
|
|
417
431
|
}));
|
|
418
432
|
//#endregion
|
|
419
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
433
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/major.js
|
|
420
434
|
var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
421
435
|
const SemVer = require_semver$1();
|
|
422
436
|
const major = (a, loose) => new SemVer(a, loose).major;
|
|
423
437
|
module.exports = major;
|
|
424
438
|
}));
|
|
425
439
|
//#endregion
|
|
426
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
440
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/minor.js
|
|
427
441
|
var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
428
442
|
const SemVer = require_semver$1();
|
|
429
443
|
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
430
444
|
module.exports = minor;
|
|
431
445
|
}));
|
|
432
446
|
//#endregion
|
|
433
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
447
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/patch.js
|
|
434
448
|
var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
435
449
|
const SemVer = require_semver$1();
|
|
436
450
|
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
437
451
|
module.exports = patch;
|
|
438
452
|
}));
|
|
439
453
|
//#endregion
|
|
440
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
454
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/prerelease.js
|
|
441
455
|
var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
442
456
|
const parse = require_parse();
|
|
443
457
|
const prerelease = (version, options) => {
|
|
@@ -447,28 +461,28 @@ var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
447
461
|
module.exports = prerelease;
|
|
448
462
|
}));
|
|
449
463
|
//#endregion
|
|
450
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
464
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/compare.js
|
|
451
465
|
var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
452
466
|
const SemVer = require_semver$1();
|
|
453
467
|
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
454
468
|
module.exports = compare;
|
|
455
469
|
}));
|
|
456
470
|
//#endregion
|
|
457
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
471
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/rcompare.js
|
|
458
472
|
var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
459
473
|
const compare = require_compare();
|
|
460
474
|
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
461
475
|
module.exports = rcompare;
|
|
462
476
|
}));
|
|
463
477
|
//#endregion
|
|
464
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
478
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/compare-loose.js
|
|
465
479
|
var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
466
480
|
const compare = require_compare();
|
|
467
481
|
const compareLoose = (a, b) => compare(a, b, true);
|
|
468
482
|
module.exports = compareLoose;
|
|
469
483
|
}));
|
|
470
484
|
//#endregion
|
|
471
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
485
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/compare-build.js
|
|
472
486
|
var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
473
487
|
const SemVer = require_semver$1();
|
|
474
488
|
const compareBuild = (a, b, loose) => {
|
|
@@ -479,63 +493,63 @@ var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
479
493
|
module.exports = compareBuild;
|
|
480
494
|
}));
|
|
481
495
|
//#endregion
|
|
482
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
496
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/sort.js
|
|
483
497
|
var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
484
498
|
const compareBuild = require_compare_build();
|
|
485
499
|
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
486
500
|
module.exports = sort;
|
|
487
501
|
}));
|
|
488
502
|
//#endregion
|
|
489
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
503
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/rsort.js
|
|
490
504
|
var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
491
505
|
const compareBuild = require_compare_build();
|
|
492
506
|
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
493
507
|
module.exports = rsort;
|
|
494
508
|
}));
|
|
495
509
|
//#endregion
|
|
496
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
510
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/gt.js
|
|
497
511
|
var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
498
512
|
const compare = require_compare();
|
|
499
513
|
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
500
514
|
module.exports = gt;
|
|
501
515
|
}));
|
|
502
516
|
//#endregion
|
|
503
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
517
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/lt.js
|
|
504
518
|
var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
505
519
|
const compare = require_compare();
|
|
506
520
|
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
507
521
|
module.exports = lt;
|
|
508
522
|
}));
|
|
509
523
|
//#endregion
|
|
510
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
524
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/eq.js
|
|
511
525
|
var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
512
526
|
const compare = require_compare();
|
|
513
527
|
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
514
528
|
module.exports = eq;
|
|
515
529
|
}));
|
|
516
530
|
//#endregion
|
|
517
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
531
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/neq.js
|
|
518
532
|
var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
519
533
|
const compare = require_compare();
|
|
520
534
|
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
521
535
|
module.exports = neq;
|
|
522
536
|
}));
|
|
523
537
|
//#endregion
|
|
524
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
538
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/gte.js
|
|
525
539
|
var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
526
540
|
const compare = require_compare();
|
|
527
541
|
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
528
542
|
module.exports = gte;
|
|
529
543
|
}));
|
|
530
544
|
//#endregion
|
|
531
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
545
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/lte.js
|
|
532
546
|
var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
533
547
|
const compare = require_compare();
|
|
534
548
|
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
535
549
|
module.exports = lte;
|
|
536
550
|
}));
|
|
537
551
|
//#endregion
|
|
538
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
552
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/cmp.js
|
|
539
553
|
var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
540
554
|
const eq = require_eq();
|
|
541
555
|
const neq = require_neq();
|
|
@@ -567,7 +581,7 @@ var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
567
581
|
module.exports = cmp;
|
|
568
582
|
}));
|
|
569
583
|
//#endregion
|
|
570
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
584
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/coerce.js
|
|
571
585
|
var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
572
586
|
const SemVer = require_semver$1();
|
|
573
587
|
const parse = require_parse();
|
|
@@ -595,7 +609,40 @@ var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
595
609
|
module.exports = coerce;
|
|
596
610
|
}));
|
|
597
611
|
//#endregion
|
|
598
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
612
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/truncate.js
|
|
613
|
+
var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
614
|
+
const parse = require_parse();
|
|
615
|
+
const constants = require_constants();
|
|
616
|
+
const SemVer = require_semver$1();
|
|
617
|
+
const truncate = (version, truncation, options) => {
|
|
618
|
+
if (!constants.RELEASE_TYPES.includes(truncation)) return null;
|
|
619
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
620
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
621
|
+
};
|
|
622
|
+
const cloneInputVersion = (version, options) => {
|
|
623
|
+
return parse(version instanceof SemVer ? version.version : version, options);
|
|
624
|
+
};
|
|
625
|
+
const doTruncation = (version, truncation) => {
|
|
626
|
+
if (isPrerelease(truncation)) return version.version;
|
|
627
|
+
version.prerelease = [];
|
|
628
|
+
switch (truncation) {
|
|
629
|
+
case "major":
|
|
630
|
+
version.minor = 0;
|
|
631
|
+
version.patch = 0;
|
|
632
|
+
break;
|
|
633
|
+
case "minor":
|
|
634
|
+
version.patch = 0;
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
return version.format();
|
|
638
|
+
};
|
|
639
|
+
const isPrerelease = (type) => {
|
|
640
|
+
return type.startsWith("pre");
|
|
641
|
+
};
|
|
642
|
+
module.exports = truncate;
|
|
643
|
+
}));
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/internal/lrucache.js
|
|
599
646
|
var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
600
647
|
var LRUCache = class {
|
|
601
648
|
constructor() {
|
|
@@ -628,7 +675,7 @@ var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
628
675
|
module.exports = LRUCache;
|
|
629
676
|
}));
|
|
630
677
|
//#endregion
|
|
631
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
678
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/classes/range.js
|
|
632
679
|
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
633
680
|
const SPACE_CHARACTERS = /\s+/g;
|
|
634
681
|
module.exports = class Range {
|
|
@@ -682,6 +729,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
682
729
|
return this.range;
|
|
683
730
|
}
|
|
684
731
|
parseRange(range) {
|
|
732
|
+
range = range.replace(BUILDSTRIPRE, "");
|
|
685
733
|
const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
|
|
686
734
|
const cached = cache.get(memoKey);
|
|
687
735
|
if (cached) return cached;
|
|
@@ -740,8 +788,9 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
740
788
|
const Comparator = require_comparator();
|
|
741
789
|
const debug = require_debug();
|
|
742
790
|
const SemVer = require_semver$1();
|
|
743
|
-
const { safeRe: re, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
791
|
+
const { safeRe: re, src, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
744
792
|
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
793
|
+
const BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
745
794
|
const isNullSet = (c) => c.value === "<0.0.0-0";
|
|
746
795
|
const isAny = (c) => c.value === "";
|
|
747
796
|
const isSatisfiable = (comparators, options) => {
|
|
@@ -757,6 +806,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
757
806
|
return result;
|
|
758
807
|
};
|
|
759
808
|
const parseComparator = (comp, options) => {
|
|
809
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
760
810
|
debug("comp", comp, options);
|
|
761
811
|
comp = replaceCarets(comp, options);
|
|
762
812
|
debug("caret", comp);
|
|
@@ -769,6 +819,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
769
819
|
return comp;
|
|
770
820
|
};
|
|
771
821
|
const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
822
|
+
const invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
772
823
|
const replaceTildes = (comp, options) => {
|
|
773
824
|
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
774
825
|
};
|
|
@@ -809,8 +860,8 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
809
860
|
else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
810
861
|
} else {
|
|
811
862
|
debug("no pr");
|
|
812
|
-
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}
|
|
813
|
-
else ret = `>=${M}.${m}.${p}
|
|
863
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
864
|
+
else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
814
865
|
else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
815
866
|
}
|
|
816
867
|
debug("caret return", ret);
|
|
@@ -826,6 +877,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
826
877
|
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
827
878
|
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
828
879
|
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
880
|
+
if (invalidXRangeOrder(M, m, p)) return comp;
|
|
829
881
|
const xM = isX(M);
|
|
830
882
|
const xm = xM || isX(m);
|
|
831
883
|
const xp = xm || isX(p);
|
|
@@ -899,7 +951,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
899
951
|
};
|
|
900
952
|
}));
|
|
901
953
|
//#endregion
|
|
902
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
954
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/classes/comparator.js
|
|
903
955
|
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
904
956
|
const ANY = Symbol("SemVer ANY");
|
|
905
957
|
module.exports = class Comparator {
|
|
@@ -969,7 +1021,7 @@ var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
969
1021
|
const Range = require_range();
|
|
970
1022
|
}));
|
|
971
1023
|
//#endregion
|
|
972
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1024
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/functions/satisfies.js
|
|
973
1025
|
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
974
1026
|
const Range = require_range();
|
|
975
1027
|
const satisfies = (version, range, options) => {
|
|
@@ -983,14 +1035,14 @@ var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
983
1035
|
module.exports = satisfies;
|
|
984
1036
|
}));
|
|
985
1037
|
//#endregion
|
|
986
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1038
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/to-comparators.js
|
|
987
1039
|
var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
988
1040
|
const Range = require_range();
|
|
989
1041
|
const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
990
1042
|
module.exports = toComparators;
|
|
991
1043
|
}));
|
|
992
1044
|
//#endregion
|
|
993
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1045
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/max-satisfying.js
|
|
994
1046
|
var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
995
1047
|
const SemVer = require_semver$1();
|
|
996
1048
|
const Range = require_range();
|
|
@@ -1016,7 +1068,7 @@ var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1016
1068
|
module.exports = maxSatisfying;
|
|
1017
1069
|
}));
|
|
1018
1070
|
//#endregion
|
|
1019
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1071
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/min-satisfying.js
|
|
1020
1072
|
var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1021
1073
|
const SemVer = require_semver$1();
|
|
1022
1074
|
const Range = require_range();
|
|
@@ -1042,7 +1094,7 @@ var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1042
1094
|
module.exports = minSatisfying;
|
|
1043
1095
|
}));
|
|
1044
1096
|
//#endregion
|
|
1045
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1097
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/min-version.js
|
|
1046
1098
|
var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1047
1099
|
const SemVer = require_semver$1();
|
|
1048
1100
|
const Range = require_range();
|
|
@@ -1081,7 +1133,7 @@ var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1081
1133
|
module.exports = minVersion;
|
|
1082
1134
|
}));
|
|
1083
1135
|
//#endregion
|
|
1084
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1136
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/valid.js
|
|
1085
1137
|
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1086
1138
|
const Range = require_range();
|
|
1087
1139
|
const validRange = (range, options) => {
|
|
@@ -1094,7 +1146,7 @@ var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1094
1146
|
module.exports = validRange;
|
|
1095
1147
|
}));
|
|
1096
1148
|
//#endregion
|
|
1097
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1149
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/outside.js
|
|
1098
1150
|
var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1099
1151
|
const SemVer = require_semver$1();
|
|
1100
1152
|
const Comparator = require_comparator();
|
|
@@ -1147,21 +1199,21 @@ var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1147
1199
|
module.exports = outside;
|
|
1148
1200
|
}));
|
|
1149
1201
|
//#endregion
|
|
1150
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1202
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/gtr.js
|
|
1151
1203
|
var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1152
1204
|
const outside = require_outside();
|
|
1153
1205
|
const gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1154
1206
|
module.exports = gtr;
|
|
1155
1207
|
}));
|
|
1156
1208
|
//#endregion
|
|
1157
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1209
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/ltr.js
|
|
1158
1210
|
var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1159
1211
|
const outside = require_outside();
|
|
1160
1212
|
const ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1161
1213
|
module.exports = ltr;
|
|
1162
1214
|
}));
|
|
1163
1215
|
//#endregion
|
|
1164
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1216
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/intersects.js
|
|
1165
1217
|
var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1166
1218
|
const Range = require_range();
|
|
1167
1219
|
const intersects = (r1, r2, options) => {
|
|
@@ -1172,7 +1224,7 @@ var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1172
1224
|
module.exports = intersects;
|
|
1173
1225
|
}));
|
|
1174
1226
|
//#endregion
|
|
1175
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1227
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/simplify.js
|
|
1176
1228
|
var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1177
1229
|
const satisfies = require_satisfies();
|
|
1178
1230
|
const compare = require_compare();
|
|
@@ -1202,7 +1254,7 @@ var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1202
1254
|
};
|
|
1203
1255
|
}));
|
|
1204
1256
|
//#endregion
|
|
1205
|
-
//#region ../../node_modules/.pnpm/semver@7.
|
|
1257
|
+
//#region ../../node_modules/.pnpm/semver@7.8.4/node_modules/semver/ranges/subset.js
|
|
1206
1258
|
var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1207
1259
|
const Range = require_range();
|
|
1208
1260
|
const Comparator = require_comparator();
|
|
@@ -1266,7 +1318,7 @@ var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1266
1318
|
if (c.operator === ">" || c.operator === ">=") {
|
|
1267
1319
|
higher = higherGT(gt, c, options);
|
|
1268
1320
|
if (higher === c && higher !== gt) return false;
|
|
1269
|
-
} else if (gt.operator === ">=" && !
|
|
1321
|
+
} else if (gt.operator === ">=" && !c.test(gt.semver)) return false;
|
|
1270
1322
|
}
|
|
1271
1323
|
if (lt) {
|
|
1272
1324
|
if (needDomLTPre) {
|
|
@@ -1275,7 +1327,7 @@ var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1275
1327
|
if (c.operator === "<" || c.operator === "<=") {
|
|
1276
1328
|
lower = lowerLT(lt, c, options);
|
|
1277
1329
|
if (lower === c && lower !== lt) return false;
|
|
1278
|
-
} else if (lt.operator === "<=" && !
|
|
1330
|
+
} else if (lt.operator === "<=" && !c.test(lt.semver)) return false;
|
|
1279
1331
|
}
|
|
1280
1332
|
if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
|
|
1281
1333
|
}
|
|
@@ -1327,6 +1379,7 @@ var import_semver = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
1327
1379
|
lte: require_lte(),
|
|
1328
1380
|
cmp: require_cmp(),
|
|
1329
1381
|
coerce: require_coerce(),
|
|
1382
|
+
truncate: require_truncate(),
|
|
1330
1383
|
Comparator: require_comparator(),
|
|
1331
1384
|
Range: require_range(),
|
|
1332
1385
|
satisfies: require_satisfies(),
|
|
@@ -1465,7 +1518,7 @@ const fingerprintStrategy = async (bundles, { channel = "production", minBundleI
|
|
|
1465
1518
|
return INIT_BUNDLE_ROLLBACK_UPDATE_INFO;
|
|
1466
1519
|
};
|
|
1467
1520
|
//#endregion
|
|
1468
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1521
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
1469
1522
|
const encoder = new TextEncoder();
|
|
1470
1523
|
const decoder = new TextDecoder();
|
|
1471
1524
|
function concat(...buffers) {
|
|
@@ -1478,8 +1531,17 @@ function concat(...buffers) {
|
|
|
1478
1531
|
}
|
|
1479
1532
|
return buf;
|
|
1480
1533
|
}
|
|
1534
|
+
function encode$1(string) {
|
|
1535
|
+
const bytes = new Uint8Array(string.length);
|
|
1536
|
+
for (let i = 0; i < string.length; i++) {
|
|
1537
|
+
const code = string.charCodeAt(i);
|
|
1538
|
+
if (code > 127) throw new TypeError("non-ASCII string encountered in encode()");
|
|
1539
|
+
bytes[i] = code;
|
|
1540
|
+
}
|
|
1541
|
+
return bytes;
|
|
1542
|
+
}
|
|
1481
1543
|
//#endregion
|
|
1482
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1544
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/base64.js
|
|
1483
1545
|
function encodeBase64(input) {
|
|
1484
1546
|
if (Uint8Array.prototype.toBase64) return input.toBase64();
|
|
1485
1547
|
const CHUNK_SIZE = 32768;
|
|
@@ -1495,12 +1557,12 @@ function decodeBase64(encoded) {
|
|
|
1495
1557
|
return bytes;
|
|
1496
1558
|
}
|
|
1497
1559
|
//#endregion
|
|
1498
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1560
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/util/base64url.js
|
|
1499
1561
|
function decode(input) {
|
|
1500
1562
|
if (Uint8Array.fromBase64) return Uint8Array.fromBase64(typeof input === "string" ? input : decoder.decode(input), { alphabet: "base64url" });
|
|
1501
1563
|
let encoded = input;
|
|
1502
1564
|
if (encoded instanceof Uint8Array) encoded = decoder.decode(encoded);
|
|
1503
|
-
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/")
|
|
1565
|
+
encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
1504
1566
|
try {
|
|
1505
1567
|
return decodeBase64(encoded);
|
|
1506
1568
|
} catch {
|
|
@@ -1517,7 +1579,87 @@ function encode(input) {
|
|
|
1517
1579
|
return encodeBase64(unencoded).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1518
1580
|
}
|
|
1519
1581
|
//#endregion
|
|
1520
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1582
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/crypto_key.js
|
|
1583
|
+
const unusable = (name, prop = "algorithm.name") => /* @__PURE__ */ new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
|
|
1584
|
+
const isAlgorithm = (algorithm, name) => algorithm.name === name;
|
|
1585
|
+
function getHashLength(hash) {
|
|
1586
|
+
return parseInt(hash.name.slice(4), 10);
|
|
1587
|
+
}
|
|
1588
|
+
function checkHashLength(algorithm, expected) {
|
|
1589
|
+
if (getHashLength(algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
1590
|
+
}
|
|
1591
|
+
function getNamedCurve(alg) {
|
|
1592
|
+
switch (alg) {
|
|
1593
|
+
case "ES256": return "P-256";
|
|
1594
|
+
case "ES384": return "P-384";
|
|
1595
|
+
case "ES512": return "P-521";
|
|
1596
|
+
default: throw new Error("unreachable");
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
function checkUsage(key, usage) {
|
|
1600
|
+
if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
1601
|
+
}
|
|
1602
|
+
function checkSigCryptoKey(key, alg, usage) {
|
|
1603
|
+
switch (alg) {
|
|
1604
|
+
case "HS256":
|
|
1605
|
+
case "HS384":
|
|
1606
|
+
case "HS512":
|
|
1607
|
+
if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
|
|
1608
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
1609
|
+
break;
|
|
1610
|
+
case "RS256":
|
|
1611
|
+
case "RS384":
|
|
1612
|
+
case "RS512":
|
|
1613
|
+
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
|
|
1614
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
1615
|
+
break;
|
|
1616
|
+
case "PS256":
|
|
1617
|
+
case "PS384":
|
|
1618
|
+
case "PS512":
|
|
1619
|
+
if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
|
|
1620
|
+
checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));
|
|
1621
|
+
break;
|
|
1622
|
+
case "Ed25519":
|
|
1623
|
+
case "EdDSA":
|
|
1624
|
+
if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
|
|
1625
|
+
break;
|
|
1626
|
+
case "ML-DSA-44":
|
|
1627
|
+
case "ML-DSA-65":
|
|
1628
|
+
case "ML-DSA-87":
|
|
1629
|
+
if (!isAlgorithm(key.algorithm, alg)) throw unusable(alg);
|
|
1630
|
+
break;
|
|
1631
|
+
case "ES256":
|
|
1632
|
+
case "ES384":
|
|
1633
|
+
case "ES512": {
|
|
1634
|
+
if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
|
|
1635
|
+
const expected = getNamedCurve(alg);
|
|
1636
|
+
if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
|
|
1637
|
+
break;
|
|
1638
|
+
}
|
|
1639
|
+
default: throw new TypeError("CryptoKey does not support this operation");
|
|
1640
|
+
}
|
|
1641
|
+
checkUsage(key, usage);
|
|
1642
|
+
}
|
|
1643
|
+
//#endregion
|
|
1644
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
1645
|
+
function message(msg, actual, ...types) {
|
|
1646
|
+
types = types.filter(Boolean);
|
|
1647
|
+
if (types.length > 2) {
|
|
1648
|
+
const last = types.pop();
|
|
1649
|
+
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
1650
|
+
} else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
|
|
1651
|
+
else msg += `of type ${types[0]}.`;
|
|
1652
|
+
if (actual == null) msg += ` Received ${actual}`;
|
|
1653
|
+
else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
|
|
1654
|
+
else if (typeof actual === "object" && actual != null) {
|
|
1655
|
+
if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
|
|
1656
|
+
}
|
|
1657
|
+
return msg;
|
|
1658
|
+
}
|
|
1659
|
+
const invalidKeyInput = (actual, ...types) => message("Key must be ", actual, ...types);
|
|
1660
|
+
const withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);
|
|
1661
|
+
//#endregion
|
|
1662
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/util/errors.js
|
|
1521
1663
|
var JOSEError = class extends Error {
|
|
1522
1664
|
static code = "ERR_JOSE_GENERIC";
|
|
1523
1665
|
code = "ERR_JOSE_GENERIC";
|
|
@@ -1585,105 +1727,40 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
|
|
|
1585
1727
|
}
|
|
1586
1728
|
};
|
|
1587
1729
|
//#endregion
|
|
1588
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
function getHashLength(hash) {
|
|
1596
|
-
return parseInt(hash.name.slice(4), 10);
|
|
1597
|
-
}
|
|
1598
|
-
function getNamedCurve(alg) {
|
|
1599
|
-
switch (alg) {
|
|
1600
|
-
case "ES256": return "P-256";
|
|
1601
|
-
case "ES384": return "P-384";
|
|
1602
|
-
case "ES512": return "P-521";
|
|
1603
|
-
default: throw new Error("unreachable");
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
function checkUsage(key, usage) {
|
|
1607
|
-
if (usage && !key.usages.includes(usage)) throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
|
|
1608
|
-
}
|
|
1609
|
-
function checkSigCryptoKey(key, alg, usage) {
|
|
1610
|
-
switch (alg) {
|
|
1611
|
-
case "HS256":
|
|
1612
|
-
case "HS384":
|
|
1613
|
-
case "HS512": {
|
|
1614
|
-
if (!isAlgorithm(key.algorithm, "HMAC")) throw unusable("HMAC");
|
|
1615
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
1616
|
-
if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
1617
|
-
break;
|
|
1618
|
-
}
|
|
1619
|
-
case "RS256":
|
|
1620
|
-
case "RS384":
|
|
1621
|
-
case "RS512": {
|
|
1622
|
-
if (!isAlgorithm(key.algorithm, "RSASSA-PKCS1-v1_5")) throw unusable("RSASSA-PKCS1-v1_5");
|
|
1623
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
1624
|
-
if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
1625
|
-
break;
|
|
1626
|
-
}
|
|
1627
|
-
case "PS256":
|
|
1628
|
-
case "PS384":
|
|
1629
|
-
case "PS512": {
|
|
1630
|
-
if (!isAlgorithm(key.algorithm, "RSA-PSS")) throw unusable("RSA-PSS");
|
|
1631
|
-
const expected = parseInt(alg.slice(2), 10);
|
|
1632
|
-
if (getHashLength(key.algorithm.hash) !== expected) throw unusable(`SHA-${expected}`, "algorithm.hash");
|
|
1633
|
-
break;
|
|
1634
|
-
}
|
|
1635
|
-
case "Ed25519":
|
|
1636
|
-
case "EdDSA":
|
|
1637
|
-
if (!isAlgorithm(key.algorithm, "Ed25519")) throw unusable("Ed25519");
|
|
1638
|
-
break;
|
|
1639
|
-
case "ES256":
|
|
1640
|
-
case "ES384":
|
|
1641
|
-
case "ES512": {
|
|
1642
|
-
if (!isAlgorithm(key.algorithm, "ECDSA")) throw unusable("ECDSA");
|
|
1643
|
-
const expected = getNamedCurve(alg);
|
|
1644
|
-
if (key.algorithm.namedCurve !== expected) throw unusable(expected, "algorithm.namedCurve");
|
|
1645
|
-
break;
|
|
1646
|
-
}
|
|
1647
|
-
default: throw new TypeError("CryptoKey does not support this operation");
|
|
1648
|
-
}
|
|
1649
|
-
checkUsage(key, usage);
|
|
1650
|
-
}
|
|
1651
|
-
//#endregion
|
|
1652
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/invalid_key_input.js
|
|
1653
|
-
function message(msg, actual, ...types) {
|
|
1654
|
-
types = types.filter(Boolean);
|
|
1655
|
-
if (types.length > 2) {
|
|
1656
|
-
const last = types.pop();
|
|
1657
|
-
msg += `one of type ${types.join(", ")}, or ${last}.`;
|
|
1658
|
-
} else if (types.length === 2) msg += `one of type ${types[0]} or ${types[1]}.`;
|
|
1659
|
-
else msg += `of type ${types[0]}.`;
|
|
1660
|
-
if (actual == null) msg += ` Received ${actual}`;
|
|
1661
|
-
else if (typeof actual === "function" && actual.name) msg += ` Received function ${actual.name}`;
|
|
1662
|
-
else if (typeof actual === "object" && actual != null) {
|
|
1663
|
-
if (actual.constructor?.name) msg += ` Received an instance of ${actual.constructor.name}`;
|
|
1730
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/is_key_like.js
|
|
1731
|
+
const isCryptoKey = (key) => {
|
|
1732
|
+
if (key?.[Symbol.toStringTag] === "CryptoKey") return true;
|
|
1733
|
+
try {
|
|
1734
|
+
return key instanceof CryptoKey;
|
|
1735
|
+
} catch {
|
|
1736
|
+
return false;
|
|
1664
1737
|
}
|
|
1665
|
-
return msg;
|
|
1666
|
-
}
|
|
1667
|
-
var invalid_key_input_default = (actual, ...types) => {
|
|
1668
|
-
return message("Key must be ", actual, ...types);
|
|
1669
1738
|
};
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
}
|
|
1739
|
+
const isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
|
|
1740
|
+
const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
|
|
1673
1741
|
//#endregion
|
|
1674
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1675
|
-
function
|
|
1676
|
-
|
|
1742
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/helpers.js
|
|
1743
|
+
function assertNotSet(value, name) {
|
|
1744
|
+
if (value) throw new TypeError(`${name} can only be called once`);
|
|
1677
1745
|
}
|
|
1678
|
-
function
|
|
1679
|
-
|
|
1746
|
+
function decodeBase64url(value, label, ErrorClass) {
|
|
1747
|
+
try {
|
|
1748
|
+
return decode(value);
|
|
1749
|
+
} catch {
|
|
1750
|
+
throw new ErrorClass(`Failed to base64url decode the ${label}`);
|
|
1751
|
+
}
|
|
1680
1752
|
}
|
|
1681
|
-
var is_key_like_default = (key) => {
|
|
1682
|
-
return isCryptoKey(key) || isKeyObject(key);
|
|
1683
|
-
};
|
|
1684
1753
|
//#endregion
|
|
1685
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1686
|
-
|
|
1754
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/type_checks.js
|
|
1755
|
+
const isObjectLike = (value) => typeof value === "object" && value !== null;
|
|
1756
|
+
function isObject(input) {
|
|
1757
|
+
if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]") return false;
|
|
1758
|
+
if (Object.getPrototypeOf(input) === null) return true;
|
|
1759
|
+
let proto = input;
|
|
1760
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
1761
|
+
return Object.getPrototypeOf(input) === proto;
|
|
1762
|
+
}
|
|
1763
|
+
function isDisjoint(...headers) {
|
|
1687
1764
|
const sources = headers.filter(Boolean);
|
|
1688
1765
|
if (sources.length === 0 || sources.length === 1) return true;
|
|
1689
1766
|
let acc;
|
|
@@ -1699,33 +1776,101 @@ var is_disjoint_default = (...headers) => {
|
|
|
1699
1776
|
}
|
|
1700
1777
|
}
|
|
1701
1778
|
return true;
|
|
1702
|
-
};
|
|
1703
|
-
//#endregion
|
|
1704
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/is_object.js
|
|
1705
|
-
function isObjectLike(value) {
|
|
1706
|
-
return typeof value === "object" && value !== null;
|
|
1707
1779
|
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
1713
|
-
return Object.getPrototypeOf(input) === proto;
|
|
1714
|
-
};
|
|
1780
|
+
const isJWK = (key) => isObject(key) && typeof key.kty === "string";
|
|
1781
|
+
const isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
1782
|
+
const isPublicJWK = (key) => key.kty !== "oct" && key.d === void 0 && key.priv === void 0;
|
|
1783
|
+
const isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
1715
1784
|
//#endregion
|
|
1716
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1717
|
-
|
|
1785
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/signing.js
|
|
1786
|
+
function checkKeyLength(alg, key) {
|
|
1718
1787
|
if (alg.startsWith("RS") || alg.startsWith("PS")) {
|
|
1719
1788
|
const { modulusLength } = key.algorithm;
|
|
1720
1789
|
if (typeof modulusLength !== "number" || modulusLength < 2048) throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
|
|
1721
1790
|
}
|
|
1722
|
-
}
|
|
1791
|
+
}
|
|
1792
|
+
function subtleAlgorithm(alg, algorithm) {
|
|
1793
|
+
const hash = `SHA-${alg.slice(-3)}`;
|
|
1794
|
+
switch (alg) {
|
|
1795
|
+
case "HS256":
|
|
1796
|
+
case "HS384":
|
|
1797
|
+
case "HS512": return {
|
|
1798
|
+
hash,
|
|
1799
|
+
name: "HMAC"
|
|
1800
|
+
};
|
|
1801
|
+
case "PS256":
|
|
1802
|
+
case "PS384":
|
|
1803
|
+
case "PS512": return {
|
|
1804
|
+
hash,
|
|
1805
|
+
name: "RSA-PSS",
|
|
1806
|
+
saltLength: parseInt(alg.slice(-3), 10) >> 3
|
|
1807
|
+
};
|
|
1808
|
+
case "RS256":
|
|
1809
|
+
case "RS384":
|
|
1810
|
+
case "RS512": return {
|
|
1811
|
+
hash,
|
|
1812
|
+
name: "RSASSA-PKCS1-v1_5"
|
|
1813
|
+
};
|
|
1814
|
+
case "ES256":
|
|
1815
|
+
case "ES384":
|
|
1816
|
+
case "ES512": return {
|
|
1817
|
+
hash,
|
|
1818
|
+
name: "ECDSA",
|
|
1819
|
+
namedCurve: algorithm.namedCurve
|
|
1820
|
+
};
|
|
1821
|
+
case "Ed25519":
|
|
1822
|
+
case "EdDSA": return { name: "Ed25519" };
|
|
1823
|
+
case "ML-DSA-44":
|
|
1824
|
+
case "ML-DSA-65":
|
|
1825
|
+
case "ML-DSA-87": return { name: alg };
|
|
1826
|
+
default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
async function getSigKey(alg, key, usage) {
|
|
1830
|
+
if (key instanceof Uint8Array) {
|
|
1831
|
+
if (!alg.startsWith("HS")) throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
1832
|
+
return crypto.subtle.importKey("raw", key, {
|
|
1833
|
+
hash: `SHA-${alg.slice(-3)}`,
|
|
1834
|
+
name: "HMAC"
|
|
1835
|
+
}, false, [usage]);
|
|
1836
|
+
}
|
|
1837
|
+
checkSigCryptoKey(key, alg, usage);
|
|
1838
|
+
return key;
|
|
1839
|
+
}
|
|
1840
|
+
async function sign(alg, key, data) {
|
|
1841
|
+
const cryptoKey = await getSigKey(alg, key, "sign");
|
|
1842
|
+
checkKeyLength(alg, cryptoKey);
|
|
1843
|
+
const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);
|
|
1844
|
+
return new Uint8Array(signature);
|
|
1845
|
+
}
|
|
1846
|
+
async function verify(alg, key, signature, data) {
|
|
1847
|
+
const cryptoKey = await getSigKey(alg, key, "verify");
|
|
1848
|
+
checkKeyLength(alg, cryptoKey);
|
|
1849
|
+
const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);
|
|
1850
|
+
try {
|
|
1851
|
+
return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);
|
|
1852
|
+
} catch {
|
|
1853
|
+
return false;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1723
1856
|
//#endregion
|
|
1724
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1857
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/jwk_to_key.js
|
|
1858
|
+
const unsupportedAlg = "Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value";
|
|
1725
1859
|
function subtleMapping(jwk) {
|
|
1726
1860
|
let algorithm;
|
|
1727
1861
|
let keyUsages;
|
|
1728
1862
|
switch (jwk.kty) {
|
|
1863
|
+
case "AKP":
|
|
1864
|
+
switch (jwk.alg) {
|
|
1865
|
+
case "ML-DSA-44":
|
|
1866
|
+
case "ML-DSA-65":
|
|
1867
|
+
case "ML-DSA-87":
|
|
1868
|
+
algorithm = { name: jwk.alg };
|
|
1869
|
+
keyUsages = jwk.priv ? ["sign"] : ["verify"];
|
|
1870
|
+
break;
|
|
1871
|
+
default: throw new JOSENotSupported(unsupportedAlg);
|
|
1872
|
+
}
|
|
1873
|
+
break;
|
|
1729
1874
|
case "RSA":
|
|
1730
1875
|
switch (jwk.alg) {
|
|
1731
1876
|
case "PS256":
|
|
@@ -1756,29 +1901,21 @@ function subtleMapping(jwk) {
|
|
|
1756
1901
|
};
|
|
1757
1902
|
keyUsages = jwk.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
1758
1903
|
break;
|
|
1759
|
-
default: throw new JOSENotSupported(
|
|
1904
|
+
default: throw new JOSENotSupported(unsupportedAlg);
|
|
1760
1905
|
}
|
|
1761
1906
|
break;
|
|
1762
1907
|
case "EC":
|
|
1763
1908
|
switch (jwk.alg) {
|
|
1764
1909
|
case "ES256":
|
|
1765
|
-
algorithm = {
|
|
1766
|
-
name: "ECDSA",
|
|
1767
|
-
namedCurve: "P-256"
|
|
1768
|
-
};
|
|
1769
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
1770
|
-
break;
|
|
1771
1910
|
case "ES384":
|
|
1772
|
-
algorithm = {
|
|
1773
|
-
name: "ECDSA",
|
|
1774
|
-
namedCurve: "P-384"
|
|
1775
|
-
};
|
|
1776
|
-
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
1777
|
-
break;
|
|
1778
1911
|
case "ES512":
|
|
1779
1912
|
algorithm = {
|
|
1780
1913
|
name: "ECDSA",
|
|
1781
|
-
namedCurve:
|
|
1914
|
+
namedCurve: {
|
|
1915
|
+
ES256: "P-256",
|
|
1916
|
+
ES384: "P-384",
|
|
1917
|
+
ES512: "P-521"
|
|
1918
|
+
}[jwk.alg]
|
|
1782
1919
|
};
|
|
1783
1920
|
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
1784
1921
|
break;
|
|
@@ -1792,7 +1929,7 @@ function subtleMapping(jwk) {
|
|
|
1792
1929
|
};
|
|
1793
1930
|
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
1794
1931
|
break;
|
|
1795
|
-
default: throw new JOSENotSupported(
|
|
1932
|
+
default: throw new JOSENotSupported(unsupportedAlg);
|
|
1796
1933
|
}
|
|
1797
1934
|
break;
|
|
1798
1935
|
case "OKP":
|
|
@@ -1809,7 +1946,7 @@ function subtleMapping(jwk) {
|
|
|
1809
1946
|
algorithm = { name: jwk.crv };
|
|
1810
1947
|
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
1811
1948
|
break;
|
|
1812
|
-
default: throw new JOSENotSupported(
|
|
1949
|
+
default: throw new JOSENotSupported(unsupportedAlg);
|
|
1813
1950
|
}
|
|
1814
1951
|
break;
|
|
1815
1952
|
default: throw new JOSENotSupported("Invalid or unsupported JWK \"kty\" (Key Type) Parameter value");
|
|
@@ -1819,59 +1956,23 @@ function subtleMapping(jwk) {
|
|
|
1819
1956
|
keyUsages
|
|
1820
1957
|
};
|
|
1821
1958
|
}
|
|
1822
|
-
|
|
1959
|
+
async function jwkToKey(jwk) {
|
|
1823
1960
|
if (!jwk.alg) throw new TypeError("\"alg\" argument is required when \"jwk.alg\" is not present");
|
|
1824
1961
|
const { algorithm, keyUsages } = subtleMapping(jwk);
|
|
1825
1962
|
const keyData = { ...jwk };
|
|
1826
|
-
delete keyData.alg;
|
|
1963
|
+
if (keyData.kty !== "AKP") delete keyData.alg;
|
|
1827
1964
|
delete keyData.use;
|
|
1828
|
-
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d ? false : true), jwk.key_ops ?? keyUsages);
|
|
1829
|
-
};
|
|
1830
|
-
//#endregion
|
|
1831
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
1832
|
-
var validate_crit_default = (Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) => {
|
|
1833
|
-
if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
|
|
1834
|
-
if (!protectedHeader || protectedHeader.crit === void 0) return /* @__PURE__ */ new Set();
|
|
1835
|
-
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) throw new Err("\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present");
|
|
1836
|
-
let recognized;
|
|
1837
|
-
if (recognizedOption !== void 0) recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
1838
|
-
else recognized = recognizedDefault;
|
|
1839
|
-
for (const parameter of protectedHeader.crit) {
|
|
1840
|
-
if (!recognized.has(parameter)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
1841
|
-
if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
1842
|
-
if (recognized.get(parameter) && protectedHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
1843
|
-
}
|
|
1844
|
-
return new Set(protectedHeader.crit);
|
|
1845
|
-
};
|
|
1846
|
-
//#endregion
|
|
1847
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/validate_algorithms.js
|
|
1848
|
-
var validate_algorithms_default = (option, algorithms) => {
|
|
1849
|
-
if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
|
|
1850
|
-
if (!algorithms) return;
|
|
1851
|
-
return new Set(algorithms);
|
|
1852
|
-
};
|
|
1853
|
-
//#endregion
|
|
1854
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/is_jwk.js
|
|
1855
|
-
function isJWK(key) {
|
|
1856
|
-
return is_object_default(key) && typeof key.kty === "string";
|
|
1857
|
-
}
|
|
1858
|
-
function isPrivateJWK(key) {
|
|
1859
|
-
return key.kty !== "oct" && typeof key.d === "string";
|
|
1860
|
-
}
|
|
1861
|
-
function isPublicJWK(key) {
|
|
1862
|
-
return key.kty !== "oct" && typeof key.d === "undefined";
|
|
1863
|
-
}
|
|
1864
|
-
function isSecretJWK(key) {
|
|
1865
|
-
return key.kty === "oct" && typeof key.k === "string";
|
|
1965
|
+
return crypto.subtle.importKey("jwk", keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);
|
|
1866
1966
|
}
|
|
1867
1967
|
//#endregion
|
|
1868
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
1968
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/normalize_key.js
|
|
1969
|
+
const unusableForAlg = "given KeyObject instance cannot be used for this algorithm";
|
|
1869
1970
|
let cache;
|
|
1870
1971
|
const handleJWK = async (key, jwk, alg, freeze = false) => {
|
|
1871
1972
|
cache ||= /* @__PURE__ */ new WeakMap();
|
|
1872
1973
|
let cached = cache.get(key);
|
|
1873
1974
|
if (cached?.[alg]) return cached[alg];
|
|
1874
|
-
const cryptoKey = await
|
|
1975
|
+
const cryptoKey = await jwkToKey({
|
|
1875
1976
|
...jwk,
|
|
1876
1977
|
alg
|
|
1877
1978
|
});
|
|
@@ -1893,14 +1994,21 @@ const handleKeyObject = (keyObject, alg) => {
|
|
|
1893
1994
|
case "ECDH-ES+A128KW":
|
|
1894
1995
|
case "ECDH-ES+A192KW":
|
|
1895
1996
|
case "ECDH-ES+A256KW": break;
|
|
1896
|
-
default: throw new TypeError(
|
|
1997
|
+
default: throw new TypeError(unusableForAlg);
|
|
1897
1998
|
}
|
|
1898
1999
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ["deriveBits"]);
|
|
1899
2000
|
}
|
|
1900
2001
|
if (keyObject.asymmetricKeyType === "ed25519") {
|
|
1901
|
-
if (alg !== "EdDSA" && alg !== "Ed25519") throw new TypeError(
|
|
2002
|
+
if (alg !== "EdDSA" && alg !== "Ed25519") throw new TypeError(unusableForAlg);
|
|
1902
2003
|
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [isPublic ? "verify" : "sign"]);
|
|
1903
2004
|
}
|
|
2005
|
+
switch (keyObject.asymmetricKeyType) {
|
|
2006
|
+
case "ml-dsa-44":
|
|
2007
|
+
case "ml-dsa-65":
|
|
2008
|
+
case "ml-dsa-87":
|
|
2009
|
+
if (alg !== keyObject.asymmetricKeyType.toUpperCase()) throw new TypeError(unusableForAlg);
|
|
2010
|
+
cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [isPublic ? "verify" : "sign"]);
|
|
2011
|
+
}
|
|
1904
2012
|
if (keyObject.asymmetricKeyType === "rsa") {
|
|
1905
2013
|
let hash;
|
|
1906
2014
|
switch (alg) {
|
|
@@ -1922,7 +2030,7 @@ const handleKeyObject = (keyObject, alg) => {
|
|
|
1922
2030
|
case "RSA-OAEP-512":
|
|
1923
2031
|
hash = "SHA-512";
|
|
1924
2032
|
break;
|
|
1925
|
-
default: throw new TypeError(
|
|
2033
|
+
default: throw new TypeError(unusableForAlg);
|
|
1926
2034
|
}
|
|
1927
2035
|
if (alg.startsWith("RSA-OAEP")) return keyObject.toCryptoKey({
|
|
1928
2036
|
name: "RSA-OAEP",
|
|
@@ -1939,16 +2047,13 @@ const handleKeyObject = (keyObject, alg) => {
|
|
|
1939
2047
|
["secp384r1", "P-384"],
|
|
1940
2048
|
["secp521r1", "P-521"]
|
|
1941
2049
|
]).get(keyObject.asymmetricKeyDetails?.namedCurve);
|
|
1942
|
-
if (!namedCurve) throw new TypeError(
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
namedCurve
|
|
1950
|
-
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
1951
|
-
if (alg === "ES512" && namedCurve === "P-521") cryptoKey = keyObject.toCryptoKey({
|
|
2050
|
+
if (!namedCurve) throw new TypeError(unusableForAlg);
|
|
2051
|
+
const expectedCurve = {
|
|
2052
|
+
ES256: "P-256",
|
|
2053
|
+
ES384: "P-384",
|
|
2054
|
+
ES512: "P-521"
|
|
2055
|
+
};
|
|
2056
|
+
if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) cryptoKey = keyObject.toCryptoKey({
|
|
1952
2057
|
name: "ECDSA",
|
|
1953
2058
|
namedCurve
|
|
1954
2059
|
}, extractable, [isPublic ? "verify" : "sign"]);
|
|
@@ -1957,12 +2062,12 @@ const handleKeyObject = (keyObject, alg) => {
|
|
|
1957
2062
|
namedCurve
|
|
1958
2063
|
}, extractable, isPublic ? [] : ["deriveBits"]);
|
|
1959
2064
|
}
|
|
1960
|
-
if (!cryptoKey) throw new TypeError(
|
|
2065
|
+
if (!cryptoKey) throw new TypeError(unusableForAlg);
|
|
1961
2066
|
if (!cached) cache.set(keyObject, { [alg]: cryptoKey });
|
|
1962
2067
|
else cached[alg] = cryptoKey;
|
|
1963
2068
|
return cryptoKey;
|
|
1964
2069
|
};
|
|
1965
|
-
|
|
2070
|
+
async function normalizeKey(key, alg) {
|
|
1966
2071
|
if (key instanceof Uint8Array) return key;
|
|
1967
2072
|
if (isCryptoKey(key)) return key;
|
|
1968
2073
|
if (isKeyObject(key)) {
|
|
@@ -1979,9 +2084,32 @@ var normalize_key_default = async (key, alg) => {
|
|
|
1979
2084
|
return handleJWK(key, key, alg, true);
|
|
1980
2085
|
}
|
|
1981
2086
|
throw new Error("unreachable");
|
|
1982
|
-
}
|
|
2087
|
+
}
|
|
2088
|
+
//#endregion
|
|
2089
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/validate_crit.js
|
|
2090
|
+
function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
|
|
2091
|
+
if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0) throw new Err("\"crit\" (Critical) Header Parameter MUST be integrity protected");
|
|
2092
|
+
if (!protectedHeader || protectedHeader.crit === void 0) return /* @__PURE__ */ new Set();
|
|
2093
|
+
if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input !== "string" || input.length === 0)) throw new Err("\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present");
|
|
2094
|
+
let recognized;
|
|
2095
|
+
if (recognizedOption !== void 0) recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);
|
|
2096
|
+
else recognized = recognizedDefault;
|
|
2097
|
+
for (const parameter of protectedHeader.crit) {
|
|
2098
|
+
if (!recognized.has(parameter)) throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
|
|
2099
|
+
if (joseHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" is missing`);
|
|
2100
|
+
if (recognized.get(parameter) && protectedHeader[parameter] === void 0) throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
|
|
2101
|
+
}
|
|
2102
|
+
return new Set(protectedHeader.crit);
|
|
2103
|
+
}
|
|
1983
2104
|
//#endregion
|
|
1984
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2105
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/validate_algorithms.js
|
|
2106
|
+
function validateAlgorithms(option, algorithms) {
|
|
2107
|
+
if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== "string"))) throw new TypeError(`"${option}" option must be an array of strings`);
|
|
2108
|
+
if (!algorithms) return;
|
|
2109
|
+
return new Set(algorithms);
|
|
2110
|
+
}
|
|
2111
|
+
//#endregion
|
|
2112
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/check_key_type.js
|
|
1985
2113
|
const tag = (key) => key?.[Symbol.toStringTag];
|
|
1986
2114
|
const jwkMatchesOp = (alg, key, usage) => {
|
|
1987
2115
|
if (key.use !== void 0) {
|
|
@@ -2031,7 +2159,7 @@ const symmetricTypeCheck = (alg, key, usage) => {
|
|
|
2031
2159
|
if (isSecretJWK(key) && jwkMatchesOp(alg, key, usage)) return;
|
|
2032
2160
|
throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present`);
|
|
2033
2161
|
}
|
|
2034
|
-
if (!
|
|
2162
|
+
if (!isKeyLike(key)) throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
2035
2163
|
if (key.type !== "secret") throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type "secret"`);
|
|
2036
2164
|
};
|
|
2037
2165
|
const asymmetricTypeCheck = (alg, key, usage) => {
|
|
@@ -2039,99 +2167,44 @@ const asymmetricTypeCheck = (alg, key, usage) => {
|
|
|
2039
2167
|
case "decrypt":
|
|
2040
2168
|
case "sign":
|
|
2041
2169
|
if (isPrivateJWK(key) && jwkMatchesOp(alg, key, usage)) return;
|
|
2042
|
-
throw new TypeError(`JSON Web Key for this operation be a private JWK`);
|
|
2170
|
+
throw new TypeError(`JSON Web Key for this operation must be a private JWK`);
|
|
2043
2171
|
case "encrypt":
|
|
2044
2172
|
case "verify":
|
|
2045
2173
|
if (isPublicJWK(key) && jwkMatchesOp(alg, key, usage)) return;
|
|
2046
|
-
throw new TypeError(`JSON Web Key for this operation be a public JWK`);
|
|
2174
|
+
throw new TypeError(`JSON Web Key for this operation must be a public JWK`);
|
|
2047
2175
|
}
|
|
2048
|
-
if (!
|
|
2176
|
+
if (!isKeyLike(key)) throw new TypeError(withAlg(alg, key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
2049
2177
|
if (key.type === "secret") throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
2050
2178
|
if (key.type === "public") switch (usage) {
|
|
2051
2179
|
case "sign": throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
2052
2180
|
case "decrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
2053
|
-
default: break;
|
|
2054
2181
|
}
|
|
2055
2182
|
if (key.type === "private") switch (usage) {
|
|
2056
2183
|
case "verify": throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
2057
2184
|
case "encrypt": throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
2058
|
-
default: break;
|
|
2059
|
-
}
|
|
2060
|
-
};
|
|
2061
|
-
var check_key_type_default = (alg, key, usage) => {
|
|
2062
|
-
if (alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(alg) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(alg)) symmetricTypeCheck(alg, key, usage);
|
|
2063
|
-
else asymmetricTypeCheck(alg, key, usage);
|
|
2064
|
-
};
|
|
2065
|
-
//#endregion
|
|
2066
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/subtle_dsa.js
|
|
2067
|
-
var subtle_dsa_default = (alg, algorithm) => {
|
|
2068
|
-
const hash = `SHA-${alg.slice(-3)}`;
|
|
2069
|
-
switch (alg) {
|
|
2070
|
-
case "HS256":
|
|
2071
|
-
case "HS384":
|
|
2072
|
-
case "HS512": return {
|
|
2073
|
-
hash,
|
|
2074
|
-
name: "HMAC"
|
|
2075
|
-
};
|
|
2076
|
-
case "PS256":
|
|
2077
|
-
case "PS384":
|
|
2078
|
-
case "PS512": return {
|
|
2079
|
-
hash,
|
|
2080
|
-
name: "RSA-PSS",
|
|
2081
|
-
saltLength: parseInt(alg.slice(-3), 10) >> 3
|
|
2082
|
-
};
|
|
2083
|
-
case "RS256":
|
|
2084
|
-
case "RS384":
|
|
2085
|
-
case "RS512": return {
|
|
2086
|
-
hash,
|
|
2087
|
-
name: "RSASSA-PKCS1-v1_5"
|
|
2088
|
-
};
|
|
2089
|
-
case "ES256":
|
|
2090
|
-
case "ES384":
|
|
2091
|
-
case "ES512": return {
|
|
2092
|
-
hash,
|
|
2093
|
-
name: "ECDSA",
|
|
2094
|
-
namedCurve: algorithm.namedCurve
|
|
2095
|
-
};
|
|
2096
|
-
case "Ed25519":
|
|
2097
|
-
case "EdDSA": return { name: "Ed25519" };
|
|
2098
|
-
default: throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
2099
|
-
}
|
|
2100
|
-
};
|
|
2101
|
-
//#endregion
|
|
2102
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/get_sign_verify_key.js
|
|
2103
|
-
var get_sign_verify_key_default = async (alg, key, usage) => {
|
|
2104
|
-
if (key instanceof Uint8Array) {
|
|
2105
|
-
if (!alg.startsWith("HS")) throw new TypeError(invalid_key_input_default(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
2106
|
-
return crypto.subtle.importKey("raw", key, {
|
|
2107
|
-
hash: `SHA-${alg.slice(-3)}`,
|
|
2108
|
-
name: "HMAC"
|
|
2109
|
-
}, false, [usage]);
|
|
2110
2185
|
}
|
|
2111
|
-
checkSigCryptoKey(key, alg, usage);
|
|
2112
|
-
return key;
|
|
2113
2186
|
};
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2187
|
+
function checkKeyType(alg, key, usage) {
|
|
2188
|
+
switch (alg.substring(0, 2)) {
|
|
2189
|
+
case "A1":
|
|
2190
|
+
case "A2":
|
|
2191
|
+
case "di":
|
|
2192
|
+
case "HS":
|
|
2193
|
+
case "PB":
|
|
2194
|
+
symmetricTypeCheck(alg, key, usage);
|
|
2195
|
+
break;
|
|
2196
|
+
default: asymmetricTypeCheck(alg, key, usage);
|
|
2124
2197
|
}
|
|
2125
|
-
}
|
|
2198
|
+
}
|
|
2126
2199
|
//#endregion
|
|
2127
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2200
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jws/flattened/verify.js
|
|
2128
2201
|
async function flattenedVerify(jws, key, options) {
|
|
2129
|
-
if (!
|
|
2202
|
+
if (!isObject(jws)) throw new JWSInvalid("Flattened JWS must be an object");
|
|
2130
2203
|
if (jws.protected === void 0 && jws.header === void 0) throw new JWSInvalid("Flattened JWS must have either of the \"protected\" or \"header\" members");
|
|
2131
2204
|
if (jws.protected !== void 0 && typeof jws.protected !== "string") throw new JWSInvalid("JWS Protected Header incorrect type");
|
|
2132
2205
|
if (jws.payload === void 0) throw new JWSInvalid("JWS Payload missing");
|
|
2133
2206
|
if (typeof jws.signature !== "string") throw new JWSInvalid("JWS Signature missing or incorrect type");
|
|
2134
|
-
if (jws.header !== void 0 && !
|
|
2207
|
+
if (jws.header !== void 0 && !isObject(jws.header)) throw new JWSInvalid("JWS Unprotected Header incorrect type");
|
|
2135
2208
|
let parsedProt = {};
|
|
2136
2209
|
if (jws.protected) try {
|
|
2137
2210
|
const protectedHeader = decode(jws.protected);
|
|
@@ -2139,12 +2212,12 @@ async function flattenedVerify(jws, key, options) {
|
|
|
2139
2212
|
} catch {
|
|
2140
2213
|
throw new JWSInvalid("JWS Protected Header is invalid");
|
|
2141
2214
|
}
|
|
2142
|
-
if (!
|
|
2215
|
+
if (!isDisjoint(parsedProt, jws.header)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
2143
2216
|
const joseHeader = {
|
|
2144
2217
|
...parsedProt,
|
|
2145
2218
|
...jws.header
|
|
2146
2219
|
};
|
|
2147
|
-
const extensions =
|
|
2220
|
+
const extensions = validateCrit(JWSInvalid, new Map([["b64", true]]), options?.crit, parsedProt, joseHeader);
|
|
2148
2221
|
let b64 = true;
|
|
2149
2222
|
if (extensions.has("b64")) {
|
|
2150
2223
|
b64 = parsedProt.b64;
|
|
@@ -2152,7 +2225,7 @@ async function flattenedVerify(jws, key, options) {
|
|
|
2152
2225
|
}
|
|
2153
2226
|
const { alg } = joseHeader;
|
|
2154
2227
|
if (typeof alg !== "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
|
|
2155
|
-
const algorithms = options &&
|
|
2228
|
+
const algorithms = options && validateAlgorithms("algorithms", options.algorithms);
|
|
2156
2229
|
if (algorithms && !algorithms.has(alg)) throw new JOSEAlgNotAllowed("\"alg\" (Algorithm) Header Parameter value not allowed");
|
|
2157
2230
|
if (b64) {
|
|
2158
2231
|
if (typeof jws.payload !== "string") throw new JWSInvalid("JWS Payload must be a string");
|
|
@@ -2162,22 +2235,13 @@ async function flattenedVerify(jws, key, options) {
|
|
|
2162
2235
|
key = await key(parsedProt, jws);
|
|
2163
2236
|
resolvedKey = true;
|
|
2164
2237
|
}
|
|
2165
|
-
|
|
2166
|
-
const data = concat(
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
} catch {
|
|
2171
|
-
throw new JWSInvalid("Failed to base64url decode the signature");
|
|
2172
|
-
}
|
|
2173
|
-
const k = await normalize_key_default(key, alg);
|
|
2174
|
-
if (!await verify_default(alg, k, signature, data)) throw new JWSSignatureVerificationFailed();
|
|
2238
|
+
checkKeyType(alg, key, "verify");
|
|
2239
|
+
const data = concat(jws.protected !== void 0 ? encode$1(jws.protected) : new Uint8Array(), encode$1("."), typeof jws.payload === "string" ? b64 ? encode$1(jws.payload) : encoder.encode(jws.payload) : jws.payload);
|
|
2240
|
+
const signature = decodeBase64url(jws.signature, "signature", JWSInvalid);
|
|
2241
|
+
const k = await normalizeKey(key, alg);
|
|
2242
|
+
if (!await verify(alg, k, signature, data)) throw new JWSSignatureVerificationFailed();
|
|
2175
2243
|
let payload;
|
|
2176
|
-
if (b64)
|
|
2177
|
-
payload = decode(jws.payload);
|
|
2178
|
-
} catch {
|
|
2179
|
-
throw new JWSInvalid("Failed to base64url decode the payload");
|
|
2180
|
-
}
|
|
2244
|
+
if (b64) payload = decodeBase64url(jws.payload, "payload", JWSInvalid);
|
|
2181
2245
|
else if (typeof jws.payload === "string") payload = encoder.encode(jws.payload);
|
|
2182
2246
|
else payload = jws.payload;
|
|
2183
2247
|
const result = { payload };
|
|
@@ -2190,7 +2254,7 @@ async function flattenedVerify(jws, key, options) {
|
|
|
2190
2254
|
return result;
|
|
2191
2255
|
}
|
|
2192
2256
|
//#endregion
|
|
2193
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2257
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jws/compact/verify.js
|
|
2194
2258
|
async function compactVerify(jws, key, options) {
|
|
2195
2259
|
if (jws instanceof Uint8Array) jws = decoder.decode(jws);
|
|
2196
2260
|
if (typeof jws !== "string") throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
|
|
@@ -2212,17 +2276,15 @@ async function compactVerify(jws, key, options) {
|
|
|
2212
2276
|
return result;
|
|
2213
2277
|
}
|
|
2214
2278
|
//#endregion
|
|
2215
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2216
|
-
|
|
2217
|
-
//#endregion
|
|
2218
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/secs.js
|
|
2279
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
2280
|
+
const epoch = (date) => Math.floor(date.getTime() / 1e3);
|
|
2219
2281
|
const minute = 60;
|
|
2220
2282
|
const hour = minute * 60;
|
|
2221
2283
|
const day = hour * 24;
|
|
2222
2284
|
const week = day * 7;
|
|
2223
2285
|
const year = day * 365.25;
|
|
2224
2286
|
const REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
|
|
2225
|
-
|
|
2287
|
+
function secs(str) {
|
|
2226
2288
|
const matched = REGEX.exec(str);
|
|
2227
2289
|
if (!matched || matched[4] && matched[1]) throw new TypeError("Invalid time period format");
|
|
2228
2290
|
const value = parseFloat(matched[2]);
|
|
@@ -2266,14 +2328,15 @@ var secs_default = (str) => {
|
|
|
2266
2328
|
}
|
|
2267
2329
|
if (matched[1] === "-" || matched[4] === "ago") return -numericDate;
|
|
2268
2330
|
return numericDate;
|
|
2269
|
-
}
|
|
2270
|
-
//#endregion
|
|
2271
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
|
|
2331
|
+
}
|
|
2272
2332
|
function validateInput(label, input) {
|
|
2273
2333
|
if (!Number.isFinite(input)) throw new TypeError(`Invalid ${label} input`);
|
|
2274
2334
|
return input;
|
|
2275
2335
|
}
|
|
2276
|
-
const normalizeTyp = (value) =>
|
|
2336
|
+
const normalizeTyp = (value) => {
|
|
2337
|
+
if (value.includes("/")) return value.toLowerCase();
|
|
2338
|
+
return `application/${value.toLowerCase()}`;
|
|
2339
|
+
};
|
|
2277
2340
|
const checkAudiencePresence = (audPayload, audOption) => {
|
|
2278
2341
|
if (typeof audPayload === "string") return audOption.includes(audPayload);
|
|
2279
2342
|
if (Array.isArray(audPayload)) return audOption.some(Set.prototype.has.bind(new Set(audPayload)));
|
|
@@ -2284,7 +2347,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
2284
2347
|
try {
|
|
2285
2348
|
payload = JSON.parse(decoder.decode(encodedPayload));
|
|
2286
2349
|
} catch {}
|
|
2287
|
-
if (!
|
|
2350
|
+
if (!isObject(payload)) throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
|
|
2288
2351
|
const { typ } = options;
|
|
2289
2352
|
if (typ && (typeof protectedHeader.typ !== "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) throw new JWTClaimValidationFailed("unexpected \"typ\" JWT header value", payload, "typ", "check_failed");
|
|
2290
2353
|
const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;
|
|
@@ -2300,7 +2363,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
2300
2363
|
let tolerance;
|
|
2301
2364
|
switch (typeof options.clockTolerance) {
|
|
2302
2365
|
case "string":
|
|
2303
|
-
tolerance =
|
|
2366
|
+
tolerance = secs(options.clockTolerance);
|
|
2304
2367
|
break;
|
|
2305
2368
|
case "number":
|
|
2306
2369
|
tolerance = options.clockTolerance;
|
|
@@ -2311,7 +2374,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
2311
2374
|
default: throw new TypeError("Invalid clockTolerance option type");
|
|
2312
2375
|
}
|
|
2313
2376
|
const { currentDate } = options;
|
|
2314
|
-
const now =
|
|
2377
|
+
const now = epoch(currentDate || /* @__PURE__ */ new Date());
|
|
2315
2378
|
if ((payload.iat !== void 0 || maxTokenAge) && typeof payload.iat !== "number") throw new JWTClaimValidationFailed("\"iat\" claim must be a number", payload, "iat", "invalid");
|
|
2316
2379
|
if (payload.nbf !== void 0) {
|
|
2317
2380
|
if (typeof payload.nbf !== "number") throw new JWTClaimValidationFailed("\"nbf\" claim must be a number", payload, "nbf", "invalid");
|
|
@@ -2323,7 +2386,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
2323
2386
|
}
|
|
2324
2387
|
if (maxTokenAge) {
|
|
2325
2388
|
const age = now - payload.iat;
|
|
2326
|
-
const max = typeof maxTokenAge === "number" ? maxTokenAge :
|
|
2389
|
+
const max = typeof maxTokenAge === "number" ? maxTokenAge : secs(maxTokenAge);
|
|
2327
2390
|
if (age - tolerance > max) throw new JWTExpired("\"iat\" claim timestamp check failed (too far in the past)", payload, "iat", "check_failed");
|
|
2328
2391
|
if (age < 0 - tolerance) throw new JWTClaimValidationFailed("\"iat\" claim timestamp check failed (it should be in the past)", payload, "iat", "check_failed");
|
|
2329
2392
|
}
|
|
@@ -2332,7 +2395,7 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
2332
2395
|
var JWTClaimsBuilder = class {
|
|
2333
2396
|
#payload;
|
|
2334
2397
|
constructor(payload) {
|
|
2335
|
-
if (!
|
|
2398
|
+
if (!isObject(payload)) throw new TypeError("JWT Claims Set MUST be an object");
|
|
2336
2399
|
this.#payload = structuredClone(payload);
|
|
2337
2400
|
}
|
|
2338
2401
|
data() {
|
|
@@ -2361,23 +2424,23 @@ var JWTClaimsBuilder = class {
|
|
|
2361
2424
|
}
|
|
2362
2425
|
set nbf(value) {
|
|
2363
2426
|
if (typeof value === "number") this.#payload.nbf = validateInput("setNotBefore", value);
|
|
2364
|
-
else if (value instanceof Date) this.#payload.nbf = validateInput("setNotBefore",
|
|
2365
|
-
else this.#payload.nbf =
|
|
2427
|
+
else if (value instanceof Date) this.#payload.nbf = validateInput("setNotBefore", epoch(value));
|
|
2428
|
+
else this.#payload.nbf = epoch(/* @__PURE__ */ new Date()) + secs(value);
|
|
2366
2429
|
}
|
|
2367
2430
|
set exp(value) {
|
|
2368
2431
|
if (typeof value === "number") this.#payload.exp = validateInput("setExpirationTime", value);
|
|
2369
|
-
else if (value instanceof Date) this.#payload.exp = validateInput("setExpirationTime",
|
|
2370
|
-
else this.#payload.exp =
|
|
2432
|
+
else if (value instanceof Date) this.#payload.exp = validateInput("setExpirationTime", epoch(value));
|
|
2433
|
+
else this.#payload.exp = epoch(/* @__PURE__ */ new Date()) + secs(value);
|
|
2371
2434
|
}
|
|
2372
2435
|
set iat(value) {
|
|
2373
|
-
if (
|
|
2374
|
-
else if (value instanceof Date) this.#payload.iat = validateInput("setIssuedAt",
|
|
2375
|
-
else if (typeof value === "string") this.#payload.iat = validateInput("setIssuedAt",
|
|
2436
|
+
if (value === void 0) this.#payload.iat = epoch(/* @__PURE__ */ new Date());
|
|
2437
|
+
else if (value instanceof Date) this.#payload.iat = validateInput("setIssuedAt", epoch(value));
|
|
2438
|
+
else if (typeof value === "string") this.#payload.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value));
|
|
2376
2439
|
else this.#payload.iat = validateInput("setIssuedAt", value);
|
|
2377
2440
|
}
|
|
2378
2441
|
};
|
|
2379
2442
|
//#endregion
|
|
2380
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2443
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jwt/verify.js
|
|
2381
2444
|
async function jwtVerify(jwt, key, options) {
|
|
2382
2445
|
const verified = await compactVerify(jwt, key, options);
|
|
2383
2446
|
if (verified.protectedHeader.crit?.includes("b64") && verified.protectedHeader.b64 === false) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
@@ -2392,15 +2455,7 @@ async function jwtVerify(jwt, key, options) {
|
|
|
2392
2455
|
return result;
|
|
2393
2456
|
}
|
|
2394
2457
|
//#endregion
|
|
2395
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2396
|
-
var sign_default = async (alg, key, data) => {
|
|
2397
|
-
const cryptoKey = await get_sign_verify_key_default(alg, key, "sign");
|
|
2398
|
-
check_key_length_default(alg, cryptoKey);
|
|
2399
|
-
const signature = await crypto.subtle.sign(subtle_dsa_default(alg, cryptoKey.algorithm), cryptoKey, data);
|
|
2400
|
-
return new Uint8Array(signature);
|
|
2401
|
-
};
|
|
2402
|
-
//#endregion
|
|
2403
|
-
//#region ../../node_modules/.pnpm/jose@6.0.10/node_modules/jose/dist/webapi/jws/flattened/sign.js
|
|
2458
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jws/flattened/sign.js
|
|
2404
2459
|
var FlattenedSign = class {
|
|
2405
2460
|
#payload;
|
|
2406
2461
|
#protectedHeader;
|
|
@@ -2410,23 +2465,23 @@ var FlattenedSign = class {
|
|
|
2410
2465
|
this.#payload = payload;
|
|
2411
2466
|
}
|
|
2412
2467
|
setProtectedHeader(protectedHeader) {
|
|
2413
|
-
|
|
2468
|
+
assertNotSet(this.#protectedHeader, "setProtectedHeader");
|
|
2414
2469
|
this.#protectedHeader = protectedHeader;
|
|
2415
2470
|
return this;
|
|
2416
2471
|
}
|
|
2417
2472
|
setUnprotectedHeader(unprotectedHeader) {
|
|
2418
|
-
|
|
2473
|
+
assertNotSet(this.#unprotectedHeader, "setUnprotectedHeader");
|
|
2419
2474
|
this.#unprotectedHeader = unprotectedHeader;
|
|
2420
2475
|
return this;
|
|
2421
2476
|
}
|
|
2422
2477
|
async sign(key, options) {
|
|
2423
2478
|
if (!this.#protectedHeader && !this.#unprotectedHeader) throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
2424
|
-
if (!
|
|
2479
|
+
if (!isDisjoint(this.#protectedHeader, this.#unprotectedHeader)) throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
2425
2480
|
const joseHeader = {
|
|
2426
2481
|
...this.#protectedHeader,
|
|
2427
2482
|
...this.#unprotectedHeader
|
|
2428
2483
|
};
|
|
2429
|
-
const extensions =
|
|
2484
|
+
const extensions = validateCrit(JWSInvalid, new Map([["b64", true]]), options?.crit, this.#protectedHeader, joseHeader);
|
|
2430
2485
|
let b64 = true;
|
|
2431
2486
|
if (extensions.has("b64")) {
|
|
2432
2487
|
b64 = this.#protectedHeader.b64;
|
|
@@ -2434,25 +2489,37 @@ var FlattenedSign = class {
|
|
|
2434
2489
|
}
|
|
2435
2490
|
const { alg } = joseHeader;
|
|
2436
2491
|
if (typeof alg !== "string" || !alg) throw new JWSInvalid("JWS \"alg\" (Algorithm) Header Parameter missing or invalid");
|
|
2437
|
-
|
|
2438
|
-
let
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2492
|
+
checkKeyType(alg, key, "sign");
|
|
2493
|
+
let payloadS;
|
|
2494
|
+
let payloadB;
|
|
2495
|
+
if (b64) {
|
|
2496
|
+
payloadS = encode(this.#payload);
|
|
2497
|
+
payloadB = encode$1(payloadS);
|
|
2498
|
+
} else {
|
|
2499
|
+
payloadB = this.#payload;
|
|
2500
|
+
payloadS = "";
|
|
2501
|
+
}
|
|
2502
|
+
let protectedHeaderString;
|
|
2503
|
+
let protectedHeaderBytes;
|
|
2504
|
+
if (this.#protectedHeader) {
|
|
2505
|
+
protectedHeaderString = encode(JSON.stringify(this.#protectedHeader));
|
|
2506
|
+
protectedHeaderBytes = encode$1(protectedHeaderString);
|
|
2507
|
+
} else {
|
|
2508
|
+
protectedHeaderString = "";
|
|
2509
|
+
protectedHeaderBytes = new Uint8Array();
|
|
2510
|
+
}
|
|
2511
|
+
const data = concat(protectedHeaderBytes, encode$1("."), payloadB);
|
|
2444
2512
|
const jws = {
|
|
2445
|
-
signature: encode(await
|
|
2446
|
-
payload:
|
|
2513
|
+
signature: encode(await sign(alg, await normalizeKey(key, alg), data)),
|
|
2514
|
+
payload: payloadS
|
|
2447
2515
|
};
|
|
2448
|
-
if (b64) jws.payload = decoder.decode(payload);
|
|
2449
2516
|
if (this.#unprotectedHeader) jws.header = this.#unprotectedHeader;
|
|
2450
|
-
if (this.#protectedHeader) jws.protected =
|
|
2517
|
+
if (this.#protectedHeader) jws.protected = protectedHeaderString;
|
|
2451
2518
|
return jws;
|
|
2452
2519
|
}
|
|
2453
2520
|
};
|
|
2454
2521
|
//#endregion
|
|
2455
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2522
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jws/compact/sign.js
|
|
2456
2523
|
var CompactSign = class {
|
|
2457
2524
|
#flattened;
|
|
2458
2525
|
constructor(payload) {
|
|
@@ -2469,7 +2536,7 @@ var CompactSign = class {
|
|
|
2469
2536
|
}
|
|
2470
2537
|
};
|
|
2471
2538
|
//#endregion
|
|
2472
|
-
//#region ../../node_modules/.pnpm/jose@6.
|
|
2539
|
+
//#region ../../node_modules/.pnpm/jose@6.2.3/node_modules/jose/dist/webapi/jwt/sign.js
|
|
2473
2540
|
var SignJWT = class {
|
|
2474
2541
|
#protectedHeader;
|
|
2475
2542
|
#jwt;
|