diff --git a/dist/otpauth.cjs.js b/dist/otpauth.cjs.js index 8c95b60a..5640c2fb 100644 --- a/dist/otpauth.cjs.js +++ b/dist/otpauth.cjs.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.10 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.11 | (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'; @@ -2297,7 +2297,7 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = "7.0.10"; +var version = "7.0.11"; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.cjs.min.js b/dist/otpauth.cjs.min.js index 2504fcd9..097c83b1 100644 --- a/dist/otpauth.cjs.min.js +++ b/dist/otpauth.cjs.min.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.10 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.11 | (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.~_-]+=[^?&]*(?:&[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.10";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.11";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 0b1a70d3..6083c776 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 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.~_-]+=[^?&]*(?:&[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":";;;;gQAKA,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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AAU,0CAFpB8F,EAAO9C,QAAUzH,SAASgK,EAAUvC,QAAS,QAI1C,CAAA,GAAgB,SAAZiC,QAYH,IAAIjF,UAAU,uBAXpBgF,EAAMpB,UAG0B,IAArB2B,EAAU1B,OAAwB,KACvCU,uBAAuBwB,KAAKR,EAAU1B,cAGlC,IAAI7D,UAAU,8BAFpB8F,EAAOjC,OAAStI,SAASgK,EAAU1B,OAAQ,QAWzB,IAApBsB,EAASvK,UACXkL,EAAOhD,MAAQqC,EAAS,QACQ,IAArBI,EAAU3C,OACnBkD,EAAOlD,OAASuC,EAAS,OACpB,CAAA,GAAII,EAAU3C,SAAWuC,EAAS,SAGjC,IAAInF,UAAU,8BAFpB8F,EAAOlD,OAAS2C,EAAU3C,YAK5BkD,EAAOhD,MAAQqC,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 +{"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.~_-]+=[^?&]*(?:&[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","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","value","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":";;;;gQAKA,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,KADaN,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI,KAAK,GAEdJ,EAAOF,IAAcT,EAAIG,IAAO,GAAKU,EAAgBL,GAAgBE,EAAa,UAG7E,OAASC,SAA6B,EAAbX,EAAIc,OAAaP,GAA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I,SAASiK,EAAU1B,OAAQ,QAWzB,IAApBsB,EAAStK,UACXiL,EAAOhD,MAAQqC,EAAS,QACQ,IAArBI,EAAU3C,OACnBkD,EAAOlD,OAASuC,EAAS,OACpB,CAAA,GAAII,EAAU3C,SAAWuC,EAAS,SAGjC,IAAIpF,UAAU,8BAFpB+F,EAAOlD,OAAS2C,EAAU3C,YAK5BkD,EAAOhD,MAAQqC,EAAS,QACQ,IAArBI,EAAU3C,SACnBkD,EAAOlD,OAAS2C,EAAU3C,gBAMA,IAArB2C,EAAUxC,SACjBqB,aAAa2B,KAAKR,EAAUxC,cAItB,IAAIhD,UAAU,4CAFpB+F,EAAO/C,OAASwC,EAAUxC,YAMO,IAAxBwC,EAAUlG,UAA2B,KAC1CgF,gBAAgB0B,KAAKR,EAAUlG,iBAG3B,IAAIU,UAAU,iCAFpB+F,EAAOzG,UAAYkG,EAAUlG,kBAOD,IAArBkG,EAAUnF,OAAwB,KACvCmE,uBAAuBwB,KAAKR,EAAUnF,cAGlC,IAAIL,UAAU,8BAFpB+F,EAAO1F,OAAS9E,SAASiK,EAAUnF,OAAQ,WAMxC,IAAI4E,EAAIc;MAQjB,SAAiBrC,MACXA,aAAed,MAAQc,aAAeG,YACjCH,EAAIpF,iBAGP,IAAI0B,UAAU,uCC9JlBiG,QAAU"} \ No newline at end of file diff --git a/dist/otpauth.esm.js b/dist/otpauth.esm.js index 4507a185..cea79602 100644 --- a/dist/otpauth.esm.js +++ b/dist/otpauth.esm.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.10 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.11 | (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) { @@ -2293,6 +2293,6 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = "7.0.10"; +var version = "7.0.11"; export { HOTP, Secret, TOTP, URI, version }; diff --git a/dist/otpauth.esm.min.js b/dist/otpauth.esm.min.js index 4b309707..bc5820a9 100644 --- a/dist/otpauth.esm.min.js +++ b/dist/otpauth.esm.min.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.10 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.11 | (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 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.~_-]+=[^?&]*(?:&[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.10";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.11";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 5fb5bc16..f080ef03 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 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.~_-]+=[^?&]*(?:&[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","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U3C,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 +{"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.~_-]+=[^?&]*(?:&[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","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","value","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":";;;;sLAKA,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,KADaN,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI,KAAK,GAEdJ,EAAOF,IAAcT,EAAIG,IAAO,GAAKU,EAAgBL,GAAgBE,EAAa,UAG7E,OAASC,SAA6B,EAAbX,EAAIc,OAAaP,GAAAA,SA6BnCS,EACdC,EACAC,EACAV,UAIQU,OACD,WAEA,cAEA,8BAIG,IAAIC,MAAM,qDAIZF,OACD,aAOI,SAAUG,EAAaC,EAAwBC,UA7N5D,SACEF,EACAd,EACAC,EACAC,OAEIL,EAAGN,EAAKY,EAAWC,KAEnB,GAAMU,EAAIN,OAAS,EACrB,MAAM,IAAIK,MAAM,qDAIZR,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAIiB,EAAIN,OAAQX,GAAK,EAAG,IAClCN,EAAM0B,SAASH,EAAII,OAAOrB,EAAG,GAAI;AAC5BsB,MAAM5B,GAQT,MAAM,IAAIsB,MAAM,sDANhBV,GADAC,GAAcP,IAAM,GA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AAU,iCAFpB+F,EAAOzG,UAAYkG,EAAUlG,kBAOD,IAArBkG,EAAUnF,OAAwB,KACvCmE,uBAAuBwB,KAAKR,EAAUnF,cAGlC,IAAIL,UAAU,8BAFpB+F,EAAO1F,OAAS9E,SAASiK,EAAUnF,OAAQ,WAMxC,IAAI4E,EAAIc;MAQjB,SAAiBrC,MACXA,aAAed,MAAQc,aAAeG,YACjCH,EAAIpF,iBAGP,IAAI0B,UAAU,uCC9JlBiG,QAAU"} \ No newline at end of file diff --git a/dist/otpauth.umd.js b/dist/otpauth.umd.js index abbb7e1d..a174cc96 100644 --- a/dist/otpauth.umd.js +++ b/dist/otpauth.umd.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.10 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.11 | (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) { @@ -2299,7 +2299,7 @@ * Library version. * @type {string} */ - var version = "7.0.10"; + var version = "7.0.11"; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.umd.min.js b/dist/otpauth.umd.min.js index 346fccf0..65c04610 100644 --- a/dist/otpauth.umd.min.js +++ b/dist/otpauth.umd.min.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.10 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.11 | (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 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.~_-]+=[^?&]*(?:&[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.10";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.11";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 6d1e1dc1..5a9f8cc0 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 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.~_-]+=[^?&]*(?:&[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":";;;;qeAKA,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,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,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 +{"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.~_-]+=[^?&]*(?:&[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","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","value","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":";;;;qeAKA,IAAMA,UAAY,SAACC,WACXC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACP,IAARD,EADkBC,IAEtBH,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,iBAGP,IAAI0B,UAAU,uCC9JlBiG,QAAU"} \ No newline at end of file diff --git a/docs/classes/HOTP.html b/docs/classes/HOTP.html index 1b0af807..1b26835f 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

  • 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

  • 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: string
+

Returns HOTP

Properties

algorithm: string

HMAC hashing algorithm.

-
counter: number
+
counter: number

Initial counter value.

-
digits: number
+
digits: number

Token length.

-
issuer: string
+
issuer: string

Account provider.

-
label: string
+
label: string

Account label.

-
secret: Secret
+
secret: Secret

Secret key.

-

Accessors

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

Accessors

  • 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([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([config]?: undefined | { counter: undefined | number }): string
  • Generates an HOTP token.

    Parameters

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

      Configuration options.

    Returns string

    Token.

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

    Returns string

    URI.

    -
  • validate(config: { counter: undefined | number; token: string; window: undefined | number }): null | number
  • 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.

    -
  • generate(config: { algorithm: undefined | string; counter: undefined | number; digits: undefined | number; secret: Secret }): string
  • 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.

    -
  • validate(config: { algorithm: undefined | string; counter: undefined | number; digits: number; secret: Secret; token: string; window: undefined | number }): null | number
  • 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 0e50a539..1af20ab3 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

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

      Hierarchy

      • Secret

      Index

      Constructors

      • 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: ArrayBuffer
      +

    Returns Secret

Properties

buffer: ArrayBuffer

Secret key.

-

Accessors

  • get base32(): string

Accessors

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

    -

    Returns string

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

    -

    Returns string

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

    -

    Returns string

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

    -

    Returns string

Methods

  • fromBase32(str: string): Secret

Methods

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

    Parameters

    • str: string

      Base32 string.

    Returns Secret

    Secret object.

    -
  • Converts a hexadecimal string to a Secret object.

    Parameters

    • str: string

      Hexadecimal string.

    Returns Secret

    Secret object.

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

    Parameters

    • str: string

      Latin-1 string.

    Returns Secret

    Secret object.

    -
  • 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 645b4963..10801b5e 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

      • 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

      • 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: string
      +

    Returns TOTP

Properties

algorithm: string

HMAC hashing algorithm.

-
digits: number
+
digits: number

Token length.

-
issuer: string
+
issuer: string

Account provider.

-
label: string
+
label: string

Account label.

-
period: number
+
period: number

Token time-step duration.

-
secret: Secret
+
secret: Secret

Secret key.

-

Accessors

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

Accessors

  • 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([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([config]?: undefined | { timestamp: undefined | number }): string
  • Generates a TOTP token.

    Parameters

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

      Configuration options.

    Returns string

    Token.

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

    Returns string

    URI.

    -
  • validate(config: { timestamp: undefined | number; token: string; window: undefined | number }): null | number
  • 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.

    -
  • generate(config: { algorithm: undefined | string; digits: undefined | number; period: undefined | number; secret: Secret; timestamp: undefined | number }): string
  • 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.

    -
  • validate(config: { algorithm: undefined | string; digits: number; period: undefined | number; secret: Secret; timestamp: undefined | number; token: string; window: undefined | number }): null | number
  • 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 391d14fe..6860c76e 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

      Methods

      Hierarchy

      • URI

      Index

      Constructors

      Methods

      Constructors

      Methods

      • 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.

        -
      • 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 0eb05f7e..bddd6e76 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: string = "__OTPAUTH_VERSION__"
          +otpauth
          Options
          All
          • Public
          • Public/Protected
          • All
          Menu

          otpauth

          Index

          Classes

          Variables

          Variables

          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 d0e1f9f1..6eef84b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "otpauth", - "version": "7.0.10", + "version": "7.0.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "otpauth", - "version": "7.0.10", + "version": "7.0.11", "license": "MIT", "dependencies": { "jssha": "~3.2.0" diff --git a/package.json b/package.json index 21d009af..ee97af76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "otpauth", - "version": "7.0.10", + "version": "7.0.11", "description": "One Time Password (HOTP/TOTP) library for Node.js, Deno and browsers", "keywords": [ "otp",