@camstack/system 1.1.6 → 1.1.7
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/addon-runner.js +1 -1
- package/dist/addon-runner.mjs +1 -1
- package/dist/auth/totp-manager.d.ts +3 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2992 -5
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2987 -7
- package/dist/builtins/local-auth/local-auth.addon.js +3640 -653
- package/dist/builtins/local-auth/local-auth.addon.mjs +3858 -842
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/index.js +1552 -146
- package/dist/index.mjs +1638 -234
- package/dist/{manifest-python-deps-CUPtSyZ8.js → manifest-python-deps-B3CACH8P.js} +1 -1
- package/dist/{manifest-python-deps-i1IOGMpu.mjs → manifest-python-deps-tH6H06_K.mjs} +1 -2
- package/dist/{resource-monitor-BkP504Vq.mjs → resource-monitor-Le3l0qS2.mjs} +1 -1
- package/package.json +3 -3
- package/dist/chunk-CNf5ZN-e.mjs +0 -37
- package/dist/graceful-fs-BoR9GuPS.mjs +0 -1423
- package/dist/graceful-fs-lg19SZNz.js +0 -1434
- package/dist/main-BOG1xxwD.mjs +0 -9976
- package/dist/main-B_G1JH3Q.js +0 -9983
- package/dist/semver-BQBSy1FJ.mjs +0 -1504
- package/dist/semver-D3n3E_fi.js +0 -1515
- package/dist/tar-BgAEMRBR.js +0 -5434
- package/dist/tar-ByMOPNM0.mjs +0 -5429
|
@@ -1,9 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as require_ms, t as require_semver } from "../../semver-BQBSy1FJ.mjs";
|
|
1
|
+
import { createRequire } from "node:module";
|
|
3
2
|
import { ApiKeyRecordSchema, BaseAddon, ScopedTokenSchema, UserRecordSchema, authProviderCapability, userManagementCapability } from "@camstack/types";
|
|
4
|
-
import * as crypto$
|
|
3
|
+
import * as crypto$1 from "node:crypto";
|
|
5
4
|
import { randomUUID } from "node:crypto";
|
|
6
5
|
import nodeCrypto from "crypto";
|
|
6
|
+
//#region \0rolldown/runtime.js
|
|
7
|
+
var __create = Object.create;
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
14
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
15
|
+
var __exportAll = (all, no_symbols) => {
|
|
16
|
+
let target = {};
|
|
17
|
+
for (var name in all) __defProp(target, name, {
|
|
18
|
+
get: all[name],
|
|
19
|
+
enumerable: true
|
|
20
|
+
});
|
|
21
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
22
|
+
return target;
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
26
|
+
key = keys[i];
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
35
|
+
value: mod,
|
|
36
|
+
enumerable: true
|
|
37
|
+
}) : target, mod));
|
|
38
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
40
|
+
//#endregion
|
|
7
41
|
//#region ../../node_modules/safe-buffer/index.js
|
|
8
42
|
var require_safe_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9
43
|
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
@@ -227,14 +261,14 @@ var require_buffer_equal_constant_time = /* @__PURE__ */ __commonJSMin(((exports
|
|
|
227
261
|
//#region ../../node_modules/jwa/index.js
|
|
228
262
|
var require_jwa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
229
263
|
var Buffer = require_safe_buffer().Buffer;
|
|
230
|
-
var crypto$
|
|
264
|
+
var crypto$2 = __require("crypto");
|
|
231
265
|
var formatEcdsa = require_ecdsa_sig_formatter();
|
|
232
266
|
var util$2 = __require("util");
|
|
233
267
|
var MSG_INVALID_ALGORITHM = "\"%s\" is not a valid algorithm.\n Supported algorithms are:\n \"HS256\", \"HS384\", \"HS512\", \"RS256\", \"RS384\", \"RS512\", \"PS256\", \"PS384\", \"PS512\", \"ES256\", \"ES384\", \"ES512\" and \"none\".";
|
|
234
268
|
var MSG_INVALID_SECRET = "secret must be a string or buffer";
|
|
235
269
|
var MSG_INVALID_VERIFIER_KEY = "key must be a string or a buffer";
|
|
236
270
|
var MSG_INVALID_SIGNER_KEY = "key must be a string, a buffer or an object";
|
|
237
|
-
var supportsKeyObjects = typeof crypto$
|
|
271
|
+
var supportsKeyObjects = typeof crypto$2.createPublicKey === "function";
|
|
238
272
|
if (supportsKeyObjects) {
|
|
239
273
|
MSG_INVALID_VERIFIER_KEY += " or a KeyObject";
|
|
240
274
|
MSG_INVALID_SECRET += "or a KeyObject";
|
|
@@ -287,14 +321,14 @@ var require_jwa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
287
321
|
return function sign(thing, secret) {
|
|
288
322
|
checkIsSecretKey(secret);
|
|
289
323
|
thing = normalizeInput(thing);
|
|
290
|
-
var hmac = crypto$
|
|
324
|
+
var hmac = crypto$2.createHmac("sha" + bits, secret);
|
|
291
325
|
return fromBase64((hmac.update(thing), hmac.digest("base64")));
|
|
292
326
|
};
|
|
293
327
|
}
|
|
294
328
|
var bufferEqual;
|
|
295
|
-
var timingSafeEqual = "timingSafeEqual" in crypto$
|
|
329
|
+
var timingSafeEqual = "timingSafeEqual" in crypto$2 ? function timingSafeEqual(a, b) {
|
|
296
330
|
if (a.byteLength !== b.byteLength) return false;
|
|
297
|
-
return crypto$
|
|
331
|
+
return crypto$2.timingSafeEqual(a, b);
|
|
298
332
|
} : function timingSafeEqual(a, b) {
|
|
299
333
|
if (!bufferEqual) bufferEqual = require_buffer_equal_constant_time();
|
|
300
334
|
return bufferEqual(a, b);
|
|
@@ -309,7 +343,7 @@ var require_jwa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
309
343
|
return function sign(thing, privateKey) {
|
|
310
344
|
checkIsPrivateKey(privateKey);
|
|
311
345
|
thing = normalizeInput(thing);
|
|
312
|
-
var signer = crypto$
|
|
346
|
+
var signer = crypto$2.createSign("RSA-SHA" + bits);
|
|
313
347
|
return fromBase64((signer.update(thing), signer.sign(privateKey, "base64")));
|
|
314
348
|
};
|
|
315
349
|
}
|
|
@@ -318,7 +352,7 @@ var require_jwa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
318
352
|
checkIsPublicKey(publicKey);
|
|
319
353
|
thing = normalizeInput(thing);
|
|
320
354
|
signature = toBase64(signature);
|
|
321
|
-
var verifier = crypto$
|
|
355
|
+
var verifier = crypto$2.createVerify("RSA-SHA" + bits);
|
|
322
356
|
verifier.update(thing);
|
|
323
357
|
return verifier.verify(publicKey, signature, "base64");
|
|
324
358
|
};
|
|
@@ -327,11 +361,11 @@ var require_jwa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
327
361
|
return function sign(thing, privateKey) {
|
|
328
362
|
checkIsPrivateKey(privateKey);
|
|
329
363
|
thing = normalizeInput(thing);
|
|
330
|
-
var signer = crypto$
|
|
364
|
+
var signer = crypto$2.createSign("RSA-SHA" + bits);
|
|
331
365
|
return fromBase64((signer.update(thing), signer.sign({
|
|
332
366
|
key: privateKey,
|
|
333
|
-
padding: crypto$
|
|
334
|
-
saltLength: crypto$
|
|
367
|
+
padding: crypto$2.constants.RSA_PKCS1_PSS_PADDING,
|
|
368
|
+
saltLength: crypto$2.constants.RSA_PSS_SALTLEN_DIGEST
|
|
335
369
|
}, "base64")));
|
|
336
370
|
};
|
|
337
371
|
}
|
|
@@ -340,12 +374,12 @@ var require_jwa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
340
374
|
checkIsPublicKey(publicKey);
|
|
341
375
|
thing = normalizeInput(thing);
|
|
342
376
|
signature = toBase64(signature);
|
|
343
|
-
var verifier = crypto$
|
|
377
|
+
var verifier = crypto$2.createVerify("RSA-SHA" + bits);
|
|
344
378
|
verifier.update(thing);
|
|
345
379
|
return verifier.verify({
|
|
346
380
|
key: publicKey,
|
|
347
|
-
padding: crypto$
|
|
348
|
-
saltLength: crypto$
|
|
381
|
+
padding: crypto$2.constants.RSA_PKCS1_PSS_PADDING,
|
|
382
|
+
saltLength: crypto$2.constants.RSA_PSS_SALTLEN_DIGEST
|
|
349
383
|
}, signature, "base64");
|
|
350
384
|
};
|
|
351
385
|
}
|
|
@@ -674,6 +708,124 @@ var require_TokenExpiredError = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
674
708
|
module.exports = TokenExpiredError;
|
|
675
709
|
}));
|
|
676
710
|
//#endregion
|
|
711
|
+
//#region ../../node_modules/ms/index.js
|
|
712
|
+
var require_ms = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
713
|
+
/**
|
|
714
|
+
* Helpers.
|
|
715
|
+
*/
|
|
716
|
+
var s = 1e3;
|
|
717
|
+
var m = s * 60;
|
|
718
|
+
var h = m * 60;
|
|
719
|
+
var d = h * 24;
|
|
720
|
+
var w = d * 7;
|
|
721
|
+
var y = d * 365.25;
|
|
722
|
+
/**
|
|
723
|
+
* Parse or format the given `val`.
|
|
724
|
+
*
|
|
725
|
+
* Options:
|
|
726
|
+
*
|
|
727
|
+
* - `long` verbose formatting [false]
|
|
728
|
+
*
|
|
729
|
+
* @param {String|Number} val
|
|
730
|
+
* @param {Object} [options]
|
|
731
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
732
|
+
* @return {String|Number}
|
|
733
|
+
* @api public
|
|
734
|
+
*/
|
|
735
|
+
module.exports = function(val, options) {
|
|
736
|
+
options = options || {};
|
|
737
|
+
var type = typeof val;
|
|
738
|
+
if (type === "string" && val.length > 0) return parse(val);
|
|
739
|
+
else if (type === "number" && isFinite(val)) return options.long ? fmtLong(val) : fmtShort(val);
|
|
740
|
+
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
741
|
+
};
|
|
742
|
+
/**
|
|
743
|
+
* Parse the given `str` and return milliseconds.
|
|
744
|
+
*
|
|
745
|
+
* @param {String} str
|
|
746
|
+
* @return {Number}
|
|
747
|
+
* @api private
|
|
748
|
+
*/
|
|
749
|
+
function parse(str) {
|
|
750
|
+
str = String(str);
|
|
751
|
+
if (str.length > 100) return;
|
|
752
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
753
|
+
if (!match) return;
|
|
754
|
+
var n = parseFloat(match[1]);
|
|
755
|
+
switch ((match[2] || "ms").toLowerCase()) {
|
|
756
|
+
case "years":
|
|
757
|
+
case "year":
|
|
758
|
+
case "yrs":
|
|
759
|
+
case "yr":
|
|
760
|
+
case "y": return n * y;
|
|
761
|
+
case "weeks":
|
|
762
|
+
case "week":
|
|
763
|
+
case "w": return n * w;
|
|
764
|
+
case "days":
|
|
765
|
+
case "day":
|
|
766
|
+
case "d": return n * d;
|
|
767
|
+
case "hours":
|
|
768
|
+
case "hour":
|
|
769
|
+
case "hrs":
|
|
770
|
+
case "hr":
|
|
771
|
+
case "h": return n * h;
|
|
772
|
+
case "minutes":
|
|
773
|
+
case "minute":
|
|
774
|
+
case "mins":
|
|
775
|
+
case "min":
|
|
776
|
+
case "m": return n * m;
|
|
777
|
+
case "seconds":
|
|
778
|
+
case "second":
|
|
779
|
+
case "secs":
|
|
780
|
+
case "sec":
|
|
781
|
+
case "s": return n * s;
|
|
782
|
+
case "milliseconds":
|
|
783
|
+
case "millisecond":
|
|
784
|
+
case "msecs":
|
|
785
|
+
case "msec":
|
|
786
|
+
case "ms": return n;
|
|
787
|
+
default: return;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Short format for `ms`.
|
|
792
|
+
*
|
|
793
|
+
* @param {Number} ms
|
|
794
|
+
* @return {String}
|
|
795
|
+
* @api private
|
|
796
|
+
*/
|
|
797
|
+
function fmtShort(ms) {
|
|
798
|
+
var msAbs = Math.abs(ms);
|
|
799
|
+
if (msAbs >= d) return Math.round(ms / d) + "d";
|
|
800
|
+
if (msAbs >= h) return Math.round(ms / h) + "h";
|
|
801
|
+
if (msAbs >= m) return Math.round(ms / m) + "m";
|
|
802
|
+
if (msAbs >= s) return Math.round(ms / s) + "s";
|
|
803
|
+
return ms + "ms";
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Long format for `ms`.
|
|
807
|
+
*
|
|
808
|
+
* @param {Number} ms
|
|
809
|
+
* @return {String}
|
|
810
|
+
* @api private
|
|
811
|
+
*/
|
|
812
|
+
function fmtLong(ms) {
|
|
813
|
+
var msAbs = Math.abs(ms);
|
|
814
|
+
if (msAbs >= d) return plural(ms, msAbs, d, "day");
|
|
815
|
+
if (msAbs >= h) return plural(ms, msAbs, h, "hour");
|
|
816
|
+
if (msAbs >= m) return plural(ms, msAbs, m, "minute");
|
|
817
|
+
if (msAbs >= s) return plural(ms, msAbs, s, "second");
|
|
818
|
+
return ms + " ms";
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Pluralization helper.
|
|
822
|
+
*/
|
|
823
|
+
function plural(ms, msAbs, n, name) {
|
|
824
|
+
var isPlural = msAbs >= n * 1.5;
|
|
825
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
826
|
+
}
|
|
827
|
+
}));
|
|
828
|
+
//#endregion
|
|
677
829
|
//#region ../../node_modules/jsonwebtoken/lib/timespan.js
|
|
678
830
|
var require_timespan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
679
831
|
var ms = require_ms();
|
|
@@ -688,202 +840,1586 @@ var require_timespan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
688
840
|
};
|
|
689
841
|
}));
|
|
690
842
|
//#endregion
|
|
691
|
-
//#region ../../node_modules/
|
|
692
|
-
var
|
|
693
|
-
|
|
843
|
+
//#region ../../node_modules/semver/internal/constants.js
|
|
844
|
+
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
845
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
846
|
+
var MAX_LENGTH = 256;
|
|
847
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
848
|
+
module.exports = {
|
|
849
|
+
MAX_LENGTH,
|
|
850
|
+
MAX_SAFE_COMPONENT_LENGTH: 16,
|
|
851
|
+
MAX_SAFE_BUILD_LENGTH: MAX_LENGTH - 6,
|
|
852
|
+
MAX_SAFE_INTEGER,
|
|
853
|
+
RELEASE_TYPES: [
|
|
854
|
+
"major",
|
|
855
|
+
"premajor",
|
|
856
|
+
"minor",
|
|
857
|
+
"preminor",
|
|
858
|
+
"patch",
|
|
859
|
+
"prepatch",
|
|
860
|
+
"prerelease"
|
|
861
|
+
],
|
|
862
|
+
SEMVER_SPEC_VERSION,
|
|
863
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
864
|
+
FLAG_LOOSE: 2
|
|
865
|
+
};
|
|
694
866
|
}));
|
|
695
867
|
//#endregion
|
|
696
|
-
//#region ../../node_modules/
|
|
697
|
-
var
|
|
698
|
-
module.exports =
|
|
868
|
+
//#region ../../node_modules/semver/internal/debug.js
|
|
869
|
+
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
870
|
+
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
699
871
|
}));
|
|
700
872
|
//#endregion
|
|
701
|
-
//#region ../../node_modules/
|
|
702
|
-
var
|
|
703
|
-
var
|
|
704
|
-
var
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
"PS384",
|
|
722
|
-
"PS512"
|
|
723
|
-
]
|
|
873
|
+
//#region ../../node_modules/semver/internal/re.js
|
|
874
|
+
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
875
|
+
var { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
876
|
+
var debug = require_debug();
|
|
877
|
+
exports = module.exports = {};
|
|
878
|
+
var re = exports.re = [];
|
|
879
|
+
var safeRe = exports.safeRe = [];
|
|
880
|
+
var src = exports.src = [];
|
|
881
|
+
var safeSrc = exports.safeSrc = [];
|
|
882
|
+
var t = exports.t = {};
|
|
883
|
+
var R = 0;
|
|
884
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
885
|
+
var safeRegexReplacements = [
|
|
886
|
+
["\\s", 1],
|
|
887
|
+
["\\d", MAX_LENGTH],
|
|
888
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
889
|
+
];
|
|
890
|
+
var makeSafeRegex = (value) => {
|
|
891
|
+
for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
892
|
+
return value;
|
|
724
893
|
};
|
|
725
|
-
var
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
894
|
+
var createToken = (name, value, isGlobal) => {
|
|
895
|
+
const safe = makeSafeRegex(value);
|
|
896
|
+
const index = R++;
|
|
897
|
+
debug(name, index, value);
|
|
898
|
+
t[name] = index;
|
|
899
|
+
src[index] = value;
|
|
900
|
+
safeSrc[index] = safe;
|
|
901
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
902
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
729
903
|
};
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
904
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
905
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
906
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
907
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
908
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
909
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
910
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
911
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
912
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
913
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
914
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
915
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
916
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
917
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
918
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
919
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
920
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
921
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
922
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
923
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
924
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
925
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
926
|
+
createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
927
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
928
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
929
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
930
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
931
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
932
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
933
|
+
exports.tildeTrimReplace = "$1~";
|
|
934
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
935
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
936
|
+
createToken("LONECARET", "(?:\\^)");
|
|
937
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
938
|
+
exports.caretTrimReplace = "$1^";
|
|
939
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
940
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
941
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
942
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
943
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
944
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
945
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
946
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
947
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
948
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
949
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
950
|
+
}));
|
|
951
|
+
//#endregion
|
|
952
|
+
//#region ../../node_modules/semver/internal/parse-options.js
|
|
953
|
+
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
954
|
+
var looseOption = Object.freeze({ loose: true });
|
|
955
|
+
var emptyOpts = Object.freeze({});
|
|
956
|
+
var parseOptions = (options) => {
|
|
957
|
+
if (!options) return emptyOpts;
|
|
958
|
+
if (typeof options !== "object") return looseOption;
|
|
959
|
+
return options;
|
|
753
960
|
};
|
|
961
|
+
module.exports = parseOptions;
|
|
754
962
|
}));
|
|
755
963
|
//#endregion
|
|
756
|
-
//#region ../../node_modules/
|
|
757
|
-
var
|
|
758
|
-
|
|
964
|
+
//#region ../../node_modules/semver/internal/identifiers.js
|
|
965
|
+
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
966
|
+
var numeric = /^[0-9]+$/;
|
|
967
|
+
var compareIdentifiers = (a, b) => {
|
|
968
|
+
if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
|
|
969
|
+
const anum = numeric.test(a);
|
|
970
|
+
const bnum = numeric.test(b);
|
|
971
|
+
if (anum && bnum) {
|
|
972
|
+
a = +a;
|
|
973
|
+
b = +b;
|
|
974
|
+
}
|
|
975
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
976
|
+
};
|
|
977
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
978
|
+
module.exports = {
|
|
979
|
+
compareIdentifiers,
|
|
980
|
+
rcompareIdentifiers
|
|
981
|
+
};
|
|
759
982
|
}));
|
|
760
983
|
//#endregion
|
|
761
|
-
//#region ../../node_modules/
|
|
762
|
-
var
|
|
763
|
-
var
|
|
764
|
-
var
|
|
765
|
-
var
|
|
766
|
-
var
|
|
767
|
-
var
|
|
768
|
-
var
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
984
|
+
//#region ../../node_modules/semver/classes/semver.js
|
|
985
|
+
var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
986
|
+
var debug = require_debug();
|
|
987
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
988
|
+
var { safeRe: re, t } = require_re();
|
|
989
|
+
var parseOptions = require_parse_options();
|
|
990
|
+
var { compareIdentifiers } = require_identifiers();
|
|
991
|
+
var isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
992
|
+
const identifiers = identifier.split(".");
|
|
993
|
+
if (identifiers.length > prerelease.length) return false;
|
|
994
|
+
for (let i = 0; i < identifiers.length; i++) if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) return false;
|
|
995
|
+
return true;
|
|
996
|
+
};
|
|
997
|
+
module.exports = class SemVer {
|
|
998
|
+
constructor(version, options) {
|
|
999
|
+
options = parseOptions(options);
|
|
1000
|
+
if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
|
|
1001
|
+
else version = version.version;
|
|
1002
|
+
else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
1003
|
+
if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
1004
|
+
debug("SemVer", version, options);
|
|
1005
|
+
this.options = options;
|
|
1006
|
+
this.loose = !!options.loose;
|
|
1007
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
1008
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
1009
|
+
if (!m) throw new TypeError(`Invalid Version: ${version}`);
|
|
1010
|
+
this.raw = version;
|
|
1011
|
+
this.major = +m[1];
|
|
1012
|
+
this.minor = +m[2];
|
|
1013
|
+
this.patch = +m[3];
|
|
1014
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
|
|
1015
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
1016
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
1017
|
+
if (!m[4]) this.prerelease = [];
|
|
1018
|
+
else this.prerelease = m[4].split(".").map((id) => {
|
|
1019
|
+
if (/^[0-9]+$/.test(id)) {
|
|
1020
|
+
const num = +id;
|
|
1021
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
|
|
1022
|
+
}
|
|
1023
|
+
return id;
|
|
1024
|
+
});
|
|
1025
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
1026
|
+
this.format();
|
|
800
1027
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
else done = function(err, data) {
|
|
806
|
-
if (err) throw err;
|
|
807
|
-
return data;
|
|
808
|
-
};
|
|
809
|
-
if (options.clockTimestamp && typeof options.clockTimestamp !== "number") return done(new JsonWebTokenError("clockTimestamp must be a number"));
|
|
810
|
-
if (options.nonce !== void 0 && (typeof options.nonce !== "string" || options.nonce.trim() === "")) return done(new JsonWebTokenError("nonce must be a non-empty string"));
|
|
811
|
-
if (options.allowInvalidAsymmetricKeyTypes !== void 0 && typeof options.allowInvalidAsymmetricKeyTypes !== "boolean") return done(new JsonWebTokenError("allowInvalidAsymmetricKeyTypes must be a boolean"));
|
|
812
|
-
const clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1e3);
|
|
813
|
-
if (!jwtString) return done(new JsonWebTokenError("jwt must be provided"));
|
|
814
|
-
if (typeof jwtString !== "string") return done(new JsonWebTokenError("jwt must be a string"));
|
|
815
|
-
const parts = jwtString.split(".");
|
|
816
|
-
if (parts.length !== 3) return done(new JsonWebTokenError("jwt malformed"));
|
|
817
|
-
let decodedToken;
|
|
818
|
-
try {
|
|
819
|
-
decodedToken = decode(jwtString, { complete: true });
|
|
820
|
-
} catch (err) {
|
|
821
|
-
return done(err);
|
|
1028
|
+
format() {
|
|
1029
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
1030
|
+
if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
|
|
1031
|
+
return this.version;
|
|
822
1032
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
};
|
|
832
|
-
return getSecret(header, function(err, secretOrPublicKey) {
|
|
833
|
-
if (err) return done(new JsonWebTokenError("error in secret or public key callback: " + err.message));
|
|
834
|
-
const hasSignature = parts[2].trim() !== "";
|
|
835
|
-
if (!hasSignature && secretOrPublicKey) return done(new JsonWebTokenError("jwt signature is required"));
|
|
836
|
-
if (hasSignature && !secretOrPublicKey) return done(new JsonWebTokenError("secret or public key must be provided"));
|
|
837
|
-
if (!hasSignature && !options.algorithms) return done(new JsonWebTokenError("please specify \"none\" in \"algorithms\" to verify unsigned tokens"));
|
|
838
|
-
if (secretOrPublicKey != null && !(secretOrPublicKey instanceof KeyObject$1)) try {
|
|
839
|
-
secretOrPublicKey = createPublicKey(secretOrPublicKey);
|
|
840
|
-
} catch (_) {
|
|
841
|
-
try {
|
|
842
|
-
secretOrPublicKey = createSecretKey$1(typeof secretOrPublicKey === "string" ? Buffer.from(secretOrPublicKey) : secretOrPublicKey);
|
|
843
|
-
} catch (_) {
|
|
844
|
-
return done(new JsonWebTokenError("secretOrPublicKey is not valid key material"));
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
if (!options.algorithms) if (secretOrPublicKey.type === "secret") options.algorithms = HS_ALGS;
|
|
848
|
-
else if (["rsa", "rsa-pss"].includes(secretOrPublicKey.asymmetricKeyType)) options.algorithms = RSA_KEY_ALGS;
|
|
849
|
-
else if (secretOrPublicKey.asymmetricKeyType === "ec") options.algorithms = EC_KEY_ALGS;
|
|
850
|
-
else options.algorithms = PUB_KEY_ALGS;
|
|
851
|
-
if (options.algorithms.indexOf(decodedToken.header.alg) === -1) return done(new JsonWebTokenError("invalid algorithm"));
|
|
852
|
-
if (header.alg.startsWith("HS") && secretOrPublicKey.type !== "secret") return done(new JsonWebTokenError(`secretOrPublicKey must be a symmetric key when using ${header.alg}`));
|
|
853
|
-
else if (/^(?:RS|PS|ES)/.test(header.alg) && secretOrPublicKey.type !== "public") return done(new JsonWebTokenError(`secretOrPublicKey must be an asymmetric key when using ${header.alg}`));
|
|
854
|
-
if (!options.allowInvalidAsymmetricKeyTypes) try {
|
|
855
|
-
validateAsymmetricKey(header.alg, secretOrPublicKey);
|
|
856
|
-
} catch (e) {
|
|
857
|
-
return done(e);
|
|
858
|
-
}
|
|
859
|
-
let valid;
|
|
860
|
-
try {
|
|
861
|
-
valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey);
|
|
862
|
-
} catch (e) {
|
|
863
|
-
return done(e);
|
|
864
|
-
}
|
|
865
|
-
if (!valid) return done(new JsonWebTokenError("invalid signature"));
|
|
866
|
-
const payload = decodedToken.payload;
|
|
867
|
-
if (typeof payload.nbf !== "undefined" && !options.ignoreNotBefore) {
|
|
868
|
-
if (typeof payload.nbf !== "number") return done(new JsonWebTokenError("invalid nbf value"));
|
|
869
|
-
if (payload.nbf > clockTimestamp + (options.clockTolerance || 0)) return done(new NotBeforeError("jwt not active", /* @__PURE__ */ new Date(payload.nbf * 1e3)));
|
|
1033
|
+
toString() {
|
|
1034
|
+
return this.version;
|
|
1035
|
+
}
|
|
1036
|
+
compare(other) {
|
|
1037
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
1038
|
+
if (!(other instanceof SemVer)) {
|
|
1039
|
+
if (typeof other === "string" && other === this.version) return 0;
|
|
1040
|
+
other = new SemVer(other, this.options);
|
|
870
1041
|
}
|
|
871
|
-
if (
|
|
872
|
-
|
|
873
|
-
|
|
1042
|
+
if (other.version === this.version) return 0;
|
|
1043
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
1044
|
+
}
|
|
1045
|
+
compareMain(other) {
|
|
1046
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
1047
|
+
if (this.major < other.major) return -1;
|
|
1048
|
+
if (this.major > other.major) return 1;
|
|
1049
|
+
if (this.minor < other.minor) return -1;
|
|
1050
|
+
if (this.minor > other.minor) return 1;
|
|
1051
|
+
if (this.patch < other.patch) return -1;
|
|
1052
|
+
if (this.patch > other.patch) return 1;
|
|
1053
|
+
return 0;
|
|
1054
|
+
}
|
|
1055
|
+
comparePre(other) {
|
|
1056
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
1057
|
+
if (this.prerelease.length && !other.prerelease.length) return -1;
|
|
1058
|
+
else if (!this.prerelease.length && other.prerelease.length) return 1;
|
|
1059
|
+
else if (!this.prerelease.length && !other.prerelease.length) return 0;
|
|
1060
|
+
let i = 0;
|
|
1061
|
+
do {
|
|
1062
|
+
const a = this.prerelease[i];
|
|
1063
|
+
const b = other.prerelease[i];
|
|
1064
|
+
debug("prerelease compare", i, a, b);
|
|
1065
|
+
if (a === void 0 && b === void 0) return 0;
|
|
1066
|
+
else if (b === void 0) return 1;
|
|
1067
|
+
else if (a === void 0) return -1;
|
|
1068
|
+
else if (a === b) continue;
|
|
1069
|
+
else return compareIdentifiers(a, b);
|
|
1070
|
+
} while (++i);
|
|
1071
|
+
}
|
|
1072
|
+
compareBuild(other) {
|
|
1073
|
+
if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
|
|
1074
|
+
let i = 0;
|
|
1075
|
+
do {
|
|
1076
|
+
const a = this.build[i];
|
|
1077
|
+
const b = other.build[i];
|
|
1078
|
+
debug("build compare", i, a, b);
|
|
1079
|
+
if (a === void 0 && b === void 0) return 0;
|
|
1080
|
+
else if (b === void 0) return 1;
|
|
1081
|
+
else if (a === void 0) return -1;
|
|
1082
|
+
else if (a === b) continue;
|
|
1083
|
+
else return compareIdentifiers(a, b);
|
|
1084
|
+
} while (++i);
|
|
1085
|
+
}
|
|
1086
|
+
inc(release, identifier, identifierBase) {
|
|
1087
|
+
if (release.startsWith("pre")) {
|
|
1088
|
+
if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
|
|
1089
|
+
if (identifier) {
|
|
1090
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
1091
|
+
if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
|
|
1092
|
+
}
|
|
874
1093
|
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1094
|
+
switch (release) {
|
|
1095
|
+
case "premajor":
|
|
1096
|
+
this.prerelease.length = 0;
|
|
1097
|
+
this.patch = 0;
|
|
1098
|
+
this.minor = 0;
|
|
1099
|
+
this.major++;
|
|
1100
|
+
this.inc("pre", identifier, identifierBase);
|
|
1101
|
+
break;
|
|
1102
|
+
case "preminor":
|
|
1103
|
+
this.prerelease.length = 0;
|
|
1104
|
+
this.patch = 0;
|
|
1105
|
+
this.minor++;
|
|
1106
|
+
this.inc("pre", identifier, identifierBase);
|
|
1107
|
+
break;
|
|
1108
|
+
case "prepatch":
|
|
1109
|
+
this.prerelease.length = 0;
|
|
1110
|
+
this.inc("patch", identifier, identifierBase);
|
|
1111
|
+
this.inc("pre", identifier, identifierBase);
|
|
1112
|
+
break;
|
|
1113
|
+
case "prerelease":
|
|
1114
|
+
if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
|
|
1115
|
+
this.inc("pre", identifier, identifierBase);
|
|
1116
|
+
break;
|
|
1117
|
+
case "release":
|
|
1118
|
+
if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
|
|
1119
|
+
this.prerelease.length = 0;
|
|
1120
|
+
break;
|
|
1121
|
+
case "major":
|
|
1122
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
|
|
1123
|
+
this.minor = 0;
|
|
1124
|
+
this.patch = 0;
|
|
1125
|
+
this.prerelease = [];
|
|
1126
|
+
break;
|
|
1127
|
+
case "minor":
|
|
1128
|
+
if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
|
|
1129
|
+
this.patch = 0;
|
|
1130
|
+
this.prerelease = [];
|
|
1131
|
+
break;
|
|
1132
|
+
case "patch":
|
|
1133
|
+
if (this.prerelease.length === 0) this.patch++;
|
|
1134
|
+
this.prerelease = [];
|
|
1135
|
+
break;
|
|
1136
|
+
case "pre": {
|
|
1137
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
1138
|
+
if (this.prerelease.length === 0) this.prerelease = [base];
|
|
1139
|
+
else {
|
|
1140
|
+
let i = this.prerelease.length;
|
|
1141
|
+
while (--i >= 0) if (typeof this.prerelease[i] === "number") {
|
|
1142
|
+
this.prerelease[i]++;
|
|
1143
|
+
i = -2;
|
|
1144
|
+
}
|
|
1145
|
+
if (i === -1) {
|
|
1146
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
|
|
1147
|
+
this.prerelease.push(base);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (identifier) {
|
|
1151
|
+
let prerelease = [identifier, base];
|
|
1152
|
+
if (identifierBase === false) prerelease = [identifier];
|
|
1153
|
+
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
1154
|
+
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
1155
|
+
if (isNaN(prereleaseBase)) this.prerelease = prerelease;
|
|
1156
|
+
} else this.prerelease = prerelease;
|
|
1157
|
+
}
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1160
|
+
default: throw new Error(`invalid increment argument: ${release}`);
|
|
882
1161
|
}
|
|
883
|
-
|
|
884
|
-
|
|
1162
|
+
this.raw = this.format();
|
|
1163
|
+
if (this.build.length) this.raw += `+${this.build.join(".")}`;
|
|
1164
|
+
return this;
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
}));
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region ../../node_modules/semver/functions/parse.js
|
|
1170
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1171
|
+
var SemVer = require_semver$1();
|
|
1172
|
+
var parse = (version, options, throwErrors = false) => {
|
|
1173
|
+
if (version instanceof SemVer) return version;
|
|
1174
|
+
try {
|
|
1175
|
+
return new SemVer(version, options);
|
|
1176
|
+
} catch (er) {
|
|
1177
|
+
if (!throwErrors) return null;
|
|
1178
|
+
throw er;
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
module.exports = parse;
|
|
1182
|
+
}));
|
|
1183
|
+
//#endregion
|
|
1184
|
+
//#region ../../node_modules/semver/functions/valid.js
|
|
1185
|
+
var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1186
|
+
var parse = require_parse();
|
|
1187
|
+
var valid = (version, options) => {
|
|
1188
|
+
const v = parse(version, options);
|
|
1189
|
+
return v ? v.version : null;
|
|
1190
|
+
};
|
|
1191
|
+
module.exports = valid;
|
|
1192
|
+
}));
|
|
1193
|
+
//#endregion
|
|
1194
|
+
//#region ../../node_modules/semver/functions/clean.js
|
|
1195
|
+
var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1196
|
+
var parse = require_parse();
|
|
1197
|
+
var clean = (version, options) => {
|
|
1198
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
1199
|
+
return s ? s.version : null;
|
|
1200
|
+
};
|
|
1201
|
+
module.exports = clean;
|
|
1202
|
+
}));
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region ../../node_modules/semver/functions/inc.js
|
|
1205
|
+
var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1206
|
+
var SemVer = require_semver$1();
|
|
1207
|
+
var inc = (version, release, options, identifier, identifierBase) => {
|
|
1208
|
+
if (typeof options === "string") {
|
|
1209
|
+
identifierBase = identifier;
|
|
1210
|
+
identifier = options;
|
|
1211
|
+
options = void 0;
|
|
1212
|
+
}
|
|
1213
|
+
try {
|
|
1214
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
1215
|
+
} catch (er) {
|
|
1216
|
+
return null;
|
|
1217
|
+
}
|
|
1218
|
+
};
|
|
1219
|
+
module.exports = inc;
|
|
1220
|
+
}));
|
|
1221
|
+
//#endregion
|
|
1222
|
+
//#region ../../node_modules/semver/functions/diff.js
|
|
1223
|
+
var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1224
|
+
var parse = require_parse();
|
|
1225
|
+
var diff = (version1, version2) => {
|
|
1226
|
+
const v1 = parse(version1, null, true);
|
|
1227
|
+
const v2 = parse(version2, null, true);
|
|
1228
|
+
const comparison = v1.compare(v2);
|
|
1229
|
+
if (comparison === 0) return null;
|
|
1230
|
+
const v1Higher = comparison > 0;
|
|
1231
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
1232
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
1233
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
1234
|
+
if (!!lowVersion.prerelease.length && !highHasPre) {
|
|
1235
|
+
if (!lowVersion.patch && !lowVersion.minor) return "major";
|
|
1236
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
1237
|
+
if (lowVersion.minor && !lowVersion.patch) return "minor";
|
|
1238
|
+
return "patch";
|
|
885
1239
|
}
|
|
886
|
-
|
|
1240
|
+
}
|
|
1241
|
+
const prefix = highHasPre ? "pre" : "";
|
|
1242
|
+
if (v1.major !== v2.major) return prefix + "major";
|
|
1243
|
+
if (v1.minor !== v2.minor) return prefix + "minor";
|
|
1244
|
+
if (v1.patch !== v2.patch) return prefix + "patch";
|
|
1245
|
+
return "prerelease";
|
|
1246
|
+
};
|
|
1247
|
+
module.exports = diff;
|
|
1248
|
+
}));
|
|
1249
|
+
//#endregion
|
|
1250
|
+
//#region ../../node_modules/semver/functions/major.js
|
|
1251
|
+
var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1252
|
+
var SemVer = require_semver$1();
|
|
1253
|
+
var major = (a, loose) => new SemVer(a, loose).major;
|
|
1254
|
+
module.exports = major;
|
|
1255
|
+
}));
|
|
1256
|
+
//#endregion
|
|
1257
|
+
//#region ../../node_modules/semver/functions/minor.js
|
|
1258
|
+
var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1259
|
+
var SemVer = require_semver$1();
|
|
1260
|
+
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
1261
|
+
module.exports = minor;
|
|
1262
|
+
}));
|
|
1263
|
+
//#endregion
|
|
1264
|
+
//#region ../../node_modules/semver/functions/patch.js
|
|
1265
|
+
var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1266
|
+
var SemVer = require_semver$1();
|
|
1267
|
+
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
1268
|
+
module.exports = patch;
|
|
1269
|
+
}));
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region ../../node_modules/semver/functions/prerelease.js
|
|
1272
|
+
var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1273
|
+
var parse = require_parse();
|
|
1274
|
+
var prerelease = (version, options) => {
|
|
1275
|
+
const parsed = parse(version, options);
|
|
1276
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
1277
|
+
};
|
|
1278
|
+
module.exports = prerelease;
|
|
1279
|
+
}));
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region ../../node_modules/semver/functions/compare.js
|
|
1282
|
+
var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1283
|
+
var SemVer = require_semver$1();
|
|
1284
|
+
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
1285
|
+
module.exports = compare;
|
|
1286
|
+
}));
|
|
1287
|
+
//#endregion
|
|
1288
|
+
//#region ../../node_modules/semver/functions/rcompare.js
|
|
1289
|
+
var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1290
|
+
var compare = require_compare();
|
|
1291
|
+
var rcompare = (a, b, loose) => compare(b, a, loose);
|
|
1292
|
+
module.exports = rcompare;
|
|
1293
|
+
}));
|
|
1294
|
+
//#endregion
|
|
1295
|
+
//#region ../../node_modules/semver/functions/compare-loose.js
|
|
1296
|
+
var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1297
|
+
var compare = require_compare();
|
|
1298
|
+
var compareLoose = (a, b) => compare(a, b, true);
|
|
1299
|
+
module.exports = compareLoose;
|
|
1300
|
+
}));
|
|
1301
|
+
//#endregion
|
|
1302
|
+
//#region ../../node_modules/semver/functions/compare-build.js
|
|
1303
|
+
var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1304
|
+
var SemVer = require_semver$1();
|
|
1305
|
+
var compareBuild = (a, b, loose) => {
|
|
1306
|
+
const versionA = new SemVer(a, loose);
|
|
1307
|
+
const versionB = new SemVer(b, loose);
|
|
1308
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
1309
|
+
};
|
|
1310
|
+
module.exports = compareBuild;
|
|
1311
|
+
}));
|
|
1312
|
+
//#endregion
|
|
1313
|
+
//#region ../../node_modules/semver/functions/sort.js
|
|
1314
|
+
var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1315
|
+
var compareBuild = require_compare_build();
|
|
1316
|
+
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
1317
|
+
module.exports = sort;
|
|
1318
|
+
}));
|
|
1319
|
+
//#endregion
|
|
1320
|
+
//#region ../../node_modules/semver/functions/rsort.js
|
|
1321
|
+
var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1322
|
+
var compareBuild = require_compare_build();
|
|
1323
|
+
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
1324
|
+
module.exports = rsort;
|
|
1325
|
+
}));
|
|
1326
|
+
//#endregion
|
|
1327
|
+
//#region ../../node_modules/semver/functions/gt.js
|
|
1328
|
+
var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1329
|
+
var compare = require_compare();
|
|
1330
|
+
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
1331
|
+
module.exports = gt;
|
|
1332
|
+
}));
|
|
1333
|
+
//#endregion
|
|
1334
|
+
//#region ../../node_modules/semver/functions/lt.js
|
|
1335
|
+
var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1336
|
+
var compare = require_compare();
|
|
1337
|
+
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
1338
|
+
module.exports = lt;
|
|
1339
|
+
}));
|
|
1340
|
+
//#endregion
|
|
1341
|
+
//#region ../../node_modules/semver/functions/eq.js
|
|
1342
|
+
var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1343
|
+
var compare = require_compare();
|
|
1344
|
+
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
1345
|
+
module.exports = eq;
|
|
1346
|
+
}));
|
|
1347
|
+
//#endregion
|
|
1348
|
+
//#region ../../node_modules/semver/functions/neq.js
|
|
1349
|
+
var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1350
|
+
var compare = require_compare();
|
|
1351
|
+
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
1352
|
+
module.exports = neq;
|
|
1353
|
+
}));
|
|
1354
|
+
//#endregion
|
|
1355
|
+
//#region ../../node_modules/semver/functions/gte.js
|
|
1356
|
+
var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1357
|
+
var compare = require_compare();
|
|
1358
|
+
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
1359
|
+
module.exports = gte;
|
|
1360
|
+
}));
|
|
1361
|
+
//#endregion
|
|
1362
|
+
//#region ../../node_modules/semver/functions/lte.js
|
|
1363
|
+
var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1364
|
+
var compare = require_compare();
|
|
1365
|
+
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
1366
|
+
module.exports = lte;
|
|
1367
|
+
}));
|
|
1368
|
+
//#endregion
|
|
1369
|
+
//#region ../../node_modules/semver/functions/cmp.js
|
|
1370
|
+
var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1371
|
+
var eq = require_eq();
|
|
1372
|
+
var neq = require_neq();
|
|
1373
|
+
var gt = require_gt();
|
|
1374
|
+
var gte = require_gte();
|
|
1375
|
+
var lt = require_lt();
|
|
1376
|
+
var lte = require_lte();
|
|
1377
|
+
var cmp = (a, op, b, loose) => {
|
|
1378
|
+
switch (op) {
|
|
1379
|
+
case "===":
|
|
1380
|
+
if (typeof a === "object") a = a.version;
|
|
1381
|
+
if (typeof b === "object") b = b.version;
|
|
1382
|
+
return a === b;
|
|
1383
|
+
case "!==":
|
|
1384
|
+
if (typeof a === "object") a = a.version;
|
|
1385
|
+
if (typeof b === "object") b = b.version;
|
|
1386
|
+
return a !== b;
|
|
1387
|
+
case "":
|
|
1388
|
+
case "=":
|
|
1389
|
+
case "==": return eq(a, b, loose);
|
|
1390
|
+
case "!=": return neq(a, b, loose);
|
|
1391
|
+
case ">": return gt(a, b, loose);
|
|
1392
|
+
case ">=": return gte(a, b, loose);
|
|
1393
|
+
case "<": return lt(a, b, loose);
|
|
1394
|
+
case "<=": return lte(a, b, loose);
|
|
1395
|
+
default: throw new TypeError(`Invalid operator: ${op}`);
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
module.exports = cmp;
|
|
1399
|
+
}));
|
|
1400
|
+
//#endregion
|
|
1401
|
+
//#region ../../node_modules/semver/functions/coerce.js
|
|
1402
|
+
var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1403
|
+
var SemVer = require_semver$1();
|
|
1404
|
+
var parse = require_parse();
|
|
1405
|
+
var { safeRe: re, t } = require_re();
|
|
1406
|
+
var coerce = (version, options) => {
|
|
1407
|
+
if (version instanceof SemVer) return version;
|
|
1408
|
+
if (typeof version === "number") version = String(version);
|
|
1409
|
+
if (typeof version !== "string") return null;
|
|
1410
|
+
options = options || {};
|
|
1411
|
+
let match = null;
|
|
1412
|
+
if (!options.rtl) match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
1413
|
+
else {
|
|
1414
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
1415
|
+
let next;
|
|
1416
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
1417
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
|
|
1418
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
1419
|
+
}
|
|
1420
|
+
coerceRtlRegex.lastIndex = -1;
|
|
1421
|
+
}
|
|
1422
|
+
if (match === null) return null;
|
|
1423
|
+
const major = match[2];
|
|
1424
|
+
return parse(`${major}.${match[3] || "0"}.${match[4] || "0"}${options.includePrerelease && match[5] ? `-${match[5]}` : ""}${options.includePrerelease && match[6] ? `+${match[6]}` : ""}`, options);
|
|
1425
|
+
};
|
|
1426
|
+
module.exports = coerce;
|
|
1427
|
+
}));
|
|
1428
|
+
//#endregion
|
|
1429
|
+
//#region ../../node_modules/semver/functions/truncate.js
|
|
1430
|
+
var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1431
|
+
var parse = require_parse();
|
|
1432
|
+
var constants = require_constants();
|
|
1433
|
+
var SemVer = require_semver$1();
|
|
1434
|
+
var truncate = (version, truncation, options) => {
|
|
1435
|
+
if (!constants.RELEASE_TYPES.includes(truncation)) return null;
|
|
1436
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
1437
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
1438
|
+
};
|
|
1439
|
+
var cloneInputVersion = (version, options) => {
|
|
1440
|
+
return parse(version instanceof SemVer ? version.version : version, options);
|
|
1441
|
+
};
|
|
1442
|
+
var doTruncation = (version, truncation) => {
|
|
1443
|
+
if (isPrerelease(truncation)) return version.version;
|
|
1444
|
+
version.prerelease = [];
|
|
1445
|
+
switch (truncation) {
|
|
1446
|
+
case "major":
|
|
1447
|
+
version.minor = 0;
|
|
1448
|
+
version.patch = 0;
|
|
1449
|
+
break;
|
|
1450
|
+
case "minor":
|
|
1451
|
+
version.patch = 0;
|
|
1452
|
+
break;
|
|
1453
|
+
}
|
|
1454
|
+
return version.format();
|
|
1455
|
+
};
|
|
1456
|
+
var isPrerelease = (type) => {
|
|
1457
|
+
return type.startsWith("pre");
|
|
1458
|
+
};
|
|
1459
|
+
module.exports = truncate;
|
|
1460
|
+
}));
|
|
1461
|
+
//#endregion
|
|
1462
|
+
//#region ../../node_modules/semver/internal/lrucache.js
|
|
1463
|
+
var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1464
|
+
var LRUCache = class {
|
|
1465
|
+
constructor() {
|
|
1466
|
+
this.max = 1e3;
|
|
1467
|
+
this.map = /* @__PURE__ */ new Map();
|
|
1468
|
+
}
|
|
1469
|
+
get(key) {
|
|
1470
|
+
const value = this.map.get(key);
|
|
1471
|
+
if (value === void 0) return;
|
|
1472
|
+
else {
|
|
1473
|
+
this.map.delete(key);
|
|
1474
|
+
this.map.set(key, value);
|
|
1475
|
+
return value;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
delete(key) {
|
|
1479
|
+
return this.map.delete(key);
|
|
1480
|
+
}
|
|
1481
|
+
set(key, value) {
|
|
1482
|
+
if (!this.delete(key) && value !== void 0) {
|
|
1483
|
+
if (this.map.size >= this.max) {
|
|
1484
|
+
const firstKey = this.map.keys().next().value;
|
|
1485
|
+
this.delete(firstKey);
|
|
1486
|
+
}
|
|
1487
|
+
this.map.set(key, value);
|
|
1488
|
+
}
|
|
1489
|
+
return this;
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
module.exports = LRUCache;
|
|
1493
|
+
}));
|
|
1494
|
+
//#endregion
|
|
1495
|
+
//#region ../../node_modules/semver/classes/range.js
|
|
1496
|
+
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1497
|
+
var SPACE_CHARACTERS = /\s+/g;
|
|
1498
|
+
module.exports = class Range {
|
|
1499
|
+
constructor(range, options) {
|
|
1500
|
+
options = parseOptions(options);
|
|
1501
|
+
if (range instanceof Range) if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
|
|
1502
|
+
else return new Range(range.raw, options);
|
|
1503
|
+
if (range instanceof Comparator) {
|
|
1504
|
+
this.raw = range.value;
|
|
1505
|
+
this.set = [[range]];
|
|
1506
|
+
this.formatted = void 0;
|
|
1507
|
+
return this;
|
|
1508
|
+
}
|
|
1509
|
+
this.options = options;
|
|
1510
|
+
this.loose = !!options.loose;
|
|
1511
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
1512
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
1513
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
1514
|
+
if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
1515
|
+
if (this.set.length > 1) {
|
|
1516
|
+
const first = this.set[0];
|
|
1517
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
1518
|
+
if (this.set.length === 0) this.set = [first];
|
|
1519
|
+
else if (this.set.length > 1) {
|
|
1520
|
+
for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
|
|
1521
|
+
this.set = [c];
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
this.formatted = void 0;
|
|
1527
|
+
}
|
|
1528
|
+
get range() {
|
|
1529
|
+
if (this.formatted === void 0) {
|
|
1530
|
+
this.formatted = "";
|
|
1531
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1532
|
+
if (i > 0) this.formatted += "||";
|
|
1533
|
+
const comps = this.set[i];
|
|
1534
|
+
for (let k = 0; k < comps.length; k++) {
|
|
1535
|
+
if (k > 0) this.formatted += " ";
|
|
1536
|
+
this.formatted += comps[k].toString().trim();
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return this.formatted;
|
|
1541
|
+
}
|
|
1542
|
+
format() {
|
|
1543
|
+
return this.range;
|
|
1544
|
+
}
|
|
1545
|
+
toString() {
|
|
1546
|
+
return this.range;
|
|
1547
|
+
}
|
|
1548
|
+
parseRange(range) {
|
|
1549
|
+
range = range.replace(BUILDSTRIPRE, "");
|
|
1550
|
+
const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
|
|
1551
|
+
const cached = cache.get(memoKey);
|
|
1552
|
+
if (cached) return cached;
|
|
1553
|
+
const loose = this.options.loose;
|
|
1554
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
1555
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
1556
|
+
debug("hyphen replace", range);
|
|
1557
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
1558
|
+
debug("comparator trim", range);
|
|
1559
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
1560
|
+
debug("tilde trim", range);
|
|
1561
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
1562
|
+
debug("caret trim", range);
|
|
1563
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
1564
|
+
if (loose) rangeList = rangeList.filter((comp) => {
|
|
1565
|
+
debug("loose invalid filter", comp, this.options);
|
|
1566
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
1567
|
+
});
|
|
1568
|
+
debug("range list", rangeList);
|
|
1569
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
1570
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
1571
|
+
for (const comp of comparators) {
|
|
1572
|
+
if (isNullSet(comp)) return [comp];
|
|
1573
|
+
rangeMap.set(comp.value, comp);
|
|
1574
|
+
}
|
|
1575
|
+
if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
|
|
1576
|
+
const result = [...rangeMap.values()];
|
|
1577
|
+
cache.set(memoKey, result);
|
|
1578
|
+
return result;
|
|
1579
|
+
}
|
|
1580
|
+
intersects(range, options) {
|
|
1581
|
+
if (!(range instanceof Range)) throw new TypeError("a Range is required");
|
|
1582
|
+
return this.set.some((thisComparators) => {
|
|
1583
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
1584
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
1585
|
+
return rangeComparators.every((rangeComparator) => {
|
|
1586
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
1587
|
+
});
|
|
1588
|
+
});
|
|
1589
|
+
});
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
test(version) {
|
|
1593
|
+
if (!version) return false;
|
|
1594
|
+
if (typeof version === "string") try {
|
|
1595
|
+
version = new SemVer(version, this.options);
|
|
1596
|
+
} catch (er) {
|
|
1597
|
+
return false;
|
|
1598
|
+
}
|
|
1599
|
+
for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
|
|
1600
|
+
return false;
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
var cache = new (require_lrucache())();
|
|
1604
|
+
var parseOptions = require_parse_options();
|
|
1605
|
+
var Comparator = require_comparator();
|
|
1606
|
+
var debug = require_debug();
|
|
1607
|
+
var SemVer = require_semver$1();
|
|
1608
|
+
var { safeRe: re, src, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
|
|
1609
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
1610
|
+
var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
1611
|
+
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
1612
|
+
var isAny = (c) => c.value === "";
|
|
1613
|
+
var isSatisfiable = (comparators, options) => {
|
|
1614
|
+
let result = true;
|
|
1615
|
+
const remainingComparators = comparators.slice();
|
|
1616
|
+
let testComparator = remainingComparators.pop();
|
|
1617
|
+
while (result && remainingComparators.length) {
|
|
1618
|
+
result = remainingComparators.every((otherComparator) => {
|
|
1619
|
+
return testComparator.intersects(otherComparator, options);
|
|
1620
|
+
});
|
|
1621
|
+
testComparator = remainingComparators.pop();
|
|
1622
|
+
}
|
|
1623
|
+
return result;
|
|
1624
|
+
};
|
|
1625
|
+
var parseComparator = (comp, options) => {
|
|
1626
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
1627
|
+
debug("comp", comp, options);
|
|
1628
|
+
comp = replaceCarets(comp, options);
|
|
1629
|
+
debug("caret", comp);
|
|
1630
|
+
comp = replaceTildes(comp, options);
|
|
1631
|
+
debug("tildes", comp);
|
|
1632
|
+
comp = replaceXRanges(comp, options);
|
|
1633
|
+
debug("xrange", comp);
|
|
1634
|
+
comp = replaceStars(comp, options);
|
|
1635
|
+
debug("stars", comp);
|
|
1636
|
+
return comp;
|
|
1637
|
+
};
|
|
1638
|
+
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
1639
|
+
var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
1640
|
+
var replaceTildes = (comp, options) => {
|
|
1641
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
1642
|
+
};
|
|
1643
|
+
var replaceTilde = (comp, options) => {
|
|
1644
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1645
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1646
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1647
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
1648
|
+
let ret;
|
|
1649
|
+
if (isX(M)) ret = "";
|
|
1650
|
+
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1651
|
+
else if (isX(p)) ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1652
|
+
else if (pr) {
|
|
1653
|
+
debug("replaceTilde pr", pr);
|
|
1654
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1655
|
+
} else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1656
|
+
debug("tilde return", ret);
|
|
1657
|
+
return ret;
|
|
1658
|
+
});
|
|
1659
|
+
};
|
|
1660
|
+
var replaceCarets = (comp, options) => {
|
|
1661
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
1662
|
+
};
|
|
1663
|
+
var replaceCaret = (comp, options) => {
|
|
1664
|
+
debug("caret", comp, options);
|
|
1665
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1666
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1667
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1668
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
1669
|
+
let ret;
|
|
1670
|
+
if (isX(M)) ret = "";
|
|
1671
|
+
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1672
|
+
else if (isX(p)) if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1673
|
+
else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
1674
|
+
else if (pr) {
|
|
1675
|
+
debug("replaceCaret pr", pr);
|
|
1676
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1677
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1678
|
+
else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1679
|
+
} else {
|
|
1680
|
+
debug("no pr");
|
|
1681
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
1682
|
+
else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1683
|
+
else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1684
|
+
}
|
|
1685
|
+
debug("caret return", ret);
|
|
1686
|
+
return ret;
|
|
1687
|
+
});
|
|
1688
|
+
};
|
|
1689
|
+
var replaceXRanges = (comp, options) => {
|
|
1690
|
+
debug("replaceXRanges", comp, options);
|
|
1691
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
1692
|
+
};
|
|
1693
|
+
var replaceXRange = (comp, options) => {
|
|
1694
|
+
comp = comp.trim();
|
|
1695
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1696
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1697
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1698
|
+
if (invalidXRangeOrder(M, m, p)) return comp;
|
|
1699
|
+
const xM = isX(M);
|
|
1700
|
+
const xm = xM || isX(m);
|
|
1701
|
+
const xp = xm || isX(p);
|
|
1702
|
+
const anyX = xp;
|
|
1703
|
+
if (gtlt === "=" && anyX) gtlt = "";
|
|
1704
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
1705
|
+
if (xM) if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
|
|
1706
|
+
else ret = "*";
|
|
1707
|
+
else if (gtlt && anyX) {
|
|
1708
|
+
if (xm) m = 0;
|
|
1709
|
+
p = 0;
|
|
1710
|
+
if (gtlt === ">") {
|
|
1711
|
+
gtlt = ">=";
|
|
1712
|
+
if (xm) {
|
|
1713
|
+
M = +M + 1;
|
|
1714
|
+
m = 0;
|
|
1715
|
+
p = 0;
|
|
1716
|
+
} else {
|
|
1717
|
+
m = +m + 1;
|
|
1718
|
+
p = 0;
|
|
1719
|
+
}
|
|
1720
|
+
} else if (gtlt === "<=") {
|
|
1721
|
+
gtlt = "<";
|
|
1722
|
+
if (xm) M = +M + 1;
|
|
1723
|
+
else m = +m + 1;
|
|
1724
|
+
}
|
|
1725
|
+
if (gtlt === "<") pr = "-0";
|
|
1726
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
1727
|
+
} else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
1728
|
+
else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
1729
|
+
debug("xRange return", ret);
|
|
1730
|
+
return ret;
|
|
1731
|
+
});
|
|
1732
|
+
};
|
|
1733
|
+
var replaceStars = (comp, options) => {
|
|
1734
|
+
debug("replaceStars", comp, options);
|
|
1735
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
1736
|
+
};
|
|
1737
|
+
var replaceGTE0 = (comp, options) => {
|
|
1738
|
+
debug("replaceGTE0", comp, options);
|
|
1739
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
1740
|
+
};
|
|
1741
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
1742
|
+
if (isX(fM)) from = "";
|
|
1743
|
+
else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
1744
|
+
else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
1745
|
+
else if (fpr) from = `>=${from}`;
|
|
1746
|
+
else from = `>=${from}${incPr ? "-0" : ""}`;
|
|
1747
|
+
if (isX(tM)) to = "";
|
|
1748
|
+
else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
|
|
1749
|
+
else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
|
|
1750
|
+
else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
1751
|
+
else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
1752
|
+
else to = `<=${to}`;
|
|
1753
|
+
return `${from} ${to}`.trim();
|
|
1754
|
+
};
|
|
1755
|
+
var testSet = (set, version, options) => {
|
|
1756
|
+
for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
|
|
1757
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
1758
|
+
for (let i = 0; i < set.length; i++) {
|
|
1759
|
+
debug(set[i].semver);
|
|
1760
|
+
if (set[i].semver === Comparator.ANY) continue;
|
|
1761
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
1762
|
+
const allowed = set[i].semver;
|
|
1763
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return false;
|
|
1767
|
+
}
|
|
1768
|
+
return true;
|
|
1769
|
+
};
|
|
1770
|
+
}));
|
|
1771
|
+
//#endregion
|
|
1772
|
+
//#region ../../node_modules/semver/classes/comparator.js
|
|
1773
|
+
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1774
|
+
var ANY = Symbol("SemVer ANY");
|
|
1775
|
+
module.exports = class Comparator {
|
|
1776
|
+
static get ANY() {
|
|
1777
|
+
return ANY;
|
|
1778
|
+
}
|
|
1779
|
+
constructor(comp, options) {
|
|
1780
|
+
options = parseOptions(options);
|
|
1781
|
+
if (comp instanceof Comparator) if (comp.loose === !!options.loose) return comp;
|
|
1782
|
+
else comp = comp.value;
|
|
1783
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
1784
|
+
debug("comparator", comp, options);
|
|
1785
|
+
this.options = options;
|
|
1786
|
+
this.loose = !!options.loose;
|
|
1787
|
+
this.parse(comp);
|
|
1788
|
+
if (this.semver === ANY) this.value = "";
|
|
1789
|
+
else this.value = this.operator + this.semver.version;
|
|
1790
|
+
debug("comp", this);
|
|
1791
|
+
}
|
|
1792
|
+
parse(comp) {
|
|
1793
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
1794
|
+
const m = comp.match(r);
|
|
1795
|
+
if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
|
|
1796
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
1797
|
+
if (this.operator === "=") this.operator = "";
|
|
1798
|
+
if (!m[2]) this.semver = ANY;
|
|
1799
|
+
else this.semver = new SemVer(m[2], this.options.loose);
|
|
1800
|
+
}
|
|
1801
|
+
toString() {
|
|
1802
|
+
return this.value;
|
|
1803
|
+
}
|
|
1804
|
+
test(version) {
|
|
1805
|
+
debug("Comparator.test", version, this.options.loose);
|
|
1806
|
+
if (this.semver === ANY || version === ANY) return true;
|
|
1807
|
+
if (typeof version === "string") try {
|
|
1808
|
+
version = new SemVer(version, this.options);
|
|
1809
|
+
} catch (er) {
|
|
1810
|
+
return false;
|
|
1811
|
+
}
|
|
1812
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
1813
|
+
}
|
|
1814
|
+
intersects(comp, options) {
|
|
1815
|
+
if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
|
|
1816
|
+
if (this.operator === "") {
|
|
1817
|
+
if (this.value === "") return true;
|
|
1818
|
+
return new Range(comp.value, options).test(this.value);
|
|
1819
|
+
} else if (comp.operator === "") {
|
|
1820
|
+
if (comp.value === "") return true;
|
|
1821
|
+
return new Range(this.value, options).test(comp.semver);
|
|
1822
|
+
}
|
|
1823
|
+
options = parseOptions(options);
|
|
1824
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
|
|
1825
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
|
|
1826
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
|
|
1827
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
|
|
1828
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
|
|
1829
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
|
|
1830
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
|
|
1831
|
+
return false;
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
var parseOptions = require_parse_options();
|
|
1835
|
+
var { safeRe: re, t } = require_re();
|
|
1836
|
+
var cmp = require_cmp();
|
|
1837
|
+
var debug = require_debug();
|
|
1838
|
+
var SemVer = require_semver$1();
|
|
1839
|
+
var Range = require_range();
|
|
1840
|
+
}));
|
|
1841
|
+
//#endregion
|
|
1842
|
+
//#region ../../node_modules/semver/functions/satisfies.js
|
|
1843
|
+
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1844
|
+
var Range = require_range();
|
|
1845
|
+
var satisfies = (version, range, options) => {
|
|
1846
|
+
try {
|
|
1847
|
+
range = new Range(range, options);
|
|
1848
|
+
} catch (er) {
|
|
1849
|
+
return false;
|
|
1850
|
+
}
|
|
1851
|
+
return range.test(version);
|
|
1852
|
+
};
|
|
1853
|
+
module.exports = satisfies;
|
|
1854
|
+
}));
|
|
1855
|
+
//#endregion
|
|
1856
|
+
//#region ../../node_modules/semver/ranges/to-comparators.js
|
|
1857
|
+
var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1858
|
+
var Range = require_range();
|
|
1859
|
+
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1860
|
+
module.exports = toComparators;
|
|
1861
|
+
}));
|
|
1862
|
+
//#endregion
|
|
1863
|
+
//#region ../../node_modules/semver/ranges/max-satisfying.js
|
|
1864
|
+
var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1865
|
+
var SemVer = require_semver$1();
|
|
1866
|
+
var Range = require_range();
|
|
1867
|
+
var maxSatisfying = (versions, range, options) => {
|
|
1868
|
+
let max = null;
|
|
1869
|
+
let maxSV = null;
|
|
1870
|
+
let rangeObj = null;
|
|
1871
|
+
try {
|
|
1872
|
+
rangeObj = new Range(range, options);
|
|
1873
|
+
} catch (er) {
|
|
1874
|
+
return null;
|
|
1875
|
+
}
|
|
1876
|
+
versions.forEach((v) => {
|
|
1877
|
+
if (rangeObj.test(v)) {
|
|
1878
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
1879
|
+
max = v;
|
|
1880
|
+
maxSV = new SemVer(max, options);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
});
|
|
1884
|
+
return max;
|
|
1885
|
+
};
|
|
1886
|
+
module.exports = maxSatisfying;
|
|
1887
|
+
}));
|
|
1888
|
+
//#endregion
|
|
1889
|
+
//#region ../../node_modules/semver/ranges/min-satisfying.js
|
|
1890
|
+
var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1891
|
+
var SemVer = require_semver$1();
|
|
1892
|
+
var Range = require_range();
|
|
1893
|
+
var minSatisfying = (versions, range, options) => {
|
|
1894
|
+
let min = null;
|
|
1895
|
+
let minSV = null;
|
|
1896
|
+
let rangeObj = null;
|
|
1897
|
+
try {
|
|
1898
|
+
rangeObj = new Range(range, options);
|
|
1899
|
+
} catch (er) {
|
|
1900
|
+
return null;
|
|
1901
|
+
}
|
|
1902
|
+
versions.forEach((v) => {
|
|
1903
|
+
if (rangeObj.test(v)) {
|
|
1904
|
+
if (!min || minSV.compare(v) === 1) {
|
|
1905
|
+
min = v;
|
|
1906
|
+
minSV = new SemVer(min, options);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
return min;
|
|
1911
|
+
};
|
|
1912
|
+
module.exports = minSatisfying;
|
|
1913
|
+
}));
|
|
1914
|
+
//#endregion
|
|
1915
|
+
//#region ../../node_modules/semver/ranges/min-version.js
|
|
1916
|
+
var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1917
|
+
var SemVer = require_semver$1();
|
|
1918
|
+
var Range = require_range();
|
|
1919
|
+
var gt = require_gt();
|
|
1920
|
+
var minVersion = (range, loose) => {
|
|
1921
|
+
range = new Range(range, loose);
|
|
1922
|
+
let minver = new SemVer("0.0.0");
|
|
1923
|
+
if (range.test(minver)) return minver;
|
|
1924
|
+
minver = new SemVer("0.0.0-0");
|
|
1925
|
+
if (range.test(minver)) return minver;
|
|
1926
|
+
minver = null;
|
|
1927
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1928
|
+
const comparators = range.set[i];
|
|
1929
|
+
let setMin = null;
|
|
1930
|
+
comparators.forEach((comparator) => {
|
|
1931
|
+
const compver = new SemVer(comparator.semver.version);
|
|
1932
|
+
switch (comparator.operator) {
|
|
1933
|
+
case ">":
|
|
1934
|
+
if (compver.prerelease.length === 0) compver.patch++;
|
|
1935
|
+
else compver.prerelease.push(0);
|
|
1936
|
+
compver.raw = compver.format();
|
|
1937
|
+
case "":
|
|
1938
|
+
case ">=":
|
|
1939
|
+
if (!setMin || gt(compver, setMin)) setMin = compver;
|
|
1940
|
+
break;
|
|
1941
|
+
case "<":
|
|
1942
|
+
case "<=": break;
|
|
1943
|
+
/* istanbul ignore next */
|
|
1944
|
+
default: throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
if (setMin && (!minver || gt(minver, setMin))) minver = setMin;
|
|
1948
|
+
}
|
|
1949
|
+
if (minver && range.test(minver)) return minver;
|
|
1950
|
+
return null;
|
|
1951
|
+
};
|
|
1952
|
+
module.exports = minVersion;
|
|
1953
|
+
}));
|
|
1954
|
+
//#endregion
|
|
1955
|
+
//#region ../../node_modules/semver/ranges/valid.js
|
|
1956
|
+
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1957
|
+
var Range = require_range();
|
|
1958
|
+
var validRange = (range, options) => {
|
|
1959
|
+
try {
|
|
1960
|
+
return new Range(range, options).range || "*";
|
|
1961
|
+
} catch (er) {
|
|
1962
|
+
return null;
|
|
1963
|
+
}
|
|
1964
|
+
};
|
|
1965
|
+
module.exports = validRange;
|
|
1966
|
+
}));
|
|
1967
|
+
//#endregion
|
|
1968
|
+
//#region ../../node_modules/semver/ranges/outside.js
|
|
1969
|
+
var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1970
|
+
var SemVer = require_semver$1();
|
|
1971
|
+
var Comparator = require_comparator();
|
|
1972
|
+
var { ANY } = Comparator;
|
|
1973
|
+
var Range = require_range();
|
|
1974
|
+
var satisfies = require_satisfies();
|
|
1975
|
+
var gt = require_gt();
|
|
1976
|
+
var lt = require_lt();
|
|
1977
|
+
var lte = require_lte();
|
|
1978
|
+
var gte = require_gte();
|
|
1979
|
+
var outside = (version, range, hilo, options) => {
|
|
1980
|
+
version = new SemVer(version, options);
|
|
1981
|
+
range = new Range(range, options);
|
|
1982
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
1983
|
+
switch (hilo) {
|
|
1984
|
+
case ">":
|
|
1985
|
+
gtfn = gt;
|
|
1986
|
+
ltefn = lte;
|
|
1987
|
+
ltfn = lt;
|
|
1988
|
+
comp = ">";
|
|
1989
|
+
ecomp = ">=";
|
|
1990
|
+
break;
|
|
1991
|
+
case "<":
|
|
1992
|
+
gtfn = lt;
|
|
1993
|
+
ltefn = gte;
|
|
1994
|
+
ltfn = gt;
|
|
1995
|
+
comp = "<";
|
|
1996
|
+
ecomp = "<=";
|
|
1997
|
+
break;
|
|
1998
|
+
default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
|
|
1999
|
+
}
|
|
2000
|
+
if (satisfies(version, range, options)) return false;
|
|
2001
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
2002
|
+
const comparators = range.set[i];
|
|
2003
|
+
let high = null;
|
|
2004
|
+
let low = null;
|
|
2005
|
+
comparators.forEach((comparator) => {
|
|
2006
|
+
if (comparator.semver === ANY) comparator = new Comparator(">=0.0.0");
|
|
2007
|
+
high = high || comparator;
|
|
2008
|
+
low = low || comparator;
|
|
2009
|
+
if (gtfn(comparator.semver, high.semver, options)) high = comparator;
|
|
2010
|
+
else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
|
|
2011
|
+
});
|
|
2012
|
+
if (high.operator === comp || high.operator === ecomp) return false;
|
|
2013
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
|
|
2014
|
+
else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
|
|
2015
|
+
}
|
|
2016
|
+
return true;
|
|
2017
|
+
};
|
|
2018
|
+
module.exports = outside;
|
|
2019
|
+
}));
|
|
2020
|
+
//#endregion
|
|
2021
|
+
//#region ../../node_modules/semver/ranges/gtr.js
|
|
2022
|
+
var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2023
|
+
var outside = require_outside();
|
|
2024
|
+
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
2025
|
+
module.exports = gtr;
|
|
2026
|
+
}));
|
|
2027
|
+
//#endregion
|
|
2028
|
+
//#region ../../node_modules/semver/ranges/ltr.js
|
|
2029
|
+
var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2030
|
+
var outside = require_outside();
|
|
2031
|
+
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
2032
|
+
module.exports = ltr;
|
|
2033
|
+
}));
|
|
2034
|
+
//#endregion
|
|
2035
|
+
//#region ../../node_modules/semver/ranges/intersects.js
|
|
2036
|
+
var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2037
|
+
var Range = require_range();
|
|
2038
|
+
var intersects = (r1, r2, options) => {
|
|
2039
|
+
r1 = new Range(r1, options);
|
|
2040
|
+
r2 = new Range(r2, options);
|
|
2041
|
+
return r1.intersects(r2, options);
|
|
2042
|
+
};
|
|
2043
|
+
module.exports = intersects;
|
|
2044
|
+
}));
|
|
2045
|
+
//#endregion
|
|
2046
|
+
//#region ../../node_modules/semver/ranges/simplify.js
|
|
2047
|
+
var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2048
|
+
var satisfies = require_satisfies();
|
|
2049
|
+
var compare = require_compare();
|
|
2050
|
+
module.exports = (versions, range, options) => {
|
|
2051
|
+
const set = [];
|
|
2052
|
+
let first = null;
|
|
2053
|
+
let prev = null;
|
|
2054
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
2055
|
+
for (const version of v) if (satisfies(version, range, options)) {
|
|
2056
|
+
prev = version;
|
|
2057
|
+
if (!first) first = version;
|
|
2058
|
+
} else {
|
|
2059
|
+
if (prev) set.push([first, prev]);
|
|
2060
|
+
prev = null;
|
|
2061
|
+
first = null;
|
|
2062
|
+
}
|
|
2063
|
+
if (first) set.push([first, null]);
|
|
2064
|
+
const ranges = [];
|
|
2065
|
+
for (const [min, max] of set) if (min === max) ranges.push(min);
|
|
2066
|
+
else if (!max && min === v[0]) ranges.push("*");
|
|
2067
|
+
else if (!max) ranges.push(`>=${min}`);
|
|
2068
|
+
else if (min === v[0]) ranges.push(`<=${max}`);
|
|
2069
|
+
else ranges.push(`${min} - ${max}`);
|
|
2070
|
+
const simplified = ranges.join(" || ");
|
|
2071
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
2072
|
+
return simplified.length < original.length ? simplified : range;
|
|
2073
|
+
};
|
|
2074
|
+
}));
|
|
2075
|
+
//#endregion
|
|
2076
|
+
//#region ../../node_modules/semver/ranges/subset.js
|
|
2077
|
+
var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2078
|
+
var Range = require_range();
|
|
2079
|
+
var Comparator = require_comparator();
|
|
2080
|
+
var { ANY } = Comparator;
|
|
2081
|
+
var satisfies = require_satisfies();
|
|
2082
|
+
var compare = require_compare();
|
|
2083
|
+
var subset = (sub, dom, options = {}) => {
|
|
2084
|
+
if (sub === dom) return true;
|
|
2085
|
+
sub = new Range(sub, options);
|
|
2086
|
+
dom = new Range(dom, options);
|
|
2087
|
+
let sawNonNull = false;
|
|
2088
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
2089
|
+
for (const simpleDom of dom.set) {
|
|
2090
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
2091
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
2092
|
+
if (isSub) continue OUTER;
|
|
2093
|
+
}
|
|
2094
|
+
if (sawNonNull) return false;
|
|
2095
|
+
}
|
|
2096
|
+
return true;
|
|
2097
|
+
};
|
|
2098
|
+
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
2099
|
+
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
2100
|
+
var simpleSubset = (sub, dom, options) => {
|
|
2101
|
+
if (sub === dom) return true;
|
|
2102
|
+
if (sub.length === 1 && sub[0].semver === ANY) if (dom.length === 1 && dom[0].semver === ANY) return true;
|
|
2103
|
+
else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
|
|
2104
|
+
else sub = minimumVersion;
|
|
2105
|
+
if (dom.length === 1 && dom[0].semver === ANY) if (options.includePrerelease) return true;
|
|
2106
|
+
else dom = minimumVersion;
|
|
2107
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
2108
|
+
let gt, lt;
|
|
2109
|
+
for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
|
|
2110
|
+
else if (c.operator === "<" || c.operator === "<=") lt = lowerLT(lt, c, options);
|
|
2111
|
+
else eqSet.add(c.semver);
|
|
2112
|
+
if (eqSet.size > 1) return null;
|
|
2113
|
+
let gtltComp;
|
|
2114
|
+
if (gt && lt) {
|
|
2115
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
2116
|
+
if (gtltComp > 0) return null;
|
|
2117
|
+
else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
|
|
2118
|
+
}
|
|
2119
|
+
for (const eq of eqSet) {
|
|
2120
|
+
if (gt && !satisfies(eq, String(gt), options)) return null;
|
|
2121
|
+
if (lt && !satisfies(eq, String(lt), options)) return null;
|
|
2122
|
+
for (const c of dom) if (!satisfies(eq, String(c), options)) return false;
|
|
2123
|
+
return true;
|
|
2124
|
+
}
|
|
2125
|
+
let higher, lower;
|
|
2126
|
+
let hasDomLT, hasDomGT;
|
|
2127
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
2128
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
2129
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
|
|
2130
|
+
for (const c of dom) {
|
|
2131
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
2132
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
2133
|
+
if (gt) {
|
|
2134
|
+
if (needDomGTPre) {
|
|
2135
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) needDomGTPre = false;
|
|
2136
|
+
}
|
|
2137
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
2138
|
+
higher = higherGT(gt, c, options);
|
|
2139
|
+
if (higher === c && higher !== gt) return false;
|
|
2140
|
+
} else if (gt.operator === ">=" && !c.test(gt.semver)) return false;
|
|
2141
|
+
}
|
|
2142
|
+
if (lt) {
|
|
2143
|
+
if (needDomLTPre) {
|
|
2144
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) needDomLTPre = false;
|
|
2145
|
+
}
|
|
2146
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
2147
|
+
lower = lowerLT(lt, c, options);
|
|
2148
|
+
if (lower === c && lower !== lt) return false;
|
|
2149
|
+
} else if (lt.operator === "<=" && !c.test(lt.semver)) return false;
|
|
2150
|
+
}
|
|
2151
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
|
|
2152
|
+
}
|
|
2153
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
|
|
2154
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
|
|
2155
|
+
if (needDomGTPre || needDomLTPre) return false;
|
|
2156
|
+
return true;
|
|
2157
|
+
};
|
|
2158
|
+
var higherGT = (a, b, options) => {
|
|
2159
|
+
if (!a) return b;
|
|
2160
|
+
const comp = compare(a.semver, b.semver, options);
|
|
2161
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
2162
|
+
};
|
|
2163
|
+
var lowerLT = (a, b, options) => {
|
|
2164
|
+
if (!a) return b;
|
|
2165
|
+
const comp = compare(a.semver, b.semver, options);
|
|
2166
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
2167
|
+
};
|
|
2168
|
+
module.exports = subset;
|
|
2169
|
+
}));
|
|
2170
|
+
//#endregion
|
|
2171
|
+
//#region ../../node_modules/semver/index.js
|
|
2172
|
+
var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2173
|
+
var internalRe = require_re();
|
|
2174
|
+
var constants = require_constants();
|
|
2175
|
+
var SemVer = require_semver$1();
|
|
2176
|
+
var identifiers = require_identifiers();
|
|
2177
|
+
module.exports = {
|
|
2178
|
+
parse: require_parse(),
|
|
2179
|
+
valid: require_valid$1(),
|
|
2180
|
+
clean: require_clean(),
|
|
2181
|
+
inc: require_inc(),
|
|
2182
|
+
diff: require_diff(),
|
|
2183
|
+
major: require_major(),
|
|
2184
|
+
minor: require_minor(),
|
|
2185
|
+
patch: require_patch(),
|
|
2186
|
+
prerelease: require_prerelease(),
|
|
2187
|
+
compare: require_compare(),
|
|
2188
|
+
rcompare: require_rcompare(),
|
|
2189
|
+
compareLoose: require_compare_loose(),
|
|
2190
|
+
compareBuild: require_compare_build(),
|
|
2191
|
+
sort: require_sort(),
|
|
2192
|
+
rsort: require_rsort(),
|
|
2193
|
+
gt: require_gt(),
|
|
2194
|
+
lt: require_lt(),
|
|
2195
|
+
eq: require_eq(),
|
|
2196
|
+
neq: require_neq(),
|
|
2197
|
+
gte: require_gte(),
|
|
2198
|
+
lte: require_lte(),
|
|
2199
|
+
cmp: require_cmp(),
|
|
2200
|
+
coerce: require_coerce(),
|
|
2201
|
+
truncate: require_truncate(),
|
|
2202
|
+
Comparator: require_comparator(),
|
|
2203
|
+
Range: require_range(),
|
|
2204
|
+
satisfies: require_satisfies(),
|
|
2205
|
+
toComparators: require_to_comparators(),
|
|
2206
|
+
maxSatisfying: require_max_satisfying(),
|
|
2207
|
+
minSatisfying: require_min_satisfying(),
|
|
2208
|
+
minVersion: require_min_version(),
|
|
2209
|
+
validRange: require_valid(),
|
|
2210
|
+
outside: require_outside(),
|
|
2211
|
+
gtr: require_gtr(),
|
|
2212
|
+
ltr: require_ltr(),
|
|
2213
|
+
intersects: require_intersects(),
|
|
2214
|
+
simplifyRange: require_simplify(),
|
|
2215
|
+
subset: require_subset(),
|
|
2216
|
+
SemVer,
|
|
2217
|
+
re: internalRe.re,
|
|
2218
|
+
src: internalRe.src,
|
|
2219
|
+
tokens: internalRe.t,
|
|
2220
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
2221
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
2222
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
2223
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
2224
|
+
};
|
|
2225
|
+
}));
|
|
2226
|
+
//#endregion
|
|
2227
|
+
//#region ../../node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js
|
|
2228
|
+
var require_asymmetricKeyDetailsSupported = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2229
|
+
module.exports = require_semver().satisfies(process.version, ">=15.7.0");
|
|
2230
|
+
}));
|
|
2231
|
+
//#endregion
|
|
2232
|
+
//#region ../../node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js
|
|
2233
|
+
var require_rsaPssKeyDetailsSupported = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2234
|
+
module.exports = require_semver().satisfies(process.version, ">=16.9.0");
|
|
2235
|
+
}));
|
|
2236
|
+
//#endregion
|
|
2237
|
+
//#region ../../node_modules/jsonwebtoken/lib/validateAsymmetricKey.js
|
|
2238
|
+
var require_validateAsymmetricKey = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2239
|
+
var ASYMMETRIC_KEY_DETAILS_SUPPORTED = require_asymmetricKeyDetailsSupported();
|
|
2240
|
+
var RSA_PSS_KEY_DETAILS_SUPPORTED = require_rsaPssKeyDetailsSupported();
|
|
2241
|
+
var allowedAlgorithmsForKeys = {
|
|
2242
|
+
"ec": [
|
|
2243
|
+
"ES256",
|
|
2244
|
+
"ES384",
|
|
2245
|
+
"ES512"
|
|
2246
|
+
],
|
|
2247
|
+
"rsa": [
|
|
2248
|
+
"RS256",
|
|
2249
|
+
"PS256",
|
|
2250
|
+
"RS384",
|
|
2251
|
+
"PS384",
|
|
2252
|
+
"RS512",
|
|
2253
|
+
"PS512"
|
|
2254
|
+
],
|
|
2255
|
+
"rsa-pss": [
|
|
2256
|
+
"PS256",
|
|
2257
|
+
"PS384",
|
|
2258
|
+
"PS512"
|
|
2259
|
+
]
|
|
2260
|
+
};
|
|
2261
|
+
var allowedCurves = {
|
|
2262
|
+
ES256: "prime256v1",
|
|
2263
|
+
ES384: "secp384r1",
|
|
2264
|
+
ES512: "secp521r1"
|
|
2265
|
+
};
|
|
2266
|
+
module.exports = function(algorithm, key) {
|
|
2267
|
+
if (!algorithm || !key) return;
|
|
2268
|
+
const keyType = key.asymmetricKeyType;
|
|
2269
|
+
if (!keyType) return;
|
|
2270
|
+
const allowedAlgorithms = allowedAlgorithmsForKeys[keyType];
|
|
2271
|
+
if (!allowedAlgorithms) throw new Error(`Unknown key type "${keyType}".`);
|
|
2272
|
+
if (!allowedAlgorithms.includes(algorithm)) throw new Error(`"alg" parameter for "${keyType}" key type must be one of: ${allowedAlgorithms.join(", ")}.`);
|
|
2273
|
+
/* istanbul ignore next */
|
|
2274
|
+
if (ASYMMETRIC_KEY_DETAILS_SUPPORTED) switch (keyType) {
|
|
2275
|
+
case "ec":
|
|
2276
|
+
const keyCurve = key.asymmetricKeyDetails.namedCurve;
|
|
2277
|
+
const allowedCurve = allowedCurves[algorithm];
|
|
2278
|
+
if (keyCurve !== allowedCurve) throw new Error(`"alg" parameter "${algorithm}" requires curve "${allowedCurve}".`);
|
|
2279
|
+
break;
|
|
2280
|
+
case "rsa-pss":
|
|
2281
|
+
if (RSA_PSS_KEY_DETAILS_SUPPORTED) {
|
|
2282
|
+
const length = parseInt(algorithm.slice(-3), 10);
|
|
2283
|
+
const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = key.asymmetricKeyDetails;
|
|
2284
|
+
if (hashAlgorithm !== `sha${length}` || mgf1HashAlgorithm !== hashAlgorithm) throw new Error(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of "alg" ${algorithm}.`);
|
|
2285
|
+
if (saltLength !== void 0 && saltLength > length >> 3) throw new Error(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of "alg" ${algorithm}.`);
|
|
2286
|
+
}
|
|
2287
|
+
break;
|
|
2288
|
+
}
|
|
2289
|
+
};
|
|
2290
|
+
}));
|
|
2291
|
+
//#endregion
|
|
2292
|
+
//#region ../../node_modules/jsonwebtoken/lib/psSupported.js
|
|
2293
|
+
var require_psSupported = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2294
|
+
module.exports = require_semver().satisfies(process.version, "^6.12.0 || >=8.0.0");
|
|
2295
|
+
}));
|
|
2296
|
+
//#endregion
|
|
2297
|
+
//#region ../../node_modules/jsonwebtoken/verify.js
|
|
2298
|
+
var require_verify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2299
|
+
var JsonWebTokenError = require_JsonWebTokenError();
|
|
2300
|
+
var NotBeforeError = require_NotBeforeError();
|
|
2301
|
+
var TokenExpiredError = require_TokenExpiredError();
|
|
2302
|
+
var decode = require_decode();
|
|
2303
|
+
var timespan = require_timespan();
|
|
2304
|
+
var validateAsymmetricKey = require_validateAsymmetricKey();
|
|
2305
|
+
var PS_SUPPORTED = require_psSupported();
|
|
2306
|
+
var jws = require_jws();
|
|
2307
|
+
var { KeyObject: KeyObject$1, createSecretKey: createSecretKey$1, createPublicKey } = __require("crypto");
|
|
2308
|
+
var PUB_KEY_ALGS = [
|
|
2309
|
+
"RS256",
|
|
2310
|
+
"RS384",
|
|
2311
|
+
"RS512"
|
|
2312
|
+
];
|
|
2313
|
+
var EC_KEY_ALGS = [
|
|
2314
|
+
"ES256",
|
|
2315
|
+
"ES384",
|
|
2316
|
+
"ES512"
|
|
2317
|
+
];
|
|
2318
|
+
var RSA_KEY_ALGS = [
|
|
2319
|
+
"RS256",
|
|
2320
|
+
"RS384",
|
|
2321
|
+
"RS512"
|
|
2322
|
+
];
|
|
2323
|
+
var HS_ALGS = [
|
|
2324
|
+
"HS256",
|
|
2325
|
+
"HS384",
|
|
2326
|
+
"HS512"
|
|
2327
|
+
];
|
|
2328
|
+
if (PS_SUPPORTED) {
|
|
2329
|
+
PUB_KEY_ALGS.splice(PUB_KEY_ALGS.length, 0, "PS256", "PS384", "PS512");
|
|
2330
|
+
RSA_KEY_ALGS.splice(RSA_KEY_ALGS.length, 0, "PS256", "PS384", "PS512");
|
|
2331
|
+
}
|
|
2332
|
+
module.exports = function(jwtString, secretOrPublicKey, options, callback) {
|
|
2333
|
+
if (typeof options === "function" && !callback) {
|
|
2334
|
+
callback = options;
|
|
2335
|
+
options = {};
|
|
2336
|
+
}
|
|
2337
|
+
if (!options) options = {};
|
|
2338
|
+
options = Object.assign({}, options);
|
|
2339
|
+
let done;
|
|
2340
|
+
if (callback) done = callback;
|
|
2341
|
+
else done = function(err, data) {
|
|
2342
|
+
if (err) throw err;
|
|
2343
|
+
return data;
|
|
2344
|
+
};
|
|
2345
|
+
if (options.clockTimestamp && typeof options.clockTimestamp !== "number") return done(new JsonWebTokenError("clockTimestamp must be a number"));
|
|
2346
|
+
if (options.nonce !== void 0 && (typeof options.nonce !== "string" || options.nonce.trim() === "")) return done(new JsonWebTokenError("nonce must be a non-empty string"));
|
|
2347
|
+
if (options.allowInvalidAsymmetricKeyTypes !== void 0 && typeof options.allowInvalidAsymmetricKeyTypes !== "boolean") return done(new JsonWebTokenError("allowInvalidAsymmetricKeyTypes must be a boolean"));
|
|
2348
|
+
const clockTimestamp = options.clockTimestamp || Math.floor(Date.now() / 1e3);
|
|
2349
|
+
if (!jwtString) return done(new JsonWebTokenError("jwt must be provided"));
|
|
2350
|
+
if (typeof jwtString !== "string") return done(new JsonWebTokenError("jwt must be a string"));
|
|
2351
|
+
const parts = jwtString.split(".");
|
|
2352
|
+
if (parts.length !== 3) return done(new JsonWebTokenError("jwt malformed"));
|
|
2353
|
+
let decodedToken;
|
|
2354
|
+
try {
|
|
2355
|
+
decodedToken = decode(jwtString, { complete: true });
|
|
2356
|
+
} catch (err) {
|
|
2357
|
+
return done(err);
|
|
2358
|
+
}
|
|
2359
|
+
if (!decodedToken) return done(new JsonWebTokenError("invalid token"));
|
|
2360
|
+
const header = decodedToken.header;
|
|
2361
|
+
let getSecret;
|
|
2362
|
+
if (typeof secretOrPublicKey === "function") {
|
|
2363
|
+
if (!callback) return done(new JsonWebTokenError("verify must be called asynchronous if secret or public key is provided as a callback"));
|
|
2364
|
+
getSecret = secretOrPublicKey;
|
|
2365
|
+
} else getSecret = function(header, secretCallback) {
|
|
2366
|
+
return secretCallback(null, secretOrPublicKey);
|
|
2367
|
+
};
|
|
2368
|
+
return getSecret(header, function(err, secretOrPublicKey) {
|
|
2369
|
+
if (err) return done(new JsonWebTokenError("error in secret or public key callback: " + err.message));
|
|
2370
|
+
const hasSignature = parts[2].trim() !== "";
|
|
2371
|
+
if (!hasSignature && secretOrPublicKey) return done(new JsonWebTokenError("jwt signature is required"));
|
|
2372
|
+
if (hasSignature && !secretOrPublicKey) return done(new JsonWebTokenError("secret or public key must be provided"));
|
|
2373
|
+
if (!hasSignature && !options.algorithms) return done(new JsonWebTokenError("please specify \"none\" in \"algorithms\" to verify unsigned tokens"));
|
|
2374
|
+
if (secretOrPublicKey != null && !(secretOrPublicKey instanceof KeyObject$1)) try {
|
|
2375
|
+
secretOrPublicKey = createPublicKey(secretOrPublicKey);
|
|
2376
|
+
} catch (_) {
|
|
2377
|
+
try {
|
|
2378
|
+
secretOrPublicKey = createSecretKey$1(typeof secretOrPublicKey === "string" ? Buffer.from(secretOrPublicKey) : secretOrPublicKey);
|
|
2379
|
+
} catch (_) {
|
|
2380
|
+
return done(new JsonWebTokenError("secretOrPublicKey is not valid key material"));
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
if (!options.algorithms) if (secretOrPublicKey.type === "secret") options.algorithms = HS_ALGS;
|
|
2384
|
+
else if (["rsa", "rsa-pss"].includes(secretOrPublicKey.asymmetricKeyType)) options.algorithms = RSA_KEY_ALGS;
|
|
2385
|
+
else if (secretOrPublicKey.asymmetricKeyType === "ec") options.algorithms = EC_KEY_ALGS;
|
|
2386
|
+
else options.algorithms = PUB_KEY_ALGS;
|
|
2387
|
+
if (options.algorithms.indexOf(decodedToken.header.alg) === -1) return done(new JsonWebTokenError("invalid algorithm"));
|
|
2388
|
+
if (header.alg.startsWith("HS") && secretOrPublicKey.type !== "secret") return done(new JsonWebTokenError(`secretOrPublicKey must be a symmetric key when using ${header.alg}`));
|
|
2389
|
+
else if (/^(?:RS|PS|ES)/.test(header.alg) && secretOrPublicKey.type !== "public") return done(new JsonWebTokenError(`secretOrPublicKey must be an asymmetric key when using ${header.alg}`));
|
|
2390
|
+
if (!options.allowInvalidAsymmetricKeyTypes) try {
|
|
2391
|
+
validateAsymmetricKey(header.alg, secretOrPublicKey);
|
|
2392
|
+
} catch (e) {
|
|
2393
|
+
return done(e);
|
|
2394
|
+
}
|
|
2395
|
+
let valid;
|
|
2396
|
+
try {
|
|
2397
|
+
valid = jws.verify(jwtString, decodedToken.header.alg, secretOrPublicKey);
|
|
2398
|
+
} catch (e) {
|
|
2399
|
+
return done(e);
|
|
2400
|
+
}
|
|
2401
|
+
if (!valid) return done(new JsonWebTokenError("invalid signature"));
|
|
2402
|
+
const payload = decodedToken.payload;
|
|
2403
|
+
if (typeof payload.nbf !== "undefined" && !options.ignoreNotBefore) {
|
|
2404
|
+
if (typeof payload.nbf !== "number") return done(new JsonWebTokenError("invalid nbf value"));
|
|
2405
|
+
if (payload.nbf > clockTimestamp + (options.clockTolerance || 0)) return done(new NotBeforeError("jwt not active", /* @__PURE__ */ new Date(payload.nbf * 1e3)));
|
|
2406
|
+
}
|
|
2407
|
+
if (typeof payload.exp !== "undefined" && !options.ignoreExpiration) {
|
|
2408
|
+
if (typeof payload.exp !== "number") return done(new JsonWebTokenError("invalid exp value"));
|
|
2409
|
+
if (clockTimestamp >= payload.exp + (options.clockTolerance || 0)) return done(new TokenExpiredError("jwt expired", /* @__PURE__ */ new Date(payload.exp * 1e3)));
|
|
2410
|
+
}
|
|
2411
|
+
if (options.audience) {
|
|
2412
|
+
const audiences = Array.isArray(options.audience) ? options.audience : [options.audience];
|
|
2413
|
+
if (!(Array.isArray(payload.aud) ? payload.aud : [payload.aud]).some(function(targetAudience) {
|
|
2414
|
+
return audiences.some(function(audience) {
|
|
2415
|
+
return audience instanceof RegExp ? audience.test(targetAudience) : audience === targetAudience;
|
|
2416
|
+
});
|
|
2417
|
+
})) return done(new JsonWebTokenError("jwt audience invalid. expected: " + audiences.join(" or ")));
|
|
2418
|
+
}
|
|
2419
|
+
if (options.issuer) {
|
|
2420
|
+
if (typeof options.issuer === "string" && payload.iss !== options.issuer || Array.isArray(options.issuer) && options.issuer.indexOf(payload.iss) === -1) return done(new JsonWebTokenError("jwt issuer invalid. expected: " + options.issuer));
|
|
2421
|
+
}
|
|
2422
|
+
if (options.subject) {
|
|
887
2423
|
if (payload.sub !== options.subject) return done(new JsonWebTokenError("jwt subject invalid. expected: " + options.subject));
|
|
888
2424
|
}
|
|
889
2425
|
if (options.jwtid) {
|
|
@@ -2640,7 +4176,7 @@ var randomFallback = null;
|
|
|
2640
4176
|
* @throws {Error} If no random implementation is available
|
|
2641
4177
|
* @inner
|
|
2642
4178
|
*/
|
|
2643
|
-
function randomBytes$
|
|
4179
|
+
function randomBytes$2(len) {
|
|
2644
4180
|
try {
|
|
2645
4181
|
return crypto.getRandomValues(new Uint8Array(len));
|
|
2646
4182
|
} catch {}
|
|
@@ -2667,7 +4203,7 @@ function genSaltSync(rounds, seed_length) {
|
|
|
2667
4203
|
if (rounds < 10) salt.push("0");
|
|
2668
4204
|
salt.push(rounds.toString());
|
|
2669
4205
|
salt.push("$");
|
|
2670
|
-
salt.push(base64_encode(randomBytes$
|
|
4206
|
+
salt.push(base64_encode(randomBytes$2(BCRYPT_SALT_LEN), BCRYPT_SALT_LEN));
|
|
2671
4207
|
return salt.join("");
|
|
2672
4208
|
}
|
|
2673
4209
|
/**
|
|
@@ -4440,7 +5976,7 @@ var AuthManager = class {
|
|
|
4440
5976
|
const configured = this.config.get("auth.jwtSecret");
|
|
4441
5977
|
if (configured) this.jwtSecret = configured;
|
|
4442
5978
|
else {
|
|
4443
|
-
const secret = crypto$
|
|
5979
|
+
const secret = crypto$1.randomBytes(32).toString("hex");
|
|
4444
5980
|
this.config.update("auth", { jwtSecret: secret });
|
|
4445
5981
|
this.logger.info("Generated JWT secret and saved to config.yaml (auth.jwtSecret)");
|
|
4446
5982
|
this.jwtSecret = secret;
|
|
@@ -4461,15 +5997,15 @@ var AuthManager = class {
|
|
|
4461
5997
|
return compare(password, hash);
|
|
4462
5998
|
}
|
|
4463
5999
|
generateApiKey() {
|
|
4464
|
-
const token = crypto$
|
|
6000
|
+
const token = crypto$1.randomBytes(32).toString("hex");
|
|
4465
6001
|
return {
|
|
4466
6002
|
token,
|
|
4467
|
-
hash: crypto$
|
|
6003
|
+
hash: crypto$1.createHash("sha256").update(token).digest("hex"),
|
|
4468
6004
|
prefix: token.slice(0, 8)
|
|
4469
6005
|
};
|
|
4470
6006
|
}
|
|
4471
6007
|
validateApiKey(token, storedHash) {
|
|
4472
|
-
return crypto$
|
|
6008
|
+
return crypto$1.createHash("sha256").update(token).digest("hex") === storedHash;
|
|
4473
6009
|
}
|
|
4474
6010
|
/**
|
|
4475
6011
|
* Create a service token for agent/worker authentication.
|
|
@@ -4645,7 +6181,7 @@ var UserManager = class {
|
|
|
4645
6181
|
const passwordHash = await this.auth.hashPassword(input.password);
|
|
4646
6182
|
const now = Date.now();
|
|
4647
6183
|
const record = {
|
|
4648
|
-
id: crypto$
|
|
6184
|
+
id: crypto$1.randomUUID(),
|
|
4649
6185
|
username: input.username,
|
|
4650
6186
|
passwordHash,
|
|
4651
6187
|
isAdmin: input.isAdmin ?? false,
|
|
@@ -4762,7 +6298,7 @@ var ApiKeyManager = class {
|
|
|
4762
6298
|
const { token: rawToken, hash, prefix } = this.auth.generateApiKey();
|
|
4763
6299
|
const now = Date.now();
|
|
4764
6300
|
const record = {
|
|
4765
|
-
id: crypto$
|
|
6301
|
+
id: crypto$1.randomUUID(),
|
|
4766
6302
|
label: input.label,
|
|
4767
6303
|
isAdmin: input.isAdmin ?? false,
|
|
4768
6304
|
allowedProviders: input.allowedProviders ?? "*",
|
|
@@ -4839,11 +6375,11 @@ var ScopedTokenManager = class {
|
|
|
4839
6375
|
this.store = store;
|
|
4840
6376
|
}
|
|
4841
6377
|
async create(userId, name, scopes, expiresAt) {
|
|
4842
|
-
const rawToken = `${TOKEN_PREFIX}${crypto$
|
|
4843
|
-
const tokenHash = crypto$
|
|
6378
|
+
const rawToken = `${TOKEN_PREFIX}${crypto$1.randomBytes(32).toString("hex")}`;
|
|
6379
|
+
const tokenHash = crypto$1.createHash("sha256").update(rawToken).digest("hex");
|
|
4844
6380
|
const tokenPrefix = rawToken.slice(0, 12);
|
|
4845
6381
|
const record = {
|
|
4846
|
-
id: crypto$
|
|
6382
|
+
id: crypto$1.randomUUID(),
|
|
4847
6383
|
userId,
|
|
4848
6384
|
name,
|
|
4849
6385
|
tokenHash,
|
|
@@ -4867,7 +6403,7 @@ var ScopedTokenManager = class {
|
|
|
4867
6403
|
}
|
|
4868
6404
|
async validate(rawToken) {
|
|
4869
6405
|
if (!rawToken.startsWith(TOKEN_PREFIX)) return null;
|
|
4870
|
-
const tokenHash = crypto$
|
|
6406
|
+
const tokenHash = crypto$1.createHash("sha256").update(rawToken).digest("hex");
|
|
4871
6407
|
const results = await this.store.query.query({
|
|
4872
6408
|
collection: TOKENS_COLLECTION,
|
|
4873
6409
|
filter: { where: { tokenHash } }
|
|
@@ -5011,7 +6547,7 @@ var OauthSessionManager = class {
|
|
|
5011
6547
|
async create(input) {
|
|
5012
6548
|
const now = Date.now();
|
|
5013
6549
|
const session = {
|
|
5014
|
-
id: crypto$
|
|
6550
|
+
id: crypto$1.randomUUID(),
|
|
5015
6551
|
userId: input.userId,
|
|
5016
6552
|
username: input.username,
|
|
5017
6553
|
integrationId: input.integrationId,
|
|
@@ -5090,682 +6626,2144 @@ var OauthSessionManager = class {
|
|
|
5090
6626
|
data: { ...updated }
|
|
5091
6627
|
});
|
|
5092
6628
|
}
|
|
6629
|
+
}, i$2 = class extends Error {
|
|
6630
|
+
constructor(e, t) {
|
|
6631
|
+
super(e, t), this.name = "OTPError";
|
|
6632
|
+
}
|
|
6633
|
+
}, G$3 = class extends i$2 {
|
|
6634
|
+
constructor(e) {
|
|
6635
|
+
super(e), this.name = "PluginError";
|
|
6636
|
+
}
|
|
6637
|
+
}, Y$3 = class extends G$3 {
|
|
6638
|
+
constructor() {
|
|
6639
|
+
super("Crypto plugin is required."), this.name = "CryptoPluginMissingError";
|
|
6640
|
+
}
|
|
6641
|
+
}, L$2 = class extends G$3 {
|
|
6642
|
+
constructor() {
|
|
6643
|
+
super("Base32 plugin is required."), this.name = "Base32PluginMissingError";
|
|
6644
|
+
}
|
|
6645
|
+
}, a$2 = class extends i$2 {
|
|
6646
|
+
constructor(e) {
|
|
6647
|
+
super(e), this.name = "ConfigurationError";
|
|
6648
|
+
}
|
|
5093
6649
|
};
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
6650
|
+
new TextEncoder();
|
|
6651
|
+
new TextDecoder();
|
|
6652
|
+
var ur$3 = 3600, pr$3 = Number.MAX_SAFE_INTEGER, er$3 = Symbol("otplib.guardrails.override");
|
|
6653
|
+
function y$2(r, e, t) {
|
|
6654
|
+
if (typeof e != "number" || !Number.isSafeInteger(e)) throw new a$2(`Guardrail '${r}' must be a safe integer`);
|
|
6655
|
+
if (e < t) throw new a$2(`Guardrail '${r}' must be >= ${t}`);
|
|
6656
|
+
}
|
|
6657
|
+
var d$5 = Object.freeze({
|
|
6658
|
+
MIN_SECRET_BYTES: 16,
|
|
6659
|
+
MAX_SECRET_BYTES: 64,
|
|
6660
|
+
MIN_PERIOD: 1,
|
|
6661
|
+
MAX_PERIOD: ur$3,
|
|
6662
|
+
MAX_COUNTER: pr$3,
|
|
6663
|
+
MAX_WINDOW: 99,
|
|
6664
|
+
[er$3]: !1
|
|
6665
|
+
});
|
|
6666
|
+
function hr$2(r) {
|
|
6667
|
+
if (!r) return d$5;
|
|
6668
|
+
r.MIN_SECRET_BYTES !== void 0 && y$2("MIN_SECRET_BYTES", r.MIN_SECRET_BYTES, 1), r.MAX_SECRET_BYTES !== void 0 && y$2("MAX_SECRET_BYTES", r.MAX_SECRET_BYTES, 1), r.MIN_PERIOD !== void 0 && y$2("MIN_PERIOD", r.MIN_PERIOD, 1), r.MAX_PERIOD !== void 0 && y$2("MAX_PERIOD", r.MAX_PERIOD, 1), r.MAX_COUNTER !== void 0 && y$2("MAX_COUNTER", r.MAX_COUNTER, 0), r.MAX_WINDOW !== void 0 && y$2("MAX_WINDOW", r.MAX_WINDOW, 1);
|
|
6669
|
+
let e = {
|
|
6670
|
+
...d$5,
|
|
6671
|
+
...r
|
|
5111
6672
|
};
|
|
5112
|
-
|
|
5113
|
-
|
|
6673
|
+
if (e.MIN_SECRET_BYTES > e.MAX_SECRET_BYTES) throw new a$2("Guardrail 'MIN_SECRET_BYTES' must be <= 'MAX_SECRET_BYTES'");
|
|
6674
|
+
if (e.MIN_PERIOD > e.MAX_PERIOD) throw new a$2("Guardrail 'MIN_PERIOD' must be <= 'MAX_PERIOD'");
|
|
6675
|
+
return Object.freeze({
|
|
6676
|
+
...e,
|
|
6677
|
+
[er$3]: !0
|
|
6678
|
+
});
|
|
6679
|
+
}
|
|
6680
|
+
function Dr(r) {
|
|
6681
|
+
let { crypto: e, base32: t, length: o = 20 } = r;
|
|
6682
|
+
dr$2(e), nr$2(t);
|
|
6683
|
+
let n = e.randomBytes(o);
|
|
6684
|
+
return t.encode(n, { padding: !1 });
|
|
6685
|
+
}
|
|
6686
|
+
function dr$2(r) {
|
|
6687
|
+
if (!r) throw new Y$3();
|
|
6688
|
+
}
|
|
6689
|
+
function nr$2(r) {
|
|
6690
|
+
if (!r) throw new L$2();
|
|
6691
|
+
}
|
|
6692
|
+
//#endregion
|
|
6693
|
+
//#region ../../node_modules/@otplib/hotp/node_modules/@otplib/core/dist/index.js
|
|
6694
|
+
var i$1 = class extends Error {
|
|
6695
|
+
constructor(e, t) {
|
|
6696
|
+
super(e, t), this.name = "OTPError";
|
|
6697
|
+
}
|
|
6698
|
+
}, x$2 = class extends i$1 {
|
|
6699
|
+
constructor(e) {
|
|
6700
|
+
super(e), this.name = "SecretError";
|
|
6701
|
+
}
|
|
6702
|
+
}, h$1 = class extends x$2 {
|
|
6703
|
+
constructor(e, t) {
|
|
6704
|
+
super(`Secret must be at least ${e} bytes (${e * 8} bits), got ${t} bytes`), this.name = "SecretTooShortError";
|
|
6705
|
+
}
|
|
6706
|
+
}, P$1 = class extends x$2 {
|
|
6707
|
+
constructor(e, t) {
|
|
6708
|
+
super(`Secret must not exceed ${e} bytes, got ${t} bytes`), this.name = "SecretTooLongError";
|
|
6709
|
+
}
|
|
6710
|
+
}, m$2 = class extends i$1 {
|
|
6711
|
+
constructor(e) {
|
|
6712
|
+
super(e), this.name = "CounterError";
|
|
6713
|
+
}
|
|
6714
|
+
}, O$2 = class extends m$2 {
|
|
6715
|
+
constructor() {
|
|
6716
|
+
super("Counter must be non-negative"), this.name = "CounterNegativeError";
|
|
6717
|
+
}
|
|
6718
|
+
}, T$2 = class extends m$2 {
|
|
6719
|
+
constructor() {
|
|
6720
|
+
super("Counter exceeds maximum safe integer value"), this.name = "CounterOverflowError";
|
|
6721
|
+
}
|
|
6722
|
+
}, b$2 = class extends m$2 {
|
|
6723
|
+
constructor() {
|
|
6724
|
+
super("Counter must be a finite integer"), this.name = "CounterNotIntegerError";
|
|
6725
|
+
}
|
|
6726
|
+
}, R$2 = class extends i$1 {
|
|
6727
|
+
constructor(e) {
|
|
6728
|
+
super(e), this.name = "TokenError";
|
|
6729
|
+
}
|
|
6730
|
+
}, I$2 = class extends R$2 {
|
|
6731
|
+
constructor(e, t) {
|
|
6732
|
+
super(`Token must be ${e} digits, got ${t}`), this.name = "TokenLengthError";
|
|
6733
|
+
}
|
|
6734
|
+
}, M$1 = class extends R$2 {
|
|
6735
|
+
constructor() {
|
|
6736
|
+
super("Token must contain only digits"), this.name = "TokenFormatError";
|
|
6737
|
+
}
|
|
6738
|
+
}, N$1 = class extends i$1 {
|
|
6739
|
+
constructor(e, t) {
|
|
6740
|
+
super(e, t), this.name = "CryptoError";
|
|
6741
|
+
}
|
|
6742
|
+
}, c$2 = class extends N$1 {
|
|
6743
|
+
constructor(e, t) {
|
|
6744
|
+
super(`HMAC computation failed: ${e}`, t), this.name = "HMACError";
|
|
6745
|
+
}
|
|
6746
|
+
}, v$2 = class extends N$1 {
|
|
6747
|
+
constructor(e, t) {
|
|
6748
|
+
super(`Random byte generation failed: ${e}`, t), this.name = "RandomBytesError";
|
|
6749
|
+
}
|
|
6750
|
+
}, g$1 = class extends i$1 {
|
|
6751
|
+
constructor(e) {
|
|
6752
|
+
super(e), this.name = "CounterToleranceError";
|
|
6753
|
+
}
|
|
6754
|
+
}, U$2 = class extends g$1 {
|
|
6755
|
+
constructor(e, t) {
|
|
6756
|
+
super(`Counter tolerance validation failed: total checks (${t}) exceeds MAX_WINDOW (${e})`), this.name = "CounterToleranceTooLargeError";
|
|
6757
|
+
}
|
|
6758
|
+
}, X$1 = class extends g$1 {
|
|
6759
|
+
constructor() {
|
|
6760
|
+
super("Counter tolerance cannot contain negative values"), this.name = "CounterToleranceNegativeError";
|
|
6761
|
+
}
|
|
6762
|
+
}, G$2 = class extends i$1 {
|
|
6763
|
+
constructor(e) {
|
|
6764
|
+
super(e), this.name = "PluginError";
|
|
6765
|
+
}
|
|
6766
|
+
}, Y$2 = class extends G$2 {
|
|
6767
|
+
constructor() {
|
|
6768
|
+
super("Crypto plugin is required."), this.name = "CryptoPluginMissingError";
|
|
6769
|
+
}
|
|
6770
|
+
}, L$1 = class extends G$2 {
|
|
6771
|
+
constructor() {
|
|
6772
|
+
super("Base32 plugin is required."), this.name = "Base32PluginMissingError";
|
|
6773
|
+
}
|
|
6774
|
+
}, a$1 = class extends i$1 {
|
|
6775
|
+
constructor(e) {
|
|
6776
|
+
super(e), this.name = "ConfigurationError";
|
|
6777
|
+
}
|
|
6778
|
+
}, W$1 = class extends a$1 {
|
|
6779
|
+
constructor() {
|
|
6780
|
+
super("Secret is required. Use generateSecret() to create one, or provide via { secret: 'YOUR_BASE32_SECRET' }"), this.name = "SecretMissingError";
|
|
6781
|
+
}
|
|
6782
|
+
};
|
|
6783
|
+
new TextEncoder();
|
|
6784
|
+
new TextDecoder();
|
|
6785
|
+
var ur$2 = 3600, pr$2 = Number.MAX_SAFE_INTEGER, er$2 = Symbol("otplib.guardrails.override");
|
|
6786
|
+
function y$1(r, e, t) {
|
|
6787
|
+
if (typeof e != "number" || !Number.isSafeInteger(e)) throw new a$1(`Guardrail '${r}' must be a safe integer`);
|
|
6788
|
+
if (e < t) throw new a$1(`Guardrail '${r}' must be >= ${t}`);
|
|
6789
|
+
}
|
|
6790
|
+
var d$4 = Object.freeze({
|
|
6791
|
+
MIN_SECRET_BYTES: 16,
|
|
6792
|
+
MAX_SECRET_BYTES: 64,
|
|
6793
|
+
MIN_PERIOD: 1,
|
|
6794
|
+
MAX_PERIOD: ur$2,
|
|
6795
|
+
MAX_COUNTER: pr$2,
|
|
6796
|
+
MAX_WINDOW: 99,
|
|
6797
|
+
[er$2]: !1
|
|
6798
|
+
});
|
|
6799
|
+
function hr$1(r) {
|
|
6800
|
+
if (!r) return d$4;
|
|
6801
|
+
r.MIN_SECRET_BYTES !== void 0 && y$1("MIN_SECRET_BYTES", r.MIN_SECRET_BYTES, 1), r.MAX_SECRET_BYTES !== void 0 && y$1("MAX_SECRET_BYTES", r.MAX_SECRET_BYTES, 1), r.MIN_PERIOD !== void 0 && y$1("MIN_PERIOD", r.MIN_PERIOD, 1), r.MAX_PERIOD !== void 0 && y$1("MAX_PERIOD", r.MAX_PERIOD, 1), r.MAX_COUNTER !== void 0 && y$1("MAX_COUNTER", r.MAX_COUNTER, 0), r.MAX_WINDOW !== void 0 && y$1("MAX_WINDOW", r.MAX_WINDOW, 1);
|
|
6802
|
+
let e = {
|
|
6803
|
+
...d$4,
|
|
6804
|
+
...r
|
|
5114
6805
|
};
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
6806
|
+
if (e.MIN_SECRET_BYTES > e.MAX_SECRET_BYTES) throw new a$1("Guardrail 'MIN_SECRET_BYTES' must be <= 'MAX_SECRET_BYTES'");
|
|
6807
|
+
if (e.MIN_PERIOD > e.MAX_PERIOD) throw new a$1("Guardrail 'MIN_PERIOD' must be <= 'MAX_PERIOD'");
|
|
6808
|
+
return Object.freeze({
|
|
6809
|
+
...e,
|
|
6810
|
+
[er$2]: !0
|
|
6811
|
+
});
|
|
6812
|
+
}
|
|
6813
|
+
function Or$1(r, e = d$4) {
|
|
6814
|
+
if (r.length < e.MIN_SECRET_BYTES) throw new h$1(e.MIN_SECRET_BYTES, r.length);
|
|
6815
|
+
if (r.length > e.MAX_SECRET_BYTES) throw new P$1(e.MAX_SECRET_BYTES, r.length);
|
|
6816
|
+
}
|
|
6817
|
+
function br(r, e = d$4) {
|
|
6818
|
+
if (typeof r == "number") {
|
|
6819
|
+
if (!Number.isFinite(r) || !Number.isInteger(r)) throw new b$2();
|
|
6820
|
+
if (!Number.isSafeInteger(r)) throw new T$2();
|
|
6821
|
+
}
|
|
6822
|
+
let t = typeof r == "bigint" ? r : BigInt(r);
|
|
6823
|
+
if (t < 0n) throw new O$2();
|
|
6824
|
+
if (t > BigInt(e.MAX_COUNTER)) throw new T$2();
|
|
6825
|
+
}
|
|
6826
|
+
function Sr$1(r, e) {
|
|
6827
|
+
if (r.length !== e) throw new I$2(e, r.length);
|
|
6828
|
+
if (!/^\d+$/.test(r)) throw new M$1();
|
|
6829
|
+
}
|
|
6830
|
+
function Br(r, e = d$4) {
|
|
6831
|
+
let [t, o] = Er(r);
|
|
6832
|
+
if (!Number.isSafeInteger(t) || !Number.isSafeInteger(o)) throw new g$1("Counter tolerance values must be safe integers");
|
|
6833
|
+
if (t < 0 || o < 0) throw new X$1();
|
|
6834
|
+
let n = t + o + 1;
|
|
6835
|
+
if (n > e.MAX_WINDOW) throw new U$2(e.MAX_WINDOW, n);
|
|
6836
|
+
}
|
|
6837
|
+
function _r(r) {
|
|
6838
|
+
let e = typeof r == "bigint" ? r : BigInt(r), t = /* @__PURE__ */ new ArrayBuffer(8);
|
|
6839
|
+
return new DataView(t).setBigUint64(0, e, !1), new Uint8Array(t);
|
|
6840
|
+
}
|
|
6841
|
+
function Rr(r) {
|
|
6842
|
+
let e = r[r.length - 1] & 15;
|
|
6843
|
+
return (r[e] & 127) << 24 | r[e + 1] << 16 | r[e + 2] << 8 | r[e + 3];
|
|
6844
|
+
}
|
|
6845
|
+
function Ir(r, e) {
|
|
6846
|
+
return (r % 10 ** e).toString().padStart(e, "0");
|
|
6847
|
+
}
|
|
6848
|
+
function vr$1(r, e) {
|
|
6849
|
+
return typeof r == "string" ? (nr$1(e), e.decode(r)) : r;
|
|
6850
|
+
}
|
|
6851
|
+
function Er(r = 0) {
|
|
6852
|
+
return Array.isArray(r) ? r : [0, r];
|
|
6853
|
+
}
|
|
6854
|
+
function dr$1(r) {
|
|
6855
|
+
if (!r) throw new Y$2();
|
|
6856
|
+
}
|
|
6857
|
+
function nr$1(r) {
|
|
6858
|
+
if (!r) throw new L$1();
|
|
6859
|
+
}
|
|
6860
|
+
function Xr$1(r) {
|
|
6861
|
+
if (!r) throw new W$1();
|
|
6862
|
+
}
|
|
6863
|
+
var K = class {
|
|
6864
|
+
constructor(e) {
|
|
6865
|
+
this.crypto = e;
|
|
6866
|
+
}
|
|
6867
|
+
get plugin() {
|
|
6868
|
+
return this.crypto;
|
|
6869
|
+
}
|
|
6870
|
+
async hmac(e, t, o) {
|
|
6871
|
+
try {
|
|
6872
|
+
let n = this.crypto.hmac(e, t, o);
|
|
6873
|
+
return n instanceof Promise ? await n : n;
|
|
6874
|
+
} catch (n) {
|
|
6875
|
+
throw new c$2(n instanceof Error ? n.message : String(n), { cause: n });
|
|
6876
|
+
}
|
|
6877
|
+
}
|
|
6878
|
+
hmacSync(e, t, o) {
|
|
6879
|
+
try {
|
|
6880
|
+
let n = this.crypto.hmac(e, t, o);
|
|
6881
|
+
if (n instanceof Promise) throw new c$2("Crypto plugin does not support synchronous HMAC operations");
|
|
6882
|
+
return n;
|
|
6883
|
+
} catch (n) {
|
|
6884
|
+
if (n instanceof c$2) throw n;
|
|
6885
|
+
throw new c$2(n instanceof Error ? n.message : String(n), { cause: n });
|
|
6886
|
+
}
|
|
6887
|
+
}
|
|
6888
|
+
randomBytes(e) {
|
|
6889
|
+
try {
|
|
6890
|
+
return this.crypto.randomBytes(e);
|
|
6891
|
+
} catch (t) {
|
|
6892
|
+
throw new v$2(t instanceof Error ? t.message : String(t), { cause: t });
|
|
6893
|
+
}
|
|
6894
|
+
}
|
|
6895
|
+
};
|
|
6896
|
+
function Wr(r) {
|
|
6897
|
+
return new K(r);
|
|
6898
|
+
}
|
|
5118
6899
|
//#endregion
|
|
5119
|
-
//#region ../../node_modules/
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
255,
|
|
5136
|
-
255,
|
|
5137
|
-
255,
|
|
5138
|
-
255,
|
|
5139
|
-
255,
|
|
5140
|
-
0,
|
|
5141
|
-
1,
|
|
5142
|
-
2,
|
|
5143
|
-
3,
|
|
5144
|
-
4,
|
|
5145
|
-
5,
|
|
5146
|
-
6,
|
|
5147
|
-
7,
|
|
5148
|
-
8,
|
|
5149
|
-
9,
|
|
5150
|
-
10,
|
|
5151
|
-
11,
|
|
5152
|
-
12,
|
|
5153
|
-
13,
|
|
5154
|
-
14,
|
|
5155
|
-
15,
|
|
5156
|
-
16,
|
|
5157
|
-
17,
|
|
5158
|
-
18,
|
|
5159
|
-
19,
|
|
5160
|
-
20,
|
|
5161
|
-
21,
|
|
5162
|
-
22,
|
|
5163
|
-
23,
|
|
5164
|
-
24,
|
|
5165
|
-
25,
|
|
5166
|
-
255,
|
|
5167
|
-
255,
|
|
5168
|
-
255,
|
|
5169
|
-
255,
|
|
5170
|
-
255,
|
|
5171
|
-
255,
|
|
5172
|
-
0,
|
|
5173
|
-
1,
|
|
5174
|
-
2,
|
|
5175
|
-
3,
|
|
5176
|
-
4,
|
|
5177
|
-
5,
|
|
5178
|
-
6,
|
|
5179
|
-
7,
|
|
5180
|
-
8,
|
|
5181
|
-
9,
|
|
5182
|
-
10,
|
|
5183
|
-
11,
|
|
5184
|
-
12,
|
|
5185
|
-
13,
|
|
5186
|
-
14,
|
|
5187
|
-
15,
|
|
5188
|
-
16,
|
|
5189
|
-
17,
|
|
5190
|
-
18,
|
|
5191
|
-
19,
|
|
5192
|
-
20,
|
|
5193
|
-
21,
|
|
5194
|
-
22,
|
|
5195
|
-
23,
|
|
5196
|
-
24,
|
|
5197
|
-
25,
|
|
5198
|
-
255,
|
|
5199
|
-
255,
|
|
5200
|
-
255,
|
|
5201
|
-
255,
|
|
5202
|
-
255
|
|
5203
|
-
];
|
|
5204
|
-
function quintetCount(buff) {
|
|
5205
|
-
var quintets = Math.floor(buff.length / 5);
|
|
5206
|
-
return buff.length % 5 === 0 ? quintets : quintets + 1;
|
|
5207
|
-
}
|
|
5208
|
-
exports.encode = function(plain) {
|
|
5209
|
-
if (!Buffer.isBuffer(plain)) plain = new Buffer(plain);
|
|
5210
|
-
var i = 0;
|
|
5211
|
-
var j = 0;
|
|
5212
|
-
var shiftIndex = 0;
|
|
5213
|
-
var digit = 0;
|
|
5214
|
-
var encoded = new Buffer(quintetCount(plain) * 8);
|
|
5215
|
-
while (i < plain.length) {
|
|
5216
|
-
var current = plain[i];
|
|
5217
|
-
if (shiftIndex > 3) {
|
|
5218
|
-
digit = current & 255 >> shiftIndex;
|
|
5219
|
-
shiftIndex = (shiftIndex + 5) % 8;
|
|
5220
|
-
digit = digit << shiftIndex | (i + 1 < plain.length ? plain[i + 1] : 0) >> 8 - shiftIndex;
|
|
5221
|
-
i++;
|
|
5222
|
-
} else {
|
|
5223
|
-
digit = current >> 8 - (shiftIndex + 5) & 31;
|
|
5224
|
-
shiftIndex = (shiftIndex + 5) % 8;
|
|
5225
|
-
if (shiftIndex === 0) i++;
|
|
5226
|
-
}
|
|
5227
|
-
encoded[j] = charTable.charCodeAt(digit);
|
|
5228
|
-
j++;
|
|
6900
|
+
//#region ../../node_modules/@otplib/uri/dist/index.js
|
|
6901
|
+
function m$1(r) {
|
|
6902
|
+
let { type: e, label: s, params: t } = r, o = `otpauth://${e}/${s.split(":").map((c) => encodeURIComponent(c)).join(":")}?`, n = [];
|
|
6903
|
+
return t.secret && n.push(`secret=${encodeURIComponent(t.secret)}`), t.issuer && n.push(`issuer=${encodeURIComponent(t.issuer)}`), t.algorithm && t.algorithm !== "sha1" && n.push(`algorithm=${t.algorithm.toUpperCase()}`), t.digits && t.digits !== 6 && n.push(`digits=${t.digits}`), e === "hotp" && t.counter !== void 0 && n.push(`counter=${t.counter}`), e === "totp" && t.period !== void 0 && t.period !== 30 && n.push(`period=${t.period}`), o += n.join("&"), o;
|
|
6904
|
+
}
|
|
6905
|
+
function x$1(r) {
|
|
6906
|
+
let { issuer: e, label: s, secret: t, algorithm: i = "sha1", digits: o = 6, period: n = 30 } = r;
|
|
6907
|
+
return m$1({
|
|
6908
|
+
type: "totp",
|
|
6909
|
+
label: e ? `${e}:${s}` : s,
|
|
6910
|
+
params: {
|
|
6911
|
+
secret: t,
|
|
6912
|
+
issuer: e,
|
|
6913
|
+
algorithm: i,
|
|
6914
|
+
digits: o,
|
|
6915
|
+
period: n
|
|
5229
6916
|
}
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
if (encodedByte < byteTable.length) {
|
|
5244
|
-
plainDigit = byteTable[encodedByte];
|
|
5245
|
-
if (shiftIndex <= 3) {
|
|
5246
|
-
shiftIndex = (shiftIndex + 5) % 8;
|
|
5247
|
-
if (shiftIndex === 0) {
|
|
5248
|
-
plainChar |= plainDigit;
|
|
5249
|
-
decoded[plainPos] = plainChar;
|
|
5250
|
-
plainPos++;
|
|
5251
|
-
plainChar = 0;
|
|
5252
|
-
} else plainChar |= 255 & plainDigit << 8 - shiftIndex;
|
|
5253
|
-
} else {
|
|
5254
|
-
shiftIndex = (shiftIndex + 5) % 8;
|
|
5255
|
-
plainChar |= 255 & plainDigit >>> shiftIndex;
|
|
5256
|
-
decoded[plainPos] = plainChar;
|
|
5257
|
-
plainPos++;
|
|
5258
|
-
plainChar = 255 & plainDigit << 8 - shiftIndex;
|
|
5259
|
-
}
|
|
5260
|
-
} else throw new Error("Invalid input - it is not base32 encoded string");
|
|
6917
|
+
});
|
|
6918
|
+
}
|
|
6919
|
+
function U$1(r) {
|
|
6920
|
+
let { issuer: e, label: s, secret: t, counter: i = 0, algorithm: o = "sha1", digits: n = 6 } = r;
|
|
6921
|
+
return m$1({
|
|
6922
|
+
type: "hotp",
|
|
6923
|
+
label: e ? `${e}:${s}` : s,
|
|
6924
|
+
params: {
|
|
6925
|
+
secret: t,
|
|
6926
|
+
issuer: e,
|
|
6927
|
+
algorithm: o,
|
|
6928
|
+
digits: n,
|
|
6929
|
+
counter: i
|
|
5261
6930
|
}
|
|
5262
|
-
|
|
6931
|
+
});
|
|
6932
|
+
}
|
|
6933
|
+
//#endregion
|
|
6934
|
+
//#region ../../node_modules/@otplib/hotp/dist/index.js
|
|
6935
|
+
function v$1(u) {
|
|
6936
|
+
let { secret: t, counter: e, algorithm: r = "sha1", digits: i = 6, crypto: n, base32: o, guardrails: a, hooks: s } = u;
|
|
6937
|
+
Xr$1(t), dr$1(n);
|
|
6938
|
+
let c = vr$1(t, o);
|
|
6939
|
+
Or$1(c, a), br(e, a);
|
|
6940
|
+
return {
|
|
6941
|
+
ctx: Wr(n),
|
|
6942
|
+
algorithm: r,
|
|
6943
|
+
digits: i,
|
|
6944
|
+
secretBytes: c,
|
|
6945
|
+
counterBytes: _r(e),
|
|
6946
|
+
hooks: s
|
|
5263
6947
|
};
|
|
5264
|
-
}
|
|
6948
|
+
}
|
|
6949
|
+
function F$1(u) {
|
|
6950
|
+
let { ctx: t, algorithm: e, digits: r, secretBytes: i, counterBytes: n, hooks: o } = v$1(u), a = t.hmacSync(e, i, n), s = o?.truncateDigest ? o.truncateDigest(a) : Rr(a);
|
|
6951
|
+
return o?.encodeToken ? o.encodeToken(s, r) : Ir(s, r);
|
|
6952
|
+
}
|
|
6953
|
+
function G$1(u) {
|
|
6954
|
+
let { secret: t, counter: e, token: r, algorithm: i = "sha1", digits: n = 6, crypto: o, base32: a, counterTolerance: s = 0, guardrails: c = hr$1(), hooks: p } = u;
|
|
6955
|
+
Xr$1(t), dr$1(o);
|
|
6956
|
+
let l = vr$1(t, a);
|
|
6957
|
+
Or$1(l, c), br(e, c), p?.validateToken ? p.validateToken(r, n) : Sr$1(r, n), Br(s, c);
|
|
6958
|
+
let V = typeof e == "bigint" ? Number(e) : e, [f, d] = Er(s);
|
|
6959
|
+
return {
|
|
6960
|
+
token: r,
|
|
6961
|
+
counterNum: V,
|
|
6962
|
+
past: f,
|
|
6963
|
+
future: d,
|
|
6964
|
+
totalChecks: f + d + 1,
|
|
6965
|
+
crypto: o,
|
|
6966
|
+
getGenerateOptions: (B) => ({
|
|
6967
|
+
secret: l,
|
|
6968
|
+
counter: B,
|
|
6969
|
+
algorithm: i,
|
|
6970
|
+
digits: n,
|
|
6971
|
+
crypto: o,
|
|
6972
|
+
guardrails: c,
|
|
6973
|
+
hooks: p
|
|
6974
|
+
})
|
|
6975
|
+
};
|
|
6976
|
+
}
|
|
6977
|
+
function Y$1(u) {
|
|
6978
|
+
let { token: t, counterNum: e, past: r, totalChecks: i, crypto: n, getGenerateOptions: o } = G$1(u), a = Math.max(0, r - e);
|
|
6979
|
+
for (let s = a; s < i; s++) {
|
|
6980
|
+
let c = s - r, l = F$1(o(e + c));
|
|
6981
|
+
if (n.constantTimeEqual(l, t)) return {
|
|
6982
|
+
valid: !0,
|
|
6983
|
+
delta: c | 0
|
|
6984
|
+
};
|
|
6985
|
+
}
|
|
6986
|
+
return { valid: !1 };
|
|
6987
|
+
}
|
|
5265
6988
|
//#endregion
|
|
5266
|
-
//#region ../../node_modules/
|
|
5267
|
-
var
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
}
|
|
6989
|
+
//#region ../../node_modules/@otplib/totp/node_modules/@otplib/core/dist/index.js
|
|
6990
|
+
var i = class extends Error {
|
|
6991
|
+
constructor(e, t) {
|
|
6992
|
+
super(e, t), this.name = "OTPError";
|
|
6993
|
+
}
|
|
6994
|
+
}, x = class extends i {
|
|
6995
|
+
constructor(e) {
|
|
6996
|
+
super(e), this.name = "SecretError";
|
|
6997
|
+
}
|
|
6998
|
+
}, h = class extends x {
|
|
6999
|
+
constructor(e, t) {
|
|
7000
|
+
super(`Secret must be at least ${e} bytes (${e * 8} bits), got ${t} bytes`), this.name = "SecretTooShortError";
|
|
7001
|
+
}
|
|
7002
|
+
}, P = class extends x {
|
|
7003
|
+
constructor(e, t) {
|
|
7004
|
+
super(`Secret must not exceed ${e} bytes, got ${t} bytes`), this.name = "SecretTooLongError";
|
|
7005
|
+
}
|
|
7006
|
+
}, A$1 = class extends i {
|
|
7007
|
+
constructor(e) {
|
|
7008
|
+
super(e), this.name = "TimeError";
|
|
7009
|
+
}
|
|
7010
|
+
}, C = class extends A$1 {
|
|
7011
|
+
constructor() {
|
|
7012
|
+
super("Time must be non-negative"), this.name = "TimeNegativeError";
|
|
7013
|
+
}
|
|
7014
|
+
}, S = class extends A$1 {
|
|
7015
|
+
constructor() {
|
|
7016
|
+
super("Time must be a finite number"), this.name = "TimeNotFiniteError";
|
|
7017
|
+
}
|
|
7018
|
+
}, B = class extends i {
|
|
7019
|
+
constructor(e) {
|
|
7020
|
+
super(e), this.name = "PeriodError";
|
|
7021
|
+
}
|
|
7022
|
+
}, w$1 = class extends B {
|
|
7023
|
+
constructor(e) {
|
|
7024
|
+
super(`Period must be at least ${e} second(s)`), this.name = "PeriodTooSmallError";
|
|
7025
|
+
}
|
|
7026
|
+
}, _$1 = class extends B {
|
|
7027
|
+
constructor(e) {
|
|
7028
|
+
super(`Period must not exceed ${e} seconds`), this.name = "PeriodTooLargeError";
|
|
7029
|
+
}
|
|
7030
|
+
}, R$1 = class extends i {
|
|
7031
|
+
constructor(e) {
|
|
7032
|
+
super(e), this.name = "TokenError";
|
|
7033
|
+
}
|
|
7034
|
+
}, I$1 = class extends R$1 {
|
|
7035
|
+
constructor(e, t) {
|
|
7036
|
+
super(`Token must be ${e} digits, got ${t}`), this.name = "TokenLengthError";
|
|
7037
|
+
}
|
|
7038
|
+
}, M = class extends R$1 {
|
|
7039
|
+
constructor() {
|
|
7040
|
+
super("Token must contain only digits"), this.name = "TokenFormatError";
|
|
7041
|
+
}
|
|
7042
|
+
}, E = class extends i {
|
|
7043
|
+
constructor(e) {
|
|
7044
|
+
super(e), this.name = "EpochToleranceError";
|
|
7045
|
+
}
|
|
7046
|
+
}, k$1 = class extends E {
|
|
7047
|
+
constructor() {
|
|
7048
|
+
super("Epoch tolerance cannot contain negative values"), this.name = "EpochToleranceNegativeError";
|
|
7049
|
+
}
|
|
7050
|
+
}, q = class extends E {
|
|
7051
|
+
constructor(e, t) {
|
|
7052
|
+
super(`Epoch tolerance must not exceed ${e} seconds, got ${t}. Large tolerances can cause performance issues.`), this.name = "EpochToleranceTooLargeError";
|
|
7053
|
+
}
|
|
7054
|
+
}, G = class extends i {
|
|
7055
|
+
constructor(e) {
|
|
7056
|
+
super(e), this.name = "PluginError";
|
|
7057
|
+
}
|
|
7058
|
+
}, Y = class extends G {
|
|
7059
|
+
constructor() {
|
|
7060
|
+
super("Crypto plugin is required."), this.name = "CryptoPluginMissingError";
|
|
7061
|
+
}
|
|
7062
|
+
}, L = class extends G {
|
|
7063
|
+
constructor() {
|
|
7064
|
+
super("Base32 plugin is required."), this.name = "Base32PluginMissingError";
|
|
7065
|
+
}
|
|
7066
|
+
}, a = class extends i {
|
|
7067
|
+
constructor(e) {
|
|
7068
|
+
super(e), this.name = "ConfigurationError";
|
|
7069
|
+
}
|
|
7070
|
+
}, W = class extends a {
|
|
7071
|
+
constructor() {
|
|
7072
|
+
super("Secret is required. Use generateSecret() to create one, or provide via { secret: 'YOUR_BASE32_SECRET' }"), this.name = "SecretMissingError";
|
|
7073
|
+
}
|
|
7074
|
+
}, f = class extends i {
|
|
7075
|
+
constructor(e) {
|
|
7076
|
+
super(e), this.name = "AfterTimeStepError";
|
|
7077
|
+
}
|
|
7078
|
+
}, J = class extends f {
|
|
7079
|
+
constructor() {
|
|
7080
|
+
super("afterTimeStep must be >= 0"), this.name = "AfterTimeStepNegativeError";
|
|
7081
|
+
}
|
|
7082
|
+
}, Q = class extends f {
|
|
7083
|
+
constructor() {
|
|
7084
|
+
super("Invalid afterTimeStep: non-integer value"), this.name = "AfterTimeStepNotIntegerError";
|
|
7085
|
+
}
|
|
7086
|
+
}, Z$1 = class extends f {
|
|
7087
|
+
constructor() {
|
|
7088
|
+
super("Invalid afterTimeStep: cannot be greater than current time step plus window"), this.name = "AfterTimeStepRangeExceededError";
|
|
7089
|
+
}
|
|
7090
|
+
};
|
|
7091
|
+
new TextEncoder();
|
|
7092
|
+
new TextDecoder();
|
|
7093
|
+
var ur$1 = 3600, pr$1 = Number.MAX_SAFE_INTEGER, er$1 = Symbol("otplib.guardrails.override");
|
|
7094
|
+
function y(r, e, t) {
|
|
7095
|
+
if (typeof e != "number" || !Number.isSafeInteger(e)) throw new a(`Guardrail '${r}' must be a safe integer`);
|
|
7096
|
+
if (e < t) throw new a(`Guardrail '${r}' must be >= ${t}`);
|
|
7097
|
+
}
|
|
7098
|
+
var d$3 = Object.freeze({
|
|
7099
|
+
MIN_SECRET_BYTES: 16,
|
|
7100
|
+
MAX_SECRET_BYTES: 64,
|
|
7101
|
+
MIN_PERIOD: 1,
|
|
7102
|
+
MAX_PERIOD: ur$1,
|
|
7103
|
+
MAX_COUNTER: pr$1,
|
|
7104
|
+
MAX_WINDOW: 99,
|
|
7105
|
+
[er$1]: !1
|
|
7106
|
+
});
|
|
7107
|
+
function hr(r) {
|
|
7108
|
+
if (!r) return d$3;
|
|
7109
|
+
r.MIN_SECRET_BYTES !== void 0 && y("MIN_SECRET_BYTES", r.MIN_SECRET_BYTES, 1), r.MAX_SECRET_BYTES !== void 0 && y("MAX_SECRET_BYTES", r.MAX_SECRET_BYTES, 1), r.MIN_PERIOD !== void 0 && y("MIN_PERIOD", r.MIN_PERIOD, 1), r.MAX_PERIOD !== void 0 && y("MAX_PERIOD", r.MAX_PERIOD, 1), r.MAX_COUNTER !== void 0 && y("MAX_COUNTER", r.MAX_COUNTER, 0), r.MAX_WINDOW !== void 0 && y("MAX_WINDOW", r.MAX_WINDOW, 1);
|
|
7110
|
+
let e = {
|
|
7111
|
+
...d$3,
|
|
7112
|
+
...r
|
|
7113
|
+
};
|
|
7114
|
+
if (e.MIN_SECRET_BYTES > e.MAX_SECRET_BYTES) throw new a("Guardrail 'MIN_SECRET_BYTES' must be <= 'MAX_SECRET_BYTES'");
|
|
7115
|
+
if (e.MIN_PERIOD > e.MAX_PERIOD) throw new a("Guardrail 'MIN_PERIOD' must be <= 'MAX_PERIOD'");
|
|
7116
|
+
return Object.freeze({
|
|
7117
|
+
...e,
|
|
7118
|
+
[er$1]: !0
|
|
7119
|
+
});
|
|
7120
|
+
}
|
|
7121
|
+
function Or(r, e = d$3) {
|
|
7122
|
+
if (r.length < e.MIN_SECRET_BYTES) throw new h(e.MIN_SECRET_BYTES, r.length);
|
|
7123
|
+
if (r.length > e.MAX_SECRET_BYTES) throw new P(e.MAX_SECRET_BYTES, r.length);
|
|
7124
|
+
}
|
|
7125
|
+
function Ar(r) {
|
|
7126
|
+
if (!Number.isFinite(r)) throw new S();
|
|
7127
|
+
if (r < 0) throw new C();
|
|
7128
|
+
}
|
|
7129
|
+
function Cr(r, e = d$3) {
|
|
7130
|
+
if (!Number.isInteger(r) || r < e.MIN_PERIOD) throw new w$1(e.MIN_PERIOD);
|
|
7131
|
+
if (r > e.MAX_PERIOD) throw new _$1(e.MAX_PERIOD);
|
|
7132
|
+
}
|
|
7133
|
+
function Sr(r, e) {
|
|
7134
|
+
if (r.length !== e) throw new I$1(e, r.length);
|
|
7135
|
+
if (!/^\d+$/.test(r)) throw new M();
|
|
7136
|
+
}
|
|
7137
|
+
function wr(r, e = 30, t = d$3) {
|
|
7138
|
+
let [o, n] = Array.isArray(r) ? r : [r, r];
|
|
7139
|
+
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(n)) throw new E("Epoch tolerance values must be safe integers");
|
|
7140
|
+
if (o < 0 || n < 0) throw new k$1();
|
|
7141
|
+
let s = (t.MAX_WINDOW - 1) * e, u = o + n;
|
|
7142
|
+
if (u > s) throw new q(s, u);
|
|
7143
|
+
}
|
|
7144
|
+
function vr(r, e) {
|
|
7145
|
+
return typeof r == "string" ? (nr(e), e.decode(r)) : r;
|
|
7146
|
+
}
|
|
7147
|
+
function Ur(r = 0) {
|
|
7148
|
+
return Array.isArray(r) ? r : [r, r];
|
|
7149
|
+
}
|
|
7150
|
+
function dr(r) {
|
|
7151
|
+
if (!r) throw new Y();
|
|
7152
|
+
}
|
|
7153
|
+
function nr(r) {
|
|
7154
|
+
if (!r) throw new L();
|
|
7155
|
+
}
|
|
7156
|
+
function Xr(r) {
|
|
7157
|
+
if (!r) throw new W();
|
|
7158
|
+
}
|
|
5272
7159
|
//#endregion
|
|
5273
|
-
//#region ../../node_modules/@otplib/
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
var keyDecoder = (encodedSecret, encoding) => {
|
|
5288
|
-
return thirtyTwo.decode(encodedSecret).toString(encoding);
|
|
7160
|
+
//#region ../../node_modules/@otplib/totp/dist/index.js
|
|
7161
|
+
function k(r) {
|
|
7162
|
+
let { secret: e, epoch: n = Math.floor(Date.now() / 1e3), t0: o = 0, period: i = 30, algorithm: s = "sha1", digits: l = 6, crypto: a, base32: u, guardrails: c = hr(), hooks: t } = r;
|
|
7163
|
+
Xr(e), dr(a);
|
|
7164
|
+
let p = vr(e, u);
|
|
7165
|
+
Or(p, c), Ar(n), Cr(i, c);
|
|
7166
|
+
return {
|
|
7167
|
+
secret: p,
|
|
7168
|
+
counter: Math.floor((n - o) / i),
|
|
7169
|
+
algorithm: s,
|
|
7170
|
+
digits: l,
|
|
7171
|
+
crypto: a,
|
|
7172
|
+
guardrails: c,
|
|
7173
|
+
hooks: t
|
|
5289
7174
|
};
|
|
5290
|
-
|
|
5291
|
-
|
|
7175
|
+
}
|
|
7176
|
+
function Z(r) {
|
|
7177
|
+
return F$1(k(r));
|
|
7178
|
+
}
|
|
7179
|
+
function _(r, e) {
|
|
7180
|
+
if (r !== void 0) {
|
|
7181
|
+
if (r < 0) throw new J();
|
|
7182
|
+
if (!Number.isSafeInteger(r)) throw new Q();
|
|
7183
|
+
if (r > e) throw new Z$1();
|
|
7184
|
+
}
|
|
7185
|
+
}
|
|
7186
|
+
function w(r, e) {
|
|
7187
|
+
return e !== void 0 && r <= e;
|
|
7188
|
+
}
|
|
7189
|
+
function R(r) {
|
|
7190
|
+
let { secret: e, token: n, epoch: o = Math.floor(Date.now() / 1e3), t0: i = 0, period: s = 30, algorithm: l = "sha1", digits: a = 6, crypto: u, base32: c, epochTolerance: t = 0, afterTimeStep: p, guardrails: f = hr(), hooks: T } = r;
|
|
7191
|
+
Xr(e), dr(u);
|
|
7192
|
+
let m = vr(e, c);
|
|
7193
|
+
Or(m, f), Ar(o), Cr(s, f), T?.validateToken ? T.validateToken(n, a) : Sr(n, a), wr(t, s, f);
|
|
7194
|
+
let M = Math.floor((o - i) / s), [I, q] = Ur(t), A = Math.max(0, Math.floor((o - I - i) / s)), S = Math.floor((o + q - i) / s);
|
|
7195
|
+
return _(p, S), {
|
|
7196
|
+
token: n,
|
|
7197
|
+
crypto: u,
|
|
7198
|
+
minCounter: A,
|
|
7199
|
+
maxCounter: S,
|
|
7200
|
+
currentCounter: M,
|
|
7201
|
+
t0: i,
|
|
7202
|
+
period: s,
|
|
7203
|
+
afterTimeStep: p,
|
|
7204
|
+
getGenerateOptions: (D) => ({
|
|
7205
|
+
secret: m,
|
|
7206
|
+
epoch: D * s + i,
|
|
7207
|
+
t0: i,
|
|
7208
|
+
period: s,
|
|
7209
|
+
algorithm: l,
|
|
7210
|
+
digits: a,
|
|
7211
|
+
crypto: u,
|
|
7212
|
+
guardrails: f,
|
|
7213
|
+
hooks: T
|
|
7214
|
+
})
|
|
5292
7215
|
};
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
})
|
|
7216
|
+
}
|
|
7217
|
+
function ie(r) {
|
|
7218
|
+
let { token: e, crypto: n, minCounter: o, maxCounter: i, currentCounter: s, t0: l, period: a, afterTimeStep: u, getGenerateOptions: c } = R(r);
|
|
7219
|
+
for (let t = o; t <= i; t++) {
|
|
7220
|
+
if (w(t, u)) continue;
|
|
7221
|
+
let p = Z(c(t));
|
|
7222
|
+
if (n.constantTimeEqual(p, e)) return {
|
|
7223
|
+
valid: !0,
|
|
7224
|
+
delta: t - s,
|
|
7225
|
+
epoch: t * a + l,
|
|
7226
|
+
timeStep: t
|
|
7227
|
+
};
|
|
7228
|
+
}
|
|
7229
|
+
return { valid: !1 };
|
|
7230
|
+
}
|
|
5296
7231
|
//#endregion
|
|
5297
|
-
//#region ../../node_modules/@
|
|
7232
|
+
//#region ../../node_modules/@scure/base/index.js
|
|
7233
|
+
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
7234
|
+
function isBytes$1(a) {
|
|
7235
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
7236
|
+
}
|
|
7237
|
+
function isArrayOf(isString, arr) {
|
|
7238
|
+
if (!Array.isArray(arr)) return false;
|
|
7239
|
+
if (arr.length === 0) return true;
|
|
7240
|
+
if (isString) return arr.every((item) => typeof item === "string");
|
|
7241
|
+
else return arr.every((item) => Number.isSafeInteger(item));
|
|
7242
|
+
}
|
|
7243
|
+
function afn(input) {
|
|
7244
|
+
if (typeof input !== "function") throw new TypeError("function expected");
|
|
7245
|
+
return true;
|
|
7246
|
+
}
|
|
7247
|
+
function astr(label, input) {
|
|
7248
|
+
if (typeof input !== "string") throw new TypeError(`${label}: string expected`);
|
|
7249
|
+
return true;
|
|
7250
|
+
}
|
|
7251
|
+
function anumber$1(n) {
|
|
7252
|
+
if (typeof n !== "number") throw new TypeError(`number expected, got ${typeof n}`);
|
|
7253
|
+
if (!Number.isSafeInteger(n)) throw new RangeError(`invalid integer: ${n}`);
|
|
7254
|
+
}
|
|
7255
|
+
function aArr(input) {
|
|
7256
|
+
if (!Array.isArray(input)) throw new TypeError("array expected");
|
|
7257
|
+
}
|
|
7258
|
+
function astrArr(label, input) {
|
|
7259
|
+
if (!isArrayOf(true, input)) throw new TypeError(`${label}: array of strings expected`);
|
|
7260
|
+
}
|
|
7261
|
+
function anumArr(label, input) {
|
|
7262
|
+
if (!isArrayOf(false, input)) throw new TypeError(`${label}: array of numbers expected`);
|
|
7263
|
+
}
|
|
5298
7264
|
/**
|
|
5299
|
-
* @
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
function objectValues(value) {
|
|
5308
|
-
return Object.keys(value).map((key) => value[key]);
|
|
5309
|
-
}
|
|
5310
|
-
(function(HashAlgorithms) {
|
|
5311
|
-
HashAlgorithms["SHA1"] = "sha1";
|
|
5312
|
-
HashAlgorithms["SHA256"] = "sha256";
|
|
5313
|
-
HashAlgorithms["SHA512"] = "sha512";
|
|
5314
|
-
})(exports.HashAlgorithms || (exports.HashAlgorithms = {}));
|
|
5315
|
-
var HASH_ALGORITHMS = objectValues(exports.HashAlgorithms);
|
|
5316
|
-
(function(KeyEncodings) {
|
|
5317
|
-
KeyEncodings["ASCII"] = "ascii";
|
|
5318
|
-
KeyEncodings["BASE64"] = "base64";
|
|
5319
|
-
KeyEncodings["HEX"] = "hex";
|
|
5320
|
-
KeyEncodings["LATIN1"] = "latin1";
|
|
5321
|
-
KeyEncodings["UTF8"] = "utf8";
|
|
5322
|
-
})(exports.KeyEncodings || (exports.KeyEncodings = {}));
|
|
5323
|
-
var KEY_ENCODINGS = objectValues(exports.KeyEncodings);
|
|
5324
|
-
(function(Strategy) {
|
|
5325
|
-
Strategy["HOTP"] = "hotp";
|
|
5326
|
-
Strategy["TOTP"] = "totp";
|
|
5327
|
-
})(exports.Strategy || (exports.Strategy = {}));
|
|
5328
|
-
var STRATEGY = objectValues(exports.Strategy);
|
|
5329
|
-
var createDigestPlaceholder = () => {
|
|
5330
|
-
throw new Error("Please provide an options.createDigest implementation.");
|
|
7265
|
+
* @__NO_SIDE_EFFECTS__
|
|
7266
|
+
*/
|
|
7267
|
+
function chain(...args) {
|
|
7268
|
+
const id = (a) => a;
|
|
7269
|
+
const wrap = (a, b) => (c) => a(b(c));
|
|
7270
|
+
return {
|
|
7271
|
+
encode: args.map((x) => x.encode).reduceRight(wrap, id),
|
|
7272
|
+
decode: args.map((x) => x.decode).reduce(wrap, id)
|
|
5331
7273
|
};
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
if (options.algorithm) params.push(`&algorithm=${options.algorithm.toUpperCase()}`);
|
|
5350
|
-
if (options.issuer) params.push(`&issuer=${encodeURIComponent(options.issuer)}`);
|
|
5351
|
-
return tmpl.replace("{labelPrefix}", encodeURIComponent(options.issuer || options.accountName)).replace("{accountName}", encodeURIComponent(options.accountName)).replace("{secret}", options.secret).replace("{query}", params.join(""));
|
|
5352
|
-
}
|
|
5353
|
-
var OTP = class OTP {
|
|
5354
|
-
constructor(defaultOptions = {}) {
|
|
5355
|
-
this._defaultOptions = Object.freeze({ ...defaultOptions });
|
|
5356
|
-
this._options = Object.freeze({});
|
|
5357
|
-
}
|
|
5358
|
-
create(defaultOptions = {}) {
|
|
5359
|
-
return new OTP(defaultOptions);
|
|
5360
|
-
}
|
|
5361
|
-
clone(defaultOptions = {}) {
|
|
5362
|
-
const instance = this.create({
|
|
5363
|
-
...this._defaultOptions,
|
|
5364
|
-
...defaultOptions
|
|
5365
|
-
});
|
|
5366
|
-
instance.options = this._options;
|
|
5367
|
-
return instance;
|
|
5368
|
-
}
|
|
5369
|
-
get options() {
|
|
5370
|
-
return Object.freeze({
|
|
5371
|
-
...this._defaultOptions,
|
|
5372
|
-
...this._options
|
|
7274
|
+
}
|
|
7275
|
+
/**
|
|
7276
|
+
* Encodes integer radix representation to array of strings using alphabet and back.
|
|
7277
|
+
* Could also be array of strings.
|
|
7278
|
+
* @__NO_SIDE_EFFECTS__
|
|
7279
|
+
*/
|
|
7280
|
+
function alphabet(letters) {
|
|
7281
|
+
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
7282
|
+
const len = lettersA.length;
|
|
7283
|
+
astrArr("alphabet", lettersA);
|
|
7284
|
+
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
|
7285
|
+
return {
|
|
7286
|
+
encode: (digits) => {
|
|
7287
|
+
aArr(digits);
|
|
7288
|
+
return digits.map((i) => {
|
|
7289
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= len) throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
|
7290
|
+
return lettersA[i];
|
|
5373
7291
|
});
|
|
5374
|
-
}
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
7292
|
+
},
|
|
7293
|
+
decode: (input) => {
|
|
7294
|
+
aArr(input);
|
|
7295
|
+
return input.map((letter) => {
|
|
7296
|
+
astr("alphabet.decode", letter);
|
|
7297
|
+
const i = indexes.get(letter);
|
|
7298
|
+
if (i === void 0) throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
7299
|
+
return i;
|
|
5379
7300
|
});
|
|
5380
7301
|
}
|
|
5381
|
-
allOptions() {
|
|
5382
|
-
return this.options;
|
|
5383
|
-
}
|
|
5384
|
-
resetOptions() {
|
|
5385
|
-
this._options = Object.freeze({});
|
|
5386
|
-
}
|
|
5387
|
-
};
|
|
5388
|
-
function hotpOptionsValidator(options) {
|
|
5389
|
-
if (typeof options.createDigest !== "function") throw new Error("Expecting options.createDigest to be a function.");
|
|
5390
|
-
if (typeof options.createHmacKey !== "function") throw new Error("Expecting options.createHmacKey to be a function.");
|
|
5391
|
-
if (typeof options.digits !== "number") throw new Error("Expecting options.digits to be a number.");
|
|
5392
|
-
if (!options.algorithm || HASH_ALGORITHMS.indexOf(options.algorithm) < 0) throw new Error(`Expecting options.algorithm to be one of ${HASH_ALGORITHMS.join(", ")}. Received ${options.algorithm}.`);
|
|
5393
|
-
if (!options.encoding || KEY_ENCODINGS.indexOf(options.encoding) < 0) throw new Error(`Expecting options.encoding to be one of ${KEY_ENCODINGS.join(", ")}. Received ${options.encoding}.`);
|
|
5394
|
-
}
|
|
5395
|
-
var hotpCreateHmacKey = (algorithm, secret, encoding) => {
|
|
5396
|
-
return Buffer.from(secret, encoding).toString("hex");
|
|
5397
7302
|
};
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
hotpOptionsValidator(options);
|
|
5413
|
-
return Object.freeze(options);
|
|
5414
|
-
}
|
|
5415
|
-
function hotpCounter(counter) {
|
|
5416
|
-
return padStart(counter.toString(16), 16, "0");
|
|
5417
|
-
}
|
|
5418
|
-
function hotpDigestToToken(hexDigest, digits) {
|
|
5419
|
-
const digest = Buffer.from(hexDigest, "hex");
|
|
5420
|
-
const offset = digest[digest.length - 1] & 15;
|
|
5421
|
-
const token = ((digest[offset] & 127) << 24 | (digest[offset + 1] & 255) << 16 | (digest[offset + 2] & 255) << 8 | digest[offset + 3] & 255) % Math.pow(10, digits);
|
|
5422
|
-
return padStart(String(token), digits, "0");
|
|
5423
|
-
}
|
|
5424
|
-
function hotpDigest(secret, counter, options) {
|
|
5425
|
-
const hexCounter = hotpCounter(counter);
|
|
5426
|
-
const hmacKey = options.createHmacKey(options.algorithm, secret, options.encoding);
|
|
5427
|
-
return options.createDigest(options.algorithm, hmacKey, hexCounter);
|
|
5428
|
-
}
|
|
5429
|
-
function hotpToken(secret, counter, options) {
|
|
5430
|
-
return hotpDigestToToken(options.digest || hotpDigest(secret, counter, options), options.digits);
|
|
5431
|
-
}
|
|
5432
|
-
function hotpCheck(token, secret, counter, options) {
|
|
5433
|
-
if (!isTokenValid(token)) return false;
|
|
5434
|
-
return token === hotpToken(secret, counter, options);
|
|
5435
|
-
}
|
|
5436
|
-
function hotpKeyuri(accountName, issuer, secret, counter, options) {
|
|
5437
|
-
return keyuri({
|
|
5438
|
-
algorithm: options.algorithm,
|
|
5439
|
-
digits: options.digits,
|
|
5440
|
-
type: exports.Strategy.HOTP,
|
|
5441
|
-
accountName,
|
|
5442
|
-
counter,
|
|
5443
|
-
issuer,
|
|
5444
|
-
secret
|
|
5445
|
-
});
|
|
5446
|
-
}
|
|
5447
|
-
var HOTP = class HOTP extends OTP {
|
|
5448
|
-
create(defaultOptions = {}) {
|
|
5449
|
-
return new HOTP(defaultOptions);
|
|
5450
|
-
}
|
|
5451
|
-
allOptions() {
|
|
5452
|
-
return hotpOptions(this.options);
|
|
5453
|
-
}
|
|
5454
|
-
generate(secret, counter) {
|
|
5455
|
-
return hotpToken(secret, counter, this.allOptions());
|
|
5456
|
-
}
|
|
5457
|
-
check(token, secret, counter) {
|
|
5458
|
-
return hotpCheck(token, secret, counter, this.allOptions());
|
|
5459
|
-
}
|
|
5460
|
-
verify(opts) {
|
|
5461
|
-
if (typeof opts !== "object") throw new Error("Expecting argument 0 of verify to be an object");
|
|
5462
|
-
return this.check(opts.token, opts.secret, opts.counter);
|
|
5463
|
-
}
|
|
5464
|
-
keyuri(accountName, issuer, secret, counter) {
|
|
5465
|
-
return hotpKeyuri(accountName, issuer, secret, counter, this.allOptions());
|
|
7303
|
+
}
|
|
7304
|
+
/**
|
|
7305
|
+
* @__NO_SIDE_EFFECTS__
|
|
7306
|
+
*/
|
|
7307
|
+
function join(separator = "") {
|
|
7308
|
+
astr("join", separator);
|
|
7309
|
+
return {
|
|
7310
|
+
encode: (from) => {
|
|
7311
|
+
astrArr("join.decode", from);
|
|
7312
|
+
return from.join(separator);
|
|
7313
|
+
},
|
|
7314
|
+
decode: (to) => {
|
|
7315
|
+
astr("join.decode", to);
|
|
7316
|
+
return to.split(separator);
|
|
5466
7317
|
}
|
|
5467
7318
|
};
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
return
|
|
7319
|
+
}
|
|
7320
|
+
/**
|
|
7321
|
+
* Pad strings array so it has integer number of bits
|
|
7322
|
+
* @__NO_SIDE_EFFECTS__
|
|
7323
|
+
*/
|
|
7324
|
+
function padding(bits, chr = "=") {
|
|
7325
|
+
anumber$1(bits);
|
|
7326
|
+
astr("padding", chr);
|
|
7327
|
+
return {
|
|
7328
|
+
encode(data) {
|
|
7329
|
+
astrArr("padding.encode", data);
|
|
7330
|
+
while (data.length * bits % 8) data.push(chr);
|
|
7331
|
+
return data;
|
|
7332
|
+
},
|
|
7333
|
+
decode(input) {
|
|
7334
|
+
astrArr("padding.decode", input);
|
|
7335
|
+
let end = input.length;
|
|
7336
|
+
if (end * bits % 8) throw new Error("padding: invalid, string should have whole number of bytes");
|
|
7337
|
+
for (; end > 0 && input[end - 1] === chr; end--) if ((end - 1) * bits % 8 === 0) throw new Error("padding: invalid, string has too much padding");
|
|
7338
|
+
return input.slice(0, end);
|
|
5488
7339
|
}
|
|
5489
|
-
return hexSecret;
|
|
5490
7340
|
};
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
7341
|
+
}
|
|
7342
|
+
/**
|
|
7343
|
+
* @__NO_SIDE_EFFECTS__
|
|
7344
|
+
*/
|
|
7345
|
+
function normalize(fn) {
|
|
7346
|
+
afn(fn);
|
|
7347
|
+
return {
|
|
7348
|
+
encode: (from) => from,
|
|
7349
|
+
decode: (to) => fn(to)
|
|
7350
|
+
};
|
|
7351
|
+
}
|
|
7352
|
+
var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
|
|
7353
|
+
var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
|
|
7354
|
+
var powers = /* @__PURE__ */ (() => {
|
|
7355
|
+
let res = [];
|
|
7356
|
+
for (let i = 0; i < 40; i++) res.push(2 ** i);
|
|
7357
|
+
return res;
|
|
7358
|
+
})();
|
|
7359
|
+
/**
|
|
7360
|
+
* Implemented with numbers, because BigInt is 5x slower
|
|
7361
|
+
*/
|
|
7362
|
+
function convertRadix2(data, from, to, padding) {
|
|
7363
|
+
aArr(data);
|
|
7364
|
+
if (from <= 0 || from > 32) throw new RangeError(`convertRadix2: wrong from=${from}`);
|
|
7365
|
+
if (to <= 0 || to > 32) throw new RangeError(`convertRadix2: wrong to=${to}`);
|
|
7366
|
+
if (/* @__PURE__ */ radix2carry(from, to) > 32) throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
|
|
7367
|
+
let carry = 0;
|
|
7368
|
+
let pos = 0;
|
|
7369
|
+
const max = powers[from];
|
|
7370
|
+
const mask = powers[to] - 1;
|
|
7371
|
+
const res = [];
|
|
7372
|
+
for (const n of data) {
|
|
7373
|
+
anumber$1(n);
|
|
7374
|
+
if (n >= max) throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
|
|
7375
|
+
carry = carry << from | n;
|
|
7376
|
+
if (pos + from > 32) throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
|
|
7377
|
+
pos += from;
|
|
7378
|
+
for (; pos >= to; pos -= to) res.push((carry >> pos - to & mask) >>> 0);
|
|
7379
|
+
const pow = powers[pos];
|
|
7380
|
+
if (pow === void 0) throw new Error("invalid carry");
|
|
7381
|
+
carry &= pow - 1;
|
|
7382
|
+
}
|
|
7383
|
+
carry = carry << to - pos & mask;
|
|
7384
|
+
if (!padding && pos >= from) throw new Error("Excess padding");
|
|
7385
|
+
if (!padding && carry > 0) throw new Error(`Non-zero padding: ${carry}`);
|
|
7386
|
+
if (padding && pos > 0) res.push(carry >>> 0);
|
|
7387
|
+
return res;
|
|
7388
|
+
}
|
|
7389
|
+
/**
|
|
7390
|
+
* If both bases are power of same number (like `2**8 <-> 2**64`),
|
|
7391
|
+
* there is a linear algorithm. For now we have implementation for power-of-two bases only.
|
|
7392
|
+
* @__NO_SIDE_EFFECTS__
|
|
7393
|
+
*/
|
|
7394
|
+
function radix2(bits, revPadding = false) {
|
|
7395
|
+
anumber$1(bits);
|
|
7396
|
+
if (bits <= 0 || bits > 32) throw new RangeError("radix2: bits should be in (0..32]");
|
|
7397
|
+
if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32) throw new RangeError("radix2: carry overflow");
|
|
7398
|
+
return {
|
|
7399
|
+
encode: (bytes) => {
|
|
7400
|
+
if (!isBytes$1(bytes)) throw new TypeError("radix2.encode input should be Uint8Array");
|
|
7401
|
+
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
|
|
7402
|
+
},
|
|
7403
|
+
decode: (digits) => {
|
|
7404
|
+
anumArr("radix2.decode", digits);
|
|
7405
|
+
return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
|
|
5497
7406
|
}
|
|
5498
7407
|
};
|
|
5499
|
-
|
|
7408
|
+
}
|
|
7409
|
+
function unsafeWrapper(fn) {
|
|
7410
|
+
afn(fn);
|
|
7411
|
+
return function(...args) {
|
|
7412
|
+
try {
|
|
7413
|
+
return fn.apply(null, args);
|
|
7414
|
+
} catch (e) {}
|
|
7415
|
+
};
|
|
7416
|
+
}
|
|
7417
|
+
chain(radix2(4), alphabet("0123456789ABCDEF"), join(""));
|
|
7418
|
+
/**
|
|
7419
|
+
* base32 encoding from RFC 4648. Has padding.
|
|
7420
|
+
* RFC 4648 §6 Table 3 uses uppercase letters, and RFC 4648 §3.4 allows applications to choose
|
|
7421
|
+
* upper- or lowercase alphabets. We keep the published uppercase table and do not case-fold decode input.
|
|
7422
|
+
* Use `base32nopad` for unpadded version.
|
|
7423
|
+
* Also check out `base32hex`, `base32hexnopad`, `base32crockford`.
|
|
7424
|
+
* @example
|
|
7425
|
+
* ```js
|
|
7426
|
+
* base32.encode(Uint8Array.from([0x12, 0xab]));
|
|
7427
|
+
* // => 'CKVQ===='
|
|
7428
|
+
* base32.decode('CKVQ====');
|
|
7429
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
7430
|
+
* ```
|
|
7431
|
+
*/
|
|
7432
|
+
var base32 = /* @__PURE__ */ Object.freeze(chain(radix2(5), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), padding(5), join("")));
|
|
7433
|
+
chain(radix2(5), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), join(""));
|
|
7434
|
+
chain(radix2(5), alphabet("0123456789ABCDEFGHIJKLMNOPQRSTUV"), padding(5), join(""));
|
|
7435
|
+
chain(radix2(5), alphabet("0123456789ABCDEFGHIJKLMNOPQRSTUV"), join(""));
|
|
7436
|
+
chain(radix2(5), alphabet("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), join(""), normalize((s) => s.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
|
|
7437
|
+
var hasBase64Builtin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toBase64 === "function" && typeof Uint8Array.fromBase64 === "function")();
|
|
7438
|
+
hasBase64Builtin || chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), padding(6), join(""));
|
|
7439
|
+
chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), join(""));
|
|
7440
|
+
hasBase64Builtin || chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), padding(6), join(""));
|
|
7441
|
+
chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), join(""));
|
|
7442
|
+
var BECH_ALPHABET = chain(alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), join(""));
|
|
7443
|
+
var POLYMOD_GENERATORS = [
|
|
7444
|
+
996825010,
|
|
7445
|
+
642813549,
|
|
7446
|
+
513874426,
|
|
7447
|
+
1027748829,
|
|
7448
|
+
705979059
|
|
7449
|
+
];
|
|
7450
|
+
function bech32Polymod(pre) {
|
|
7451
|
+
const b = pre >> 25;
|
|
7452
|
+
let chk = (pre & 33554431) << 5;
|
|
7453
|
+
for (let i = 0; i < POLYMOD_GENERATORS.length; i++) if ((b >> i & 1) === 1) chk ^= POLYMOD_GENERATORS[i];
|
|
7454
|
+
return chk;
|
|
7455
|
+
}
|
|
7456
|
+
function bechChecksum(prefix, words, encodingConst = 1) {
|
|
7457
|
+
const len = prefix.length;
|
|
7458
|
+
let chk = 1;
|
|
7459
|
+
for (let i = 0; i < len; i++) {
|
|
7460
|
+
const c = prefix.charCodeAt(i);
|
|
7461
|
+
if (c < 33 || c > 126) throw new Error(`Invalid prefix (${prefix})`);
|
|
7462
|
+
chk = bech32Polymod(chk) ^ c >> 5;
|
|
7463
|
+
}
|
|
7464
|
+
chk = bech32Polymod(chk);
|
|
7465
|
+
for (let i = 0; i < len; i++) chk = bech32Polymod(chk) ^ prefix.charCodeAt(i) & 31;
|
|
7466
|
+
for (let v of words) chk = bech32Polymod(chk) ^ v;
|
|
7467
|
+
for (let i = 0; i < 6; i++) chk = bech32Polymod(chk);
|
|
7468
|
+
chk ^= encodingConst;
|
|
7469
|
+
return BECH_ALPHABET.encode(convertRadix2([chk % powers[30]], 30, 5, false));
|
|
7470
|
+
}
|
|
7471
|
+
/**
|
|
7472
|
+
* @__NO_SIDE_EFFECTS__
|
|
7473
|
+
*/
|
|
7474
|
+
function genBech32(encoding) {
|
|
7475
|
+
const ENCODING_CONST = encoding === "bech32" ? 1 : 734539939;
|
|
7476
|
+
const _words = radix2(5);
|
|
7477
|
+
const fromWords = _words.decode;
|
|
7478
|
+
const toWords = _words.encode;
|
|
7479
|
+
const fromWordsUnsafe = unsafeWrapper(fromWords);
|
|
7480
|
+
function encode(prefix, words, limit = 90) {
|
|
7481
|
+
astr("bech32.encode prefix", prefix);
|
|
7482
|
+
if (isBytes$1(words)) words = Array.from(words);
|
|
7483
|
+
anumArr("bech32.encode", words);
|
|
7484
|
+
const plen = prefix.length;
|
|
7485
|
+
if (plen === 0) throw new TypeError(`Invalid prefix length ${plen}`);
|
|
7486
|
+
const actualLength = plen + 7 + words.length;
|
|
7487
|
+
if (limit !== false && actualLength > limit) throw new TypeError(`Length ${actualLength} exceeds limit ${limit}`);
|
|
7488
|
+
const lowered = prefix.toLowerCase();
|
|
7489
|
+
const sum = bechChecksum(lowered, words, ENCODING_CONST);
|
|
7490
|
+
return `${lowered}1${BECH_ALPHABET.encode(words)}${sum}`;
|
|
7491
|
+
}
|
|
7492
|
+
function decode(str, limit = 90) {
|
|
7493
|
+
astr("bech32.decode input", str);
|
|
7494
|
+
const slen = str.length;
|
|
7495
|
+
if (slen < 8 || limit !== false && slen > limit) throw new TypeError(`invalid string length: ${slen} (${str}). Expected (8..${limit})`);
|
|
7496
|
+
const lowered = str.toLowerCase();
|
|
7497
|
+
if (str !== lowered && str !== str.toUpperCase()) throw new Error(`String must be lowercase or uppercase`);
|
|
7498
|
+
const sepIndex = lowered.lastIndexOf("1");
|
|
7499
|
+
if (sepIndex === 0 || sepIndex === -1) throw new Error(`Letter "1" must be present between prefix and data only`);
|
|
7500
|
+
const prefix = lowered.slice(0, sepIndex);
|
|
7501
|
+
const data = lowered.slice(sepIndex + 1);
|
|
7502
|
+
if (data.length < 6) throw new Error("Data must be at least 6 characters long");
|
|
7503
|
+
const words = BECH_ALPHABET.decode(data).slice(0, -6);
|
|
7504
|
+
const sum = bechChecksum(prefix, words, ENCODING_CONST);
|
|
7505
|
+
if (!data.endsWith(sum)) throw new Error(`Invalid checksum in ${str}: expected "${sum}"`);
|
|
5500
7506
|
return {
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
createHmacKey: totpCreateHmacKey,
|
|
5504
|
-
digits: 6,
|
|
5505
|
-
encoding: exports.KeyEncodings.ASCII,
|
|
5506
|
-
epoch: Date.now(),
|
|
5507
|
-
step: 30,
|
|
5508
|
-
window: 0
|
|
7507
|
+
prefix,
|
|
7508
|
+
words
|
|
5509
7509
|
};
|
|
5510
7510
|
}
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
7511
|
+
const decodeUnsafe = unsafeWrapper(decode);
|
|
7512
|
+
function decodeToBytes(str) {
|
|
7513
|
+
const { prefix, words } = decode(str, false);
|
|
7514
|
+
return {
|
|
7515
|
+
prefix,
|
|
7516
|
+
words,
|
|
7517
|
+
bytes: fromWords(words)
|
|
5515
7518
|
};
|
|
5516
|
-
totpOptionsValidator(options);
|
|
5517
|
-
return Object.freeze(options);
|
|
5518
|
-
}
|
|
5519
|
-
function totpCounter(epoch, step) {
|
|
5520
|
-
return Math.floor(epoch / step / 1e3);
|
|
5521
7519
|
}
|
|
5522
|
-
function
|
|
5523
|
-
return
|
|
7520
|
+
function encodeFromBytes(prefix, bytes) {
|
|
7521
|
+
return encode(prefix, toWords(bytes));
|
|
5524
7522
|
}
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
7523
|
+
return {
|
|
7524
|
+
encode,
|
|
7525
|
+
decode,
|
|
7526
|
+
encodeFromBytes,
|
|
7527
|
+
decodeToBytes,
|
|
7528
|
+
decodeUnsafe,
|
|
7529
|
+
fromWords,
|
|
7530
|
+
fromWordsUnsafe,
|
|
7531
|
+
toWords
|
|
7532
|
+
};
|
|
7533
|
+
}
|
|
7534
|
+
genBech32("bech32");
|
|
7535
|
+
genBech32("bech32m");
|
|
7536
|
+
/* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")() || chain(radix2(4), alphabet("0123456789abcdef"), join(""), normalize((s) => {
|
|
7537
|
+
if (typeof s !== "string" || s.length % 2 !== 0) throw new TypeError(`hex.decode: expected string, got ${typeof s} with length ${s.length}`);
|
|
7538
|
+
return s.toLowerCase();
|
|
7539
|
+
}));
|
|
7540
|
+
//#endregion
|
|
7541
|
+
//#region ../../node_modules/@otplib/plugin-base32-scure/dist/index.js
|
|
7542
|
+
var r = class {
|
|
7543
|
+
name = "scure";
|
|
7544
|
+
encode(o, e = {}) {
|
|
7545
|
+
let { padding: t = !1 } = e, n = base32.encode(o);
|
|
7546
|
+
return t ? n : n.replace(/=+$/, "");
|
|
7547
|
+
}
|
|
7548
|
+
decode(o) {
|
|
7549
|
+
try {
|
|
7550
|
+
let e = o.toUpperCase(), t = e.padEnd(Math.ceil(e.length / 8) * 8, "=");
|
|
7551
|
+
return base32.decode(t);
|
|
7552
|
+
} catch (e) {
|
|
7553
|
+
throw new Error(`Invalid Base32 string: ${e.message}`);
|
|
5531
7554
|
}
|
|
5532
|
-
return result;
|
|
5533
7555
|
}
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
7556
|
+
}, d$2 = Object.freeze(new r());
|
|
7557
|
+
//#endregion
|
|
7558
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/node_modules/@noble/hashes/utils.js
|
|
7559
|
+
/**
|
|
7560
|
+
* Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.
|
|
7561
|
+
* @param a - value to test
|
|
7562
|
+
* @returns `true` when the value is a Uint8Array-compatible view.
|
|
7563
|
+
* @example
|
|
7564
|
+
* Check whether a value is a Uint8Array-compatible view.
|
|
7565
|
+
* ```ts
|
|
7566
|
+
* isBytes(new Uint8Array([1, 2, 3]));
|
|
7567
|
+
* ```
|
|
7568
|
+
*/
|
|
7569
|
+
function isBytes(a) {
|
|
7570
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
7571
|
+
}
|
|
7572
|
+
/**
|
|
7573
|
+
* Asserts something is a non-negative integer.
|
|
7574
|
+
* @param n - number to validate
|
|
7575
|
+
* @param title - label included in thrown errors
|
|
7576
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7577
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
7578
|
+
* @example
|
|
7579
|
+
* Validate a non-negative integer option.
|
|
7580
|
+
* ```ts
|
|
7581
|
+
* anumber(32, 'length');
|
|
7582
|
+
* ```
|
|
7583
|
+
*/
|
|
7584
|
+
function anumber(n, title = "") {
|
|
7585
|
+
if (typeof n !== "number") {
|
|
7586
|
+
const prefix = title && `"${title}" `;
|
|
7587
|
+
throw new TypeError(`${prefix}expected number, got ${typeof n}`);
|
|
5542
7588
|
}
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
}
|
|
5547
|
-
function totpCheckByEpoch(epochs, token, secret, options) {
|
|
5548
|
-
let position = null;
|
|
5549
|
-
epochs.some((epoch, idx) => {
|
|
5550
|
-
if (totpCheck(token, secret, {
|
|
5551
|
-
...options,
|
|
5552
|
-
epoch
|
|
5553
|
-
})) {
|
|
5554
|
-
position = idx + 1;
|
|
5555
|
-
return true;
|
|
5556
|
-
}
|
|
5557
|
-
return false;
|
|
5558
|
-
});
|
|
5559
|
-
return position;
|
|
5560
|
-
}
|
|
5561
|
-
function totpCheckWithWindow(token, secret, options) {
|
|
5562
|
-
if (totpCheck(token, secret, options)) return 0;
|
|
5563
|
-
const epochs = totpEpochAvailable(options.epoch, options.step, options.window);
|
|
5564
|
-
const backward = totpCheckByEpoch(epochs.past, token, secret, options);
|
|
5565
|
-
if (backward !== null) return backward * -1;
|
|
5566
|
-
return totpCheckByEpoch(epochs.future, token, secret, options);
|
|
5567
|
-
}
|
|
5568
|
-
function totpTimeUsed(epoch, step) {
|
|
5569
|
-
return Math.floor(epoch / 1e3) % step;
|
|
5570
|
-
}
|
|
5571
|
-
function totpTimeRemaining(epoch, step) {
|
|
5572
|
-
return step - totpTimeUsed(epoch, step);
|
|
5573
|
-
}
|
|
5574
|
-
function totpKeyuri(accountName, issuer, secret, options) {
|
|
5575
|
-
return keyuri({
|
|
5576
|
-
algorithm: options.algorithm,
|
|
5577
|
-
digits: options.digits,
|
|
5578
|
-
step: options.step,
|
|
5579
|
-
type: exports.Strategy.TOTP,
|
|
5580
|
-
accountName,
|
|
5581
|
-
issuer,
|
|
5582
|
-
secret
|
|
5583
|
-
});
|
|
7589
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
7590
|
+
const prefix = title && `"${title}" `;
|
|
7591
|
+
throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
|
|
5584
7592
|
}
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
7593
|
+
}
|
|
7594
|
+
/**
|
|
7595
|
+
* Asserts something is Uint8Array.
|
|
7596
|
+
* @param value - value to validate
|
|
7597
|
+
* @param length - optional exact length constraint
|
|
7598
|
+
* @param title - label included in thrown errors
|
|
7599
|
+
* @returns The validated byte array.
|
|
7600
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7601
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
7602
|
+
* @example
|
|
7603
|
+
* Validate that a value is a byte array.
|
|
7604
|
+
* ```ts
|
|
7605
|
+
* abytes(new Uint8Array([1, 2, 3]));
|
|
7606
|
+
* ```
|
|
7607
|
+
*/
|
|
7608
|
+
function abytes(value, length, title = "") {
|
|
7609
|
+
const bytes = isBytes(value);
|
|
7610
|
+
const len = value?.length;
|
|
7611
|
+
const needsLen = length !== void 0;
|
|
7612
|
+
if (!bytes || needsLen && len !== length) {
|
|
7613
|
+
const prefix = title && `"${title}" `;
|
|
7614
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
7615
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
7616
|
+
const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
|
|
7617
|
+
if (!bytes) throw new TypeError(message);
|
|
7618
|
+
throw new RangeError(message);
|
|
7619
|
+
}
|
|
7620
|
+
return value;
|
|
7621
|
+
}
|
|
7622
|
+
/**
|
|
7623
|
+
* Asserts something is a wrapped hash constructor.
|
|
7624
|
+
* @param h - hash constructor to validate
|
|
7625
|
+
* @throws On wrong argument types or invalid hash wrapper shape. {@link TypeError}
|
|
7626
|
+
* @throws On invalid hash metadata ranges or values. {@link RangeError}
|
|
7627
|
+
* @throws If the hash metadata allows empty outputs or block sizes. {@link Error}
|
|
7628
|
+
* @example
|
|
7629
|
+
* Validate a callable hash wrapper.
|
|
7630
|
+
* ```ts
|
|
7631
|
+
* import { ahash } from '@noble/hashes/utils.js';
|
|
7632
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7633
|
+
* ahash(sha256);
|
|
7634
|
+
* ```
|
|
7635
|
+
*/
|
|
7636
|
+
function ahash(h) {
|
|
7637
|
+
if (typeof h !== "function" || typeof h.create !== "function") throw new TypeError("Hash must wrapped by utils.createHasher");
|
|
7638
|
+
anumber(h.outputLen);
|
|
7639
|
+
anumber(h.blockLen);
|
|
7640
|
+
if (h.outputLen < 1) throw new Error("\"outputLen\" must be >= 1");
|
|
7641
|
+
if (h.blockLen < 1) throw new Error("\"blockLen\" must be >= 1");
|
|
7642
|
+
}
|
|
7643
|
+
/**
|
|
7644
|
+
* Asserts a hash instance has not been destroyed or finished.
|
|
7645
|
+
* @param instance - hash instance to validate
|
|
7646
|
+
* @param checkFinished - whether to reject finalized instances
|
|
7647
|
+
* @throws If the hash instance has already been destroyed or finalized. {@link Error}
|
|
7648
|
+
* @example
|
|
7649
|
+
* Validate that a hash instance is still usable.
|
|
7650
|
+
* ```ts
|
|
7651
|
+
* import { aexists } from '@noble/hashes/utils.js';
|
|
7652
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7653
|
+
* const hash = sha256.create();
|
|
7654
|
+
* aexists(hash);
|
|
7655
|
+
* ```
|
|
7656
|
+
*/
|
|
7657
|
+
function aexists(instance, checkFinished = true) {
|
|
7658
|
+
if (instance.destroyed) throw new Error("Hash instance has been destroyed");
|
|
7659
|
+
if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
|
|
7660
|
+
}
|
|
7661
|
+
/**
|
|
7662
|
+
* Asserts output is a sufficiently-sized byte array.
|
|
7663
|
+
* @param out - destination buffer
|
|
7664
|
+
* @param instance - hash instance providing output length
|
|
7665
|
+
* Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
|
|
7666
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7667
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
7668
|
+
* @example
|
|
7669
|
+
* Validate a caller-provided digest buffer.
|
|
7670
|
+
* ```ts
|
|
7671
|
+
* import { aoutput } from '@noble/hashes/utils.js';
|
|
7672
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7673
|
+
* const hash = sha256.create();
|
|
7674
|
+
* aoutput(new Uint8Array(hash.outputLen), hash);
|
|
7675
|
+
* ```
|
|
7676
|
+
*/
|
|
7677
|
+
function aoutput(out, instance) {
|
|
7678
|
+
abytes(out, void 0, "digestInto() output");
|
|
7679
|
+
const min = instance.outputLen;
|
|
7680
|
+
if (out.length < min) throw new RangeError("\"digestInto() output\" expected to be of length >=" + min);
|
|
7681
|
+
}
|
|
7682
|
+
/**
|
|
7683
|
+
* Zeroizes typed arrays in place. Warning: JS provides no guarantees.
|
|
7684
|
+
* @param arrays - arrays to overwrite with zeros
|
|
7685
|
+
* @example
|
|
7686
|
+
* Zeroize sensitive buffers in place.
|
|
7687
|
+
* ```ts
|
|
7688
|
+
* clean(new Uint8Array([1, 2, 3]));
|
|
7689
|
+
* ```
|
|
7690
|
+
*/
|
|
7691
|
+
function clean(...arrays) {
|
|
7692
|
+
for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
|
|
7693
|
+
}
|
|
7694
|
+
/**
|
|
7695
|
+
* Creates a DataView for byte-level manipulation.
|
|
7696
|
+
* @param arr - source typed array
|
|
7697
|
+
* @returns DataView over the same buffer region.
|
|
7698
|
+
* @example
|
|
7699
|
+
* Create a DataView over an existing buffer.
|
|
7700
|
+
* ```ts
|
|
7701
|
+
* createView(new Uint8Array(4));
|
|
7702
|
+
* ```
|
|
7703
|
+
*/
|
|
7704
|
+
function createView(arr) {
|
|
7705
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
7706
|
+
}
|
|
7707
|
+
/**
|
|
7708
|
+
* Rotate-right operation for uint32 values.
|
|
7709
|
+
* @param word - source word
|
|
7710
|
+
* @param shift - shift amount in bits
|
|
7711
|
+
* @returns Rotated word.
|
|
7712
|
+
* @example
|
|
7713
|
+
* Rotate a 32-bit word to the right.
|
|
7714
|
+
* ```ts
|
|
7715
|
+
* rotr(0x12345678, 8);
|
|
7716
|
+
* ```
|
|
7717
|
+
*/
|
|
7718
|
+
function rotr(word, shift) {
|
|
7719
|
+
return word << 32 - shift | word >>> shift;
|
|
7720
|
+
}
|
|
7721
|
+
/**
|
|
7722
|
+
* Rotate-left operation for uint32 values.
|
|
7723
|
+
* @param word - source word
|
|
7724
|
+
* @param shift - shift amount in bits
|
|
7725
|
+
* @returns Rotated word.
|
|
7726
|
+
* @example
|
|
7727
|
+
* Rotate a 32-bit word to the left.
|
|
7728
|
+
* ```ts
|
|
7729
|
+
* rotl(0x12345678, 8);
|
|
7730
|
+
* ```
|
|
7731
|
+
*/
|
|
7732
|
+
function rotl(word, shift) {
|
|
7733
|
+
return word << shift | word >>> 32 - shift >>> 0;
|
|
7734
|
+
}
|
|
7735
|
+
/**
|
|
7736
|
+
* Creates a callable hash function from a stateful class constructor.
|
|
7737
|
+
* @param hashCons - hash constructor or factory
|
|
7738
|
+
* @param info - optional metadata such as DER OID
|
|
7739
|
+
* @returns Frozen callable hash wrapper with `.create()`.
|
|
7740
|
+
* Wrapper construction eagerly calls `hashCons(undefined)` once to read
|
|
7741
|
+
* `outputLen` / `blockLen`, so constructor side effects happen at module
|
|
7742
|
+
* init time.
|
|
7743
|
+
* @example
|
|
7744
|
+
* Wrap a stateful hash constructor into a callable helper.
|
|
7745
|
+
* ```ts
|
|
7746
|
+
* import { createHasher } from '@noble/hashes/utils.js';
|
|
7747
|
+
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
7748
|
+
* const wrapped = createHasher(sha256.create, { oid: sha256.oid });
|
|
7749
|
+
* wrapped(new Uint8Array([1]));
|
|
7750
|
+
* ```
|
|
7751
|
+
*/
|
|
7752
|
+
function createHasher(hashCons, info = {}) {
|
|
7753
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
7754
|
+
const tmp = hashCons(void 0);
|
|
7755
|
+
hashC.outputLen = tmp.outputLen;
|
|
7756
|
+
hashC.blockLen = tmp.blockLen;
|
|
7757
|
+
hashC.canXOF = tmp.canXOF;
|
|
7758
|
+
hashC.create = (opts) => hashCons(opts);
|
|
7759
|
+
Object.assign(hashC, info);
|
|
7760
|
+
return Object.freeze(hashC);
|
|
7761
|
+
}
|
|
7762
|
+
/**
|
|
7763
|
+
* Cryptographically secure PRNG backed by `crypto.getRandomValues`.
|
|
7764
|
+
* @param bytesLength - number of random bytes to generate
|
|
7765
|
+
* @returns Random bytes.
|
|
7766
|
+
* The platform `getRandomValues()` implementation still defines any
|
|
7767
|
+
* single-call length cap, and this helper rejects oversize requests
|
|
7768
|
+
* with a stable library `RangeError` instead of host-specific errors.
|
|
7769
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
7770
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
7771
|
+
* @throws If the current runtime does not provide `crypto.getRandomValues`. {@link Error}
|
|
7772
|
+
* @example
|
|
7773
|
+
* Generate a fresh random key or nonce.
|
|
7774
|
+
* ```ts
|
|
7775
|
+
* const key = randomBytes(16);
|
|
7776
|
+
* ```
|
|
7777
|
+
*/
|
|
7778
|
+
function randomBytes$1(bytesLength = 32) {
|
|
7779
|
+
anumber(bytesLength, "bytesLength");
|
|
7780
|
+
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
7781
|
+
if (typeof cr?.getRandomValues !== "function") throw new Error("crypto.getRandomValues must be defined");
|
|
7782
|
+
if (bytesLength > 65536) throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
7783
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
7784
|
+
}
|
|
7785
|
+
/**
|
|
7786
|
+
* Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.
|
|
7787
|
+
* @param suffix - final OID byte for the selected hash.
|
|
7788
|
+
* The helper accepts any byte even though only the documented NIST hash
|
|
7789
|
+
* suffixes are meaningful downstream.
|
|
7790
|
+
* @returns Object containing the DER-encoded OID.
|
|
7791
|
+
* @example
|
|
7792
|
+
* Build OID metadata for a NIST hash.
|
|
7793
|
+
* ```ts
|
|
7794
|
+
* oidNist(0x01);
|
|
7795
|
+
* ```
|
|
7796
|
+
*/
|
|
7797
|
+
var oidNist = (suffix) => ({ oid: Uint8Array.from([
|
|
7798
|
+
6,
|
|
7799
|
+
9,
|
|
7800
|
+
96,
|
|
7801
|
+
134,
|
|
7802
|
+
72,
|
|
7803
|
+
1,
|
|
7804
|
+
101,
|
|
7805
|
+
3,
|
|
7806
|
+
4,
|
|
7807
|
+
2,
|
|
7808
|
+
suffix
|
|
7809
|
+
]) });
|
|
7810
|
+
//#endregion
|
|
7811
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/node_modules/@noble/hashes/hmac.js
|
|
7812
|
+
/**
|
|
7813
|
+
* HMAC: RFC2104 message authentication code.
|
|
7814
|
+
* @module
|
|
7815
|
+
*/
|
|
7816
|
+
/**
|
|
7817
|
+
* Internal class for HMAC.
|
|
7818
|
+
* Accepts any byte key, although RFC 2104 §3 recommends keys at least
|
|
7819
|
+
* `HashLen` bytes long.
|
|
7820
|
+
*/
|
|
7821
|
+
var _HMAC = class {
|
|
7822
|
+
oHash;
|
|
7823
|
+
iHash;
|
|
7824
|
+
blockLen;
|
|
7825
|
+
outputLen;
|
|
7826
|
+
canXOF = false;
|
|
7827
|
+
finished = false;
|
|
7828
|
+
destroyed = false;
|
|
7829
|
+
constructor(hash, key) {
|
|
7830
|
+
ahash(hash);
|
|
7831
|
+
abytes(key, void 0, "key");
|
|
7832
|
+
this.iHash = hash.create();
|
|
7833
|
+
if (typeof this.iHash.update !== "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
7834
|
+
this.blockLen = this.iHash.blockLen;
|
|
7835
|
+
this.outputLen = this.iHash.outputLen;
|
|
7836
|
+
const blockLen = this.blockLen;
|
|
7837
|
+
const pad = new Uint8Array(blockLen);
|
|
7838
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
7839
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 54;
|
|
7840
|
+
this.iHash.update(pad);
|
|
7841
|
+
this.oHash = hash.create();
|
|
7842
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 106;
|
|
7843
|
+
this.oHash.update(pad);
|
|
7844
|
+
clean(pad);
|
|
7845
|
+
}
|
|
7846
|
+
update(buf) {
|
|
7847
|
+
aexists(this);
|
|
7848
|
+
this.iHash.update(buf);
|
|
7849
|
+
return this;
|
|
7850
|
+
}
|
|
7851
|
+
digestInto(out) {
|
|
7852
|
+
aexists(this);
|
|
7853
|
+
aoutput(out, this);
|
|
7854
|
+
this.finished = true;
|
|
7855
|
+
const buf = out.subarray(0, this.outputLen);
|
|
7856
|
+
this.iHash.digestInto(buf);
|
|
7857
|
+
this.oHash.update(buf);
|
|
7858
|
+
this.oHash.digestInto(buf);
|
|
7859
|
+
this.destroy();
|
|
7860
|
+
}
|
|
7861
|
+
digest() {
|
|
7862
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
7863
|
+
this.digestInto(out);
|
|
7864
|
+
return out;
|
|
7865
|
+
}
|
|
7866
|
+
_cloneInto(to) {
|
|
7867
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
7868
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
7869
|
+
to = to;
|
|
7870
|
+
to.finished = finished;
|
|
7871
|
+
to.destroyed = destroyed;
|
|
7872
|
+
to.blockLen = blockLen;
|
|
7873
|
+
to.outputLen = outputLen;
|
|
7874
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
7875
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
7876
|
+
return to;
|
|
7877
|
+
}
|
|
7878
|
+
clone() {
|
|
7879
|
+
return this._cloneInto();
|
|
7880
|
+
}
|
|
7881
|
+
destroy() {
|
|
7882
|
+
this.destroyed = true;
|
|
7883
|
+
this.oHash.destroy();
|
|
7884
|
+
this.iHash.destroy();
|
|
7885
|
+
}
|
|
7886
|
+
};
|
|
7887
|
+
var hmac = /* @__PURE__ */ (() => {
|
|
7888
|
+
const hmac_ = ((hash, key, message) => new _HMAC(hash, key).update(message).digest());
|
|
7889
|
+
hmac_.create = (hash, key) => new _HMAC(hash, key);
|
|
7890
|
+
return hmac_;
|
|
7891
|
+
})();
|
|
7892
|
+
//#endregion
|
|
7893
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/node_modules/@noble/hashes/_md.js
|
|
7894
|
+
/**
|
|
7895
|
+
* Internal Merkle-Damgard hash utils.
|
|
7896
|
+
* @module
|
|
7897
|
+
*/
|
|
7898
|
+
/**
|
|
7899
|
+
* Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
|
|
7900
|
+
* Returns bits from `b` when `a` is set, otherwise from `c`.
|
|
7901
|
+
* The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
|
|
7902
|
+
* set the same bit.
|
|
7903
|
+
* @param a - selector word
|
|
7904
|
+
* @param b - word chosen when selector bit is set
|
|
7905
|
+
* @param c - word chosen when selector bit is clear
|
|
7906
|
+
* @returns Mixed 32-bit word.
|
|
7907
|
+
* @example
|
|
7908
|
+
* Combine three words with the shared 32-bit choice primitive.
|
|
7909
|
+
* ```ts
|
|
7910
|
+
* Chi(0xffffffff, 0x12345678, 0x87654321);
|
|
7911
|
+
* ```
|
|
7912
|
+
*/
|
|
7913
|
+
function Chi(a, b, c) {
|
|
7914
|
+
return a & b ^ ~a & c;
|
|
7915
|
+
}
|
|
7916
|
+
/**
|
|
7917
|
+
* Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
|
|
7918
|
+
* Returns bits shared by at least two inputs.
|
|
7919
|
+
* @param a - first input word
|
|
7920
|
+
* @param b - second input word
|
|
7921
|
+
* @param c - third input word
|
|
7922
|
+
* @returns Mixed 32-bit word.
|
|
7923
|
+
* @example
|
|
7924
|
+
* Combine three words with the shared 32-bit majority primitive.
|
|
7925
|
+
* ```ts
|
|
7926
|
+
* Maj(0xffffffff, 0x12345678, 0x87654321);
|
|
7927
|
+
* ```
|
|
7928
|
+
*/
|
|
7929
|
+
function Maj(a, b, c) {
|
|
7930
|
+
return a & b ^ a & c ^ b & c;
|
|
7931
|
+
}
|
|
7932
|
+
/**
|
|
7933
|
+
* Merkle-Damgard hash construction base class.
|
|
7934
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
7935
|
+
* Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
|
|
7936
|
+
* strings with partial-byte tails.
|
|
7937
|
+
* @param blockLen - internal block size in bytes
|
|
7938
|
+
* @param outputLen - digest size in bytes
|
|
7939
|
+
* @param padOffset - trailing length field size in bytes
|
|
7940
|
+
* @param isLE - whether length and state words are encoded in little-endian
|
|
7941
|
+
* @example
|
|
7942
|
+
* Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
|
|
7943
|
+
* ```ts
|
|
7944
|
+
* import { _SHA1 } from '@noble/hashes/legacy.js';
|
|
7945
|
+
* const hash = new _SHA1();
|
|
7946
|
+
* hash.update(new Uint8Array([97, 98, 99]));
|
|
7947
|
+
* hash.digest();
|
|
7948
|
+
* ```
|
|
7949
|
+
*/
|
|
7950
|
+
var HashMD = class {
|
|
7951
|
+
blockLen;
|
|
7952
|
+
outputLen;
|
|
7953
|
+
canXOF = false;
|
|
7954
|
+
padOffset;
|
|
7955
|
+
isLE;
|
|
7956
|
+
buffer;
|
|
7957
|
+
view;
|
|
7958
|
+
finished = false;
|
|
7959
|
+
length = 0;
|
|
7960
|
+
pos = 0;
|
|
7961
|
+
destroyed = false;
|
|
7962
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
7963
|
+
this.blockLen = blockLen;
|
|
7964
|
+
this.outputLen = outputLen;
|
|
7965
|
+
this.padOffset = padOffset;
|
|
7966
|
+
this.isLE = isLE;
|
|
7967
|
+
this.buffer = new Uint8Array(blockLen);
|
|
7968
|
+
this.view = createView(this.buffer);
|
|
7969
|
+
}
|
|
7970
|
+
update(data) {
|
|
7971
|
+
aexists(this);
|
|
7972
|
+
abytes(data);
|
|
7973
|
+
const { view, buffer, blockLen } = this;
|
|
7974
|
+
const len = data.length;
|
|
7975
|
+
for (let pos = 0; pos < len;) {
|
|
7976
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
7977
|
+
if (take === blockLen) {
|
|
7978
|
+
const dataView = createView(data);
|
|
7979
|
+
for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
|
|
7980
|
+
continue;
|
|
7981
|
+
}
|
|
7982
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
7983
|
+
this.pos += take;
|
|
7984
|
+
pos += take;
|
|
7985
|
+
if (this.pos === blockLen) {
|
|
7986
|
+
this.process(view, 0);
|
|
7987
|
+
this.pos = 0;
|
|
7988
|
+
}
|
|
5591
7989
|
}
|
|
5592
|
-
|
|
5593
|
-
|
|
7990
|
+
this.length += data.length;
|
|
7991
|
+
this.roundClean();
|
|
7992
|
+
return this;
|
|
7993
|
+
}
|
|
7994
|
+
digestInto(out) {
|
|
7995
|
+
aexists(this);
|
|
7996
|
+
aoutput(out, this);
|
|
7997
|
+
this.finished = true;
|
|
7998
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
7999
|
+
let { pos } = this;
|
|
8000
|
+
buffer[pos++] = 128;
|
|
8001
|
+
clean(this.buffer.subarray(pos));
|
|
8002
|
+
if (this.padOffset > blockLen - pos) {
|
|
8003
|
+
this.process(view, 0);
|
|
8004
|
+
pos = 0;
|
|
5594
8005
|
}
|
|
5595
|
-
|
|
5596
|
-
|
|
8006
|
+
for (let i = pos; i < blockLen; i++) buffer[i] = 0;
|
|
8007
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
8008
|
+
this.process(view, 0);
|
|
8009
|
+
const oview = createView(out);
|
|
8010
|
+
const len = this.outputLen;
|
|
8011
|
+
if (len % 4) throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
8012
|
+
const outLen = len / 4;
|
|
8013
|
+
const state = this.get();
|
|
8014
|
+
if (outLen > state.length) throw new Error("_sha2: outputLen bigger than state");
|
|
8015
|
+
for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
|
|
8016
|
+
}
|
|
8017
|
+
digest() {
|
|
8018
|
+
const { buffer, outputLen } = this;
|
|
8019
|
+
this.digestInto(buffer);
|
|
8020
|
+
const res = buffer.slice(0, outputLen);
|
|
8021
|
+
this.destroy();
|
|
8022
|
+
return res;
|
|
8023
|
+
}
|
|
8024
|
+
_cloneInto(to) {
|
|
8025
|
+
to ||= new this.constructor();
|
|
8026
|
+
to.set(...this.get());
|
|
8027
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
8028
|
+
to.destroyed = destroyed;
|
|
8029
|
+
to.finished = finished;
|
|
8030
|
+
to.length = length;
|
|
8031
|
+
to.pos = pos;
|
|
8032
|
+
if (length % blockLen) to.buffer.set(buffer);
|
|
8033
|
+
return to;
|
|
8034
|
+
}
|
|
8035
|
+
clone() {
|
|
8036
|
+
return this._cloneInto();
|
|
8037
|
+
}
|
|
8038
|
+
};
|
|
8039
|
+
/**
|
|
8040
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
8041
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
8042
|
+
*/
|
|
8043
|
+
/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
|
|
8044
|
+
* square roots of the first eight prime numbers. Exported as a shared table; callers must treat
|
|
8045
|
+
* it as read-only because constructors copy words from it by index. */
|
|
8046
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
8047
|
+
1779033703,
|
|
8048
|
+
3144134277,
|
|
8049
|
+
1013904242,
|
|
8050
|
+
2773480762,
|
|
8051
|
+
1359893119,
|
|
8052
|
+
2600822924,
|
|
8053
|
+
528734635,
|
|
8054
|
+
1541459225
|
|
8055
|
+
]);
|
|
8056
|
+
/** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
8057
|
+
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first
|
|
8058
|
+
* eight prime numbers. Exported as a shared table; callers must treat it as read-only because
|
|
8059
|
+
* constructors copy halves from it by index. */
|
|
8060
|
+
var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
8061
|
+
1779033703,
|
|
8062
|
+
4089235720,
|
|
8063
|
+
3144134277,
|
|
8064
|
+
2227873595,
|
|
8065
|
+
1013904242,
|
|
8066
|
+
4271175723,
|
|
8067
|
+
2773480762,
|
|
8068
|
+
1595750129,
|
|
8069
|
+
1359893119,
|
|
8070
|
+
2917565137,
|
|
8071
|
+
2600822924,
|
|
8072
|
+
725511199,
|
|
8073
|
+
528734635,
|
|
8074
|
+
4215389547,
|
|
8075
|
+
1541459225,
|
|
8076
|
+
327033209
|
|
8077
|
+
]);
|
|
8078
|
+
//#endregion
|
|
8079
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/node_modules/@noble/hashes/legacy.js
|
|
8080
|
+
/**
|
|
8081
|
+
|
|
8082
|
+
SHA1 (RFC 3174), MD5 (RFC 1321), and RIPEMD160 legacy, weak hash functions.
|
|
8083
|
+
RFC 2286 only covers HMAC-RIPEMD160 wrapper material and test vectors,
|
|
8084
|
+
not the base RIPEMD-160 compression spec.
|
|
8085
|
+
Don't use them in a new protocol. What "weak" means:
|
|
8086
|
+
|
|
8087
|
+
- Collisions can be made with 2^18 effort in MD5, 2^60 in SHA1, 2^80 in RIPEMD160.
|
|
8088
|
+
- No practical pre-image attacks (only theoretical, 2^123.4)
|
|
8089
|
+
- HMAC seems kinda ok: https://www.rfc-editor.org/rfc/rfc6151
|
|
8090
|
+
* @module
|
|
8091
|
+
*/
|
|
8092
|
+
/** Initial SHA-1 state from RFC 3174 §6.1. */
|
|
8093
|
+
var SHA1_IV = /* @__PURE__ */ Uint32Array.from([
|
|
8094
|
+
1732584193,
|
|
8095
|
+
4023233417,
|
|
8096
|
+
2562383102,
|
|
8097
|
+
271733878,
|
|
8098
|
+
3285377520
|
|
8099
|
+
]);
|
|
8100
|
+
var SHA1_W = /* @__PURE__ */ new Uint32Array(80);
|
|
8101
|
+
/** Internal SHA1 legacy hash class. */
|
|
8102
|
+
var _SHA1 = class extends HashMD {
|
|
8103
|
+
A = SHA1_IV[0] | 0;
|
|
8104
|
+
B = SHA1_IV[1] | 0;
|
|
8105
|
+
C = SHA1_IV[2] | 0;
|
|
8106
|
+
D = SHA1_IV[3] | 0;
|
|
8107
|
+
E = SHA1_IV[4] | 0;
|
|
8108
|
+
constructor() {
|
|
8109
|
+
super(64, 20, 8, false);
|
|
8110
|
+
}
|
|
8111
|
+
get() {
|
|
8112
|
+
const { A, B, C, D, E } = this;
|
|
8113
|
+
return [
|
|
8114
|
+
A,
|
|
8115
|
+
B,
|
|
8116
|
+
C,
|
|
8117
|
+
D,
|
|
8118
|
+
E
|
|
8119
|
+
];
|
|
8120
|
+
}
|
|
8121
|
+
set(A, B, C, D, E) {
|
|
8122
|
+
this.A = A | 0;
|
|
8123
|
+
this.B = B | 0;
|
|
8124
|
+
this.C = C | 0;
|
|
8125
|
+
this.D = D | 0;
|
|
8126
|
+
this.E = E | 0;
|
|
8127
|
+
}
|
|
8128
|
+
process(view, offset) {
|
|
8129
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA1_W[i] = view.getUint32(offset, false);
|
|
8130
|
+
for (let i = 16; i < 80; i++) SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);
|
|
8131
|
+
let { A, B, C, D, E } = this;
|
|
8132
|
+
for (let i = 0; i < 80; i++) {
|
|
8133
|
+
let F, K;
|
|
8134
|
+
if (i < 20) {
|
|
8135
|
+
F = Chi(B, C, D);
|
|
8136
|
+
K = 1518500249;
|
|
8137
|
+
} else if (i < 40) {
|
|
8138
|
+
F = B ^ C ^ D;
|
|
8139
|
+
K = 1859775393;
|
|
8140
|
+
} else if (i < 60) {
|
|
8141
|
+
F = Maj(B, C, D);
|
|
8142
|
+
K = 2400959708;
|
|
8143
|
+
} else {
|
|
8144
|
+
F = B ^ C ^ D;
|
|
8145
|
+
K = 3395469782;
|
|
8146
|
+
}
|
|
8147
|
+
const T = rotl(A, 5) + F + E + K + SHA1_W[i] | 0;
|
|
8148
|
+
E = D;
|
|
8149
|
+
D = C;
|
|
8150
|
+
C = rotl(B, 30);
|
|
8151
|
+
B = A;
|
|
8152
|
+
A = T;
|
|
5597
8153
|
}
|
|
5598
|
-
|
|
5599
|
-
|
|
8154
|
+
A = A + this.A | 0;
|
|
8155
|
+
B = B + this.B | 0;
|
|
8156
|
+
C = C + this.C | 0;
|
|
8157
|
+
D = D + this.D | 0;
|
|
8158
|
+
E = E + this.E | 0;
|
|
8159
|
+
this.set(A, B, C, D, E);
|
|
8160
|
+
}
|
|
8161
|
+
roundClean() {
|
|
8162
|
+
clean(SHA1_W);
|
|
8163
|
+
}
|
|
8164
|
+
destroy() {
|
|
8165
|
+
this.destroyed = true;
|
|
8166
|
+
this.set(0, 0, 0, 0, 0);
|
|
8167
|
+
clean(this.buffer);
|
|
8168
|
+
}
|
|
8169
|
+
};
|
|
8170
|
+
/**
|
|
8171
|
+
* SHA1 (RFC 3174) legacy hash function. It was cryptographically broken.
|
|
8172
|
+
* @param msg - message bytes to hash
|
|
8173
|
+
* @returns Digest bytes.
|
|
8174
|
+
* @example
|
|
8175
|
+
* Hash a message with SHA1.
|
|
8176
|
+
* ```ts
|
|
8177
|
+
* sha1(new Uint8Array([97, 98, 99]));
|
|
8178
|
+
* ```
|
|
8179
|
+
*/
|
|
8180
|
+
var sha1 = /* @__PURE__ */ createHasher(() => new _SHA1());
|
|
8181
|
+
//#endregion
|
|
8182
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/node_modules/@noble/hashes/_u64.js
|
|
8183
|
+
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
8184
|
+
var _32n = /* @__PURE__ */ BigInt(32);
|
|
8185
|
+
function fromBig(n, le = false) {
|
|
8186
|
+
if (le) return {
|
|
8187
|
+
h: Number(n & U32_MASK64),
|
|
8188
|
+
l: Number(n >> _32n & U32_MASK64)
|
|
8189
|
+
};
|
|
8190
|
+
return {
|
|
8191
|
+
h: Number(n >> _32n & U32_MASK64) | 0,
|
|
8192
|
+
l: Number(n & U32_MASK64) | 0
|
|
8193
|
+
};
|
|
8194
|
+
}
|
|
8195
|
+
function split(lst, le = false) {
|
|
8196
|
+
const len = lst.length;
|
|
8197
|
+
let Ah = new Uint32Array(len);
|
|
8198
|
+
let Al = new Uint32Array(len);
|
|
8199
|
+
for (let i = 0; i < len; i++) {
|
|
8200
|
+
const { h, l } = fromBig(lst[i], le);
|
|
8201
|
+
[Ah[i], Al[i]] = [h, l];
|
|
8202
|
+
}
|
|
8203
|
+
return [Ah, Al];
|
|
8204
|
+
}
|
|
8205
|
+
var shrSH = (h, _l, s) => h >>> s;
|
|
8206
|
+
var shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
8207
|
+
var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
8208
|
+
var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
8209
|
+
var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
8210
|
+
var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
8211
|
+
function add(Ah, Al, Bh, Bl) {
|
|
8212
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
8213
|
+
return {
|
|
8214
|
+
h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
|
|
8215
|
+
l: l | 0
|
|
8216
|
+
};
|
|
8217
|
+
}
|
|
8218
|
+
var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
8219
|
+
var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
8220
|
+
var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
8221
|
+
var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
8222
|
+
var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
8223
|
+
var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
8224
|
+
//#endregion
|
|
8225
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/node_modules/@noble/hashes/sha2.js
|
|
8226
|
+
/**
|
|
8227
|
+
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
8228
|
+
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
8229
|
+
* Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and
|
|
8230
|
+
* {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.
|
|
8231
|
+
* @module
|
|
8232
|
+
*/
|
|
8233
|
+
/**
|
|
8234
|
+
* SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits
|
|
8235
|
+
* of the cube roots of the first 64 primes (2..311).
|
|
8236
|
+
*/
|
|
8237
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
8238
|
+
1116352408,
|
|
8239
|
+
1899447441,
|
|
8240
|
+
3049323471,
|
|
8241
|
+
3921009573,
|
|
8242
|
+
961987163,
|
|
8243
|
+
1508970993,
|
|
8244
|
+
2453635748,
|
|
8245
|
+
2870763221,
|
|
8246
|
+
3624381080,
|
|
8247
|
+
310598401,
|
|
8248
|
+
607225278,
|
|
8249
|
+
1426881987,
|
|
8250
|
+
1925078388,
|
|
8251
|
+
2162078206,
|
|
8252
|
+
2614888103,
|
|
8253
|
+
3248222580,
|
|
8254
|
+
3835390401,
|
|
8255
|
+
4022224774,
|
|
8256
|
+
264347078,
|
|
8257
|
+
604807628,
|
|
8258
|
+
770255983,
|
|
8259
|
+
1249150122,
|
|
8260
|
+
1555081692,
|
|
8261
|
+
1996064986,
|
|
8262
|
+
2554220882,
|
|
8263
|
+
2821834349,
|
|
8264
|
+
2952996808,
|
|
8265
|
+
3210313671,
|
|
8266
|
+
3336571891,
|
|
8267
|
+
3584528711,
|
|
8268
|
+
113926993,
|
|
8269
|
+
338241895,
|
|
8270
|
+
666307205,
|
|
8271
|
+
773529912,
|
|
8272
|
+
1294757372,
|
|
8273
|
+
1396182291,
|
|
8274
|
+
1695183700,
|
|
8275
|
+
1986661051,
|
|
8276
|
+
2177026350,
|
|
8277
|
+
2456956037,
|
|
8278
|
+
2730485921,
|
|
8279
|
+
2820302411,
|
|
8280
|
+
3259730800,
|
|
8281
|
+
3345764771,
|
|
8282
|
+
3516065817,
|
|
8283
|
+
3600352804,
|
|
8284
|
+
4094571909,
|
|
8285
|
+
275423344,
|
|
8286
|
+
430227734,
|
|
8287
|
+
506948616,
|
|
8288
|
+
659060556,
|
|
8289
|
+
883997877,
|
|
8290
|
+
958139571,
|
|
8291
|
+
1322822218,
|
|
8292
|
+
1537002063,
|
|
8293
|
+
1747873779,
|
|
8294
|
+
1955562222,
|
|
8295
|
+
2024104815,
|
|
8296
|
+
2227730452,
|
|
8297
|
+
2361852424,
|
|
8298
|
+
2428436474,
|
|
8299
|
+
2756734187,
|
|
8300
|
+
3204031479,
|
|
8301
|
+
3329325298
|
|
8302
|
+
]);
|
|
8303
|
+
/** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */
|
|
8304
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
8305
|
+
/** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */
|
|
8306
|
+
var SHA2_32B = class extends HashMD {
|
|
8307
|
+
constructor(outputLen) {
|
|
8308
|
+
super(64, outputLen, 8, false);
|
|
8309
|
+
}
|
|
8310
|
+
get() {
|
|
8311
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
8312
|
+
return [
|
|
8313
|
+
A,
|
|
8314
|
+
B,
|
|
8315
|
+
C,
|
|
8316
|
+
D,
|
|
8317
|
+
E,
|
|
8318
|
+
F,
|
|
8319
|
+
G,
|
|
8320
|
+
H
|
|
8321
|
+
];
|
|
8322
|
+
}
|
|
8323
|
+
set(A, B, C, D, E, F, G, H) {
|
|
8324
|
+
this.A = A | 0;
|
|
8325
|
+
this.B = B | 0;
|
|
8326
|
+
this.C = C | 0;
|
|
8327
|
+
this.D = D | 0;
|
|
8328
|
+
this.E = E | 0;
|
|
8329
|
+
this.F = F | 0;
|
|
8330
|
+
this.G = G | 0;
|
|
8331
|
+
this.H = H | 0;
|
|
8332
|
+
}
|
|
8333
|
+
process(view, offset) {
|
|
8334
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
|
|
8335
|
+
for (let i = 16; i < 64; i++) {
|
|
8336
|
+
const W15 = SHA256_W[i - 15];
|
|
8337
|
+
const W2 = SHA256_W[i - 2];
|
|
8338
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
8339
|
+
SHA256_W[i] = (rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10) + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
5600
8340
|
}
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
8341
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
8342
|
+
for (let i = 0; i < 64; i++) {
|
|
8343
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
8344
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
8345
|
+
const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
|
|
8346
|
+
H = G;
|
|
8347
|
+
G = F;
|
|
8348
|
+
F = E;
|
|
8349
|
+
E = D + T1 | 0;
|
|
8350
|
+
D = C;
|
|
8351
|
+
C = B;
|
|
8352
|
+
B = A;
|
|
8353
|
+
A = T1 + T2 | 0;
|
|
5604
8354
|
}
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
8355
|
+
A = A + this.A | 0;
|
|
8356
|
+
B = B + this.B | 0;
|
|
8357
|
+
C = C + this.C | 0;
|
|
8358
|
+
D = D + this.D | 0;
|
|
8359
|
+
E = E + this.E | 0;
|
|
8360
|
+
F = F + this.F | 0;
|
|
8361
|
+
G = G + this.G | 0;
|
|
8362
|
+
H = H + this.H | 0;
|
|
8363
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
8364
|
+
}
|
|
8365
|
+
roundClean() {
|
|
8366
|
+
clean(SHA256_W);
|
|
8367
|
+
}
|
|
8368
|
+
destroy() {
|
|
8369
|
+
this.destroyed = true;
|
|
8370
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
8371
|
+
clean(this.buffer);
|
|
8372
|
+
}
|
|
8373
|
+
};
|
|
8374
|
+
/** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */
|
|
8375
|
+
var _SHA256 = class extends SHA2_32B {
|
|
8376
|
+
A = SHA256_IV[0] | 0;
|
|
8377
|
+
B = SHA256_IV[1] | 0;
|
|
8378
|
+
C = SHA256_IV[2] | 0;
|
|
8379
|
+
D = SHA256_IV[3] | 0;
|
|
8380
|
+
E = SHA256_IV[4] | 0;
|
|
8381
|
+
F = SHA256_IV[5] | 0;
|
|
8382
|
+
G = SHA256_IV[6] | 0;
|
|
8383
|
+
H = SHA256_IV[7] | 0;
|
|
8384
|
+
constructor() {
|
|
8385
|
+
super(32);
|
|
8386
|
+
}
|
|
8387
|
+
};
|
|
8388
|
+
var K512 = /* @__PURE__ */ (() => split([
|
|
8389
|
+
"0x428a2f98d728ae22",
|
|
8390
|
+
"0x7137449123ef65cd",
|
|
8391
|
+
"0xb5c0fbcfec4d3b2f",
|
|
8392
|
+
"0xe9b5dba58189dbbc",
|
|
8393
|
+
"0x3956c25bf348b538",
|
|
8394
|
+
"0x59f111f1b605d019",
|
|
8395
|
+
"0x923f82a4af194f9b",
|
|
8396
|
+
"0xab1c5ed5da6d8118",
|
|
8397
|
+
"0xd807aa98a3030242",
|
|
8398
|
+
"0x12835b0145706fbe",
|
|
8399
|
+
"0x243185be4ee4b28c",
|
|
8400
|
+
"0x550c7dc3d5ffb4e2",
|
|
8401
|
+
"0x72be5d74f27b896f",
|
|
8402
|
+
"0x80deb1fe3b1696b1",
|
|
8403
|
+
"0x9bdc06a725c71235",
|
|
8404
|
+
"0xc19bf174cf692694",
|
|
8405
|
+
"0xe49b69c19ef14ad2",
|
|
8406
|
+
"0xefbe4786384f25e3",
|
|
8407
|
+
"0x0fc19dc68b8cd5b5",
|
|
8408
|
+
"0x240ca1cc77ac9c65",
|
|
8409
|
+
"0x2de92c6f592b0275",
|
|
8410
|
+
"0x4a7484aa6ea6e483",
|
|
8411
|
+
"0x5cb0a9dcbd41fbd4",
|
|
8412
|
+
"0x76f988da831153b5",
|
|
8413
|
+
"0x983e5152ee66dfab",
|
|
8414
|
+
"0xa831c66d2db43210",
|
|
8415
|
+
"0xb00327c898fb213f",
|
|
8416
|
+
"0xbf597fc7beef0ee4",
|
|
8417
|
+
"0xc6e00bf33da88fc2",
|
|
8418
|
+
"0xd5a79147930aa725",
|
|
8419
|
+
"0x06ca6351e003826f",
|
|
8420
|
+
"0x142929670a0e6e70",
|
|
8421
|
+
"0x27b70a8546d22ffc",
|
|
8422
|
+
"0x2e1b21385c26c926",
|
|
8423
|
+
"0x4d2c6dfc5ac42aed",
|
|
8424
|
+
"0x53380d139d95b3df",
|
|
8425
|
+
"0x650a73548baf63de",
|
|
8426
|
+
"0x766a0abb3c77b2a8",
|
|
8427
|
+
"0x81c2c92e47edaee6",
|
|
8428
|
+
"0x92722c851482353b",
|
|
8429
|
+
"0xa2bfe8a14cf10364",
|
|
8430
|
+
"0xa81a664bbc423001",
|
|
8431
|
+
"0xc24b8b70d0f89791",
|
|
8432
|
+
"0xc76c51a30654be30",
|
|
8433
|
+
"0xd192e819d6ef5218",
|
|
8434
|
+
"0xd69906245565a910",
|
|
8435
|
+
"0xf40e35855771202a",
|
|
8436
|
+
"0x106aa07032bbd1b8",
|
|
8437
|
+
"0x19a4c116b8d2d0c8",
|
|
8438
|
+
"0x1e376c085141ab53",
|
|
8439
|
+
"0x2748774cdf8eeb99",
|
|
8440
|
+
"0x34b0bcb5e19b48a8",
|
|
8441
|
+
"0x391c0cb3c5c95a63",
|
|
8442
|
+
"0x4ed8aa4ae3418acb",
|
|
8443
|
+
"0x5b9cca4f7763e373",
|
|
8444
|
+
"0x682e6ff3d6b2b8a3",
|
|
8445
|
+
"0x748f82ee5defb2fc",
|
|
8446
|
+
"0x78a5636f43172f60",
|
|
8447
|
+
"0x84c87814a1f0ab72",
|
|
8448
|
+
"0x8cc702081a6439ec",
|
|
8449
|
+
"0x90befffa23631e28",
|
|
8450
|
+
"0xa4506cebde82bde9",
|
|
8451
|
+
"0xbef9a3f7b2c67915",
|
|
8452
|
+
"0xc67178f2e372532b",
|
|
8453
|
+
"0xca273eceea26619c",
|
|
8454
|
+
"0xd186b8c721c0c207",
|
|
8455
|
+
"0xeada7dd6cde0eb1e",
|
|
8456
|
+
"0xf57d4f7fee6ed178",
|
|
8457
|
+
"0x06f067aa72176fba",
|
|
8458
|
+
"0x0a637dc5a2c898a6",
|
|
8459
|
+
"0x113f9804bef90dae",
|
|
8460
|
+
"0x1b710b35131c471b",
|
|
8461
|
+
"0x28db77f523047d84",
|
|
8462
|
+
"0x32caab7b40c72493",
|
|
8463
|
+
"0x3c9ebe0a15c9bebc",
|
|
8464
|
+
"0x431d67c49c100d4c",
|
|
8465
|
+
"0x4cc5d4becb3e42b6",
|
|
8466
|
+
"0x597f299cfc657e2a",
|
|
8467
|
+
"0x5fcb6fab3ad6faec",
|
|
8468
|
+
"0x6c44198c4a475817"
|
|
8469
|
+
].map((n) => BigInt(n))))();
|
|
8470
|
+
var SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
|
|
8471
|
+
var SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
|
|
8472
|
+
var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
8473
|
+
var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
8474
|
+
/** Internal SHA-384 / SHA-512 compression engine from RFC 6234 §6.4. */
|
|
8475
|
+
var SHA2_64B = class extends HashMD {
|
|
8476
|
+
constructor(outputLen) {
|
|
8477
|
+
super(128, outputLen, 16, false);
|
|
8478
|
+
}
|
|
8479
|
+
get() {
|
|
8480
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
8481
|
+
return [
|
|
8482
|
+
Ah,
|
|
8483
|
+
Al,
|
|
8484
|
+
Bh,
|
|
8485
|
+
Bl,
|
|
8486
|
+
Ch,
|
|
8487
|
+
Cl,
|
|
8488
|
+
Dh,
|
|
8489
|
+
Dl,
|
|
8490
|
+
Eh,
|
|
8491
|
+
El,
|
|
8492
|
+
Fh,
|
|
8493
|
+
Fl,
|
|
8494
|
+
Gh,
|
|
8495
|
+
Gl,
|
|
8496
|
+
Hh,
|
|
8497
|
+
Hl
|
|
8498
|
+
];
|
|
8499
|
+
}
|
|
8500
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
8501
|
+
this.Ah = Ah | 0;
|
|
8502
|
+
this.Al = Al | 0;
|
|
8503
|
+
this.Bh = Bh | 0;
|
|
8504
|
+
this.Bl = Bl | 0;
|
|
8505
|
+
this.Ch = Ch | 0;
|
|
8506
|
+
this.Cl = Cl | 0;
|
|
8507
|
+
this.Dh = Dh | 0;
|
|
8508
|
+
this.Dl = Dl | 0;
|
|
8509
|
+
this.Eh = Eh | 0;
|
|
8510
|
+
this.El = El | 0;
|
|
8511
|
+
this.Fh = Fh | 0;
|
|
8512
|
+
this.Fl = Fl | 0;
|
|
8513
|
+
this.Gh = Gh | 0;
|
|
8514
|
+
this.Gl = Gl | 0;
|
|
8515
|
+
this.Hh = Hh | 0;
|
|
8516
|
+
this.Hl = Hl | 0;
|
|
8517
|
+
}
|
|
8518
|
+
process(view, offset) {
|
|
8519
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
8520
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
8521
|
+
SHA512_W_L[i] = view.getUint32(offset += 4);
|
|
5608
8522
|
}
|
|
5609
|
-
|
|
5610
|
-
const
|
|
5611
|
-
|
|
8523
|
+
for (let i = 16; i < 80; i++) {
|
|
8524
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
8525
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
8526
|
+
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
8527
|
+
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
8528
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
8529
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
8530
|
+
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
8531
|
+
const SUMl = add4L(s0l, rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6), SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
8532
|
+
SHA512_W_H[i] = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]) | 0;
|
|
8533
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
5612
8534
|
}
|
|
5613
|
-
|
|
5614
|
-
|
|
8535
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
8536
|
+
for (let i = 0; i < 80; i++) {
|
|
8537
|
+
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
8538
|
+
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
8539
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
8540
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
8541
|
+
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
8542
|
+
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
8543
|
+
const T1l = T1ll | 0;
|
|
8544
|
+
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
8545
|
+
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
8546
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
8547
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
8548
|
+
Hh = Gh | 0;
|
|
8549
|
+
Hl = Gl | 0;
|
|
8550
|
+
Gh = Fh | 0;
|
|
8551
|
+
Gl = Fl | 0;
|
|
8552
|
+
Fh = Eh | 0;
|
|
8553
|
+
Fl = El | 0;
|
|
8554
|
+
({h: Eh, l: El} = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
8555
|
+
Dh = Ch | 0;
|
|
8556
|
+
Dl = Cl | 0;
|
|
8557
|
+
Ch = Bh | 0;
|
|
8558
|
+
Cl = Bl | 0;
|
|
8559
|
+
Bh = Ah | 0;
|
|
8560
|
+
Bl = Al | 0;
|
|
8561
|
+
const All = add3L(T1l, sigma0l, MAJl);
|
|
8562
|
+
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
8563
|
+
Al = All | 0;
|
|
5615
8564
|
}
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
}
|
|
5634
|
-
function authenticatorOptions(opt) {
|
|
5635
|
-
const options = {
|
|
5636
|
-
...authenticatorDefaultOptions(),
|
|
5637
|
-
...opt
|
|
5638
|
-
};
|
|
5639
|
-
authenticatorOptionValidator(options);
|
|
5640
|
-
return Object.freeze(options);
|
|
8565
|
+
({h: Ah, l: Al} = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
8566
|
+
({h: Bh, l: Bl} = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
8567
|
+
({h: Ch, l: Cl} = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
8568
|
+
({h: Dh, l: Dl} = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
8569
|
+
({h: Eh, l: El} = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
8570
|
+
({h: Fh, l: Fl} = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
8571
|
+
({h: Gh, l: Gl} = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
8572
|
+
({h: Hh, l: Hl} = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
8573
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
8574
|
+
}
|
|
8575
|
+
roundClean() {
|
|
8576
|
+
clean(SHA512_W_H, SHA512_W_L);
|
|
8577
|
+
}
|
|
8578
|
+
destroy() {
|
|
8579
|
+
this.destroyed = true;
|
|
8580
|
+
clean(this.buffer);
|
|
8581
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
5641
8582
|
}
|
|
5642
|
-
|
|
5643
|
-
|
|
8583
|
+
};
|
|
8584
|
+
/** Internal SHA-512 hash class grounded in RFC 6234 §6.3 and §6.4. */
|
|
8585
|
+
var _SHA512 = class extends SHA2_64B {
|
|
8586
|
+
Ah = SHA512_IV[0] | 0;
|
|
8587
|
+
Al = SHA512_IV[1] | 0;
|
|
8588
|
+
Bh = SHA512_IV[2] | 0;
|
|
8589
|
+
Bl = SHA512_IV[3] | 0;
|
|
8590
|
+
Ch = SHA512_IV[4] | 0;
|
|
8591
|
+
Cl = SHA512_IV[5] | 0;
|
|
8592
|
+
Dh = SHA512_IV[6] | 0;
|
|
8593
|
+
Dl = SHA512_IV[7] | 0;
|
|
8594
|
+
Eh = SHA512_IV[8] | 0;
|
|
8595
|
+
El = SHA512_IV[9] | 0;
|
|
8596
|
+
Fh = SHA512_IV[10] | 0;
|
|
8597
|
+
Fl = SHA512_IV[11] | 0;
|
|
8598
|
+
Gh = SHA512_IV[12] | 0;
|
|
8599
|
+
Gl = SHA512_IV[13] | 0;
|
|
8600
|
+
Hh = SHA512_IV[14] | 0;
|
|
8601
|
+
Hl = SHA512_IV[15] | 0;
|
|
8602
|
+
constructor() {
|
|
8603
|
+
super(64);
|
|
5644
8604
|
}
|
|
5645
|
-
|
|
5646
|
-
|
|
8605
|
+
};
|
|
8606
|
+
/**
|
|
8607
|
+
* SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:
|
|
8608
|
+
*
|
|
8609
|
+
* - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.
|
|
8610
|
+
* - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
8611
|
+
* - Each sha256 hash is executing 2^18 bit operations.
|
|
8612
|
+
* - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.
|
|
8613
|
+
* @param msg - message bytes to hash
|
|
8614
|
+
* @returns Digest bytes.
|
|
8615
|
+
* @example
|
|
8616
|
+
* Hash a message with SHA2-256.
|
|
8617
|
+
* ```ts
|
|
8618
|
+
* sha256(new Uint8Array([97, 98, 99]));
|
|
8619
|
+
* ```
|
|
8620
|
+
*/
|
|
8621
|
+
var sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), /* @__PURE__ */ oidNist(1));
|
|
8622
|
+
/**
|
|
8623
|
+
* SHA2-512 hash function from RFC 4634.
|
|
8624
|
+
* @param msg - message bytes to hash
|
|
8625
|
+
* @returns Digest bytes.
|
|
8626
|
+
* @example
|
|
8627
|
+
* Hash a message with SHA2-512.
|
|
8628
|
+
* ```ts
|
|
8629
|
+
* sha512(new Uint8Array([97, 98, 99]));
|
|
8630
|
+
* ```
|
|
8631
|
+
*/
|
|
8632
|
+
var sha512 = /* @__PURE__ */ createHasher(() => new _SHA512(), /* @__PURE__ */ oidNist(3)), yr = new TextEncoder();
|
|
8633
|
+
new TextDecoder();
|
|
8634
|
+
//#endregion
|
|
8635
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/node_modules/@otplib/core/dist/index.js
|
|
8636
|
+
var ur = 3600, pr = Number.MAX_SAFE_INTEGER;
|
|
8637
|
+
Object.freeze({
|
|
8638
|
+
MIN_SECRET_BYTES: 16,
|
|
8639
|
+
MAX_SECRET_BYTES: 64,
|
|
8640
|
+
MIN_PERIOD: 1,
|
|
8641
|
+
MAX_PERIOD: ur,
|
|
8642
|
+
MAX_COUNTER: pr,
|
|
8643
|
+
MAX_WINDOW: 99,
|
|
8644
|
+
[Symbol("otplib.guardrails.override")]: !1
|
|
8645
|
+
});
|
|
8646
|
+
function gr(r, e) {
|
|
8647
|
+
return r.length === e.length;
|
|
8648
|
+
}
|
|
8649
|
+
function tr(r, e) {
|
|
8650
|
+
let t = rr(r), o = rr(e);
|
|
8651
|
+
if (!gr(t, o)) return !1;
|
|
8652
|
+
let n = 0;
|
|
8653
|
+
for (let s = 0; s < t.length; s++) n |= t[s] ^ o[s];
|
|
8654
|
+
return n === 0;
|
|
8655
|
+
}
|
|
8656
|
+
function rr(r) {
|
|
8657
|
+
return typeof r == "string" ? yr.encode(r) : r;
|
|
8658
|
+
}
|
|
8659
|
+
//#endregion
|
|
8660
|
+
//#region ../../node_modules/@otplib/plugin-crypto-noble/dist/index.js
|
|
8661
|
+
var t = class {
|
|
8662
|
+
name = "noble";
|
|
8663
|
+
hmac(r, n, a) {
|
|
8664
|
+
return hmac(r === "sha1" ? sha1 : r === "sha256" ? sha256 : sha512, n, a);
|
|
5647
8665
|
}
|
|
5648
|
-
|
|
5649
|
-
return
|
|
8666
|
+
randomBytes(r) {
|
|
8667
|
+
return randomBytes$1(r);
|
|
5650
8668
|
}
|
|
5651
|
-
|
|
5652
|
-
return
|
|
8669
|
+
constantTimeEqual(r, n) {
|
|
8670
|
+
return tr(r, n);
|
|
5653
8671
|
}
|
|
5654
|
-
|
|
5655
|
-
|
|
8672
|
+
}, A = Object.freeze(new t());
|
|
8673
|
+
//#endregion
|
|
8674
|
+
//#region node_modules/otplib/dist/index.js
|
|
8675
|
+
function c(t) {
|
|
8676
|
+
return {
|
|
8677
|
+
secret: t.secret,
|
|
8678
|
+
strategy: t.strategy ?? "totp",
|
|
8679
|
+
crypto: t.crypto ?? A,
|
|
8680
|
+
base32: t.base32 ?? d$2,
|
|
8681
|
+
algorithm: t.algorithm ?? "sha1",
|
|
8682
|
+
digits: t.digits ?? 6,
|
|
8683
|
+
period: t.period ?? 30,
|
|
8684
|
+
epoch: t.epoch ?? Math.floor(Date.now() / 1e3),
|
|
8685
|
+
t0: t.t0 ?? 0,
|
|
8686
|
+
counter: t.counter,
|
|
8687
|
+
guardrails: t.guardrails ?? hr$2(),
|
|
8688
|
+
hooks: t.hooks
|
|
8689
|
+
};
|
|
8690
|
+
}
|
|
8691
|
+
function O(t) {
|
|
8692
|
+
return {
|
|
8693
|
+
...c(t),
|
|
8694
|
+
token: t.token,
|
|
8695
|
+
epochTolerance: t.epochTolerance ?? 0,
|
|
8696
|
+
counterTolerance: t.counterTolerance ?? 0,
|
|
8697
|
+
afterTimeStep: t.afterTimeStep
|
|
8698
|
+
};
|
|
8699
|
+
}
|
|
8700
|
+
function l(t, e, r) {
|
|
8701
|
+
if (t === "totp") return r.totp();
|
|
8702
|
+
if (t === "hotp") {
|
|
8703
|
+
if (e === void 0) throw new a$2("Counter is required for HOTP strategy. Example: { strategy: 'hotp', counter: 0 }");
|
|
8704
|
+
return r.hotp(e);
|
|
5656
8705
|
}
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
8706
|
+
throw new a$2(`Unknown OTP strategy: ${t}. Valid strategies are 'totp' or 'hotp'.`);
|
|
8707
|
+
}
|
|
8708
|
+
function I(t) {
|
|
8709
|
+
let { crypto: e = A, base32: r = d$2, length: a = 20 } = t || {};
|
|
8710
|
+
return Dr({
|
|
8711
|
+
crypto: e,
|
|
8712
|
+
base32: r,
|
|
8713
|
+
length: a
|
|
8714
|
+
});
|
|
8715
|
+
}
|
|
8716
|
+
function T(t) {
|
|
8717
|
+
let { strategy: e = "totp", issuer: r, label: a, secret: o, algorithm: i = "sha1", digits: s = 6, period: n = 30, counter: p } = t;
|
|
8718
|
+
return l(e, p, {
|
|
8719
|
+
totp: () => x$1({
|
|
8720
|
+
issuer: r,
|
|
8721
|
+
label: a,
|
|
8722
|
+
secret: o,
|
|
8723
|
+
algorithm: i,
|
|
8724
|
+
digits: s,
|
|
8725
|
+
period: n
|
|
8726
|
+
}),
|
|
8727
|
+
hotp: (y) => U$1({
|
|
8728
|
+
issuer: r,
|
|
8729
|
+
label: a,
|
|
8730
|
+
secret: o,
|
|
8731
|
+
algorithm: i,
|
|
8732
|
+
digits: s,
|
|
8733
|
+
counter: y
|
|
8734
|
+
})
|
|
8735
|
+
});
|
|
8736
|
+
}
|
|
8737
|
+
function d(t) {
|
|
8738
|
+
let e = O(t), { secret: r, token: a, crypto: o, base32: i, algorithm: s, digits: n, hooks: p } = e, y = {
|
|
8739
|
+
secret: r,
|
|
8740
|
+
token: a,
|
|
8741
|
+
crypto: o,
|
|
8742
|
+
base32: i,
|
|
8743
|
+
algorithm: s,
|
|
8744
|
+
digits: n,
|
|
8745
|
+
hooks: p
|
|
5679
8746
|
};
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
exports.hotpCounter = hotpCounter;
|
|
5697
|
-
exports.hotpCreateHmacKey = hotpCreateHmacKey;
|
|
5698
|
-
exports.hotpDefaultOptions = hotpDefaultOptions;
|
|
5699
|
-
exports.hotpDigestToToken = hotpDigestToToken;
|
|
5700
|
-
exports.hotpKeyuri = hotpKeyuri;
|
|
5701
|
-
exports.hotpOptions = hotpOptions;
|
|
5702
|
-
exports.hotpOptionsValidator = hotpOptionsValidator;
|
|
5703
|
-
exports.hotpToken = hotpToken;
|
|
5704
|
-
exports.isTokenValid = isTokenValid;
|
|
5705
|
-
exports.keyuri = keyuri;
|
|
5706
|
-
exports.objectValues = objectValues;
|
|
5707
|
-
exports.padStart = padStart;
|
|
5708
|
-
exports.totpCheck = totpCheck;
|
|
5709
|
-
exports.totpCheckByEpoch = totpCheckByEpoch;
|
|
5710
|
-
exports.totpCheckWithWindow = totpCheckWithWindow;
|
|
5711
|
-
exports.totpCounter = totpCounter;
|
|
5712
|
-
exports.totpCreateHmacKey = totpCreateHmacKey;
|
|
5713
|
-
exports.totpDefaultOptions = totpDefaultOptions;
|
|
5714
|
-
exports.totpEpochAvailable = totpEpochAvailable;
|
|
5715
|
-
exports.totpKeyuri = totpKeyuri;
|
|
5716
|
-
exports.totpOptions = totpOptions;
|
|
5717
|
-
exports.totpOptionsValidator = totpOptionsValidator;
|
|
5718
|
-
exports.totpPadSecret = totpPadSecret;
|
|
5719
|
-
exports.totpTimeRemaining = totpTimeRemaining;
|
|
5720
|
-
exports.totpTimeUsed = totpTimeUsed;
|
|
5721
|
-
exports.totpToken = totpToken;
|
|
5722
|
-
}));
|
|
5723
|
-
//#endregion
|
|
5724
|
-
//#region ../../node_modules/@otplib/preset-default/index.js
|
|
5725
|
-
/**
|
|
5726
|
-
* @otplib/preset-default
|
|
5727
|
-
*
|
|
5728
|
-
* @author Gerald Yeo <contact@fusedthought.com>
|
|
5729
|
-
* @version: 12.0.1
|
|
5730
|
-
* @license: MIT
|
|
5731
|
-
**/
|
|
5732
|
-
var require_preset_default = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5733
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5734
|
-
var pluginCrypto = require_plugin_crypto();
|
|
5735
|
-
var pluginThirtyTwo = require_plugin_thirty_two();
|
|
5736
|
-
var core = require_core();
|
|
5737
|
-
var hotp = new core.HOTP({ createDigest: pluginCrypto.createDigest });
|
|
5738
|
-
var totp = new core.TOTP({ createDigest: pluginCrypto.createDigest });
|
|
5739
|
-
exports.authenticator = new core.Authenticator({
|
|
5740
|
-
createDigest: pluginCrypto.createDigest,
|
|
5741
|
-
createRandomBytes: pluginCrypto.createRandomBytes,
|
|
5742
|
-
keyDecoder: pluginThirtyTwo.keyDecoder,
|
|
5743
|
-
keyEncoder: pluginThirtyTwo.keyEncoder
|
|
8747
|
+
return l(e.strategy, e.counter, {
|
|
8748
|
+
totp: () => ie({
|
|
8749
|
+
...y,
|
|
8750
|
+
period: e.period,
|
|
8751
|
+
epoch: e.epoch,
|
|
8752
|
+
t0: e.t0,
|
|
8753
|
+
epochTolerance: e.epochTolerance,
|
|
8754
|
+
afterTimeStep: e.afterTimeStep,
|
|
8755
|
+
guardrails: e.guardrails
|
|
8756
|
+
}),
|
|
8757
|
+
hotp: (f) => Y$1({
|
|
8758
|
+
...y,
|
|
8759
|
+
counter: f,
|
|
8760
|
+
counterTolerance: e.counterTolerance,
|
|
8761
|
+
guardrails: e.guardrails
|
|
8762
|
+
})
|
|
5744
8763
|
});
|
|
5745
|
-
|
|
5746
|
-
exports.totp = totp;
|
|
5747
|
-
}));
|
|
5748
|
-
/**
|
|
5749
|
-
* otplib
|
|
5750
|
-
*
|
|
5751
|
-
* @author Gerald Yeo <contact@fusedthought.com>
|
|
5752
|
-
* @version: 12.0.1
|
|
5753
|
-
* @license: MIT
|
|
5754
|
-
**/
|
|
8764
|
+
}
|
|
5755
8765
|
//#endregion
|
|
5756
8766
|
//#region src/auth/totp-manager.ts
|
|
5757
|
-
var import_otplib = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
5758
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5759
|
-
var presetDefault = require_preset_default();
|
|
5760
|
-
Object.keys(presetDefault).forEach(function(k) {
|
|
5761
|
-
if (k !== "default") Object.defineProperty(exports, k, {
|
|
5762
|
-
enumerable: true,
|
|
5763
|
-
get: function() {
|
|
5764
|
-
return presetDefault[k];
|
|
5765
|
-
}
|
|
5766
|
-
});
|
|
5767
|
-
});
|
|
5768
|
-
})))();
|
|
5769
8767
|
/**
|
|
5770
8768
|
* TOTP / 2FA enrollment manager.
|
|
5771
8769
|
*
|
|
@@ -5784,13 +8782,16 @@ var import_otplib = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
5784
8782
|
* we do NOT reuse the old secret on re-enroll (avoids the case where a
|
|
5785
8783
|
* leaked secret stays valid after a "rotation").
|
|
5786
8784
|
*
|
|
5787
|
-
*
|
|
5788
|
-
* default 30-second
|
|
5789
|
-
*
|
|
5790
|
-
*
|
|
8785
|
+
* `otplib` v13's functional API (`generateSync`/`verifySync`) uses RFC 6238
|
|
8786
|
+
* TOTP with a default 30-second period. We pass a per-call `epochTolerance`
|
|
8787
|
+
* of one step in either direction (±30 s) — operator clock skew is the usual
|
|
8788
|
+
* culprit for "valid code rejected" complaints.
|
|
5791
8789
|
*/
|
|
5792
8790
|
var TOTP_COLLECTION = "user_totp";
|
|
5793
8791
|
var ISSUER = "CamStack";
|
|
8792
|
+
/** RFC 6238 default time step. otplib v13 measures `epochTolerance` in
|
|
8793
|
+
* seconds, so a `window` of N steps maps to `N * TOTP_PERIOD_SECONDS`. */
|
|
8794
|
+
var TOTP_PERIOD_SECONDS = 30;
|
|
5794
8795
|
function parseRow(data) {
|
|
5795
8796
|
const userId = data["userId"];
|
|
5796
8797
|
const secret = data["secret"];
|
|
@@ -5808,9 +8809,12 @@ function parseRow(data) {
|
|
|
5808
8809
|
}
|
|
5809
8810
|
var TotpManager = class {
|
|
5810
8811
|
store;
|
|
8812
|
+
/** ±N steps of clock-skew tolerance, expressed in seconds for otplib v13's
|
|
8813
|
+
* per-call `epochTolerance`. Default window 1 = ±30 s. */
|
|
8814
|
+
epochTolerance;
|
|
5811
8815
|
constructor(store, opts = {}) {
|
|
5812
8816
|
this.store = store;
|
|
5813
|
-
|
|
8817
|
+
this.epochTolerance = (opts.window ?? 1) * TOTP_PERIOD_SECONDS;
|
|
5814
8818
|
}
|
|
5815
8819
|
/**
|
|
5816
8820
|
* Begin enrollment. Always generates a fresh secret — calling `setup`
|
|
@@ -5822,8 +8826,12 @@ var TotpManager = class {
|
|
|
5822
8826
|
* recognition. `ISSUER` is the CamStack brand.
|
|
5823
8827
|
*/
|
|
5824
8828
|
async setup(userId, username) {
|
|
5825
|
-
const secret =
|
|
5826
|
-
const otpauthUrl =
|
|
8829
|
+
const secret = I();
|
|
8830
|
+
const otpauthUrl = T({
|
|
8831
|
+
secret,
|
|
8832
|
+
label: username,
|
|
8833
|
+
issuer: ISSUER
|
|
8834
|
+
});
|
|
5827
8835
|
const row = {
|
|
5828
8836
|
userId,
|
|
5829
8837
|
secret,
|
|
@@ -5856,7 +8864,11 @@ var TotpManager = class {
|
|
|
5856
8864
|
async confirm(userId, code) {
|
|
5857
8865
|
const row = await this.find(userId);
|
|
5858
8866
|
if (!row) return false;
|
|
5859
|
-
if (!
|
|
8867
|
+
if (!d({
|
|
8868
|
+
token: code,
|
|
8869
|
+
secret: row.secret,
|
|
8870
|
+
epochTolerance: this.epochTolerance
|
|
8871
|
+
}).valid) return false;
|
|
5860
8872
|
if (row.confirmedAt === null) {
|
|
5861
8873
|
const next = {
|
|
5862
8874
|
...row,
|
|
@@ -5889,7 +8901,11 @@ var TotpManager = class {
|
|
|
5889
8901
|
const row = await this.find(userId);
|
|
5890
8902
|
if (!row) return false;
|
|
5891
8903
|
if (row.confirmedAt === null) return false;
|
|
5892
|
-
return
|
|
8904
|
+
return d({
|
|
8905
|
+
token: code,
|
|
8906
|
+
secret: row.secret,
|
|
8907
|
+
epochTolerance: this.epochTolerance
|
|
8908
|
+
}).valid;
|
|
5893
8909
|
}
|
|
5894
8910
|
/**
|
|
5895
8911
|
* Read the user's enrollment status. Pending half-enrollments are
|
|
@@ -6559,4 +9575,4 @@ var LocalAuthAddon = class extends BaseAddon {
|
|
|
6559
9575
|
}
|
|
6560
9576
|
};
|
|
6561
9577
|
//#endregion
|
|
6562
|
-
export { LocalAuthAddon, LocalAuthAddon as default,
|
|
9578
|
+
export { LocalAuthAddon, LocalAuthAddon as default, require_ms as a, __esmMin as c, __toCommonJS as d, __toESM as f, AuthManager as i, __exportAll as l, ApiKeyManager as n, require_safe_buffer as o, UserManager as r, __commonJSMin as s, ScopedTokenManager as t, __require as u };
|