mirror of
https://github.com/hectorm/otpauth.git
synced 2026-05-07 20:12:27 +00:00
1.0.1
This commit is contained in:
+43
-44
@@ -1,45 +1,44 @@
|
||||
/*! OTPAuth v1.0.0 | (c) Héctor Molinero Fernández <hector@molinero.xyz> | https://github.com/zant95/otpauth | MIT */
|
||||
(function(){'use strict';var M={scope:{},getGlobal:function(w){return"undefined"!=typeof window&&window===w?w:"undefined"!=typeof global&&null!=global?global:w}};M.global=M.getGlobal(this);
|
||||
function U(w){return function(k){function h(e){if(g[e])return g[e].exports;var d=g[e]={i:e,l:!1,exports:{}};k[e].call(d.exports,d,d.exports,h);d.l=!0;return d.exports}var g={};h.m=k;h.c=g;h.i=function(e){return e};h.d=function(e,d,a){h.o(e,d)||Object.defineProperty(e,d,{configurable:!1,enumerable:!0,get:a})};h.n=function(e){var d=e&&e.__esModule?function(){return e["default"]}:function(){return e};h.d(d,"a",d);return d};h.o=function(e,d){return Object.prototype.hasOwnProperty.call(e,d)};h.p="";return h(h.s=
|
||||
8)}([function(k,h){function g(){}M.global.Object.defineProperties(g,{uint:{configurable:!0,enumerable:!0,get:function(){return{decode:function(e){e=new Uint8Array(e);for(var d=0,a=0;a<e.length;a++)0!==e[a]&&(d*=256,d+=e[a]);return d},encode:function(e){for(var d=new ArrayBuffer(8),a=new Uint8Array(d),b=7;0<=b&&0!==e;b--)a[b]=e&255,e-=a[b],e/=256;return d}}}},raw:{configurable:!0,enumerable:!0,get:function(){return{decode:function(e){return String.fromCharCode.apply(null,new Uint8Array(e))},encode:function(e){for(var d=
|
||||
new ArrayBuffer(e.length),a=new Uint8Array(d),b=0;b<e.length;b++)a[b]=e.charCodeAt(b);return d}}}},b32:{configurable:!0,enumerable:!0,get:function(){return{decode:function(e){e=new Uint8Array(e);for(var d=0,a=0,b="",c=0;c<e.length;c++)for(a=a<<8|e[c],d+=8;5<=d;)b+="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"[a>>>d-5&31],d-=5;0<d&&(b+="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"[a<<5-d&31]);return b},encode:function(e){var d=e.toUpperCase();e=new ArrayBuffer(5*e.length/8|0);for(var a=new Uint8Array(e),b=0,c=0,f=0,l=0;l<
|
||||
d.length;l++){var N="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(d[l]);if(-1===N)throw Error("Invalid character found: "+d[l]);c=c<<5|N;b+=5;8<=b&&(a[f++]=c>>>b-8&255,b-=8)}return e}}}},hex:{configurable:!0,enumerable:!0,get:function(){return{decode:function(e){e=new Uint8Array(e);for(var d="",a=0;a<e.length;a++)var b=e[a].toString(16),d=d+(1===b.length?"0"+b:b);return d.toUpperCase()},encode:function(e){for(var d=new ArrayBuffer(e.length/2),a=new Uint8Array(d),b=0;b<a.length;b++)a[b]=parseInt(e.substr(2*
|
||||
b,2),16);return d}}}}});h.a=g},function(k,h,g){(function(e){function d(a){a=(void 0===a?{}:a).buffer;this.buffer="undefined"===typeof a?this.buffer=d.getRandomBytes():a;this.raw=c.a.raw.decode(this.buffer);this.b32=c.a.b32.decode(this.buffer);this.hex=c.a.hex.decode(this.buffer)}var a=g(5),b=g.n(a),c=g(0);d.getRandomBytes=function(a){a=void 0===a?{}:a;a=void 0===a.size?20:a.size;if("undefined"!==typeof b.a&&"undefined"!==typeof b.a.randomBytes)a=new Uint8Array(b.a.randomBytes(a).buffer,0,a);else if(a=
|
||||
new Uint8Array(a),"undefined"!==typeof e.crypto&&"undefined"!==typeof e.crypto.getRandomValues)e.crypto.getRandomValues(a);else if("undefined"!==typeof e.msCrypto&&"undefined"!==typeof e.msCrypto.getRandomValues)e.msCrypto.getRandomValues(a);else for(var l=0;l<a.length;l++)a[l]=Math.floor(256*Math.random());return a.buffer};h.a=d}).call(h,g(6))},function(k,h,g){function e(){}k=g(5);var d=g.n(k);k=g(7);var a=g.n(k),b={SHA1:"sha1",SHA256:"sha256",SHA512:"sha512"};e.digest=function(c){var f=c.algorithm,
|
||||
l=c.key;c=c.message;if(!(f in b))throw Error("Unknown hash function");if("undefined"!==typeof d.a&&"undefined"!==typeof d.a.createHmac)l=d.a.createHmac(f,new Uint8Array(l)),l.update(new Uint8Array(c)),c=l.digest();else if("undefined"!==typeof a.a){var e=a.a.hash[b[f]],f=a.a.codec.arrayBuffer.fromBits,g=a.a.codec.arrayBuffer.toBits,l=new a.a.misc.hmac(g(l),e);l.update(g(c));c=f(l.digest(),!1)}else throw Error("Unable to create HMAC digest");return c};h.a=e},function(k,h,g){function e(a){var c=void 0===
|
||||
a?{}:a;a=void 0===c.issuer?"":c.issuer;var l=void 0===c.label?"OTPAuth":c.label,f=void 0===c.secret?new b.a:c.secret,d=void 0===c.algorithm?"SHA1":c.algorithm,e=void 0===c.digits?6:c.digits,c=void 0===c.period?30:c.period;this.issuer=a;this.label=l;this.secret=f;this.algorithm=d;this.digits=e;this.period=c}function d(a){var c=void 0===a?{}:a;a=void 0===c.issuer?"":c.issuer;var l=void 0===c.label?"OTPAuth":c.label,f=void 0===c.secret?new b.a:c.secret,d=void 0===c.algorithm?"SHA1":c.algorithm,e=void 0===
|
||||
c.digits?6:c.digits,c=void 0===c.counter?0:c.counter;this.issuer=a;this.label=l;this.algorithm=d;this.secret=f;this.digits=e;this.counter=c}var a=g(0),b=g(1),c=g(2),f=g(4);d.generate=function(b){var l=void 0===b.digits?6:b.digits,f=void 0===b.pad?!0:b.pad;b=new Uint8Array(c.a.digest({algorithm:void 0===b.algorithm?"SHA1":b.algorithm,key:b.secret.buffer,message:a.a.uint.encode(void 0===b.counter?0:b.counter)}));var d=b[b.byteLength-1]&15;b=((b[d]&127)<<24|(b[d+1]&255)<<16|(b[d+2]&255)<<8|b[d+3]&255)%
|
||||
Math.pow(10,l);return f?Array(1+l-String(b).length).join("0")+b:b};d.prototype.generate=function(a){a=void 0===a?{}:a;var b=void 0===a.counter?this.counter++:a.counter;return d.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:b,pad:a.pad})};d.validate=function(a){var b=a.token,c=a.secret,f=a.algorithm,l=void 0===a.counter?0:a.counter;a=void 0===a.window?50:a.window;for(var e=parseInt(b,10),g=l-a;g<=l+a;++g){var h=d.generate({secret:c,algorithm:f,counter:g,digits:b.length,
|
||||
pad:!1});if(e===h)return g-l}return null};d.prototype.validate=function(a){return d.validate({token:a.token,secret:this.secret,algorithm:this.algorithm,counter:void 0===a.counter?this.counter:a.counter,window:a.window})};d.prototype.toString=function(){return f.a.stringify(this)};h.a=d;e.generate=function(a){var b=a.secret,c=a.algorithm,f=a.digits,l=void 0===a.period?30:a.period,e=void 0===a.timestamp?Date.now():a.timestamp;return d.generate({secret:b,algorithm:c,digits:f,counter:Math.floor(e/1E3/
|
||||
l),pad:a.pad})};e.prototype.generate=function(a){a=void 0===a?{}:a;var b=void 0===a.timestamp?Date.now():a.timestamp;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:b,pad:a.pad})};e.validate=function(a){var b=a.token,c=a.secret,f=a.algorithm,l=void 0===a.period?30:a.period,e=void 0===a.timestamp?Date.now():a.timestamp;return d.validate({token:b,secret:c,algorithm:f,counter:Math.floor(e/1E3/l),window:a.window})};e.prototype.validate=function(a){return e.validate({token:a.token,
|
||||
secret:this.secret,algorithm:this.algorithm,period:this.period,timestamp:a.timestamp,window:a.window})};e.prototype.toString=function(){return f.a.stringify(this)};h.b=e},function(k,h,g){function e(){}var d=g(0),a=g(1),b=g(3),c=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?(?:issuer|label|secret|algorithm|digits|counter|period)+=[^&]+)+)$/i,f=/^[2-7A-Z]+$/i,l=/SHA(?:1|256|512)/i,N=/^[+-]?[0-9]+$/,Z=/^\+?[1-9][0-9]*$/;e.parse=function(e){var g=decodeURIComponent(e).match(c);if(null===g)throw Error("Invalid URI format");
|
||||
e=g[1].toLowerCase();var E=g[2].split(/:(.+)/,2),g=g[3].split("\x26").reduce(function(a,b){b=b.split(/=(.+)/,2);var c=b[0].toLowerCase();a[c]=b[1];return a},{}),h,k={};if("hotp"===e)if(h=b.a,N.test(g.counter))k.counter=parseInt(g.counter,10);else throw Error("Missing or invalid 'counter' parameter");else if("totp"===e){if(h=b.b,"undefined"!==typeof g.period&&"totp"===e)if(Z.test(g.period))k.period=parseInt(g.period,10);else throw Error("Invalid 'period' parameter");}else throw Error("Unknown OTP type");
|
||||
if(2===E.length)if(k.label=E[1],"undefined"===typeof g.issuer)k.issuer=E[0];else if(g.issuer===E[0])k.issuer=g.issuer;else throw Error("Invalid 'issuer' parameter");else k.label=E[0],"undefined"!==typeof g.issuer&&(k.issuer=g.issuer);if(f.test(g.secret))k.secret=new a.a({buffer:d.a.b32.encode(g.secret)});else throw Error("Missing or invalid 'secret' parameter");if("undefined"!==typeof g.algorithm)if(l.test(g.algorithm))k.algorithm=g.algorithm;else throw Error("Invalid 'algorithm' parameter");if("undefined"!==
|
||||
typeof g.digits)if(Z.test(g.digits))k.digits=parseInt(g.digits,10);else throw Error("Invalid 'digits' parameter");return new h(k)};e.stringify=function(a){if(!(a instanceof b.a||a instanceof b.b))throw Error("Invalid 'HOTP/TOTP' object");return encodeURI("otpauth://"+(a instanceof b.b?"totp":"hotp")+(0<a.issuer.length?"/"+a.issuer+":"+a.label+"?issuer\x3d"+a.issuer+"\x26":"/"+a.label+"?")+("secret\x3d"+a.secret.b32)+("\x26algorithm\x3d"+a.algorithm)+("\x26digits\x3d"+a.digits)+(a instanceof b.b?"\x26period\x3d"+
|
||||
a.period:"\x26counter\x3d"+a.counter))};h.a=e},function(k){k.exports=w},function(k){var h;h=function(){return this}();try{h=h||Function("return this")()||(0,eval)("this")}catch(g){"object"===typeof window&&(h=window)}k.exports=h},function(k,h){var g,e,d={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=
|
||||
a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}},bitArray:{bitSlice:function(a,b,c){a=d.bitArray._shiftRight(a.slice(b/32),32-(b&31)).slice(1);return void 0===c?a:d.bitArray.clamp(a,c-b)},extract:function(a,b,c){var f=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-f^a[b/32+1|0]>>>f:a[b/32|0]>>>f)&(1<<c)-1},concat:function(a,b){if(0===a.length||0===b.length)return a.concat(b);
|
||||
var c=a[a.length-1],f=d.bitArray.getPartial(c);return 32===f?a.concat(b):d.bitArray._shiftRight(b,f,c|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;return 0===b?0:32*(b-1)+d.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(32*a.length<b)return a;a=a.slice(0,Math.ceil(b/32));var c=a.length;b&=31;0<c&&b&&(a[c-1]=d.bitArray.partial(b,a[c-1]&2147483648>>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+1099511627776*a},getPartial:function(a){return Math.round(a/
|
||||
1099511627776)||32},equal:function(a,b){if(d.bitArray.bitLength(a)!==d.bitArray.bitLength(b))return!1;var c=0,f;for(f=0;f<a.length;f++)c|=a[f]^b[f];return 0===c},_shiftRight:function(a,b,c,f){var l;for(void 0===f&&(f=[]);32<=b;b-=32)f.push(c),c=0;if(0===b)return f.concat(a);for(l=0;l<a.length;l++)f.push(c|a[l]>>>b),c=a[l]<<32-b;a=d.bitArray.getPartial(a.length?a[a.length-1]:0);f.push(d.bitArray.partial(b+a&31,32<b+a?c:f.pop(),1));return f},_xor4:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],
|
||||
a[3]^b[3]]},byteswapM:function(a){var b,c;for(b=0;b<a.length;++b)c=a[b],a[b]=c>>>24|c>>>8&65280|(c&65280)<<8|c<<24;return a}}};"undefined"===typeof ArrayBuffer&&function(a){a.ArrayBuffer=function(){};a.DataView=function(){}}(this);d.codec.arrayBuffer={fromBits:function(a,b,c){var f;b=void 0==b?!0:b;c=c||8;if(0===a.length)return new ArrayBuffer(0);f=d.bitArray.bitLength(a)/8;if(0!==d.bitArray.bitLength(a)%8)throw new d.exception.invalid("Invalid bit size, must be divisble by 8 to fit in an arraybuffer correctly");
|
||||
b&&0!==f%c&&(f+=c-f%c);c=new DataView(new ArrayBuffer(4*a.length));for(b=0;b<a.length;b++)c.setUint32(4*b,a[b]<<32);a=new DataView(new ArrayBuffer(f));if(a.byteLength===c.byteLength)return c.buffer;f=c.byteLength<a.byteLength?c.byteLength:a.byteLength;for(b=0;b<f;b++)a.setUint8(b,c.getUint8(b));return a.buffer},toBits:function(a){var b=[],c,f,l;if(0===a.byteLength)return[];f=new DataView(a);c=f.byteLength-f.byteLength%4;for(a=0;a<c;a+=4)b.push(f.getUint32(a));if(0!=f.byteLength%4){l=new DataView(new ArrayBuffer(4));
|
||||
a=0;for(var e=f.byteLength%4;a<e;a++)l.setUint8(a+4-e,f.getUint8(c+a));b.push(d.bitArray.partial(f.byteLength%4*8,l.getUint32(0)))}return b},hexDumpBuffer:function(a){a=new DataView(a);for(var b="",c=0;c<a.byteLength;c+=2){0==c%16&&(b+="\n"+c.toString(16)+"\t");var f;f=a.getUint16(c).toString(16);f+="";f=4<=f.length?f:Array(4-f.length+1).join("0")+f;b+=f+" "}console.log(b.toUpperCase())}};d.hash.sha1=function(a){a?(this._h=a._h.slice(0),this._buffer=a._buffer.slice(0),this._length=a._length):this.reset()};
|
||||
d.hash.sha1.hash=function(a){return(new d.hash.sha1).update(a).finalize()};d.hash.sha1.prototype={blockSize:512,reset:function(){this._h=this._init.slice(0);this._buffer=[];this._length=0;return this},update:function(a){"string"===typeof a&&(a=d.codec.utf8String.toBits(a));var b,c=this._buffer=d.bitArray.concat(this._buffer,a);b=this._length;a=this._length=b+d.bitArray.bitLength(a);if(9007199254740991<a)throw new d.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!==typeof Uint32Array){var f=
|
||||
new Uint32Array(c),l=0;for(b=this.blockSize+b-(this.blockSize+b&this.blockSize-1);b<=a;b+=this.blockSize)this._block(f.subarray(16*l,16*(l+1))),l+=1;c.splice(0,16*l)}else for(b=this.blockSize+b-(this.blockSize+b&this.blockSize-1);b<=a;b+=this.blockSize)this._block(c.splice(0,16));return this},finalize:function(){var a,b=this._buffer,c=this._h,b=d.bitArray.concat(b,[d.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this._length/4294967296));for(b.push(this._length|0);b.length;)this._block(b.splice(0,
|
||||
16));this.reset();return c},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(a,b,c,f){if(19>=a)return b&c|~b&f;if(39>=a)return b^c^f;if(59>=a)return b&c|b&f|c&f;if(79>=a)return b^c^f},_S:function(a,b){return b<<a|b>>>32-a},_block:function(a){var b,c,f,d,e,g,h=this._h,k;if("undefined"!==typeof Uint32Array)for(k=Array(80),b=0;16>b;b++)k[b]=a[b];else k=a;c=h[0];f=h[1];d=h[2];e=h[3];g=h[4];for(a=0;79>=a;a++)16<=a&&(k[a]=this._S(1,
|
||||
k[a-3]^k[a-8]^k[a-14]^k[a-16])),b=this._S(5,c)+this._f(a,f,d,e)+g+k[a]+this._key[Math.floor(a/20)]|0,g=e,e=d,d=this._S(30,f),f=c,c=b;h[0]=h[0]+c|0;h[1]=h[1]+f|0;h[2]=h[2]+d|0;h[3]=h[3]+e|0;h[4]=h[4]+g|0}};d.hash.sha256=function(a){this._key[0]||this._precompute();a?(this._h=a._h.slice(0),this._buffer=a._buffer.slice(0),this._length=a._length):this.reset()};d.hash.sha256.hash=function(a){return(new d.hash.sha256).update(a).finalize()};d.hash.sha256.prototype={blockSize:512,reset:function(){this._h=
|
||||
this._init.slice(0);this._buffer=[];this._length=0;return this},update:function(a){"string"===typeof a&&(a=d.codec.utf8String.toBits(a));var b,c=this._buffer=d.bitArray.concat(this._buffer,a);b=this._length;a=this._length=b+d.bitArray.bitLength(a);if(9007199254740991<a)throw new d.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!==typeof Uint32Array){var f=new Uint32Array(c),e=0;for(b=512+b-(512+b&511);b<=a;b+=512)this._block(f.subarray(16*e,16*(e+1))),e+=1;c.splice(0,16*e)}else for(b=
|
||||
512+b-(512+b&511);b<=a;b+=512)this._block(c.splice(0,16));return this},finalize:function(){var a,b=this._buffer,c=this._h,b=d.bitArray.concat(b,[d.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this._length/4294967296));for(b.push(this._length|0);b.length;)this._block(b.splice(0,16));this.reset();return c},_init:[],_key:[],_precompute:function(){function a(a){return 4294967296*(a-Math.floor(a))|0}for(var b=0,c=2,f,d;64>b;c++){d=!0;for(f=2;f*f<=c;f++)if(0===c%f){d=!1;
|
||||
break}d&&(8>b&&(this._init[b]=a(Math.pow(c,.5))),this._key[b]=a(Math.pow(c,1/3)),b++)}},_block:function(a){var b,c,f,d=this._h,e=this._key,g=d[0],h=d[1],k=d[2],z=d[3],p=d[4],A=d[5],x=d[6],B=d[7];for(b=0;64>b;b++)16>b?c=a[b]:(c=a[b+1&15],f=a[b+14&15],c=a[b&15]=(c>>>7^c>>>18^c>>>3^c<<25^c<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+a[b&15]+a[b+9&15]|0),c=c+B+(p>>>6^p>>>11^p>>>25^p<<26^p<<21^p<<7)+(x^p&(A^x))+e[b],B=x,x=A,A=p,p=z+c|0,z=k,k=h,h=g,g=c+(h&k^z&(h^k))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|
|
||||
0;d[0]=d[0]+g|0;d[1]=d[1]+h|0;d[2]=d[2]+k|0;d[3]=d[3]+z|0;d[4]=d[4]+p|0;d[5]=d[5]+A|0;d[6]=d[6]+x|0;d[7]=d[7]+B|0}};d.hash.sha512=function(a){this._key[0]||this._precompute();a?(this._h=a._h.slice(0),this._buffer=a._buffer.slice(0),this._length=a._length):this.reset()};d.hash.sha512.hash=function(a){return(new d.hash.sha512).update(a).finalize()};d.hash.sha512.prototype={blockSize:1024,reset:function(){this._h=this._init.slice(0);this._buffer=[];this._length=0;return this},update:function(a){"string"===
|
||||
typeof a&&(a=d.codec.utf8String.toBits(a));var b,c=this._buffer=d.bitArray.concat(this._buffer,a);b=this._length;a=this._length=b+d.bitArray.bitLength(a);if(9007199254740991<a)throw new d.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!==typeof Uint32Array){var f=new Uint32Array(c),e=0;for(b=1024+b-(1024+b&1023);b<=a;b+=1024)this._block(f.subarray(32*e,32*(e+1))),e+=1;c.splice(0,32*e)}else for(b=1024+b-(1024+b&1023);b<=a;b+=1024)this._block(c.splice(0,32));return this},finalize:function(){var a,
|
||||
b=this._buffer,c=this._h,b=d.bitArray.concat(b,[d.bitArray.partial(1,1)]);for(a=b.length+4;a&31;a++)b.push(0);b.push(0);b.push(0);b.push(Math.floor(this._length/4294967296));for(b.push(this._length|0);b.length;)this._block(b.splice(0,32));this.reset();return c},_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(){function a(a){return 4294967296*(a-Math.floor(a))|0}function b(a){return 1099511627776*(a-Math.floor(a))&255}for(var c=0,d=2,e,g;80>c;d++){g=!0;for(e=2;e*e<=d;e++)if(0===d%e){g=!1;break}g&&(8>c&&(this._init[2*c]=a(Math.pow(d,.5)),this._init[2*c+1]=b(Math.pow(d,.5))<<24|this._initr[c]),this._key[2*c]=a(Math.pow(d,1/3)),this._key[2*c+1]=b(Math.pow(d,1/3))<<24|this._keyr[c],c++)}},_block:function(a){var b,c,d=this._h,e=this._key,g=d[0],h=d[1],k=d[2],w=
|
||||
d[3],z=d[4],p=d[5],A=d[6],x=d[7],B=d[8],O=d[9],aa=d[10],P=d[11],ba=d[12],Q=d[13],ca=d[14],R=d[15],q;if("undefined"!==typeof Uint32Array){q=Array(160);for(var n=0;32>n;n++)q[n]=a[n]}else q=a;var n=g,r=h,F=k,C=w,G=z,D=p,V=A,H=x,u=B,t=O,S=aa,I=P,T=ba,J=Q,W=ca,K=R;for(a=0;80>a;a++){if(16>a)b=q[2*a],c=q[2*a+1];else{c=q[2*(a-15)];var m=q[2*(a-15)+1];b=(m<<31|c>>>1)^(m<<24|c>>>8)^c>>>7;var v=(c<<31|m>>>1)^(c<<24|m>>>8)^(c<<25|m>>>7);c=q[2*(a-2)];var y=q[2*(a-2)+1],m=(y<<13|c>>>19)^(c<<3|y>>>29)^c>>>6,y=
|
||||
(c<<13|y>>>19)^(y<<3|c>>>29)^(c<<26|y>>>6),X=q[2*(a-7)],Y=q[2*(a-16)],L=q[2*(a-16)+1];c=v+q[2*(a-7)+1];b=b+X+(c>>>0<v>>>0?1:0);c+=y;b+=m+(c>>>0<y>>>0?1:0);c+=L;b+=Y+(c>>>0<L>>>0?1:0)}q[2*a]=b|=0;q[2*a+1]=c|=0;var X=u&S^~u&T,da=t&I^~t&J,y=n&F^n&G^F&G,fa=r&C^r&D^C&D,Y=(r<<4|n>>>28)^(n<<30|r>>>2)^(n<<25|r>>>7),L=(n<<4|r>>>28)^(r<<30|n>>>2)^(r<<25|n>>>7),ga=e[2*a],ea=e[2*a+1],m=K+((u<<18|t>>>14)^(u<<14|t>>>18)^(t<<23|u>>>9)),v=W+((t<<18|u>>>14)^(t<<14|u>>>18)^(u<<23|t>>>9))+(m>>>0<K>>>0?1:0),m=m+da,v=
|
||||
v+(X+(m>>>0<da>>>0?1:0)),m=m+ea,v=v+(ga+(m>>>0<ea>>>0?1:0)),m=m+c|0,v=v+(b+(m>>>0<c>>>0?1:0));c=L+fa;b=Y+y+(c>>>0<L>>>0?1:0);W=T;K=J;T=S;J=I;S=u;I=t;t=H+m|0;u=V+v+(t>>>0<H>>>0?1:0)|0;V=G;H=D;G=F;D=C;F=n;C=r;r=m+c|0;n=v+b+(r>>>0<m>>>0?1:0)|0}h=d[1]=h+r|0;d[0]=g+n+(h>>>0<r>>>0?1:0)|0;w=d[3]=w+C|0;d[2]=k+F+(w>>>0<C>>>0?1:0)|0;p=d[5]=p+D|0;d[4]=z+G+(p>>>0<D>>>0?1:0)|0;x=d[7]=x+H|0;d[6]=A+V+(x>>>0<H>>>0?1:0)|0;O=d[9]=O+t|0;d[8]=B+u+(O>>>0<t>>>0?1:0)|0;P=d[11]=P+I|0;d[10]=aa+S+(P>>>0<I>>>0?1:0)|0;Q=d[13]=
|
||||
Q+J|0;d[12]=ba+T+(Q>>>0<J>>>0?1:0)|0;R=d[15]=R+K|0;d[14]=ca+W+(R>>>0<K>>>0?1:0)|0}};d.misc.hmac=function(a,b){this._hash=b=b||d.hash.sha256;var c=[[],[]],e,g=b.prototype.blockSize/32;this._baseHash=[new b,new b];a.length>g&&(a=b.hash(a));for(e=0;e<g;e++)c[0][e]=a[e]^909522486,c[1][e]=a[e]^1549556828;this._baseHash[0].update(c[0]);this._baseHash[1].update(c[1]);this._resultHash=new b(this._baseHash[0])};d.misc.hmac.prototype.encrypt=d.misc.hmac.prototype.mac=function(a){if(this._updated)throw new d.exception.invalid("encrypt on already updated hmac called!");
|
||||
this.update(a);return this.digest(a)};d.misc.hmac.prototype.reset=function(){this._resultHash=new this._hash(this._baseHash[0]);this._updated=!1};d.misc.hmac.prototype.update=function(a){this._updated=!0;this._resultHash.update(a)};d.misc.hmac.prototype.digest=function(){var a=this._resultHash.finalize(),a=(new this._hash(this._baseHash[1])).update(a).finalize();this.reset();return a};"undefined"!==typeof k&&k.exports&&(k.exports=d);!(g=[],e=function(){return d}.apply(h,g),void 0!==e&&(k.exports=
|
||||
e))},function(k,h,g){Object.defineProperty(h,"__esModule",{value:!0});g.d(h,"Utils",function(){return e.a});var e=g(0),d=g(1);g.d(h,"Secret",function(){return d.a});var a=g(2);g.d(h,"HMAC",function(){return a.a});var b=g(3);g.d(h,"HOTP",function(){return b.a});g.d(h,"TOTP",function(){return b.b});var c=g(4);g.d(h,"URI",function(){return c.a})}])}
|
||||
"object"===typeof exports&&"object"===typeof module?module.exports=U(require("crypto")):"function"===typeof define&&define.amd?define(["crypto"],U):"object"===typeof exports?exports.OTPAuth=U(require("crypto")):this.OTPAuth=U(this.crypto);}).call(this);
|
||||
/*! OTPAuth v1.0.1 | (c) Héctor Molinero Fernández <hector@molinero.xyz> | https://github.com/zant95/otpauth | MIT */
|
||||
(function(){'use strict';function L(U){return function(k){function h(c){if(g[c])return g[c].exports;var e=g[c]={i:c,l:!1,exports:{}};k[c].call(e.exports,e,e.exports,h);e.l=!0;return e.exports}var g={};h.m=k;h.c=g;h.i=function(c){return c};h.d=function(c,e,a){h.o(c,e)||Object.defineProperty(c,e,{configurable:!1,enumerable:!0,get:a})};h.n=function(c){var e=c&&c.__esModule?function(){return c["default"]}:function(){return c};h.d(e,"a",e);return e};h.o=function(c,e){return Object.prototype.hasOwnProperty.call(c,
|
||||
e)};h.p="";return h(h.s=8)}([function(k,h){var g={uint:{},raw:{},b32:{},hex:{}};h.a=g;g.uint.decode=function(c){c=new Uint8Array(c);for(var e=0,a=0;a<c.length;a++)0!==c[a]&&(e*=256,e+=c[a]);return e};g.uint.encode=function(c){for(var e=new ArrayBuffer(8),a=new Uint8Array(e),b=7;0<=b&&0!==c;b--)a[b]=c&255,c-=a[b],c/=256;return e};g.raw.decode=function(c){c=new Uint8Array(c);for(var e="",a=0;a<c.length;a++)e+=String.fromCharCode(c[a]);return e};g.raw.encode=function(c){for(var e=new ArrayBuffer(c.length),
|
||||
a=new Uint8Array(e),b=0;b<c.length;b++)a[b]=c.charCodeAt(b);return e};g.b32.alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";g.b32.decode=function(c){c=new Uint8Array(c);for(var e=0,a=0,b="",d=0;d<c.length;d++)for(a=a<<8|c[d],e+=8;5<=e;)b+=g.b32.alphabet[a>>>e-5&31],e-=5;0<e&&(b+=g.b32.alphabet[a<<5-e&31]);return b};g.b32.encode=function(c){var e=c.toUpperCase();c=new ArrayBuffer(5*c.length/8|0);for(var a=new Uint8Array(c),b=0,d=0,f=0,l=0;l<e.length;l++){var M=g.b32.alphabet.indexOf(e[l]);if(-1===M)throw Error("Invalid character found: "+
|
||||
e[l]);d=d<<5|M;b+=5;8<=b&&(a[f++]=d>>>b-8&255,b-=8)}return c};g.hex.decode=function(c){c=new Uint8Array(c);for(var e="",a=0;a<c.length;a++)var b=c[a].toString(16),e=e+(1===b.length?"0"+b:b);return e.toUpperCase()};g.hex.encode=function(c){for(var e=new ArrayBuffer(c.length/2),a=new Uint8Array(e),b=0;b<a.length;b++)a[b]=parseInt(c.substr(2*b,2),16);return e};k={};h.b=k;k.buf2arrbuf=function(c){if(c.buffer instanceof ArrayBuffer)return c.buffer;for(var e=new ArrayBuffer(c.length),a=new Uint8Array(e),
|
||||
b=0;b<a.length;b++)a[b]=c[b];return e};k.arrbuf2buf=function(c){if("function"===typeof Buffer.from)return Buffer.from(c);var e=new Buffer(c.byteLength);c=new Uint8Array(c);for(var a=0;a<c.length;a++)e[a]=c[a];return e}},function(k,h,g){(function(c){function e(a){a=(void 0===a?{}:a).buffer;this.buffer="undefined"===typeof a?this.buffer=e.getRandomBytes():a;this.raw=d.a.raw.decode(this.buffer);this.b32=d.a.b32.decode(this.buffer);this.hex=d.a.hex.decode(this.buffer)}var a=g(5),b=g.n(a),d=g(0);e.getRandomBytes=
|
||||
function(a){a=void 0===a?{}:a;a=void 0===a.size?20:a.size;if("undefined"!==typeof b.a&&"function"===typeof b.a.randomBytes)a=d.b.buf2arrbuf(b.a.randomBytes(a));else{a=new Uint8Array(a);if("undefined"!==typeof c.crypto&&"function"===typeof c.crypto.getRandomValues)c.crypto.getRandomValues(a);else if("undefined"!==typeof c.msCrypto&&"function"===typeof c.msCrypto.getRandomValues)c.msCrypto.getRandomValues(a);else for(var l=0;l<a.length;l++)a[l]=Math.floor(256*Math.random());a=a.buffer}return a};h.a=
|
||||
e}).call(h,g(6))},function(k,h,g){function c(){}k=g(5);var e=g.n(k);k=g(7);var a=g.n(k),b=g(0),d={SHA1:"sha1",SHA256:"sha256",SHA512:"sha512"};c.digest=function(f){var l=f.algorithm,c=f.key;f=f.message;if(!(l in d))throw Error("Unknown hash function");if("undefined"!==typeof e.a&&"function"===typeof e.a.createHmac)c=e.a.createHmac(l,b.b.arrbuf2buf(c)),c.update(b.b.arrbuf2buf(f)),f=c.digest(),"string"===typeof f&&(f=b.a.raw.encode(f));else if("undefined"!==typeof a.a){var g=a.a.hash[d[l]],l=a.a.codec.arrayBuffer.fromBits,
|
||||
y=a.a.codec.arrayBuffer.toBits,c=new a.a.misc.hmac(y(c),g);c.update(y(f));f=l(c.digest(),!1)}else throw Error("Unable to create HMAC digest");return f};h.a=c},function(k,h,g){function c(a){var d=void 0===a?{}:a;a=void 0===d.issuer?"":d.issuer;var l=void 0===d.label?"OTPAuth":d.label,f=void 0===d.secret?new b.a:d.secret,e=void 0===d.algorithm?"SHA1":d.algorithm,c=void 0===d.digits?6:d.digits,d=void 0===d.period?30:d.period;this.issuer=a;this.label=l;this.secret=f;this.algorithm=e;this.digits=c;this.period=
|
||||
d}function e(a){var d=void 0===a?{}:a;a=void 0===d.issuer?"":d.issuer;var l=void 0===d.label?"OTPAuth":d.label,f=void 0===d.secret?new b.a:d.secret,e=void 0===d.algorithm?"SHA1":d.algorithm,c=void 0===d.digits?6:d.digits,d=void 0===d.counter?0:d.counter;this.issuer=a;this.label=l;this.algorithm=e;this.secret=f;this.digits=c;this.counter=d}var a=g(0),b=g(1),d=g(2),f=g(4);e.generate=function(b){var f=void 0===b.digits?6:b.digits,l=void 0===b.pad?!0:b.pad;b=new Uint8Array(d.a.digest({algorithm:void 0===
|
||||
b.algorithm?"SHA1":b.algorithm,key:b.secret.buffer,message:a.a.uint.encode(void 0===b.counter?0:b.counter)}));var e=b[b.byteLength-1]&15;b=((b[e]&127)<<24|(b[e+1]&255)<<16|(b[e+2]&255)<<8|b[e+3]&255)%Math.pow(10,f);return l?Array(1+f-String(b).length).join("0")+b:b};e.prototype.generate=function(a){a=void 0===a?{}:a;var b=void 0===a.counter?this.counter++:a.counter;return e.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:b,pad:a.pad})};e.validate=function(a){var b=
|
||||
a.token,d=a.secret,f=a.algorithm,l=void 0===a.counter?0:a.counter;a=void 0===a.window?50:a.window;for(var c=parseInt(b,10),g=l-a;g<=l+a;++g){var h=e.generate({secret:d,algorithm:f,counter:g,digits:b.length,pad:!1});if(c===h)return g-l}return null};e.prototype.validate=function(a){return e.validate({token:a.token,secret:this.secret,algorithm:this.algorithm,counter:void 0===a.counter?this.counter:a.counter,window:a.window})};e.prototype.toString=function(){return f.a.stringify(this)};h.a=e;c.generate=
|
||||
function(a){var b=a.secret,d=a.algorithm,f=a.digits,l=void 0===a.period?30:a.period,c=void 0===a.timestamp?Date.now():a.timestamp;return e.generate({secret:b,algorithm:d,digits:f,counter:Math.floor(c/1E3/l),pad:a.pad})};c.prototype.generate=function(a){a=void 0===a?{}:a;var b=void 0===a.timestamp?Date.now():a.timestamp;return c.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:b,pad:a.pad})};c.validate=function(a){var b=a.token,d=a.secret,f=a.algorithm,
|
||||
c=void 0===a.period?30:a.period,l=void 0===a.timestamp?Date.now():a.timestamp;return e.validate({token:b,secret:d,algorithm:f,counter:Math.floor(l/1E3/c),window:a.window})};c.prototype.validate=function(a){return c.validate({token:a.token,secret:this.secret,algorithm:this.algorithm,period:this.period,timestamp:a.timestamp,window:a.window})};c.prototype.toString=function(){return f.a.stringify(this)};h.b=c},function(k,h,g){function c(){}var e=g(0),a=g(1),b=g(3),d=/^otpauth:\/\/([ht]otp)\/(.+)\?((?:&?(?:issuer|label|secret|algorithm|digits|counter|period)=[^&]+)+)$/i,
|
||||
f=/^[2-7A-Z]+$/i,l=/SHA(?:1|256|512)/i,M=/^[+-]?[0-9]+$/,Z=/^\+?[1-9][0-9]*$/;c.parse=function(c){var g=decodeURIComponent(c).match(d);if(null===g)throw Error("Invalid URI format");var y=g[1].toLowerCase();c=g[2].split(/:(.+)/,2);var g=g[3].split("\x26").reduce(function(a,b){b=b.split(/=(.+)/,2);var d=b[0].toLowerCase();a[d]=b[1];return a},{}),h={};if("hotp"===y)if(y=b.a,"undefined"!==typeof g.counter&&M.test(g.counter))h.counter=parseInt(g.counter,10);else throw Error("Missing or invalid 'counter' parameter");
|
||||
else if("totp"===y){if(y=b.b,"undefined"!==typeof g.period)if(Z.test(g.period))h.period=parseInt(g.period,10);else throw Error("Invalid 'period' parameter");}else throw Error("Unknown OTP type");if(2===c.length)if(h.label=c[1],"undefined"===typeof g.issuer)h.issuer=c[0];else if(g.issuer===c[0])h.issuer=g.issuer;else throw Error("Invalid 'issuer' parameter");else h.label=c[0],"undefined"!==typeof g.issuer&&(h.issuer=g.issuer);if("undefined"!==typeof g.secret&&f.test(g.secret))h.secret=new a.a({buffer:e.a.b32.encode(g.secret)});
|
||||
else throw Error("Missing or invalid 'secret' parameter");if("undefined"!==typeof g.algorithm)if(l.test(g.algorithm))h.algorithm=g.algorithm;else throw Error("Invalid 'algorithm' parameter");if("undefined"!==typeof g.digits)if(Z.test(g.digits))h.digits=parseInt(g.digits,10);else throw Error("Invalid 'digits' parameter");return new y(h)};c.stringify=function(a){if(!(a instanceof b.a||a instanceof b.b))throw Error("Invalid 'HOTP/TOTP' object");return encodeURI("otpauth://"+(a instanceof b.b?"totp":
|
||||
"hotp")+(0<a.issuer.length?"/"+a.issuer+":"+a.label+"?issuer\x3d"+a.issuer+"\x26":"/"+a.label+"?")+("secret\x3d"+a.secret.b32)+("\x26algorithm\x3d"+a.algorithm)+("\x26digits\x3d"+a.digits)+(a instanceof b.b?"\x26period\x3d"+a.period:"\x26counter\x3d"+a.counter))};h.a=c},function(k){k.exports=U},function(k){var h;h=function(){return this}();try{h=h||Function("return this")()||(0,eval)("this")}catch(g){"object"===typeof window&&(h=window)}k.exports=h},function(k,h){var g,c,e={cipher:{},hash:{},keyexchange:{},
|
||||
mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}},bitArray:{bitSlice:function(a,b,d){a=e.bitArray._shiftRight(a.slice(b/32),32-(b&31)).slice(1);return void 0===
|
||||
d?a:e.bitArray.clamp(a,d-b)},extract:function(a,b,d){var f=Math.floor(-b-d&31);return((b+d-1^b)&-32?a[b/32|0]<<32-f^a[b/32+1|0]>>>f:a[b/32|0]>>>f)&(1<<d)-1},concat:function(a,b){if(0===a.length||0===b.length)return a.concat(b);var d=a[a.length-1],f=e.bitArray.getPartial(d);return 32===f?a.concat(b):e.bitArray._shiftRight(b,f,d|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;return 0===b?0:32*(b-1)+e.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(32*a.length<b)return a;a=a.slice(0,
|
||||
Math.ceil(b/32));var d=a.length;b&=31;0<d&&b&&(a[d-1]=e.bitArray.partial(b,a[d-1]&2147483648>>b-1,1));return a},partial:function(a,b,d){return 32===a?b:(d?b|0:b<<32-a)+1099511627776*a},getPartial:function(a){return Math.round(a/1099511627776)||32},equal:function(a,b){if(e.bitArray.bitLength(a)!==e.bitArray.bitLength(b))return!1;var d=0,f;for(f=0;f<a.length;f++)d|=a[f]^b[f];return 0===d},_shiftRight:function(a,b,d,f){var c;for(void 0===f&&(f=[]);32<=b;b-=32)f.push(d),d=0;if(0===b)return f.concat(a);
|
||||
for(c=0;c<a.length;c++)f.push(d|a[c]>>>b),d=a[c]<<32-b;a=e.bitArray.getPartial(a.length?a[a.length-1]:0);f.push(e.bitArray.partial(b+a&31,32<b+a?d:f.pop(),1));return f},_xor4:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]},byteswapM:function(a){var b,d;for(b=0;b<a.length;++b)d=a[b],a[b]=d>>>24|d>>>8&65280|(d&65280)<<8|d<<24;return a}}};"undefined"===typeof ArrayBuffer&&function(a){a.ArrayBuffer=function(){};a.DataView=function(){}}(this);e.codec.arrayBuffer={fromBits:function(a,b,d){var f;
|
||||
b=void 0==b?!0:b;d=d||8;if(0===a.length)return new ArrayBuffer(0);f=e.bitArray.bitLength(a)/8;if(0!==e.bitArray.bitLength(a)%8)throw new e.exception.invalid("Invalid bit size, must be divisble by 8 to fit in an arraybuffer correctly");b&&0!==f%d&&(f+=d-f%d);d=new DataView(new ArrayBuffer(4*a.length));for(b=0;b<a.length;b++)d.setUint32(4*b,a[b]<<32);a=new DataView(new ArrayBuffer(f));if(a.byteLength===d.byteLength)return d.buffer;f=d.byteLength<a.byteLength?d.byteLength:a.byteLength;for(b=0;b<f;b++)a.setUint8(b,
|
||||
d.getUint8(b));return a.buffer},toBits:function(a){var b=[],d,f,c;if(0===a.byteLength)return[];f=new DataView(a);d=f.byteLength-f.byteLength%4;for(a=0;a<d;a+=4)b.push(f.getUint32(a));if(0!=f.byteLength%4){c=new DataView(new ArrayBuffer(4));a=0;for(var g=f.byteLength%4;a<g;a++)c.setUint8(a+4-g,f.getUint8(d+a));b.push(e.bitArray.partial(f.byteLength%4*8,c.getUint32(0)))}return b},hexDumpBuffer:function(a){a=new DataView(a);for(var b="",d=0;d<a.byteLength;d+=2){0==d%16&&(b+="\n"+d.toString(16)+"\t");
|
||||
var f;f=a.getUint16(d).toString(16);f+="";f=4<=f.length?f:Array(4-f.length+1).join("0")+f;b+=f+" "}console.log(b.toUpperCase())}};e.hash.sha1=function(a){a?(this._h=a._h.slice(0),this._buffer=a._buffer.slice(0),this._length=a._length):this.reset()};e.hash.sha1.hash=function(a){return(new e.hash.sha1).update(a).finalize()};e.hash.sha1.prototype={blockSize:512,reset:function(){this._h=this._init.slice(0);this._buffer=[];this._length=0;return this},update:function(a){"string"===typeof a&&(a=e.codec.utf8String.toBits(a));
|
||||
var b,d=this._buffer=e.bitArray.concat(this._buffer,a);b=this._length;a=this._length=b+e.bitArray.bitLength(a);if(9007199254740991<a)throw new e.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!==typeof Uint32Array){var f=new Uint32Array(d),c=0;for(b=this.blockSize+b-(this.blockSize+b&this.blockSize-1);b<=a;b+=this.blockSize)this._block(f.subarray(16*c,16*(c+1))),c+=1;d.splice(0,16*c)}else for(b=this.blockSize+b-(this.blockSize+b&this.blockSize-1);b<=a;b+=this.blockSize)this._block(d.splice(0,
|
||||
16));return this},finalize:function(){var a,b=this._buffer,d=this._h,b=e.bitArray.concat(b,[e.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this._length/4294967296));for(b.push(this._length|0);b.length;)this._block(b.splice(0,16));this.reset();return d},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(a,b,d,f){if(19>=a)return b&d|~b&f;if(39>=a)return b^d^f;if(59>=a)return b&d|b&f|d&f;if(79>=
|
||||
a)return b^d^f},_S:function(a,b){return b<<a|b>>>32-a},_block:function(a){var b,d,f,e,c,g,h=this._h,k;if("undefined"!==typeof Uint32Array)for(k=Array(80),b=0;16>b;b++)k[b]=a[b];else k=a;d=h[0];f=h[1];e=h[2];c=h[3];g=h[4];for(a=0;79>=a;a++)16<=a&&(k[a]=this._S(1,k[a-3]^k[a-8]^k[a-14]^k[a-16])),b=this._S(5,d)+this._f(a,f,e,c)+g+k[a]+this._key[Math.floor(a/20)]|0,g=c,c=e,e=this._S(30,f),f=d,d=b;h[0]=h[0]+d|0;h[1]=h[1]+f|0;h[2]=h[2]+e|0;h[3]=h[3]+c|0;h[4]=h[4]+g|0}};e.hash.sha256=function(a){this._key[0]||
|
||||
this._precompute();a?(this._h=a._h.slice(0),this._buffer=a._buffer.slice(0),this._length=a._length):this.reset()};e.hash.sha256.hash=function(a){return(new e.hash.sha256).update(a).finalize()};e.hash.sha256.prototype={blockSize:512,reset:function(){this._h=this._init.slice(0);this._buffer=[];this._length=0;return this},update:function(a){"string"===typeof a&&(a=e.codec.utf8String.toBits(a));var b,d=this._buffer=e.bitArray.concat(this._buffer,a);b=this._length;a=this._length=b+e.bitArray.bitLength(a);
|
||||
if(9007199254740991<a)throw new e.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!==typeof Uint32Array){var f=new Uint32Array(d),c=0;for(b=512+b-(512+b&511);b<=a;b+=512)this._block(f.subarray(16*c,16*(c+1))),c+=1;d.splice(0,16*c)}else for(b=512+b-(512+b&511);b<=a;b+=512)this._block(d.splice(0,16));return this},finalize:function(){var a,b=this._buffer,d=this._h,b=e.bitArray.concat(b,[e.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this._length/
|
||||
4294967296));for(b.push(this._length|0);b.length;)this._block(b.splice(0,16));this.reset();return d},_init:[],_key:[],_precompute:function(){function a(a){return 4294967296*(a-Math.floor(a))|0}for(var b=0,d=2,f,c;64>b;d++){c=!0;for(f=2;f*f<=d;f++)if(0===d%f){c=!1;break}c&&(8>b&&(this._init[b]=a(Math.pow(d,.5))),this._key[b]=a(Math.pow(d,1/3)),b++)}},_block:function(a){var b,d,f,c=this._h,e=this._key,g=c[0],h=c[1],k=c[2],z=c[3],p=c[4],A=c[5],w=c[6],B=c[7];for(b=0;64>b;b++)16>b?d=a[b]:(d=a[b+1&15],
|
||||
f=a[b+14&15],d=a[b&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(f>>>17^f>>>19^f>>>10^f<<15^f<<13)+a[b&15]+a[b+9&15]|0),d=d+B+(p>>>6^p>>>11^p>>>25^p<<26^p<<21^p<<7)+(w^p&(A^w))+e[b],B=w,w=A,A=p,p=z+d|0,z=k,k=h,h=g,g=d+(h&k^z&(h^k))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|0;c[0]=c[0]+g|0;c[1]=c[1]+h|0;c[2]=c[2]+k|0;c[3]=c[3]+z|0;c[4]=c[4]+p|0;c[5]=c[5]+A|0;c[6]=c[6]+w|0;c[7]=c[7]+B|0}};e.hash.sha512=function(a){this._key[0]||this._precompute();a?(this._h=a._h.slice(0),this._buffer=a._buffer.slice(0),this._length=
|
||||
a._length):this.reset()};e.hash.sha512.hash=function(a){return(new e.hash.sha512).update(a).finalize()};e.hash.sha512.prototype={blockSize:1024,reset:function(){this._h=this._init.slice(0);this._buffer=[];this._length=0;return this},update:function(a){"string"===typeof a&&(a=e.codec.utf8String.toBits(a));var b,d=this._buffer=e.bitArray.concat(this._buffer,a);b=this._length;a=this._length=b+e.bitArray.bitLength(a);if(9007199254740991<a)throw new e.exception.invalid("Cannot hash more than 2^53 - 1 bits");
|
||||
if("undefined"!==typeof Uint32Array){var c=new Uint32Array(d),g=0;for(b=1024+b-(1024+b&1023);b<=a;b+=1024)this._block(c.subarray(32*g,32*(g+1))),g+=1;d.splice(0,32*g)}else for(b=1024+b-(1024+b&1023);b<=a;b+=1024)this._block(d.splice(0,32));return this},finalize:function(){var a,b=this._buffer,d=this._h,b=e.bitArray.concat(b,[e.bitArray.partial(1,1)]);for(a=b.length+4;a&31;a++)b.push(0);b.push(0);b.push(0);b.push(Math.floor(this._length/4294967296));for(b.push(this._length|0);b.length;)this._block(b.splice(0,
|
||||
32));this.reset();return d},_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(){function a(a){return 4294967296*(a-Math.floor(a))|0}function b(a){return 1099511627776*(a-Math.floor(a))&255}for(var d=0,c=2,e,g;80>d;c++){g=!0;for(e=2;e*e<=c;e++)if(0===c%e){g=!1;break}g&&
|
||||
(8>d&&(this._init[2*d]=a(Math.pow(c,.5)),this._init[2*d+1]=b(Math.pow(c,.5))<<24|this._initr[d]),this._key[2*d]=a(Math.pow(c,1/3)),this._key[2*d+1]=b(Math.pow(c,1/3))<<24|this._keyr[d],d++)}},_block:function(a){var b,d,c=this._h,e=this._key,g=c[0],h=c[1],k=c[2],N=c[3],z=c[4],p=c[5],A=c[6],w=c[7],B=c[8],O=c[9],aa=c[10],P=c[11],ba=c[12],Q=c[13],ca=c[14],R=c[15],q;if("undefined"!==typeof Uint32Array){q=Array(160);for(var n=0;32>n;n++)q[n]=a[n]}else q=a;var n=g,r=h,E=k,C=N,F=z,D=p,V=A,G=w,u=B,t=O,S=aa,
|
||||
H=P,T=ba,I=Q,W=ca,J=R;for(a=0;80>a;a++){if(16>a)b=q[2*a],d=q[2*a+1];else{d=q[2*(a-15)];var m=q[2*(a-15)+1];b=(m<<31|d>>>1)^(m<<24|d>>>8)^d>>>7;var v=(d<<31|m>>>1)^(d<<24|m>>>8)^(d<<25|m>>>7);d=q[2*(a-2)];var x=q[2*(a-2)+1],m=(x<<13|d>>>19)^(d<<3|x>>>29)^d>>>6,x=(d<<13|x>>>19)^(x<<3|d>>>29)^(d<<26|x>>>6),X=q[2*(a-7)],Y=q[2*(a-16)],K=q[2*(a-16)+1];d=v+q[2*(a-7)+1];b=b+X+(d>>>0<v>>>0?1:0);d+=x;b+=m+(d>>>0<x>>>0?1:0);d+=K;b+=Y+(d>>>0<K>>>0?1:0)}q[2*a]=b|=0;q[2*a+1]=d|=0;var X=u&S^~u&T,da=t&H^~t&I,x=n&
|
||||
E^n&F^E&F,U=r&C^r&D^C&D,Y=(r<<4|n>>>28)^(n<<30|r>>>2)^(n<<25|r>>>7),K=(n<<4|r>>>28)^(r<<30|n>>>2)^(r<<25|n>>>7),fa=e[2*a],ea=e[2*a+1],m=J+((u<<18|t>>>14)^(u<<14|t>>>18)^(t<<23|u>>>9)),v=W+((t<<18|u>>>14)^(t<<14|u>>>18)^(u<<23|t>>>9))+(m>>>0<J>>>0?1:0),m=m+da,v=v+(X+(m>>>0<da>>>0?1:0)),m=m+ea,v=v+(fa+(m>>>0<ea>>>0?1:0)),m=m+d|0,v=v+(b+(m>>>0<d>>>0?1:0));d=K+U;b=Y+x+(d>>>0<K>>>0?1:0);W=T;J=I;T=S;I=H;S=u;H=t;t=G+m|0;u=V+v+(t>>>0<G>>>0?1:0)|0;V=F;G=D;F=E;D=C;E=n;C=r;r=m+d|0;n=v+b+(r>>>0<m>>>0?1:0)|0}h=
|
||||
c[1]=h+r|0;c[0]=g+n+(h>>>0<r>>>0?1:0)|0;N=c[3]=N+C|0;c[2]=k+E+(N>>>0<C>>>0?1:0)|0;p=c[5]=p+D|0;c[4]=z+F+(p>>>0<D>>>0?1:0)|0;w=c[7]=w+G|0;c[6]=A+V+(w>>>0<G>>>0?1:0)|0;O=c[9]=O+t|0;c[8]=B+u+(O>>>0<t>>>0?1:0)|0;P=c[11]=P+H|0;c[10]=aa+S+(P>>>0<H>>>0?1:0)|0;Q=c[13]=Q+I|0;c[12]=ba+T+(Q>>>0<I>>>0?1:0)|0;R=c[15]=R+J|0;c[14]=ca+W+(R>>>0<J>>>0?1:0)|0}};e.misc.hmac=function(a,b){this._hash=b=b||e.hash.sha256;var c=[[],[]],f,g=b.prototype.blockSize/32;this._baseHash=[new b,new b];a.length>g&&(a=b.hash(a));for(f=
|
||||
0;f<g;f++)c[0][f]=a[f]^909522486,c[1][f]=a[f]^1549556828;this._baseHash[0].update(c[0]);this._baseHash[1].update(c[1]);this._resultHash=new b(this._baseHash[0])};e.misc.hmac.prototype.encrypt=e.misc.hmac.prototype.mac=function(a){if(this._updated)throw new e.exception.invalid("encrypt on already updated hmac called!");this.update(a);return this.digest(a)};e.misc.hmac.prototype.reset=function(){this._resultHash=new this._hash(this._baseHash[0]);this._updated=!1};e.misc.hmac.prototype.update=function(a){this._updated=
|
||||
!0;this._resultHash.update(a)};e.misc.hmac.prototype.digest=function(){var a=this._resultHash.finalize(),a=(new this._hash(this._baseHash[1])).update(a).finalize();this.reset();return a};"undefined"!==typeof k&&k.exports&&(k.exports=e);!(g=[],c=function(){return e}.apply(h,g),void 0!==c&&(k.exports=c))},function(k,h,g){Object.defineProperty(h,"__esModule",{value:!0});g.d(h,"Utils",function(){return c.a});var c=g(0),e=g(1);g.d(h,"Secret",function(){return e.a});var a=g(2);g.d(h,"HMAC",function(){return a.a});
|
||||
var b=g(3);g.d(h,"HOTP",function(){return b.a});g.d(h,"TOTP",function(){return b.b});var d=g(4);g.d(h,"URI",function(){return d.a})}])}"object"===typeof exports&&"object"===typeof module?module.exports=L(require("crypto")):"function"===typeof define&&define.amd?define(["crypto"],L):"object"===typeof exports?exports.OTPAuth=L(require("crypto")):this.OTPAuth=L(this.crypto);}).call(this);
|
||||
//# sourceMappingURL=otpauth.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+63
-64
@@ -1,66 +1,65 @@
|
||||
{
|
||||
"name": "otpauth",
|
||||
"libraryName": "OTPAuth",
|
||||
"version": "1.0.0",
|
||||
"description": "One Time Password (HOTP/TOTP) library for Node.js and browser",
|
||||
"keywords": [
|
||||
"otp",
|
||||
"hotp",
|
||||
"totp",
|
||||
"one time password",
|
||||
"2fa",
|
||||
"2 factor",
|
||||
"two factor",
|
||||
"two-factor",
|
||||
"2step",
|
||||
"2 step",
|
||||
"two step",
|
||||
"two-step",
|
||||
"auth",
|
||||
"authenticator",
|
||||
"google authenticator"
|
||||
],
|
||||
"author": "Héctor Molinero Fernández <hector@molinero.xyz>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/zant95/otpauth",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zant95/otpauth.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/zant95/otpauth/issues"
|
||||
},
|
||||
"main": "./lib/otpauth.js",
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --config .eslintrc.js .",
|
||||
"build-otpauth": "webpack --display-reasons --config .webpack.js",
|
||||
"build-sjcl": "node .sjcl.js",
|
||||
"build": "run-s build-sjcl build-otpauth",
|
||||
"test-browser": "karma start .karma.js",
|
||||
"test-node": "mocha --reporter dot",
|
||||
"test": "run-s test-node test-browser",
|
||||
"doc": "rimraf ./doc && esdoc -c .esdoc.js",
|
||||
"dist": "run-s lint build test doc",
|
||||
"version": "run-s dist && git add -A lib"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"google-closure-compiler-js": "20161201.0.0",
|
||||
"sjcl": "1.0.6",
|
||||
"webpack": "2.2.0-rc.3",
|
||||
"chai": "latest",
|
||||
"esdoc": "latest",
|
||||
"eslint": "latest",
|
||||
"karma": "latest",
|
||||
"karma-chai": "latest",
|
||||
"karma-mocha": "latest",
|
||||
"karma-phantomjs-launcher": "latest",
|
||||
"mocha": "latest",
|
||||
"npm-run-all": "latest",
|
||||
"rimraf": "latest"
|
||||
}
|
||||
"name": "otpauth",
|
||||
"libraryName": "OTPAuth",
|
||||
"version": "1.0.1",
|
||||
"description": "One Time Password (HOTP/TOTP) library for Node.js and browser",
|
||||
"keywords": [
|
||||
"otp",
|
||||
"hotp",
|
||||
"totp",
|
||||
"one time password",
|
||||
"2fa",
|
||||
"2 factor",
|
||||
"two factor",
|
||||
"two-factor",
|
||||
"2step",
|
||||
"2 step",
|
||||
"two step",
|
||||
"two-step",
|
||||
"auth",
|
||||
"authenticator",
|
||||
"google authenticator"
|
||||
],
|
||||
"author": "Héctor Molinero Fernández <hector@molinero.xyz>",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/zant95/otpauth",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zant95/otpauth.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/zant95/otpauth/issues"
|
||||
},
|
||||
"main": "./lib/otpauth.js",
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --config .eslintrc.js .",
|
||||
"build-otpauth": "webpack --display-reasons --config .webpack.js",
|
||||
"build-sjcl": "node .sjcl.js",
|
||||
"build": "run-s build-sjcl build-otpauth",
|
||||
"test-browser": "karma start .karma.js",
|
||||
"test-node": "mocha --reporter dot",
|
||||
"test": "run-s test-node test-browser",
|
||||
"doc": "rimraf ./doc && esdoc -c .esdoc.js",
|
||||
"dist": "run-s lint build test doc",
|
||||
"version": "run-s dist && git add -A lib"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"google-closure-compiler-js": "20161201.0.0",
|
||||
"sjcl": "1.0.6",
|
||||
"webpack": "2.2.0-rc.3",
|
||||
"chai": "latest",
|
||||
"esdoc": "latest",
|
||||
"eslint": "latest",
|
||||
"karma": "latest",
|
||||
"karma-chai": "latest",
|
||||
"karma-mocha": "latest",
|
||||
"karma-phantomjs-launcher": "latest",
|
||||
"mocha": "latest",
|
||||
"npm-run-all": "latest",
|
||||
"rimraf": "latest"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user