{"version":3,"file":"otpauth.cjs.min.js","sources":["src/utils.js","sjcl/sjcl.js","src/crypto.js","src/secret.js","src/otp.js","src/uri.js","src/version.js"],"sourcesContent":["/**\n * An object containing some utilities.\n * @type {Object}\n */\nexport const Utils = {\n\n\t/**\n\t * UInt conversion.\n\t * @type {Object}\n\t */\n\tuint: {\n\n\t\t/**\n\t\t * Converts an ArrayBuffer to an integer.\n\t\t * @param {ArrayBuffer} buf ArrayBuffer.\n\t\t * @returns {number} Integer.\n\t\t */\n\t\tfromBuf: buf => {\n\t\t\tconst arr = new Uint8Array(buf);\n\t\t\tlet num = 0;\n\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tif (arr[i] !== 0) {\n\t\t\t\t\tnum *= 256;\n\t\t\t\t\tnum += arr[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn num;\n\t\t},\n\n\t\t/**\n\t\t * Converts an integer to an ArrayBuffer.\n\t\t * @param {number} num Integer.\n\t\t * @returns {ArrayBuffer} ArrayBuffer.\n\t\t */\n\t\ttoBuf: num => {\n\t\t\tconst buf = new ArrayBuffer(8);\n\t\t\tconst arr = new Uint8Array(buf);\n\t\t\tlet acc = num;\n\n\t\t\tfor (let i = 7; i >= 0; i--) {\n\t\t\t\tif (acc === 0) break;\n\n\t\t\t\tarr[i] = acc & 255;\n\t\t\t\tacc -= arr[i];\n\t\t\t\tacc /= 256;\n\t\t\t}\n\n\t\t\treturn buf;\n\t\t}\n\n\t},\n\n\t/**\n\t * Raw string conversion.\n\t * @type {Object}\n\t */\n\traw: {\n\n\t\t/**\n\t\t * Converts an ArrayBuffer to a string.\n\t\t * @param {ArrayBuffer} buf ArrayBuffer.\n\t\t * @returns {string} String.\n\t\t */\n\t\tfromBuf: buf => {\n\t\t\tconst arr = new Uint8Array(buf);\n\t\t\tlet str = '';\n\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tstr += String.fromCharCode(arr[i]);\n\t\t\t}\n\n\t\t\treturn str;\n\t\t},\n\n\t\t/**\n\t\t * Converts a string to an ArrayBuffer.\n\t\t * @param {string} str String.\n\t\t * @returns {ArrayBuffer} ArrayBuffer.\n\t\t */\n\t\ttoBuf: str => {\n\t\t\tconst buf = new ArrayBuffer(str.length);\n\t\t\tconst arr = new Uint8Array(buf);\n\n\t\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\t\tarr[i] = str.charCodeAt(i);\n\t\t\t}\n\n\t\t\treturn buf;\n\t\t}\n\n\t},\n\n\t/**\n\t * Base32 string conversion.\n\t * @type {Object}\n\t */\n\tb32: {\n\n\t\t/**\n\t\t * RFC 4648 base32 alphabet without pad.\n\t\t * @type {string}\n\t\t */\n\t\talphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',\n\n\t\t/**\n\t\t * Converts an ArrayBuffer to a base32 string (RFC 4648)\n\t\t * (https://github.com/LinusU/base32-encode).\n\t\t * @param {ArrayBuffer} buf ArrayBuffer.\n\t\t * @returns {string} Base32 string.\n\t\t */\n\t\tfromBuf: buf => {\n\t\t\tconst arr = new Uint8Array(buf);\n\n\t\t\tlet bits = 0;\n\t\t\tlet value = 0;\n\t\t\tlet str = '';\n\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tvalue = (value << 8) | arr[i];\n\t\t\t\tbits += 8;\n\n\t\t\t\twhile (bits >= 5) {\n\t\t\t\t\tstr += Utils.b32.alphabet[(value >>> bits - 5) & 31];\n\t\t\t\t\tbits -= 5;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (bits > 0) {\n\t\t\t\tstr += Utils.b32.alphabet[(value << 5 - bits) & 31];\n\t\t\t}\n\n\t\t\treturn str;\n\t\t},\n\n\t\t/**\n\t\t * Converts a base32 string to an ArrayBuffer (RFC 4648)\n\t\t * (https://github.com/LinusU/base32-decode).\n\t\t * @param {string} str Base32 string.\n\t\t * @returns {ArrayBuffer} ArrayBuffer.\n\t\t */\n\t\ttoBuf: str => {\n\t\t\t// Canonicalize to all upper case and remove padding if it exists.\n\t\t\tstr = str.toUpperCase().replace(/=+$/, '');\n\n\t\t\tconst buf = new ArrayBuffer((str.length * 5) / 8 | 0);\n\t\t\tconst arr = new Uint8Array(buf);\n\n\t\t\tlet bits = 0;\n\t\t\tlet value = 0;\n\t\t\tlet index = 0;\n\n\t\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\t\tconst idx = Utils.b32.alphabet.indexOf(str[i]);\n\t\t\t\tif (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n\t\t\t\tvalue = (value << 5) | idx;\n\t\t\t\tbits += 5;\n\n\t\t\t\tif (bits >= 8) {\n\t\t\t\t\tarr[index++] = (value >>> bits - 8) & 255;\n\t\t\t\t\tbits -= 8;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn buf;\n\t\t}\n\n\t},\n\n\t/**\n\t * Hexadecimal string conversion.\n\t * @type {Object}\n\t */\n\thex: {\n\n\t\t/**\n\t\t * Converts an ArrayBuffer to a hexadecimal string.\n\t\t * @param {ArrayBuffer} buf ArrayBuffer.\n\t\t * @returns {string} Hexadecimal string.\n\t\t */\n\t\tfromBuf: buf => {\n\t\t\tconst arr = new Uint8Array(buf);\n\t\t\tlet str = '';\n\n\t\t\tfor (let i = 0; i < arr.length; i++) {\n\t\t\t\tconst hex = arr[i].toString(16);\n\t\t\t\tstr += hex.length === 2 ? hex : `0${hex}`;\n\t\t\t}\n\n\t\t\treturn str.toUpperCase();\n\t\t},\n\n\t\t/**\n\t\t * Converts a hexadecimal string to an ArrayBuffer.\n\t\t * @param {string} str Hexadecimal string.\n\t\t * @returns {ArrayBuffer} ArrayBuffer.\n\t\t */\n\t\ttoBuf: str => {\n\t\t\tconst buf = new ArrayBuffer(str.length / 2);\n\t\t\tconst arr = new Uint8Array(buf);\n\n\t\t\tfor (let i = 0, j = 0; i < arr.length; i += 1, j += 2) {\n\t\t\t\tarr[i] = parseInt(str.substr(j, 2), 16);\n\t\t\t}\n\n\t\t\treturn buf;\n\t\t}\n\n\t},\n\n\t/**\n\t * Pads a number with leading zeros.\n\t * @param {number|string} num Number.\n\t * @param {number} digits Digits.\n\t * @returns {string} Padded number.\n\t */\n\tpad: (num, digits) => {\n\t\tlet prefix = '';\n\t\tlet repeat = digits - String(num).length;\n\t\twhile (repeat-- > 0) prefix += '0';\n\t\treturn `${prefix}${num}`;\n\t}\n\n};\n\n/**\n * An object containing some utilities (for internal use only).\n * @private\n * @type {Object}\n */\nexport const InternalUtils = {\n\n\t/**\n\t * \"globalThis\" ponyfill\n\t * (https://mathiasbynens.be/notes/globalthis).\n\t * @type {Object}\n\t */\n\tget globalThis() {\n\t\tlet _globalThis;\n\n\t\t/* eslint-disable no-extend-native, no-restricted-globals, no-undef */\n\t\tif (typeof globalThis === 'object') {\n\t\t\t_globalThis = globalThis;\n\t\t} else {\n\t\t\tObject.defineProperty(Object.prototype, '__magicalGlobalThis__', {\n\t\t\t\tget() { return this; },\n\t\t\t\tconfigurable: true\n\t\t\t});\n\t\t\ttry {\n\t\t\t\t_globalThis = __magicalGlobalThis__;\n\t\t\t} finally {\n\t\t\t\tdelete Object.prototype.__magicalGlobalThis__;\n\t\t\t}\n\t\t}\n\n\t\tif (typeof _globalThis === 'undefined') {\n\t\t\t// Still unable to determine \"globalThis\", fall back to a naive method.\n\t\t\tif (typeof self !== 'undefined') {\n\t\t\t\t_globalThis = self;\n\t\t\t} else if (typeof window !== 'undefined') {\n\t\t\t\t_globalThis = window;\n\t\t\t} else if (typeof global !== 'undefined') {\n\t\t\t\t_globalThis = global;\n\t\t\t}\n\t\t}\n\t\t/* eslint-enable */\n\n\t\tObject.defineProperty(this, 'globalThis', {\n\t\t\tenumerable: true,\n\t\t\tvalue: _globalThis\n\t\t});\n\n\t\treturn this.globalThis;\n\t},\n\n\t/**\n\t * \"console\" ponyfill.\n\t * @type {Object}\n\t */\n\tget console() {\n\t\tconst _console = {};\n\n\t\tconst methods = [\n\t\t\t'assert', 'clear', 'context', 'count', 'countReset', 'debug', 'dir', 'dirxml',\n\t\t\t'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'profile',\n\t\t\t'profileEnd', 'table', 'time', 'timeEnd', 'timeLog', 'timeStamp', 'trace', 'warn'\n\t\t];\n\n\t\tif (typeof InternalUtils.globalThis.console === 'object') {\n\t\t\tfor (const method of methods) {\n\t\t\t\t_console[method] = typeof InternalUtils.globalThis.console[method] === 'function'\n\t\t\t\t\t? InternalUtils.globalThis.console[method]\n\t\t\t\t\t: () => {};\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const method of methods) {\n\t\t\t\t_console[method] = () => {};\n\t\t\t}\n\t\t}\n\n\t\tObject.defineProperty(this, 'console', {\n\t\t\tenumerable: true,\n\t\t\tvalue: _console\n\t\t});\n\n\t\treturn this.console;\n\t},\n\n\t/**\n\t * Detect if running in \"Node.js\".\n\t * @type {boolean}\n\t */\n\tget isNode() {\n\t\tconst _isNode = Object.prototype.toString.call(InternalUtils.globalThis.process) === '[object process]';\n\n\t\tObject.defineProperty(this, 'isNode', {\n\t\t\tenumerable: true,\n\t\t\tvalue: _isNode\n\t\t});\n\n\t\treturn this.isNode;\n\t},\n\n\t/**\n\t * Dynamically import \"Node.js\" modules.\n\t * (`eval` is used to prevent bundlers from including the module,\n\t * e.g., [webpack/webpack#8826](https://github.com/webpack/webpack/issues/8826))\n\t * @type {Function}\n\t */\n\tget nodeRequire() {\n\t\tconst _nodeRequire = InternalUtils.isNode\n\t\t\t// eslint-disable-next-line no-eval\n\t\t\t? eval('require')\n\t\t\t: () => {};\n\n\t\tObject.defineProperty(this, 'nodeRequire', {\n\t\t\tenumerable: true,\n\t\t\tvalue: _nodeRequire\n\t\t});\n\n\t\treturn this.nodeRequire;\n\t}\n\n};\n","/** @fileOverview Javascript cryptography implementation.\n *\n * Crush to remove comments, shorten variable names and\n * generally reduce transmission size.\n *\n * @author Emily Stark\n * @author Mike Hamburg\n * @author Dan Boneh\n */\n\n\"use strict\";\n/*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */\n/*global document, window, escape, unescape, module, require, Uint32Array */\n\n/**\n * The Stanford Javascript Crypto Library, top-level namespace.\n * @namespace\n */\nvar sjcl = {\n /**\n * Symmetric ciphers.\n * @namespace\n */\n cipher: {},\n\n /**\n * Hash functions. Right now only SHA256 is implemented.\n * @namespace\n */\n hash: {},\n\n /**\n * Key exchange functions. Right now only SRP is implemented.\n * @namespace\n */\n keyexchange: {},\n \n /**\n * Cipher modes of operation.\n * @namespace\n */\n mode: {},\n\n /**\n * Miscellaneous. HMAC and PBKDF2.\n * @namespace\n */\n misc: {},\n \n /**\n * Bit array encoders and decoders.\n * @namespace\n *\n * @description\n * The members of this namespace are functions which translate between\n * SJCL's bitArrays and other objects (usually strings). Because it\n * isn't always clear which direction is encoding and which is decoding,\n * the method names are \"fromBits\" and \"toBits\".\n */\n codec: {},\n \n /**\n * Exceptions.\n * @namespace\n */\n exception: {\n /**\n * Ciphertext is corrupt.\n * @constructor\n */\n corrupt: function(message) {\n this.toString = function() { return \"CORRUPT: \"+this.message; };\n this.message = message;\n },\n \n /**\n * Invalid parameter.\n * @constructor\n */\n invalid: function(message) {\n this.toString = function() { return \"INVALID: \"+this.message; };\n this.message = message;\n },\n \n /**\n * Bug or missing feature in SJCL.\n * @constructor\n */\n bug: function(message) {\n this.toString = function() { return \"BUG: \"+this.message; };\n this.message = message;\n },\n\n /**\n * Something isn't ready.\n * @constructor\n */\n notReady: function(message) {\n this.toString = function() { return \"NOT READY: \"+this.message; };\n this.message = message;\n }\n }\n};\n/** @fileOverview Arrays of bits, encoded as arrays of Numbers.\n *\n * @author Emily Stark\n * @author Mike Hamburg\n * @author Dan Boneh\n */\n\n/**\n * Arrays of bits, encoded as arrays of Numbers.\n * @namespace\n * @description\n *

\n * These objects are the currency accepted by SJCL's crypto functions.\n *

\n *\n *

\n * Most of our crypto primitives operate on arrays of 4-byte words internally,\n * but many of them can take arguments that are not a multiple of 4 bytes.\n * This library encodes arrays of bits (whose size need not be a multiple of 8\n * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an\n * array of words, 32 bits at a time. Since the words are double-precision\n * floating point numbers, they fit some extra data. We use this (in a private,\n * possibly-changing manner) to encode the number of bits actually present\n * in the last word of the array.\n *

\n *\n *

\n * Because bitwise ops clear this out-of-band data, these arrays can be passed\n * to ciphers like AES which want arrays of words.\n *

\n */\nsjcl.bitArray = {\n /**\n * Array slices in units of bits.\n * @param {bitArray} a The array to slice.\n * @param {Number} bstart The offset to the start of the slice, in bits.\n * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,\n * slice until the end of the array.\n * @return {bitArray} The requested slice.\n */\n bitSlice: function (a, bstart, bend) {\n a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1);\n return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);\n },\n\n /**\n * Extract a number packed into a bit array.\n * @param {bitArray} a The array to slice.\n * @param {Number} bstart The offset to the start of the slice, in bits.\n * @param {Number} blength The length of the number to extract.\n * @return {Number} The requested slice.\n */\n extract: function(a, bstart, blength) {\n // FIXME: this Math.floor is not necessary at all, but for some reason\n // seems to suppress a bug in the Chromium JIT.\n var x, sh = Math.floor((-bstart-blength) & 31);\n if ((bstart + blength - 1 ^ bstart) & -32) {\n // it crosses a boundary\n x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh);\n } else {\n // within a single word\n x = a[bstart/32|0] >>> sh;\n }\n return x & ((1< 0 && len) {\n a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1);\n }\n return a;\n },\n\n /**\n * Make a partial word for a bit array.\n * @param {Number} len The number of bits in the word.\n * @param {Number} x The bits.\n * @param {Number} [_end=0] Pass 1 if x has already been shifted to the high side.\n * @return {Number} The partial word.\n */\n partial: function (len, x, _end) {\n if (len === 32) { return x; }\n return (_end ? x|0 : x << (32-len)) + len * 0x10000000000;\n },\n\n /**\n * Get the number of bits used by a partial word.\n * @param {Number} x The partial word.\n * @return {Number} The number of bits used by the partial word.\n */\n getPartial: function (x) {\n return Math.round(x/0x10000000000) || 32;\n },\n\n /**\n * Compare two arrays for equality in a predictable amount of time.\n * @param {bitArray} a The first array.\n * @param {bitArray} b The second array.\n * @return {boolean} true if a == b; false otherwise.\n */\n equal: function (a, b) {\n if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {\n return false;\n }\n var x = 0, i;\n for (i=0; i= 32; shift -= 32) {\n out.push(carry);\n carry = 0;\n }\n if (shift === 0) {\n return out.concat(a);\n }\n \n for (i=0; i>>shift);\n carry = a[i] << (32-shift);\n }\n last2 = a.length ? a[a.length-1] : 0;\n shift2 = sjcl.bitArray.getPartial(last2);\n out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));\n return out;\n },\n \n /** xor a block of 4 words together.\n * @private\n */\n _xor4: function(x,y) {\n return [x[0]^y[0],x[1]^y[1],x[2]^y[2],x[3]^y[3]];\n },\n\n /** byteswap a word array inplace.\n * (does not handle partial words)\n * @param {sjcl.bitArray} a word array\n * @return {sjcl.bitArray} byteswapped array\n */\n byteswapM: function(a) {\n var i, v, m = 0xff00;\n for (i = 0; i < a.length; ++i) {\n v = a[i];\n a[i] = (v >>> 24) | ((v >>> 8) & m) | ((v & m) << 8) | (v << 24);\n }\n return a;\n }\n};\n/** @fileOverview Bit array codec implementations.\n *\n * @author Marco Munizaga\n */\n\n//patch arraybuffers if they don't exist\nif (typeof(ArrayBuffer) === 'undefined') {\n (function(globals){\n \"use strict\";\n globals.ArrayBuffer = function(){};\n globals.DataView = function(){};\n }(this));\n}\n\n/**\n * ArrayBuffer\n * @namespace\n */\nsjcl.codec.arrayBuffer = {\n /** Convert from a bitArray to an ArrayBuffer. \n * Will default to 8byte padding if padding is undefined*/\n fromBits: function (arr, padding, padding_count) {\n var out, i, ol, tmp, smallest;\n padding = padding==undefined ? true : padding;\n padding_count = padding_count || 8;\n\n if (arr.length === 0) {\n return new ArrayBuffer(0);\n }\n\n ol = sjcl.bitArray.bitLength(arr)/8;\n\n //check to make sure the bitLength is divisible by 8, if it isn't \n //we can't do anything since arraybuffers work with bytes, not bits\n if ( sjcl.bitArray.bitLength(arr)%8 !== 0 ) {\n throw new sjcl.exception.invalid(\"Invalid bit size, must be divisble by 8 to fit in an arraybuffer correctly\");\n }\n\n if (padding && ol%padding_count !== 0){\n ol += padding_count - (ol%padding_count);\n }\n\n\n //padded temp for easy copying\n tmp = new DataView(new ArrayBuffer(arr.length*4));\n for (i=0; i= width ? n : new Array(width - n.length + 1).join('0') + n;\n };\n\n for (var i = 0; i < stringBufferView.byteLength; i+=2) {\n if (i%16 == 0) string += ('\\n'+(i).toString(16)+'\\t');\n string += ( pad(stringBufferView.getUint16(i).toString(16),4) + ' ');\n }\n\n if ( typeof console === undefined ){\n console = console || {log:function(){}}; //fix for IE\n }\n console.log(string.toUpperCase());\n }\n};\n\n/** @fileOverview Javascript SHA-1 implementation.\n *\n * Based on the implementation in RFC 3174, method 1, and on the SJCL\n * SHA-256 implementation.\n *\n * @author Quinn Slack\n */\n\n/**\n * Context for a SHA-1 operation in progress.\n * @constructor\n */\nsjcl.hash.sha1 = function (hash) {\n if (hash) {\n this._h = hash._h.slice(0);\n this._buffer = hash._buffer.slice(0);\n this._length = hash._length;\n } else {\n this.reset();\n }\n};\n\n/**\n * Hash a string or an array of words.\n * @static\n * @param {bitArray|String} data the data to hash.\n * @return {bitArray} The hash value, an array of 5 big-endian words.\n */\nsjcl.hash.sha1.hash = function (data) {\n return (new sjcl.hash.sha1()).update(data).finalize();\n};\n\nsjcl.hash.sha1.prototype = {\n /**\n * The hash's block size, in bits.\n * @constant\n */\n blockSize: 512,\n \n /**\n * Reset the hash state.\n * @return this\n */\n reset:function () {\n this._h = this._init.slice(0);\n this._buffer = [];\n this._length = 0;\n return this;\n },\n \n /**\n * Input several words to the hash.\n * @param {bitArray|String} data the data to hash.\n * @return this\n */\n update: function (data) {\n if (typeof data === \"string\") {\n data = sjcl.codec.utf8String.toBits(data);\n }\n var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),\n ol = this._length,\n nl = this._length = ol + sjcl.bitArray.bitLength(data);\n if (nl > 9007199254740991){\n throw new sjcl.exception.invalid(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n if (typeof Uint32Array !== 'undefined') {\n\tvar c = new Uint32Array(b);\n \tvar j = 0;\n \tfor (i = this.blockSize+ol - ((this.blockSize+ol) & (this.blockSize-1)); i <= nl;\n\t\ti+= this.blockSize) {\n \t this._block(c.subarray(16 * j, 16 * (j+1)));\n \t j += 1;\n \t}\n \tb.splice(0, 16 * j);\n } else {\n \tfor (i = this.blockSize+ol - ((this.blockSize+ol) & (this.blockSize-1)); i <= nl;\n i+= this.blockSize) {\n \t this._block(b.splice(0,16));\n \t}\n }\n return this;\n },\n \n /**\n * Complete hashing and output the hash value.\n * @return {bitArray} The hash value, an array of 5 big-endian words. TODO\n */\n finalize:function () {\n var i, b = this._buffer, h = this._h;\n\n // Round out and push the buffer\n b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);\n // Round out the buffer to a multiple of 16 words, less the 2 length words.\n for (i = b.length + 2; i & 15; i++) {\n b.push(0);\n }\n\n // append the length\n b.push(Math.floor(this._length / 0x100000000));\n b.push(this._length | 0);\n\n while (b.length) {\n this._block(b.splice(0,16));\n }\n\n this.reset();\n return h;\n },\n\n /**\n * The SHA-1 initialization vector.\n * @private\n */\n _init:[0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0],\n\n /**\n * The SHA-1 hash key.\n * @private\n */\n _key:[0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6],\n\n /**\n * The SHA-1 logical functions f(0), f(1), ..., f(79).\n * @private\n */\n _f:function(t, b, c, d) {\n if (t <= 19) {\n return (b & c) | (~b & d);\n } else if (t <= 39) {\n return b ^ c ^ d;\n } else if (t <= 59) {\n return (b & c) | (b & d) | (c & d);\n } else if (t <= 79) {\n return b ^ c ^ d;\n }\n },\n\n /**\n * Circular left-shift operator.\n * @private\n */\n _S:function(n, x) {\n return (x << n) | (x >>> 32-n);\n },\n \n /**\n * Perform one cycle of SHA-1.\n * @param {Uint32Array|bitArray} words one block of words.\n * @private\n */\n _block:function (words) {\n var t, tmp, a, b, c, d, e,\n h = this._h;\n var w;\n if (typeof Uint32Array !== 'undefined') {\n // When words is passed to _block, it has 16 elements. SHA1 _block\n // function extends words with new elements (at the end there are 80 elements). \n // The problem is that if we use Uint32Array instead of Array, \n // the length of Uint32Array cannot be changed. Thus, we replace words with a \n // normal Array here.\n w = Array(80); // do not use Uint32Array here as the instantiation is slower\n for (var j=0; j<16; j++){\n w[j] = words[j];\n }\n } else {\n w = words;\n }\n\n a = h[0]; b = h[1]; c = h[2]; d = h[3]; e = h[4]; \n\n for (t=0; t<=79; t++) {\n if (t >= 16) {\n w[t] = this._S(1, w[t-3] ^ w[t-8] ^ w[t-14] ^ w[t-16]);\n }\n tmp = (this._S(5, a) + this._f(t, b, c, d) + e + w[t] +\n this._key[Math.floor(t/20)]) | 0;\n e = d;\n d = c;\n c = this._S(30, b);\n b = a;\n a = tmp;\n }\n\n h[0] = (h[0]+a) |0;\n h[1] = (h[1]+b) |0;\n h[2] = (h[2]+c) |0;\n h[3] = (h[3]+d) |0;\n h[4] = (h[4]+e) |0;\n }\n};\n/** @fileOverview Javascript SHA-256 implementation.\n *\n * An older version of this implementation is available in the public\n * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,\n * Stanford University 2008-2010 and BSD-licensed for liability\n * reasons.\n *\n * Special thanks to Aldo Cortesi for pointing out several bugs in\n * this code.\n *\n * @author Emily Stark\n * @author Mike Hamburg\n * @author Dan Boneh\n */\n\n/**\n * Context for a SHA-256 operation in progress.\n * @constructor\n */\nsjcl.hash.sha256 = function (hash) {\n if (!this._key[0]) { this._precompute(); }\n if (hash) {\n this._h = hash._h.slice(0);\n this._buffer = hash._buffer.slice(0);\n this._length = hash._length;\n } else {\n this.reset();\n }\n};\n\n/**\n * Hash a string or an array of words.\n * @static\n * @param {bitArray|String} data the data to hash.\n * @return {bitArray} The hash value, an array of 16 big-endian words.\n */\nsjcl.hash.sha256.hash = function (data) {\n return (new sjcl.hash.sha256()).update(data).finalize();\n};\n\nsjcl.hash.sha256.prototype = {\n /**\n * The hash's block size, in bits.\n * @constant\n */\n blockSize: 512,\n \n /**\n * Reset the hash state.\n * @return this\n */\n reset:function () {\n this._h = this._init.slice(0);\n this._buffer = [];\n this._length = 0;\n return this;\n },\n \n /**\n * Input several words to the hash.\n * @param {bitArray|String} data the data to hash.\n * @return this\n */\n update: function (data) {\n if (typeof data === \"string\") {\n data = sjcl.codec.utf8String.toBits(data);\n }\n var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),\n ol = this._length,\n nl = this._length = ol + sjcl.bitArray.bitLength(data);\n if (nl > 9007199254740991){\n throw new sjcl.exception.invalid(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n if (typeof Uint32Array !== 'undefined') {\n\tvar c = new Uint32Array(b);\n \tvar j = 0;\n \tfor (i = 512+ol - ((512+ol) & 511); i <= nl; i+= 512) {\n \t this._block(c.subarray(16 * j, 16 * (j+1)));\n \t j += 1;\n \t}\n \tb.splice(0, 16 * j);\n } else {\n\tfor (i = 512+ol - ((512+ol) & 511); i <= nl; i+= 512) {\n \t this._block(b.splice(0,16));\n \t}\n }\n return this;\n },\n \n /**\n * Complete hashing and output the hash value.\n * @return {bitArray} The hash value, an array of 8 big-endian words.\n */\n finalize:function () {\n var i, b = this._buffer, h = this._h;\n\n // Round out and push the buffer\n b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);\n \n // Round out the buffer to a multiple of 16 words, less the 2 length words.\n for (i = b.length + 2; i & 15; i++) {\n b.push(0);\n }\n \n // append the length\n b.push(Math.floor(this._length / 0x100000000));\n b.push(this._length | 0);\n\n while (b.length) {\n this._block(b.splice(0,16));\n }\n\n this.reset();\n return h;\n },\n\n /**\n * The SHA-256 initialization vector, to be precomputed.\n * @private\n */\n _init:[],\n /*\n _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],\n */\n \n /**\n * The SHA-256 hash key, to be precomputed.\n * @private\n */\n _key:[],\n /*\n _key:\n [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2],\n */\n\n\n /**\n * Function to precompute _init and _key.\n * @private\n */\n _precompute: function () {\n var i = 0, prime = 2, factor, isPrime;\n\n function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }\n\n for (; i<64; prime++) {\n isPrime = true;\n for (factor=2; factor*factor <= prime; factor++) {\n if (prime % factor === 0) {\n isPrime = false;\n break;\n }\n }\n if (isPrime) {\n if (i<8) {\n this._init[i] = frac(Math.pow(prime, 1/2));\n }\n this._key[i] = frac(Math.pow(prime, 1/3));\n i++;\n }\n }\n },\n \n /**\n * Perform one cycle of SHA-256.\n * @param {Uint32Array|bitArray} w one block of words.\n * @private\n */\n _block:function (w) { \n var i, tmp, a, b,\n h = this._h,\n k = this._key,\n h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3],\n h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7];\n\n /* Rationale for placement of |0 :\n * If a value can overflow is original 32 bits by a factor of more than a few\n * million (2^23 ish), there is a possibility that it might overflow the\n * 53-bit mantissa and lose precision.\n *\n * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that\n * propagates around the loop, and on the hash state h[]. I don't believe\n * that the clamps on h4 and on h0 are strictly necessary, but it's close\n * (for h4 anyway), and better safe than sorry.\n *\n * The clamps on h[] are necessary for the output to be correct even in the\n * common case and for short inputs.\n */\n for (i=0; i<64; i++) {\n // load up the input word for this round\n if (i<16) {\n tmp = w[i];\n } else {\n a = w[(i+1 ) & 15];\n b = w[(i+14) & 15];\n tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) + \n (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +\n w[i&15] + w[(i+9) & 15]) | 0;\n }\n \n tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;\n \n // shift register\n h7 = h6; h6 = h5; h5 = h4;\n h4 = h3 + tmp | 0;\n h3 = h2; h2 = h1; h1 = h0;\n\n h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0;\n }\n\n h[0] = h[0]+h0 | 0;\n h[1] = h[1]+h1 | 0;\n h[2] = h[2]+h2 | 0;\n h[3] = h[3]+h3 | 0;\n h[4] = h[4]+h4 | 0;\n h[5] = h[5]+h5 | 0;\n h[6] = h[6]+h6 | 0;\n h[7] = h[7]+h7 | 0;\n }\n};\n\n\n/** @fileOverview Javascript SHA-512 implementation.\n *\n * This implementation was written for CryptoJS by Jeff Mott and adapted for\n * SJCL by Stefan Thomas.\n *\n * CryptoJS (c) 2009–2012 by Jeff Mott. All rights reserved.\n * Released with New BSD License\n *\n * @author Emily Stark\n * @author Mike Hamburg\n * @author Dan Boneh\n * @author Jeff Mott\n * @author Stefan Thomas\n */\n\n/**\n * Context for a SHA-512 operation in progress.\n * @constructor\n */\nsjcl.hash.sha512 = function (hash) {\n if (!this._key[0]) { this._precompute(); }\n if (hash) {\n this._h = hash._h.slice(0);\n this._buffer = hash._buffer.slice(0);\n this._length = hash._length;\n } else {\n this.reset();\n }\n};\n\n/**\n * Hash a string or an array of words.\n * @static\n * @param {bitArray|String} data the data to hash.\n * @return {bitArray} The hash value, an array of 16 big-endian words.\n */\nsjcl.hash.sha512.hash = function (data) {\n return (new sjcl.hash.sha512()).update(data).finalize();\n};\n\nsjcl.hash.sha512.prototype = {\n /**\n * The hash's block size, in bits.\n * @constant\n */\n blockSize: 1024,\n \n /**\n * Reset the hash state.\n * @return this\n */\n reset:function () {\n this._h = this._init.slice(0);\n this._buffer = [];\n this._length = 0;\n return this;\n },\n \n /**\n * Input several words to the hash.\n * @param {bitArray|String} data the data to hash.\n * @return this\n */\n update: function (data) {\n if (typeof data === \"string\") {\n data = sjcl.codec.utf8String.toBits(data);\n }\n var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),\n ol = this._length,\n nl = this._length = ol + sjcl.bitArray.bitLength(data);\n if (nl > 9007199254740991){\n throw new sjcl.exception.invalid(\"Cannot hash more than 2^53 - 1 bits\");\n }\n\n if (typeof Uint32Array !== 'undefined') {\n var c = new Uint32Array(b);\n var j = 0;\n for (i = 1024+ol - ((1024+ol) & 1023); i <= nl; i+= 1024) {\n this._block(c.subarray(32 * j, 32 * (j+1)));\n j += 1;\n }\n b.splice(0, 32 * j);\n } else {\n for (i = 1024+ol - ((1024+ol) & 1023); i <= nl; i+= 1024) {\n this._block(b.splice(0,32));\n }\n }\n return this;\n },\n \n /**\n * Complete hashing and output the hash value.\n * @return {bitArray} The hash value, an array of 16 big-endian words.\n */\n finalize:function () {\n var i, b = this._buffer, h = this._h;\n\n // Round out and push the buffer\n b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);\n\n // Round out the buffer to a multiple of 32 words, less the 4 length words.\n for (i = b.length + 4; i & 31; i++) {\n b.push(0);\n }\n\n // append the length\n b.push(0);\n b.push(0);\n b.push(Math.floor(this._length / 0x100000000));\n b.push(this._length | 0);\n\n while (b.length) {\n this._block(b.splice(0,32));\n }\n\n this.reset();\n return h;\n },\n\n /**\n * The SHA-512 initialization vector, to be precomputed.\n * @private\n */\n _init:[],\n\n /**\n * Least significant 24 bits of SHA512 initialization values.\n *\n * Javascript only has 53 bits of precision, so we compute the 40 most\n * significant bits and add the remaining 24 bits as constants.\n *\n * @private\n */\n _initr: [ 0xbcc908, 0xcaa73b, 0x94f82b, 0x1d36f1, 0xe682d1, 0x3e6c1f, 0x41bd6b, 0x7e2179 ],\n\n /*\n _init:\n [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,\n 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179],\n */\n\n /**\n * The SHA-512 hash key, to be precomputed.\n * @private\n */\n _key:[],\n\n /**\n * Least significant 24 bits of SHA512 key values.\n * @private\n */\n _keyr:\n [0x28ae22, 0xef65cd, 0x4d3b2f, 0x89dbbc, 0x48b538, 0x05d019, 0x194f9b, 0x6d8118,\n 0x030242, 0x706fbe, 0xe4b28c, 0xffb4e2, 0x7b896f, 0x1696b1, 0xc71235, 0x692694,\n 0xf14ad2, 0x4f25e3, 0x8cd5b5, 0xac9c65, 0x2b0275, 0xa6e483, 0x41fbd4, 0x1153b5,\n 0x66dfab, 0xb43210, 0xfb213f, 0xef0ee4, 0xa88fc2, 0x0aa725, 0x03826f, 0x0e6e70,\n 0xd22ffc, 0x26c926, 0xc42aed, 0x95b3df, 0xaf63de, 0x77b2a8, 0xedaee6, 0x82353b,\n 0xf10364, 0x423001, 0xf89791, 0x54be30, 0xef5218, 0x65a910, 0x71202a, 0xbbd1b8,\n 0xd2d0c8, 0x41ab53, 0x8eeb99, 0x9b48a8, 0xc95a63, 0x418acb, 0x63e373, 0xb2b8a3,\n 0xefb2fc, 0x172f60, 0xf0ab72, 0x6439ec, 0x631e28, 0x82bde9, 0xc67915, 0x72532b,\n 0x26619c, 0xc0c207, 0xe0eb1e, 0x6ed178, 0x176fba, 0xc898a6, 0xf90dae, 0x1c471b,\n 0x047d84, 0xc72493, 0xc9bebc, 0x100d4c, 0x3e42b6, 0x657e2a, 0xd6faec, 0x475817],\n\n /*\n _key:\n [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,\n 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,\n 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,\n 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,\n 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,\n 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,\n 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,\n 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,\n 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,\n 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,\n 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,\n 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,\n 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,\n 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,\n 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,\n 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,\n 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,\n 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,\n 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,\n 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817],\n */\n\n /**\n * Function to precompute _init and _key.\n * @private\n */\n _precompute: function () {\n // XXX: This code is for precomputing the SHA256 constants, change for\n // SHA512 and re-enable.\n var i = 0, prime = 2, factor , isPrime;\n\n function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }\n function frac2(x) { return (x-Math.floor(x)) * 0x10000000000 & 0xff; }\n\n for (; i<80; prime++) {\n isPrime = true;\n for (factor=2; factor*factor <= prime; factor++) {\n if (prime % factor === 0) {\n isPrime = false;\n break;\n }\n }\n if (isPrime) {\n if (i<8) {\n this._init[i*2] = frac(Math.pow(prime, 1/2));\n this._init[i*2+1] = (frac2(Math.pow(prime, 1/2)) << 24) | this._initr[i];\n }\n this._key[i*2] = frac(Math.pow(prime, 1/3));\n this._key[i*2+1] = (frac2(Math.pow(prime, 1/3)) << 24) | this._keyr[i];\n i++;\n }\n }\n },\n\n /**\n * Perform one cycle of SHA-512.\n * @param {Uint32Array|bitArray} words one block of words.\n * @private\n */\n _block:function (words) {\n var i, wrh, wrl,\n h = this._h,\n k = this._key,\n h0h = h[ 0], h0l = h[ 1], h1h = h[ 2], h1l = h[ 3],\n h2h = h[ 4], h2l = h[ 5], h3h = h[ 6], h3l = h[ 7],\n h4h = h[ 8], h4l = h[ 9], h5h = h[10], h5l = h[11],\n h6h = h[12], h6l = h[13], h7h = h[14], h7l = h[15];\n var w;\n if (typeof Uint32Array !== 'undefined') {\n\t// When words is passed to _block, it has 32 elements. SHA512 _block\n\t// function extends words with new elements (at the end there are 160 elements). \n\t// The problem is that if we use Uint32Array instead of Array, \n\t// the length of Uint32Array cannot be changed. Thus, we replace words with a \n\t// normal Array here.\n w = Array(160); // do not use Uint32Array here as the instantiation is slower\n for (var j=0; j<32; j++){\n \t w[j] = words[j]; \n }\n } else {\n\tw = words;\n } \n\n // Working variables\n var ah = h0h, al = h0l, bh = h1h, bl = h1l,\n ch = h2h, cl = h2l, dh = h3h, dl = h3l,\n eh = h4h, el = h4l, fh = h5h, fl = h5l,\n gh = h6h, gl = h6l, hh = h7h, hl = h7l;\n\n for (i=0; i<80; i++) {\n // load up the input word for this round\n if (i<16) {\n wrh = w[i * 2];\n wrl = w[i * 2 + 1];\n } else {\n // Gamma0\n var gamma0xh = w[(i-15) * 2];\n var gamma0xl = w[(i-15) * 2 + 1];\n var gamma0h =\n ((gamma0xl << 31) | (gamma0xh >>> 1)) ^\n ((gamma0xl << 24) | (gamma0xh >>> 8)) ^\n (gamma0xh >>> 7);\n var gamma0l =\n ((gamma0xh << 31) | (gamma0xl >>> 1)) ^\n ((gamma0xh << 24) | (gamma0xl >>> 8)) ^\n ((gamma0xh << 25) | (gamma0xl >>> 7));\n\n // Gamma1\n var gamma1xh = w[(i-2) * 2];\n var gamma1xl = w[(i-2) * 2 + 1];\n var gamma1h =\n ((gamma1xl << 13) | (gamma1xh >>> 19)) ^\n ((gamma1xh << 3) | (gamma1xl >>> 29)) ^\n (gamma1xh >>> 6);\n var gamma1l =\n ((gamma1xh << 13) | (gamma1xl >>> 19)) ^\n ((gamma1xl << 3) | (gamma1xh >>> 29)) ^\n ((gamma1xh << 26) | (gamma1xl >>> 6));\n\n // Shortcuts\n var wr7h = w[(i-7) * 2];\n var wr7l = w[(i-7) * 2 + 1];\n\n var wr16h = w[(i-16) * 2];\n var wr16l = w[(i-16) * 2 + 1];\n\n // W(round) = gamma0 + W(round - 7) + gamma1 + W(round - 16)\n wrl = gamma0l + wr7l;\n wrh = gamma0h + wr7h + ((wrl >>> 0) < (gamma0l >>> 0) ? 1 : 0);\n wrl += gamma1l;\n wrh += gamma1h + ((wrl >>> 0) < (gamma1l >>> 0) ? 1 : 0);\n wrl += wr16l;\n wrh += wr16h + ((wrl >>> 0) < (wr16l >>> 0) ? 1 : 0);\n }\n\n w[i*2] = wrh |= 0;\n w[i*2 + 1] = wrl |= 0;\n\n // Ch\n var chh = (eh & fh) ^ (~eh & gh);\n var chl = (el & fl) ^ (~el & gl);\n\n // Maj\n var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);\n var majl = (al & bl) ^ (al & cl) ^ (bl & cl);\n\n // Sigma0\n var sigma0h = ((al << 4) | (ah >>> 28)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));\n var sigma0l = ((ah << 4) | (al >>> 28)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));\n\n // Sigma1\n var sigma1h = ((el << 18) | (eh >>> 14)) ^ ((el << 14) | (eh >>> 18)) ^ ((eh << 23) | (el >>> 9));\n var sigma1l = ((eh << 18) | (el >>> 14)) ^ ((eh << 14) | (el >>> 18)) ^ ((el << 23) | (eh >>> 9));\n\n // K(round)\n var krh = k[i*2];\n var krl = k[i*2+1];\n\n // t1 = h + sigma1 + ch + K(round) + W(round)\n var t1l = hl + sigma1l;\n var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);\n t1l += chl;\n t1h += chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);\n t1l += krl;\n t1h += krh + ((t1l >>> 0) < (krl >>> 0) ? 1 : 0);\n t1l = t1l + wrl|0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=1054972\n t1h += wrh + ((t1l >>> 0) < (wrl >>> 0) ? 1 : 0);\n\n // t2 = sigma0 + maj\n var t2l = sigma0l + majl;\n var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);\n\n // Update working variables\n hh = gh;\n hl = gl;\n gh = fh;\n gl = fl;\n fh = eh;\n fl = el;\n el = (dl + t1l) | 0;\n eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;\n dh = ch;\n dl = cl;\n ch = bh;\n cl = bl;\n bh = ah;\n bl = al;\n al = (t1l + t2l) | 0;\n ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;\n }\n\n // Intermediate hash\n h0l = h[1] = (h0l + al) | 0;\n h[0] = (h0h + ah + ((h0l >>> 0) < (al >>> 0) ? 1 : 0)) | 0;\n h1l = h[3] = (h1l + bl) | 0;\n h[2] = (h1h + bh + ((h1l >>> 0) < (bl >>> 0) ? 1 : 0)) | 0;\n h2l = h[5] = (h2l + cl) | 0;\n h[4] = (h2h + ch + ((h2l >>> 0) < (cl >>> 0) ? 1 : 0)) | 0;\n h3l = h[7] = (h3l + dl) | 0;\n h[6] = (h3h + dh + ((h3l >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;\n h4l = h[9] = (h4l + el) | 0;\n h[8] = (h4h + eh + ((h4l >>> 0) < (el >>> 0) ? 1 : 0)) | 0;\n h5l = h[11] = (h5l + fl) | 0;\n h[10] = (h5h + fh + ((h5l >>> 0) < (fl >>> 0) ? 1 : 0)) | 0;\n h6l = h[13] = (h6l + gl) | 0;\n h[12] = (h6h + gh + ((h6l >>> 0) < (gl >>> 0) ? 1 : 0)) | 0;\n h7l = h[15] = (h7l + hl) | 0;\n h[14] = (h7h + hh + ((h7l >>> 0) < (hl >>> 0) ? 1 : 0)) | 0;\n }\n};\n\n\n/** @fileOverview HMAC implementation.\n *\n * @author Emily Stark\n * @author Mike Hamburg\n * @author Dan Boneh\n */\n\n/** HMAC with the specified hash function.\n * @constructor\n * @param {bitArray} key the key for HMAC.\n * @param {Object} [Hash=sjcl.hash.sha256] The hash function to use.\n */\nsjcl.misc.hmac = function (key, Hash) {\n this._hash = Hash = Hash || sjcl.hash.sha256;\n var exKey = [[],[]], i,\n bs = Hash.prototype.blockSize / 32;\n this._baseHash = [new Hash(), new Hash()];\n\n if (key.length > bs) {\n key = Hash.hash(key);\n }\n \n for (i=0; i {\n\t\t\tconst nodeBuffer = new NodeBuffer(arrayBuffer.byteLength);\n\t\t\tconst uint8Array = new Uint8Array(arrayBuffer);\n\t\t\tfor (let i = 0; i < uint8Array.length; i++) {\n\t\t\t\tnodeBuffer[i] = uint8Array[i];\n\t\t\t}\n\t\t\treturn nodeBuffer;\n\t\t};\n\t}\n\n\tlet nodeBufferToArrayBuffer;\n\tif (NodeBuffer.prototype instanceof Uint8Array) {\n\t\tnodeBufferToArrayBuffer = nodeBuffer => nodeBuffer.buffer;\n\t} else {\n\t\t// Node.js < 4.0.0\n\t\tnodeBufferToArrayBuffer = nodeBuffer => {\n\t\t\tconst uint8Array = new Uint8Array(nodeBuffer.length);\n\t\t\tfor (let i = 0; i < uint8Array.length; i++) {\n\t\t\t\tuint8Array[i] = nodeBuffer[i];\n\t\t\t}\n\t\t\treturn uint8Array.buffer;\n\t\t};\n\t}\n\n\trandomBytes = size => {\n\t\tconst bytes = NodeCrypto.randomBytes(size);\n\t\treturn nodeBufferToArrayBuffer(bytes);\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\n\t\tconst hmac = NodeCrypto.createHmac(algorithm, nodeBufferFromArrayBuffer(key));\n\t\thmac.update(nodeBufferFromArrayBuffer(message));\n\t\treturn nodeBufferToArrayBuffer(hmac.digest());\n\t};\n} else {\n\tconst BrowserCrypto = InternalUtils.globalThis.crypto || InternalUtils.globalThis.msCrypto;\n\n\tlet getRandomValues;\n\tif (typeof BrowserCrypto !== 'undefined' && typeof BrowserCrypto.getRandomValues === 'function') {\n\t\tgetRandomValues = array => {\n\t\t\tBrowserCrypto.getRandomValues(array);\n\t\t};\n\t} else {\n\t\tInternalUtils.console.warn('Cryptography API not available, falling back to \\'Math.random\\'...');\n\t\tgetRandomValues = array => {\n\t\t\tfor (let i = 0; i < array.length; i++) {\n\t\t\t\tarray[i] = Math.floor(Math.random() * 256);\n\t\t\t}\n\t\t};\n\t}\n\n\trandomBytes = size => {\n\t\tconst bytes = new Uint8Array(size);\n\t\tgetRandomValues(bytes);\n\t\treturn bytes.buffer;\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\n\t\tconst hash = sjcl.hash[algorithm.toLowerCase()];\n\t\tif (typeof hash === 'undefined') {\n\t\t\tthrow new TypeError('Unknown hash function');\n\t\t}\n\t\t// eslint-disable-next-line new-cap\n\t\tconst hmac = new sjcl.misc.hmac(sjcl.codec.arrayBuffer.toBits(key), hash);\n\t\thmac.update(sjcl.codec.arrayBuffer.toBits(message));\n\t\treturn sjcl.codec.arrayBuffer.fromBits(hmac.digest(), false);\n\t};\n}\n\n/**\n * An object containing some cryptography functions with dirty workarounds for Node.js and browsers.\n * @private\n * @type {Object}\n */\nexport const Crypto = {\n\n\t/**\n\t * Returns random bytes.\n\t * @param {number} size Size.\n\t * @returns {ArrayBuffer} Random bytes.\n\t */\n\trandomBytes,\n\n\t/**\n\t * Calculates an HMAC digest.\n\t * In Node.js, the command `openssl list -digest-algorithms` displays the available digest algorithms.\n\t * @param {string} algorithm Algorithm.\n\t * @param {ArrayBuffer} key Key.\n\t * @param {ArrayBuffer} message Message.\n\t * @returns {ArrayBuffer} Digest.\n\t */\n\thmacDigest\n\n};\n","import { Utils } from './utils';\nimport { Crypto } from './crypto';\n\n/**\n * Secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBuffer} [config.buffer=Crypto.randomBytes] Secret key.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\nexport class Secret {\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? Crypto.randomBytes(size)\n\t\t\t: buffer;\n\t}\n\n\t/**\n\t * Converts a raw string to a Secret object.\n\t * @param {string} str Raw string.\n\t * @returns {Secret} Secret object.\n\t */\n\tstatic fromRaw(str) {\n\t\treturn new Secret({ buffer: Utils.raw.toBuf(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 fromB32(str) {\n\t\treturn new Secret({ buffer: Utils.b32.toBuf(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: Utils.hex.toBuf(str) });\n\t}\n\n\t/**\n\t * String representation of secret key.\n\t * @type {string}\n\t */\n\tget raw() {\n\t\tObject.defineProperty(this, 'raw', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: Utils.raw.fromBuf(this.buffer)\n\t\t});\n\n\t\treturn this.raw;\n\t}\n\n\t/**\n\t * Base32 representation of secret key.\n\t * @type {string}\n\t */\n\tget b32() {\n\t\tObject.defineProperty(this, 'b32', {\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: Utils.b32.fromBuf(this.buffer)\n\t\t});\n\n\t\treturn this.b32;\n\t}\n\n\t/**\n\t * Hexadecimal 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\tconfigurable: true,\n\t\t\twritable: true,\n\t\t\tvalue: Utils.hex.fromBuf(this.buffer)\n\t\t});\n\n\t\treturn this.hex;\n\t}\n}\n","import { Utils } from './utils';\nimport { Crypto } from './crypto';\nimport { Secret } from './secret';\n\n/**\n * Default configuration.\n * @private\n * @type {Object}\n */\nconst defaults = {\n\tissuer: '',\n\tlabel: 'OTPAuth',\n\talgorithm: 'SHA1',\n\tdigits: 6,\n\tcounter: 0,\n\tperiod: 30,\n\twindow: 1\n};\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm (RFC 4226)\n * (https://tools.ietf.org/html/rfc4226).\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\nexport class HOTP {\n\tconstructor({\n\t\tissuer = defaults.issuer,\n\t\tlabel = defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = defaults.algorithm,\n\t\tdigits = defaults.digits,\n\t\tcounter = 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.fromB32(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;\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 = defaults.algorithm,\n\t\tdigits = defaults.digits,\n\t\tcounter = defaults.counter\n\t}) {\n\t\tconst digest = new Uint8Array(Crypto.hmacDigest(algorithm, secret.buffer, Utils.uint.toBuf(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 Utils.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.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\tcounter = defaults.counter,\n\t\twindow = defaults.window\n\t}) {\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: token.length,\n\t\t\t\tcounter: i\n\t\t\t});\n\n\t\t\tif (token === generatedToken) {\n\t\t\t\treturn i - counter;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\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: Utils.pad(token, this.digits),\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\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.b32)}&`\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\n/**\n * TOTP: Time-Based One-Time Password Algorithm (RFC 6238)\n * (https://tools.ietf.org/html/rfc6238).\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\nexport class TOTP {\n\tconstructor({\n\t\tissuer = defaults.issuer,\n\t\tlabel = defaults.label,\n\t\tsecret = new Secret(),\n\t\talgorithm = defaults.algorithm,\n\t\tdigits = defaults.digits,\n\t\tperiod = 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.fromB32(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;\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 = 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.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\tperiod = 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\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: Utils.pad(token, this.digits),\n\t\t\tsecret: this.secret,\n\t\t\talgorithm: this.algorithm,\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.b32)}&`\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 { Utils } from './utils';\nimport { Secret } from './secret';\n// eslint-disable-next-line import/no-cycle\nimport { HOTP, TOTP } from './otp';\n\n/**\n * Valid key URI parameters.\n * @private\n * @type {Array}\n */\nconst OTPURI_PARAMS = ['issuer', 'secret', 'algorithm', 'digits', 'counter', 'period'];\n\n/**\n * Key URI regex.\n * otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS\n * @private\n * @type {RegExp}\n */\nconst OTPURI_REGEX = new RegExp(`^otpauth:\\\\/\\\\/([ht]otp)\\\\/(.+)\\\\?((?:&?(?:${OTPURI_PARAMS.join('|')})=[^&]+)+)$`, 'i');\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @private\n * @type {string}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @private\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|256|512)$/i;\n\n/**\n * Integer regex.\n * @private\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @private\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion\n * (https://github.com/google/google-authenticator/wiki/Key-Uri-Format).\n */\nexport 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\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\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 = new Secret({ buffer: Utils.b32.toBuf(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 * @param {Object} [config] Configuration options.\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 */\nexport const version = '__OTPAUTH_VERSION__';\n"],"names":["Utils","uint","fromBuf","buf","arr","Uint8Array","num","i","length","toBuf","ArrayBuffer","acc","raw","str","String","fromCharCode","charCodeAt","b32","alphabet","bits","value","toUpperCase","replace","index","idx","indexOf","TypeError","hex","toString","j","parseInt","substr","pad","digits","prefix","repeat","InternalUtils","_globalThis","globalThis","Object","defineProperty","prototype","get","this","configurable","__magicalGlobalThis__","self","window","global","enumerable","_console","methods","_typeof","console","method","_isNode","call","process","isNode","_nodeRequire","eval","nodeRequire","sjcl","cipher","hash","keyexchange","mode","misc","codec","exception","corrupt","message","invalid","bug","notReady","globals","randomBytes","hmacDigest","bitArray","bitSlice","a","bstart","bend","_shiftRight","slice","undefined","clamp","extract","blength","sh","Math","floor","concat","a1","a2","last","shift","getPartial","bitLength","x","l","len","ceil","partial","_end","round","equal","b","carry","out","last2","shift2","push","pop","_xor4","y","byteswapM","v","DataView","arrayBuffer","fromBits","padding","padding_count","ol","tmp","smallest","setUint32","byteLength","buffer","setUint8","getUint8","toBits","inView","getUint32","hexDumpBuffer","n","width","stringBufferView","string","getUint16","Array","join","log","sha1","_h","_buffer","_length","reset","data","update","finalize","blockSize","_init","utf8String","nl","Uint32Array","c","_block","subarray","splice","h","_key","_f","t","d","_S","words","e","w","sha256","_precompute","factor","isPrime","prime","frac","pow","k","h0","h1","h2","h3","h4","h5","h6","h7","sha512","_initr","_keyr","frac2","wrh","wrl","h0h","h0l","h1h","h1l","h2h","h2l","h3h","h3l","h4h","h4l","h5h","h5l","h6h","h6l","h7h","h7l","ah","al","bh","bl","ch","cl","dh","dl","eh","el","fh","fl","gh","gl","hh","hl","gamma0xh","gamma0xl","gamma0h","gamma0l","gamma1xh","gamma1xl","gamma1h","gamma1l","wr7h","wr7l","wr16h","wr16l","chh","chl","majh","majl","sigma0h","sigma0l","sigma1h","sigma1l","krh","krl","t1l","t1h","t2l","hmac","key","Hash","_hash","exKey","bs","_baseHash","_resultHash","encrypt","mac","_updated","digest","result","NodeBuffer","Buffer","NodeCrypto","nodeBufferFromArrayBuffer","nodeBufferToArrayBuffer","from","nodeBuffer","uint8Array","size","bytes","algorithm","createHmac","BrowserCrypto","crypto","msCrypto","getRandomValues","array","warn","random","toLowerCase","Crypto","Secret","writable","defaults","issuer","label","counter","period","HOTP","secret","fromB32","generate","token","validate","encodeURIComponent","offset","otp","TOTP","timestamp","Date","now","OTPURI_PARAMS","OTPURI_REGEX","RegExp","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","uri","uriGroups","match","error","isArray","URIError","OTP","uriType","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","config","test","version"],"mappings":";;;u0BAIaA,MAAQ,CAMpBC,KAAM,CAOLC,QAAS,SAAAC,WACFC,EAAM,IAAIC,WAAWF,GACvBG,EAAM,EAEDC,EAAI,EAAGA,EAAIH,EAAII,OAAQD,IAChB,IAAXH,EAAIG,KACPD,GAAO,IACPA,GAAOF,EAAIG,WAIND,GAQRG,MAAO,SAAAH;QACAH,EAAM,IAAIO,YAAY,GACtBN,EAAM,IAAIC,WAAWF,GACvBQ,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