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