From 9d84ac789da77cd85bd374e81c3a930e19fbc759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Molinero=20Fern=C3=A1ndez?= Date: Sat, 24 Apr 2021 01:17:46 +0200 Subject: [PATCH] 7.0.1 --- dist/otpauth.cjs.js | 112 +++++++++++----------- dist/otpauth.cjs.min.js | 46 ++++----- dist/otpauth.cjs.min.js.map | 2 +- dist/otpauth.d.ts | 22 +++-- dist/otpauth.esm.js | 112 +++++++++++----------- dist/otpauth.esm.min.js | 46 ++++----- dist/otpauth.esm.min.js.map | 2 +- dist/otpauth.umd.js | 112 +++++++++++----------- dist/otpauth.umd.min.js | 36 +++---- dist/otpauth.umd.min.js.map | 2 +- docs/classes/hotp.html | 25 +++-- docs/classes/secret.html | 27 ++++-- docs/classes/totp.html | 25 +++-- docs/classes/uri.html | 4 +- docs/index.html | 2 +- docs/modules.html | 2 +- package-lock.json | 4 +- package.json | 2 +- types/hotp.d.ts | 12 ++- types/index.d.ts | 10 +- types/secret.d.ts | 8 +- types/totp.d.ts | 12 ++- types/uri.d.ts | 6 +- types/utils/console.d.ts | 3 +- types/utils/crypto/hmac-digest.d.ts | 3 +- types/utils/crypto/random-bytes.d.ts | 3 +- types/utils/crypto/timing-safe-equal.d.ts | 3 +- types/utils/encoding/base32.d.ts | 12 +++ types/utils/encoding/hex.d.ts | 12 ++- types/utils/encoding/latin1.d.ts | 10 ++ types/utils/encoding/uint.d.ts | 10 ++ types/utils/encoding/utf8.d.ts | 10 ++ types/utils/global-this.d.ts | 3 +- types/utils/is-node.d.ts | 3 +- types/utils/node-require.d.ts | 3 +- types/utils/pad.d.ts | 3 +- types/version.d.ts | 3 +- 37 files changed, 400 insertions(+), 312 deletions(-) diff --git a/dist/otpauth.cjs.js b/dist/otpauth.cjs.js index 8a54da9b..fee154b6 100644 --- a/dist/otpauth.cjs.js +++ b/dist/otpauth.cjs.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.1 | (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'; @@ -1212,14 +1212,11 @@ var _default = /*#__PURE__*/function () { * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} */ -var magicalGlobalThis = function () { - /* eslint-disable no-extend-native, no-undef, no-restricted-globals */ - var magic; - - if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === 'object') { - magic = globalThis; - } else { - Object.defineProperty(Object.prototype, '__OTPAUTH_GLOBALTHIS__', { +var globalThis = function () { + // @ts-ignore + if (_typeof(globalThis) === 'object') return globalThis;else { + // eslint-disable-next-line no-extend-native + Object.defineProperty(Object.prototype, '__GLOBALTHIS__', { get: function get() { return this; }, @@ -1228,26 +1225,20 @@ var magicalGlobalThis = function () { try { // @ts-ignore - magic = __OTPAUTH_GLOBALTHIS__; + // eslint-disable-next-line no-undef + if (typeof __GLOBALTHIS__ !== 'undefined') return __GLOBALTHIS__; } finally { // @ts-ignore - delete Object.prototype.__OTPAUTH_GLOBALTHIS__; + delete Object.prototype.__GLOBALTHIS__; } - } + } // Still unable to determine "globalThis", fall back to a naive method. - if (typeof magic === 'undefined') { - // Still unable to determine "globalThis", fall back to a naive method. - if (typeof self !== 'undefined') { - magic = self; - } else if (typeof window !== 'undefined') { - magic = window; - } else if (typeof global !== 'undefined') { - magic = global; - } - } + /* eslint-disable no-undef, no-restricted-globals */ - return magic; + if (typeof self !== 'undefined') return self;else if (typeof window !== 'undefined') return window;else if (typeof global !== 'undefined') return global; /* eslint-enable */ + + return undefined; }(); /** @@ -1255,7 +1246,7 @@ var magicalGlobalThis = function () { * @type {boolean} */ -var isNode = Object.prototype.toString.call(magicalGlobalThis.process) === '[object process]'; +var isNode = Object.prototype.toString.call(globalThis.process) === '[object process]'; /** * Dynamically import Node.js modules ("eval" is used to prevent bundlers from including the module). @@ -1267,7 +1258,7 @@ var isNode = Object.prototype.toString.call(magicalGlobalThis.process) === '[obj var nodeRequire = isNode // eslint-disable-next-line no-eval ? eval('require') : function () {}; -var NodeBuffer$1 = isNode ? magicalGlobalThis.Buffer : undefined; +var NodeBuffer$1 = isNode ? globalThis.Buffer : undefined; var NodeCrypto$2 = isNode ? nodeRequire('crypto') : undefined; /** * OpenSSL to jsSHA algorithms. @@ -1377,6 +1368,7 @@ var base32ToBuf = function base32ToBuf(str) { * @returns {string} Base32 string. */ + var base32FromBuf = function base32FromBuf(buf) { var arr = new Uint8Array(buf); var bits = 0; @@ -1400,11 +1392,28 @@ var base32FromBuf = function base32FromBuf(buf) { return str; }; +/** + * Converts a hexadecimal string to an ArrayBuffer. + * @param {string} str Hexadecimal string. + * @returns {ArrayBuffer} ArrayBuffer. + */ +var hexToBuf = function hexToBuf(str) { + var buf = new ArrayBuffer(str.length / 2); + var arr = new Uint8Array(buf); + + for (var i = 0; i < str.length; i += 2) { + arr[i / 2] = parseInt(str.substr(i, 2), 16); + } + + return buf; +}; /** * Converts an ArrayBuffer to a hexadecimal string. * @param {ArrayBuffer} buf ArrayBuffer. * @returns {string} Hexadecimal string. */ + + var hexFromBuf = function hexFromBuf(buf) { var arr = new Uint8Array(buf); var str = ''; @@ -1417,22 +1426,6 @@ var hexFromBuf = function hexFromBuf(buf) { return str.toUpperCase(); }; -/** - * Converts a hexadecimal string to an ArrayBuffer. - * @param {string} str Hexadecimal string. - * @returns {ArrayBuffer} ArrayBuffer. - */ - -var hexToBuf = function hexToBuf(str) { - var buf = new ArrayBuffer(str.length / 2); - var arr = new Uint8Array(buf); - - for (var i = 0; i < str.length; i += 2) { - arr[i / 2] = parseInt(str.substr(i, 2), 16); - } - - return buf; -}; /** * Converts a Latin-1 string to an ArrayBuffer. @@ -1455,6 +1448,7 @@ var latin1ToBuf = function latin1ToBuf(str) { * @returns {string} Latin-1 string. */ + var latin1FromBuf = function latin1FromBuf(buf) { var arr = new Uint8Array(buf); var str = ''; @@ -1471,13 +1465,13 @@ var latin1FromBuf = function latin1FromBuf(buf) { * @type {TextEncoder|null} */ -var ENCODER = magicalGlobalThis.TextEncoder ? new magicalGlobalThis.TextEncoder('utf-8') : null; +var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder('utf-8') : null; /** * TextDecoder instance. * @type {TextDecoder|null} */ -var DECODER = magicalGlobalThis.TextDecoder ? new magicalGlobalThis.TextDecoder('utf-8') : null; +var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : null; /** * Converts an UTF-8 string to an ArrayBuffer. * @param {string} str String. @@ -1497,6 +1491,7 @@ var utf8ToBuf = function utf8ToBuf(str) { * @returns {string} String. */ + var utf8FromBuf = function utf8FromBuf(buf) { if (!DECODER) { throw new Error('Encoding API not available'); @@ -1506,7 +1501,7 @@ var utf8FromBuf = function utf8FromBuf(buf) { }; var NodeCrypto$1 = isNode ? nodeRequire('crypto') : undefined; -var BrowserCrypto = !isNode ? magicalGlobalThis.crypto || magicalGlobalThis.msCrypto : undefined; +var BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined; /** * Returns random bytes. * @param {number} size Size. @@ -1525,10 +1520,13 @@ var randomBytes = function randomBytes(size) { } }; +/** + * OTP secret key. + */ + var Secret = /*#__PURE__*/function () { /** - * Secret key object. - * @constructor + * Creates a secret key object. * @param {Object} [config] Configuration options. * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key. * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided. @@ -1661,7 +1659,7 @@ var Secret = /*#__PURE__*/function () { return Secret; }(); -var NodeBuffer = isNode ? magicalGlobalThis.Buffer : undefined; +var NodeBuffer = isNode ? globalThis.Buffer : undefined; var NodeCrypto = isNode ? nodeRequire('crypto') : undefined; /** * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values. @@ -1689,11 +1687,14 @@ var timingSafeEqual = function timingSafeEqual(a, b) { } }; +/** + * HOTP: An HMAC-based One-time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} + */ + var HOTP = /*#__PURE__*/function () { /** - * HOTP: An HMAC-based One-time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} - * @constructor + * Creates an HOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -1909,11 +1910,14 @@ var HOTP = /*#__PURE__*/function () { return HOTP; }(); +/** + * TOTP: Time-Based One-Time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} + */ + var TOTP = /*#__PURE__*/function () { /** - * TOTP: Time-Based One-Time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} - * @constructor + * Creates a TOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -2298,7 +2302,7 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = '7.0.0'; +var version = '7.0.1'; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.cjs.min.js b/dist/otpauth.cjs.min.js index 69daf3e9..23a3ba36 100644 --- a/dist/otpauth.cjs.min.js +++ b/dist/otpauth.cjs.min.js @@ -1,39 +1,39 @@ -/*! otpauth v7.0.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.1 | (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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n=0&&0!==r;i--)n[i]=255&r,r-=n[i],r/=256;return t},t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function n(e,t,n,r){var i,o,u,a=t||[0],s=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i>>2,a.length<=o&&a.push(0),a[o]|=e[i]<<8*(c+r*(u%4));return{value:a,binLen:8*e.length+n}}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(e,t,n){return function(e,t,n,r){var i,o,u,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");var s=t||[0],c=(n=n||0)>>>3,f=-1===r?3:0;for(i=0;i>>1)+c)>>>2;s.length<=u;)s.push(0);s[u]|=o<<8*(f+r*(a%4))}return{value:s,binLen:4*e.length+n}}(e,t,n,i)};case"TEXT": -return function(e,t,n){return function(e,t,n,r,i){var o,u,a,s,c,f,l,h,w=0,p=n||[0],d=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a(o=e.charCodeAt(a))?u.push(o):2048>o?(u.push(192|o>>>6),u.push(128|63&o)):55296>o||57344<=o?u.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(a)),u.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;p.length<=c;)p.push(0);p[c]|=u[s]<<8*(l+i*(f%4)),w+=1}else for(l=-1===i?2:0,h="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a>>8),c=(f=w+d)>>>2;p.length<=c;)p.push(0);p[c]|=o<<8*(l+i*(f%4)),w+=2}return{value:p,binLen:8*w+r}}(e,r,t,n,i)};case"B64":return function(e,n,r){return function(e,n,r,i){var o,u,a,s,c,f,l=0,h=n||[0],w=(r=r||0)>>>3,p=-1===i?3:0,d=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""), --1!==d&&d>>2;l.length<=f;)l.push(0);l[f]|=(a>>>16-8*u&255)<<8*(p+i*(c%4)),h+=1}}return{value:l,binLen:8*h+r}}(e,n,r,i)};case"BYTES":return function(e,t,n){return function(e,t,n,r){var i,o,u,a,s=t||[0],f=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o>>2,s.length<=u&&s.push(0),s[u]|=i<<8*(c+r*(a%4));return{value:s,binLen:8*e.length+n}}(e,t,n,i)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,r,i){return n(new Uint8Array(e),t,r,i)}(e,t,r,i)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return n(e,t,r,i)};default: +throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function r(e,n,r,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){var i,o,u="",a=t/8,s=-1===n?3:0;for(i=0;i>>2]>>>8*(s+n*(i%4)),u+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?u.toUpperCase():u}(e,n,r,i)};case"B64":return function(e){return function(e,n,r,i){var o,u,a,s,f,c="",h=n/8,l=-1===r?3:0;for(o=0;o>>2]:0,f=o+2>>2]:0,a=(e[o>>>2]>>>8*(l+r*(o%4))&255)<<16|(s>>>8*(l+r*((o+1)%4))&255)<<8|f>>>8*(l+r*((o+2)%4))&255,u=0;u<4;u+=1)c+=8*o+6*u<=n?t.charAt(a>>>6*(3-u)&63):i.b64Pad;return c}(e,n,r,i)};case"BYTES":return function(e){return function(e,t,n){var r,i,o="",u=t/8,a=-1===n?3:0;for(r=0;r>>2]>>>8*(a+n*(r%4))&255,o+=String.fromCharCode(i);return o}(e,n,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){ return function(e,t,n){var r,i=t/8,o=new ArrayBuffer(i),u=new Uint8Array(o),a=-1===n?3:0;for(r=0;r>>2]>>>8*(a+n*(r%4))&255;return o}(e,n,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){var r,i=t/8,o=-1===n?3:0,u=new Uint8Array(i);for(r=0;r>>2]>>>8*(o+n*(r%4))&255;return u}(e,n,r)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}} var i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],h="Chosen SHA variant is not supported";function u(e,t){var n,r,i=e.binLen>>>3,o=t.binLen>>>3,u=i<<3,a=4-i<<3;if(i%4!=0){ for(n=0;n>>2,e.value[r]|=t.value[n>>>2]<>>2]>>>a;return(e.value.length<<2)-4>=o+i&&e.value.pop(),{value:e.value,binLen:e.binLen+t.binLen}}return{value:e.value.concat(t.value),binLen:e.binLen+t.binLen}}function w(e){var t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function c(t,n,r,i){var o=t+" must include a value and format";if(!n){if(!i)throw new Error(o);return i}if(void 0===n.value||!n.format)throw new Error(o);return e(n.format,n.encoding||"UTF8",r)(n.value)}var f=function(){function t(e,n,r){ _classCallCheck(this,t);var i=r||{};if(this.t=n,this.i=i.encoding||"UTF8",this.numRounds=i.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.s=e,this.o=[],this.h=0,this.u=!1,this.l=0,this.A=!1,this.H=[],this.S=[]}return _createClass(t,[{key:"update",value:function(e){var t,n=0,r=this.p>>>5,i=this.m(e,this.o,this.h),o=i.binLen,u=i.value,a=o>>>5;for(t=0;t>>5),this.h=o%this.p,this.u=!0}},{key:"getHash",value:function(e,t){var n,i,o=this.U,u=w(t);if(this.v){if(-1===u.outputLen)throw new Error("Output length must be specified in options");o=u.outputLen}var a=r(e,o,this.K,u);if(this.A&&this.T)return a(this.T(u));for(i=this.F(this.o.slice(),this.h,this.l,this.g(this.C),o),n=1;n>>24-o%32),i=this.F(i,o,0,this.B(this.s),o);return a(i)}},{key:"setHMACKey", value:function(t,n,r){if(!this.L)throw new Error("Variant does not support HMAC");if(this.u)throw new Error("Cannot set MAC key after calling update");var i=e(n,(r||{}).encoding||"UTF8",this.K);this.M(i(t))}},{key:"M",value:function(e){var t,n=this.p>>>3,r=n/4-1;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.A)throw new Error("MAC key already set");for(n>>32-t} -function l(e,t){return e>>>t|e<<32-t}function A(e,t){return e>>>t}function E(e,t,n){return e^t^n}function H(e,t,n){return e&t^~e&n}function S(e,t,n){return e&t^e&n^t&n}function b(e){return l(e,2)^l(e,13)^l(e,22)}function p(e,t){var n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function d(e,t,n,r){var i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){var o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function C(e){return l(e,7)^l(e,18)^A(e,3)}function y(e){return l(e,6)^l(e,11)^l(e,25)}function R(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function U(e,t){var n,r,i,o,u,s,c,f=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],c=0;c<80;c+=1)f[c]=c<16?e[c]:a(f[c-3]^f[c-8]^f[c-14]^f[c-16],1), -s=c<20?m(a(n,5),H(r,i,o),u,1518500249,f[c]):c<40?m(a(n,5),E(r,i,o),u,1859775393,f[c]):c<60?m(a(n,5),S(r,i,o),u,2400959708,f[c]):m(a(n,5),E(r,i,o),u,3395469782,f[c]),u=o,o=i,i=a(r,30),r=n,n=s;return t[0]=p(n,t[0]),t[1]=p(r,t[1]),t[2]=p(i,t[2]),t[3]=p(o,t[3]),t[4]=p(u,t[4]),t}function v(e,t,n,r){for(var i,o=15+(t+65>>>9<<4),u=t+n;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&u,e[o-1]=u/4294967296|0,i=0;i>>9<<4),a=t+n;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o>>t|e<<32-t}function A(e,t){return e>>>t}function E(e,t,n){return e^t^n}function H(e,t,n){return e&t^~e&n}function S(e,t,n){return e&t^e&n^t&n}function b(e){return l(e,2)^l(e,13)^l(e,22)}function p(e,t){var n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function d(e,t,n,r){var i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){var o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function C(e){return l(e,7)^l(e,18)^A(e,3)}function y(e){return l(e,6)^l(e,11)^l(e,25)}function R(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function U(e,t){var n,r,i,o,u,s,f,c=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],f=0;f<80;f+=1)c[f]=f<16?e[f]:a(c[f-3]^c[f-8]^c[f-14]^c[f-16],1), +s=f<20?m(a(n,5),H(r,i,o),u,1518500249,c[f]):f<40?m(a(n,5),E(r,i,o),u,1859775393,c[f]):f<60?m(a(n,5),S(r,i,o),u,2400959708,c[f]):m(a(n,5),E(r,i,o),u,3395469782,c[f]),u=o,o=i,i=a(r,30),r=n,n=s;return t[0]=p(n,t[0]),t[1]=p(r,t[1]),t[2]=p(i,t[2]),t[3]=p(o,t[3]),t[4]=p(u,t[4]),t}function v(e,t,n,r){for(var i,o=15+(t+65>>>9<<4),u=t+n;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&u,e[o-1]=u/4294967296|0,i=0;i>>9<<4),a=t+n;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o32?(n=64-t,new B(e.N<>>n,e.Y<>>n)):0!==t?(n=32-t,new B(e.Y<>>n,e.N<>>n)):e}function M(e,t){var n;return t<32?(n=32-t,new B(e.Y>>>t|e.N<>>t|e.Y<>>t|e.Y<>>t|e.N<>>t,e.N>>>t|e.Y<<32-t)}function Y(e,t,n){return new B(e.Y&t.Y^e.Y&n.Y^t.Y&n.Y,e.N&t.N^e.N&n.N^t.N&n.N)}function N(e){var t=M(e,28),n=M(e,34),r=M(e,39);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function I(e,t){var n,r;n=(65535&e.N)+(65535&t.N);var i=(65535&(r=(e.N>>>16)+(t.N>>>16)+(n>>>16)))<<16|65535&n;return n=(65535&e.Y)+(65535&t.Y)+(r>>>16),r=(e.Y>>>16)+(t.Y>>>16)+(n>>>16),new B((65535&r)<<16|65535&n,i)}function X(e,t,n,r){var i,o;i=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&r.N);var u=(65535&(o=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(r.N>>>16)+(i>>>16)))<<16|65535&i;return i=(65535&e.Y)+(65535&t.Y)+(65535&n.Y)+(65535&r.Y)+(o>>>16), o=(e.Y>>>16)+(t.Y>>>16)+(n.Y>>>16)+(r.Y>>>16)+(i>>>16),new B((65535&o)<<16|65535&i,u)}function z(e,t,n,r,i){var o,u;o=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&r.N)+(65535&i.N);var a=(65535&(u=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(r.N>>>16)+(i.N>>>16)+(o>>>16)))<<16|65535&o;return o=(65535&e.Y)+(65535&t.Y)+(65535&n.Y)+(65535&r.Y)+(65535&i.Y)+(u>>>16),u=(e.Y>>>16)+(t.Y>>>16)+(n.Y>>>16)+(r.Y>>>16)+(i.Y>>>16)+(o>>>16),new B((65535&u)<<16|65535&o,a)}function x(e,t){return new B(e.Y^t.Y,e.N^t.N)}function _(e){var t=M(e,19),n=M(e,61),r=k(e,6);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function O(e){var t=M(e,1),n=M(e,8),r=k(e,7);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function P(e){var t=M(e,14),n=M(e,18),r=M(e,41);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)} var V=[new B(i[0],3609767458),new B(i[1],602891725),new B(i[2],3964484399),new B(i[3],2173295548),new B(i[4],4081628472),new B(i[5],3053834265),new B(i[6],2937671579),new B(i[7],3664609560),new B(i[8],2734883394),new B(i[9],1164996542),new B(i[10],1323610764),new B(i[11],3590304994),new B(i[12],4068182383),new B(i[13],991336113),new B(i[14],633803317),new B(i[15],3479774868),new B(i[16],2666613458),new B(i[17],944711139),new B(i[18],2341262773),new B(i[19],2007800933),new B(i[20],1495990901),new B(i[21],1856431235),new B(i[22],3175218132),new B(i[23],2198950837),new B(i[24],3999719339),new B(i[25],766784016),new B(i[26],2566594879),new B(i[27],3203337956),new B(i[28],1034457026),new B(i[29],2466948901),new B(i[30],3758326383),new B(i[31],168717936),new B(i[32],1188179964),new B(i[33],1546045734),new B(i[34],1522805485),new B(i[35],2643833823),new B(i[36],2343527390),new B(i[37],1014477480),new B(i[38],1206759142),new B(i[39],344077627),new B(i[40],1290863460),new B(i[41],3158454273),new B(i[42],3505952657),new B(i[43],106217008),new B(i[44],3606008344),new B(i[45],1432725776),new B(i[46],1467031594),new B(i[47],851169720),new B(i[48],3100823752),new B(i[49],1363258195),new B(i[50],3750685593),new B(i[51],3785050280),new B(i[52],3318307427),new B(i[53],3812723403),new B(i[54],2003034995),new B(i[55],3602036899),new B(i[56],1575990012),new B(i[57],1125592928),new B(i[58],2716904306),new B(i[59],442776044),new B(i[60],593698344),new B(i[61],3733110249),new B(i[62],2999351573),new B(i[63],3815920427),new B(3391569614,3928383900),new B(3515267271,566280711),new B(3940187606,3454069534),new B(4118630271,4000239992),new B(116418474,1914138554),new B(174292421,2731055270),new B(289380356,3203993006),new B(460393269,320620315),new B(685471733,587496836),new B(852142971,1086792851),new B(1017036298,365543100),new B(1126000580,2618297676),new B(1288033470,3409855158),new B(1501505948,4234509866),new B(1607167915,987167468),new B(1816402316,1246189591)] -;function Z(e){return"SHA-384"===e?[new B(3418070365,s[0]),new B(1654270250,s[1]),new B(2438529370,s[2]),new B(355462360,s[3]),new B(1731405415,s[4]),new B(41048885895,s[5]),new B(3675008525,s[6]),new B(1203062813,s[7])]:[new B(o[0],4089235720),new B(o[1],2227873595),new B(o[2],4271175723),new B(o[3],1595750129),new B(o[4],2917565137),new B(o[5],725511199),new B(o[6],4215389547),new B(o[7],327033209)]}function j(e,t){var n,r,i,o,u,a,s,c,f,l,h,w,p,d,v,g=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],a=t[5],s=t[6],c=t[7],h=0;h<80;h+=1)h<16?(w=2*h,g[h]=new B(e[w],e[w+1])):g[h]=X(_(g[h-2]),g[h-7],O(g[h-15]),g[h-16]),f=z(c,P(u),(d=a,v=s,new B((p=u).Y&d.Y^~p.Y&v.Y,p.N&d.N^~p.N&v.N)),V[h],g[h]),l=I(N(n),Y(n,r,i)),c=s,s=a,a=u,u=I(o,f),o=i,i=r,r=n,n=I(f,l);return t[0]=I(n,t[0]),t[1]=I(r,t[1]),t[2]=I(i,t[2]),t[3]=I(o,t[3]),t[4]=I(u,t[4]),t[5]=I(a,t[5]),t[6]=I(s,t[6]),t[7]=I(c,t[7]),t}var q=function(t){_inherits(r,f);var n=_createSuper(r);function r(t,i,o){var u;if(_classCallCheck(this,r), +;function Z(e){return"SHA-384"===e?[new B(3418070365,s[0]),new B(1654270250,s[1]),new B(2438529370,s[2]),new B(355462360,s[3]),new B(1731405415,s[4]),new B(41048885895,s[5]),new B(3675008525,s[6]),new B(1203062813,s[7])]:[new B(o[0],4089235720),new B(o[1],2227873595),new B(o[2],4271175723),new B(o[3],1595750129),new B(o[4],2917565137),new B(o[5],725511199),new B(o[6],4215389547),new B(o[7],327033209)]}function j(e,t){var n,r,i,o,u,a,s,f,c,h,l,w,p,d,v,g=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],a=t[5],s=t[6],f=t[7],l=0;l<80;l+=1)l<16?(w=2*l,g[l]=new B(e[w],e[w+1])):g[l]=X(_(g[l-2]),g[l-7],O(g[l-15]),g[l-16]),c=z(f,P(u),(d=a,v=s,new B((p=u).Y&d.Y^~p.Y&v.Y,p.N&d.N^~p.N&v.N)),V[l],g[l]),h=I(N(n),Y(n,r,i)),f=s,s=a,a=u,u=I(o,c),o=i,i=r,r=n,n=I(c,h);return t[0]=I(n,t[0]),t[1]=I(r,t[1]),t[2]=I(i,t[2]),t[3]=I(o,t[3]),t[4]=I(u,t[4]),t[5]=I(a,t[5]),t[6]=I(s,t[6]),t[7]=I(f,t[7]),t}var q=function(t){_inherits(r,f);var n=_createSuper(r);function r(t,i,o){var u;if(_classCallCheck(this,r), "SHA-384"!==t&&"SHA-512"!==t)throw new Error(h);var a=o||{};return(u=n.call(this,t,i,o)).T=u.k,u.L=!0,u.K=-1,u.m=e(u.t,u.i,u.K),u.R=j,u.g=function(e){return e.slice()},u.B=Z,u.F=function(e,n,r,i){return function(e,t,n,r,i){for(var o,u=31+(t+129>>>10<<5),a=t+n;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o>>1)%5][(r>>>1)/5|0]=x(t[(r>>>1)%5][(r>>>1)/5|0],new B(e[r+1],e[r]));for(n=0;n<24;n+=1){for(o=J(),r=0;r<5;r+=1)l[r]=(u=t[r][0],a=t[r][1],s=t[r][2], -c=t[r][3],f=t[r][4],new B(u.Y^a.Y^s.Y^c.Y^f.Y,u.N^a.N^s.N^c.N^f.N));for(r=0;r<5;r+=1)h[r]=x(l[(r+4)%5],L(l[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(t[r][i],h[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)o[i][(2*r+3*i)%5]=L(t[r][i],G[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(o[r][i],new B(~o[(r+1)%5][i].Y&o[(r+2)%5][i].Y,~o[(r+1)%5][i].N&o[(r+2)%5][i].N));t[0][0]=x(t[0][0],D[n])}return t}function $(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function tt(e){return u($(e.binLen),e)}function nt(e,t){var n,r=$(t),i=t>>>2,o=(i-(r=u(r,e)).value.length%i)%i;for(n=0;n>>5,h=t>>>5;for(a=0;a=i;a+=l)r=W(e.slice(a,a+l),r),t-=i;for(e=e.slice(a),t%=i;e.length>>3)>>2]^=o<=u));)f.push(s.Y),0==64*(c+=1)%i&&(W(null,r),c=0);return f}(e,t,0,r,s,a,i)},f.hmacKey&&u.M(c("hmacKey",f.hmacKey,u.K)),u}return _createClass(r,[{key:"_",value:function(e,t){var n=function(e){var t=e||{};return{funcName:c("funcName",t.funcName,1,{value:[],binLen:0}),customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);var r=u(tt(n.funcName),tt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){for(var i=nt(r,this.p>>>3),o=0;o>>5)this.C=this.R(i.slice(o,o+(this.p>>>5)),this.C),this.l+=this.p;return 4}return 31}},{key:"I",value:function(e){var t=function(e){var t=e||{};return{kmacKey:c("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._(e,t.funcName) +}(),D=[new B(0,1),new B(0,32898),new B(2147483648,32906),new B(2147483648,2147516416),new B(0,32907),new B(0,2147483649),new B(2147483648,2147516545),new B(2147483648,32777),new B(0,138),new B(0,136),new B(0,2147516425),new B(0,2147483658),new B(0,2147516555),new B(2147483648,139),new B(2147483648,32905),new B(2147483648,32771),new B(2147483648,32770),new B(2147483648,128),new B(0,32778),new B(2147483648,2147483658),new B(2147483648,2147516545),new B(2147483648,32896),new B(0,2147483649),new B(2147483648,2147516424)],G=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function J(e){var t,n=[];for(t=0;t<5;t+=1)n[t]=[new B(0,0),new B(0,0),new B(0,0),new B(0,0),new B(0,0)];return n}function Q(e){var t,n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function W(e,t){var n,r,i,o,u,a,s,f,c,h=[],l=[];if(null!==e)for(r=0;r>>1)%5][(r>>>1)/5|0]=x(t[(r>>>1)%5][(r>>>1)/5|0],new B(e[r+1],e[r]));for(n=0;n<24;n+=1){for(o=J(),r=0;r<5;r+=1)h[r]=(u=t[r][0],a=t[r][1],s=t[r][2], +f=t[r][3],c=t[r][4],new B(u.Y^a.Y^s.Y^f.Y^c.Y,u.N^a.N^s.N^f.N^c.N));for(r=0;r<5;r+=1)l[r]=x(h[(r+4)%5],L(h[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(t[r][i],l[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)o[i][(2*r+3*i)%5]=L(t[r][i],G[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(o[r][i],new B(~o[(r+1)%5][i].Y&o[(r+2)%5][i].Y,~o[(r+1)%5][i].N&o[(r+2)%5][i].N));t[0][0]=x(t[0][0],D[n])}return t}function $(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function tt(e){return u($(e.binLen),e)}function nt(e,t){var n,r=$(t),i=t>>>2,o=(i-(r=u(r,e)).value.length%i)%i;for(n=0;n>>5,l=t>>>5;for(a=0;a=i;a+=h)r=W(e.slice(a,a+h),r),t-=i;for(e=e.slice(a),t%=i;e.length>>3)>>2]^=o<=u));)c.push(s.Y),0==64*(f+=1)%i&&(W(null,r),f=0);return c}(e,t,0,r,s,a,i)},f.hmacKey&&u.M(c("hmacKey",f.hmacKey,u.K)),u}return _createClass(r,[{key:"_",value:function(e,t){var n=function(e){var t=e||{};return{funcName:c("funcName",t.funcName,1,{value:[],binLen:0}),customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);var r=u(tt(n.funcName),tt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){for(var i=nt(r,this.p>>>3),o=0;o>>5)this.C=this.R(i.slice(o,o+(this.p>>>5)),this.C),this.l+=this.p;return 4}return 31}},{key:"I",value:function(e){var t=function(e){var t=e||{};return{kmacKey:c("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._(e,t.funcName) ;for(var n=nt(tt(t.kmacKey),this.p>>>3),r=0;r>>5)this.C=this.R(n.slice(r,r+(this.p>>>5)),this.C),this.l+=this.p;this.A=!0}},{key:"X",value:function(e){var t=u({value:this.o.slice(),binLen:this.h},function(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r>>2]|=n<<8*r,r+=1);return i[(r=0!==r?r:1)>>2]|=r<<8*r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}(e.outputLen));return this.F(t.value,t.binLen,this.l,this.g(this.C),e.outputLen)}}]),r}(),_default=function(){function e(t,n,r){if(_classCallCheck(this,e),"SHA-1"==t)this.O=new K(t,n,r);else if("SHA-224"==t||"SHA-256"==t)this.O=new g(t,n,r);else if("SHA-384"==t||"SHA-512"==t)this.O=new q(t,n,r);else{if("SHA3-224"!=t&&"SHA3-256"!=t&&"SHA3-384"!=t&&"SHA3-512"!=t&&"SHAKE128"!=t&&"SHAKE256"!=t&&"CSHAKE128"!=t&&"CSHAKE256"!=t&&"KMAC128"!=t&&"KMAC256"!=t)throw new Error(h);this.O=new et(t,n,r)}}return _createClass(e,[{key:"update",value:function(e){this.O.update(e)}},{key:"getHash", -value:function(e,t){return this.O.getHash(e,t)}},{key:"setHMACKey",value:function(e,t,n){this.O.setHMACKey(e,t,n)}},{key:"getHMAC",value:function(e,t){return this.O.getHMAC(e,t)}}]),e}(),magicalGlobalThis=function(){var e;if("object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis)))e=globalThis;else{Object.defineProperty(Object.prototype,"__OTPAUTH_GLOBALTHIS__",{get:function(){return this},configurable:!0});try{e=__OTPAUTH_GLOBALTHIS__}finally{delete Object.prototype.__OTPAUTH_GLOBALTHIS__}}return void 0===e&&("undefined"!=typeof self?e=self:"undefined"!=typeof window?e=window:"undefined"!=typeof global&&(e=global)),e}(),isNode="[object process]"===Object.prototype.toString.call(magicalGlobalThis.process),nodeRequire=isNode?eval("require"):function(){},NodeBuffer$1=isNode?magicalGlobalThis.Buffer:void 0,NodeCrypto$2=isNode?nodeRequire("crypto"):void 0,OPENSSL_TO_JSSHA_ALGO={SHA1:"SHA-1",SHA224:"SHA-224",SHA256:"SHA-256",SHA384:"SHA-384",SHA512:"SHA-512","SHA3-224":"SHA3-224", -"SHA3-256":"SHA3-256","SHA3-384":"SHA3-384","SHA3-512":"SHA3-512"},hmacDigest=function(e,t,n){if(isNode){var r=NodeCrypto$2.createHmac(e,NodeBuffer$1.from(t));return r.update(NodeBuffer$1.from(n)),r.digest().buffer}var i=OPENSSL_TO_JSSHA_ALGO[e.toUpperCase()];if(void 0===i)throw new TypeError("Unknown hash function");var o=new _default(i,"ARRAYBUFFER");return o.setHMACKey(t,"ARRAYBUFFER"),o.update(n),o.getHMAC("ARRAYBUFFER")},pad=function(e,t){for(var n="",r=t-String(e).length;r-- >0;)n+="0";return"".concat(n).concat(e)},ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",base32ToBuf=function(e){for(var t=e.toUpperCase().replace(/=+$/,""),n=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(n),i=0,o=0,u=0,a=0;a=8&&(r[u++]=o>>>i-8&255,i-=8)}return n},base32FromBuf=function(e){for(var t=new Uint8Array(e),n=0,r=0,i="",o=0;o=5;)i+=ALPHABET[r>>>n-5&31],n-=5 -;return n>0&&(i+=ALPHABET[r<<5-n&31]),i},hexFromBuf=function(e){for(var t=new Uint8Array(e),n="",r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.buffer,r=t.size,i=void 0===r?20:r;_classCallCheck(this,e),this.buffer=void 0===n?randomBytes(i):n}return _createClass(e,[{key:"latin1",get:function(){return Object.defineProperty(this,"latin1",{enumerable:!0,value:latin1FromBuf(this.buffer)}),this.latin1}},{key:"utf8",get:function(){return Object.defineProperty(this,"utf8",{enumerable:!0,value:utf8FromBuf(this.buffer)}),this.utf8}},{key:"base32",get:function(){return Object.defineProperty(this,"base32",{enumerable:!0,value:base32FromBuf(this.buffer)}),this.base32}},{key:"hex",get:function(){ -return Object.defineProperty(this,"hex",{enumerable:!0,value:hexFromBuf(this.buffer)}),this.hex}}],[{key:"fromLatin1",value:function(t){return new e({buffer:latin1ToBuf(t)})}},{key:"fromUTF8",value:function(t){return new e({buffer:utf8ToBuf(t)})}},{key:"fromBase32",value:function(t){return new e({buffer:base32ToBuf(t)})}},{key:"fromHex",value:function(t){return new e({buffer:hexToBuf(t)})}}]),e}(),NodeBuffer=isNode?magicalGlobalThis.Buffer:void 0,NodeCrypto=isNode?nodeRequire("crypto"):void 0,timingSafeEqual=function(e,t){if(isNode)return NodeCrypto.timingSafeEqual(NodeBuffer.from(e),NodeBuffer.from(t));if(e.length!==t.length)throw new TypeError("Input strings must have the same length");for(var n=-1,r=0;++n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,c=void 0===s?e.defaults.algorithm:s,f=t.digits,l=void 0===f?e.defaults.digits:f,h=t.counter,w=void 0===h?e.defaults.counter:h;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=c.toUpperCase(),this.digits=l,this.counter=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.counter,r=void 0===n?this.counter++:n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:r})}},{key:"validate",value:function(t){var n=t.token,r=t.counter,i=void 0===r?this.counter:r,o=t.window;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:i,window:o})}},{key:"toString",value:function(){var e=encodeURIComponent -;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"counter=".concat(e(this.counter))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=void 0===r?e.defaults.algorithm:r,o=t.digits,u=void 0===o?e.defaults.digits:o,a=t.counter,s=void 0===a?e.defaults.counter:a,c=new Uint8Array(hmacDigest(i,n.buffer,uintToBuf(s))),f=15&c[c.byteLength-1],l=((127&c[f])<<24|(255&c[f+1])<<16|(255&c[f+2])<<8|255&c[f+3])%Math.pow(10,u);return pad(l,u)}},{key:"validate",value:function(t){var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.counter,a=void 0===u?e.defaults.counter:u,s=t.window,c=void 0===s?e.defaults.window:s;if(n.length!==o)return null -;for(var f=null,l=a-c;l<=a+c;++l){var h=e.generate({secret:r,algorithm:i,digits:o,counter:l});timingSafeEqual(n,h)&&(f=l-a)}return f}}]),e}(),TOTP=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,c=void 0===s?e.defaults.algorithm:s,f=t.digits,l=void 0===f?e.defaults.digits:f,h=t.period,w=void 0===h?e.defaults.period:h;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=c.toUpperCase(),this.digits=l,this.period=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.timestamp,r=void 0===n?Date.now():n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r})}},{key:"validate",value:function(t){var n=t.token,r=t.timestamp,i=t.window +value:function(e,t){return this.O.getHash(e,t)}},{key:"setHMACKey",value:function(e,t,n){this.O.setHMACKey(e,t,n)}},{key:"getHMAC",value:function(e,t){return this.O.getHMAC(e,t)}}]),e}(),globalThis=function(){if("object"===_typeof(globalThis))return globalThis;Object.defineProperty(Object.prototype,"__GLOBALTHIS__",{get:function(){return this},configurable:!0});try{if("undefined"!=typeof __GLOBALTHIS__)return __GLOBALTHIS__}finally{delete Object.prototype.__GLOBALTHIS__}return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0}(),isNode="[object process]"===Object.prototype.toString.call(globalThis.process),nodeRequire=isNode?eval("require"):function(){},NodeBuffer$1=isNode?globalThis.Buffer:void 0,NodeCrypto$2=isNode?nodeRequire("crypto"):void 0,OPENSSL_TO_JSSHA_ALGO={SHA1:"SHA-1",SHA224:"SHA-224",SHA256:"SHA-256",SHA384:"SHA-384",SHA512:"SHA-512","SHA3-224":"SHA3-224","SHA3-256":"SHA3-256","SHA3-384":"SHA3-384","SHA3-512":"SHA3-512" +},hmacDigest=function(e,t,n){if(isNode){var r=NodeCrypto$2.createHmac(e,NodeBuffer$1.from(t));return r.update(NodeBuffer$1.from(n)),r.digest().buffer}var i=OPENSSL_TO_JSSHA_ALGO[e.toUpperCase()];if(void 0===i)throw new TypeError("Unknown hash function");var o=new _default(i,"ARRAYBUFFER");return o.setHMACKey(t,"ARRAYBUFFER"),o.update(n),o.getHMAC("ARRAYBUFFER")},pad=function(e,t){for(var n="",r=t-String(e).length;r-- >0;)n+="0";return"".concat(n).concat(e)},ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",base32ToBuf=function(e){for(var t=e.toUpperCase().replace(/=+$/,""),n=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(n),i=0,o=0,u=0,a=0;a=8&&(r[u++]=o>>>i-8&255,i-=8)}return n},base32FromBuf=function(e){for(var t=new Uint8Array(e),n=0,r=0,i="",o=0;o=5;)i+=ALPHABET[r>>>n-5&31],n-=5;return n>0&&(i+=ALPHABET[r<<5-n&31]),i},hexToBuf=function(e){ +for(var t=new ArrayBuffer(e.length/2),n=new Uint8Array(t),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.buffer,r=t.size,i=void 0===r?20:r;_classCallCheck(this,e),this.buffer=void 0===n?randomBytes(i):n}return _createClass(e,[{key:"latin1",get:function(){return Object.defineProperty(this,"latin1",{enumerable:!0,value:latin1FromBuf(this.buffer)}),this.latin1}},{key:"utf8",get:function(){return Object.defineProperty(this,"utf8",{enumerable:!0,value:utf8FromBuf(this.buffer)}),this.utf8}},{key:"base32",get:function(){return Object.defineProperty(this,"base32",{enumerable:!0,value:base32FromBuf(this.buffer)}),this.base32}},{key:"hex",get:function(){ +return Object.defineProperty(this,"hex",{enumerable:!0,value:hexFromBuf(this.buffer)}),this.hex}}],[{key:"fromLatin1",value:function(t){return new e({buffer:latin1ToBuf(t)})}},{key:"fromUTF8",value:function(t){return new e({buffer:utf8ToBuf(t)})}},{key:"fromBase32",value:function(t){return new e({buffer:base32ToBuf(t)})}},{key:"fromHex",value:function(t){return new e({buffer:hexToBuf(t)})}}]),e}(),NodeBuffer=isNode?globalThis.Buffer:void 0,NodeCrypto=isNode?nodeRequire("crypto"):void 0,timingSafeEqual=function(e,t){if(isNode)return NodeCrypto.timingSafeEqual(NodeBuffer.from(e),NodeBuffer.from(t));if(e.length!==t.length)throw new TypeError("Input strings must have the same length");for(var n=-1,r=0;++n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,h=void 0===c?e.defaults.digits:c,l=t.counter,w=void 0===l?e.defaults.counter:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=h,this.counter=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.counter,r=void 0===n?this.counter++:n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:r})}},{key:"validate",value:function(t){var n=t.token,r=t.counter,i=void 0===r?this.counter:r,o=t.window;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:i,window:o})}},{key:"toString",value:function(){var e=encodeURIComponent +;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"counter=".concat(e(this.counter))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=void 0===r?e.defaults.algorithm:r,o=t.digits,u=void 0===o?e.defaults.digits:o,a=t.counter,s=void 0===a?e.defaults.counter:a,f=new Uint8Array(hmacDigest(i,n.buffer,uintToBuf(s))),c=15&f[f.byteLength-1],h=((127&f[c])<<24|(255&f[c+1])<<16|(255&f[c+2])<<8|255&f[c+3])%Math.pow(10,u);return pad(h,u)}},{key:"validate",value:function(t){var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.counter,a=void 0===u?e.defaults.counter:u,s=t.window,f=void 0===s?e.defaults.window:s;if(n.length!==o)return null +;for(var c=null,h=a-f;h<=a+f;++h){var l=e.generate({secret:r,algorithm:i,digits:o,counter:h});timingSafeEqual(n,l)&&(c=h-a)}return c}}]),e}(),TOTP=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,h=void 0===c?e.defaults.digits:c,l=t.period,w=void 0===l?e.defaults.period:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=h,this.period=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.timestamp,r=void 0===n?Date.now():n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r})}},{key:"validate",value:function(t){var n=t.token,r=t.timestamp,i=t.window ;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r,window:i})}},{key:"toString",value:function(){var e=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"period=".concat(e(this.period))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,period:30,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=t.digits,o=t.period,u=void 0===o?e.defaults.period:o,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:n,algorithm:r,digits:i,counter:Math.floor(s/1e3/u)})}},{key:"validate",value:function(t){ -var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.period,a=void 0===u?e.defaults.period:u,s=t.timestamp,c=void 0===s?Date.now():s,f=t.window;return HOTP.validate({token:n,secret:r,algorithm:i,digits:o,counter:Math.floor(c/1e3/a),window:f})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var n,r=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var n=t.split(/=(.*)/,2).map(decodeURIComponent),r=n[0].toLowerCase(),i=n[1],o=e;return o[r]=i,o}),{}),u={};if("hotp"===r){if(n=HOTP, +var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.period,a=void 0===u?e.defaults.period:u,s=t.timestamp,f=void 0===s?Date.now():s,c=t.window;return HOTP.validate({token:n,secret:r,algorithm:i,digits:o,counter:Math.floor(f/1e3/a),window:c})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var n,r=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var n=t.split(/=(.*)/,2).map(decodeURIComponent),r=n[0].toLowerCase(),i=n[1],o=e;return o[r]=i,o}),{}),u={};if("hotp"===r){if(n=HOTP, void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");u.counter=parseInt(o.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");u.period=parseInt(o.period,10)}}if(2===i.length)if(u.label=i[1],void 0===o.issuer)u.issuer=i[0];else{if(o.issuer!==i[0])throw new TypeError("Invalid 'issuer' parameter");u.issuer=o.issuer}else u.label=i[0],void 0!==o.issuer&&(u.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(u.secret=o.secret,void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");u.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter");u.digits=parseInt(o.digits,10)}return new n(u)}},{key:"stringify", -value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.0";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.1";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 3ce3a484..4bafd0a5 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 */\nexport const uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nexport const uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport default nodeRequire;\n","import jsSHA from 'jssha';\n\nimport globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport default hmacDigest;\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport default pad;\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nexport const base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n","/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nexport const hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\n/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nexport const latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n","import globalThis from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nexport const utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n","import globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport default randomBytes;\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport randomBytes from './utils/crypto/random-bytes';\n\nexport default class Secret {\n\t/**\n\t * Secret key object.\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n","import globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport default timingSafeEqual;\n","import { uintToBuf } from './utils/encoding/uint';\nimport hmacDigest from './utils/crypto/hmac-digest';\nimport pad from './utils/pad';\nimport Secret from './secret';\nimport timingSafeEqual from './utils/crypto/timing-safe-equal';\n\nexport default class HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * HOTP: An HMAC-based One-time Password Algorithm.\n\t * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n","import HOTP from './hotp';\nimport Secret from './secret';\n\nexport default class TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * TOTP: Time-Based One-Time Password Algorithm.\n\t * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n","import HOTP from './hotp';\nimport TOTP from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nexport default class URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport default 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","magicalGlobalThis","magic","globalThis","Object","defineProperty","prototype","get","this","configurable","__OTPAUTH_GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexFromBuf","hex","hexToBuf","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":";;;;GAKO,IAAMA,UAAY,SAACC,WACnBC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACR,IAARD,EADmBC,IAEvBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGDJ,GCbFM,EAAS,mEA4Pf,SAASC,EACPL,EACAM,EACAC,EACAC,OAEIL,EAAGM,EAAWC,EAGZC,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAIH,EAAIc,OAAQX,GAAK,EAE/BM,GADAC,EAAaP,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI,KAAK,GAEdJ,EAAOF,IAAcT,EAAIG,IAAO,GAAKU,EAAgBL,GAAgBE,EAAa,UAG7E,CAAEM,MAAOL,EAAQM,OAAqB,EAAbjB,EAAIc,OAAaP,GAAAA,SA6BnCW,EACdC,EACAC,EACAZ,UAIQY,OACD,WAEA,cAEA,8BAIG,IAAIC,MAAM,qDAIZF,OACD,aAOI,SAAUG,EAAaC,EAAwBC,UA7N5D,SACEF,EACAhB,EACAC,EACAC,OAEIL,EAAGN,EAAKY,EAAWC,KAEnB,GAAMY,EAAIR,OAAS,EACrB,MAAM,IAAIO,MAAM,qDAIZV,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAImB,EAAIR,OAA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AASuC,EAAS,OACnB,CAAA,GAAII,EAAU3C,SAAWuC,EAAS,SAGlC,IAAInF,UAAU,8BAFpB8F,EAAOlD,OAAS2C,EAAU3C,YAK3BkD,EAAOhD,MAAQqC,EAAS,QACQ,IAArBI,EAAU3C,SACpBkD,EAAOlD,OAAS2C,EAAU3C,gBAKI,IAArB2C,EAAUxC,SAA0BqB,aAAa2B,KAAKR,EAAUxC,cAGpE,IAAI/C,UAAU,4CAFpB8F,EAAO/C,OAASwC,EAAUxC,YAMQ,IAAxBwC,EAAUjG,UAA2B,KAC3C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG5B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOC,IAArBiG,EAAUlF,OAAwB,KACxCkE,uBAAuBwB,KAAKR,EAAUlF,cAGnC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAAS1E,SAAS4J,EAAUlF,OAAQ,WAMtC,IAAI2E,EAAIc;MAQhB,SAAiBrC,MACZA,aAAed,MAAQc,aAAeG,YAClCH,EAAI9E,iBAGN,IAAIqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.cjs.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport { nodeRequire };\n","import jsSHA from 'jssha';\n\nimport { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport { hmacDigest };\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport { pad };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nconst base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n\nexport { base32ToBuf, base32FromBuf };\n","/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nconst hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\nexport { hexToBuf, hexFromBuf };\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nconst latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n\nexport { latin1ToBuf, latin1FromBuf };\n","import { globalThis } from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nconst utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n\nexport { utf8ToBuf, utf8FromBuf };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport { randomBytes };\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport { randomBytes } from './utils/crypto/random-bytes';\n\n/**\n * OTP secret key.\n */\nclass Secret {\n\t/**\n\t * Creates a secret key object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n\nexport { Secret };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from './utils/encoding/uint';\nimport { hmacDigest } from './utils/crypto/hmac-digest';\nimport { pad } from './utils/pad';\nimport { Secret } from './secret';\nimport { timingSafeEqual } from './utils/crypto/timing-safe-equal';\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates an HOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n\nexport { HOTP };\n","import { HOTP } from './hotp';\nimport { Secret } from './secret';\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates a TOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n\nexport { TOTP };\n","import { HOTP } from './hotp';\nimport { TOTP } from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;GAKA,IAAMA,UAAY,SAACC,WACZC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACR,IAARD,EADmBC,IAEvBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGDJ,GCbFM,EAAS,mEA4Pf,SAASC,EACPL,EACAM,EACAC,EACAC,OAEIL,EAAGM,EAAWC,EAGZC,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,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IqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file diff --git a/dist/otpauth.d.ts b/dist/otpauth.d.ts index c7c7421c..6f64e0e6 100644 --- a/dist/otpauth.d.ts +++ b/dist/otpauth.d.ts @@ -1,3 +1,6 @@ +/** + * OTP secret key. + */ declare class Secret { /** * Converts a Latin-1 string to a Secret object. @@ -24,8 +27,7 @@ declare class Secret { */ static fromHex(str: string): Secret; /** - * Secret key object. - * @constructor + * Creates a secret key object. * @param {Object} [config] Configuration options. * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key. * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided. @@ -61,6 +63,10 @@ declare class Secret { get hex(): string; } +/** + * HOTP: An HMAC-based One-time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} + */ declare class HOTP { /** * Default configuration. @@ -116,9 +122,7 @@ declare class HOTP { window?: number | undefined; }): number | null; /** - * HOTP: An HMAC-based One-time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} - * @constructor + * Creates an HOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -194,6 +198,10 @@ declare class HOTP { toString(): string; } +/** + * TOTP: Time-Based One-Time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} + */ declare class TOTP { /** * Default configuration. @@ -253,9 +261,7 @@ declare class TOTP { window?: number | undefined; }): number | null; /** - * TOTP: Time-Based One-Time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} - * @constructor + * Creates a TOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. diff --git a/dist/otpauth.esm.js b/dist/otpauth.esm.js index 7f12c39d..1b7b528a 100644 --- a/dist/otpauth.esm.js +++ b/dist/otpauth.esm.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.1 | (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) { @@ -1208,14 +1208,11 @@ var _default = /*#__PURE__*/function () { * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} */ -var magicalGlobalThis = function () { - /* eslint-disable no-extend-native, no-undef, no-restricted-globals */ - var magic; - - if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === 'object') { - magic = globalThis; - } else { - Object.defineProperty(Object.prototype, '__OTPAUTH_GLOBALTHIS__', { +var globalThis = function () { + // @ts-ignore + if (_typeof(globalThis) === 'object') return globalThis;else { + // eslint-disable-next-line no-extend-native + Object.defineProperty(Object.prototype, '__GLOBALTHIS__', { get: function get() { return this; }, @@ -1224,26 +1221,20 @@ var magicalGlobalThis = function () { try { // @ts-ignore - magic = __OTPAUTH_GLOBALTHIS__; + // eslint-disable-next-line no-undef + if (typeof __GLOBALTHIS__ !== 'undefined') return __GLOBALTHIS__; } finally { // @ts-ignore - delete Object.prototype.__OTPAUTH_GLOBALTHIS__; + delete Object.prototype.__GLOBALTHIS__; } - } + } // Still unable to determine "globalThis", fall back to a naive method. - if (typeof magic === 'undefined') { - // Still unable to determine "globalThis", fall back to a naive method. - if (typeof self !== 'undefined') { - magic = self; - } else if (typeof window !== 'undefined') { - magic = window; - } else if (typeof global !== 'undefined') { - magic = global; - } - } + /* eslint-disable no-undef, no-restricted-globals */ - return magic; + if (typeof self !== 'undefined') return self;else if (typeof window !== 'undefined') return window;else if (typeof global !== 'undefined') return global; /* eslint-enable */ + + return undefined; }(); /** @@ -1251,7 +1242,7 @@ var magicalGlobalThis = function () { * @type {boolean} */ -var isNode = Object.prototype.toString.call(magicalGlobalThis.process) === '[object process]'; +var isNode = Object.prototype.toString.call(globalThis.process) === '[object process]'; /** * Dynamically import Node.js modules ("eval" is used to prevent bundlers from including the module). @@ -1263,7 +1254,7 @@ var isNode = Object.prototype.toString.call(magicalGlobalThis.process) === '[obj var nodeRequire = isNode // eslint-disable-next-line no-eval ? eval('require') : function () {}; -var NodeBuffer$1 = isNode ? magicalGlobalThis.Buffer : undefined; +var NodeBuffer$1 = isNode ? globalThis.Buffer : undefined; var NodeCrypto$2 = isNode ? nodeRequire('crypto') : undefined; /** * OpenSSL to jsSHA algorithms. @@ -1373,6 +1364,7 @@ var base32ToBuf = function base32ToBuf(str) { * @returns {string} Base32 string. */ + var base32FromBuf = function base32FromBuf(buf) { var arr = new Uint8Array(buf); var bits = 0; @@ -1396,11 +1388,28 @@ var base32FromBuf = function base32FromBuf(buf) { return str; }; +/** + * Converts a hexadecimal string to an ArrayBuffer. + * @param {string} str Hexadecimal string. + * @returns {ArrayBuffer} ArrayBuffer. + */ +var hexToBuf = function hexToBuf(str) { + var buf = new ArrayBuffer(str.length / 2); + var arr = new Uint8Array(buf); + + for (var i = 0; i < str.length; i += 2) { + arr[i / 2] = parseInt(str.substr(i, 2), 16); + } + + return buf; +}; /** * Converts an ArrayBuffer to a hexadecimal string. * @param {ArrayBuffer} buf ArrayBuffer. * @returns {string} Hexadecimal string. */ + + var hexFromBuf = function hexFromBuf(buf) { var arr = new Uint8Array(buf); var str = ''; @@ -1413,22 +1422,6 @@ var hexFromBuf = function hexFromBuf(buf) { return str.toUpperCase(); }; -/** - * Converts a hexadecimal string to an ArrayBuffer. - * @param {string} str Hexadecimal string. - * @returns {ArrayBuffer} ArrayBuffer. - */ - -var hexToBuf = function hexToBuf(str) { - var buf = new ArrayBuffer(str.length / 2); - var arr = new Uint8Array(buf); - - for (var i = 0; i < str.length; i += 2) { - arr[i / 2] = parseInt(str.substr(i, 2), 16); - } - - return buf; -}; /** * Converts a Latin-1 string to an ArrayBuffer. @@ -1451,6 +1444,7 @@ var latin1ToBuf = function latin1ToBuf(str) { * @returns {string} Latin-1 string. */ + var latin1FromBuf = function latin1FromBuf(buf) { var arr = new Uint8Array(buf); var str = ''; @@ -1467,13 +1461,13 @@ var latin1FromBuf = function latin1FromBuf(buf) { * @type {TextEncoder|null} */ -var ENCODER = magicalGlobalThis.TextEncoder ? new magicalGlobalThis.TextEncoder('utf-8') : null; +var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder('utf-8') : null; /** * TextDecoder instance. * @type {TextDecoder|null} */ -var DECODER = magicalGlobalThis.TextDecoder ? new magicalGlobalThis.TextDecoder('utf-8') : null; +var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : null; /** * Converts an UTF-8 string to an ArrayBuffer. * @param {string} str String. @@ -1493,6 +1487,7 @@ var utf8ToBuf = function utf8ToBuf(str) { * @returns {string} String. */ + var utf8FromBuf = function utf8FromBuf(buf) { if (!DECODER) { throw new Error('Encoding API not available'); @@ -1502,7 +1497,7 @@ var utf8FromBuf = function utf8FromBuf(buf) { }; var NodeCrypto$1 = isNode ? nodeRequire('crypto') : undefined; -var BrowserCrypto = !isNode ? magicalGlobalThis.crypto || magicalGlobalThis.msCrypto : undefined; +var BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined; /** * Returns random bytes. * @param {number} size Size. @@ -1521,10 +1516,13 @@ var randomBytes = function randomBytes(size) { } }; +/** + * OTP secret key. + */ + var Secret = /*#__PURE__*/function () { /** - * Secret key object. - * @constructor + * Creates a secret key object. * @param {Object} [config] Configuration options. * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key. * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided. @@ -1657,7 +1655,7 @@ var Secret = /*#__PURE__*/function () { return Secret; }(); -var NodeBuffer = isNode ? magicalGlobalThis.Buffer : undefined; +var NodeBuffer = isNode ? globalThis.Buffer : undefined; var NodeCrypto = isNode ? nodeRequire('crypto') : undefined; /** * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values. @@ -1685,11 +1683,14 @@ var timingSafeEqual = function timingSafeEqual(a, b) { } }; +/** + * HOTP: An HMAC-based One-time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} + */ + var HOTP = /*#__PURE__*/function () { /** - * HOTP: An HMAC-based One-time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} - * @constructor + * Creates an HOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -1905,11 +1906,14 @@ var HOTP = /*#__PURE__*/function () { return HOTP; }(); +/** + * TOTP: Time-Based One-Time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} + */ + var TOTP = /*#__PURE__*/function () { /** - * TOTP: Time-Based One-Time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} - * @constructor + * Creates a TOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -2294,6 +2298,6 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = '7.0.0'; +var version = '7.0.1'; export { HOTP, Secret, TOTP, URI, version }; diff --git a/dist/otpauth.esm.min.js b/dist/otpauth.esm.min.js index 5ab84698..4b5ca212 100644 --- a/dist/otpauth.esm.min.js +++ b/dist/otpauth.esm.min.js @@ -1,39 +1,39 @@ -/*! otpauth v7.0.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.1 | (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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n=0&&0!==r;i--)n[i]=255&r,r-=n[i],r/=256;return t},t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function n(e,t,n,r){var i,o,u,a=t||[0],s=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i>>2,a.length<=o&&a.push(0),a[o]|=e[i]<<8*(c+r*(u%4));return{value:a,binLen:8*e.length+n}}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(e,t,n){return function(e,t,n,r){var i,o,u,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");var s=t||[0],c=(n=n||0)>>>3,f=-1===r?3:0;for(i=0;i>>1)+c)>>>2;s.length<=u;)s.push(0);s[u]|=o<<8*(f+r*(a%4))}return{value:s,binLen:4*e.length+n}}(e,t,n,i)};case"TEXT":return function(e,t,n){return function(e,t,n,r,i){ -var o,u,a,s,c,f,h,l,w=0,p=n||[0],d=(r=r||0)>>>3;if("UTF8"===t)for(h=-1===i?3:0,a=0;a(o=e.charCodeAt(a))?u.push(o):2048>o?(u.push(192|o>>>6),u.push(128|63&o)):55296>o||57344<=o?u.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(a)),u.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;p.length<=c;)p.push(0);p[c]|=u[s]<<8*(h+i*(f%4)),w+=1}else for(h=-1===i?2:0,l="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a>>8),c=(f=w+d)>>>2;p.length<=c;)p.push(0);p[c]|=o<<8*(h+i*(f%4)),w+=2}return{value:p,binLen:8*w+r}}(e,r,t,n,i)};case"B64":return function(e,n,r){return function(e,n,r,i){var o,u,a,s,c,f,h=0,l=n||[0],w=(r=r||0)>>>3,p=-1===i?3:0,d=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==d&&d>>2;l.length<=f;)l.push(0);l[f]|=(a>>>16-8*u&255)<<8*(p+i*(c%4)),h+=1}}return{value:l,binLen:8*h+r}}(e,n,r,i)};case"BYTES":return function(e,t,n){return function(e,t,n,r){var i,o,u,a,s=t||[0],f=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o>>2,s.length<=u&&s.push(0),s[u]|=i<<8*(c+r*(a%4));return{value:s,binLen:8*e.length+n}}(e,t,n,i)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,r,i){return n(new Uint8Array(e),t,r,i)}(e,t,r,i)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return n(e,t,r,i)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function r(e,n,r,i){switch(e){case"HEX": +return function(e){return function(e,t,n,r){var i,o,u="",a=t/8,s=-1===n?3:0;for(i=0;i>>2]>>>8*(s+n*(i%4)),u+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?u.toUpperCase():u}(e,n,r,i)};case"B64":return function(e){return function(e,n,r,i){var o,u,a,s,f,c="",h=n/8,l=-1===r?3:0;for(o=0;o>>2]:0,f=o+2>>2]:0,a=(e[o>>>2]>>>8*(l+r*(o%4))&255)<<16|(s>>>8*(l+r*((o+1)%4))&255)<<8|f>>>8*(l+r*((o+2)%4))&255,u=0;u<4;u+=1)c+=8*o+6*u<=n?t.charAt(a>>>6*(3-u)&63):i.b64Pad;return c}(e,n,r,i)};case"BYTES":return function(e){return function(e,t,n){var r,i,o="",u=t/8,a=-1===n?3:0;for(r=0;r>>2]>>>8*(a+n*(r%4))&255,o+=String.fromCharCode(i);return o}(e,n,r)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){var r,i=t/8,o=new ArrayBuffer(i),u=new Uint8Array(o),a=-1===n?3:0;for(r=0;r>>2]>>>8*(a+n*(r%4))&255 ;return o}(e,n,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){var r,i=t/8,o=-1===n?3:0,u=new Uint8Array(i);for(r=0;r>>2]>>>8*(o+n*(r%4))&255;return u}(e,n,r)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}} var i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],h="Chosen SHA variant is not supported";function u(e,t){var n,r,i=e.binLen>>>3,o=t.binLen>>>3,u=i<<3,a=4-i<<3;if(i%4!=0){ for(n=0;n>>2,e.value[r]|=t.value[n>>>2]<>>2]>>>a;return(e.value.length<<2)-4>=o+i&&e.value.pop(),{value:e.value,binLen:e.binLen+t.binLen}}return{value:e.value.concat(t.value),binLen:e.binLen+t.binLen}}function w(e){var t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function c(t,n,r,i){var o=t+" must include a value and format";if(!n){if(!i)throw new Error(o);return i}if(void 0===n.value||!n.format)throw new Error(o);return e(n.format,n.encoding||"UTF8",r)(n.value)}var f=function(){function t(e,n,r){ _classCallCheck(this,t);var i=r||{};if(this.t=n,this.i=i.encoding||"UTF8",this.numRounds=i.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.s=e,this.o=[],this.h=0,this.u=!1,this.l=0,this.A=!1,this.H=[],this.S=[]}return _createClass(t,[{key:"update",value:function(e){var t,n=0,r=this.p>>>5,i=this.m(e,this.o,this.h),o=i.binLen,u=i.value,a=o>>>5;for(t=0;t>>5),this.h=o%this.p,this.u=!0}},{key:"getHash",value:function(e,t){var n,i,o=this.U,u=w(t);if(this.v){if(-1===u.outputLen)throw new Error("Output length must be specified in options");o=u.outputLen}var a=r(e,o,this.K,u);if(this.A&&this.T)return a(this.T(u));for(i=this.F(this.o.slice(),this.h,this.l,this.g(this.C),o),n=1;n>>24-o%32),i=this.F(i,o,0,this.B(this.s),o);return a(i)}},{key:"setHMACKey", value:function(t,n,r){if(!this.L)throw new Error("Variant does not support HMAC");if(this.u)throw new Error("Cannot set MAC key after calling update");var i=e(n,(r||{}).encoding||"UTF8",this.K);this.M(i(t))}},{key:"M",value:function(e){var t,n=this.p>>>3,r=n/4-1;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.A)throw new Error("MAC key already set");for(n>>32-t} -function l(e,t){return e>>>t|e<<32-t}function A(e,t){return e>>>t}function E(e,t,n){return e^t^n}function H(e,t,n){return e&t^~e&n}function S(e,t,n){return e&t^e&n^t&n}function b(e){return l(e,2)^l(e,13)^l(e,22)}function p(e,t){var n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function d(e,t,n,r){var i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){var o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function C(e){return l(e,7)^l(e,18)^A(e,3)}function y(e){return l(e,6)^l(e,11)^l(e,25)}function R(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function U(e,t){var n,r,i,o,u,s,c,f=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],c=0;c<80;c+=1)f[c]=c<16?e[c]:a(f[c-3]^f[c-8]^f[c-14]^f[c-16],1), -s=c<20?m(a(n,5),H(r,i,o),u,1518500249,f[c]):c<40?m(a(n,5),E(r,i,o),u,1859775393,f[c]):c<60?m(a(n,5),S(r,i,o),u,2400959708,f[c]):m(a(n,5),E(r,i,o),u,3395469782,f[c]),u=o,o=i,i=a(r,30),r=n,n=s;return t[0]=p(n,t[0]),t[1]=p(r,t[1]),t[2]=p(i,t[2]),t[3]=p(o,t[3]),t[4]=p(u,t[4]),t}function v(e,t,n,r){for(var i,o=15+(t+65>>>9<<4),u=t+n;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&u,e[o-1]=u/4294967296|0,i=0;i>>9<<4),a=t+n;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o>>t|e<<32-t}function A(e,t){return e>>>t}function E(e,t,n){return e^t^n}function H(e,t,n){return e&t^~e&n}function S(e,t,n){return e&t^e&n^t&n}function b(e){return l(e,2)^l(e,13)^l(e,22)}function p(e,t){var n=(65535&e)+(65535&t);return(65535&(e>>>16)+(t>>>16)+(n>>>16))<<16|65535&n}function d(e,t,n,r){var i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16))<<16|65535&i}function m(e,t,n,r,i){var o=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return(65535&(e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(o>>>16))<<16|65535&o}function C(e){return l(e,7)^l(e,18)^A(e,3)}function y(e){return l(e,6)^l(e,11)^l(e,25)}function R(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function U(e,t){var n,r,i,o,u,s,f,c=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],f=0;f<80;f+=1)c[f]=f<16?e[f]:a(c[f-3]^c[f-8]^c[f-14]^c[f-16],1), +s=f<20?m(a(n,5),H(r,i,o),u,1518500249,c[f]):f<40?m(a(n,5),E(r,i,o),u,1859775393,c[f]):f<60?m(a(n,5),S(r,i,o),u,2400959708,c[f]):m(a(n,5),E(r,i,o),u,3395469782,c[f]),u=o,o=i,i=a(r,30),r=n,n=s;return t[0]=p(n,t[0]),t[1]=p(r,t[1]),t[2]=p(i,t[2]),t[3]=p(o,t[3]),t[4]=p(u,t[4]),t}function v(e,t,n,r){for(var i,o=15+(t+65>>>9<<4),u=t+n;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&u,e[o-1]=u/4294967296|0,i=0;i>>9<<4),a=t+n;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o32?(n=64-t,new B(e.N<>>n,e.Y<>>n)):0!==t?(n=32-t,new B(e.Y<>>n,e.N<>>n)):e}function M(e,t){var n;return t<32?(n=32-t,new B(e.Y>>>t|e.N<>>t|e.Y<>>t|e.Y<>>t|e.N<>>t,e.N>>>t|e.Y<<32-t)}function Y(e,t,n){return new B(e.Y&t.Y^e.Y&n.Y^t.Y&n.Y,e.N&t.N^e.N&n.N^t.N&n.N)}function N(e){var t=M(e,28),n=M(e,34),r=M(e,39);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function I(e,t){var n,r;n=(65535&e.N)+(65535&t.N);var i=(65535&(r=(e.N>>>16)+(t.N>>>16)+(n>>>16)))<<16|65535&n;return n=(65535&e.Y)+(65535&t.Y)+(r>>>16),r=(e.Y>>>16)+(t.Y>>>16)+(n>>>16),new B((65535&r)<<16|65535&n,i)}function X(e,t,n,r){var i,o;i=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&r.N);var u=(65535&(o=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(r.N>>>16)+(i>>>16)))<<16|65535&i;return i=(65535&e.Y)+(65535&t.Y)+(65535&n.Y)+(65535&r.Y)+(o>>>16), o=(e.Y>>>16)+(t.Y>>>16)+(n.Y>>>16)+(r.Y>>>16)+(i>>>16),new B((65535&o)<<16|65535&i,u)}function z(e,t,n,r,i){var o,u;o=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&r.N)+(65535&i.N);var a=(65535&(u=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(r.N>>>16)+(i.N>>>16)+(o>>>16)))<<16|65535&o;return o=(65535&e.Y)+(65535&t.Y)+(65535&n.Y)+(65535&r.Y)+(65535&i.Y)+(u>>>16),u=(e.Y>>>16)+(t.Y>>>16)+(n.Y>>>16)+(r.Y>>>16)+(i.Y>>>16)+(o>>>16),new B((65535&u)<<16|65535&o,a)}function x(e,t){return new B(e.Y^t.Y,e.N^t.N)}function _(e){var t=M(e,19),n=M(e,61),r=k(e,6);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function O(e){var t=M(e,1),n=M(e,8),r=k(e,7);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function P(e){var t=M(e,14),n=M(e,18),r=M(e,41);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)} var V=[new B(i[0],3609767458),new B(i[1],602891725),new B(i[2],3964484399),new B(i[3],2173295548),new B(i[4],4081628472),new B(i[5],3053834265),new B(i[6],2937671579),new B(i[7],3664609560),new B(i[8],2734883394),new B(i[9],1164996542),new B(i[10],1323610764),new B(i[11],3590304994),new B(i[12],4068182383),new B(i[13],991336113),new B(i[14],633803317),new B(i[15],3479774868),new B(i[16],2666613458),new B(i[17],944711139),new B(i[18],2341262773),new B(i[19],2007800933),new B(i[20],1495990901),new B(i[21],1856431235),new B(i[22],3175218132),new B(i[23],2198950837),new B(i[24],3999719339),new B(i[25],766784016),new B(i[26],2566594879),new B(i[27],3203337956),new B(i[28],1034457026),new B(i[29],2466948901),new B(i[30],3758326383),new B(i[31],168717936),new B(i[32],1188179964),new B(i[33],1546045734),new B(i[34],1522805485),new B(i[35],2643833823),new B(i[36],2343527390),new B(i[37],1014477480),new B(i[38],1206759142),new B(i[39],344077627),new B(i[40],1290863460),new B(i[41],3158454273),new B(i[42],3505952657),new B(i[43],106217008),new B(i[44],3606008344),new B(i[45],1432725776),new B(i[46],1467031594),new B(i[47],851169720),new B(i[48],3100823752),new B(i[49],1363258195),new B(i[50],3750685593),new B(i[51],3785050280),new B(i[52],3318307427),new B(i[53],3812723403),new B(i[54],2003034995),new B(i[55],3602036899),new B(i[56],1575990012),new B(i[57],1125592928),new B(i[58],2716904306),new B(i[59],442776044),new B(i[60],593698344),new B(i[61],3733110249),new B(i[62],2999351573),new B(i[63],3815920427),new B(3391569614,3928383900),new B(3515267271,566280711),new B(3940187606,3454069534),new B(4118630271,4000239992),new B(116418474,1914138554),new B(174292421,2731055270),new B(289380356,3203993006),new B(460393269,320620315),new B(685471733,587496836),new B(852142971,1086792851),new B(1017036298,365543100),new B(1126000580,2618297676),new B(1288033470,3409855158),new B(1501505948,4234509866),new B(1607167915,987167468),new B(1816402316,1246189591)] -;function Z(e){return"SHA-384"===e?[new B(3418070365,s[0]),new B(1654270250,s[1]),new B(2438529370,s[2]),new B(355462360,s[3]),new B(1731405415,s[4]),new B(41048885895,s[5]),new B(3675008525,s[6]),new B(1203062813,s[7])]:[new B(o[0],4089235720),new B(o[1],2227873595),new B(o[2],4271175723),new B(o[3],1595750129),new B(o[4],2917565137),new B(o[5],725511199),new B(o[6],4215389547),new B(o[7],327033209)]}function j(e,t){var n,r,i,o,u,a,s,c,f,h,l,w,p,d,v,g=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],a=t[5],s=t[6],c=t[7],l=0;l<80;l+=1)l<16?(w=2*l,g[l]=new B(e[w],e[w+1])):g[l]=X(_(g[l-2]),g[l-7],O(g[l-15]),g[l-16]),f=z(c,P(u),(d=a,v=s,new B((p=u).Y&d.Y^~p.Y&v.Y,p.N&d.N^~p.N&v.N)),V[l],g[l]),h=I(N(n),Y(n,r,i)),c=s,s=a,a=u,u=I(o,f),o=i,i=r,r=n,n=I(f,h);return t[0]=I(n,t[0]),t[1]=I(r,t[1]),t[2]=I(i,t[2]),t[3]=I(o,t[3]),t[4]=I(u,t[4]),t[5]=I(a,t[5]),t[6]=I(s,t[6]),t[7]=I(c,t[7]),t}var q=function(t){_inherits(r,f);var n=_createSuper(r);function r(t,i,o){var u;if(_classCallCheck(this,r), +;function Z(e){return"SHA-384"===e?[new B(3418070365,s[0]),new B(1654270250,s[1]),new B(2438529370,s[2]),new B(355462360,s[3]),new B(1731405415,s[4]),new B(41048885895,s[5]),new B(3675008525,s[6]),new B(1203062813,s[7])]:[new B(o[0],4089235720),new B(o[1],2227873595),new B(o[2],4271175723),new B(o[3],1595750129),new B(o[4],2917565137),new B(o[5],725511199),new B(o[6],4215389547),new B(o[7],327033209)]}function j(e,t){var n,r,i,o,u,a,s,f,c,h,l,w,p,d,v,g=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],a=t[5],s=t[6],f=t[7],l=0;l<80;l+=1)l<16?(w=2*l,g[l]=new B(e[w],e[w+1])):g[l]=X(_(g[l-2]),g[l-7],O(g[l-15]),g[l-16]),c=z(f,P(u),(d=a,v=s,new B((p=u).Y&d.Y^~p.Y&v.Y,p.N&d.N^~p.N&v.N)),V[l],g[l]),h=I(N(n),Y(n,r,i)),f=s,s=a,a=u,u=I(o,c),o=i,i=r,r=n,n=I(c,h);return t[0]=I(n,t[0]),t[1]=I(r,t[1]),t[2]=I(i,t[2]),t[3]=I(o,t[3]),t[4]=I(u,t[4]),t[5]=I(a,t[5]),t[6]=I(s,t[6]),t[7]=I(f,t[7]),t}var q=function(t){_inherits(r,f);var n=_createSuper(r);function r(t,i,o){var u;if(_classCallCheck(this,r), "SHA-384"!==t&&"SHA-512"!==t)throw new Error(h);var a=o||{};return(u=n.call(this,t,i,o)).T=u.k,u.L=!0,u.K=-1,u.m=e(u.t,u.i,u.K),u.R=j,u.g=function(e){return e.slice()},u.B=Z,u.F=function(e,n,r,i){return function(e,t,n,r,i){for(var o,u=31+(t+129>>>10<<5),a=t+n;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o>>1)%5][(r>>>1)/5|0]=x(t[(r>>>1)%5][(r>>>1)/5|0],new B(e[r+1],e[r]));for(n=0;n<24;n+=1){for(o=J(),r=0;r<5;r+=1)h[r]=(u=t[r][0],a=t[r][1],s=t[r][2], -c=t[r][3],f=t[r][4],new B(u.Y^a.Y^s.Y^c.Y^f.Y,u.N^a.N^s.N^c.N^f.N));for(r=0;r<5;r+=1)l[r]=x(h[(r+4)%5],L(h[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(t[r][i],l[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)o[i][(2*r+3*i)%5]=L(t[r][i],G[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(o[r][i],new B(~o[(r+1)%5][i].Y&o[(r+2)%5][i].Y,~o[(r+1)%5][i].N&o[(r+2)%5][i].N));t[0][0]=x(t[0][0],D[n])}return t}function $(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function tt(e){return u($(e.binLen),e)}function nt(e,t){var n,r=$(t),i=t>>>2,o=(i-(r=u(r,e)).value.length%i)%i;for(n=0;n>>5,l=t>>>5;for(a=0;a=i;a+=h)r=W(e.slice(a,a+h),r),t-=i;for(e=e.slice(a),t%=i;e.length>>3)>>2]^=o<=u));)f.push(s.Y),0==64*(c+=1)%i&&(W(null,r),c=0);return f}(e,t,0,r,s,a,i)},f.hmacKey&&u.M(c("hmacKey",f.hmacKey,u.K)),u}return _createClass(r,[{key:"_",value:function(e,t){var n=function(e){var t=e||{};return{funcName:c("funcName",t.funcName,1,{value:[],binLen:0}),customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);var r=u(tt(n.funcName),tt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){for(var i=nt(r,this.p>>>3),o=0;o>>5)this.C=this.R(i.slice(o,o+(this.p>>>5)),this.C),this.l+=this.p;return 4}return 31}},{key:"I",value:function(e){var t=function(e){var t=e||{};return{kmacKey:c("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._(e,t.funcName) +}(),D=[new B(0,1),new B(0,32898),new B(2147483648,32906),new B(2147483648,2147516416),new B(0,32907),new B(0,2147483649),new B(2147483648,2147516545),new B(2147483648,32777),new B(0,138),new B(0,136),new B(0,2147516425),new B(0,2147483658),new B(0,2147516555),new B(2147483648,139),new B(2147483648,32905),new B(2147483648,32771),new B(2147483648,32770),new B(2147483648,128),new B(0,32778),new B(2147483648,2147483658),new B(2147483648,2147516545),new B(2147483648,32896),new B(0,2147483649),new B(2147483648,2147516424)],G=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function J(e){var t,n=[];for(t=0;t<5;t+=1)n[t]=[new B(0,0),new B(0,0),new B(0,0),new B(0,0),new B(0,0)];return n}function Q(e){var t,n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function W(e,t){var n,r,i,o,u,a,s,f,c,h=[],l=[];if(null!==e)for(r=0;r>>1)%5][(r>>>1)/5|0]=x(t[(r>>>1)%5][(r>>>1)/5|0],new B(e[r+1],e[r]));for(n=0;n<24;n+=1){for(o=J(),r=0;r<5;r+=1)h[r]=(u=t[r][0],a=t[r][1],s=t[r][2], +f=t[r][3],c=t[r][4],new B(u.Y^a.Y^s.Y^f.Y^c.Y,u.N^a.N^s.N^f.N^c.N));for(r=0;r<5;r+=1)l[r]=x(h[(r+4)%5],L(h[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(t[r][i],l[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)o[i][(2*r+3*i)%5]=L(t[r][i],G[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(o[r][i],new B(~o[(r+1)%5][i].Y&o[(r+2)%5][i].Y,~o[(r+1)%5][i].N&o[(r+2)%5][i].N));t[0][0]=x(t[0][0],D[n])}return t}function $(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function tt(e){return u($(e.binLen),e)}function nt(e,t){var n,r=$(t),i=t>>>2,o=(i-(r=u(r,e)).value.length%i)%i;for(n=0;n>>5,l=t>>>5;for(a=0;a=i;a+=h)r=W(e.slice(a,a+h),r),t-=i;for(e=e.slice(a),t%=i;e.length>>3)>>2]^=o<=u));)c.push(s.Y),0==64*(f+=1)%i&&(W(null,r),f=0);return c}(e,t,0,r,s,a,i)},f.hmacKey&&u.M(c("hmacKey",f.hmacKey,u.K)),u}return _createClass(r,[{key:"_",value:function(e,t){var n=function(e){var t=e||{};return{funcName:c("funcName",t.funcName,1,{value:[],binLen:0}),customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);var r=u(tt(n.funcName),tt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){for(var i=nt(r,this.p>>>3),o=0;o>>5)this.C=this.R(i.slice(o,o+(this.p>>>5)),this.C),this.l+=this.p;return 4}return 31}},{key:"I",value:function(e){var t=function(e){var t=e||{};return{kmacKey:c("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._(e,t.funcName) ;for(var n=nt(tt(t.kmacKey),this.p>>>3),r=0;r>>5)this.C=this.R(n.slice(r,r+(this.p>>>5)),this.C),this.l+=this.p;this.A=!0}},{key:"X",value:function(e){var t=u({value:this.o.slice(),binLen:this.h},function(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r>>2]|=n<<8*r,r+=1);return i[(r=0!==r?r:1)>>2]|=r<<8*r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}(e.outputLen));return this.F(t.value,t.binLen,this.l,this.g(this.C),e.outputLen)}}]),r}(),_default=function(){function e(t,n,r){if(_classCallCheck(this,e),"SHA-1"==t)this.O=new K(t,n,r);else if("SHA-224"==t||"SHA-256"==t)this.O=new g(t,n,r);else if("SHA-384"==t||"SHA-512"==t)this.O=new q(t,n,r);else{if("SHA3-224"!=t&&"SHA3-256"!=t&&"SHA3-384"!=t&&"SHA3-512"!=t&&"SHAKE128"!=t&&"SHAKE256"!=t&&"CSHAKE128"!=t&&"CSHAKE256"!=t&&"KMAC128"!=t&&"KMAC256"!=t)throw new Error(h);this.O=new et(t,n,r)}}return _createClass(e,[{key:"update",value:function(e){this.O.update(e)}},{key:"getHash", -value:function(e,t){return this.O.getHash(e,t)}},{key:"setHMACKey",value:function(e,t,n){this.O.setHMACKey(e,t,n)}},{key:"getHMAC",value:function(e,t){return this.O.getHMAC(e,t)}}]),e}(),magicalGlobalThis=function(){var e;if("object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis)))e=globalThis;else{Object.defineProperty(Object.prototype,"__OTPAUTH_GLOBALTHIS__",{get:function(){return this},configurable:!0});try{e=__OTPAUTH_GLOBALTHIS__}finally{delete Object.prototype.__OTPAUTH_GLOBALTHIS__}}return void 0===e&&("undefined"!=typeof self?e=self:"undefined"!=typeof window?e=window:"undefined"!=typeof global&&(e=global)),e}(),isNode="[object process]"===Object.prototype.toString.call(magicalGlobalThis.process),nodeRequire=isNode?eval("require"):function(){},NodeBuffer$1=isNode?magicalGlobalThis.Buffer:void 0,NodeCrypto$2=isNode?nodeRequire("crypto"):void 0,OPENSSL_TO_JSSHA_ALGO={SHA1:"SHA-1",SHA224:"SHA-224",SHA256:"SHA-256",SHA384:"SHA-384",SHA512:"SHA-512","SHA3-224":"SHA3-224", -"SHA3-256":"SHA3-256","SHA3-384":"SHA3-384","SHA3-512":"SHA3-512"},hmacDigest=function(e,t,n){if(isNode){var r=NodeCrypto$2.createHmac(e,NodeBuffer$1.from(t));return r.update(NodeBuffer$1.from(n)),r.digest().buffer}var i=OPENSSL_TO_JSSHA_ALGO[e.toUpperCase()];if(void 0===i)throw new TypeError("Unknown hash function");var o=new _default(i,"ARRAYBUFFER");return o.setHMACKey(t,"ARRAYBUFFER"),o.update(n),o.getHMAC("ARRAYBUFFER")},pad=function(e,t){for(var n="",r=t-String(e).length;r-- >0;)n+="0";return"".concat(n).concat(e)},ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",base32ToBuf=function(e){for(var t=e.toUpperCase().replace(/=+$/,""),n=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(n),i=0,o=0,u=0,a=0;a=8&&(r[u++]=o>>>i-8&255,i-=8)}return n},base32FromBuf=function(e){for(var t=new Uint8Array(e),n=0,r=0,i="",o=0;o=5;)i+=ALPHABET[r>>>n-5&31],n-=5 -;return n>0&&(i+=ALPHABET[r<<5-n&31]),i},hexFromBuf=function(e){for(var t=new Uint8Array(e),n="",r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.buffer,r=t.size,i=void 0===r?20:r;_classCallCheck(this,e),this.buffer=void 0===n?randomBytes(i):n}return _createClass(e,[{key:"latin1",get:function(){return Object.defineProperty(this,"latin1",{enumerable:!0,value:latin1FromBuf(this.buffer)}),this.latin1}},{key:"utf8",get:function(){return Object.defineProperty(this,"utf8",{enumerable:!0,value:utf8FromBuf(this.buffer)}),this.utf8}},{key:"base32",get:function(){return Object.defineProperty(this,"base32",{enumerable:!0,value:base32FromBuf(this.buffer)}),this.base32}},{key:"hex",get:function(){ -return Object.defineProperty(this,"hex",{enumerable:!0,value:hexFromBuf(this.buffer)}),this.hex}}],[{key:"fromLatin1",value:function(t){return new e({buffer:latin1ToBuf(t)})}},{key:"fromUTF8",value:function(t){return new e({buffer:utf8ToBuf(t)})}},{key:"fromBase32",value:function(t){return new e({buffer:base32ToBuf(t)})}},{key:"fromHex",value:function(t){return new e({buffer:hexToBuf(t)})}}]),e}(),NodeBuffer=isNode?magicalGlobalThis.Buffer:void 0,NodeCrypto=isNode?nodeRequire("crypto"):void 0,timingSafeEqual=function(e,t){if(isNode)return NodeCrypto.timingSafeEqual(NodeBuffer.from(e),NodeBuffer.from(t));if(e.length!==t.length)throw new TypeError("Input strings must have the same length");for(var n=-1,r=0;++n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,c=void 0===s?e.defaults.algorithm:s,f=t.digits,h=void 0===f?e.defaults.digits:f,l=t.counter,w=void 0===l?e.defaults.counter:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=c.toUpperCase(),this.digits=h,this.counter=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.counter,r=void 0===n?this.counter++:n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:r})}},{key:"validate",value:function(t){var n=t.token,r=t.counter,i=void 0===r?this.counter:r,o=t.window;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:i,window:o})}},{key:"toString",value:function(){var e=encodeURIComponent -;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"counter=".concat(e(this.counter))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=void 0===r?e.defaults.algorithm:r,o=t.digits,u=void 0===o?e.defaults.digits:o,a=t.counter,s=void 0===a?e.defaults.counter:a,c=new Uint8Array(hmacDigest(i,n.buffer,uintToBuf(s))),f=15&c[c.byteLength-1],h=((127&c[f])<<24|(255&c[f+1])<<16|(255&c[f+2])<<8|255&c[f+3])%Math.pow(10,u);return pad(h,u)}},{key:"validate",value:function(t){var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.counter,a=void 0===u?e.defaults.counter:u,s=t.window,c=void 0===s?e.defaults.window:s;if(n.length!==o)return null -;for(var f=null,h=a-c;h<=a+c;++h){var l=e.generate({secret:r,algorithm:i,digits:o,counter:h});timingSafeEqual(n,l)&&(f=h-a)}return f}}]),e}(),TOTP=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,c=void 0===s?e.defaults.algorithm:s,f=t.digits,h=void 0===f?e.defaults.digits:f,l=t.period,w=void 0===l?e.defaults.period:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=c.toUpperCase(),this.digits=h,this.period=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.timestamp,r=void 0===n?Date.now():n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r})}},{key:"validate",value:function(t){var n=t.token,r=t.timestamp,i=t.window +value:function(e,t){return this.O.getHash(e,t)}},{key:"setHMACKey",value:function(e,t,n){this.O.setHMACKey(e,t,n)}},{key:"getHMAC",value:function(e,t){return this.O.getHMAC(e,t)}}]),e}(),globalThis=function(){if("object"===_typeof(globalThis))return globalThis;Object.defineProperty(Object.prototype,"__GLOBALTHIS__",{get:function(){return this},configurable:!0});try{if("undefined"!=typeof __GLOBALTHIS__)return __GLOBALTHIS__}finally{delete Object.prototype.__GLOBALTHIS__}return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0}(),isNode="[object process]"===Object.prototype.toString.call(globalThis.process),nodeRequire=isNode?eval("require"):function(){},NodeBuffer$1=isNode?globalThis.Buffer:void 0,NodeCrypto$2=isNode?nodeRequire("crypto"):void 0,OPENSSL_TO_JSSHA_ALGO={SHA1:"SHA-1",SHA224:"SHA-224",SHA256:"SHA-256",SHA384:"SHA-384",SHA512:"SHA-512","SHA3-224":"SHA3-224","SHA3-256":"SHA3-256","SHA3-384":"SHA3-384","SHA3-512":"SHA3-512" +},hmacDigest=function(e,t,n){if(isNode){var r=NodeCrypto$2.createHmac(e,NodeBuffer$1.from(t));return r.update(NodeBuffer$1.from(n)),r.digest().buffer}var i=OPENSSL_TO_JSSHA_ALGO[e.toUpperCase()];if(void 0===i)throw new TypeError("Unknown hash function");var o=new _default(i,"ARRAYBUFFER");return o.setHMACKey(t,"ARRAYBUFFER"),o.update(n),o.getHMAC("ARRAYBUFFER")},pad=function(e,t){for(var n="",r=t-String(e).length;r-- >0;)n+="0";return"".concat(n).concat(e)},ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",base32ToBuf=function(e){for(var t=e.toUpperCase().replace(/=+$/,""),n=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(n),i=0,o=0,u=0,a=0;a=8&&(r[u++]=o>>>i-8&255,i-=8)}return n},base32FromBuf=function(e){for(var t=new Uint8Array(e),n=0,r=0,i="",o=0;o=5;)i+=ALPHABET[r>>>n-5&31],n-=5;return n>0&&(i+=ALPHABET[r<<5-n&31]),i},hexToBuf=function(e){ +for(var t=new ArrayBuffer(e.length/2),n=new Uint8Array(t),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.buffer,r=t.size,i=void 0===r?20:r;_classCallCheck(this,e),this.buffer=void 0===n?randomBytes(i):n}return _createClass(e,[{key:"latin1",get:function(){return Object.defineProperty(this,"latin1",{enumerable:!0,value:latin1FromBuf(this.buffer)}),this.latin1}},{key:"utf8",get:function(){return Object.defineProperty(this,"utf8",{enumerable:!0,value:utf8FromBuf(this.buffer)}),this.utf8}},{key:"base32",get:function(){return Object.defineProperty(this,"base32",{enumerable:!0,value:base32FromBuf(this.buffer)}),this.base32}},{key:"hex",get:function(){ +return Object.defineProperty(this,"hex",{enumerable:!0,value:hexFromBuf(this.buffer)}),this.hex}}],[{key:"fromLatin1",value:function(t){return new e({buffer:latin1ToBuf(t)})}},{key:"fromUTF8",value:function(t){return new e({buffer:utf8ToBuf(t)})}},{key:"fromBase32",value:function(t){return new e({buffer:base32ToBuf(t)})}},{key:"fromHex",value:function(t){return new e({buffer:hexToBuf(t)})}}]),e}(),NodeBuffer=isNode?globalThis.Buffer:void 0,NodeCrypto=isNode?nodeRequire("crypto"):void 0,timingSafeEqual=function(e,t){if(isNode)return NodeCrypto.timingSafeEqual(NodeBuffer.from(e),NodeBuffer.from(t));if(e.length!==t.length)throw new TypeError("Input strings must have the same length");for(var n=-1,r=0;++n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,h=void 0===c?e.defaults.digits:c,l=t.counter,w=void 0===l?e.defaults.counter:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=h,this.counter=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.counter,r=void 0===n?this.counter++:n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:r})}},{key:"validate",value:function(t){var n=t.token,r=t.counter,i=void 0===r?this.counter:r,o=t.window;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:i,window:o})}},{key:"toString",value:function(){var e=encodeURIComponent +;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"counter=".concat(e(this.counter))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=void 0===r?e.defaults.algorithm:r,o=t.digits,u=void 0===o?e.defaults.digits:o,a=t.counter,s=void 0===a?e.defaults.counter:a,f=new Uint8Array(hmacDigest(i,n.buffer,uintToBuf(s))),c=15&f[f.byteLength-1],h=((127&f[c])<<24|(255&f[c+1])<<16|(255&f[c+2])<<8|255&f[c+3])%Math.pow(10,u);return pad(h,u)}},{key:"validate",value:function(t){var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.counter,a=void 0===u?e.defaults.counter:u,s=t.window,f=void 0===s?e.defaults.window:s;if(n.length!==o)return null +;for(var c=null,h=a-f;h<=a+f;++h){var l=e.generate({secret:r,algorithm:i,digits:o,counter:h});timingSafeEqual(n,l)&&(c=h-a)}return c}}]),e}(),TOTP=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,h=void 0===c?e.defaults.digits:c,l=t.period,w=void 0===l?e.defaults.period:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=h,this.period=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.timestamp,r=void 0===n?Date.now():n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r})}},{key:"validate",value:function(t){var n=t.token,r=t.timestamp,i=t.window ;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r,window:i})}},{key:"toString",value:function(){var e=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"period=".concat(e(this.period))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,period:30,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=t.digits,o=t.period,u=void 0===o?e.defaults.period:o,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:n,algorithm:r,digits:i,counter:Math.floor(s/1e3/u)})}},{key:"validate",value:function(t){ -var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.period,a=void 0===u?e.defaults.period:u,s=t.timestamp,c=void 0===s?Date.now():s,f=t.window;return HOTP.validate({token:n,secret:r,algorithm:i,digits:o,counter:Math.floor(c/1e3/a),window:f})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var n,r=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var n=t.split(/=(.*)/,2).map(decodeURIComponent),r=n[0].toLowerCase(),i=n[1],o=e;return o[r]=i,o}),{}),u={};if("hotp"===r){if(n=HOTP, +var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.period,a=void 0===u?e.defaults.period:u,s=t.timestamp,f=void 0===s?Date.now():s,c=t.window;return HOTP.validate({token:n,secret:r,algorithm:i,digits:o,counter:Math.floor(f/1e3/a),window:c})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var n,r=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var n=t.split(/=(.*)/,2).map(decodeURIComponent),r=n[0].toLowerCase(),i=n[1],o=e;return o[r]=i,o}),{}),u={};if("hotp"===r){if(n=HOTP, void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");u.counter=parseInt(o.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");u.period=parseInt(o.period,10)}}if(2===i.length)if(u.label=i[1],void 0===o.issuer)u.issuer=i[0];else{if(o.issuer!==i[0])throw new TypeError("Invalid 'issuer' parameter");u.issuer=o.issuer}else u.label=i[0],void 0!==o.issuer&&(u.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(u.secret=o.secret,void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");u.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter");u.digits=parseInt(o.digits,10)}return new n(u)}},{key:"stringify", -value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.0";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.1";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 3461a272..8e5df216 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 */\nexport const uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nexport const uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport default nodeRequire;\n","import jsSHA from 'jssha';\n\nimport globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport default hmacDigest;\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport default pad;\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nexport const base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n","/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nexport const hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\n/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nexport const latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n","import globalThis from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nexport const utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n","import globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport default randomBytes;\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport randomBytes from './utils/crypto/random-bytes';\n\nexport default class Secret {\n\t/**\n\t * Secret key object.\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n","import globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport default timingSafeEqual;\n","import { uintToBuf } from './utils/encoding/uint';\nimport hmacDigest from './utils/crypto/hmac-digest';\nimport pad from './utils/pad';\nimport Secret from './secret';\nimport timingSafeEqual from './utils/crypto/timing-safe-equal';\n\nexport default class HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * HOTP: An HMAC-based One-time Password Algorithm.\n\t * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n","import HOTP from './hotp';\nimport Secret from './secret';\n\nexport default class TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * TOTP: Time-Based One-Time Password Algorithm.\n\t * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n","import HOTP from './hotp';\nimport TOTP from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nexport default class URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport default 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","magicalGlobalThis","magic","globalThis","Object","defineProperty","prototype","get","this","configurable","__OTPAUTH_GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexFromBuf","hex","hexToBuf","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":";;;48BAKO,IAAMA,UAAY,SAACC;QACnBC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACR,IAARD,EADmBC,IAEvBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGDJ,GCbFM,EAAS,mEA4Pf,SAASC,EACPL,EACAM,EACAC,EACAC,OAEIL,EAAGM,EAAWC,EAGZC,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAIH,EAAIc,OAAQX,GAAK,EAE/BM,GADAC,EAAaP,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI,KAAK,GAEdJ,EAAOF,IAAcT,EAAIG,IAAO,GAAKU,EAAgBL,GAAgBE,EAAa,UAG7E,CAAEM,MAAOL,EAAQM,OAAqB,EAAbjB,EAAIc,OAAaP,GAAAA,SA6BnCW,EACdC,EACAC,EACAZ,UAIQY,OACD,WAEA,cAEA,8BAIG,IAAIC,MAAM,qDAIZF,OACD,aAOI,SAAUG,EAAaC,EAAwBC,UA7N5D,SACEF,EACAhB,EACAC,EACAC,OAEIL,EAAGN,EAAKY,EAAWC,KAEnB,GAAMY,EAAIR,OAAS,EACrB,MAAM,IAAIO,MAAM,qDAIZV,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAImB,EAAIR,OAAQX,GAAK,EAAG,IAClCN,EAAM4B,SAASH,EAAII,OAAOvB,EAAG,GAAI,IAC5BwB,MAAM9B,GAQT,MAAM,I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AS2C,EAAU3C,YAK3BkD,EAAOhD,MAAQqC,EAAS,QACQ,IAArBI,EAAU3C,SACpBkD,EAAOlD,OAAS2C,EAAU3C,gBAKI,IAArB2C,EAAUxC,SAA0BqB,aAAa2B,KAAKR,EAAUxC,cAGpE,IAAI/C,UAAU,4CAFpB8F,EAAO/C,OAASwC,EAAUxC,YAMQ,IAAxBwC,EAAUjG,UAA2B,KAC3C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG5B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOC,IAArBiG,EAAUlF,OAAwB,KACxCkE,uBAAuBwB,KAAKR,EAAUlF,cAGnC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAAS1E,SAAS4J,EAAUlF,OAAQ,WAMtC,IAAI2E,EAAIc;MAQhB,SAAiBrC,MACZA,aAAed,MAAQc,aAAeG,YAClCH,EAAI9E,iBAGN,IAAIqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.esm.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport { nodeRequire };\n","import jsSHA from 'jssha';\n\nimport { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport { hmacDigest };\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport { pad };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nconst base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n\nexport { base32ToBuf, base32FromBuf };\n","/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nconst hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\nexport { hexToBuf, hexFromBuf };\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nconst latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n\nexport { latin1ToBuf, latin1FromBuf };\n","import { globalThis } from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nconst utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n\nexport { utf8ToBuf, utf8FromBuf };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport { randomBytes };\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport { randomBytes } from './utils/crypto/random-bytes';\n\n/**\n * OTP secret key.\n */\nclass Secret {\n\t/**\n\t * Creates a secret key object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n\nexport { Secret };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from './utils/encoding/uint';\nimport { hmacDigest } from './utils/crypto/hmac-digest';\nimport { pad } from './utils/pad';\nimport { Secret } from './secret';\nimport { timingSafeEqual } from './utils/crypto/timing-safe-equal';\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates an HOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n\nexport { HOTP };\n","import { HOTP } from './hotp';\nimport { Secret } from './secret';\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates a TOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n\nexport { TOTP };\n","import { HOTP } from './hotp';\nimport { TOTP } from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;48BAKA,IAAMA,UAAY,SAACC;QACZC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACR,IAARD,EADmBC,IAEvBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGDJ,GCbFM,EAAS,mEA4Pf,SAASC,EACPL,EACAM,EACAC,EACAC,OAEIL,EAAGM,EAAWC,EAGZC,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAIH,EAAIc,OAAQX,GAAK,EAE/BM,GADAC,EAAaP,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI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--- a/dist/otpauth.umd.js +++ b/dist/otpauth.umd.js @@ -1,4 +1,4 @@ -/*! otpauth v7.0.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.1 | (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) { @@ -1214,14 +1214,11 @@ * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} */ - var magicalGlobalThis = function () { - /* eslint-disable no-extend-native, no-undef, no-restricted-globals */ - var magic; - - if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === 'object') { - magic = globalThis; - } else { - Object.defineProperty(Object.prototype, '__OTPAUTH_GLOBALTHIS__', { + var globalThis = function () { + // @ts-ignore + if (_typeof(globalThis) === 'object') return globalThis;else { + // eslint-disable-next-line no-extend-native + Object.defineProperty(Object.prototype, '__GLOBALTHIS__', { get: function get() { return this; }, @@ -1230,26 +1227,20 @@ try { // @ts-ignore - magic = __OTPAUTH_GLOBALTHIS__; + // eslint-disable-next-line no-undef + if (typeof __GLOBALTHIS__ !== 'undefined') return __GLOBALTHIS__; } finally { // @ts-ignore - delete Object.prototype.__OTPAUTH_GLOBALTHIS__; + delete Object.prototype.__GLOBALTHIS__; } - } + } // Still unable to determine "globalThis", fall back to a naive method. - if (typeof magic === 'undefined') { - // Still unable to determine "globalThis", fall back to a naive method. - if (typeof self !== 'undefined') { - magic = self; - } else if (typeof window !== 'undefined') { - magic = window; - } else if (typeof global !== 'undefined') { - magic = global; - } - } + /* eslint-disable no-undef, no-restricted-globals */ - return magic; + if (typeof self !== 'undefined') return self;else if (typeof window !== 'undefined') return window;else if (typeof global !== 'undefined') return global; /* eslint-enable */ + + return undefined; }(); /** @@ -1257,7 +1248,7 @@ * @type {boolean} */ - var isNode = Object.prototype.toString.call(magicalGlobalThis.process) === '[object process]'; + var isNode = Object.prototype.toString.call(globalThis.process) === '[object process]'; /** * Dynamically import Node.js modules ("eval" is used to prevent bundlers from including the module). @@ -1269,7 +1260,7 @@ var nodeRequire = isNode // eslint-disable-next-line no-eval ? eval('require') : function () {}; - var NodeBuffer$1 = isNode ? magicalGlobalThis.Buffer : undefined; + var NodeBuffer$1 = isNode ? globalThis.Buffer : undefined; var NodeCrypto$2 = isNode ? nodeRequire('crypto') : undefined; /** * OpenSSL to jsSHA algorithms. @@ -1379,6 +1370,7 @@ * @returns {string} Base32 string. */ + var base32FromBuf = function base32FromBuf(buf) { var arr = new Uint8Array(buf); var bits = 0; @@ -1402,11 +1394,28 @@ return str; }; + /** + * Converts a hexadecimal string to an ArrayBuffer. + * @param {string} str Hexadecimal string. + * @returns {ArrayBuffer} ArrayBuffer. + */ + var hexToBuf = function hexToBuf(str) { + var buf = new ArrayBuffer(str.length / 2); + var arr = new Uint8Array(buf); + + for (var i = 0; i < str.length; i += 2) { + arr[i / 2] = parseInt(str.substr(i, 2), 16); + } + + return buf; + }; /** * Converts an ArrayBuffer to a hexadecimal string. * @param {ArrayBuffer} buf ArrayBuffer. * @returns {string} Hexadecimal string. */ + + var hexFromBuf = function hexFromBuf(buf) { var arr = new Uint8Array(buf); var str = ''; @@ -1419,22 +1428,6 @@ return str.toUpperCase(); }; - /** - * Converts a hexadecimal string to an ArrayBuffer. - * @param {string} str Hexadecimal string. - * @returns {ArrayBuffer} ArrayBuffer. - */ - - var hexToBuf = function hexToBuf(str) { - var buf = new ArrayBuffer(str.length / 2); - var arr = new Uint8Array(buf); - - for (var i = 0; i < str.length; i += 2) { - arr[i / 2] = parseInt(str.substr(i, 2), 16); - } - - return buf; - }; /** * Converts a Latin-1 string to an ArrayBuffer. @@ -1457,6 +1450,7 @@ * @returns {string} Latin-1 string. */ + var latin1FromBuf = function latin1FromBuf(buf) { var arr = new Uint8Array(buf); var str = ''; @@ -1473,13 +1467,13 @@ * @type {TextEncoder|null} */ - var ENCODER = magicalGlobalThis.TextEncoder ? new magicalGlobalThis.TextEncoder('utf-8') : null; + var ENCODER = globalThis.TextEncoder ? new globalThis.TextEncoder('utf-8') : null; /** * TextDecoder instance. * @type {TextDecoder|null} */ - var DECODER = magicalGlobalThis.TextDecoder ? new magicalGlobalThis.TextDecoder('utf-8') : null; + var DECODER = globalThis.TextDecoder ? new globalThis.TextDecoder('utf-8') : null; /** * Converts an UTF-8 string to an ArrayBuffer. * @param {string} str String. @@ -1499,6 +1493,7 @@ * @returns {string} String. */ + var utf8FromBuf = function utf8FromBuf(buf) { if (!DECODER) { throw new Error('Encoding API not available'); @@ -1508,7 +1503,7 @@ }; var NodeCrypto$1 = isNode ? nodeRequire('crypto') : undefined; - var BrowserCrypto = !isNode ? magicalGlobalThis.crypto || magicalGlobalThis.msCrypto : undefined; + var BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined; /** * Returns random bytes. * @param {number} size Size. @@ -1527,10 +1522,13 @@ } }; + /** + * OTP secret key. + */ + var Secret = /*#__PURE__*/function () { /** - * Secret key object. - * @constructor + * Creates a secret key object. * @param {Object} [config] Configuration options. * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key. * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided. @@ -1663,7 +1661,7 @@ return Secret; }(); - var NodeBuffer = isNode ? magicalGlobalThis.Buffer : undefined; + var NodeBuffer = isNode ? globalThis.Buffer : undefined; var NodeCrypto = isNode ? nodeRequire('crypto') : undefined; /** * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values. @@ -1691,11 +1689,14 @@ } }; + /** + * HOTP: An HMAC-based One-time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} + */ + var HOTP = /*#__PURE__*/function () { /** - * HOTP: An HMAC-based One-time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} - * @constructor + * Creates an HOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -1911,11 +1912,14 @@ return HOTP; }(); + /** + * TOTP: Time-Based One-Time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} + */ + var TOTP = /*#__PURE__*/function () { /** - * TOTP: Time-Based One-Time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} - * @constructor + * Creates a TOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -2300,7 +2304,7 @@ * Library version. * @type {string} */ - var version = '7.0.0'; + var version = '7.0.1'; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.umd.min.js b/dist/otpauth.umd.min.js index 6264250e..f3057d86 100644 --- a/dist/otpauth.umd.min.js +++ b/dist/otpauth.umd.min.js @@ -1,11 +1,11 @@ -/*! otpauth v7.0.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v7.0.1 | (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})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n=0&&0!==r;i--)n[i]=255&r,r-=n[i],r/=256;return t},t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function n(e,t,n,r){var i,o,u,a=t||[0],s=(n=n||0)>>>3,f=-1===r?3:0;for(i=0;i>>2,a.length<=o&&a.push(0),a[o]|=e[i]<<8*(f+r*(u%4));return{value:a,binLen:8*e.length+n}}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(e,t,n){return function(e,t,n,r){var i,o,u,a;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");var s=t||[0],f=(n=n||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+f)>>>2;s.length<=u;)s.push(0);s[u]|=o<<8*(c+r*(a%4))}return{value:s,binLen:4*e.length+n}}(e,t,n,i)};case"TEXT":return function(e,t,n){return function(e,t,n,r,i){var o,u,a,s,f,c,l,h,w=0,p=n||[0],d=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,a=0;a(o=e.charCodeAt(a))?u.push(o):2048>o?(u.push(192|o>>>6),u.push(128|63&o)):55296>o||57344<=o?u.push(224|o>>>12,128|o>>>6&63,128|63&o):(a+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(a)),u.push(240|o>>>18,128|o>>>12&63,128|o>>>6&63,128|63&o)),s=0;s>>2;p.length<=f;)p.push(0);p[f]|=u[s]<<8*(l+i*(c%4)),w+=1}else for(l=-1===i?2:0,h="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,a=0;a>>8),f=(c=w+d)>>>2;p.length<=f;)p.push(0);p[f]|=o<<8*(l+i*(c%4)),w+=2}return{value:p,binLen:8*w+r}}(e,r,t,n,i)};case"B64":return function(e,n,r){return function(e,n,r,i){ -var o,u,a,s,f,c,l=0,h=n||[0],w=(r=r||0)>>>3,p=-1===i?3:0,d=e.indexOf("=");if(-1===e.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==d&&d>>2;l.length<=f;)l.push(0);l[f]|=(a>>>16-8*u&255)<<8*(p+i*(c%4)),h+=1}}return{value:l,binLen:8*h+r}}(e,n,r,i)};case"BYTES":return function(e,t,n){return function(e,t,n,r){var i,o,u,a,s=t||[0],f=(n=n||0)>>>3,c=-1===r?3:0;for(o=0;o>>2,s.length<=u&&s.push(0),s[u]|=i<<8*(c+r*(a%4));return{value:s,binLen:8*e.length+n}}(e,t,n,i)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e,t,r){return function(e,t,r,i){return n(new Uint8Array(e),t,r,i)}(e,t,r,i)};case"UINT8ARRAY":try{new Uint8Array(0) +}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e,t,r){return n(e,t,r,i)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function r(e,n,r,i){switch(e){case"HEX":return function(e){return function(e,t,n,r){var i,o,u="",a=t/8,s=-1===n?3:0;for(i=0;i>>2]>>>8*(s+n*(i%4)),u+="0123456789abcdef".charAt(o>>>4&15)+"0123456789abcdef".charAt(15&o);return r.outputUpper?u.toUpperCase():u}(e,n,r,i)};case"B64":return function(e){return function(e,n,r,i){var o,u,a,s,f,c="",h=n/8,l=-1===r?3:0;for(o=0;o>>2]:0,f=o+2>>2]:0,a=(e[o>>>2]>>>8*(l+r*(o%4))&255)<<16|(s>>>8*(l+r*((o+1)%4))&255)<<8|f>>>8*(l+r*((o+2)%4))&255,u=0;u<4;u+=1)c+=8*o+6*u<=n?t.charAt(a>>>6*(3-u)&63):i.b64Pad;return c}(e,n,r,i)};case"BYTES":return function(e){return function(e,t,n){var r,i,o="",u=t/8,a=-1===n?3:0;for(r=0;r>>2]>>>8*(a+n*(r%4))&255,o+=String.fromCharCode(i);return o}(e,n,r)};case"ARRAYBUFFER":try{ new ArrayBuffer(0)}catch(e){throw new Error("ARRAYBUFFER not supported by this environment")}return function(e){return function(e,t,n){var r,i=t/8,o=new ArrayBuffer(i),u=new Uint8Array(o),a=-1===n?3:0;for(r=0;r>>2]>>>8*(a+n*(r%4))&255;return o}(e,n,r)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(e){throw new Error("UINT8ARRAY not supported by this environment")}return function(e){return function(e,t,n){var r,i=t/8,o=-1===n?3:0,u=new Uint8Array(i);for(r=0;r>>2]>>>8*(o+n*(r%4))&255;return u}(e,n,r)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}} var i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],h="Chosen SHA variant is not supported";function u(e,t){var n,r,i=e.binLen>>>3,o=t.binLen>>>3,u=i<<3,a=4-i<<3;if(i%4!=0){ for(n=0;n>>2,e.value[r]|=t.value[n>>>2]<>>2]>>>a;return(e.value.length<<2)-4>=o+i&&e.value.pop(),{value:e.value,binLen:e.binLen+t.binLen}}return{value:e.value.concat(t.value),binLen:e.binLen+t.binLen}}function w(e){var t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function c(t,n,r,i){var o=t+" must include a value and format";if(!n){if(!i)throw new Error(o);return i}if(void 0===n.value||!n.format)throw new Error(o);return e(n.format,n.encoding||"UTF8",r)(n.value)}var f=function(){function t(e,n,r){ @@ -17,23 +17,23 @@ s=t[5],f=t[6],c=t[7],v=0;v<64;v+=1)B[v]=v<16?e[v]:d(l(g=B[v-2],17)^l(g,19)^A(g,1 }(f),B=function e(t,n){_classCallCheck(this,e),this.Y=t,this.N=n};function L(e,t){var n;return t>32?(n=64-t,new B(e.N<>>n,e.Y<>>n)):0!==t?(n=32-t,new B(e.Y<>>n,e.N<>>n)):e}function M(e,t){var n;return t<32?(n=32-t,new B(e.Y>>>t|e.N<>>t|e.Y<>>t|e.Y<>>t|e.N<>>t,e.N>>>t|e.Y<<32-t)}function Y(e,t,n){return new B(e.Y&t.Y^e.Y&n.Y^t.Y&n.Y,e.N&t.N^e.N&n.N^t.N&n.N)}function N(e){var t=M(e,28),n=M(e,34),r=M(e,39);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function I(e,t){var n,r;n=(65535&e.N)+(65535&t.N);var i=(65535&(r=(e.N>>>16)+(t.N>>>16)+(n>>>16)))<<16|65535&n;return n=(65535&e.Y)+(65535&t.Y)+(r>>>16),r=(e.Y>>>16)+(t.Y>>>16)+(n>>>16),new B((65535&r)<<16|65535&n,i)}function X(e,t,n,r){var i,o;i=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&r.N);var u=(65535&(o=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(r.N>>>16)+(i>>>16)))<<16|65535&i;return i=(65535&e.Y)+(65535&t.Y)+(65535&n.Y)+(65535&r.Y)+(o>>>16), o=(e.Y>>>16)+(t.Y>>>16)+(n.Y>>>16)+(r.Y>>>16)+(i>>>16),new B((65535&o)<<16|65535&i,u)}function z(e,t,n,r,i){var o,u;o=(65535&e.N)+(65535&t.N)+(65535&n.N)+(65535&r.N)+(65535&i.N);var a=(65535&(u=(e.N>>>16)+(t.N>>>16)+(n.N>>>16)+(r.N>>>16)+(i.N>>>16)+(o>>>16)))<<16|65535&o;return o=(65535&e.Y)+(65535&t.Y)+(65535&n.Y)+(65535&r.Y)+(65535&i.Y)+(u>>>16),u=(e.Y>>>16)+(t.Y>>>16)+(n.Y>>>16)+(r.Y>>>16)+(i.Y>>>16)+(o>>>16),new B((65535&u)<<16|65535&o,a)}function x(e,t){return new B(e.Y^t.Y,e.N^t.N)}function _(e){var t=M(e,19),n=M(e,61),r=k(e,6);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function O(e){var t=M(e,1),n=M(e,8),r=k(e,7);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)}function P(e){var t=M(e,14),n=M(e,18),r=M(e,41);return new B(t.Y^n.Y^r.Y,t.N^n.N^r.N)} var V=[new B(i[0],3609767458),new B(i[1],602891725),new B(i[2],3964484399),new B(i[3],2173295548),new B(i[4],4081628472),new B(i[5],3053834265),new B(i[6],2937671579),new B(i[7],3664609560),new B(i[8],2734883394),new B(i[9],1164996542),new B(i[10],1323610764),new B(i[11],3590304994),new B(i[12],4068182383),new B(i[13],991336113),new B(i[14],633803317),new B(i[15],3479774868),new B(i[16],2666613458),new B(i[17],944711139),new B(i[18],2341262773),new B(i[19],2007800933),new B(i[20],1495990901),new B(i[21],1856431235),new B(i[22],3175218132),new B(i[23],2198950837),new B(i[24],3999719339),new B(i[25],766784016),new B(i[26],2566594879),new B(i[27],3203337956),new B(i[28],1034457026),new B(i[29],2466948901),new B(i[30],3758326383),new B(i[31],168717936),new B(i[32],1188179964),new B(i[33],1546045734),new B(i[34],1522805485),new B(i[35],2643833823),new B(i[36],2343527390),new B(i[37],1014477480),new B(i[38],1206759142),new B(i[39],344077627),new B(i[40],1290863460),new B(i[41],3158454273),new B(i[42],3505952657),new B(i[43],106217008),new B(i[44],3606008344),new B(i[45],1432725776),new B(i[46],1467031594),new B(i[47],851169720),new B(i[48],3100823752),new B(i[49],1363258195),new B(i[50],3750685593),new B(i[51],3785050280),new B(i[52],3318307427),new B(i[53],3812723403),new B(i[54],2003034995),new B(i[55],3602036899),new B(i[56],1575990012),new B(i[57],1125592928),new B(i[58],2716904306),new B(i[59],442776044),new B(i[60],593698344),new B(i[61],3733110249),new B(i[62],2999351573),new B(i[63],3815920427),new B(3391569614,3928383900),new B(3515267271,566280711),new B(3940187606,3454069534),new B(4118630271,4000239992),new B(116418474,1914138554),new B(174292421,2731055270),new B(289380356,3203993006),new B(460393269,320620315),new B(685471733,587496836),new B(852142971,1086792851),new B(1017036298,365543100),new B(1126000580,2618297676),new B(1288033470,3409855158),new B(1501505948,4234509866),new B(1607167915,987167468),new B(1816402316,1246189591)] -;function Z(e){return"SHA-384"===e?[new B(3418070365,s[0]),new B(1654270250,s[1]),new B(2438529370,s[2]),new B(355462360,s[3]),new B(1731405415,s[4]),new B(41048885895,s[5]),new B(3675008525,s[6]),new B(1203062813,s[7])]:[new B(o[0],4089235720),new B(o[1],2227873595),new B(o[2],4271175723),new B(o[3],1595750129),new B(o[4],2917565137),new B(o[5],725511199),new B(o[6],4215389547),new B(o[7],327033209)]}function j(e,t){var n,r,i,o,u,a,s,f,c,l,h,w,p,d,v,g=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],a=t[5],s=t[6],f=t[7],h=0;h<80;h+=1)h<16?(w=2*h,g[h]=new B(e[w],e[w+1])):g[h]=X(_(g[h-2]),g[h-7],O(g[h-15]),g[h-16]),c=z(f,P(u),(d=a,v=s,new B((p=u).Y&d.Y^~p.Y&v.Y,p.N&d.N^~p.N&v.N)),V[h],g[h]),l=I(N(n),Y(n,r,i)),f=s,s=a,a=u,u=I(o,c),o=i,i=r,r=n,n=I(c,l);return t[0]=I(n,t[0]),t[1]=I(r,t[1]),t[2]=I(i,t[2]),t[3]=I(o,t[3]),t[4]=I(u,t[4]),t[5]=I(a,t[5]),t[6]=I(s,t[6]),t[7]=I(f,t[7]),t}var q=function(t){_inherits(r,t);var n=_createSuper(r);function r(t,i,o){var u;if(_classCallCheck(this,r), +;function Z(e){return"SHA-384"===e?[new B(3418070365,s[0]),new B(1654270250,s[1]),new B(2438529370,s[2]),new B(355462360,s[3]),new B(1731405415,s[4]),new B(41048885895,s[5]),new B(3675008525,s[6]),new B(1203062813,s[7])]:[new B(o[0],4089235720),new B(o[1],2227873595),new B(o[2],4271175723),new B(o[3],1595750129),new B(o[4],2917565137),new B(o[5],725511199),new B(o[6],4215389547),new B(o[7],327033209)]}function j(e,t){var n,r,i,o,u,a,s,f,c,h,l,w,p,d,v,g=[];for(n=t[0],r=t[1],i=t[2],o=t[3],u=t[4],a=t[5],s=t[6],f=t[7],l=0;l<80;l+=1)l<16?(w=2*l,g[l]=new B(e[w],e[w+1])):g[l]=X(_(g[l-2]),g[l-7],O(g[l-15]),g[l-16]),c=z(f,P(u),(d=a,v=s,new B((p=u).Y&d.Y^~p.Y&v.Y,p.N&d.N^~p.N&v.N)),V[l],g[l]),h=I(N(n),Y(n,r,i)),f=s,s=a,a=u,u=I(o,c),o=i,i=r,r=n,n=I(c,h);return t[0]=I(n,t[0]),t[1]=I(r,t[1]),t[2]=I(i,t[2]),t[3]=I(o,t[3]),t[4]=I(u,t[4]),t[5]=I(a,t[5]),t[6]=I(s,t[6]),t[7]=I(f,t[7]),t}var q=function(t){_inherits(r,t);var n=_createSuper(r);function r(t,i,o){var u;if(_classCallCheck(this,r), "SHA-384"!==t&&"SHA-512"!==t)throw new Error(h);var a=o||{};return(u=n.call(this,t,i,o)).T=u.k,u.L=!0,u.K=-1,u.m=e(u.t,u.i,u.K),u.R=j,u.g=function(e){return e.slice()},u.B=Z,u.F=function(e,n,r,i){return function(e,t,n,r,i){for(var o,u=31+(t+129>>>10<<5),a=t+n;e.length<=u;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[u]=4294967295&a,e[u-1]=a/4294967296|0,o=0;o>>1)%5][(r>>>1)/5|0]=x(t[(r>>>1)%5][(r>>>1)/5|0],new B(e[r+1],e[r]));for(n=0;n<24;n+=1){for(o=J(),r=0;r<5;r+=1)l[r]=(u=t[r][0],a=t[r][1], -s=t[r][2],f=t[r][3],c=t[r][4],new B(u.Y^a.Y^s.Y^f.Y^c.Y,u.N^a.N^s.N^f.N^c.N));for(r=0;r<5;r+=1)h[r]=x(l[(r+4)%5],L(l[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(t[r][i],h[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)o[i][(2*r+3*i)%5]=L(t[r][i],G[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(o[r][i],new B(~o[(r+1)%5][i].Y&o[(r+2)%5][i].Y,~o[(r+1)%5][i].N&o[(r+2)%5][i].N));t[0][0]=x(t[0][0],D[n])}return t}function $(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function tt(e){return u($(e.binLen),e)}function nt(e,t){var n,r=$(t),i=t>>>2,o=(i-(r=u(r,e)).value.length%i)%i;for(n=0;n>>5,h=t>>>5 -;for(a=0;a=i;a+=l)r=W(e.slice(a,a+l),r),t-=i;for(e=e.slice(a),t%=i;e.length>>3)>>2]^=o<=u));)c.push(s.Y),0==64*(f+=1)%i&&(W(null,r),f=0);return c}(e,t,0,r,s,a,i)},f.hmacKey&&u.M(c("hmacKey",f.hmacKey,u.K)),u}return _createClass(r,[{key:"_",value:function(e,t){var n=function(e){var t=e||{};return{funcName:c("funcName",t.funcName,1,{value:[],binLen:0}),customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);var r=u(tt(n.funcName),tt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){for(var i=nt(r,this.p>>>3),o=0;o>>5)this.C=this.R(i.slice(o,o+(this.p>>>5)),this.C),this.l+=this.p;return 4}return 31}},{key:"I",value:function(e){var t=function(e){var t=e||{};return{kmacKey:c("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:c("Customization",t.customization,1,{value:[],binLen:0})} +}(f),D=[new B(0,1),new B(0,32898),new B(2147483648,32906),new B(2147483648,2147516416),new B(0,32907),new B(0,2147483649),new B(2147483648,2147516545),new B(2147483648,32777),new B(0,138),new B(0,136),new B(0,2147516425),new B(0,2147483658),new B(0,2147516555),new B(2147483648,139),new B(2147483648,32905),new B(2147483648,32771),new B(2147483648,32770),new B(2147483648,128),new B(0,32778),new B(2147483648,2147483658),new B(2147483648,2147516545),new B(2147483648,32896),new B(0,2147483649),new B(2147483648,2147516424)],G=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function J(e){var t,n=[];for(t=0;t<5;t+=1)n[t]=[new B(0,0),new B(0,0),new B(0,0),new B(0,0),new B(0,0)];return n}function Q(e){var t,n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function W(e,t){var n,r,i,o,u,a,s,f,c,h=[],l=[];if(null!==e)for(r=0;r>>1)%5][(r>>>1)/5|0]=x(t[(r>>>1)%5][(r>>>1)/5|0],new B(e[r+1],e[r]));for(n=0;n<24;n+=1){for(o=J(),r=0;r<5;r+=1)h[r]=(u=t[r][0],a=t[r][1], +s=t[r][2],f=t[r][3],c=t[r][4],new B(u.Y^a.Y^s.Y^f.Y^c.Y,u.N^a.N^s.N^f.N^c.N));for(r=0;r<5;r+=1)l[r]=x(h[(r+4)%5],L(h[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(t[r][i],l[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)o[i][(2*r+3*i)%5]=L(t[r][i],G[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=x(o[r][i],new B(~o[(r+1)%5][i].Y&o[(r+2)%5][i].Y,~o[(r+1)%5][i].N&o[(r+2)%5][i].N));t[0][0]=x(t[0][0],D[n])}return t}function $(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function tt(e){return u($(e.binLen),e)}function nt(e,t){var n,r=$(t),i=t>>>2,o=(i-(r=u(r,e)).value.length%i)%i;for(n=0;n>>5,l=t>>>5 +;for(a=0;a=i;a+=h)r=W(e.slice(a,a+h),r),t-=i;for(e=e.slice(a),t%=i;e.length>>3)>>2]^=o<=u));)c.push(s.Y),0==64*(f+=1)%i&&(W(null,r),f=0);return c}(e,t,0,r,s,a,i)},f.hmacKey&&u.M(c("hmacKey",f.hmacKey,u.K)),u}return _createClass(r,[{key:"_",value:function(e,t){var n=function(e){var t=e||{};return{funcName:c("funcName",t.funcName,1,{value:[],binLen:0}),customization:c("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);var r=u(tt(n.funcName),tt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){for(var i=nt(r,this.p>>>3),o=0;o>>5)this.C=this.R(i.slice(o,o+(this.p>>>5)),this.C),this.l+=this.p;return 4}return 31}},{key:"I",value:function(e){var t=function(e){var t=e||{};return{kmacKey:c("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:c("Customization",t.customization,1,{value:[],binLen:0})} }(e||{});this._(e,t.funcName);for(var n=nt(tt(t.kmacKey),this.p>>>3),r=0;r>>5)this.C=this.R(n.slice(r,r+(this.p>>>5)),this.C),this.l+=this.p;this.A=!0}},{key:"X",value:function(e){var t=u({value:this.o.slice(),binLen:this.h},function(e){var t,n,r=0,i=[0,0],o=[4294967295&e,e/4294967296&2097151];for(t=6;t>=0;t--)0===(n=o[t>>2]>>>8*t&255)&&0===r||(i[r>>2]|=n<<8*r,r+=1);return i[(r=0!==r?r:1)>>2]|=r<<8*r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}(e.outputLen));return this.F(t.value,t.binLen,this.l,this.g(this.C),e.outputLen)}}]),r}(f),_default=function(){function e(t,n,r){if(_classCallCheck(this,e),"SHA-1"==t)this.O=new K(t,n,r);else if("SHA-224"==t||"SHA-256"==t)this.O=new g(t,n,r);else if("SHA-384"==t||"SHA-512"==t)this.O=new q(t,n,r);else{if("SHA3-224"!=t&&"SHA3-256"!=t&&"SHA3-384"!=t&&"SHA3-512"!=t&&"SHAKE128"!=t&&"SHAKE256"!=t&&"CSHAKE128"!=t&&"CSHAKE256"!=t&&"KMAC128"!=t&&"KMAC256"!=t)throw new Error(h);this.O=new et(t,n,r)}}return _createClass(e,[{key:"update",value:function(e){ -this.O.update(e)}},{key:"getHash",value:function(e,t){return this.O.getHash(e,t)}},{key:"setHMACKey",value:function(e,t,n){this.O.setHMACKey(e,t,n)}},{key:"getHMAC",value:function(e,t){return this.O.getHMAC(e,t)}}]),e}(),magicalGlobalThis=function(){var e;if("object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis)))e=globalThis;else{Object.defineProperty(Object.prototype,"__OTPAUTH_GLOBALTHIS__",{get:function(){return this},configurable:!0});try{e=__OTPAUTH_GLOBALTHIS__}finally{delete Object.prototype.__OTPAUTH_GLOBALTHIS__}}return void 0===e&&("undefined"!=typeof self?e=self:"undefined"!=typeof window?e=window:"undefined"!=typeof global&&(e=global)),e}(),isNode="[object process]"===Object.prototype.toString.call(magicalGlobalThis.process),nodeRequire=isNode?eval("require"):function(){},NodeBuffer$1=isNode?magicalGlobalThis.Buffer:void 0,NodeCrypto$2=isNode?nodeRequire("crypto"):void 0,OPENSSL_TO_JSSHA_ALGO={SHA1:"SHA-1",SHA224:"SHA-224",SHA256:"SHA-256",SHA384:"SHA-384",SHA512:"SHA-512", -"SHA3-224":"SHA3-224","SHA3-256":"SHA3-256","SHA3-384":"SHA3-384","SHA3-512":"SHA3-512"},hmacDigest=function(e,t,n){if(isNode){var r=NodeCrypto$2.createHmac(e,NodeBuffer$1.from(t));return r.update(NodeBuffer$1.from(n)),r.digest().buffer}var i=OPENSSL_TO_JSSHA_ALGO[e.toUpperCase()];if(void 0===i)throw new TypeError("Unknown hash function");var o=new _default(i,"ARRAYBUFFER");return o.setHMACKey(t,"ARRAYBUFFER"),o.update(n),o.getHMAC("ARRAYBUFFER")},pad=function(e,t){for(var n="",r=t-String(e).length;r-- >0;)n+="0";return"".concat(n).concat(e)},ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",base32ToBuf=function(e){for(var t=e.toUpperCase().replace(/=+$/,""),n=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(n),i=0,o=0,u=0,a=0;a=8&&(r[u++]=o>>>i-8&255,i-=8)}return n},base32FromBuf=function(e){for(var t=new Uint8Array(e),n=0,r=0,i="",o=0;o=5;)i+=ALPHABET[r>>>n-5&31],n-=5;return n>0&&(i+=ALPHABET[r<<5-n&31]),i},hexFromBuf=function(e){for(var t=new Uint8Array(e),n="",r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.buffer,r=t.size,i=void 0===r?20:r;_classCallCheck(this,e),this.buffer=void 0===n?randomBytes(i):n}return _createClass(e,[{key:"latin1",get:function(){return Object.defineProperty(this,"latin1",{enumerable:!0,value:latin1FromBuf(this.buffer)}),this.latin1}},{key:"utf8",get:function(){return Object.defineProperty(this,"utf8",{enumerable:!0,value:utf8FromBuf(this.buffer)}),this.utf8}},{key:"base32",get:function(){return Object.defineProperty(this,"base32",{enumerable:!0,value:base32FromBuf(this.buffer)}),this.base32}},{key:"hex",get:function(){ -return Object.defineProperty(this,"hex",{enumerable:!0,value:hexFromBuf(this.buffer)}),this.hex}}],[{key:"fromLatin1",value:function(t){return new e({buffer:latin1ToBuf(t)})}},{key:"fromUTF8",value:function(t){return new e({buffer:utf8ToBuf(t)})}},{key:"fromBase32",value:function(t){return new e({buffer:base32ToBuf(t)})}},{key:"fromHex",value:function(t){return new e({buffer:hexToBuf(t)})}}]),e}(),NodeBuffer=isNode?magicalGlobalThis.Buffer:void 0,NodeCrypto=isNode?nodeRequire("crypto"):void 0,timingSafeEqual=function(e,t){if(isNode)return NodeCrypto.timingSafeEqual(NodeBuffer.from(e),NodeBuffer.from(t));if(e.length!==t.length)throw new TypeError("Input strings must have the same length");for(var n=-1,r=0;++n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,l=void 0===c?e.defaults.digits:c,h=t.counter,w=void 0===h?e.defaults.counter:h;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=l,this.counter=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.counter,r=void 0===n?this.counter++:n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:r})}},{key:"validate",value:function(t){var n=t.token,r=t.counter,i=void 0===r?this.counter:r,o=t.window;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:i,window:o})}},{key:"toString",value:function(){var e=encodeURIComponent -;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"counter=".concat(e(this.counter))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=void 0===r?e.defaults.algorithm:r,o=t.digits,u=void 0===o?e.defaults.digits:o,a=t.counter,s=void 0===a?e.defaults.counter:a,f=new Uint8Array(hmacDigest(i,n.buffer,uintToBuf(s))),c=15&f[f.byteLength-1],l=((127&f[c])<<24|(255&f[c+1])<<16|(255&f[c+2])<<8|255&f[c+3])%Math.pow(10,u);return pad(l,u)}},{key:"validate",value:function(t){var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.counter,a=void 0===u?e.defaults.counter:u,s=t.window,f=void 0===s?e.defaults.window:s;if(n.length!==o)return null -;for(var c=null,l=a-f;l<=a+f;++l){var h=e.generate({secret:r,algorithm:i,digits:o,counter:l});timingSafeEqual(n,h)&&(c=l-a)}return c}}]),e}(),TOTP=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,l=void 0===c?e.defaults.digits:c,h=t.period,w=void 0===h?e.defaults.period:h;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=l,this.period=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.timestamp,r=void 0===n?Date.now():n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r})}},{key:"validate",value:function(t){var n=t.token,r=t.timestamp,i=t.window +this.O.update(e)}},{key:"getHash",value:function(e,t){return this.O.getHash(e,t)}},{key:"setHMACKey",value:function(e,t,n){this.O.setHMACKey(e,t,n)}},{key:"getHMAC",value:function(e,t){return this.O.getHMAC(e,t)}}]),e}(),globalThis=function(){if("object"===_typeof(globalThis))return globalThis;Object.defineProperty(Object.prototype,"__GLOBALTHIS__",{get:function(){return this},configurable:!0});try{if("undefined"!=typeof __GLOBALTHIS__)return __GLOBALTHIS__}finally{delete Object.prototype.__GLOBALTHIS__}return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0}(),isNode="[object process]"===Object.prototype.toString.call(globalThis.process),nodeRequire=isNode?eval("require"):function(){},NodeBuffer$1=isNode?globalThis.Buffer:void 0,NodeCrypto$2=isNode?nodeRequire("crypto"):void 0,OPENSSL_TO_JSSHA_ALGO={SHA1:"SHA-1",SHA224:"SHA-224",SHA256:"SHA-256",SHA384:"SHA-384",SHA512:"SHA-512","SHA3-224":"SHA3-224","SHA3-256":"SHA3-256","SHA3-384":"SHA3-384", +"SHA3-512":"SHA3-512"},hmacDigest=function(e,t,n){if(isNode){var r=NodeCrypto$2.createHmac(e,NodeBuffer$1.from(t));return r.update(NodeBuffer$1.from(n)),r.digest().buffer}var i=OPENSSL_TO_JSSHA_ALGO[e.toUpperCase()];if(void 0===i)throw new TypeError("Unknown hash function");var o=new _default(i,"ARRAYBUFFER");return o.setHMACKey(t,"ARRAYBUFFER"),o.update(n),o.getHMAC("ARRAYBUFFER")},pad=function(e,t){for(var n="",r=t-String(e).length;r-- >0;)n+="0";return"".concat(n).concat(e)},ALPHABET="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",base32ToBuf=function(e){for(var t=e.toUpperCase().replace(/=+$/,""),n=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(n),i=0,o=0,u=0,a=0;a=8&&(r[u++]=o>>>i-8&255,i-=8)}return n},base32FromBuf=function(e){for(var t=new Uint8Array(e),n=0,r=0,i="",o=0;o=5;)i+=ALPHABET[r>>>n-5&31],n-=5;return n>0&&(i+=ALPHABET[r<<5-n&31]),i +},hexToBuf=function(e){for(var t=new ArrayBuffer(e.length/2),n=new Uint8Array(t),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.buffer,r=t.size,i=void 0===r?20:r;_classCallCheck(this,e),this.buffer=void 0===n?randomBytes(i):n}return _createClass(e,[{key:"latin1",get:function(){return Object.defineProperty(this,"latin1",{enumerable:!0,value:latin1FromBuf(this.buffer)}),this.latin1}},{key:"utf8",get:function(){return Object.defineProperty(this,"utf8",{enumerable:!0,value:utf8FromBuf(this.buffer)}),this.utf8}},{key:"base32",get:function(){return Object.defineProperty(this,"base32",{enumerable:!0,value:base32FromBuf(this.buffer)}),this.base32}},{key:"hex",get:function(){ +return Object.defineProperty(this,"hex",{enumerable:!0,value:hexFromBuf(this.buffer)}),this.hex}}],[{key:"fromLatin1",value:function(t){return new e({buffer:latin1ToBuf(t)})}},{key:"fromUTF8",value:function(t){return new e({buffer:utf8ToBuf(t)})}},{key:"fromBase32",value:function(t){return new e({buffer:base32ToBuf(t)})}},{key:"fromHex",value:function(t){return new e({buffer:hexToBuf(t)})}}]),e}(),NodeBuffer=isNode?globalThis.Buffer:void 0,NodeCrypto=isNode?nodeRequire("crypto"):void 0,timingSafeEqual=function(e,t){if(isNode)return NodeCrypto.timingSafeEqual(NodeBuffer.from(e),NodeBuffer.from(t));if(e.length!==t.length)throw new TypeError("Input strings must have the same length");for(var n=-1,r=0;++n0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,h=void 0===c?e.defaults.digits:c,l=t.counter,w=void 0===l?e.defaults.counter:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=h,this.counter=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.counter,r=void 0===n?this.counter++:n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:r})}},{key:"validate",value:function(t){var n=t.token,r=t.counter,i=void 0===r?this.counter:r,o=t.window;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:i,window:o})}},{key:"toString",value:function(){var e=encodeURIComponent +;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"counter=".concat(e(this.counter))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=void 0===r?e.defaults.algorithm:r,o=t.digits,u=void 0===o?e.defaults.digits:o,a=t.counter,s=void 0===a?e.defaults.counter:a,f=new Uint8Array(hmacDigest(i,n.buffer,uintToBuf(s))),c=15&f[f.byteLength-1],h=((127&f[c])<<24|(255&f[c+1])<<16|(255&f[c+2])<<8|255&f[c+3])%Math.pow(10,u);return pad(h,u)}},{key:"validate",value:function(t){var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.counter,a=void 0===u?e.defaults.counter:u,s=t.window,f=void 0===s?e.defaults.window:s;if(n.length!==o)return null +;for(var c=null,h=a-f;h<=a+f;++h){var l=e.generate({secret:r,algorithm:i,digits:o,counter:h});timingSafeEqual(n,l)&&(c=h-a)}return c}}]),e}(),TOTP=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.issuer,r=void 0===n?e.defaults.issuer:n,i=t.label,o=void 0===i?e.defaults.label:i,u=t.secret,a=void 0===u?new Secret:u,s=t.algorithm,f=void 0===s?e.defaults.algorithm:s,c=t.digits,h=void 0===c?e.defaults.digits:c,l=t.period,w=void 0===l?e.defaults.period:l;_classCallCheck(this,e),this.issuer=r,this.label=o,this.secret="string"==typeof a?Secret.fromBase32(a):a,this.algorithm=f.toUpperCase(),this.digits=h,this.period=w}return _createClass(e,[{key:"generate",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.timestamp,r=void 0===n?Date.now():n;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r})}},{key:"validate",value:function(t){var n=t.token,r=t.timestamp,i=t.window ;return e.validate({token:n,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:r,window:i})}},{key:"toString",value:function(){var e=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(e(this.issuer),":").concat(e(this.label),"?issuer=").concat(e(this.issuer),"&"):"".concat(e(this.label),"?"))+"secret=".concat(e(this.secret.base32),"&")+"algorithm=".concat(e(this.algorithm),"&")+"digits=".concat(e(this.digits),"&")+"period=".concat(e(this.period))}}],[{key:"defaults",get:function(){return{issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,period:30,window:1}}},{key:"generate",value:function(t){var n=t.secret,r=t.algorithm,i=t.digits,o=t.period,u=void 0===o?e.defaults.period:o,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:n,algorithm:r,digits:i,counter:Math.floor(s/1e3/u)})}},{key:"validate",value:function(t){ var n=t.token,r=t.secret,i=t.algorithm,o=t.digits,u=t.period,a=void 0===u?e.defaults.period:u,s=t.timestamp,f=void 0===s?Date.now():s,c=t.window;return HOTP.validate({token:n,secret:r,algorithm:i,digits:o,counter:Math.floor(f/1e3/a),window:c})}}]),e}(),OTPURI_REGEX=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i,SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function e(){_classCallCheck(this,e)}return _createClass(e,null,[{key:"parse",value:function(e){var t;try{t=e.match(OTPURI_REGEX)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");var n,r=t[1].toLowerCase(),i=t[2].split(/:(.+)/,2).map(decodeURIComponent),o=t[3].split("&").reduce((function(e,t){var n=t.split(/=(.*)/,2).map(decodeURIComponent),r=n[0].toLowerCase(),i=n[1],o=e;return o[r]=i,o}),{}),u={};if("hotp"===r){if(n=HOTP, void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");u.counter=parseInt(o.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");u.period=parseInt(o.period,10)}}if(2===i.length)if(u.label=i[1],void 0===o.issuer)u.issuer=i[0];else{if(o.issuer!==i[0])throw new TypeError("Invalid 'issuer' parameter");u.issuer=o.issuer}else u.label=i[0],void 0!==o.issuer&&(u.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(u.secret=o.secret,void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");u.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter");u.digits=parseInt(o.digits,10)}return new n(u)}},{key:"stringify", -value:function(e){if(e instanceof HOTP||e instanceof TOTP)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),e}(),version="7.0.0";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.1";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 59e51aa9..c65048df 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 */\nexport const uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nexport const uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport default nodeRequire;\n","import jsSHA from 'jssha';\n\nimport globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport default hmacDigest;\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport default pad;\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nexport const base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n","/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nexport const hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\n/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nexport const latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n","import globalThis from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nexport const utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nexport const utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n","import globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport default randomBytes;\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport randomBytes from './utils/crypto/random-bytes';\n\nexport default class Secret {\n\t/**\n\t * Secret key object.\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n","import globalThis from '../global-this';\nimport isNode from '../is-node';\nimport nodeRequire from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport default timingSafeEqual;\n","import { uintToBuf } from './utils/encoding/uint';\nimport hmacDigest from './utils/crypto/hmac-digest';\nimport pad from './utils/pad';\nimport Secret from './secret';\nimport timingSafeEqual from './utils/crypto/timing-safe-equal';\n\nexport default class HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * HOTP: An HMAC-based One-time Password Algorithm.\n\t * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n","import HOTP from './hotp';\nimport Secret from './secret';\n\nexport default class TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * TOTP: Time-Based One-Time Password Algorithm.\n\t * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n\t * @constructor\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n","import HOTP from './hotp';\nimport TOTP from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nexport default class URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport default 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","magicalGlobalThis","magic","globalThis","Object","defineProperty","prototype","get","this","configurable","__OTPAUTH_GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexFromBuf","hex","hexToBuf","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","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2C,EAAU3C,gBAKI,IAArB2C,EAAUxC,SAA0BqB,aAAa2B,KAAKR,EAAUxC,cAGpE,IAAI/C,UAAU,4CAFpB8F,EAAO/C,OAASwC,EAAUxC,YAMQ,IAAxBwC,EAAUjG,UAA2B,KAC3C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG5B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOC,IAArBiG,EAAUlF,OAAwB,KACxCkE,uBAAuBwB,KAAKR,EAAUlF,cAGnC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAAS1E,SAAS4J,EAAUlF,OAAQ,WAMtC,IAAI2E,EAAIc;MAQhB,SAAiBrC,MACZA,aAAed,MAAQc,aAAeG,YAClCH,EAAI9E,iBAGN,IAAIqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.umd.min.js","sources":["../src/utils/encoding/uint.js","../node_modules/jssha/dist/sha.mjs","../src/utils/global-this.js","../src/utils/is-node.js","../src/utils/node-require.js","../src/utils/crypto/hmac-digest.js","../src/utils/pad.js","../src/utils/encoding/base32.js","../src/utils/encoding/hex.js","../src/utils/encoding/latin1.js","../src/utils/encoding/utf8.js","../src/utils/crypto/random-bytes.js","../src/secret.js","../src/utils/crypto/timing-safe-equal.js","../src/hotp.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an ArrayBuffer.\n * @param {number} num Integer.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst uintToBuf = (num) => {\n\tconst buf = new ArrayBuffer(8);\n\tconst arr = new Uint8Array(buf);\n\tlet acc = num;\n\n\tfor (let i = 7; i >= 0; i--) {\n\t\tif (acc === 0) break;\n\t\tarr[i] = acc & 255;\n\t\tacc -= arr[i];\n\t\tacc /= 256;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to an integer.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {number} Integer.\n */\nconst uintFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet num = 0;\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (arr[i] !== 0) {\n\t\t\tnum *= 256;\n\t\t\tnum += arr[i];\n\t\t}\n\t}\n\n\treturn num;\n};\n\nexport { uintToBuf, uintFromBuf };\n","/**\n * A JavaScript implementation of the SHA family of hashes - defined in FIPS PUB 180-4, FIPS PUB 202,\n * and SP 800-185 - as well as the corresponding HMAC implementation as defined in FIPS PUB 198-1.\n *\n * Copyright 2008-2020 Brian Turek, 1998-2009 Paul Johnston & Contributors\n * Distributed under the BSD License\n * See http://caligatio.github.com/jsSHA/ for more information\n */\nconst t=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";function n(t,n,e,r){let i,s,o;const h=n||[0],u=(e=e||0)>>>3,w=-1===r?3:0;for(i=0;i>>2,h.length<=s&&h.push(0),h[s]|=t[i]<<8*(w+r*(o%4));return{value:h,binLen:8*t.length+e}}function e(e,r,i){switch(r){case\"UTF8\":case\"UTF16BE\":case\"UTF16LE\":break;default:throw new Error(\"encoding must be UTF8, UTF16BE, or UTF16LE\")}switch(e){case\"HEX\":return function(t,n,e){return function(t,n,e,r){let i,s,o,h;if(0!=t.length%2)throw new Error(\"String of HEX type must be in byte increments\");const u=n||[0],w=(e=e||0)>>>3,c=-1===r?3:0;for(i=0;i>>1)+w,o=h>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(c+r*(h%4))}return{value:u,binLen:4*t.length+e}}(t,n,e,i)};case\"TEXT\":return function(t,n,e){return function(t,n,e,r,i){let s,o,h,u,w,c,f,a,l=0;const A=e||[0],E=(r=r||0)>>>3;if(\"UTF8\"===n)for(f=-1===i?3:0,h=0;hs?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(h+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(h)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u>>2;A.length<=w;)A.push(0);A[w]|=o[u]<<8*(f+i*(c%4)),l+=1}else for(f=-1===i?2:0,a=\"UTF16LE\"===n&&1!==i||\"UTF16LE\"!==n&&1===i,h=0;h>>8),c=l+E,w=c>>>2;A.length<=w;)A.push(0);A[w]|=s<<8*(f+i*(c%4)),l+=2}return{value:A,binLen:8*l+r}}(t,r,n,e,i)};case\"B64\":return function(n,e,r){return function(n,e,r,i){let s,o,h,u,w,c,f,a=0;const l=e||[0],A=(r=r||0)>>>3,E=-1===i?3:0,H=n.indexOf(\"=\");if(-1===n.search(/^[a-zA-Z0-9=+/]+$/))throw new Error(\"Invalid character in base-64 string\");if(n=n.replace(/=/g,\"\"),-1!==H&&H {};\n\nexport { nodeRequire };\n","import jsSHA from 'jssha';\n\nimport { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * OpenSSL to jsSHA algorithms.\n * @type {Object.}\n */\nconst OPENSSL_TO_JSSHA_ALGO = {\n\t'SHA1': 'SHA-1',\n\t'SHA224': 'SHA-224',\n\t'SHA256': 'SHA-256',\n\t'SHA384': 'SHA-384',\n\t'SHA512': 'SHA-512',\n\t'SHA3-224': 'SHA3-224',\n\t'SHA3-256': 'SHA3-256',\n\t'SHA3-384': 'SHA3-384',\n\t'SHA3-512': 'SHA3-512',\n};\n\n/**\n * Calculates an HMAC digest.\n * In Node.js, the command \"openssl list -digest-algorithms\" displays the available digest algorithms.\n * @param {string} algorithm Algorithm.\n * @param {ArrayBuffer} key Key.\n * @param {ArrayBuffer} message Message.\n * @returns {ArrayBuffer} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n\tif (isNode) {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, NodeBuffer.from(key));\n\t\thmac.update(NodeBuffer.from(message));\n\t\treturn hmac.digest().buffer;\n\t} else {\n\t\tconst variant = OPENSSL_TO_JSSHA_ALGO[algorithm.toUpperCase()];\n\t\tif (typeof variant === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// @ts-ignore\n\t\t// eslint-disable-next-line @babel/new-cap\n\t\tconst hmac = new jsSHA(variant, 'ARRAYBUFFER');\n\t\thmac.setHMACKey(key, 'ARRAYBUFFER');\n\t\thmac.update(message);\n\t\treturn hmac.getHMAC('ARRAYBUFFER');\n\t}\n};\n\nexport { hmacDigest };\n","/**\n * Pads a number with leading zeros.\n * @param {number|string} num Number.\n * @param {number} digits Digits.\n * @returns {string} Padded number.\n */\nconst pad = (num, digits) => {\n\tlet prefix = '';\n\tlet repeat = digits - String(num).length;\n\twhile (repeat-- > 0) prefix += '0';\n\treturn `${prefix}${num}`;\n};\n\nexport { pad };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';\n\n/**\n * Converts a base32 string to an ArrayBuffer (RFC 4648).\n * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode}\n * @param {string} str Base32 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst base32ToBuf = (str) => {\n\t// Canonicalize to all upper case and remove padding if it exists.\n\tconst cstr = str.toUpperCase().replace(/=+$/, '');\n\n\tconst buf = new ArrayBuffer((cstr.length * 5) / 8 | 0);\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet index = 0;\n\n\tfor (let i = 0; i < cstr.length; i++) {\n\t\tconst idx = ALPHABET.indexOf(cstr[i]);\n\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${cstr[i]}`);\n\n\t\tvalue = (value << 5) | idx;\n\t\tbits += 5;\n\n\t\tif (bits >= 8) {\n\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\tbits -= 8;\n\t\t}\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a base32 string (RFC 4648).\n * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode}\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Base32 string.\n */\nconst base32FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet bits = 0;\n\tlet value = 0;\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tvalue = (value << 8) | arr[i];\n\t\tbits += 8;\n\n\t\twhile (bits >= 5) {\n\t\t\tstr += ALPHABET[(value >>> bits - 5) & 31];\n\t\t\tbits -= 5;\n\t\t}\n\t}\n\n\tif (bits > 0) {\n\t\tstr += ALPHABET[(value << 5 - bits) & 31];\n\t}\n\n\treturn str;\n};\n\nexport { base32ToBuf, base32FromBuf };\n","/**\n * Converts a hexadecimal string to an ArrayBuffer.\n * @param {string} str Hexadecimal string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst hexToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length / 2);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i += 2) {\n\t\tarr[i / 2] = parseInt(str.substr(i, 2), 16);\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a hexadecimal string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Hexadecimal string.\n */\nconst hexFromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tconst hex = arr[i].toString(16);\n\t\tif (hex.length === 1) str += '0';\n\t\tstr += hex;\n\t}\n\n\treturn str.toUpperCase();\n};\n\nexport { hexToBuf, hexFromBuf };\n","/**\n * Converts a Latin-1 string to an ArrayBuffer.\n * @param {string} str Latin-1 string.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst latin1ToBuf = (str) => {\n\tconst buf = new ArrayBuffer(str.length);\n\tconst arr = new Uint8Array(buf);\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\tarr[i] = str.charCodeAt(i) & 0xFF;\n\t}\n\n\treturn buf;\n};\n\n/**\n * Converts an ArrayBuffer to a Latin-1 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} Latin-1 string.\n */\nconst latin1FromBuf = (buf) => {\n\tconst arr = new Uint8Array(buf);\n\tlet str = '';\n\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tstr += String.fromCharCode(arr[i]);\n\t}\n\n\treturn str;\n};\n\nexport { latin1ToBuf, latin1FromBuf };\n","import { globalThis } from '../global-this';\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalThis.TextEncoder\n\t? new globalThis.TextEncoder('utf-8')\n\t: null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalThis.TextDecoder\n\t? new globalThis.TextDecoder('utf-8')\n\t: null;\n\n/**\n * Converts an UTF-8 string to an ArrayBuffer.\n * @param {string} str String.\n * @returns {ArrayBuffer} ArrayBuffer.\n */\nconst utf8ToBuf = (str) => {\n\tif (!ENCODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn ENCODER.encode(str).buffer;\n};\n\n/**\n * Converts an ArrayBuffer to an UTF-8 string.\n * @param {ArrayBuffer} buf ArrayBuffer.\n * @returns {string} String.\n */\nconst utf8FromBuf = (buf) => {\n\tif (!DECODER) {\n\t\tthrow new Error('Encoding API not available');\n\t}\n\n\treturn DECODER.decode(buf);\n};\n\nexport { utf8ToBuf, utf8FromBuf };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\nconst BrowserCrypto = !isNode ? globalThis.crypto || globalThis.msCrypto : undefined;\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {ArrayBuffer} Random bytes.\n */\nconst randomBytes = (size) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.randomBytes(size).buffer;\n\t} else {\n\t\tif (!BrowserCrypto || !BrowserCrypto.getRandomValues) {\n\t\t\tthrow new Error('Cryptography API not available');\n\t\t}\n\t\treturn BrowserCrypto.getRandomValues(new Uint8Array(size)).buffer;\n\t}\n};\n\nexport { randomBytes };\n","import { base32ToBuf, base32FromBuf } from './utils/encoding/base32';\nimport { hexToBuf, hexFromBuf } from './utils/encoding/hex';\nimport { latin1ToBuf, latin1FromBuf } from './utils/encoding/latin1';\nimport { utf8ToBuf, utf8FromBuf } from './utils/encoding/utf8';\nimport { randomBytes } from './utils/crypto/random-bytes';\n\n/**\n * OTP secret key.\n */\nclass Secret {\n\t/**\n\t * Creates a secret key object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key.\n\t * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n\t */\n\tconstructor({ buffer, size = 20 } = {}) {\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {ArrayBuffer}\n\t\t */\n\t\tthis.buffer = typeof buffer === 'undefined'\n\t\t\t? randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a Latin-1 string to a Secret object.\n\t * @param {string} str Latin-1 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromLatin1(str) {\n\t\treturn new Secret({ buffer: latin1ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts an UTF-8 string to a Secret object.\n\t * @param {string} str UTF-8 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromUTF8(str) {\n\t\treturn new Secret({ buffer: utf8ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a base32 string to a Secret object.\n\t * @param {string} str Base32 string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromBase32(str) {\n\t\treturn new Secret({ buffer: base32ToBuf(str) });\n\t}\n\n\t/**\n\t * Converts a hexadecimal string to a Secret object.\n\t * @param {string} str Hexadecimal string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromHex(str) {\n\t\treturn new Secret({ buffer: hexToBuf(str) });\n\t}\n\n\t/**\n\t * Latin-1 string representation of secret key.\n\t * @type {string}\n\t */\n\tget latin1() {\n\t\tObject.defineProperty(this, 'latin1', {\n\t\t\tenumerable: true,\n\t\t\tvalue: latin1FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.latin1;\n\t}\n\n\t/**\n\t * UTF-8 string representation of secret key.\n\t * @type {string}\n\t */\n\tget utf8() {\n\t\tObject.defineProperty(this, 'utf8', {\n\t\t\tenumerable: true,\n\t\t\tvalue: utf8FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.utf8;\n\t}\n\n\t/**\n\t * Base32 string representation of secret key.\n\t * @type {string}\n\t */\n\tget base32() {\n\t\tObject.defineProperty(this, 'base32', {\n\t\t\tenumerable: true,\n\t\t\tvalue: base32FromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.base32;\n\t}\n\n\t/**\n\t * Hexadecimal string representation of secret key.\n\t * @type {string}\n\t */\n\tget hex() {\n\t\tObject.defineProperty(this, 'hex', {\n\t\t\tenumerable: true,\n\t\t\tvalue: hexFromBuf(this.buffer),\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n\nexport { Secret };\n","import { globalThis } from '../global-this';\nimport { isNode } from '../is-node';\nimport { nodeRequire } from '../node-require';\n\nconst NodeBuffer = isNode ? globalThis.Buffer : undefined;\nconst NodeCrypto = isNode ? nodeRequire('crypto') : undefined;\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n\tif (isNode) {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\n\t} else {\n\t\tif (a.length !== b.length) {\n\t\t\tthrow new TypeError('Input strings must have the same length');\n\t\t}\n\t\tlet i = -1;\n\t\tlet out = 0;\n\t\twhile (++i < a.length) {\n\t\t\tout |= a.charCodeAt(i) ^ b.charCodeAt(i);\n\t\t}\n\t\treturn out === 0;\n\t}\n};\n\nexport { timingSafeEqual };\n","import { uintToBuf } from './utils/encoding/uint';\nimport { hmacDigest } from './utils/crypto/hmac-digest';\nimport { pad } from './utils/pad';\nimport { Secret } from './secret';\nimport { timingSafeEqual } from './utils/crypto/timing-safe-equal';\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc4226|RFC 4226}\n */\nclass HOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * counter: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tcounter: 0,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates an HOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Initial counter value.\n\t */\n\tconstructor({\n\t\tissuer = HOTP.defaults.issuer,\n\t\tlabel = HOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Initial counter value.\n\t\t * @type {number}\n\t\t */\n\t\tthis.counter = counter;\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm = HOTP.defaults.algorithm,\n\t\tdigits = HOTP.defaults.digits,\n\t\tcounter = HOTP.defaults.counter,\n\t}) {\n\t\tconst digest = new Uint8Array(hmacDigest(algorithm, secret.buffer, uintToBuf(counter)));\n\t\tconst offset = digest[digest.byteLength - 1] & 15;\n\t\tconst otp = (\n\t\t\t((digest[offset] & 127) << 24)\n\t\t\t| ((digest[offset + 1] & 255) << 16)\n\t\t\t| ((digest[offset + 2] & 255) << 8)\n\t\t\t| (digest[offset + 3] & 255)\n\t\t) % (10 ** digits);\n\n\t\treturn pad(otp, digits);\n\t}\n\n\t/**\n\t * Generates an HOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.counter=this.counter++] Counter value.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\tcounter = this.counter++,\n\t} = {}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t});\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.counter=0] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tcounter = HOTP.defaults.counter,\n\t\twindow = HOTP.defaults.window,\n\t}) {\n\t\t// Return early if the token length does not match the digit number.\n\t\tif (token.length !== digits) return null;\n\n\t\tlet delta = null;\n\n\t\tfor (let i = counter - window; i <= counter + window; ++i) {\n\t\t\tconst generatedToken = HOTP.generate({\n\t\t\t\tsecret,\n\t\t\t\talgorithm,\n\t\t\t\tdigits,\n\t\t\t\tcounter: i,\n\t\t\t});\n\n\t\t\tif (timingSafeEqual(token, generatedToken)) {\n\t\t\t\tdelta = i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn delta;\n\t}\n\n\t/**\n\t * Validates an HOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.counter=this.counter] Counter value.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\tcounter = this.counter,\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tcounter,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://hotp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `counter=${e(this.counter)}`;\n\t}\n}\n\nexport { HOTP };\n","import { HOTP } from './hotp';\nimport { Secret } from './secret';\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * {@link https://tools.ietf.org/html/rfc6238|RFC 6238}\n */\nclass TOTP {\n\t/**\n\t * Default configuration.\n\t * @type {{\n\t * issuer: string,\n\t * label: string,\n\t * algorithm: string,\n\t * digits: number,\n\t * period: number\n\t * window: number\n\t * }}\n\t */\n\tstatic get defaults() {\n\t\treturn {\n\t\t\tissuer: '',\n\t\t\tlabel: 'OTPAuth',\n\t\t\talgorithm: 'SHA1',\n\t\t\tdigits: 6,\n\t\t\tperiod: 30,\n\t\t\twindow: 1,\n\t\t};\n\t}\n\n\t/**\n\t * Creates a TOTP object.\n\t * @param {Object} [config] Configuration options.\n\t * @param {string} [config.issuer=''] Account provider.\n\t * @param {string} [config.label='OTPAuth'] Account label.\n\t * @param {Secret|string} [config.secret=Secret] Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t */\n\tconstructor({\n\t\tissuer = TOTP.defaults.issuer,\n\t\tlabel = TOTP.defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = TOTP.defaults.algorithm,\n\t\tdigits = TOTP.defaults.digits,\n\t\tperiod = TOTP.defaults.period,\n\t} = {}) {\n\t\t/**\n\t\t * Account provider.\n\t\t * @type {string}\n\t\t */\n\t\tthis.issuer = issuer;\n\t\t/**\n\t\t * Account label.\n\t\t * @type {string}\n\t\t */\n\t\tthis.label = label;\n\t\t/**\n\t\t * Secret key.\n\t\t * @type {Secret}\n\t\t */\n\t\tthis.secret = typeof secret === 'string'\n\t\t\t? Secret.fromBase32(secret)\n\t\t\t: secret;\n\t\t/**\n\t\t * HMAC hashing algorithm.\n\t\t * @type {string}\n\t\t */\n\t\tthis.algorithm = algorithm.toUpperCase();\n\t\t/**\n\t\t * Token length.\n\t\t * @type {number}\n\t\t */\n\t\tthis.digits = digits;\n\t\t/**\n\t\t * Token time-step duration.\n\t\t * @type {number}\n\t\t */\n\t\tthis.period = period;\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} [config.digits=6] Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tstatic generate({\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t}) {\n\t\treturn HOTP.generate({\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t});\n\t}\n\n\t/**\n\t * Generates a TOTP token.\n\t * @param {Object} [config] Configuration options.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @returns {string} Token.\n\t */\n\tgenerate({\n\t\ttimestamp = Date.now(),\n\t} = {}) {\n\t\treturn TOTP.generate({\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {Secret} config.secret Secret key.\n\t * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n\t * @param {number} config.digits Token length.\n\t * @param {number} [config.period=30] Token time-step duration.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tstatic validate({\n\t\ttoken,\n\t\tsecret,\n\t\talgorithm,\n\t\tdigits,\n\t\tperiod = TOTP.defaults.period,\n\t\ttimestamp = Date.now(),\n\t\twindow,\n\t}) {\n\t\treturn HOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret,\n\t\t\talgorithm,\n\t\t\tdigits,\n\t\t\tcounter: Math.floor(timestamp / 1000 / period),\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Validates a TOTP token.\n\t * @param {Object} config Configuration options.\n\t * @param {string} config.token Token value.\n\t * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n\t * @param {number} [config.window=1] Window of counter values to test.\n\t * @returns {number|null} Token delta, or null if the token is not found.\n\t */\n\tvalidate({\n\t\ttoken,\n\t\ttimestamp,\n\t\twindow,\n\t}) {\n\t\treturn TOTP.validate({\n\t\t\ttoken,\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\n\t\t\tdigits: this.digits,\n\t\t\tperiod: this.period,\n\t\t\ttimestamp,\n\t\t\twindow,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a Google Authenticator key URI.\n\t * @returns {string} URI.\n\t */\n\ttoString() {\n\t\tconst e = encodeURIComponent;\n\t\treturn 'otpauth://totp/'\n\t\t\t+ `${this.issuer.length > 0\n\t\t\t\t? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n\t\t\t\t: `${e(this.label)}?`}`\n\t\t\t+ `secret=${e(this.secret.base32)}&`\n\t\t\t+ `algorithm=${e(this.algorithm)}&`\n\t\t\t+ `digits=${e(this.digits)}&`\n\t\t\t+ `period=${e(this.period)}`;\n\t}\n}\n\nexport { TOTP };\n","import { HOTP } from './hotp';\nimport { TOTP } from './totp';\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?[A-Z0-9.~_-]+=[^&]*)+)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format}\n */\nclass URI {\n\t/**\n\t * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n\t * @param {string} uri Google Authenticator Key URI.\n\t * @returns {HOTP|TOTP} HOTP/TOTP object.\n\t */\n\tstatic parse(uri) {\n\t\tlet uriGroups;\n\n\t\ttry {\n\t\t\turiGroups = uri.match(OTPURI_REGEX);\n\t\t} catch (error) { /* Handled below */ }\n\n\t\tif (!Array.isArray(uriGroups)) {\n\t\t\tthrow new URIError('Invalid URI format');\n\t\t}\n\n\t\t// Extract URI groups.\n\t\tconst uriType = uriGroups[1].toLowerCase();\n\t\tconst uriLabel = uriGroups[2].split(/:(.+)/, 2).map(decodeURIComponent);\n\t\t/** @type {Object.} */\n\t\tconst uriParams = uriGroups[3].split('&').reduce((acc, cur) => {\n\t\t\tconst pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n\t\t\tconst pairKey = pairArr[0].toLowerCase();\n\t\t\tconst pairVal = pairArr[1];\n\t\t\t/** @type {Object.} */\n\t\t\tconst pairAcc = acc;\n\n\t\t\tpairAcc[pairKey] = pairVal;\n\t\t\treturn pairAcc;\n\t\t}, {});\n\n\t\t// 'OTP' will be instantiated with 'config' argument.\n\t\tlet OTP;\n\t\tconst config = {};\n\n\t\tif (uriType === 'hotp') {\n\t\t\tOTP = HOTP;\n\n\t\t\t// Counter: required\n\t\t\tif (typeof uriParams.counter !== 'undefined' && INTEGER_REGEX.test(uriParams.counter)) {\n\t\t\t\tconfig.counter = parseInt(uriParams.counter, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Missing or invalid \\'counter\\' parameter');\n\t\t\t}\n\t\t} else if (uriType === 'totp') {\n\t\t\tOTP = TOTP;\n\n\t\t\t// Period: optional\n\t\t\tif (typeof uriParams.period !== 'undefined') {\n\t\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n\t\t\t\t\tconfig.period = parseInt(uriParams.period, 10);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError('Invalid \\'period\\' parameter');\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new TypeError('Unknown OTP type');\n\t\t}\n\n\t\t// Label: required\n\t\t// Issuer: optional\n\t\tif (uriLabel.length === 2) {\n\t\t\tconfig.label = uriLabel[1];\n\t\t\tif (typeof uriParams.issuer === 'undefined') {\n\t\t\t\tconfig.issuer = uriLabel[0];\n\t\t\t} else if (uriParams.issuer === uriLabel[0]) {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'issuer\\' parameter');\n\t\t\t}\n\t\t} else {\n\t\t\tconfig.label = uriLabel[0];\n\t\t\tif (typeof uriParams.issuer !== 'undefined') {\n\t\t\t\tconfig.issuer = uriParams.issuer;\n\t\t\t}\n\t\t}\n\n\t\t// Secret: required\n\t\tif (typeof uriParams.secret !== 'undefined' && SECRET_REGEX.test(uriParams.secret)) {\n\t\t\tconfig.secret = uriParams.secret;\n\t\t} else {\n\t\t\tthrow new TypeError('Missing or invalid \\'secret\\' parameter');\n\t\t}\n\n\t\t// Algorithm: optional\n\t\tif (typeof uriParams.algorithm !== 'undefined') {\n\t\t\tif (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n\t\t\t\tconfig.algorithm = uriParams.algorithm;\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'algorithm\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\t// Digits: optional\n\t\tif (typeof uriParams.digits !== 'undefined') {\n\t\t\tif (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n\t\t\t\tconfig.digits = parseInt(uriParams.digits, 10);\n\t\t\t} else {\n\t\t\t\tthrow new TypeError('Invalid \\'digits\\' parameter');\n\t\t\t}\n\t\t}\n\n\t\treturn new OTP(config);\n\t}\n\n\t/**\n\t * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n\t * @param {HOTP|TOTP} otp HOTP/TOTP object.\n\t * @returns {string} Google Authenticator Key URI.\n\t */\n\tstatic stringify(otp) {\n\t\tif (otp instanceof HOTP || otp instanceof TOTP) {\n\t\t\treturn otp.toString();\n\t\t}\n\n\t\tthrow new TypeError('Invalid \\'HOTP/TOTP\\' object');\n\t}\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = '__OTPAUTH_VERSION__';\n\nexport { version };\n"],"names":["uintToBuf","num","buf","ArrayBuffer","arr","Uint8Array","acc","i","b64Tab","uint8array2packed","existingPacked","existingPackedLen","bigEndianMod","intOffset","byteOffset","packed","existingByteLen","shiftModifier","length","push","value","binLen","getStrConverter","format","utfType","Error","str","existingBin","existingBinLen","parseInt","substr","isNaN","codePnt","codePntArr","j","transposeBytes","byteCnt","charCodeAt","tmpInt","strPart","firstEqual","indexOf","search","replace","charAt","ignore","getOutputConverter","outputBinLen","outputOptions","binarray","outputLength","formatOpts","srcByte","outputUpper","toUpperCase","triplet","int1","int2","b64Pad","String","fromCharCode","retVal","arrView","globalThis","_typeof","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","isNode","toString","call","process","nodeRequire","eval","NodeBuffer","Buffer","undefined","NodeCrypto","OPENSSL_TO_JSSHA_ALGO","hmacDigest","algorithm","key","message","hmac","createHmac","from","update","digest","buffer","variant","TypeError","jsSHA","setHMACKey","getHMAC","pad","digits","prefix","repeat","ALPHABET","base32ToBuf","cstr","bits","index","idx","base32FromBuf","hexToBuf","hexFromBuf","hex","latin1ToBuf","latin1FromBuf","ENCODER","TextEncoder","DECODER","TextDecoder","utf8ToBuf","encode","utf8FromBuf","decode","BrowserCrypto","crypto","msCrypto","randomBytes","size","getRandomValues","Secret","enumerable","latin1","utf8","base32","timingSafeEqual","a","b","out","HOTP","issuer","defaults","label","secret","counter","fromBase32","generate","token","validate","e","encodeURIComponent","offset","byteLength","otp","delta","generatedToken","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","Array","isArray","URIError","OTP","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;;sLAKA,IAAMA,UAAY,SAACC,WACZC,EAAM,IAAIC,YAAY,GACtBC,EAAM,IAAIC,WAAWH,GACvBI,EAAML,EAEDM,EAAI,EAAGA,GAAK,GACR,IAARD,EADmBC,IAEvBH,EAAIG,GAAW,IAAND,EACTA,GAAOF,EAAIG,GACXD,GAAO,WAGDJ,GCbFM,EAAS,mEA4Pf,SAASC,EACPL,EACAM,EACAC,EACAC,OAEIL,EAAGM,EAAWC,EAGZC,EAASL,GAAkB,CAAC,GAChCM,GAFFL,EAAoBA,GAAqB,KAEC,EACxCM,GAAkC,IAAlBL,EAAsB,EAAI,MAEvCL,EAAI,EAAGA,EAAIH,EAAIc,OAAQX,GAAK,EAE/BM,GADAC,EAAaP,EAAIS,KACU,EACvBD,EAAOG,QAAUL,GACnBE,EAAOI,KAAK,GAEdJ,EAAOF,IAAcT,EAAIG,IAAO,GAAKU,EAAgBL,GAAgBE,EAAa,UAG7E,CAAEM,M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UvC,eAGtE,IAAIhD,UAAU,0CAFpB8F,EAAO9C,QAAUpH,SAAS2J,EAAUvC,QAAS,QAIxC,CAAA,GAAgB,SAAZiC,QAYJ,IAAIjF,UAAU,uBAXpBgF,EAAMpB,UAG0B,IAArB2B,EAAU1B,OAAwB,KACxCU,uBAAuBwB,KAAKR,EAAU1B,cAGnC,IAAI7D,UAAU,8BAFpB8F,EAAOjC,OAASjI,SAAS2J,EAAU1B,OAAQ,QAWtB,IAApBsB,EAASlK,UACZ6K,EAAOhD,MAAQqC,EAAS,QACQ,IAArBI,EAAU3C,OACpBkD,EAAOlD,OAASuC,EAAS,OACnB,CAAA,GAAII,EAAU3C,SAAWuC,EAAS,SAGlC,IAAInF,UAAU,8BAFpB8F,EAAOlD,OAAS2C,EAAU3C,YAK3BkD,EAAOhD,MAAQqC,EAAS,QACQ,IAArBI,EAAU3C,SACpBkD,EAAOlD,OAAS2C,EAAU3C,gBAKI,IAArB2C,EAAUxC,SAA0BqB,aAAa2B,KAAKR,EAAUxC,cAGpE,IAAI/C,UAAU,4CAFpB8F,EAAO/C,OAASwC,EAAUxC,YAMQ,IAAxBwC,EAAUjG,UAA2B,KAC3C+E,gBAAgB0B,KAAKR,EAAUjG,iBAG5B,IAAIU,UAAU,iCAFpB8F,EAAOxG,UAAYiG,EAAUjG,kBAOC,IAArBiG,EAAUlF,OAAwB,KACxCkE,uBAAuBwB,KAAKR,EAAUlF,cAGnC,IAAIL,UAAU,8BAFpB8F,EAAOzF,OAASzE,SAAS2J,EAAUlF,OAAQ,WAMtC,IAAI2E,EAAIc;MAQhB,SAAiBrC,MACZA,aAAed,MAAQc,aAAeG,YAClCH,EAAI9E,iBAGN,IAAIqB,UAAU,uCCrJhBgG,QAAU"} \ No newline at end of file diff --git a/docs/classes/hotp.html b/docs/classes/hotp.html index 6736f2a3..aae55227 100644 --- a/docs/classes/hotp.html +++ b/docs/classes/hotp.html @@ -2764,6 +2764,14 @@
+
+
+
+

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

+
+
+

Hierarchy

    @@ -2824,13 +2832,12 @@

    constructor

  • -

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

    +

    Creates an HOTP object.

    Parameters

    @@ -2901,7 +2908,7 @@

    Static defaults

  • @@ -2946,7 +2953,7 @@

    generate

  • @@ -2975,7 +2982,7 @@

    toString

  • @@ -2998,7 +3005,7 @@

    validate

  • @@ -3038,7 +3045,7 @@

    Static generate

  • @@ -3081,7 +3088,7 @@

    Static validate

  • diff --git a/docs/classes/secret.html b/docs/classes/secret.html index 901d6679..499958b2 100644 --- a/docs/classes/secret.html +++ b/docs/classes/secret.html @@ -2755,6 +2755,13 @@
    +
    +
    +
    +

    OTP secret key.

    +
    +
    +

    Hierarchy

      @@ -2812,12 +2819,12 @@

      constructor

    • -

      Secret key object.

      +

      Creates a secret key object.

      Parameters

      @@ -2853,7 +2860,7 @@

      base32

    • @@ -2875,7 +2882,7 @@

      hex

    • @@ -2897,7 +2904,7 @@

      latin1

    • @@ -2919,7 +2926,7 @@

      utf8

    • @@ -2944,7 +2951,7 @@

      Static fromBase32

    • @@ -2976,7 +2983,7 @@

      Static fromHex

    • @@ -3008,7 +3015,7 @@

      Static fromLatin1

    • @@ -3040,7 +3047,7 @@

      Static fromUTF8

    • diff --git a/docs/classes/totp.html b/docs/classes/totp.html index 05bd284b..ecd7142c 100644 --- a/docs/classes/totp.html +++ b/docs/classes/totp.html @@ -2764,6 +2764,14 @@
      +
      +
      +
      +

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

      +
      +
      +

      Hierarchy

        @@ -2824,13 +2832,12 @@

        constructor

      • -

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

        +

        Creates a TOTP object.

        Parameters

        @@ -2901,7 +2908,7 @@

        Static defaults

      • @@ -2946,7 +2953,7 @@

        generate

      • @@ -2975,7 +2982,7 @@

        toString

      • @@ -2998,7 +3005,7 @@

        validate

      • @@ -3038,7 +3045,7 @@

        Static generate

      • @@ -3084,7 +3091,7 @@

        Static validate

      • diff --git a/docs/classes/uri.html b/docs/classes/uri.html index 1d0fce35..a7c1980c 100644 --- a/docs/classes/uri.html +++ b/docs/classes/uri.html @@ -2799,7 +2799,7 @@

        Static parse

      • @@ -2831,7 +2831,7 @@

        Static stringify

      • diff --git a/docs/index.html b/docs/index.html index 37185606..1611d596 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2836,7 +2836,7 @@

        Const version

        version: string = '__OTPAUTH_VERSION__'
        diff --git a/docs/modules.html b/docs/modules.html index 596e8a17..7e5f7d6f 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -2835,7 +2835,7 @@

        Const version

        version: string = '__OTPAUTH_VERSION__'
        diff --git a/package-lock.json b/package-lock.json index 3836ac89..fb9dcf99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "otpauth", - "version": "7.0.0", + "version": "7.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "7.0.0", + "version": "7.0.1", "license": "MIT", "dependencies": { "jssha": "~3.2.0" diff --git a/package.json b/package.json index 4d7632e2..07bd8cd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "otpauth", - "version": "7.0.0", + "version": "7.0.1", "description": "One Time Password (HOTP/TOTP) library for Node.js, Deno and browsers", "keywords": [ "otp", diff --git a/types/hotp.d.ts b/types/hotp.d.ts index ce59d688..0f993f08 100644 --- a/types/hotp.d.ts +++ b/types/hotp.d.ts @@ -1,4 +1,8 @@ -export default class HOTP { +/** + * HOTP: An HMAC-based One-time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} + */ +export class HOTP { /** * Default configuration. * @type {{ @@ -53,9 +57,7 @@ export default class HOTP { window?: number | undefined; }): number | null; /** - * HOTP: An HMAC-based One-time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc4226|RFC 4226} - * @constructor + * Creates an HOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -130,4 +132,4 @@ export default class HOTP { */ toString(): string; } -import Secret from "./secret"; +import { Secret } from "./secret"; diff --git a/types/index.d.ts b/types/index.d.ts index 2e12dc64..9c43b728 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,6 +1,6 @@ -import HOTP from "./hotp"; -import TOTP from "./totp"; -import URI from "./uri"; -import Secret from "./secret"; -import version from "./version"; +import { HOTP } from "./hotp"; +import { TOTP } from "./totp"; +import { URI } from "./uri"; +import { Secret } from "./secret"; +import { version } from "./version"; export { HOTP, TOTP, URI, Secret, version }; diff --git a/types/secret.d.ts b/types/secret.d.ts index de55bb7b..af3c75da 100644 --- a/types/secret.d.ts +++ b/types/secret.d.ts @@ -1,4 +1,7 @@ -export default class Secret { +/** + * OTP secret key. + */ +export class Secret { /** * Converts a Latin-1 string to a Secret object. * @param {string} str Latin-1 string. @@ -24,8 +27,7 @@ export default class Secret { */ static fromHex(str: string): Secret; /** - * Secret key object. - * @constructor + * Creates a secret key object. * @param {Object} [config] Configuration options. * @param {ArrayBuffer} [config.buffer=randomBytes] Secret key. * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided. diff --git a/types/totp.d.ts b/types/totp.d.ts index 190c7d19..8ec3b32e 100644 --- a/types/totp.d.ts +++ b/types/totp.d.ts @@ -1,4 +1,8 @@ -export default class TOTP { +/** + * TOTP: Time-Based One-Time Password Algorithm. + * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} + */ +export class TOTP { /** * Default configuration. * @type {{ @@ -57,9 +61,7 @@ export default class TOTP { window?: number | undefined; }): number | null; /** - * TOTP: Time-Based One-Time Password Algorithm. - * {@link https://tools.ietf.org/html/rfc6238|RFC 6238} - * @constructor + * Creates a TOTP object. * @param {Object} [config] Configuration options. * @param {string} [config.issuer=''] Account provider. * @param {string} [config.label='OTPAuth'] Account label. @@ -134,4 +136,4 @@ export default class TOTP { */ toString(): string; } -import Secret from "./secret"; +import { Secret } from "./secret"; diff --git a/types/uri.d.ts b/types/uri.d.ts index 60bd4676..1617f096 100644 --- a/types/uri.d.ts +++ b/types/uri.d.ts @@ -2,7 +2,7 @@ * HOTP/TOTP object/string conversion. * {@link https://github.com/google/google-authenticator/wiki/Key-Uri-Format|Key URI Format} */ -export default class URI { +export class URI { /** * Parses a Google Authenticator key URI and returns an HOTP/TOTP object. * @param {string} uri Google Authenticator Key URI. @@ -16,5 +16,5 @@ export default class URI { */ static stringify(otp: HOTP | TOTP): string; } -import HOTP from "./hotp"; -import TOTP from "./totp"; +import { HOTP } from "./hotp"; +import { TOTP } from "./totp"; diff --git a/types/utils/console.d.ts b/types/utils/console.d.ts index 85d0698c..b355ac36 100644 --- a/types/utils/console.d.ts +++ b/types/utils/console.d.ts @@ -1,8 +1,7 @@ -export default console; /** * "console" ponyfill. * @type {Object.} */ -declare const console: { +export const console: { [x: string]: any; }; diff --git a/types/utils/crypto/hmac-digest.d.ts b/types/utils/crypto/hmac-digest.d.ts index bd4388b6..8c8f8792 100644 --- a/types/utils/crypto/hmac-digest.d.ts +++ b/types/utils/crypto/hmac-digest.d.ts @@ -1,4 +1,3 @@ -export default hmacDigest; /** * Calculates an HMAC digest. * In Node.js, the command "openssl list -digest-algorithms" displays the available digest algorithms. @@ -7,4 +6,4 @@ export default hmacDigest; * @param {ArrayBuffer} message Message. * @returns {ArrayBuffer} Digest. */ -declare function hmacDigest(algorithm: string, key: ArrayBuffer, message: ArrayBuffer): ArrayBuffer; +export function hmacDigest(algorithm: string, key: ArrayBuffer, message: ArrayBuffer): ArrayBuffer; diff --git a/types/utils/crypto/random-bytes.d.ts b/types/utils/crypto/random-bytes.d.ts index 38acfeb8..5e129e82 100644 --- a/types/utils/crypto/random-bytes.d.ts +++ b/types/utils/crypto/random-bytes.d.ts @@ -1,7 +1,6 @@ -export default randomBytes; /** * Returns random bytes. * @param {number} size Size. * @returns {ArrayBuffer} Random bytes. */ -declare function randomBytes(size: number): ArrayBuffer; +export function randomBytes(size: number): ArrayBuffer; diff --git a/types/utils/crypto/timing-safe-equal.d.ts b/types/utils/crypto/timing-safe-equal.d.ts index 4f657158..e2985de8 100644 --- a/types/utils/crypto/timing-safe-equal.d.ts +++ b/types/utils/crypto/timing-safe-equal.d.ts @@ -1,8 +1,7 @@ -export default timingSafeEqual; /** * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values. * @param {string} a String a. * @param {string} b String b. * @returns {boolean} Equality result. */ -declare function timingSafeEqual(a: string, b: string): boolean; +export function timingSafeEqual(a: string, b: string): boolean; diff --git a/types/utils/encoding/base32.d.ts b/types/utils/encoding/base32.d.ts index 4f8ded1a..0809b8d9 100644 --- a/types/utils/encoding/base32.d.ts +++ b/types/utils/encoding/base32.d.ts @@ -1,2 +1,14 @@ +/** + * Converts a base32 string to an ArrayBuffer (RFC 4648). + * {@link https://github.com/LinusU/base32-decode|LinusU/base32-decode} + * @param {string} str Base32 string. + * @returns {ArrayBuffer} ArrayBuffer. + */ export function base32ToBuf(str: string): ArrayBuffer; +/** + * Converts an ArrayBuffer to a base32 string (RFC 4648). + * {@link https://github.com/LinusU/base32-encode|LinusU/base32-encode} + * @param {ArrayBuffer} buf ArrayBuffer. + * @returns {string} Base32 string. + */ export function base32FromBuf(buf: ArrayBuffer): string; diff --git a/types/utils/encoding/hex.d.ts b/types/utils/encoding/hex.d.ts index 55e3d027..4a61532f 100644 --- a/types/utils/encoding/hex.d.ts +++ b/types/utils/encoding/hex.d.ts @@ -1,2 +1,12 @@ -export function hexFromBuf(buf: ArrayBuffer): string; +/** + * Converts a hexadecimal string to an ArrayBuffer. + * @param {string} str Hexadecimal string. + * @returns {ArrayBuffer} ArrayBuffer. + */ export function hexToBuf(str: string): ArrayBuffer; +/** + * Converts an ArrayBuffer to a hexadecimal string. + * @param {ArrayBuffer} buf ArrayBuffer. + * @returns {string} Hexadecimal string. + */ +export function hexFromBuf(buf: ArrayBuffer): string; diff --git a/types/utils/encoding/latin1.d.ts b/types/utils/encoding/latin1.d.ts index 93a39f4a..bafed441 100644 --- a/types/utils/encoding/latin1.d.ts +++ b/types/utils/encoding/latin1.d.ts @@ -1,2 +1,12 @@ +/** + * Converts a Latin-1 string to an ArrayBuffer. + * @param {string} str Latin-1 string. + * @returns {ArrayBuffer} ArrayBuffer. + */ export function latin1ToBuf(str: string): ArrayBuffer; +/** + * Converts an ArrayBuffer to a Latin-1 string. + * @param {ArrayBuffer} buf ArrayBuffer. + * @returns {string} Latin-1 string. + */ export function latin1FromBuf(buf: ArrayBuffer): string; diff --git a/types/utils/encoding/uint.d.ts b/types/utils/encoding/uint.d.ts index f6e12447..19112f4b 100644 --- a/types/utils/encoding/uint.d.ts +++ b/types/utils/encoding/uint.d.ts @@ -1,2 +1,12 @@ +/** + * Converts an integer to an ArrayBuffer. + * @param {number} num Integer. + * @returns {ArrayBuffer} ArrayBuffer. + */ export function uintToBuf(num: number): ArrayBuffer; +/** + * Converts an ArrayBuffer to an integer. + * @param {ArrayBuffer} buf ArrayBuffer. + * @returns {number} Integer. + */ export function uintFromBuf(buf: ArrayBuffer): number; diff --git a/types/utils/encoding/utf8.d.ts b/types/utils/encoding/utf8.d.ts index 6f1b4b83..b858f9a9 100644 --- a/types/utils/encoding/utf8.d.ts +++ b/types/utils/encoding/utf8.d.ts @@ -1,2 +1,12 @@ +/** + * Converts an UTF-8 string to an ArrayBuffer. + * @param {string} str String. + * @returns {ArrayBuffer} ArrayBuffer. + */ export function utf8ToBuf(str: string): ArrayBuffer; +/** + * Converts an ArrayBuffer to an UTF-8 string. + * @param {ArrayBuffer} buf ArrayBuffer. + * @returns {string} String. + */ export function utf8FromBuf(buf: ArrayBuffer): string; diff --git a/types/utils/global-this.d.ts b/types/utils/global-this.d.ts index 9a729f7b..a7c7469d 100644 --- a/types/utils/global-this.d.ts +++ b/types/utils/global-this.d.ts @@ -1,9 +1,8 @@ -export default magicalGlobalThis; /** * "globalThis" ponyfill. * {@link https://mathiasbynens.be/notes/globalthis|A horrifying globalThis polyfill in universal JavaScript} * @type {Object.} */ -declare const magicalGlobalThis: { +export const globalThis: { [x: string]: any; }; diff --git a/types/utils/is-node.d.ts b/types/utils/is-node.d.ts index 16124739..d0e50c4f 100644 --- a/types/utils/is-node.d.ts +++ b/types/utils/is-node.d.ts @@ -1,6 +1,5 @@ -export default isNode; /** * Detect if running in Node.js. * @type {boolean} */ -declare const isNode: boolean; +export const isNode: boolean; diff --git a/types/utils/node-require.d.ts b/types/utils/node-require.d.ts index 3e647155..6ebe7509 100644 --- a/types/utils/node-require.d.ts +++ b/types/utils/node-require.d.ts @@ -1,8 +1,7 @@ -export default nodeRequire; /** * Dynamically import Node.js modules ("eval" is used to prevent bundlers from including the module). * {@link https://github.com/webpack/webpack/issues/8826|webpack/webpack#8826} * @param {string} name Module name. * @returns {*} Module. */ -declare const nodeRequire: any; +export const nodeRequire: any; diff --git a/types/utils/pad.d.ts b/types/utils/pad.d.ts index cb39eda6..7ea6d2c8 100644 --- a/types/utils/pad.d.ts +++ b/types/utils/pad.d.ts @@ -1,8 +1,7 @@ -export default pad; /** * Pads a number with leading zeros. * @param {number|string} num Number. * @param {number} digits Digits. * @returns {string} Padded number. */ -declare function pad(num: number | string, digits: number): string; +export function pad(num: number | string, digits: number): string; diff --git a/types/version.d.ts b/types/version.d.ts index c752a6b2..4ab5f540 100644 --- a/types/version.d.ts +++ b/types/version.d.ts @@ -1,6 +1,5 @@ -export default version; /** * Library version. * @type {string} */ -declare const version: string; +export const version: string;