From dd255295e91eb12dd491eea3b09bb8de9bbf1441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Molinero=20Fern=C3=A1ndez?= Date: Sat, 4 Dec 2021 19:15:55 +0100 Subject: [PATCH] 7.0.8 --- dist/otpauth.cjs.js | 157 +++++++++++++++++------------------ dist/otpauth.cjs.min.js | 4 +- dist/otpauth.cjs.min.js.map | 2 +- dist/otpauth.d.ts | 8 +- dist/otpauth.esm.js | 157 +++++++++++++++++------------------ dist/otpauth.esm.min.js | 4 +- dist/otpauth.esm.min.js.map | 2 +- dist/otpauth.umd.js | 157 +++++++++++++++++------------------ dist/otpauth.umd.min.js | 4 +- dist/otpauth.umd.min.js.map | 2 +- docs/classes/HOTP.html | 26 +++--- docs/classes/Secret.html | 20 ++--- docs/classes/TOTP.html | 26 +++--- docs/classes/URI.html | 4 +- docs/modules.html | 2 +- package-lock.json | 4 +- package.json | 2 +- types/hotp.d.ts | 6 +- types/index.d.ts | 10 +-- types/totp.d.ts | 6 +- types/uri.d.ts | 4 +- types/utils/global-this.d.ts | 2 +- 22 files changed, 294 insertions(+), 315 deletions(-) diff --git a/dist/otpauth.cjs.js b/dist/otpauth.cjs.js index c8cba579..b785539d 100644 --- a/dist/otpauth.cjs.js +++ b/dist/otpauth.cjs.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.7 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.8 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! jssha v3.2.0 | (c) Brian Turek | BSD-3-Clause | https://github.com/Caligatio/jsSHA */ 'use strict'; @@ -1213,12 +1213,11 @@ var _default = /*#__PURE__*/function () { * "globalThis" ponyfill. * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} -*/ + */ var globalThis = function () { // @ts-ignore - if (_typeof(globalThis) === 'object') return globalThis;else { - // eslint-disable-next-line no-extend-native - Object.defineProperty(Object.prototype, '__GLOBALTHIS__', { + if (_typeof(globalThis) === "object") return globalThis;else { + Object.defineProperty(Object.prototype, "__GLOBALTHIS__", { get: function get() { return this; }, @@ -1228,18 +1227,14 @@ var globalThis = function () { try { // @ts-ignore // eslint-disable-next-line no-undef - if (typeof __GLOBALTHIS__ !== 'undefined') return __GLOBALTHIS__; + if (typeof __GLOBALTHIS__ !== "undefined") return __GLOBALTHIS__; } finally { // @ts-ignore delete Object.prototype.__GLOBALTHIS__; } } // Still unable to determine "globalThis", fall back to a naive method. - /* eslint-disable no-undef, no-restricted-globals */ - - if (typeof self !== 'undefined') return self;else if (typeof window !== 'undefined') return window;else if (typeof global !== 'undefined') return global; - /* eslint-enable */ - + if (typeof self !== "undefined") return self;else if (typeof window !== "undefined") return window;else if (typeof global !== "undefined") return global; return undefined; }(); @@ -1248,7 +1243,7 @@ var globalThis = function () { * @type {boolean} */ -var isNode = Object.prototype.toString.call(globalThis.process) === '[object process]'; +var isNode = Object.prototype.toString.call(globalThis.process) === "[object process]"; /** * Dynamically import Node.js modules ("eval" is used to prevent bundlers from including the module). @@ -1257,26 +1252,25 @@ var isNode = Object.prototype.toString.call(globalThis.process) === '[object pro * @returns {*} Module. */ -var nodeRequire = isNode // eslint-disable-next-line no-eval -? eval('require') : function () {}; +var nodeRequire = isNode ? eval("require") : function () {}; var NodeBuffer$1 = isNode ? globalThis.Buffer : undefined; -var NodeCrypto$2 = isNode ? nodeRequire('crypto') : undefined; +var NodeCrypto$2 = isNode ? nodeRequire("crypto") : undefined; /** * OpenSSL to jsSHA algorithms. * @type {Object.} */ var OPENSSL_TO_JSSHA_ALGO = { - 'SHA1': 'SHA-1', - 'SHA224': 'SHA-224', - 'SHA256': 'SHA-256', - 'SHA384': 'SHA-384', - 'SHA512': 'SHA-512', - 'SHA3-224': 'SHA3-224', - 'SHA3-256': 'SHA3-256', - 'SHA3-384': 'SHA3-384', - 'SHA3-512': 'SHA3-512' + SHA1: "SHA-1", + SHA224: "SHA-224", + SHA256: "SHA-256", + SHA384: "SHA-384", + SHA512: "SHA-512", + "SHA3-224": "SHA3-224", + "SHA3-256": "SHA3-256", + "SHA3-384": "SHA3-384", + "SHA3-512": "SHA3-512" }; /** * Calculates an HMAC digest. @@ -1295,19 +1289,18 @@ var hmacDigest = function hmacDigest(algorithm, key, message) { } else { var variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()]; - if (typeof variant === 'undefined') { - throw new TypeError('Unknown hash function'); + if (typeof variant === "undefined") { + throw new TypeError("Unknown hash function"); } // @ts-ignore - // eslint-disable-next-line @babel/new-cap - var _hmac = new _default(variant, 'ARRAYBUFFER'); + var _hmac = new _default(variant, "ARRAYBUFFER"); - _hmac.setHMACKey(key, 'ARRAYBUFFER'); + _hmac.setHMACKey(key, "ARRAYBUFFER"); _hmac.update(message); - return _hmac.getHMAC('ARRAYBUFFER'); + return _hmac.getHMAC("ARRAYBUFFER"); } }; @@ -1318,11 +1311,11 @@ var hmacDigest = function hmacDigest(algorithm, key, message) { * @returns {string} Padded number. */ var pad = function pad(num, digits) { - var prefix = ''; + var prefix = ""; var repeat = digits - String(num).length; while (repeat-- > 0) { - prefix += '0'; + prefix += "0"; } return "".concat(prefix).concat(num); @@ -1332,7 +1325,7 @@ var pad = function pad(num, digits) { * RFC 4648 base32 alphabet without pad. * @type {string} */ -var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; +var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; /** * Converts a base32 string to an ArrayBuffer (RFC 4648). * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode} @@ -1342,7 +1335,7 @@ var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; var base32ToBuf = function base32ToBuf(str) { // Canonicalize to all upper case and remove padding if it exists. - var cstr = str.toUpperCase().replace(/=+$/, ''); + var cstr = str.toUpperCase().replace(/=+$/, ""); var buf = new ArrayBuffer(cstr.length * 5 / 8 | 0); var arr = new Uint8Array(buf); var bits = 0; @@ -1375,7 +1368,7 @@ var base32FromBuf = function base32FromBuf(buf) { var arr = new Uint8Array(buf); var bits = 0; var value = 0; - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { value = value << 8 | arr[i]; @@ -1418,11 +1411,11 @@ var hexToBuf = function hexToBuf(str) { var hexFromBuf = function hexFromBuf(buf) { var arr = new Uint8Array(buf); - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { var hex = arr[i].toString(16); - if (hex.length === 1) str += '0'; + if (hex.length === 1) str += "0"; str += hex; } @@ -1439,7 +1432,7 @@ var latin1ToBuf = function latin1ToBuf(str) { var arr = new Uint8Array(buf); for (var i = 0; i < str.length; i++) { - arr[i] = str.charCodeAt(i) & 0xFF; + arr[i] = str.charCodeAt(i) & 0xff; } return buf; @@ -1453,7 +1446,7 @@ var latin1ToBuf = function latin1ToBuf(str) { var latin1FromBuf = function latin1FromBuf(buf) { var arr = new Uint8Array(buf); - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { str += String.fromCharCode(arr[i]); @@ -1467,13 +1460,13 @@ var latin1FromBuf = function latin1FromBuf(buf) { * @type {TextEncoder|null} */ -var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder('utf-8') : null; +var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder("utf-8") : null; /** * TextDecoder instance. * @type {TextDecoder|null} */ -var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : null; +var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder("utf-8") : null; /** * Converts an UTF-8 string to an ArrayBuffer. * @param {string} str String. @@ -1482,7 +1475,7 @@ var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : nul var utf8ToBuf = function utf8ToBuf(str) { if (!ENCODER) { - throw new Error('Encoding API not available'); + throw new Error("Encoding API not available"); } return ENCODER.encode(str).buffer; @@ -1496,13 +1489,13 @@ var utf8ToBuf = function utf8ToBuf(str) { var utf8FromBuf = function utf8FromBuf(buf) { if (!DECODER) { - throw new Error('Encoding API not available'); + throw new Error("Encoding API not available"); } return DECODER.decode(buf); }; -var NodeCrypto$1 = isNode ? nodeRequire('crypto') : undefined; +var NodeCrypto$1 = isNode ? nodeRequire("crypto") : undefined; var BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined; /** * Returns random bytes. @@ -1515,7 +1508,7 @@ var randomBytes = function randomBytes(size) { return NodeCrypto$1.randomBytes(size).buffer; } else { if (!BrowserCrypto || !BrowserCrypto.getRandomValues) { - throw new Error('Cryptography API not available'); + throw new Error("Cryptography API not available"); } return BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer; @@ -1545,7 +1538,7 @@ var Secret = /*#__PURE__*/function () { * Secret key. * @type {ArrayBuffer} */ - this.buffer = typeof buffer === 'undefined' ? randomBytes(size) : buffer; + this.buffer = typeof buffer === "undefined" ? randomBytes(size) : buffer; } /** * Converts a Latin-1 string to a Secret object. @@ -1562,7 +1555,7 @@ var Secret = /*#__PURE__*/function () { * @type {string} */ function get() { - Object.defineProperty(this, 'latin1', { + Object.defineProperty(this, "latin1", { enumerable: true, value: latin1FromBuf(this.buffer) }); @@ -1576,7 +1569,7 @@ var Secret = /*#__PURE__*/function () { }, { key: "utf8", get: function get() { - Object.defineProperty(this, 'utf8', { + Object.defineProperty(this, "utf8", { enumerable: true, value: utf8FromBuf(this.buffer) }); @@ -1590,7 +1583,7 @@ var Secret = /*#__PURE__*/function () { }, { key: "base32", get: function get() { - Object.defineProperty(this, 'base32', { + Object.defineProperty(this, "base32", { enumerable: true, value: base32FromBuf(this.buffer) }); @@ -1604,7 +1597,7 @@ var Secret = /*#__PURE__*/function () { }, { key: "hex", get: function get() { - Object.defineProperty(this, 'hex', { + Object.defineProperty(this, "hex", { enumerable: true, value: hexFromBuf(this.buffer) }); @@ -1662,7 +1655,7 @@ var Secret = /*#__PURE__*/function () { }(); var NodeBuffer = isNode ? globalThis.Buffer : undefined; -var NodeCrypto = isNode ? nodeRequire('crypto') : undefined; +var NodeCrypto = isNode ? nodeRequire("crypto") : undefined; /** * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values. * @param {string} a String a. @@ -1675,7 +1668,7 @@ var timingSafeEqual = function timingSafeEqual(a, b) { return NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b)); } else { if (a.length !== b.length) { - throw new TypeError('Input strings must have the same length'); + throw new TypeError("Input strings must have the same length"); } var i = -1; @@ -1738,7 +1731,7 @@ var HOTP = /*#__PURE__*/function () { * @type {Secret} */ - this.secret = typeof secret === 'string' ? Secret.fromBase32(secret) : secret; + this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret; /** * HMAC hashing algorithm. * @type {string} @@ -1836,7 +1829,7 @@ var HOTP = /*#__PURE__*/function () { key: "toString", value: function toString() { var e = encodeURIComponent; - return 'otpauth://hotp/' + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "counter=".concat(e(this.counter)); + return "otpauth://hotp/" + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "counter=".concat(e(this.counter)); } }], [{ key: "defaults", @@ -1854,9 +1847,9 @@ var HOTP = /*#__PURE__*/function () { */ function get() { return { - issuer: '', - label: 'OTPAuth', - algorithm: 'SHA1', + issuer: "", + label: "OTPAuth", + algorithm: "SHA1", digits: 6, counter: 0, window: 1 @@ -1961,7 +1954,7 @@ var TOTP = /*#__PURE__*/function () { * @type {Secret} */ - this.secret = typeof secret === 'string' ? Secret.fromBase32(secret) : secret; + this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret; /** * HMAC hashing algorithm. * @type {string} @@ -2062,7 +2055,7 @@ var TOTP = /*#__PURE__*/function () { key: "toString", value: function toString() { var e = encodeURIComponent; - return 'otpauth://totp/' + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "period=".concat(e(this.period)); + return "otpauth://totp/" + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "period=".concat(e(this.period)); } }], [{ key: "defaults", @@ -2080,9 +2073,9 @@ var TOTP = /*#__PURE__*/function () { */ function get() { return { - issuer: '', - label: 'OTPAuth', - algorithm: 'SHA1', + issuer: "", + label: "OTPAuth", + algorithm: "SHA1", digits: 6, period: 30, window: 1 @@ -2189,7 +2182,7 @@ var URI = /*#__PURE__*/function () { } if (!Array.isArray(uriGroups)) { - throw new URIError('Invalid URI format'); + throw new URIError("Invalid URI format"); } // Extract URI groups. @@ -2197,7 +2190,7 @@ var URI = /*#__PURE__*/function () { var uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent); /** @type {Object.} */ - var uriParams = uriGroups[3].split('&').reduce(function (acc, cur) { + var uriParams = uriGroups[3].split("&").reduce(function (acc, cur) { var pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent); var pairKey = pairArr[0].toLowerCase(); var pairVal = pairArr[1]; @@ -2211,26 +2204,26 @@ var URI = /*#__PURE__*/function () { var OTP; var config = {}; - if (uriType === 'hotp') { + if (uriType === "hotp") { OTP = HOTP; // Counter: required - if (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) { + if (typeof uriParams.counter !== "undefined" && INTEGER_REGEX.test(uriParams.counter)) { config.counter = parseInt(uriParams.counter, 10); } else { - throw new TypeError('Missing or invalid \'counter\' parameter'); + throw new TypeError("Missing or invalid 'counter' parameter"); } - } else if (uriType === 'totp') { + } else if (uriType === "totp") { OTP = TOTP; // Period: optional - if (typeof uriParams.period !== 'undefined') { + if (typeof uriParams.period !== "undefined") { if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) { config.period = parseInt(uriParams.period, 10); } else { - throw new TypeError('Invalid \'period\' parameter'); + throw new TypeError("Invalid 'period' parameter"); } } } else { - throw new TypeError('Unknown OTP type'); + throw new TypeError("Unknown OTP type"); } // Label: required // Issuer: optional @@ -2238,43 +2231,43 @@ var URI = /*#__PURE__*/function () { if (uriLabel.length === 2) { config.label = uriLabel[1]; - if (typeof uriParams.issuer === 'undefined') { + if (typeof uriParams.issuer === "undefined") { config.issuer = uriLabel[0]; } else if (uriParams.issuer === uriLabel[0]) { config.issuer = uriParams.issuer; } else { - throw new TypeError('Invalid \'issuer\' parameter'); + throw new TypeError("Invalid 'issuer' parameter"); } } else { config.label = uriLabel[0]; - if (typeof uriParams.issuer !== 'undefined') { + if (typeof uriParams.issuer !== "undefined") { config.issuer = uriParams.issuer; } } // Secret: required - if (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) { + if (typeof uriParams.secret !== "undefined" && SECRET_REGEX.test(uriParams.secret)) { config.secret = uriParams.secret; } else { - throw new TypeError('Missing or invalid \'secret\' parameter'); + throw new TypeError("Missing or invalid 'secret' parameter"); } // Algorithm: optional - if (typeof uriParams.algorithm !== 'undefined') { + if (typeof uriParams.algorithm !== "undefined") { if (ALGORITHM_REGEX.test(uriParams.algorithm)) { config.algorithm = uriParams.algorithm; } else { - throw new TypeError('Invalid \'algorithm\' parameter'); + throw new TypeError("Invalid 'algorithm' parameter"); } } // Digits: optional - if (typeof uriParams.digits !== 'undefined') { + if (typeof uriParams.digits !== "undefined") { if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) { config.digits = parseInt(uriParams.digits, 10); } else { - throw new TypeError('Invalid \'digits\' parameter'); + throw new TypeError("Invalid 'digits' parameter"); } } @@ -2293,7 +2286,7 @@ var URI = /*#__PURE__*/function () { return otp.toString(); } - throw new TypeError('Invalid \'HOTP/TOTP\' object'); + throw new TypeError("Invalid 'HOTP/TOTP' object"); } }]); @@ -2304,7 +2297,7 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = '7.0.7'; +var version = "7.0.8"; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.cjs.min.js b/dist/otpauth.cjs.min.js index bd987a68..3daab85b 100644 --- a/dist/otpauth.cjs.min.js +++ b/dist/otpauth.cjs.min.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.7 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.8 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! jssha v3.2.0 | (c) Brian Turek | BSD-3-Clause | https://github.com/Caligatio/jsSHA */ "use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=t.issuer,n=voi ;return e.validate({token:r,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:n,window:i})}},{key:"toString",value:function(){var e=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"period=".concat(e(this.period))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,period:30,window:1}}},{key:"generate",value:function(t){var r=t.secret,n=t.algorithm,i=t.digits,o=t.period,u=void 0===o?e.defaults.period:o,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:r,algorithm:n,digits:i,counter:Math.floor(s/1e3/u)})}},{key:"validate",value:function(t){ var r=t.token,n=t.secret,i=t.algorithm,o=t.digits,u=t.period,a=void 0===u?e.defaults.period:u,s=t.timestamp,f=void 0===s?Date.now():s,c=t.window;return HOTP.validate({token:r,secret:n,algorithm:i,digits:o,counter:Math.floor(f/1e3/a),window:c})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var r,n=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var r=t.split(/=(.*)/,2).map(decodeURIComponent),n=r[0].toLowerCase(),i=r[1],o=e;return o[n]=i,o}),{}),u={};if("hotp"===n){if(r=HOTP, void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");u.counter=parseInt(o.counter,10)}else{if("totp"!==n)throw new TypeError("Unknown OTP type");if(r=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");u.period=parseInt(o.period,10)}}if(2===i.length)if(u.label=i[1],void 0===o.issuer)u.issuer=i[0];else{if(o.issuer!==i[0])throw new TypeError("Invalid 'issuer' parameter");u.issuer=o.issuer}else u.label=i[0],void 0!==o.issuer&&(u.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(u.secret=o.secret,void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");u.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter");u.digits=parseInt(o.digits,10)}return new r(u)}},{key:"stringify", -value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.7";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.version=version; +value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.8";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.version=version; //# sourceMappingURL=otpauth.cjs.min.js.map diff --git a/dist/otpauth.cjs.min.js.map b/dist/otpauth.cjs.min.js.map index 697542df..ca5c6fbd 100644 --- a/dist/otpauth.cjs.min.js.map +++ b/dist/otpauth.cjs.min.js.map @@ -1 +1 @@ -{"version":3,"file":"otpauth.cjs.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport { nodeRequire };\n","import jsSHA from 'jssha';\n\nimport { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport { hmacDigest };\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport { pad };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nconst base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n\nexport { base32ToBuf, base32FromBuf };\n","/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nconst hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\nexport { hexToBuf, hexFromBuf };\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nconst latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n\nexport { latin1ToBuf, latin1FromBuf };\n","import { globalThis } from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nconst utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n\nexport { utf8ToBuf, utf8FromBuf };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport { randomBytes };\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport { randomBytes } from './utils/crypto/random-bytes';\n\n/**\n * OTP secret key.\n */\nclass Secret {\n\t/**\n\t * Creates a secret key object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n\nexport { Secret };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from './utils/encoding/uint';\nimport { hmacDigest } from './utils/crypto/hmac-digest';\nimport { pad } from './utils/pad';\nimport { Secret } from './secret';\nimport { timingSafeEqual } from './utils/crypto/timing-safe-equal';\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates an HOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n\nexport { HOTP };\n","import { HOTP } from './hotp';\nimport { Secret } from './secret';\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates a TOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n\nexport { TOTP };\n","import { HOTP } from './hotp';\nimport { TOTP } from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;qKAKA,IAAMA,UAAY,SAACC,WACZC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACR,IAARD,EADmBC,IAEvBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GA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,OAAwB,KACxCkE,uBAAuBwB,KAAKR,EAAUlF,cAGnC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAASzE,SAAS2J,EAAUlF,OAAQ,WAMtC,IAAI2E,EAAIc;MAQhB,SAAiBrC,MACZA,aAAed,MAAQc,aAAeG,YAClCH,EAAI9E,iBAGN,IAAIqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.cjs.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n const arr = new Uint8Array(buf);\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {\n if (isNode) {\n return NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from \"./utils/encoding/uint.js\";\nimport { hmacDigest } from \"./utils/crypto/hmac-digest.js\";\nimport { pad } from \"./utils/pad.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./utils/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret =\n typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = algorithm.toUpperCase();\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = new Uint8Array(\n hmacDigest(algorithm, secret.buffer, uintToBuf(counter))\n );\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return pad(otp, digits);\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} config.digits Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n for (let i = counter - window; i <= counter + window; ++i) {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret =\n typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = algorithm.toUpperCase();\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm,\n digits,\n period = TOTP.defaults.period,\n timestamp = Date.now(),\n }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} config.digits Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits,\n period = TOTP.defaults.period,\n timestamp = Date.now(),\n window,\n }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX =\n /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n } catch (error) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (\n typeof uriParams.counter !== \"undefined\" &&\n INTEGER_REGEX.test(uriParams.counter)\n ) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof uriParams.issuer === \"undefined\") {\n config.issuer = uriLabel[0];\n } else if (uriParams.issuer === uriLabel[0]) {\n config.issuer = uriParams.issuer;\n } else {\n throw new TypeError(\"Invalid 'issuer' parameter\");\n }\n } else {\n config.label = uriLabel[0];\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n }\n\n // Secret: required\n if (\n typeof uriParams.secret !== \"undefined\" &&\n SECRET_REGEX.test(uriParams.secret)\n ) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","SHA1","SHA224","SHA256","SHA384","SHA512","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;qKAKA,IAAMA,UAAY,SAACC,WACXC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACP,IAARD,EADkBC,IAEtBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGFJ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iG,EAAUjG,kBAOD,IAArBiG,EAAUlF,OAAwB,KACvCkE,uBAAuBwB,KAAKR,EAAUlF,cAGlC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAAS9E,SAASgK,EAAUlF,OAAQ,WAMxC,IAAI2E,EAAIc;MAQjB,SAAiBrC,MACXA,aAAed,MAAQc,aAAeG,YACjCH,EAAInF,iBAGP,IAAI0B,UAAU,uCC9JlBgG,QAAU"} \ No newline at end of file diff --git a/dist/otpauth.d.ts b/dist/otpauth.d.ts index 6f64e0e6..fb6665a2 100644 --- a/dist/otpauth.d.ts +++ b/dist/otpauth.d.ts @@ -175,7 +175,7 @@ declare class HOTP { * @param {number} [config.counter=this.counter++] Counter value. * @returns {string} Token. */ - generate({ counter, }?: { + generate({ counter }?: { counter?: number | undefined; } | undefined): string; /** @@ -186,7 +186,7 @@ declare class HOTP { * @param {number} [config.window=1] Window of counter values to test. * @returns {number|null} Token delta, or null if the token is not found. */ - validate({ token, counter, window, }: { + validate({ token, counter, window }: { token: string; counter?: number | undefined; window?: number | undefined; @@ -314,7 +314,7 @@ declare class TOTP { * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds. * @returns {string} Token. */ - generate({ timestamp, }?: { + generate({ timestamp }?: { timestamp?: number | undefined; } | undefined): string; /** @@ -325,7 +325,7 @@ declare class TOTP { * @param {number} [config.window=1] Window of counter values to test. * @returns {number|null} Token delta, or null if the token is not found. */ - validate({ token, timestamp, window, }: { + validate({ token, timestamp, window }: { token: string; timestamp?: number | undefined; window?: number | undefined; diff --git a/dist/otpauth.esm.js b/dist/otpauth.esm.js index e87ea642..b054453d 100644 --- a/dist/otpauth.esm.js +++ b/dist/otpauth.esm.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.7 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.8 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! jssha v3.2.0 | (c) Brian Turek | BSD-3-Clause | https://github.com/Caligatio/jsSHA */ function _typeof(obj) { @@ -1209,12 +1209,11 @@ var _default = /*#__PURE__*/function () { * "globalThis" ponyfill. * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} -*/ + */ var globalThis = function () { // @ts-ignore - if (_typeof(globalThis) === 'object') return globalThis;else { - // eslint-disable-next-line no-extend-native - Object.defineProperty(Object.prototype, '__GLOBALTHIS__', { + if (_typeof(globalThis) === "object") return globalThis;else { + Object.defineProperty(Object.prototype, "__GLOBALTHIS__", { get: function get() { return this; }, @@ -1224,18 +1223,14 @@ var globalThis = function () { try { // @ts-ignore // eslint-disable-next-line no-undef - if (typeof __GLOBALTHIS__ !== 'undefined') return __GLOBALTHIS__; + if (typeof __GLOBALTHIS__ !== "undefined") return __GLOBALTHIS__; } finally { // @ts-ignore delete Object.prototype.__GLOBALTHIS__; } } // Still unable to determine "globalThis", fall back to a naive method. - /* eslint-disable no-undef, no-restricted-globals */ - - if (typeof self !== 'undefined') return self;else if (typeof window !== 'undefined') return window;else if (typeof global !== 'undefined') return global; - /* eslint-enable */ - + if (typeof self !== "undefined") return self;else if (typeof window !== "undefined") return window;else if (typeof global !== "undefined") return global; return undefined; }(); @@ -1244,7 +1239,7 @@ var globalThis = function () { * @type {boolean} */ -var isNode = Object.prototype.toString.call(globalThis.process) === '[object process]'; +var isNode = Object.prototype.toString.call(globalThis.process) === "[object process]"; /** * Dynamically import Node.js modules ("eval" is used to prevent bundlers from including the module). @@ -1253,26 +1248,25 @@ var isNode = Object.prototype.toString.call(globalThis.process) === '[object pro * @returns {*} Module. */ -var nodeRequire = isNode // eslint-disable-next-line no-eval -? eval('require') : function () {}; +var nodeRequire = isNode ? eval("require") : function () {}; var NodeBuffer$1 = isNode ? globalThis.Buffer : undefined; -var NodeCrypto$2 = isNode ? nodeRequire('crypto') : undefined; +var NodeCrypto$2 = isNode ? nodeRequire("crypto") : undefined; /** * OpenSSL to jsSHA algorithms. * @type {Object.} */ var OPENSSL_TO_JSSHA_ALGO = { - 'SHA1': 'SHA-1', - 'SHA224': 'SHA-224', - 'SHA256': 'SHA-256', - 'SHA384': 'SHA-384', - 'SHA512': 'SHA-512', - 'SHA3-224': 'SHA3-224', - 'SHA3-256': 'SHA3-256', - 'SHA3-384': 'SHA3-384', - 'SHA3-512': 'SHA3-512' + SHA1: "SHA-1", + SHA224: "SHA-224", + SHA256: "SHA-256", + SHA384: "SHA-384", + SHA512: "SHA-512", + "SHA3-224": "SHA3-224", + "SHA3-256": "SHA3-256", + "SHA3-384": "SHA3-384", + "SHA3-512": "SHA3-512" }; /** * Calculates an HMAC digest. @@ -1291,19 +1285,18 @@ var hmacDigest = function hmacDigest(algorithm, key, message) { } else { var variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()]; - if (typeof variant === 'undefined') { - throw new TypeError('Unknown hash function'); + if (typeof variant === "undefined") { + throw new TypeError("Unknown hash function"); } // @ts-ignore - // eslint-disable-next-line @babel/new-cap - var _hmac = new _default(variant, 'ARRAYBUFFER'); + var _hmac = new _default(variant, "ARRAYBUFFER"); - _hmac.setHMACKey(key, 'ARRAYBUFFER'); + _hmac.setHMACKey(key, "ARRAYBUFFER"); _hmac.update(message); - return _hmac.getHMAC('ARRAYBUFFER'); + return _hmac.getHMAC("ARRAYBUFFER"); } }; @@ -1314,11 +1307,11 @@ var hmacDigest = function hmacDigest(algorithm, key, message) { * @returns {string} Padded number. */ var pad = function pad(num, digits) { - var prefix = ''; + var prefix = ""; var repeat = digits - String(num).length; while (repeat-- > 0) { - prefix += '0'; + prefix += "0"; } return "".concat(prefix).concat(num); @@ -1328,7 +1321,7 @@ var pad = function pad(num, digits) { * RFC 4648 base32 alphabet without pad. * @type {string} */ -var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; +var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; /** * Converts a base32 string to an ArrayBuffer (RFC 4648). * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode} @@ -1338,7 +1331,7 @@ var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; var base32ToBuf = function base32ToBuf(str) { // Canonicalize to all upper case and remove padding if it exists. - var cstr = str.toUpperCase().replace(/=+$/, ''); + var cstr = str.toUpperCase().replace(/=+$/, ""); var buf = new ArrayBuffer(cstr.length * 5 / 8 | 0); var arr = new Uint8Array(buf); var bits = 0; @@ -1371,7 +1364,7 @@ var base32FromBuf = function base32FromBuf(buf) { var arr = new Uint8Array(buf); var bits = 0; var value = 0; - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { value = value << 8 | arr[i]; @@ -1414,11 +1407,11 @@ var hexToBuf = function hexToBuf(str) { var hexFromBuf = function hexFromBuf(buf) { var arr = new Uint8Array(buf); - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { var hex = arr[i].toString(16); - if (hex.length === 1) str += '0'; + if (hex.length === 1) str += "0"; str += hex; } @@ -1435,7 +1428,7 @@ var latin1ToBuf = function latin1ToBuf(str) { var arr = new Uint8Array(buf); for (var i = 0; i < str.length; i++) { - arr[i] = str.charCodeAt(i) & 0xFF; + arr[i] = str.charCodeAt(i) & 0xff; } return buf; @@ -1449,7 +1442,7 @@ var latin1ToBuf = function latin1ToBuf(str) { var latin1FromBuf = function latin1FromBuf(buf) { var arr = new Uint8Array(buf); - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { str += String.fromCharCode(arr[i]); @@ -1463,13 +1456,13 @@ var latin1FromBuf = function latin1FromBuf(buf) { * @type {TextEncoder|null} */ -var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder('utf-8') : null; +var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder("utf-8") : null; /** * TextDecoder instance. * @type {TextDecoder|null} */ -var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : null; +var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder("utf-8") : null; /** * Converts an UTF-8 string to an ArrayBuffer. * @param {string} str String. @@ -1478,7 +1471,7 @@ var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : nul var utf8ToBuf = function utf8ToBuf(str) { if (!ENCODER) { - throw new Error('Encoding API not available'); + throw new Error("Encoding API not available"); } return ENCODER.encode(str).buffer; @@ -1492,13 +1485,13 @@ var utf8ToBuf = function utf8ToBuf(str) { var utf8FromBuf = function utf8FromBuf(buf) { if (!DECODER) { - throw new Error('Encoding API not available'); + throw new Error("Encoding API not available"); } return DECODER.decode(buf); }; -var NodeCrypto$1 = isNode ? nodeRequire('crypto') : undefined; +var NodeCrypto$1 = isNode ? nodeRequire("crypto") : undefined; var BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined; /** * Returns random bytes. @@ -1511,7 +1504,7 @@ var randomBytes = function randomBytes(size) { return NodeCrypto$1.randomBytes(size).buffer; } else { if (!BrowserCrypto || !BrowserCrypto.getRandomValues) { - throw new Error('Cryptography API not available'); + throw new Error("Cryptography API not available"); } return BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer; @@ -1541,7 +1534,7 @@ var Secret = /*#__PURE__*/function () { * Secret key. * @type {ArrayBuffer} */ - this.buffer = typeof buffer === 'undefined' ? randomBytes(size) : buffer; + this.buffer = typeof buffer === "undefined" ? randomBytes(size) : buffer; } /** * Converts a Latin-1 string to a Secret object. @@ -1558,7 +1551,7 @@ var Secret = /*#__PURE__*/function () { * @type {string} */ function get() { - Object.defineProperty(this, 'latin1', { + Object.defineProperty(this, "latin1", { enumerable: true, value: latin1FromBuf(this.buffer) }); @@ -1572,7 +1565,7 @@ var Secret = /*#__PURE__*/function () { }, { key: "utf8", get: function get() { - Object.defineProperty(this, 'utf8', { + Object.defineProperty(this, "utf8", { enumerable: true, value: utf8FromBuf(this.buffer) }); @@ -1586,7 +1579,7 @@ var Secret = /*#__PURE__*/function () { }, { key: "base32", get: function get() { - Object.defineProperty(this, 'base32', { + Object.defineProperty(this, "base32", { enumerable: true, value: base32FromBuf(this.buffer) }); @@ -1600,7 +1593,7 @@ var Secret = /*#__PURE__*/function () { }, { key: "hex", get: function get() { - Object.defineProperty(this, 'hex', { + Object.defineProperty(this, "hex", { enumerable: true, value: hexFromBuf(this.buffer) }); @@ -1658,7 +1651,7 @@ var Secret = /*#__PURE__*/function () { }(); var NodeBuffer = isNode ? globalThis.Buffer : undefined; -var NodeCrypto = isNode ? nodeRequire('crypto') : undefined; +var NodeCrypto = isNode ? nodeRequire("crypto") : undefined; /** * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values. * @param {string} a String a. @@ -1671,7 +1664,7 @@ var timingSafeEqual = function timingSafeEqual(a, b) { return NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b)); } else { if (a.length !== b.length) { - throw new TypeError('Input strings must have the same length'); + throw new TypeError("Input strings must have the same length"); } var i = -1; @@ -1734,7 +1727,7 @@ var HOTP = /*#__PURE__*/function () { * @type {Secret} */ - this.secret = typeof secret === 'string' ? Secret.fromBase32(secret) : secret; + this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret; /** * HMAC hashing algorithm. * @type {string} @@ -1832,7 +1825,7 @@ var HOTP = /*#__PURE__*/function () { key: "toString", value: function toString() { var e = encodeURIComponent; - return 'otpauth://hotp/' + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "counter=".concat(e(this.counter)); + return "otpauth://hotp/" + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "counter=".concat(e(this.counter)); } }], [{ key: "defaults", @@ -1850,9 +1843,9 @@ var HOTP = /*#__PURE__*/function () { */ function get() { return { - issuer: '', - label: 'OTPAuth', - algorithm: 'SHA1', + issuer: "", + label: "OTPAuth", + algorithm: "SHA1", digits: 6, counter: 0, window: 1 @@ -1957,7 +1950,7 @@ var TOTP = /*#__PURE__*/function () { * @type {Secret} */ - this.secret = typeof secret === 'string' ? Secret.fromBase32(secret) : secret; + this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret; /** * HMAC hashing algorithm. * @type {string} @@ -2058,7 +2051,7 @@ var TOTP = /*#__PURE__*/function () { key: "toString", value: function toString() { var e = encodeURIComponent; - return 'otpauth://totp/' + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "period=".concat(e(this.period)); + return "otpauth://totp/" + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "period=".concat(e(this.period)); } }], [{ key: "defaults", @@ -2076,9 +2069,9 @@ var TOTP = /*#__PURE__*/function () { */ function get() { return { - issuer: '', - label: 'OTPAuth', - algorithm: 'SHA1', + issuer: "", + label: "OTPAuth", + algorithm: "SHA1", digits: 6, period: 30, window: 1 @@ -2185,7 +2178,7 @@ var URI = /*#__PURE__*/function () { } if (!Array.isArray(uriGroups)) { - throw new URIError('Invalid URI format'); + throw new URIError("Invalid URI format"); } // Extract URI groups. @@ -2193,7 +2186,7 @@ var URI = /*#__PURE__*/function () { var uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent); /** @type {Object.} */ - var uriParams = uriGroups[3].split('&').reduce(function (acc, cur) { + var uriParams = uriGroups[3].split("&").reduce(function (acc, cur) { var pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent); var pairKey = pairArr[0].toLowerCase(); var pairVal = pairArr[1]; @@ -2207,26 +2200,26 @@ var URI = /*#__PURE__*/function () { var OTP; var config = {}; - if (uriType === 'hotp') { + if (uriType === "hotp") { OTP = HOTP; // Counter: required - if (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) { + if (typeof uriParams.counter !== "undefined" && INTEGER_REGEX.test(uriParams.counter)) { config.counter = parseInt(uriParams.counter, 10); } else { - throw new TypeError('Missing or invalid \'counter\' parameter'); + throw new TypeError("Missing or invalid 'counter' parameter"); } - } else if (uriType === 'totp') { + } else if (uriType === "totp") { OTP = TOTP; // Period: optional - if (typeof uriParams.period !== 'undefined') { + if (typeof uriParams.period !== "undefined") { if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) { config.period = parseInt(uriParams.period, 10); } else { - throw new TypeError('Invalid \'period\' parameter'); + throw new TypeError("Invalid 'period' parameter"); } } } else { - throw new TypeError('Unknown OTP type'); + throw new TypeError("Unknown OTP type"); } // Label: required // Issuer: optional @@ -2234,43 +2227,43 @@ var URI = /*#__PURE__*/function () { if (uriLabel.length === 2) { config.label = uriLabel[1]; - if (typeof uriParams.issuer === 'undefined') { + if (typeof uriParams.issuer === "undefined") { config.issuer = uriLabel[0]; } else if (uriParams.issuer === uriLabel[0]) { config.issuer = uriParams.issuer; } else { - throw new TypeError('Invalid \'issuer\' parameter'); + throw new TypeError("Invalid 'issuer' parameter"); } } else { config.label = uriLabel[0]; - if (typeof uriParams.issuer !== 'undefined') { + if (typeof uriParams.issuer !== "undefined") { config.issuer = uriParams.issuer; } } // Secret: required - if (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) { + if (typeof uriParams.secret !== "undefined" && SECRET_REGEX.test(uriParams.secret)) { config.secret = uriParams.secret; } else { - throw new TypeError('Missing or invalid \'secret\' parameter'); + throw new TypeError("Missing or invalid 'secret' parameter"); } // Algorithm: optional - if (typeof uriParams.algorithm !== 'undefined') { + if (typeof uriParams.algorithm !== "undefined") { if (ALGORITHM_REGEX.test(uriParams.algorithm)) { config.algorithm = uriParams.algorithm; } else { - throw new TypeError('Invalid \'algorithm\' parameter'); + throw new TypeError("Invalid 'algorithm' parameter"); } } // Digits: optional - if (typeof uriParams.digits !== 'undefined') { + if (typeof uriParams.digits !== "undefined") { if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) { config.digits = parseInt(uriParams.digits, 10); } else { - throw new TypeError('Invalid \'digits\' parameter'); + throw new TypeError("Invalid 'digits' parameter"); } } @@ -2289,7 +2282,7 @@ var URI = /*#__PURE__*/function () { return otp.toString(); } - throw new TypeError('Invalid \'HOTP/TOTP\' object'); + throw new TypeError("Invalid 'HOTP/TOTP' object"); } }]); @@ -2300,6 +2293,6 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = '7.0.7'; +var version = "7.0.8"; export { HOTP, Secret, TOTP, URI, version }; diff --git a/dist/otpauth.esm.min.js b/dist/otpauth.esm.min.js index 3fb7e787..4ad3031b 100644 --- a/dist/otpauth.esm.min.js +++ b/dist/otpauth.esm.min.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.7 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.8 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! jssha v3.2.0 | (c) Brian Turek | BSD-3-Clause | https://github.com/Caligatio/jsSHA */ function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=voi ;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r,window:i})}},{key:"toString",value:function(){var e=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"period=".concat(e(this.period))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,period:30,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=t.digits,o=t.period,u=void 0===o?e.defaults.period:o,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:n,algorithm:r,digits:i,counter:Math.floor(s/1e3/u)})}},{key:"validate",value:function(t){ var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.period,a=void 0===u?e.defaults.period:u,s=t.timestamp,f=void 0===s?Date.now():s,c=t.window;return HOTP.validate({token:n,secret:r,algorithm:i,digits:o,counter:Math.floor(f/1e3/a),window:c})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var n,r=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var n=t.split(/=(.*)/,2).map(decodeURIComponent),r=n[0].toLowerCase(),i=n[1],o=e;return o[r]=i,o}),{}),u={};if("hotp"===r){if(n=HOTP, void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");u.counter=parseInt(o.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");u.period=parseInt(o.period,10)}}if(2===i.length)if(u.label=i[1],void 0===o.issuer)u.issuer=i[0];else{if(o.issuer!==i[0])throw new TypeError("Invalid 'issuer' parameter");u.issuer=o.issuer}else u.label=i[0],void 0!==o.issuer&&(u.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(u.secret=o.secret,void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");u.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter");u.digits=parseInt(o.digits,10)}return new n(u)}},{key:"stringify", -value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.7";export{HOTP,Secret,TOTP,URI,version}; +value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.8";export{HOTP,Secret,TOTP,URI,version}; //# sourceMappingURL=otpauth.esm.min.js.map diff --git a/dist/otpauth.esm.min.js.map b/dist/otpauth.esm.min.js.map index 131a717e..b0a8c552 100644 --- a/dist/otpauth.esm.min.js.map +++ b/dist/otpauth.esm.min.js.map @@ -1 +1 @@ -{"version":3,"file":"otpauth.esm.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport { nodeRequire };\n","import jsSHA from 'jssha';\n\nimport { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport { hmacDigest };\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport { pad };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nconst base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n\nexport { base32ToBuf, base32FromBuf };\n","/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nconst hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\nexport { hexToBuf, hexFromBuf };\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nconst latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n\nexport { latin1ToBuf, latin1FromBuf };\n","import { globalThis } from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nconst utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n\nexport { utf8ToBuf, utf8FromBuf };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport { randomBytes };\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport { randomBytes } from './utils/crypto/random-bytes';\n\n/**\n * OTP secret key.\n */\nclass Secret {\n\t/**\n\t * Creates a secret key object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n\nexport { Secret };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from './utils/encoding/uint';\nimport { hmacDigest } from './utils/crypto/hmac-digest';\nimport { pad } from './utils/pad';\nimport { Secret } from './secret';\nimport { timingSafeEqual } from './utils/crypto/timing-safe-equal';\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates an HOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n\nexport { HOTP };\n","import { HOTP } from './hotp';\nimport { Secret } from './secret';\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates a TOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n\nexport { TOTP };\n","import { HOTP } from './hotp';\nimport { TOTP } from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;8GAKA,IAAMA,UAAY,SAACC,WACZC,EAAM,IA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C,YAMQ,IAAxBwC,EAAUjG,UAA2B,KAC3C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG5B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOC,IAArBiG,EAAUlF,OAAwB,KACxCkE,uBAAuBwB,KAAKR,EAAUlF,cAGnC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAASzE,SAAS2J,EAAUlF,OAAQ,WAMtC,IAAI2E,EAAIc;MAQhB,SAAiBrC,MACZA,aAAed,MAAQc,aAAeG,YAClCH,EAAI9E,iBAGN,IAAIqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.esm.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n const arr = new Uint8Array(buf);\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {\n if (isNode) {\n return NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from \"./utils/encoding/uint.js\";\nimport { hmacDigest } from \"./utils/crypto/hmac-digest.js\";\nimport { pad } from \"./utils/pad.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./utils/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret =\n typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = algorithm.toUpperCase();\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = new Uint8Array(\n hmacDigest(algorithm, secret.buffer, uintToBuf(counter))\n );\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return pad(otp, digits);\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} config.digits Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n for (let i = counter - window; i <= counter + window; ++i) {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret =\n typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = algorithm.toUpperCase();\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm,\n digits,\n period = TOTP.defaults.period,\n timestamp = Date.now(),\n }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} config.digits Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits,\n period = TOTP.defaults.period,\n timestamp = Date.now(),\n window,\n }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX =\n /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n } catch (error) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (\n typeof uriParams.counter !== \"undefined\" &&\n INTEGER_REGEX.test(uriParams.counter)\n ) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof uriParams.issuer === \"undefined\") {\n config.issuer = uriLabel[0];\n } else if (uriParams.issuer === uriLabel[0]) {\n config.issuer = uriParams.issuer;\n } else {\n throw new TypeError(\"Invalid 'issuer' parameter\");\n }\n } else {\n config.label = uriLabel[0];\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n }\n\n // Secret: required\n if (\n typeof uriParams.secret !== \"undefined\" &&\n SECRET_REGEX.test(uriParams.secret)\n ) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","SHA1","SHA224","SHA256","SHA384","SHA512","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;8GAKA,IAAMA,UAAY,SAACC,WACXC,EAAM,IAAIC,YAAY,GAC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,4CAFpB8F,EAAO/C,OAASwC,EAAUxC,YAMO,IAAxBwC,EAAUjG,UAA2B,KAC1C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG3B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOD,IAArBiG,EAAUlF,OAAwB,KACvCkE,uBAAuBwB,KAAKR,EAAUlF,cAGlC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAAS9E,SAASgK,EAAUlF,OAAQ,WAMxC,IAAI2E,EAAIc;MAQjB,SAAiBrC,MACXA,aAAed,MAAQc,aAAeG,YACjCH,EAAInF,iBAGP,IAAI0B,UAAU,uCC9JlBgG,QAAU"} \ No newline at end of file diff --git a/dist/otpauth.umd.js b/dist/otpauth.umd.js index d1a54cc1..0c6fddb2 100644 --- a/dist/otpauth.umd.js +++ b/dist/otpauth.umd.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.7 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.8 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! jssha v3.2.0 | (c) Brian Turek | BSD-3-Clause | https://github.com/Caligatio/jsSHA */ (function (global, factory) { @@ -1215,12 +1215,11 @@ * "globalThis" ponyfill. * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} - */ + */ var globalThis = function () { // @ts-ignore - if (_typeof(globalThis) === 'object') return globalThis;else { - // eslint-disable-next-line no-extend-native - Object.defineProperty(Object.prototype, '__GLOBALTHIS__', { + if (_typeof(globalThis) === "object") return globalThis;else { + Object.defineProperty(Object.prototype, "__GLOBALTHIS__", { get: function get() { return this; }, @@ -1230,18 +1229,14 @@ try { // @ts-ignore // eslint-disable-next-line no-undef - if (typeof __GLOBALTHIS__ !== 'undefined') return __GLOBALTHIS__; + if (typeof __GLOBALTHIS__ !== "undefined") return __GLOBALTHIS__; } finally { // @ts-ignore delete Object.prototype.__GLOBALTHIS__; } } // Still unable to determine "globalThis", fall back to a naive method. - /* eslint-disable no-undef, no-restricted-globals */ - - if (typeof self !== 'undefined') return self;else if (typeof window !== 'undefined') return window;else if (typeof global !== 'undefined') return global; - /* eslint-enable */ - + if (typeof self !== "undefined") return self;else if (typeof window !== "undefined") return window;else if (typeof global !== "undefined") return global; return undefined; }(); @@ -1250,7 +1245,7 @@ * @type {boolean} */ - var isNode = Object.prototype.toString.call(globalThis.process) === '[object process]'; + var isNode = Object.prototype.toString.call(globalThis.process) === "[object process]"; /** * Dynamically import Node.js modules ("eval" is used to prevent bundlers from including the module). @@ -1259,26 +1254,25 @@ * @returns {*} Module. */ - var nodeRequire = isNode // eslint-disable-next-line no-eval - ? eval('require') : function () {}; + var nodeRequire = isNode ? eval("require") : function () {}; var NodeBuffer$1 = isNode ? globalThis.Buffer : undefined; - var NodeCrypto$2 = isNode ? nodeRequire('crypto') : undefined; + var NodeCrypto$2 = isNode ? nodeRequire("crypto") : undefined; /** * OpenSSL to jsSHA algorithms. * @type {Object.} */ var OPENSSL_TO_JSSHA_ALGO = { - 'SHA1': 'SHA-1', - 'SHA224': 'SHA-224', - 'SHA256': 'SHA-256', - 'SHA384': 'SHA-384', - 'SHA512': 'SHA-512', - 'SHA3-224': 'SHA3-224', - 'SHA3-256': 'SHA3-256', - 'SHA3-384': 'SHA3-384', - 'SHA3-512': 'SHA3-512' + SHA1: "SHA-1", + SHA224: "SHA-224", + SHA256: "SHA-256", + SHA384: "SHA-384", + SHA512: "SHA-512", + "SHA3-224": "SHA3-224", + "SHA3-256": "SHA3-256", + "SHA3-384": "SHA3-384", + "SHA3-512": "SHA3-512" }; /** * Calculates an HMAC digest. @@ -1297,19 +1291,18 @@ } else { var variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()]; - if (typeof variant === 'undefined') { - throw new TypeError('Unknown hash function'); + if (typeof variant === "undefined") { + throw new TypeError("Unknown hash function"); } // @ts-ignore - // eslint-disable-next-line @babel/new-cap - var _hmac = new _default(variant, 'ARRAYBUFFER'); + var _hmac = new _default(variant, "ARRAYBUFFER"); - _hmac.setHMACKey(key, 'ARRAYBUFFER'); + _hmac.setHMACKey(key, "ARRAYBUFFER"); _hmac.update(message); - return _hmac.getHMAC('ARRAYBUFFER'); + return _hmac.getHMAC("ARRAYBUFFER"); } }; @@ -1320,11 +1313,11 @@ * @returns {string} Padded number. */ var pad = function pad(num, digits) { - var prefix = ''; + var prefix = ""; var repeat = digits - String(num).length; while (repeat-- > 0) { - prefix += '0'; + prefix += "0"; } return "".concat(prefix).concat(num); @@ -1334,7 +1327,7 @@ * RFC 4648 base32 alphabet without pad. * @type {string} */ - var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; + var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; /** * Converts a base32 string to an ArrayBuffer (RFC 4648). * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode} @@ -1344,7 +1337,7 @@ var base32ToBuf = function base32ToBuf(str) { // Canonicalize to all upper case and remove padding if it exists. - var cstr = str.toUpperCase().replace(/=+$/, ''); + var cstr = str.toUpperCase().replace(/=+$/, ""); var buf = new ArrayBuffer(cstr.length * 5 / 8 | 0); var arr = new Uint8Array(buf); var bits = 0; @@ -1377,7 +1370,7 @@ var arr = new Uint8Array(buf); var bits = 0; var value = 0; - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { value = value << 8 | arr[i]; @@ -1420,11 +1413,11 @@ var hexFromBuf = function hexFromBuf(buf) { var arr = new Uint8Array(buf); - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { var hex = arr[i].toString(16); - if (hex.length === 1) str += '0'; + if (hex.length === 1) str += "0"; str += hex; } @@ -1441,7 +1434,7 @@ var arr = new Uint8Array(buf); for (var i = 0; i < str.length; i++) { - arr[i] = str.charCodeAt(i) & 0xFF; + arr[i] = str.charCodeAt(i) & 0xff; } return buf; @@ -1455,7 +1448,7 @@ var latin1FromBuf = function latin1FromBuf(buf) { var arr = new Uint8Array(buf); - var str = ''; + var str = ""; for (var i = 0; i < arr.length; i++) { str += String.fromCharCode(arr[i]); @@ -1469,13 +1462,13 @@ * @type {TextEncoder|null} */ - var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder('utf-8') : null; + var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder("utf-8") : null; /** * TextDecoder instance. * @type {TextDecoder|null} */ - var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : null; + var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder("utf-8") : null; /** * Converts an UTF-8 string to an ArrayBuffer. * @param {string} str String. @@ -1484,7 +1477,7 @@ var utf8ToBuf = function utf8ToBuf(str) { if (!ENCODER) { - throw new Error('Encoding API not available'); + throw new Error("Encoding API not available"); } return ENCODER.encode(str).buffer; @@ -1498,13 +1491,13 @@ var utf8FromBuf = function utf8FromBuf(buf) { if (!DECODER) { - throw new Error('Encoding API not available'); + throw new Error("Encoding API not available"); } return DECODER.decode(buf); }; - var NodeCrypto$1 = isNode ? nodeRequire('crypto') : undefined; + var NodeCrypto$1 = isNode ? nodeRequire("crypto") : undefined; var BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined; /** * Returns random bytes. @@ -1517,7 +1510,7 @@ return NodeCrypto$1.randomBytes(size).buffer; } else { if (!BrowserCrypto || !BrowserCrypto.getRandomValues) { - throw new Error('Cryptography API not available'); + throw new Error("Cryptography API not available"); } return BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer; @@ -1547,7 +1540,7 @@ * Secret key. * @type {ArrayBuffer} */ - this.buffer = typeof buffer === 'undefined' ? randomBytes(size) : buffer; + this.buffer = typeof buffer === "undefined" ? randomBytes(size) : buffer; } /** * Converts a Latin-1 string to a Secret object. @@ -1564,7 +1557,7 @@ * @type {string} */ function get() { - Object.defineProperty(this, 'latin1', { + Object.defineProperty(this, "latin1", { enumerable: true, value: latin1FromBuf(this.buffer) }); @@ -1578,7 +1571,7 @@ }, { key: "utf8", get: function get() { - Object.defineProperty(this, 'utf8', { + Object.defineProperty(this, "utf8", { enumerable: true, value: utf8FromBuf(this.buffer) }); @@ -1592,7 +1585,7 @@ }, { key: "base32", get: function get() { - Object.defineProperty(this, 'base32', { + Object.defineProperty(this, "base32", { enumerable: true, value: base32FromBuf(this.buffer) }); @@ -1606,7 +1599,7 @@ }, { key: "hex", get: function get() { - Object.defineProperty(this, 'hex', { + Object.defineProperty(this, "hex", { enumerable: true, value: hexFromBuf(this.buffer) }); @@ -1664,7 +1657,7 @@ }(); var NodeBuffer = isNode ? globalThis.Buffer : undefined; - var NodeCrypto = isNode ? nodeRequire('crypto') : undefined; + var NodeCrypto = isNode ? nodeRequire("crypto") : undefined; /** * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values. * @param {string} a String a. @@ -1677,7 +1670,7 @@ return NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b)); } else { if (a.length !== b.length) { - throw new TypeError('Input strings must have the same length'); + throw new TypeError("Input strings must have the same length"); } var i = -1; @@ -1740,7 +1733,7 @@ * @type {Secret} */ - this.secret = typeof secret === 'string' ? Secret.fromBase32(secret) : secret; + this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret; /** * HMAC hashing algorithm. * @type {string} @@ -1838,7 +1831,7 @@ key: "toString", value: function toString() { var e = encodeURIComponent; - return 'otpauth://hotp/' + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "counter=".concat(e(this.counter)); + return "otpauth://hotp/" + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "counter=".concat(e(this.counter)); } }], [{ key: "defaults", @@ -1856,9 +1849,9 @@ */ function get() { return { - issuer: '', - label: 'OTPAuth', - algorithm: 'SHA1', + issuer: "", + label: "OTPAuth", + algorithm: "SHA1", digits: 6, counter: 0, window: 1 @@ -1963,7 +1956,7 @@ * @type {Secret} */ - this.secret = typeof secret === 'string' ? Secret.fromBase32(secret) : secret; + this.secret = typeof secret === "string" ? Secret.fromBase32(secret) : secret; /** * HMAC hashing algorithm. * @type {string} @@ -2064,7 +2057,7 @@ key: "toString", value: function toString() { var e = encodeURIComponent; - return 'otpauth://totp/' + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "period=".concat(e(this.period)); + return "otpauth://totp/" + "".concat(this.issuer.length > 0 ? "".concat(e(this.issuer), ":").concat(e(this.label), "?issuer=").concat(e(this.issuer), "&") : "".concat(e(this.label), "?")) + "secret=".concat(e(this.secret.base32), "&") + "algorithm=".concat(e(this.algorithm), "&") + "digits=".concat(e(this.digits), "&") + "period=".concat(e(this.period)); } }], [{ key: "defaults", @@ -2082,9 +2075,9 @@ */ function get() { return { - issuer: '', - label: 'OTPAuth', - algorithm: 'SHA1', + issuer: "", + label: "OTPAuth", + algorithm: "SHA1", digits: 6, period: 30, window: 1 @@ -2191,7 +2184,7 @@ } if (!Array.isArray(uriGroups)) { - throw new URIError('Invalid URI format'); + throw new URIError("Invalid URI format"); } // Extract URI groups. @@ -2199,7 +2192,7 @@ var uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent); /** @type {Object.} */ - var uriParams = uriGroups[3].split('&').reduce(function (acc, cur) { + var uriParams = uriGroups[3].split("&").reduce(function (acc, cur) { var pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent); var pairKey = pairArr[0].toLowerCase(); var pairVal = pairArr[1]; @@ -2213,26 +2206,26 @@ var OTP; var config = {}; - if (uriType === 'hotp') { + if (uriType === "hotp") { OTP = HOTP; // Counter: required - if (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) { + if (typeof uriParams.counter !== "undefined" && INTEGER_REGEX.test(uriParams.counter)) { config.counter = parseInt(uriParams.counter, 10); } else { - throw new TypeError('Missing or invalid \'counter\' parameter'); + throw new TypeError("Missing or invalid 'counter' parameter"); } - } else if (uriType === 'totp') { + } else if (uriType === "totp") { OTP = TOTP; // Period: optional - if (typeof uriParams.period !== 'undefined') { + if (typeof uriParams.period !== "undefined") { if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) { config.period = parseInt(uriParams.period, 10); } else { - throw new TypeError('Invalid \'period\' parameter'); + throw new TypeError("Invalid 'period' parameter"); } } } else { - throw new TypeError('Unknown OTP type'); + throw new TypeError("Unknown OTP type"); } // Label: required // Issuer: optional @@ -2240,43 +2233,43 @@ if (uriLabel.length === 2) { config.label = uriLabel[1]; - if (typeof uriParams.issuer === 'undefined') { + if (typeof uriParams.issuer === "undefined") { config.issuer = uriLabel[0]; } else if (uriParams.issuer === uriLabel[0]) { config.issuer = uriParams.issuer; } else { - throw new TypeError('Invalid \'issuer\' parameter'); + throw new TypeError("Invalid 'issuer' parameter"); } } else { config.label = uriLabel[0]; - if (typeof uriParams.issuer !== 'undefined') { + if (typeof uriParams.issuer !== "undefined") { config.issuer = uriParams.issuer; } } // Secret: required - if (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) { + if (typeof uriParams.secret !== "undefined" && SECRET_REGEX.test(uriParams.secret)) { config.secret = uriParams.secret; } else { - throw new TypeError('Missing or invalid \'secret\' parameter'); + throw new TypeError("Missing or invalid 'secret' parameter"); } // Algorithm: optional - if (typeof uriParams.algorithm !== 'undefined') { + if (typeof uriParams.algorithm !== "undefined") { if (ALGORITHM_REGEX.test(uriParams.algorithm)) { config.algorithm = uriParams.algorithm; } else { - throw new TypeError('Invalid \'algorithm\' parameter'); + throw new TypeError("Invalid 'algorithm' parameter"); } } // Digits: optional - if (typeof uriParams.digits !== 'undefined') { + if (typeof uriParams.digits !== "undefined") { if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) { config.digits = parseInt(uriParams.digits, 10); } else { - throw new TypeError('Invalid \'digits\' parameter'); + throw new TypeError("Invalid 'digits' parameter"); } } @@ -2295,7 +2288,7 @@ return otp.toString(); } - throw new TypeError('Invalid \'HOTP/TOTP\' object'); + throw new TypeError("Invalid 'HOTP/TOTP' object"); } }]); @@ -2306,7 +2299,7 @@ * Library version. * @type {string} */ - var version = '7.0.7'; + var version = "7.0.8"; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.umd.min.js b/dist/otpauth.umd.min.js index 3e93594f..3e0dd8e3 100644 --- a/dist/otpauth.umd.min.js +++ b/dist/otpauth.umd.min.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.7 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.8 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! jssha v3.2.0 | (c) Brian Turek | BSD-3-Clause | https://github.com/Caligatio/jsSHA */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).OTPAuth={})}(this,(function(exports){"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=voi ;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r,window:i})}},{key:"toString",value:function(){var e=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"period=".concat(e(this.period))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,period:30,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=t.digits,o=t.period,u=void 0===o?e.defaults.period:o,s=t.timestamp,a=void 0===s?Date.now():s;return HOTP.generate({secret:n,algorithm:r,digits:i,counter:Math.floor(a/1e3/u)})}},{key:"validate",value:function(t){ var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.period,s=void 0===u?e.defaults.period:u,a=t.timestamp,f=void 0===a?Date.now():a,c=t.window;return HOTP.validate({token:n,secret:r,algorithm:i,digits:o,counter:Math.floor(f/1e3/s),window:c})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var n,r=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var n=t.split(/=(.*)/,2).map(decodeURIComponent),r=n[0].toLowerCase(),i=n[1],o=e;return o[r]=i,o}),{}),u={};if("hotp"===r){if(n=HOTP, void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");u.counter=parseInt(o.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");u.period=parseInt(o.period,10)}}if(2===i.length)if(u.label=i[1],void 0===o.issuer)u.issuer=i[0];else{if(o.issuer!==i[0])throw new TypeError("Invalid 'issuer' parameter");u.issuer=o.issuer}else u.label=i[0],void 0!==o.issuer&&(u.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(u.secret=o.secret,void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");u.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter");u.digits=parseInt(o.digits,10)}return new n(u)}},{key:"stringify", -value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.7";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.version=version,Object.defineProperty(exports,"__esModule",{value:!0})})); +value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.8";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.version=version,Object.defineProperty(exports,"__esModule",{value:!0})})); //# sourceMappingURL=otpauth.umd.min.js.map diff --git a/dist/otpauth.umd.min.js.map b/dist/otpauth.umd.min.js.map index 61d4a8e9..bc371dbe 100644 --- a/dist/otpauth.umd.min.js.map +++ b/dist/otpauth.umd.min.js.map @@ -1 +1 @@ -{"version":3,"file":"otpauth.umd.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport { nodeRequire };\n","import jsSHA from 'jssha';\n\nimport { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport { hmacDigest };\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport { pad };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nconst base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n\nexport { base32ToBuf, base32FromBuf };\n","/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nconst hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\nexport { hexToBuf, hexFromBuf };\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nconst latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n\nexport { latin1ToBuf, latin1FromBuf };\n","import { globalThis } from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nconst utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n\nexport { utf8ToBuf, utf8FromBuf };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport { randomBytes };\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport { randomBytes } from './utils/crypto/random-bytes';\n\n/**\n * OTP secret key.\n */\nclass Secret {\n\t/**\n\t * Creates a secret key object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n\nexport { Secret };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from './utils/encoding/uint';\nimport { hmacDigest } from './utils/crypto/hmac-digest';\nimport { pad } from './utils/pad';\nimport { Secret } from './secret';\nimport { timingSafeEqual } from './utils/crypto/timing-safe-equal';\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates an HOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n\nexport { HOTP };\n","import { HOTP } from './hotp';\nimport { Secret } from './secret';\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates a TOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n\nexport { TOTP };\n","import { HOTP } from './hotp';\nimport { TOTP } from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;mYAKA,IAAMA,UAAY,SAACC,WACZC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACR,IAARD,EADmBC,IAEvBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGDJ,GCbFM,EAAS,mEA4Pf,SAASC,EACPL,EACAM,EACAC,EACAC,OAEIL,EAAGM,EAAWC,EAGZC,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAIH,EAAIc,OAAQX,GAAK,EAE/BM,GADAC,EAAaP,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI,KAAK,GAEdJ,EAAOF,IAAcT,EAAIG,IAAO,GAAKU,EAAgBL,GAAgBE,EAAa,UAG7E,CAAEM,MAAOL,EAAQM,OAAqB,EAAbjB,EAAIc,OAAaP,GAAAA,SA6BnCW,EACdC,EACAC,EACAZ,UAIQY,OACD,WAEA,cAEA,8BAIG,IAAIC,MAAM,qDAIZF,OACD,aAOI,SAAUG,EAAaC,EAAwBC,UA7N5D,SACEF,EACAhB,EACAC,EACAC,OAEIL,EAAGN,EAAKY,EAAWC;IAEnB,GAAMY,EAAIR,OAAS,EACrB,MAAM,IAAIO,MAAM,qDAIZV,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAImB,EAAIR,OAAQX,GAAK,EAAG,IAClCN,EAAM4B,SAASH,EAAII,OAAOvB,EAAG,GAAI,IAC5BwB,MAAM9B,GAQT,MAAM,IAAIwB,MAAM,sDANhBZ,GADAC,GAAcP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EAAOlD,OAAS2C,EAAU3C,gBAKI,IAArB2C,EAAUxC,SAA0BqB,aAAa2B,KAAKR,EAAUxC,cAGpE,IAAI/C,UAAU,4CAFpB8F,EAAO/C,OAASwC,EAAUxC,YAMQ,IAAxBwC,EAAUjG,UAA2B,KAC3C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG5B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOC,IAArBiG,EAAUlF,OAAwB,KACxCkE,uBAAuBwB,KAAKR,EAAUlF,cAGnC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAASzE,SAAS2J,EAAUlF,OAAQ,WAMtC,IAAI2E,EAAIc;MAQhB,SAAiBrC,MACZA,aAAed,MAAQc,aAAeG,YAClCH,EAAI9E,iBAGN,IAAIqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.umd.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n const arr = new Uint8Array(buf);\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {\n if (isNode) {\n return NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from \"./utils/encoding/uint.js\";\nimport { hmacDigest } from \"./utils/crypto/hmac-digest.js\";\nimport { pad } from \"./utils/pad.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./utils/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret =\n typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = algorithm.toUpperCase();\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = new Uint8Array(\n hmacDigest(algorithm, secret.buffer, uintToBuf(counter))\n );\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return pad(otp, digits);\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} config.digits Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n for (let i = counter - window; i <= counter + window; ++i) {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret =\n typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = algorithm.toUpperCase();\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm,\n digits,\n period = TOTP.defaults.period,\n timestamp = Date.now(),\n }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} config.digits Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits,\n period = TOTP.defaults.period,\n timestamp = Date.now(),\n window,\n }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta, or null if the token is not found.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX =\n /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n } catch (error) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (\n typeof uriParams.counter !== \"undefined\" &&\n INTEGER_REGEX.test(uriParams.counter)\n ) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof uriParams.issuer === \"undefined\") {\n config.issuer = uriLabel[0];\n } else if (uriParams.issuer === uriLabel[0]) {\n config.issuer = uriParams.issuer;\n } else {\n throw new TypeError(\"Invalid 'issuer' parameter\");\n }\n } else {\n config.label = uriLabel[0];\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n }\n\n // Secret: required\n if (\n typeof uriParams.secret !== \"undefined\" &&\n SECRET_REGEX.test(uriParams.secret)\n ) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","SHA1","SHA224","SHA256","SHA384","SHA512","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;mYAKA,IAAMA,UAAY,SAACC,WACXC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACP,IAARD,EADkBC,IAEtBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGFJ,GCbHM,EAAS,mEA4Pf,SAASC,EACPL,EACAM,EACAC,EACAC,OAEIL,EAAGM,EAAWC,EAGZC,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAIH,EAAIc,OAAQX,GAAK,EAE/BM,GADAC,EAAaP,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI,KAAK,GAEdJ,EAAOF,IAAcT,EAAIG,IAAO,GAAKU,EAAgBL,GAAgBE,EAAa,UAG7E,CAAEM,MAAOL,EAAQM,OAAqB,EAAbjB,EAAIc,OAAaP,GAAAA,SA6BnCW,EACdC,EACAC,EACAZ,UAIQY,OACD,WAEA,cAEA,8BAIG,IAAIC,MAAM,qDAIZF,OACD,aAOI,SAAUG,EAAaC,EAAwBC,UA7N5D,SACEF,EACAhB,EACAC,EACAC,OAEIL,EAAGN,EAAKY,EAAWC;IAEnB,GAAMY,EAAIR,OAAS,EACrB,MAAM,IAAIO,MAAM,qDAIZV,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAImB,EAAIR,OAAQX,GAAK,EAAG,IAClCN,EAAM4B,SAASH,EAAII,OAAOvB,EAAG,GAAI,IAC5BwB,MAAM9B,GAQT,MAAM,IAAIwB,MAAM,sDANhBZ,GADAC,GAAcP,IAAM,GAAK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,EAAS,QACQ,IAArBI,EAAU3C,SACnBkD,EAAOlD,OAAS2C,EAAU3C,gBAMA,IAArB2C,EAAUxC,SACjBqB,aAAa2B,KAAKR,EAAUxC,cAItB,IAAI/C,UAAU,4CAFpB8F,EAAO/C,OAASwC,EAAUxC,YAMO,IAAxBwC,EAAUjG,UAA2B,KAC1C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG3B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOD,IAArBiG,EAAUlF,OAAwB,KACvCkE,uBAAuBwB,KAAKR,EAAUlF,cAGlC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAAS9E,SAASgK,EAAUlF,OAAQ,WAMxC,IAAI2E,EAAIc;MAQjB,SAAiBrC,MACXA,aAAed,MAAQc,aAAeG,YACjCH,EAAInF,iBAGP,IAAI0B,UAAU,uCC9JlBgG,QAAU"} \ No newline at end of file diff --git a/docs/classes/HOTP.html b/docs/classes/HOTP.html index cc7e2914..ccda1dec 100644 --- a/docs/classes/HOTP.html +++ b/docs/classes/HOTP.html @@ -1,47 +1,47 @@ HOTP | otpauth
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HOTP

HOTP: An HMAC-based One-time Password Algorithm. RFC 4226

-

Hierarchy

  • HOTP

Index

Constructors

constructor

  • new HOTP([config]?: undefined | { algorithm: undefined | string; counter: undefined | number; digits: undefined | number; issuer: undefined | string; label: undefined | string; secret: undefined | string | Secret }): HOTP

Hierarchy

  • HOTP

Index

Constructors

constructor

  • new HOTP([config]?: undefined | { algorithm: undefined | string; counter: undefined | number; digits: undefined | number; issuer: undefined | string; label: undefined | string; secret: undefined | string | Secret }): HOTP
  • Creates an HOTP object.

    Parameters

    • [config]: undefined | { algorithm: undefined | string; counter: undefined | number; digits: undefined | number; issuer: undefined | string; label: undefined | string; secret: undefined | string | Secret } = {}

      Configuration options.

      -

    Returns HOTP

Properties

algorithm

algorithm: string
+

Returns HOTP

Properties

algorithm

algorithm: string

HMAC hashing algorithm.

-

counter

counter: number
+

counter

counter: number

Initial counter value.

-

digits

digits: number
+

digits

digits: number

Token length.

-

issuer

issuer: string
+

issuer

issuer: string

Account provider.

-

label

label: string
+

label

label: string

Account label.

-

secret

secret: Secret
+

secret

secret: Secret

Secret key.

-

Accessors

Static defaults

  • get defaults(): { algorithm: string; counter: number; digits: number; issuer: string; label: string; window: number }

Accessors

Static defaults

  • get defaults(): { algorithm: string; counter: number; digits: number; issuer: string; label: string; window: number }
  • Default configuration.

    -

    Returns { algorithm: string; counter: number; digits: number; issuer: string; label: string; window: number }

    • algorithm: string
    • counter: number
    • digits: number
    • issuer: string
    • label: string
    • window: number

Methods

generate

  • generate([config]?: undefined | { counter: undefined | number }): string
  • +

    Returns { algorithm: string; counter: number; digits: number; issuer: string; label: string; window: number }

    • algorithm: string
    • counter: number
    • digits: number
    • issuer: string
    • label: string
    • window: number

Methods

generate

  • generate([config]?: undefined | { counter: undefined | number }): string
  • Generates an HOTP token.

    Parameters

    • [config]: undefined | { counter: undefined | number } = {}

      Configuration options.

    Returns string

    Token.

    -

toString

  • toString(): string

toString

  • toString(): string
  • Returns a Google Authenticator key URI.

    Returns string

    URI.

    -

validate

  • validate(config: { counter: undefined | number; token: string; window: undefined | number }): null | number

validate

  • validate(config: { counter: undefined | number; token: string; window: undefined | number }): null | number
  • Validates an HOTP token.

    Parameters

    • config: { counter: undefined | number; token: string; window: undefined | number }

      Configuration options.

      • counter: undefined | number
      • token: string

        Token value.

      • window: undefined | number

    Returns null | number

    Token delta, or null if the token is not found.

    -

Static generate

  • generate(config: { algorithm: undefined | string; counter: undefined | number; digits: undefined | number; secret: Secret }): string

Static generate

  • generate(config: { algorithm: undefined | string; counter: undefined | number; digits: undefined | number; secret: Secret }): string
  • Generates an HOTP token.

    Parameters

    • config: { algorithm: undefined | string; counter: undefined | number; digits: undefined | number; secret: Secret }

      Configuration options.

      • algorithm: undefined | string
      • counter: undefined | number
      • digits: undefined | number
      • secret: Secret

        Secret key.

    Returns string

    Token.

    -

Static validate

  • validate(config: { algorithm: undefined | string; counter: undefined | number; digits: number; secret: Secret; token: string; window: undefined | number }): null | number

Static validate

  • validate(config: { algorithm: undefined | string; counter: undefined | number; digits: number; secret: Secret; token: string; window: undefined | number }): null | number
  • Validates an HOTP token.

    Parameters

    • config: { algorithm: undefined | string; counter: undefined | number; digits: number; secret: Secret; token: string; window: undefined | number }

      Configuration options.

      diff --git a/docs/classes/Secret.html b/docs/classes/Secret.html index db0b7bf3..9c3ccce7 100644 --- a/docs/classes/Secret.html +++ b/docs/classes/Secret.html @@ -1,35 +1,35 @@ Secret | otpauth
      Options
      All
      • Public
      • Public/Protected
      • All
      Menu

      Class Secret

      OTP secret key.

      -

      Hierarchy

      • Secret

      Index

      Constructors

      constructor

      • new Secret([config]?: undefined | { buffer: undefined | ArrayBuffer; size: undefined | number }): Secret

      Hierarchy

      • Secret

      Index

      Constructors

      constructor

      • new Secret([config]?: undefined | { buffer: undefined | ArrayBuffer; size: undefined | number }): Secret
      • Creates a secret key object.

        Parameters

        • [config]: undefined | { buffer: undefined | ArrayBuffer; size: undefined | number } = {}

          Configuration options.

          -

        Returns Secret

      Properties

      buffer

      buffer: ArrayBuffer
      +

    Returns Secret

Properties

buffer

buffer: ArrayBuffer

Secret key.

-

Accessors

base32

  • get base32(): string

Accessors

base32

  • get base32(): string
  • Base32 string representation of secret key.

    -

    Returns string

hex

  • get hex(): string

hex

  • get hex(): string
  • Hexadecimal string representation of secret key.

    -

    Returns string

latin1

  • get latin1(): string

latin1

  • get latin1(): string
  • Latin-1 string representation of secret key.

    -

    Returns string

utf8

  • get utf8(): string

utf8

  • get utf8(): string
  • UTF-8 string representation of secret key.

    -

    Returns string

Methods

Static fromBase32

  • fromBase32(str: string): Secret

Methods

Static fromBase32

  • fromBase32(str: string): Secret
  • Converts a base32 string to a Secret object.

    Parameters

    • str: string

      Base32 string.

    Returns Secret

    Secret object.

    -

Static fromHex

Static fromHex

  • Converts a hexadecimal string to a Secret object.

    Parameters

    • str: string

      Hexadecimal string.

    Returns Secret

    Secret object.

    -

Static fromLatin1

  • fromLatin1(str: string): Secret

Static fromLatin1

  • fromLatin1(str: string): Secret
  • Converts a Latin-1 string to a Secret object.

    Parameters

    • str: string

      Latin-1 string.

    Returns Secret

    Secret object.

    -

Static fromUTF8

Static fromUTF8

  • Converts an UTF-8 string to a Secret object.

    Parameters

    • str: string

      UTF-8 string.

      diff --git a/docs/classes/TOTP.html b/docs/classes/TOTP.html index 34918b2a..b8b0a0be 100644 --- a/docs/classes/TOTP.html +++ b/docs/classes/TOTP.html @@ -1,47 +1,47 @@ TOTP | otpauth
      Options
      All
      • Public
      • Public/Protected
      • All
      Menu

      Class TOTP

      TOTP: Time-Based One-Time Password Algorithm. RFC 6238

      -

      Hierarchy

      • TOTP

      Index

      Constructors

      constructor

      • new TOTP([config]?: undefined | { algorithm: undefined | string; digits: undefined | number; issuer: undefined | string; label: undefined | string; period: undefined | number; secret: undefined | string | Secret }): TOTP

      Hierarchy

      • TOTP

      Index

      Constructors

      constructor

      • new TOTP([config]?: undefined | { algorithm: undefined | string; digits: undefined | number; issuer: undefined | string; label: undefined | string; period: undefined | number; secret: undefined | string | Secret }): TOTP
      • Creates a TOTP object.

        Parameters

        • [config]: undefined | { algorithm: undefined | string; digits: undefined | number; issuer: undefined | string; label: undefined | string; period: undefined | number; secret: undefined | string | Secret } = {}

          Configuration options.

          -

        Returns TOTP

      Properties

      algorithm

      algorithm: string
      +

    Returns TOTP

Properties

algorithm

algorithm: string

HMAC hashing algorithm.

-

digits

digits: number
+

digits

digits: number

Token length.

-

issuer

issuer: string
+

issuer

issuer: string

Account provider.

-

label

label: string
+

label

label: string

Account label.

-

period

period: number
+

period

period: number

Token time-step duration.

-

secret

secret: Secret
+

secret

secret: Secret

Secret key.

-

Accessors

Static defaults

  • get defaults(): { algorithm: string; digits: number; issuer: string; label: string; period: number; window: number }

Accessors

Static defaults

  • get defaults(): { algorithm: string; digits: number; issuer: string; label: string; period: number; window: number }
  • Default configuration.

    -

    Returns { algorithm: string; digits: number; issuer: string; label: string; period: number; window: number }

    • algorithm: string
    • digits: number
    • issuer: string
    • label: string
    • period: number
    • window: number

Methods

generate

  • generate([config]?: undefined | { timestamp: undefined | number }): string
  • +

    Returns { algorithm: string; digits: number; issuer: string; label: string; period: number; window: number }

    • algorithm: string
    • digits: number
    • issuer: string
    • label: string
    • period: number
    • window: number

Methods

generate

  • generate([config]?: undefined | { timestamp: undefined | number }): string
  • Generates a TOTP token.

    Parameters

    • [config]: undefined | { timestamp: undefined | number } = {}

      Configuration options.

    Returns string

    Token.

    -

toString

  • toString(): string

toString

  • toString(): string
  • Returns a Google Authenticator key URI.

    Returns string

    URI.

    -

validate

  • validate(config: { timestamp: undefined | number; token: string; window: undefined | number }): null | number

validate

  • validate(config: { timestamp: undefined | number; token: string; window: undefined | number }): null | number
  • Validates a TOTP token.

    Parameters

    • config: { timestamp: undefined | number; token: string; window: undefined | number }

      Configuration options.

      • timestamp: undefined | number
      • token: string

        Token value.

      • window: undefined | number

    Returns null | number

    Token delta, or null if the token is not found.

    -

Static generate

  • generate(config: { algorithm: undefined | string; digits: undefined | number; period: undefined | number; secret: Secret; timestamp: undefined | number }): string

Static generate

  • generate(config: { algorithm: undefined | string; digits: undefined | number; period: undefined | number; secret: Secret; timestamp: undefined | number }): string
  • Generates a TOTP token.

    Parameters

    • config: { algorithm: undefined | string; digits: undefined | number; period: undefined | number; secret: Secret; timestamp: undefined | number }

      Configuration options.

      • algorithm: undefined | string
      • digits: undefined | number
      • period: undefined | number
      • secret: Secret

        Secret key.

      • timestamp: undefined | number

    Returns string

    Token.

    -

Static validate

  • validate(config: { algorithm: undefined | string; digits: number; period: undefined | number; secret: Secret; timestamp: undefined | number; token: string; window: undefined | number }): null | number

Static validate

  • validate(config: { algorithm: undefined | string; digits: number; period: undefined | number; secret: Secret; timestamp: undefined | number; token: string; window: undefined | number }): null | number
  • Validates a TOTP token.

    Parameters

    • config: { algorithm: undefined | string; digits: number; period: undefined | number; secret: Secret; timestamp: undefined | number; token: string; window: undefined | number }

      Configuration options.

      diff --git a/docs/classes/URI.html b/docs/classes/URI.html index 50961268..1ad69853 100644 --- a/docs/classes/URI.html +++ b/docs/classes/URI.html @@ -1,12 +1,12 @@ URI | otpauth
      Options
      All
      • Public
      • Public/Protected
      • All
      Menu

      Class URI

      HOTP/TOTP object/string conversion. Key URI Format

      -

      Hierarchy

      • URI

      Index

      Constructors

      Methods

      Constructors

      constructor

      Methods

      Static parse

      Hierarchy

      • URI

      Index

      Constructors

      Methods

      Constructors

      constructor

      Methods

      Static parse

      • Parses a Google Authenticator key URI and returns an HOTP/TOTP object.

        Parameters

        • uri: string

          Google Authenticator Key URI.

        Returns HOTP | TOTP

        HOTP/TOTP object.

        -

      Static stringify

      Static stringify

      • Converts an HOTP/TOTP object to a Google Authenticator key URI.

        Parameters

        • otp: HOTP | TOTP

          HOTP/TOTP object.

          diff --git a/docs/modules.html b/docs/modules.html index c8bb9e60..956440a6 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,3 +1,3 @@ -otpauth
          Options
          All
          • Public
          • Public/Protected
          • All
          Menu

          otpauth

          Index

          Classes

          Variables

          Variables

          version

          version: string = '__OTPAUTH_VERSION__'
          +otpauth
          Options
          All
          • Public
          • Public/Protected
          • All
          Menu

          otpauth

          Index

          Classes

          Variables

          Variables

          version

          version: string = "__OTPAUTH_VERSION__"

          Library version.

          Legend

          • Constructor
          • Property
          • Method
          • Static method

          Settings

          Theme

          Generated using TypeDoc

          \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d83713e4..eab229b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "otpauth", - "version": "7.0.7", + "version": "7.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "otpauth", - "version": "7.0.7", + "version": "7.0.8", "license": "MIT", "dependencies": { "jssha": "~3.2.0" diff --git a/package.json b/package.json index 17284756..dcddefbb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "otpauth", - "version": "7.0.7", + "version": "7.0.8", "description": "One Time Password (HOTP/TOTP) library for Node.js, Deno and browsers", "keywords": [ "otp", diff --git a/types/hotp.d.ts b/types/hotp.d.ts index 0f993f08..a2285517 100644 --- a/types/hotp.d.ts +++ b/types/hotp.d.ts @@ -110,7 +110,7 @@ export class HOTP { * @param {number} [config.counter=this.counter++] Counter value. * @returns {string} Token. */ - generate({ counter, }?: { + generate({ counter }?: { counter?: number | undefined; } | undefined): string; /** @@ -121,7 +121,7 @@ export class HOTP { * @param {number} [config.window=1] Window of counter values to test. * @returns {number|null} Token delta, or null if the token is not found. */ - validate({ token, counter, window, }: { + validate({ token, counter, window }: { token: string; counter?: number | undefined; window?: number | undefined; @@ -132,4 +132,4 @@ export class HOTP { */ toString(): string; } -import { Secret } from "./secret"; +import { Secret } from "./secret.js"; diff --git a/types/index.d.ts b/types/index.d.ts index 9c43b728..247add82 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,6 +1,6 @@ -import { HOTP } from "./hotp"; -import { TOTP } from "./totp"; -import { URI } from "./uri"; -import { Secret } from "./secret"; -import { version } from "./version"; +import { HOTP } from "./hotp.js"; +import { TOTP } from "./totp.js"; +import { URI } from "./uri.js"; +import { Secret } from "./secret.js"; +import { version } from "./version.js"; export { HOTP, TOTP, URI, Secret, version }; diff --git a/types/totp.d.ts b/types/totp.d.ts index 8ec3b32e..7ffc49d7 100644 --- a/types/totp.d.ts +++ b/types/totp.d.ts @@ -114,7 +114,7 @@ export class TOTP { * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds. * @returns {string} Token. */ - generate({ timestamp, }?: { + generate({ timestamp }?: { timestamp?: number | undefined; } | undefined): string; /** @@ -125,7 +125,7 @@ export class TOTP { * @param {number} [config.window=1] Window of counter values to test. * @returns {number|null} Token delta, or null if the token is not found. */ - validate({ token, timestamp, window, }: { + validate({ token, timestamp, window }: { token: string; timestamp?: number | undefined; window?: number | undefined; @@ -136,4 +136,4 @@ export class TOTP { */ toString(): string; } -import { Secret } from "./secret"; +import { Secret } from "./secret.js"; diff --git a/types/uri.d.ts b/types/uri.d.ts index 1617f096..ded2017e 100644 --- a/types/uri.d.ts +++ b/types/uri.d.ts @@ -16,5 +16,5 @@ export class URI { */ static stringify(otp: HOTP | TOTP): string; } -import { HOTP } from "./hotp"; -import { TOTP } from "./totp"; +import { HOTP } from "./hotp.js"; +import { TOTP } from "./totp.js"; diff --git a/types/utils/global-this.d.ts b/types/utils/global-this.d.ts index a7c7469d..052ac4a6 100644 --- a/types/utils/global-this.d.ts +++ b/types/utils/global-this.d.ts @@ -2,7 +2,7 @@ * "globalThis" ponyfill. * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} -*/ + */ export const globalThis: { [x: string]: any; };