From 0a13a76b3ad15ef4b4aa4f345d68b602e5ad5d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Molinero=20Fern=C3=A1ndez?= Date: Sun, 29 Nov 2020 12:29:38 +0100 Subject: [PATCH] 6.2.0 --- dist/otpauth.cjs.js | 26 ++++++++++++++++------- dist/otpauth.cjs.min.js | 42 ++++++++++++++++++------------------- dist/otpauth.cjs.min.js.map | 2 +- dist/otpauth.esm.js | 26 ++++++++++++++++------- dist/otpauth.esm.min.js | 14 ++++++------- dist/otpauth.esm.min.js.map | 2 +- dist/otpauth.umd.js | 26 ++++++++++++++++------- dist/otpauth.umd.min.js | 20 +++++++++--------- dist/otpauth.umd.min.js.map | 2 +- docs/index.html | 22 +++++++++++++++++-- package-lock.json | 2 +- package.json | 2 +- 12 files changed, 117 insertions(+), 69 deletions(-) diff --git a/dist/otpauth.cjs.js b/dist/otpauth.cjs.js index 93cebbb6..fe4f8526 100644 --- a/dist/otpauth.cjs.js +++ b/dist/otpauth.cjs.js @@ -1,5 +1,5 @@ -/*! otpauth v6.1.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v6.2.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! sjcl v1.0.8 | (c) bitwiseshiftleft | (BSD-2-Clause OR GPL-2.0-only) | https://github.com/bitwiseshiftleft/sjcl */ 'use strict'; @@ -2212,6 +2212,7 @@ var HOTP = /*#__PURE__*/function () { * @param {string} config.token Token value. * @param {Secret} config.secret Secret key. * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm. + * @param {number} config.digits Token length. * @param {number} [config.counter=0] Counter value. * @param {number} [config.window=1] Window of counter values to test. * @returns {number|null} Token delta, or null if the token is not found. @@ -2234,9 +2235,10 @@ var HOTP = /*#__PURE__*/function () { counter = _ref3$counter === void 0 ? this.counter : _ref3$counter, window = _ref3.window; return HOTP.validate({ - token: Utils.pad(token, this.digits), + token: token, secret: this.secret, algorithm: this.algorithm, + digits: this.digits, counter: counter, window: window }); @@ -2273,25 +2275,29 @@ var HOTP = /*#__PURE__*/function () { var token = _ref5.token, secret = _ref5.secret, algorithm = _ref5.algorithm, + digits = _ref5.digits, _ref5$counter = _ref5.counter, counter = _ref5$counter === void 0 ? defaults.counter : _ref5$counter, _ref5$window = _ref5.window, window = _ref5$window === void 0 ? defaults.window : _ref5$window; + // Return early if the token length does not match the digit number. + if (token.length !== digits) return null; + var delta = null; for (var i = counter - window; i <= counter + window; ++i) { var generatedToken = HOTP.generate({ secret: secret, algorithm: algorithm, - digits: token.length, + digits: digits, counter: i }); - if (token.length === generatedToken.length && Crypto.timingSafeEqual(token, generatedToken)) { - return i - counter; + if (Crypto.timingSafeEqual(token, generatedToken)) { + delta = i - counter; } } - return null; + return delta; } }]); @@ -2403,6 +2409,7 @@ var TOTP = /*#__PURE__*/function () { * @param {string} config.token Token value. * @param {Secret} config.secret Secret key. * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm. + * @param {number} config.digits Token length. * @param {number} [config.period=30] Token time-step duration. * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds. * @param {number} [config.window=1] Window of counter values to test. @@ -2425,9 +2432,10 @@ var TOTP = /*#__PURE__*/function () { timestamp = _ref8.timestamp, window = _ref8.window; return TOTP.validate({ - token: Utils.pad(token, this.digits), + token: token, secret: this.secret, algorithm: this.algorithm, + digits: this.digits, period: this.period, timestamp: timestamp, window: window @@ -2467,6 +2475,7 @@ var TOTP = /*#__PURE__*/function () { var token = _ref10.token, secret = _ref10.secret, algorithm = _ref10.algorithm, + digits = _ref10.digits, _ref10$period = _ref10.period, period = _ref10$period === void 0 ? defaults.period : _ref10$period, _ref10$timestamp = _ref10.timestamp, @@ -2476,6 +2485,7 @@ var TOTP = /*#__PURE__*/function () { token: token, secret: secret, algorithm: algorithm, + digits: digits, counter: Math.floor(timestamp / 1000 / period), window: window }); @@ -2670,7 +2680,7 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = '6.1.0'; +var version = '6.2.0'; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.cjs.min.js b/dist/otpauth.cjs.min.js index 151f87fe..ca6b93f1 100644 --- a/dist/otpauth.cjs.min.js +++ b/dist/otpauth.cjs.min.js @@ -1,30 +1,30 @@ -/*! otpauth v6.1.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v6.2.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! sjcl v1.0.8 | (c) bitwiseshiftleft | (BSD-2-Clause OR GPL-2.0-only) | https://github.com/bitwiseshiftleft/sjcl */ "use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,i=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}Object.defineProperty(exports,"__esModule",{value:!0});var Utils={uint:{fromBuf:function(t){for(var e=new Uint8Array(t),r=0,i=0;i=0&&0!==i;n--)r[n]=255&i,i-=r[n],i/=256;return e}},raw:{fromBuf:function(t){for(var e=new Uint8Array(t),r="",i=0;i=5;)n+=Utils.b32.alphabet[i>>>r-5&31],r-=5;return r>0&&(n+=Utils.b32.alphabet[i<<5-r&31]),n},toBuf:function(t){t=t.toUpperCase().replace(/=+$/,"");for(var e=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(e),i=0,n=0,o=0,a=0;a=8&&(r[o++]=n>>>i-8&255,i-=8)}return e}},hex:{fromBuf:function(t){for(var e=new Uint8Array(t),r="",i=0;it.length)&&(e=t.length);for(var r=0,i=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}Object.defineProperty(exports,"__esModule",{value:!0});var Utils={uint:{fromBuf:function(t){for(var e=new Uint8Array(t),r=0,i=0;i=0&&0!==i;n--)r[n]=255&i,i-=r[n],i/=256;return e}},raw:{fromBuf:function(t){for(var e=new Uint8Array(t),r="",i=0;i=5;)n+=Utils.b32.alphabet[i>>>r-5&31],r-=5;return r>0&&(n+=Utils.b32.alphabet[i<<5-r&31]),n},toBuf:function(t){t=t.toUpperCase().replace(/=+$/,"");for(var e=new ArrayBuffer(5*t.length/8|0),r=new Uint8Array(e),i=0,n=0,o=0,s=0;s=8&&(r[o++]=n>>>i-8&255,i-=8)}return e}},hex:{fromBuf:function(t){for(var e=new Uint8Array(t),r="",i=0;i0;)r+="0";return"".concat(r).concat(t)}},InternalUtils={get globalThis(){var t;if("object"===("undefined"==typeof globalThis?"undefined":_typeof(globalThis)))t=globalThis;else{Object.defineProperty(Object.prototype,"__magicalGlobalThis__",{get:function(){return this},configurable:!0});try{t=__magicalGlobalThis__}finally{delete Object.prototype.__magicalGlobalThis__}}return void 0===t&&("undefined"!=typeof self?t=self:"undefined"!=typeof window?t=window:"undefined"!=typeof global&&(t=global)),Object.defineProperty(this,"globalThis",{enumerable:!0,value:t}),this.globalThis},get console(){ -var t={},e=["assert","clear","context","count","countReset","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeLog","timeStamp","trace","warn"];if("object"===_typeof(InternalUtils.globalThis.console)){var r,i=_createForOfIteratorHelper(e);try{for(i.s();!(r=i.n()).done;){var n=r.value;t[n]="function"==typeof InternalUtils.globalThis.console[n]?InternalUtils.globalThis.console[n]:function(){}}}catch(t){i.e(t)}finally{i.f()}}else{var o,a=_createForOfIteratorHelper(e);try{for(a.s();!(o=a.n()).done;){t[o.value]=function(){}}}catch(t){a.e(t)}finally{a.f()}}return Object.defineProperty(this,"console",{enumerable:!0,value:t}),this.console},get isNode(){var t="[object process]"===Object.prototype.toString.call(InternalUtils.globalThis.process);return Object.defineProperty(this,"isNode",{enumerable:!0,value:t}),this.isNode},get nodeRequire(){var _nodeRequire=InternalUtils.isNode?eval("require"):function(){} +var t={},e=["assert","clear","context","count","countReset","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeLog","timeStamp","trace","warn"];if("object"===_typeof(InternalUtils.globalThis.console)){var r,i=_createForOfIteratorHelper(e);try{for(i.s();!(r=i.n()).done;){var n=r.value;t[n]="function"==typeof InternalUtils.globalThis.console[n]?InternalUtils.globalThis.console[n]:function(){}}}catch(t){i.e(t)}finally{i.f()}}else{var o,s=_createForOfIteratorHelper(e);try{for(s.s();!(o=s.n()).done;){t[o.value]=function(){}}}catch(t){s.e(t)}finally{s.f()}}return Object.defineProperty(this,"console",{enumerable:!0,value:t}),this.console},get isNode(){var t="[object process]"===Object.prototype.toString.call(InternalUtils.globalThis.process);return Object.defineProperty(this,"isNode",{enumerable:!0,value:t}),this.isNode},get nodeRequire(){var _nodeRequire=InternalUtils.isNode?eval("require"):function(){} ;return Object.defineProperty(this,"nodeRequire",{enumerable:!0,value:_nodeRequire}),this.nodeRequire}},sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}},globals,randomBytes,hmacDigest,timingSafeEqual;if(sjcl.bitArray={bitSlice:function(t,e,r){return t=sjcl.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:sjcl.bitArray.clamp(t,r-e)},extract:function(t,e,r){var i=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-i^t[e/32+1|0]>>>i:t[e/32|0]>>>i)&(1<0&&e&&(t[r-1]=sjcl.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(sjcl.bitArray.bitLength(t)!==sjcl.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r=32;e-=32)i.push(r),r=0;if(0===e)return i.concat(t);for(n=0;n>>e),r=t[n]<<32-e;return o=t.length?t[t.length-1]:0,a=sjcl.bitArray.getPartial(o),i.push(sjcl.bitArray.partial(e+a&31,e+a>32?r:i.pop(),1)),i},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]}, -byteswapM:function(t){var e,r;for(e=0;e>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},"undefined"==typeof ArrayBuffer&&(globals=void 0,globals.ArrayBuffer=function(){},globals.DataView=function(){}),sjcl.codec.arrayBuffer={fromBits:function(t,e,r){var i,n,o,a,s;if(e=null==e||e,r=r||8,0===t.length)return new ArrayBuffer(0);if(o=sjcl.bitArray.bitLength(t)/8,sjcl.bitArray.bitLength(t)%8!=0)throw new sjcl.exception.invalid("Invalid bit size, must be divisble by 8 to fit in an arraybuffer correctly");for(e&&o%r!=0&&(o+=r-o%r),a=new DataView(new ArrayBuffer(4*t.length)),n=0;n=(r=4)?e:new Array(r-e.length+1).join("0")+e)+" ");void 0===typeof console&&(console=console||{log:function(){}}),console.log(n.toUpperCase())}},sjcl.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha1.hash=function(t){return(new sjcl.hash.sha1).update(t).finalize()},sjcl.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t) -;if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),a=0;for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=n;e+=this.blockSize)this._block(o.subarray(16*a,16*(a+1))),a+=1;r.splice(0,16*a)}else for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=n;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,r,i){return t<=19?e&r|~e&i:t<=39?e^r^i:t<=59?e&r|e&i|r&i:t<=79?e^r^i:void 0},_S:function(t,e){return e<>>32-t},_block:function(t){var e,r,i,n,o,a,s,l,h=this._h -;if("undefined"!=typeof Uint32Array){l=Array(80);for(var u=0;u<16;u++)l[u]=t[u]}else l=t;for(i=h[0],n=h[1],o=h[2],a=h[3],s=h[4],e=0;e<=79;e++)e>=16&&(l[e]=this._S(1,l[e-3]^l[e-8]^l[e-14]^l[e-16])),r=this._S(5,i)+this._f(e,n,o,a)+s+l[e]+this._key[Math.floor(e/20)]|0,s=a,a=o,o=this._S(30,n),n=i,i=r;h[0]=h[0]+i|0,h[1]=h[1]+n|0,h[2]=h[2]+o|0,h[3]=h[3]+a|0,h[4]=h[4]+s|0}},sjcl.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha256.hash=function(t){return(new sjcl.hash.sha256).update(t).finalize()},sjcl.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t) -;if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),a=0;for(e=512+i-(512+i&511);e<=n;e+=512)this._block(o.subarray(16*a,16*(a+1))),a+=1;r.splice(0,16*a)}else for(e=512+i-(512+i&511);e<=n;e+=512)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){var t,e,r=0,i=2;function n(t){return 4294967296*(t-Math.floor(t))|0}for(;r<64;i++){for(e=!0,t=2;t*t<=i;t++)if(i%t==0){e=!1;break}e&&(r<8&&(this._init[r]=n(Math.pow(i,.5))),this._key[r]=n(Math.pow(i,1/3)),r++)}},_block:function(t){var e,r,i,n,o=this._h,a=this._key,s=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],g=o[7];for(e=0;e<64;e++)e<16?r=t[e]:(i=t[e+1&15], -n=t[e+14&15],r=t[15&e]=(i>>>7^i>>>18^i>>>3^i<<25^i<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+g+(c>>>6^c>>>11^c>>>25^c<<26^c<<21^c<<7)+(d^c&(f^d))+a[e],g=d,d=f,f=c,c=u+r|0,u=h,h=l,s=r+((l=s)&h^u&(l^h))+(l>>>2^l>>>13^l>>>22^l<<30^l<<19^l<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+l|0,o[2]=o[2]+h|0,o[3]=o[3]+u|0,o[4]=o[4]+c|0,o[5]=o[5]+f|0,o[6]=o[6]+d|0,o[7]=o[7]+g|0}},sjcl.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha512.hash=function(t){return(new sjcl.hash.sha512).update(t).finalize()},sjcl.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t) -;if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),a=0;for(e=1024+i-(1024+i&1023);e<=n;e+=1024)this._block(o.subarray(32*a,32*(a+1))),a+=1;r.splice(0,32*a)}else for(e=1024+i-(1024+i&1023);e<=n;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,32));return this.reset(),r},_init:[],_initr:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],_key:[], +;return 32===i?t.concat(e):sjcl.bitArray._shiftRight(e,i,0|r,t.slice(0,t.length-1))},bitLength:function(t){var e,r=t.length;return 0===r?0:(e=t[r-1],32*(r-1)+sjcl.bitArray.getPartial(e))},clamp:function(t,e){if(32*t.length0&&e&&(t[r-1]=sjcl.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(sjcl.bitArray.bitLength(t)!==sjcl.bitArray.bitLength(e))return!1;var r,i=0;for(r=0;r=32;e-=32)i.push(r),r=0;if(0===e)return i.concat(t);for(n=0;n>>e),r=t[n]<<32-e;return o=t.length?t[t.length-1]:0,s=sjcl.bitArray.getPartial(o),i.push(sjcl.bitArray.partial(e+s&31,e+s>32?r:i.pop(),1)),i},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]}, +byteswapM:function(t){var e,r;for(e=0;e>>24|r>>>8&65280|(65280&r)<<8|r<<24;return t}},"undefined"==typeof ArrayBuffer&&(globals=void 0,globals.ArrayBuffer=function(){},globals.DataView=function(){}),sjcl.codec.arrayBuffer={fromBits:function(t,e,r){var i,n,o,s,a;if(e=null==e||e,r=r||8,0===t.length)return new ArrayBuffer(0);if(o=sjcl.bitArray.bitLength(t)/8,sjcl.bitArray.bitLength(t)%8!=0)throw new sjcl.exception.invalid("Invalid bit size, must be divisble by 8 to fit in an arraybuffer correctly");for(e&&o%r!=0&&(o+=r-o%r),s=new DataView(new ArrayBuffer(4*t.length)),n=0;n=(r=4)?e:new Array(r-e.length+1).join("0")+e)+" ");void 0===typeof console&&(console=console||{log:function(){}}),console.log(n.toUpperCase())}},sjcl.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha1.hash=function(t){return(new sjcl.hash.sha1).update(t).finalize()},sjcl.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t) +;if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),s=0;for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=n;e+=this.blockSize)this._block(o.subarray(16*s,16*(s+1))),s+=1;r.splice(0,16*s)}else for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=n;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,r,i){return t<=19?e&r|~e&i:t<=39?e^r^i:t<=59?e&r|e&i|r&i:t<=79?e^r^i:void 0},_S:function(t,e){return e<>>32-t},_block:function(t){var e,r,i,n,o,s,a,l,h=this._h +;if("undefined"!=typeof Uint32Array){l=Array(80);for(var u=0;u<16;u++)l[u]=t[u]}else l=t;for(i=h[0],n=h[1],o=h[2],s=h[3],a=h[4],e=0;e<=79;e++)e>=16&&(l[e]=this._S(1,l[e-3]^l[e-8]^l[e-14]^l[e-16])),r=this._S(5,i)+this._f(e,n,o,s)+a+l[e]+this._key[Math.floor(e/20)]|0,a=s,s=o,o=this._S(30,n),n=i,i=r;h[0]=h[0]+i|0,h[1]=h[1]+n|0,h[2]=h[2]+o|0,h[3]=h[3]+s|0,h[4]=h[4]+a|0}},sjcl.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha256.hash=function(t){return(new sjcl.hash.sha256).update(t).finalize()},sjcl.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t) +;if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),s=0;for(e=512+i-(512+i&511);e<=n;e+=512)this._block(o.subarray(16*s,16*(s+1))),s+=1;r.splice(0,16*s)}else for(e=512+i-(512+i&511);e<=n;e+=512)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){var t,e,r=0,i=2;function n(t){return 4294967296*(t-Math.floor(t))|0}for(;r<64;i++){for(e=!0,t=2;t*t<=i;t++)if(i%t==0){e=!1;break}e&&(r<8&&(this._init[r]=n(Math.pow(i,.5))),this._key[r]=n(Math.pow(i,1/3)),r++)}},_block:function(t){var e,r,i,n,o=this._h,s=this._key,a=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],g=o[7];for(e=0;e<64;e++)e<16?r=t[e]:(i=t[e+1&15], +n=t[e+14&15],r=t[15&e]=(i>>>7^i>>>18^i>>>3^i<<25^i<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+g+(c>>>6^c>>>11^c>>>25^c<<26^c<<21^c<<7)+(d^c&(f^d))+s[e],g=d,d=f,f=c,c=u+r|0,u=h,h=l,a=r+((l=a)&h^u&(l^h))+(l>>>2^l>>>13^l>>>22^l<<30^l<<19^l<<10)|0;o[0]=o[0]+a|0,o[1]=o[1]+l|0,o[2]=o[2]+h|0,o[3]=o[3]+u|0,o[4]=o[4]+c|0,o[5]=o[5]+f|0,o[6]=o[6]+d|0,o[7]=o[7]+g|0}},sjcl.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha512.hash=function(t){return(new sjcl.hash.sha512).update(t).finalize()},sjcl.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t) +;if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),s=0;for(e=1024+i-(1024+i&1023);e<=n;e+=1024)this._block(o.subarray(32*s,32*(s+1))),s+=1;r.splice(0,32*s)}else for(e=1024+i-(1024+i&1023);e<=n;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,32));return this.reset(),r},_init:[],_initr:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],_key:[], _keyr:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],_precompute:function(){var t,e,r=0,i=2;function n(t){return 4294967296*(t-Math.floor(t))|0}function o(t){return 1099511627776*(t-Math.floor(t))&255}for(;r<80;i++){for(e=!0,t=2;t*t<=i;t++)if(i%t==0){e=!1;break}e&&(r<8&&(this._init[2*r]=n(Math.pow(i,.5)),this._init[2*r+1]=o(Math.pow(i,.5))<<24|this._initr[r]),this._key[2*r]=n(Math.pow(i,1/3)), -this._key[2*r+1]=o(Math.pow(i,1/3))<<24|this._keyr[r],r++)}},_block:function(t){var e,r,i,n,o=this._h,a=this._key,s=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],g=o[7],p=o[8],y=o[9],b=o[10],v=o[11],m=o[12],_=o[13],w=o[14],A=o[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var j=0;j<32;j++)n[j]=t[j]}else n=t;var k=s,U=l,T=h,S=u,E=c,I=f,B=d,R=g,C=p,O=y,P=b,L=v,M=m,x=_,H=w,G=A;for(e=0;e<80;e++){if(e<16)r=n[2*e],i=n[2*e+1];else{var z=n[2*(e-15)],N=n[2*(e-15)+1],D=(N<<31|z>>>1)^(N<<24|z>>>8)^z>>>7,V=(z<<31|N>>>1)^(z<<24|N>>>8)^(z<<25|N>>>7),q=n[2*(e-2)],X=n[2*(e-2)+1],$=(X<<13|q>>>19)^(q<<3|X>>>29)^q>>>6,F=(q<<13|X>>>19)^(X<<3|q>>>29)^(q<<26|X>>>6),Y=n[2*(e-7)],Z=n[2*(e-7)+1],J=n[2*(e-16)],K=n[2*(e-16)+1];r=D+Y+((i=V+Z)>>>0>>0?1:0),r+=$+((i+=F)>>>0>>0?1:0),r+=J+((i+=K)>>>0>>0?1:0)}n[2*e]=r|=0,n[2*e+1]=i|=0 -;var Q=C&P^~C&M,W=O&L^~O&x,tt=k&T^k&E^T&E,et=U&S^U&I^S&I,rt=(U<<4|k>>>28)^(k<<30|U>>>2)^(k<<25|U>>>7),it=(k<<4|U>>>28)^(U<<30|k>>>2)^(U<<25|k>>>7),nt=(O<<18|C>>>14)^(O<<14|C>>>18)^(C<<23|O>>>9),ot=(C<<18|O>>>14)^(C<<14|O>>>18)^(O<<23|C>>>9),at=a[2*e],st=a[2*e+1],lt=G+ot,ht=H+nt+(lt>>>0>>0?1:0);ht+=Q+((lt+=W)>>>0>>0?1:0),ht+=at+((lt+=st)>>>0>>0?1:0);var ut=it+et;H=M,G=x,M=P,x=L,P=C,L=O,C=B+(ht+=r+((lt=lt+i|0)>>>0>>0?1:0))+((O=R+lt|0)>>>0>>0?1:0)|0,B=E,R=I,E=T,I=S,T=k,S=U,k=ht+(rt+tt+(ut>>>0>>0?1:0))+((U=lt+ut|0)>>>0>>0?1:0)|0}l=o[1]=l+U|0,o[0]=s+k+(l>>>0>>0?1:0)|0,u=o[3]=u+S|0,o[2]=h+T+(u>>>0>>0?1:0)|0,f=o[5]=f+I|0,o[4]=c+E+(f>>>0>>0?1:0)|0,g=o[7]=g+R|0,o[6]=d+B+(g>>>0>>0?1:0)|0,y=o[9]=y+O|0,o[8]=p+C+(y>>>0>>0?1:0)|0,v=o[11]=v+L|0,o[10]=b+P+(v>>>0>>0?1:0)|0,_=o[13]=_+x|0,o[12]=m+M+(_>>>0>>0?1:0)|0,A=o[15]=A+G|0,o[14]=w+H+(A>>>0>>0?1:0)|0}},sjcl.misc.hmac=function(t,e){this._hash=e=e||sjcl.hash.sha256;var r,i=[[],[]],n=e.prototype.blockSize/32 +this._key[2*r+1]=o(Math.pow(i,1/3))<<24|this._keyr[r],r++)}},_block:function(t){var e,r,i,n,o=this._h,s=this._key,a=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],g=o[7],p=o[8],y=o[9],b=o[10],v=o[11],m=o[12],_=o[13],w=o[14],A=o[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var j=0;j<32;j++)n[j]=t[j]}else n=t;var k=a,T=l,U=h,S=u,E=c,I=f,B=d,R=g,C=p,O=y,P=b,L=v,M=m,x=_,H=w,G=A;for(e=0;e<80;e++){if(e<16)r=n[2*e],i=n[2*e+1];else{var z=n[2*(e-15)],N=n[2*(e-15)+1],D=(N<<31|z>>>1)^(N<<24|z>>>8)^z>>>7,V=(z<<31|N>>>1)^(z<<24|N>>>8)^(z<<25|N>>>7),q=n[2*(e-2)],X=n[2*(e-2)+1],$=(X<<13|q>>>19)^(q<<3|X>>>29)^q>>>6,F=(q<<13|X>>>19)^(X<<3|q>>>29)^(q<<26|X>>>6),Y=n[2*(e-7)],Z=n[2*(e-7)+1],J=n[2*(e-16)],K=n[2*(e-16)+1];r=D+Y+((i=V+Z)>>>0>>0?1:0),r+=$+((i+=F)>>>0>>0?1:0),r+=J+((i+=K)>>>0>>0?1:0)}n[2*e]=r|=0,n[2*e+1]=i|=0 +;var Q=C&P^~C&M,W=O&L^~O&x,tt=k&U^k&E^U&E,et=T&S^T&I^S&I,rt=(T<<4|k>>>28)^(k<<30|T>>>2)^(k<<25|T>>>7),it=(k<<4|T>>>28)^(T<<30|k>>>2)^(T<<25|k>>>7),nt=(O<<18|C>>>14)^(O<<14|C>>>18)^(C<<23|O>>>9),ot=(C<<18|O>>>14)^(C<<14|O>>>18)^(O<<23|C>>>9),st=s[2*e],at=s[2*e+1],lt=G+ot,ht=H+nt+(lt>>>0>>0?1:0);ht+=Q+((lt+=W)>>>0>>0?1:0),ht+=st+((lt+=at)>>>0>>0?1:0);var ut=it+et;H=M,G=x,M=P,x=L,P=C,L=O,C=B+(ht+=r+((lt=lt+i|0)>>>0>>0?1:0))+((O=R+lt|0)>>>0>>0?1:0)|0,B=E,R=I,E=U,I=S,U=k,S=T,k=ht+(rt+tt+(ut>>>0>>0?1:0))+((T=lt+ut|0)>>>0>>0?1:0)|0}l=o[1]=l+T|0,o[0]=a+k+(l>>>0>>0?1:0)|0,u=o[3]=u+S|0,o[2]=h+U+(u>>>0>>0?1:0)|0,f=o[5]=f+I|0,o[4]=c+E+(f>>>0>>0?1:0)|0,g=o[7]=g+R|0,o[6]=d+B+(g>>>0>>0?1:0)|0,y=o[9]=y+O|0,o[8]=p+C+(y>>>0>>0?1:0)|0,v=o[11]=v+L|0,o[10]=b+P+(v>>>0>>0?1:0)|0,_=o[13]=_+x|0,o[12]=m+M+(_>>>0>>0?1:0)|0,A=o[15]=A+G|0,o[14]=w+H+(A>>>0>>0?1:0)|0}},sjcl.misc.hmac=function(t,e){this._hash=e=e||sjcl.hash.sha256;var r,i=[[],[]],n=e.prototype.blockSize/32 ;for(this._baseHash=[new e,new e],t.length>n&&(t=e.hash(t)),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=e.buffer,i=e.size,n=void 0===i?20:i;_classCallCheck(this,t),this.buffer=void 0===r?Crypto.randomBytes(n):r}return _createClass(t,[{key:"raw",get:function(){return Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:Utils.raw.fromBuf(this.buffer)}),this.raw}},{key:"b32",get:function(){return Object.defineProperty(this,"b32",{enumerable:!0,configurable:!0,writable:!0,value:Utils.b32.fromBuf(this.buffer)}),this.b32}},{key:"hex",get:function(){return Object.defineProperty(this,"hex",{enumerable:!0,configurable:!0,writable:!0,value:Utils.hex.fromBuf(this.buffer)}),this.hex}}],[{key:"fromRaw", -value:function(e){return new t({buffer:Utils.raw.toBuf(e)})}},{key:"fromB32",value:function(e){return new t({buffer:Utils.b32.toBuf(e)})}},{key:"fromHex",value:function(e){return new t({buffer:Utils.hex.toBuf(e)})}}]),t}(),defaults={issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,period:30,window:1},HOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,a=e.secret,s=void 0===a?new Secret:a,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.counter,d=void 0===f?defaults.counter:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof s?Secret.fromB32(s):s,this.algorithm=h,this.digits=c,this.counter=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.counter,i=void 0===r?this.counter++:r;return t.generate({secret:this.secret, -algorithm:this.algorithm,digits:this.digits,counter:i})}},{key:"validate",value:function(e){var r=e.token,i=e.counter,n=void 0===i?this.counter:i,o=e.window;return t.validate({token:Utils.pad(r,this.digits),secret:this.secret,algorithm:this.algorithm,counter:n,window:o})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"counter=".concat(t(this.counter))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=void 0===r?defaults.algorithm:r,n=t.digits,o=void 0===n?defaults.digits:n,a=t.counter,s=void 0===a?defaults.counter:a,l=new Uint8Array(Crypto.hmacDigest(i,e.buffer,Utils.uint.toBuf(s))),h=15&l[l.byteLength-1],u=((127&l[h])<<24|(255&l[h+1])<<16|(255&l[h+2])<<8|255&l[h+3])%Math.pow(10,o) -;return Utils.pad(u,o)}},{key:"validate",value:function(e){for(var r=e.token,i=e.secret,n=e.algorithm,o=e.counter,a=void 0===o?defaults.counter:o,s=e.window,l=void 0===s?defaults.window:s,h=a-l;h<=a+l;++h){var u=t.generate({secret:i,algorithm:n,digits:r.length,counter:h});if(r.length===u.length&&Crypto.timingSafeEqual(r,u))return h-a}return null}}]),t}(),TOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,a=e.secret,s=void 0===a?new Secret:a,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.period,d=void 0===f?defaults.period:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof s?Secret.fromB32(s):s,this.algorithm=h,this.digits=c,this.period=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.timestamp,i=void 0===r?Date.now():r -;return t.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i})}},{key:"validate",value:function(e){var r=e.token,i=e.timestamp,n=e.window;return t.validate({token:Utils.pad(r,this.digits),secret:this.secret,algorithm:this.algorithm,period:this.period,timestamp:i,window:n})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"period=".concat(t(this.period))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=t.digits,n=t.period,o=void 0===n?defaults.period:n,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:e,algorithm:r,digits:i,counter:Math.floor(s/1e3/o)})}},{key:"validate",value:function(t){ -var e=t.token,r=t.secret,i=t.algorithm,n=t.period,o=void 0===n?defaults.period:n,a=t.timestamp,s=void 0===a?Date.now():a,l=t.window;return HOTP.validate({token:e,secret:r,algorithm:i,counter:Math.floor(s/1e3/o),window:l})}}]),t}(),OTPURI_PARAMS=["issuer","secret","algorithm","digits","counter","period"],OTPURI_REGEX=new RegExp("^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?(?:".concat(OTPURI_PARAMS.join("|"),")=[^&]+)+)$"),"i"),SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|256|512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"parse",value:function(t){var e;try{e=t.match(OTPURI_REGEX)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");var r,i=e[1].toLowerCase(),n=e[2].split(/:(.+)/,2).map(decodeURIComponent),o=e[3].split("&").reduce((function(t,e){var r=e.split(/=(.+)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),n=r[1],o=t;return o[i]=n,o}),{}),a={};if("hotp"===i){ -if(r=HOTP,void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");a.counter=parseInt(o.counter,10)}else{if("totp"!==i)throw new TypeError("Unknown OTP type");if(r=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");a.period=parseInt(o.period,10)}}if(2===n.length)if(a.label=n[1],void 0===o.issuer)a.issuer=n[0];else{if(o.issuer!==n[0])throw new TypeError("Invalid 'issuer' parameter");a.issuer=o.issuer}else a.label=n[0],void 0!==o.issuer&&(a.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(a.secret=new Secret({buffer:Utils.b32.toBuf(o.secret)}),void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");a.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter") -;a.digits=parseInt(o.digits,10)}return new r(a)}},{key:"stringify",value:function(t){if(t instanceof HOTP||t instanceof TOTP)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),t}(),version="6.1.0";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.Utils=Utils,exports.version=version; +value:function(e){return new t({buffer:Utils.raw.toBuf(e)})}},{key:"fromB32",value:function(e){return new t({buffer:Utils.b32.toBuf(e)})}},{key:"fromHex",value:function(e){return new t({buffer:Utils.hex.toBuf(e)})}}]),t}(),defaults={issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,period:30,window:1},HOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,s=e.secret,a=void 0===s?new Secret:s,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.counter,d=void 0===f?defaults.counter:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof a?Secret.fromB32(a):a,this.algorithm=h,this.digits=c,this.counter=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.counter,i=void 0===r?this.counter++:r;return t.generate({secret:this.secret, +algorithm:this.algorithm,digits:this.digits,counter:i})}},{key:"validate",value:function(e){var r=e.token,i=e.counter,n=void 0===i?this.counter:i,o=e.window;return t.validate({token:r,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:n,window:o})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"counter=".concat(t(this.counter))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=void 0===r?defaults.algorithm:r,n=t.digits,o=void 0===n?defaults.digits:n,s=t.counter,a=void 0===s?defaults.counter:s,l=new Uint8Array(Crypto.hmacDigest(i,e.buffer,Utils.uint.toBuf(a))),h=15&l[l.byteLength-1],u=((127&l[h])<<24|(255&l[h+1])<<16|(255&l[h+2])<<8|255&l[h+3])%Math.pow(10,o) +;return Utils.pad(u,o)}},{key:"validate",value:function(e){var r=e.token,i=e.secret,n=e.algorithm,o=e.digits,s=e.counter,a=void 0===s?defaults.counter:s,l=e.window,h=void 0===l?defaults.window:l;if(r.length!==o)return null;for(var u=null,c=a-h;c<=a+h;++c){var f=t.generate({secret:i,algorithm:n,digits:o,counter:c});Crypto.timingSafeEqual(r,f)&&(u=c-a)}return u}}]),t}(),TOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,s=e.secret,a=void 0===s?new Secret:s,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.period,d=void 0===f?defaults.period:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof a?Secret.fromB32(a):a,this.algorithm=h,this.digits=c,this.period=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.timestamp,i=void 0===r?Date.now():r +;return t.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i})}},{key:"validate",value:function(e){var r=e.token,i=e.timestamp,n=e.window;return t.validate({token:r,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i,window:n})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"period=".concat(t(this.period))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=t.digits,n=t.period,o=void 0===n?defaults.period:n,s=t.timestamp,a=void 0===s?Date.now():s;return HOTP.generate({secret:e,algorithm:r,digits:i,counter:Math.floor(a/1e3/o)})}},{key:"validate",value:function(t){ +var e=t.token,r=t.secret,i=t.algorithm,n=t.digits,o=t.period,s=void 0===o?defaults.period:o,a=t.timestamp,l=void 0===a?Date.now():a,h=t.window;return HOTP.validate({token:e,secret:r,algorithm:i,digits:n,counter:Math.floor(l/1e3/s),window:h})}}]),t}(),OTPURI_PARAMS=["issuer","secret","algorithm","digits","counter","period"],OTPURI_REGEX=new RegExp("^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?(?:".concat(OTPURI_PARAMS.join("|"),")=[^&]+)+)$"),"i"),SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|256|512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"parse",value:function(t){var e;try{e=t.match(OTPURI_REGEX)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");var r,i=e[1].toLowerCase(),n=e[2].split(/:(.+)/,2).map(decodeURIComponent),o=e[3].split("&").reduce((function(t,e){var r=e.split(/=(.+)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),n=r[1],o=t;return o[i]=n,o}),{}),s={} +;if("hotp"===i){if(r=HOTP,void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");s.counter=parseInt(o.counter,10)}else{if("totp"!==i)throw new TypeError("Unknown OTP type");if(r=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");s.period=parseInt(o.period,10)}}if(2===n.length)if(s.label=n[1],void 0===o.issuer)s.issuer=n[0];else{if(o.issuer!==n[0])throw new TypeError("Invalid 'issuer' parameter");s.issuer=o.issuer}else s.label=n[0],void 0!==o.issuer&&(s.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(s.secret=new Secret({buffer:Utils.b32.toBuf(o.secret)}),void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");s.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter") +;s.digits=parseInt(o.digits,10)}return new r(s)}},{key:"stringify",value:function(t){if(t instanceof HOTP||t instanceof TOTP)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),t}(),version="6.2.0";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.Utils=Utils,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 040193ca..a780a373 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.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\tconst bytes = NodeCrypto.randomBytes(size);\n\t\treturn bytes.buffer;\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\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};\n\n\ttimingSafeEqual = (a, b) => {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\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\ttimingSafeEqual = (a, b) => {\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\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\t/**\n\t * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n\t * @param {string} a String a.\n\t * @param {string} b String b.\n\t * @returns {boolean} Equality result.\n\t */\n\ttimingSafeEqual\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 (\n\t\t\t\ttoken.length === generatedToken.length\n\t\t\t\t&& Crypto.timingSafeEqual(token, generatedToken)\n\t\t\t) {\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';\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","timingSafeEqual","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","size","algorithm","createHmac","from","BrowserCrypto","crypto","msCrypto","getRandomValues","array","warn","random","bytes","toLowerCase","Crypto","Secret","writable","defaults","issuer","label","counter","period","HOTP","secret","fromB32","generate","token","validate","encodeURIComponent","offset","otp","generatedToken","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,EAAML,EAEDC,EAAI,EAAGA,GAAK,GACR,IAARI,EADmBJ,IAGvBH,EAAIG,GAAW,IAANI,EACTA,GAAOP,EAAIG,GACXI,GAAO,WAGDR,IASTS,IAAK,CAOJV,QAAS,SAAAC,WACFC,EAAM,IAAIC,WAAWF,GACvBU,EAAM,GAEDN,EAAI,EAAGA,EAAIH,EAAII,OAAQD,IAC/BM,GAAOC,OAAOC,aAAaX,EAAIG,WAGzBM,GAQRJ,MAAO,SAAAI,WACAV,EAAM,IAAIO,YAAYG,EAAIL,QAC1BJ,EAAM,IAAIC,WAAWF,GAElBI,EAAI,EAAGA,EAAIM,EAAIL,OAAQD,IAC/BH,EAAIG,GAAKM,EAAIG,WAAWT,UAGlBJ,IASTc,IAAK,CAMJC,SAAU,mCAQVhB,QAAS,SAAAC,WACFC,EAAM,IAAIC,WAAWF,GAEvBgB,EAAO,EACPC,EAAQ,EACRP,EAAM,GAEDN,EAAI,EAAGA,EAAIH,EAAII,OAAQD,QAC/Ba,EAASA,GAAS,EAAKhB,EAAIG,GAC3BY,GAAQ,EAEDA,GAAQ,GACdN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hP,UAAU,iCAFpB6S,EAAO7D,UAAYsD,EAAUtD,kBAOC,IAArBsD,EAAU/R,OAAwB,KACxCiR,uBAAuBsB,KAAKR,EAAU/R,cAGnC,IAAIP,UAAU;CAFpB6S,EAAOtS,OAASH,SAASkS,EAAU/R,OAAQ,WAMtC,IAAIyR,EAAIa,qCASCjC,MACZA,aAAeR,MAAQQ,aAAeE,YAClCF,EAAI1Q,iBAGN,IAAIF,UAAU,uCClKT+S,QAAU"} \ No newline at end of file +{"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\tconst bytes = NodeCrypto.randomBytes(size);\n\t\treturn bytes.buffer;\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\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};\n\n\ttimingSafeEqual = (a, b) => {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\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\ttimingSafeEqual = (a, b) => {\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\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\t/**\n\t * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n\t * @param {string} a String a.\n\t * @param {string} b String b.\n\t * @returns {boolean} Equality result.\n\t */\n\ttimingSafeEqual\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.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 = defaults.counter,\n\t\twindow = 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 (Crypto.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.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.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 = 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.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';\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","timingSafeEqual","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","size","algorithm","createHmac","from","BrowserCrypto","crypto","msCrypto","getRandomValues","array","warn","random","bytes","toLowerCase","Crypto","Secret","writable","defaults","issuer","label","counter","period","HOTP","secret","fromB32","generate","token","validate","encodeURIComponent","offset","otp","delta","generatedToken","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,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IF,UAAU,uCClKTgT,QAAU"} \ No newline at end of file diff --git a/dist/otpauth.esm.js b/dist/otpauth.esm.js index 0b0bf25e..93f7f6e8 100644 --- a/dist/otpauth.esm.js +++ b/dist/otpauth.esm.js @@ -1,5 +1,5 @@ -/*! otpauth v6.1.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v6.2.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! sjcl v1.0.8 | (c) bitwiseshiftleft | (BSD-2-Clause OR GPL-2.0-only) | https://github.com/bitwiseshiftleft/sjcl */ function _typeof(obj) { "@babel/helpers - typeof"; @@ -2208,6 +2208,7 @@ var HOTP = /*#__PURE__*/function () { * @param {string} config.token Token value. * @param {Secret} config.secret Secret key. * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm. + * @param {number} config.digits Token length. * @param {number} [config.counter=0] Counter value. * @param {number} [config.window=1] Window of counter values to test. * @returns {number|null} Token delta, or null if the token is not found. @@ -2230,9 +2231,10 @@ var HOTP = /*#__PURE__*/function () { counter = _ref3$counter === void 0 ? this.counter : _ref3$counter, window = _ref3.window; return HOTP.validate({ - token: Utils.pad(token, this.digits), + token: token, secret: this.secret, algorithm: this.algorithm, + digits: this.digits, counter: counter, window: window }); @@ -2269,25 +2271,29 @@ var HOTP = /*#__PURE__*/function () { var token = _ref5.token, secret = _ref5.secret, algorithm = _ref5.algorithm, + digits = _ref5.digits, _ref5$counter = _ref5.counter, counter = _ref5$counter === void 0 ? defaults.counter : _ref5$counter, _ref5$window = _ref5.window, window = _ref5$window === void 0 ? defaults.window : _ref5$window; + // Return early if the token length does not match the digit number. + if (token.length !== digits) return null; + var delta = null; for (var i = counter - window; i <= counter + window; ++i) { var generatedToken = HOTP.generate({ secret: secret, algorithm: algorithm, - digits: token.length, + digits: digits, counter: i }); - if (token.length === generatedToken.length && Crypto.timingSafeEqual(token, generatedToken)) { - return i - counter; + if (Crypto.timingSafeEqual(token, generatedToken)) { + delta = i - counter; } } - return null; + return delta; } }]); @@ -2399,6 +2405,7 @@ var TOTP = /*#__PURE__*/function () { * @param {string} config.token Token value. * @param {Secret} config.secret Secret key. * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm. + * @param {number} config.digits Token length. * @param {number} [config.period=30] Token time-step duration. * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds. * @param {number} [config.window=1] Window of counter values to test. @@ -2421,9 +2428,10 @@ var TOTP = /*#__PURE__*/function () { timestamp = _ref8.timestamp, window = _ref8.window; return TOTP.validate({ - token: Utils.pad(token, this.digits), + token: token, secret: this.secret, algorithm: this.algorithm, + digits: this.digits, period: this.period, timestamp: timestamp, window: window @@ -2463,6 +2471,7 @@ var TOTP = /*#__PURE__*/function () { var token = _ref10.token, secret = _ref10.secret, algorithm = _ref10.algorithm, + digits = _ref10.digits, _ref10$period = _ref10.period, period = _ref10$period === void 0 ? defaults.period : _ref10$period, _ref10$timestamp = _ref10.timestamp, @@ -2472,6 +2481,7 @@ var TOTP = /*#__PURE__*/function () { token: token, secret: secret, algorithm: algorithm, + digits: digits, counter: Math.floor(timestamp / 1000 / period), window: window }); @@ -2666,6 +2676,6 @@ var URI = /*#__PURE__*/function () { * Library version. * @type {string} */ -var version = '6.1.0'; +var version = '6.2.0'; export { HOTP, Secret, TOTP, URI, Utils, version }; diff --git a/dist/otpauth.esm.min.js b/dist/otpauth.esm.min.js index 0290b67a..e34999f7 100644 --- a/dist/otpauth.esm.min.js +++ b/dist/otpauth.esm.min.js @@ -1,4 +1,4 @@ -/*! otpauth v6.1.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v6.2.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! sjcl v1.0.8 | (c) bitwiseshiftleft | (BSD-2-Clause OR GPL-2.0-only) | https://github.com/bitwiseshiftleft/sjcl */ function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,i=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var Utils={uint:{fromBuf:function(t){for(var e=new Uint8Array(t),r=0,i=0;i=0&&0!==i;n--)r[n]=255&i,i-=r[n],i/=256 @@ -21,10 +21,10 @@ this._key[2*r+1]=o(Math.pow(i,1/3))<<24|this._keyr[r],r++)}},_block:function(t){ var i=NodeCrypto.createHmac(t,NodeBuffer.from(e));return i.update(NodeBuffer.from(r)),i.digest().buffer},timingSafeEqual=function(t,e){return NodeCrypto.timingSafeEqual(NodeBuffer.from(t),NodeBuffer.from(e))}}else{var BrowserCrypto=InternalUtils.globalThis.crypto||InternalUtils.globalThis.msCrypto,getRandomValues;void 0!==BrowserCrypto&&"function"==typeof BrowserCrypto.getRandomValues?getRandomValues=function(t){BrowserCrypto.getRandomValues(t)}:(InternalUtils.console.warn("Cryptography API not available, falling back to 'Math.random'..."),getRandomValues=function(t){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:{},r=e.buffer,i=e.size,n=void 0===i?20:i;_classCallCheck(this,t),this.buffer=void 0===r?Crypto.randomBytes(n):r}return _createClass(t,[{key:"raw",get:function(){return Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:Utils.raw.fromBuf(this.buffer)}),this.raw}},{key:"b32",get:function(){return Object.defineProperty(this,"b32",{enumerable:!0,configurable:!0,writable:!0,value:Utils.b32.fromBuf(this.buffer)}),this.b32}},{key:"hex",get:function(){return Object.defineProperty(this,"hex",{enumerable:!0,configurable:!0,writable:!0,value:Utils.hex.fromBuf(this.buffer)}),this.hex}}],[{key:"fromRaw", value:function(e){return new t({buffer:Utils.raw.toBuf(e)})}},{key:"fromB32",value:function(e){return new t({buffer:Utils.b32.toBuf(e)})}},{key:"fromHex",value:function(e){return new t({buffer:Utils.hex.toBuf(e)})}}]),t}(),defaults={issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,period:30,window:1},HOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,a=e.secret,s=void 0===a?new Secret:a,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.counter,d=void 0===f?defaults.counter:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof s?Secret.fromB32(s):s,this.algorithm=h,this.digits=c,this.counter=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.counter,i=void 0===r?this.counter++:r;return t.generate({secret:this.secret, -algorithm:this.algorithm,digits:this.digits,counter:i})}},{key:"validate",value:function(e){var r=e.token,i=e.counter,n=void 0===i?this.counter:i,o=e.window;return t.validate({token:Utils.pad(r,this.digits),secret:this.secret,algorithm:this.algorithm,counter:n,window:o})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"counter=".concat(t(this.counter))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=void 0===r?defaults.algorithm:r,n=t.digits,o=void 0===n?defaults.digits:n,a=t.counter,s=void 0===a?defaults.counter:a,l=new Uint8Array(Crypto.hmacDigest(i,e.buffer,Utils.uint.toBuf(s))),h=15&l[l.byteLength-1],u=((127&l[h])<<24|(255&l[h+1])<<16|(255&l[h+2])<<8|255&l[h+3])%Math.pow(10,o) -;return Utils.pad(u,o)}},{key:"validate",value:function(e){for(var r=e.token,i=e.secret,n=e.algorithm,o=e.counter,a=void 0===o?defaults.counter:o,s=e.window,l=void 0===s?defaults.window:s,h=a-l;h<=a+l;++h){var u=t.generate({secret:i,algorithm:n,digits:r.length,counter:h});if(r.length===u.length&&Crypto.timingSafeEqual(r,u))return h-a}return null}}]),t}(),TOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,a=e.secret,s=void 0===a?new Secret:a,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.period,d=void 0===f?defaults.period:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof s?Secret.fromB32(s):s,this.algorithm=h,this.digits=c,this.period=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.timestamp,i=void 0===r?Date.now():r -;return t.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i})}},{key:"validate",value:function(e){var r=e.token,i=e.timestamp,n=e.window;return t.validate({token:Utils.pad(r,this.digits),secret:this.secret,algorithm:this.algorithm,period:this.period,timestamp:i,window:n})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"period=".concat(t(this.period))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=t.digits,n=t.period,o=void 0===n?defaults.period:n,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:e,algorithm:r,digits:i,counter:Math.floor(s/1e3/o)})}},{key:"validate",value:function(t){ -var e=t.token,r=t.secret,i=t.algorithm,n=t.period,o=void 0===n?defaults.period:n,a=t.timestamp,s=void 0===a?Date.now():a,l=t.window;return HOTP.validate({token:e,secret:r,algorithm:i,counter:Math.floor(s/1e3/o),window:l})}}]),t}(),OTPURI_PARAMS=["issuer","secret","algorithm","digits","counter","period"],OTPURI_REGEX=new RegExp("^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?(?:".concat(OTPURI_PARAMS.join("|"),")=[^&]+)+)$"),"i"),SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|256|512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"parse",value:function(t){var e;try{e=t.match(OTPURI_REGEX)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");var r,i=e[1].toLowerCase(),n=e[2].split(/:(.+)/,2).map(decodeURIComponent),o=e[3].split("&").reduce((function(t,e){var r=e.split(/=(.+)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),n=r[1],o=t;return o[i]=n,o}),{}),a={};if("hotp"===i){ -if(r=HOTP,void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");a.counter=parseInt(o.counter,10)}else{if("totp"!==i)throw new TypeError("Unknown OTP type");if(r=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");a.period=parseInt(o.period,10)}}if(2===n.length)if(a.label=n[1],void 0===o.issuer)a.issuer=n[0];else{if(o.issuer!==n[0])throw new TypeError("Invalid 'issuer' parameter");a.issuer=o.issuer}else a.label=n[0],void 0!==o.issuer&&(a.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(a.secret=new Secret({buffer:Utils.b32.toBuf(o.secret)}),void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");a.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter") -;a.digits=parseInt(o.digits,10)}return new r(a)}},{key:"stringify",value:function(t){if(t instanceof HOTP||t instanceof TOTP)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),t}(),version="6.1.0";export{HOTP,Secret,TOTP,URI,Utils,version}; +algorithm:this.algorithm,digits:this.digits,counter:i})}},{key:"validate",value:function(e){var r=e.token,i=e.counter,n=void 0===i?this.counter:i,o=e.window;return t.validate({token:r,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:n,window:o})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"counter=".concat(t(this.counter))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=void 0===r?defaults.algorithm:r,n=t.digits,o=void 0===n?defaults.digits:n,a=t.counter,s=void 0===a?defaults.counter:a,l=new Uint8Array(Crypto.hmacDigest(i,e.buffer,Utils.uint.toBuf(s))),h=15&l[l.byteLength-1],u=((127&l[h])<<24|(255&l[h+1])<<16|(255&l[h+2])<<8|255&l[h+3])%Math.pow(10,o) +;return Utils.pad(u,o)}},{key:"validate",value:function(e){var r=e.token,i=e.secret,n=e.algorithm,o=e.digits,a=e.counter,s=void 0===a?defaults.counter:a,l=e.window,h=void 0===l?defaults.window:l;if(r.length!==o)return null;for(var u=null,c=s-h;c<=s+h;++c){var f=t.generate({secret:i,algorithm:n,digits:o,counter:c});Crypto.timingSafeEqual(r,f)&&(u=c-s)}return u}}]),t}(),TOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,a=e.secret,s=void 0===a?new Secret:a,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.period,d=void 0===f?defaults.period:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof s?Secret.fromB32(s):s,this.algorithm=h,this.digits=c,this.period=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.timestamp,i=void 0===r?Date.now():r +;return t.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i})}},{key:"validate",value:function(e){var r=e.token,i=e.timestamp,n=e.window;return t.validate({token:r,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i,window:n})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"period=".concat(t(this.period))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=t.digits,n=t.period,o=void 0===n?defaults.period:n,a=t.timestamp,s=void 0===a?Date.now():a;return HOTP.generate({secret:e,algorithm:r,digits:i,counter:Math.floor(s/1e3/o)})}},{key:"validate",value:function(t){ +var e=t.token,r=t.secret,i=t.algorithm,n=t.digits,o=t.period,a=void 0===o?defaults.period:o,s=t.timestamp,l=void 0===s?Date.now():s,h=t.window;return HOTP.validate({token:e,secret:r,algorithm:i,digits:n,counter:Math.floor(l/1e3/a),window:h})}}]),t}(),OTPURI_PARAMS=["issuer","secret","algorithm","digits","counter","period"],OTPURI_REGEX=new RegExp("^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?(?:".concat(OTPURI_PARAMS.join("|"),")=[^&]+)+)$"),"i"),SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|256|512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"parse",value:function(t){var e;try{e=t.match(OTPURI_REGEX)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");var r,i=e[1].toLowerCase(),n=e[2].split(/:(.+)/,2).map(decodeURIComponent),o=e[3].split("&").reduce((function(t,e){var r=e.split(/=(.+)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),n=r[1],o=t;return o[i]=n,o}),{}),a={} +;if("hotp"===i){if(r=HOTP,void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");a.counter=parseInt(o.counter,10)}else{if("totp"!==i)throw new TypeError("Unknown OTP type");if(r=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");a.period=parseInt(o.period,10)}}if(2===n.length)if(a.label=n[1],void 0===o.issuer)a.issuer=n[0];else{if(o.issuer!==n[0])throw new TypeError("Invalid 'issuer' parameter");a.issuer=o.issuer}else a.label=n[0],void 0!==o.issuer&&(a.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(a.secret=new Secret({buffer:Utils.b32.toBuf(o.secret)}),void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");a.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter") +;a.digits=parseInt(o.digits,10)}return new r(a)}},{key:"stringify",value:function(t){if(t instanceof HOTP||t instanceof TOTP)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),t}(),version="6.2.0";export{HOTP,Secret,TOTP,URI,Utils,version}; //# sourceMappingURL=otpauth.esm.min.js.map diff --git a/dist/otpauth.esm.min.js.map b/dist/otpauth.esm.min.js.map index 2a7c906d..0c7a2ecb 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.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\tconst bytes = NodeCrypto.randomBytes(size);\n\t\treturn bytes.buffer;\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\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};\n\n\ttimingSafeEqual = (a, b) => {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\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\ttimingSafeEqual = (a, b) => {\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\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\t/**\n\t * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n\t * @param {string} a String a.\n\t * @param {string} b String b.\n\t * @returns {boolean} Equality result.\n\t */\n\ttimingSafeEqual\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 (\n\t\t\t\ttoken.length === generatedToken.length\n\t\t\t\t&& Crypto.timingSafeEqual(token, generatedToken)\n\t\t\t) {\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';\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","timingSafeEqual","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","size","algorithm","createHmac","from","BrowserCrypto","crypto","msCrypto","getRandomValues","array","warn","random","bytes","toLowerCase","Crypto","Secret","writable","defaults","issuer","label","counter","period","HOTP","secret","fromB32","generate","token","validate","encodeURIComponent","offset","otp","generatedToken","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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N,IAAIF,UAAU,uCClKT+S,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.esm.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\tconst bytes = NodeCrypto.randomBytes(size);\n\t\treturn bytes.buffer;\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\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};\n\n\ttimingSafeEqual = (a, b) => {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\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\ttimingSafeEqual = (a, b) => {\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\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\t/**\n\t * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n\t * @param {string} a String a.\n\t * @param {string} b String b.\n\t * @returns {boolean} Equality result.\n\t */\n\ttimingSafeEqual\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.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 = defaults.counter,\n\t\twindow = 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 (Crypto.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.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.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 = 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.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';\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","timingSafeEqual","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","size","algorithm","createHmac","from","BrowserCrypto","crypto","msCrypto","getRandomValues","array","warn","random","bytes","toLowerCase","Crypto","Secret","writable","defaults","issuer","label","counter","period","HOTP","secret","fromB32","generate","token","validate","encodeURIComponent","offset","otp","delta","generatedToken","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":";;;gxBAIaA,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,WACAH,EAAM,IAAIO,YAAY,GACtBN,EAAM,IAAIC,WAAWF,GACvBQ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IlS,UAAU,uBAXpBiS,EAAMlB,UAG0B,IAArBwB,EAAUpC,OAAwB,KACxCsB,uBAAuBsB,KAAKR,EAAUpC,cAGnC,IAAInQ,UAAU,8BAFpB8S,EAAO3C,OAAS/P,SAASmS,EAAUpC,OAAQ,QAWtB,IAApBgC,EAASrT,UACZgU,EAAO7C,MAAQkC,EAAS,QACQ,IAArBI,EAAUvC,OACpB8C,EAAO9C,OAASmC,EAAS,OACnB,CAAA,GAAII,EAAUvC,SAAWmC,EAAS,SAGlC,IAAInS,UAAU,8BAFpB8S,EAAO9C,OAASuC,EAAUvC,YAK3B8C,EAAO7C,MAAQkC,EAAS,QACQ,IAArBI,EAAUvC,SACpB8C,EAAO9C,OAASuC,EAAUvC,gBAKI,IAArBuC,EAAUlC,SAA0BiB,aAAayB,KAAKR,EAAUlC,cAGpE,IAAIrQ,UAAU,4CAFpB8S,EAAOzC,OAAS,IAAIR,OAAO,CAAEtJ,OAAQjI,MAAMiB,IAAIR,MAAMwT,EAAUlC,eAM7B,IAAxBkC,EAAUvD,UAA2B,KAC3CuC,gBAAgBwB,KAAKR,EAAUvD,iBAG5B,IAAIhP,UAAU,iCAFpB8S,EAAO9D,UAAYuD,EAAUvD,kBAOC,IAArBuD,EAAUhS,OAAwB,KACxCkR,uBAAuBsB,KAAKR,EAAUhS,cAGnC,IAAIP,UAAU;CAFpB8S,EAAOvS,OAASH,SAASmS,EAAUhS,OAAQ,WAMtC,IAAI0R,EAAIa,qCASClC,MACZA,aAAeR,MAAQQ,aAAeG,YAClCH,EAAI1Q,iBAGN,IAAIF,UAAU,uCClKTgT,QAAU"} \ No newline at end of file diff --git a/dist/otpauth.umd.js b/dist/otpauth.umd.js index 5ab86b1f..7142324c 100644 --- a/dist/otpauth.umd.js +++ b/dist/otpauth.umd.js @@ -1,5 +1,5 @@ -/*! otpauth v6.1.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v6.2.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! sjcl v1.0.8 | (c) bitwiseshiftleft | (BSD-2-Clause OR GPL-2.0-only) | https://github.com/bitwiseshiftleft/sjcl */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : @@ -2214,6 +2214,7 @@ * @param {string} config.token Token value. * @param {Secret} config.secret Secret key. * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm. + * @param {number} config.digits Token length. * @param {number} [config.counter=0] Counter value. * @param {number} [config.window=1] Window of counter values to test. * @returns {number|null} Token delta, or null if the token is not found. @@ -2236,9 +2237,10 @@ counter = _ref3$counter === void 0 ? this.counter : _ref3$counter, window = _ref3.window; return HOTP.validate({ - token: Utils.pad(token, this.digits), + token: token, secret: this.secret, algorithm: this.algorithm, + digits: this.digits, counter: counter, window: window }); @@ -2275,25 +2277,29 @@ var token = _ref5.token, secret = _ref5.secret, algorithm = _ref5.algorithm, + digits = _ref5.digits, _ref5$counter = _ref5.counter, counter = _ref5$counter === void 0 ? defaults.counter : _ref5$counter, _ref5$window = _ref5.window, window = _ref5$window === void 0 ? defaults.window : _ref5$window; + // Return early if the token length does not match the digit number. + if (token.length !== digits) return null; + var delta = null; for (var i = counter - window; i <= counter + window; ++i) { var generatedToken = HOTP.generate({ secret: secret, algorithm: algorithm, - digits: token.length, + digits: digits, counter: i }); - if (token.length === generatedToken.length && Crypto.timingSafeEqual(token, generatedToken)) { - return i - counter; + if (Crypto.timingSafeEqual(token, generatedToken)) { + delta = i - counter; } } - return null; + return delta; } }]); @@ -2405,6 +2411,7 @@ * @param {string} config.token Token value. * @param {Secret} config.secret Secret key. * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm. + * @param {number} config.digits Token length. * @param {number} [config.period=30] Token time-step duration. * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds. * @param {number} [config.window=1] Window of counter values to test. @@ -2427,9 +2434,10 @@ timestamp = _ref8.timestamp, window = _ref8.window; return TOTP.validate({ - token: Utils.pad(token, this.digits), + token: token, secret: this.secret, algorithm: this.algorithm, + digits: this.digits, period: this.period, timestamp: timestamp, window: window @@ -2469,6 +2477,7 @@ var token = _ref10.token, secret = _ref10.secret, algorithm = _ref10.algorithm, + digits = _ref10.digits, _ref10$period = _ref10.period, period = _ref10$period === void 0 ? defaults.period : _ref10$period, _ref10$timestamp = _ref10.timestamp, @@ -2478,6 +2487,7 @@ token: token, secret: secret, algorithm: algorithm, + digits: digits, counter: Math.floor(timestamp / 1000 / period), window: window }); @@ -2672,7 +2682,7 @@ * Library version. * @type {string} */ - var version = '6.1.0'; + var version = '6.2.0'; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.umd.min.js b/dist/otpauth.umd.min.js index 77f32696..65d9068c 100644 --- a/dist/otpauth.umd.min.js +++ b/dist/otpauth.umd.min.js @@ -1,4 +1,4 @@ -/*! otpauth v6.1.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ +/*! otpauth v6.2.0 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth */ /*! sjcl v1.0.8 | (c) bitwiseshiftleft | (BSD-2-Clause OR GPL-2.0-only) | https://github.com/bitwiseshiftleft/sjcl */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).OTPAuth={})}(this,(function(exports){"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,i=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{ @@ -12,19 +12,19 @@ i.push(sjcl.bitArray.partial(e+s&31,e+s>32?r:i.pop(),1)),i},_xor4:function(t,e){ "string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t));var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t);if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),s=0;for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=n;e+=this.blockSize)this._block(o.subarray(16*s,16*(s+1))),s+=1;r.splice(0,16*s)}else for(e=this.blockSize+i-(this.blockSize+i&this.blockSize-1);e<=n;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,r,i){ return t<=19?e&r|~e&i:t<=39?e^r^i:t<=59?e&r|e&i|r&i:t<=79?e^r^i:void 0},_S:function(t,e){return e<>>32-t},_block:function(t){var e,r,i,n,o,s,a,l,h=this._h;if("undefined"!=typeof Uint32Array){l=Array(80);for(var u=0;u<16;u++)l[u]=t[u]}else l=t;for(i=h[0],n=h[1],o=h[2],s=h[3],a=h[4],e=0;e<=79;e++)e>=16&&(l[e]=this._S(1,l[e-3]^l[e-8]^l[e-14]^l[e-16])),r=this._S(5,i)+this._f(e,n,o,s)+a+l[e]+this._key[Math.floor(e/20)]|0,a=s,s=o,o=this._S(30,n),n=i,i=r;h[0]=h[0]+i|0,h[1]=h[1]+n|0,h[2]=h[2]+o|0,h[3]=h[3]+s|0,h[4]=h[4]+a|0}},sjcl.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha256.hash=function(t){return(new sjcl.hash.sha256).update(t).finalize()},sjcl.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t)) ;var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t);if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),s=0;for(e=512+i-(512+i&511);e<=n;e+=512)this._block(o.subarray(16*s,16*(s+1))),s+=1;r.splice(0,16*s)}else for(e=512+i-(512+i&511);e<=n;e+=512)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){var t,e,r=0,i=2;function n(t){return 4294967296*(t-Math.floor(t))|0}for(;r<64;i++){for(e=!0,t=2;t*t<=i;t++)if(i%t==0){e=!1;break}e&&(r<8&&(this._init[r]=n(Math.pow(i,.5))),this._key[r]=n(Math.pow(i,1/3)),r++)}},_block:function(t){ -var e,r,i,n,o=this._h,s=this._key,a=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],p=o[7];for(e=0;e<64;e++)e<16?r=t[e]:(i=t[e+1&15],n=t[e+14&15],r=t[15&e]=(i>>>7^i>>>18^i>>>3^i<<25^i<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+p+(c>>>6^c>>>11^c>>>25^c<<26^c<<21^c<<7)+(d^c&(f^d))+s[e],p=d,d=f,f=c,c=u+r|0,u=h,h=l,a=r+((l=a)&h^u&(l^h))+(l>>>2^l>>>13^l>>>22^l<<30^l<<19^l<<10)|0;o[0]=o[0]+a|0,o[1]=o[1]+l|0,o[2]=o[2]+h|0,o[3]=o[3]+u|0,o[4]=o[4]+c|0,o[5]=o[5]+f|0,o[6]=o[6]+d|0,o[7]=o[7]+p|0}},sjcl.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha512.hash=function(t){return(new sjcl.hash.sha512).update(t).finalize()},sjcl.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t)) +var e,r,i,n,o=this._h,s=this._key,a=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],g=o[7];for(e=0;e<64;e++)e<16?r=t[e]:(i=t[e+1&15],n=t[e+14&15],r=t[15&e]=(i>>>7^i>>>18^i>>>3^i<<25^i<<14)+(n>>>17^n>>>19^n>>>10^n<<15^n<<13)+t[15&e]+t[e+9&15]|0),r=r+g+(c>>>6^c>>>11^c>>>25^c<<26^c<<21^c<<7)+(d^c&(f^d))+s[e],g=d,d=f,f=c,c=u+r|0,u=h,h=l,a=r+((l=a)&h^u&(l^h))+(l>>>2^l>>>13^l>>>22^l<<30^l<<19^l<<10)|0;o[0]=o[0]+a|0,o[1]=o[1]+l|0,o[2]=o[2]+h|0,o[3]=o[3]+u|0,o[4]=o[4]+c|0,o[5]=o[5]+f|0,o[6]=o[6]+d|0,o[7]=o[7]+g|0}},sjcl.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},sjcl.hash.sha512.hash=function(t){return(new sjcl.hash.sha512).update(t).finalize()},sjcl.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=sjcl.codec.utf8String.toBits(t)) ;var e,r=this._buffer=sjcl.bitArray.concat(this._buffer,t),i=this._length,n=this._length=i+sjcl.bitArray.bitLength(t);if(n>9007199254740991)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var o=new Uint32Array(r),s=0;for(e=1024+i-(1024+i&1023);e<=n;e+=1024)this._block(o.subarray(32*s,32*(s+1))),s+=1;r.splice(0,32*s)}else for(e=1024+i-(1024+i&1023);e<=n;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=sjcl.bitArray.concat(e,[sjcl.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,32));return this.reset(),r},_init:[],_initr:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],_key:[], _keyr:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],_precompute:function(){var t,e,r=0,i=2;function n(t){return 4294967296*(t-Math.floor(t))|0}function o(t){return 1099511627776*(t-Math.floor(t))&255}for(;r<80;i++){for(e=!0,t=2;t*t<=i;t++)if(i%t==0){e=!1;break}e&&(r<8&&(this._init[2*r]=n(Math.pow(i,.5)),this._init[2*r+1]=o(Math.pow(i,.5))<<24|this._initr[r]),this._key[2*r]=n(Math.pow(i,1/3)), -this._key[2*r+1]=o(Math.pow(i,1/3))<<24|this._keyr[r],r++)}},_block:function(t){var e,r,i,n,o=this._h,s=this._key,a=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],p=o[7],g=o[8],y=o[9],b=o[10],v=o[11],m=o[12],_=o[13],w=o[14],A=o[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var j=0;j<32;j++)n[j]=t[j]}else n=t;var T=a,k=l,U=h,S=u,E=c,I=f,B=d,R=p,C=g,O=y,P=b,x=v,L=m,M=_,H=w,G=A;for(e=0;e<80;e++){if(e<16)r=n[2*e],i=n[2*e+1];else{var z=n[2*(e-15)],N=n[2*(e-15)+1],D=(N<<31|z>>>1)^(N<<24|z>>>8)^z>>>7,V=(z<<31|N>>>1)^(z<<24|N>>>8)^(z<<25|N>>>7),q=n[2*(e-2)],X=n[2*(e-2)+1],$=(X<<13|q>>>19)^(q<<3|X>>>29)^q>>>6,F=(q<<13|X>>>19)^(X<<3|q>>>29)^(q<<26|X>>>6),Y=n[2*(e-7)],Z=n[2*(e-7)+1],J=n[2*(e-16)],K=n[2*(e-16)+1];r=D+Y+((i=V+Z)>>>0>>0?1:0),r+=$+((i+=F)>>>0>>0?1:0),r+=J+((i+=K)>>>0>>0?1:0)}n[2*e]=r|=0,n[2*e+1]=i|=0 -;var Q=C&P^~C&L,W=O&x^~O&M,tt=T&U^T&E^U&E,et=k&S^k&I^S&I,rt=(k<<4|T>>>28)^(T<<30|k>>>2)^(T<<25|k>>>7),it=(T<<4|k>>>28)^(k<<30|T>>>2)^(k<<25|T>>>7),nt=(O<<18|C>>>14)^(O<<14|C>>>18)^(C<<23|O>>>9),ot=(C<<18|O>>>14)^(C<<14|O>>>18)^(O<<23|C>>>9),st=s[2*e],at=s[2*e+1],lt=G+ot,ht=H+nt+(lt>>>0>>0?1:0);ht+=Q+((lt+=W)>>>0>>0?1:0),ht+=st+((lt+=at)>>>0>>0?1:0);var ut=it+et;H=L,G=M,L=P,M=x,P=C,x=O,C=B+(ht+=r+((lt=lt+i|0)>>>0>>0?1:0))+((O=R+lt|0)>>>0>>0?1:0)|0,B=E,R=I,E=U,I=S,U=T,S=k,T=ht+(rt+tt+(ut>>>0>>0?1:0))+((k=lt+ut|0)>>>0>>0?1:0)|0}l=o[1]=l+k|0,o[0]=a+T+(l>>>0>>0?1:0)|0,u=o[3]=u+S|0,o[2]=h+U+(u>>>0>>0?1:0)|0,f=o[5]=f+I|0,o[4]=c+E+(f>>>0>>0?1:0)|0,p=o[7]=p+R|0,o[6]=d+B+(p>>>0>>0?1:0)|0,y=o[9]=y+O|0,o[8]=g+C+(y>>>0>>0?1:0)|0,v=o[11]=v+x|0,o[10]=b+P+(v>>>0>>0?1:0)|0,_=o[13]=_+M|0,o[12]=m+L+(_>>>0>>0?1:0)|0,A=o[15]=A+G|0,o[14]=w+H+(A>>>0>>0?1:0)|0}},sjcl.misc.hmac=function(t,e){this._hash=e=e||sjcl.hash.sha256;var r,i=[[],[]],n=e.prototype.blockSize/32 +this._key[2*r+1]=o(Math.pow(i,1/3))<<24|this._keyr[r],r++)}},_block:function(t){var e,r,i,n,o=this._h,s=this._key,a=o[0],l=o[1],h=o[2],u=o[3],c=o[4],f=o[5],d=o[6],g=o[7],p=o[8],y=o[9],b=o[10],v=o[11],m=o[12],_=o[13],w=o[14],A=o[15];if("undefined"!=typeof Uint32Array){n=Array(160);for(var j=0;j<32;j++)n[j]=t[j]}else n=t;var T=a,k=l,U=h,S=u,E=c,I=f,B=d,R=g,C=p,O=y,P=b,x=v,L=m,M=_,H=w,G=A;for(e=0;e<80;e++){if(e<16)r=n[2*e],i=n[2*e+1];else{var z=n[2*(e-15)],N=n[2*(e-15)+1],D=(N<<31|z>>>1)^(N<<24|z>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|0,_=o[13]=_+M|0,o[12]=m+L+(_>>>0>>0?1:0)|0,A=o[15]=A+G|0,o[14]=w+H+(A>>>0>>0?1:0)|0}},sjcl.misc.hmac=function(t,e){this._hash=e=e||sjcl.hash.sha256;var r,i=[[],[]],n=e.prototype.blockSize/32 ;for(this._baseHash=[new e,new e],t.length>n&&(t=e.hash(t)),r=0;r0&&void 0!==arguments[0]?arguments[0]:{},r=e.buffer,i=e.size,n=void 0===i?20:i;_classCallCheck(this,t),this.buffer=void 0===r?Crypto.randomBytes(n):r}return _createClass(t,[{key:"raw",get:function(){return Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:Utils.raw.fromBuf(this.buffer)}),this.raw}},{key:"b32",get:function(){return Object.defineProperty(this,"b32",{enumerable:!0,configurable:!0,writable:!0,value:Utils.b32.fromBuf(this.buffer)}),this.b32}},{key:"hex",get:function(){return Object.defineProperty(this,"hex",{enumerable:!0,configurable:!0,writable:!0,value:Utils.hex.fromBuf(this.buffer)}),this.hex}}],[{key:"fromRaw", value:function(e){return new t({buffer:Utils.raw.toBuf(e)})}},{key:"fromB32",value:function(e){return new t({buffer:Utils.b32.toBuf(e)})}},{key:"fromHex",value:function(e){return new t({buffer:Utils.hex.toBuf(e)})}}]),t}(),defaults={issuer:"",label:"OTPAuth",algorithm:"SHA1",digits:6,counter:0,period:30,window:1},HOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,s=e.secret,a=void 0===s?new Secret:s,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.counter,d=void 0===f?defaults.counter:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof a?Secret.fromB32(a):a,this.algorithm=h,this.digits=c,this.counter=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.counter,i=void 0===r?this.counter++:r;return t.generate({secret:this.secret, -algorithm:this.algorithm,digits:this.digits,counter:i})}},{key:"validate",value:function(e){var r=e.token,i=e.counter,n=void 0===i?this.counter:i,o=e.window;return t.validate({token:Utils.pad(r,this.digits),secret:this.secret,algorithm:this.algorithm,counter:n,window:o})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"counter=".concat(t(this.counter))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=void 0===r?defaults.algorithm:r,n=t.digits,o=void 0===n?defaults.digits:n,s=t.counter,a=void 0===s?defaults.counter:s,l=new Uint8Array(Crypto.hmacDigest(i,e.buffer,Utils.uint.toBuf(a))),h=15&l[l.byteLength-1],u=((127&l[h])<<24|(255&l[h+1])<<16|(255&l[h+2])<<8|255&l[h+3])%Math.pow(10,o) -;return Utils.pad(u,o)}},{key:"validate",value:function(e){for(var r=e.token,i=e.secret,n=e.algorithm,o=e.counter,s=void 0===o?defaults.counter:o,a=e.window,l=void 0===a?defaults.window:a,h=s-l;h<=s+l;++h){var u=t.generate({secret:i,algorithm:n,digits:r.length,counter:h});if(r.length===u.length&&Crypto.timingSafeEqual(r,u))return h-s}return null}}]),t}(),TOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,s=e.secret,a=void 0===s?new Secret:s,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.period,d=void 0===f?defaults.period:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof a?Secret.fromB32(a):a,this.algorithm=h,this.digits=c,this.period=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.timestamp,i=void 0===r?Date.now():r -;return t.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i})}},{key:"validate",value:function(e){var r=e.token,i=e.timestamp,n=e.window;return t.validate({token:Utils.pad(r,this.digits),secret:this.secret,algorithm:this.algorithm,period:this.period,timestamp:i,window:n})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"period=".concat(t(this.period))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=t.digits,n=t.period,o=void 0===n?defaults.period:n,s=t.timestamp,a=void 0===s?Date.now():s;return HOTP.generate({secret:e,algorithm:r,digits:i,counter:Math.floor(a/1e3/o)})}},{key:"validate",value:function(t){ -var e=t.token,r=t.secret,i=t.algorithm,n=t.period,o=void 0===n?defaults.period:n,s=t.timestamp,a=void 0===s?Date.now():s,l=t.window;return HOTP.validate({token:e,secret:r,algorithm:i,counter:Math.floor(a/1e3/o),window:l})}}]),t}(),OTPURI_PARAMS=["issuer","secret","algorithm","digits","counter","period"],OTPURI_REGEX=new RegExp("^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?(?:".concat(OTPURI_PARAMS.join("|"),")=[^&]+)+)$"),"i"),SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|256|512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"parse",value:function(t){var e;try{e=t.match(OTPURI_REGEX)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");var r,i=e[1].toLowerCase(),n=e[2].split(/:(.+)/,2).map(decodeURIComponent),o=e[3].split("&").reduce((function(t,e){var r=e.split(/=(.+)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),n=r[1],o=t;return o[i]=n,o}),{}),s={};if("hotp"===i){ -if(r=HOTP,void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");s.counter=parseInt(o.counter,10)}else{if("totp"!==i)throw new TypeError("Unknown OTP type");if(r=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");s.period=parseInt(o.period,10)}}if(2===n.length)if(s.label=n[1],void 0===o.issuer)s.issuer=n[0];else{if(o.issuer!==n[0])throw new TypeError("Invalid 'issuer' parameter");s.issuer=o.issuer}else s.label=n[0],void 0!==o.issuer&&(s.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(s.secret=new Secret({buffer:Utils.b32.toBuf(o.secret)}),void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");s.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter") -;s.digits=parseInt(o.digits,10)}return new r(s)}},{key:"stringify",value:function(t){if(t instanceof HOTP||t instanceof TOTP)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),t}(),version="6.1.0";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.Utils=Utils,exports.version=version,Object.defineProperty(exports,"__esModule",{value:!0})})); +algorithm:this.algorithm,digits:this.digits,counter:i})}},{key:"validate",value:function(e){var r=e.token,i=e.counter,n=void 0===i?this.counter:i,o=e.window;return t.validate({token:r,secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:n,window:o})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://hotp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"counter=".concat(t(this.counter))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=void 0===r?defaults.algorithm:r,n=t.digits,o=void 0===n?defaults.digits:n,s=t.counter,a=void 0===s?defaults.counter:s,l=new Uint8Array(Crypto.hmacDigest(i,e.buffer,Utils.uint.toBuf(a))),h=15&l[l.byteLength-1],u=((127&l[h])<<24|(255&l[h+1])<<16|(255&l[h+2])<<8|255&l[h+3])%Math.pow(10,o) +;return Utils.pad(u,o)}},{key:"validate",value:function(e){var r=e.token,i=e.secret,n=e.algorithm,o=e.digits,s=e.counter,a=void 0===s?defaults.counter:s,l=e.window,h=void 0===l?defaults.window:l;if(r.length!==o)return null;for(var u=null,c=a-h;c<=a+h;++c){var f=t.generate({secret:i,algorithm:n,digits:o,counter:c});Crypto.timingSafeEqual(r,f)&&(u=c-a)}return u}}]),t}(),TOTP=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.issuer,i=void 0===r?defaults.issuer:r,n=e.label,o=void 0===n?defaults.label:n,s=e.secret,a=void 0===s?new Secret:s,l=e.algorithm,h=void 0===l?defaults.algorithm:l,u=e.digits,c=void 0===u?defaults.digits:u,f=e.period,d=void 0===f?defaults.period:f;_classCallCheck(this,t),this.issuer=i,this.label=o,this.secret="string"==typeof a?Secret.fromB32(a):a,this.algorithm=h,this.digits=c,this.period=d}return _createClass(t,[{key:"generate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.timestamp,i=void 0===r?Date.now():r +;return t.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i})}},{key:"validate",value:function(e){var r=e.token,i=e.timestamp,n=e.window;return t.validate({token:r,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:i,window:n})}},{key:"toString",value:function(){var t=encodeURIComponent;return"otpauth://totp/"+"".concat(this.issuer.length>0?"".concat(t(this.issuer),":").concat(t(this.label),"?issuer=").concat(t(this.issuer),"&"):"".concat(t(this.label),"?"))+"secret=".concat(t(this.secret.b32),"&")+"algorithm=".concat(t(this.algorithm),"&")+"digits=".concat(t(this.digits),"&")+"period=".concat(t(this.period))}}],[{key:"generate",value:function(t){var e=t.secret,r=t.algorithm,i=t.digits,n=t.period,o=void 0===n?defaults.period:n,s=t.timestamp,a=void 0===s?Date.now():s;return HOTP.generate({secret:e,algorithm:r,digits:i,counter:Math.floor(a/1e3/o)})}},{key:"validate",value:function(t){ +var e=t.token,r=t.secret,i=t.algorithm,n=t.digits,o=t.period,s=void 0===o?defaults.period:o,a=t.timestamp,l=void 0===a?Date.now():a,h=t.window;return HOTP.validate({token:e,secret:r,algorithm:i,digits:n,counter:Math.floor(l/1e3/s),window:h})}}]),t}(),OTPURI_PARAMS=["issuer","secret","algorithm","digits","counter","period"],OTPURI_REGEX=new RegExp("^otpauth:\\/\\/([ht]otp)\\/(.+)\\?((?:&?(?:".concat(OTPURI_PARAMS.join("|"),")=[^&]+)+)$"),"i"),SECRET_REGEX=/^[2-7A-Z]+=*$/i,ALGORITHM_REGEX=/^SHA(?:1|256|512)$/i,INTEGER_REGEX=/^[+-]?\d+$/,POSITIVE_INTEGER_REGEX=/^\+?[1-9]\d*$/,URI=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"parse",value:function(t){var e;try{e=t.match(OTPURI_REGEX)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");var r,i=e[1].toLowerCase(),n=e[2].split(/:(.+)/,2).map(decodeURIComponent),o=e[3].split("&").reduce((function(t,e){var r=e.split(/=(.+)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),n=r[1],o=t;return o[i]=n,o}),{}),s={} +;if("hotp"===i){if(r=HOTP,void 0===o.counter||!INTEGER_REGEX.test(o.counter))throw new TypeError("Missing or invalid 'counter' parameter");s.counter=parseInt(o.counter,10)}else{if("totp"!==i)throw new TypeError("Unknown OTP type");if(r=TOTP,void 0!==o.period){if(!POSITIVE_INTEGER_REGEX.test(o.period))throw new TypeError("Invalid 'period' parameter");s.period=parseInt(o.period,10)}}if(2===n.length)if(s.label=n[1],void 0===o.issuer)s.issuer=n[0];else{if(o.issuer!==n[0])throw new TypeError("Invalid 'issuer' parameter");s.issuer=o.issuer}else s.label=n[0],void 0!==o.issuer&&(s.issuer=o.issuer);if(void 0===o.secret||!SECRET_REGEX.test(o.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(s.secret=new Secret({buffer:Utils.b32.toBuf(o.secret)}),void 0!==o.algorithm){if(!ALGORITHM_REGEX.test(o.algorithm))throw new TypeError("Invalid 'algorithm' parameter");s.algorithm=o.algorithm}if(void 0!==o.digits){if(!POSITIVE_INTEGER_REGEX.test(o.digits))throw new TypeError("Invalid 'digits' parameter") +;s.digits=parseInt(o.digits,10)}return new r(s)}},{key:"stringify",value:function(t){if(t instanceof HOTP||t instanceof TOTP)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}]),t}(),version="6.2.0";exports.HOTP=HOTP,exports.Secret=Secret,exports.TOTP=TOTP,exports.URI=URI,exports.Utils=Utils,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 a4f563b6..ee1dc77b 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.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\tconst bytes = NodeCrypto.randomBytes(size);\n\t\treturn bytes.buffer;\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\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};\n\n\ttimingSafeEqual = (a, b) => {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\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\ttimingSafeEqual = (a, b) => {\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\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\t/**\n\t * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n\t * @param {string} a String a.\n\t * @param {string} b String b.\n\t * @returns {boolean} Equality result.\n\t */\n\ttimingSafeEqual\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 (\n\t\t\t\ttoken.length === generatedToken.length\n\t\t\t\t&& Crypto.timingSafeEqual(token, generatedToken)\n\t\t\t) {\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';\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","timingSafeEqual","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","size","algorithm","createHmac","from","BrowserCrypto","crypto","msCrypto","getRandomValues","array","warn","random","bytes","toLowerCase","Crypto","Secret","writable","defaults","issuer","label","counter","period","HOTP","secret","fromB32","generate","token","validate","encodeURIComponent","offset","otp","generatedToken","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":";;;;0DAIaA,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,WACAH,EAAM,IAAIO,YAAY,GACtBN,EAAM,IAAIC,WAAWF,GACvBQ,EAAML,EAEDC,EAAI,EAAGA,GAAK,GACR,IAARI,EADmBJ,IAGvBH,EAAIG,GAAW,IAANI,EACTA,GAAOP,EAAIG,GACXI,GAAO,WAGDR,IASTS,IAAK,CAOJV,QAAS,SAAAC,WACFC,EAAM,IAAIC,WAAWF,GACvBU,EAAM,GAEDN,EAAI,EAAGA,EAAIH,EAAII,OAAQD,IAC/BM,GAAOC,OAAOC,aAAaX,EAAIG,WAGzBM,GAQRJ,MAAO,SAAAI,WACA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S,UAAU,8BAFpB6S,EAAO7C,OAASsC,EAAUtC,YAK3B6C,EAAO5C,MAAQiC,EAAS,QACQ,IAArBI,EAAUtC,SACpB6C,EAAO7C,OAASsC,EAAUtC,gBAKI,IAArBsC,EAAUjC,SAA0BgB,aAAayB,KAAKR,EAAUjC,cAGpE,IAAIrQ,UAAU,4CAFpB6S,EAAOxC,OAAS,IAAIR,OAAO,CAAEtJ,OAAQjI,MAAMiB,IAAIR,MAAMuT,EAAUjC,eAM7B,IAAxBiC,EAAUtD,UAA2B,KAC3CsC,gBAAgBwB,KAAKR,EAAUtD,iBAG5B,IAAIhP,UAAU,iCAFpB6S,EAAO7D,UAAYsD,EAAUtD,kBAOC,IAArBsD,EAAU/R,OAAwB,KACxCiR,uBAAuBsB,KAAKR,EAAU/R,cAGnC,IAAIP,UAAU;CAFpB6S,EAAOtS,OAASH,SAASkS,EAAU/R,OAAQ,WAMtC,IAAIyR,EAAIa,qCASCjC,MACZA,aAAeR,MAAQQ,aAAeE,YAClCF,EAAI1Q,iBAGN,IAAIF,UAAU,uCClKT+S,QAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.umd.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\tconst bytes = NodeCrypto.randomBytes(size);\n\t\treturn bytes.buffer;\n\t};\n\n\thmacDigest = (algorithm, key, message) => {\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};\n\n\ttimingSafeEqual = (a, b) => {\n\t\treturn NodeCrypto.timingSafeEqual(NodeBuffer.from(a), NodeBuffer.from(b));\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\ttimingSafeEqual = (a, b) => {\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\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\t/**\n\t * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n\t * @param {string} a String a.\n\t * @param {string} b String b.\n\t * @returns {boolean} Equality result.\n\t */\n\ttimingSafeEqual\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.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 = defaults.counter,\n\t\twindow = 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 (Crypto.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.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.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 = 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.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';\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","timingSafeEqual","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","size","algorithm","createHmac","from","BrowserCrypto","crypto","msCrypto","getRandomValues","array","warn","random","bytes","toLowerCase","Crypto","Secret","writable","defaults","issuer","label","counter","period","HOTP","secret","fromB32","generate","token","validate","encodeURIComponent","offset","otp","delta","generatedToken","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":";;;;0DAIaA,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,WACAH,EAAM,IAAIO,YAAY,GACtBN,EAAM,IAAIC,WAAWF,GACvBQ,EAAML,EAEDC,EAAI,EAAGA,GAAK,GACR,IAARI,EADmBJ,IAGvBH,EAAIG,GAAW,IAANI,EACTA,GAAOP,EAAIG,GACXI,GAAO,WAGDR,IASTS,IAAK,CAOJV,QAAS,SAAAC,WACFC,EAAM,IAAIC,WAAWF,GACvBU,EAAM,GAEDN,EAAI,EAAGA,EAAIH,EAAII,OAAQD,IAC/BM,GAAOC,OAAOC,aAAaX,EAAIG,WAGzBM,GAQRJ,MAAO,SAAAI,WACAV,EAAM,IAAIO,YAAYG,EAAIL,QAC1BJ,EAAM,IAAIC,WAAWF,GAElBI,EAAI,EAAGA,EAAIM,EAAIL,OAAQD,IAC/BH,EAAIG,GAAKM,EAAIG,WAAWT,UAGlBJ,IASTc,IAAK,CAMJC,SAAU,mCAQVhB,QAAS,SAAAC,WACFC,EAAM,IAAIC,WAAWF,GAEvBgB,EAAO,EACPC,EAAQ,EACRP,EAAM,GAEDN,EAAI,EAAGA,E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,MAAMiB,IAAIR,MAAMwT,EAAUlC,eAM7B,IAAxBkC,EAAUvD,UAA2B,KAC3CuC,gBAAgBwB,KAAKR,EAAUvD,iBAG5B,IAAIhP,UAAU,iCAFpB8S,EAAO9D,UAAYuD,EAAUvD,kBAOC,IAArBuD,EAAUhS,OAAwB,KACxCkR,uBAAuBsB,KAAKR,EAAUhS,cAGnC,IAAIP,UAAU;CAFpB8S,EAAOvS,OAASH,SAASmS,EAAUhS,OAAQ,WAMtC,IAAI0R,EAAIa,qCASClC,MACZA,aAAeR,MAAQQ,aAAeG,YAClCH,EAAI1Q,iBAGN,IAAIF,UAAU,uCClKTgT,QAAU"} \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 93d1c261..151c3b03 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@ - otpauth 6.1.0 | Documentation + otpauth 6.2.0 | Documentation @@ -15,7 +15,7 @@

otpauth

-
6.1.0
+
6.2.0
+ + config.digits number + + Token length. + + + + + config.counter number @@ -1831,6 +1840,15 @@

+ + config.digits number + + Token length. + + + + + config.period number diff --git a/package-lock.json b/package-lock.json index 39ad85c2..03ab7c80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "otpauth", - "version": "6.1.0", + "version": "6.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8a321239..55d77ed1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "otpauth", - "version": "6.1.0", + "version": "6.2.0", "description": "One Time Password (HOTP/TOTP) library for Node.js, Deno and browsers", "keywords": [ "otp",