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