diff --git a/dist/otpauth.d.cts b/dist/otpauth.d.cts index b3e34a4..743e64a 100644 --- a/dist/otpauth.d.cts +++ b/dist/otpauth.d.cts @@ -35,7 +35,7 @@ declare class Secret { constructor({ buffer, size }?: { buffer?: ArrayBufferLike | undefined; size?: number | undefined; - } | undefined); + }); /** * Secret key. * @type {Uint8Array} @@ -149,7 +149,7 @@ declare class HOTP { algorithm?: string | undefined; digits?: number | undefined; counter?: number | undefined; - } | undefined); + }); /** * Account provider. * @type {string} @@ -193,7 +193,7 @@ declare class HOTP { */ generate({ counter }?: { counter?: number | undefined; - } | undefined): string; + }): string; /** * Validates an HOTP token. * @param {Object} config Configuration options. @@ -297,7 +297,7 @@ declare class TOTP { algorithm?: string | undefined; digits?: number | undefined; period?: number | undefined; - } | undefined); + }); /** * Account provider. * @type {string} @@ -341,7 +341,7 @@ declare class TOTP { */ generate({ timestamp }?: { timestamp?: number | undefined; - } | undefined): string; + }): string; /** * Validates a TOTP token. * @param {Object} config Configuration options. diff --git a/dist/otpauth.d.ts b/dist/otpauth.d.ts index b3e34a4..743e64a 100644 --- a/dist/otpauth.d.ts +++ b/dist/otpauth.d.ts @@ -35,7 +35,7 @@ declare class Secret { constructor({ buffer, size }?: { buffer?: ArrayBufferLike | undefined; size?: number | undefined; - } | undefined); + }); /** * Secret key. * @type {Uint8Array} @@ -149,7 +149,7 @@ declare class HOTP { algorithm?: string | undefined; digits?: number | undefined; counter?: number | undefined; - } | undefined); + }); /** * Account provider. * @type {string} @@ -193,7 +193,7 @@ declare class HOTP { */ generate({ counter }?: { counter?: number | undefined; - } | undefined): string; + }): string; /** * Validates an HOTP token. * @param {Object} config Configuration options. @@ -297,7 +297,7 @@ declare class TOTP { algorithm?: string | undefined; digits?: number | undefined; period?: number | undefined; - } | undefined); + }); /** * Account provider. * @type {string} @@ -341,7 +341,7 @@ declare class TOTP { */ generate({ timestamp }?: { timestamp?: number | undefined; - } | undefined): string; + }): string; /** * Validates a TOTP token. * @param {Object} config Configuration options. diff --git a/dist/otpauth.esm.js b/dist/otpauth.esm.js index 8f5906d..fe8f70d 100644 --- a/dist/otpauth.esm.js +++ b/dist/otpauth.esm.js @@ -1,5 +1,5 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth -//! noble-hashes 1.5.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! noble-hashes 1.6.1 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes /// // @ts-nocheck /** @@ -19,31 +19,31 @@ return arr; }; -function number(n) { - if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`); +function anumber(n) { + if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n); } // copied from utils function isBytes(a) { - return a instanceof Uint8Array || a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'; + return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'; } -function bytes(b, ...lengths) { +function abytes(b, ...lengths) { if (!isBytes(b)) throw new Error('Uint8Array expected'); - if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`); + if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); } -function hash(h) { +function ahash(h) { if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash should be wrapped by utils.wrapConstructor'); - number(h.outputLen); - number(h.blockLen); + anumber(h.outputLen); + anumber(h.blockLen); } -function exists(instance, checkFinished = true) { +function aexists(instance, checkFinished = true) { if (instance.destroyed) throw new Error('Hash instance has been destroyed'); if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); } -function output(out, instance) { - bytes(out); +function aoutput(out, instance) { + abytes(out); const min = instance.outputLen; if (out.length < min) { - throw new Error(`digestInto() expects output buffer of length at least ${min}`); + throw new Error('digestInto() expects output buffer of length at least ' + min); } } @@ -60,9 +60,9 @@ const createView = (arr)=>new DataView(arr.buffer, arr.byteOffset, arr.byteLengt const rotr = (word, shift)=>word << 32 - shift | word >>> shift; // The rotate left (circular left shift) operation for uint32 const rotl = (word, shift)=>word << shift | word >>> 32 - shift >>> 0; -const isLE = new Uint8Array(new Uint32Array([ - 0x11223344 -]).buffer)[0] === 0x44; +const isLE = /* @__PURE__ */ (()=>new Uint8Array(new Uint32Array([ + 0x11223344 + ]).buffer)[0] === 0x44)(); // The byte swap operation for uint32 const byteSwap = (word)=>word << 24 & 0xff000000 | word << 8 & 0xff0000 | word >>> 8 & 0xff00 | word >>> 24 & 0xff; // In place byte swap for Uint32Array @@ -74,7 +74,7 @@ function byteSwap32(arr) { /** * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) */ function utf8ToBytes(str) { - if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`); + if (typeof str !== 'string') throw new Error('utf8ToBytes expected string, got ' + typeof str); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 } /** @@ -83,7 +83,7 @@ function byteSwap32(arr) { * Keep in mind for future mutable operations. */ function toBytes(data) { if (typeof data === 'string') data = utf8ToBytes(data); - bytes(data); + abytes(data); return data; } // For runtime check if class implements interface @@ -105,13 +105,13 @@ function wrapConstructor(hashCons) { // HMAC (RFC 2104) class HMAC extends Hash { update(buf) { - exists(this); + aexists(this); this.iHash.update(buf); return this; } digestInto(out) { - exists(this); - bytes(out, this.outputLen); + aexists(this); + abytes(out, this.outputLen); this.finished = true; this.iHash.digestInto(out); this.oHash.update(out); @@ -141,24 +141,24 @@ class HMAC extends Hash { this.oHash.destroy(); this.iHash.destroy(); } - constructor(hash$1, _key){ + constructor(hash, _key){ super(); this.finished = false; this.destroyed = false; - hash(hash$1); + ahash(hash); const key = toBytes(_key); - this.iHash = hash$1.create(); + this.iHash = hash.create(); if (typeof this.iHash.update !== 'function') throw new Error('Expected instance of class which extends utils.Hash'); this.blockLen = this.iHash.blockLen; this.outputLen = this.iHash.outputLen; const blockLen = this.blockLen; const pad = new Uint8Array(blockLen); // blockLen can be bigger than outputLen - pad.set(key.length > blockLen ? hash$1.create().update(key).digest() : key); + pad.set(key.length > blockLen ? hash.create().update(key).digest() : key); for(let i = 0; i < pad.length; i++)pad[i] ^= 0x36; this.iHash.update(pad); // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone - this.oHash = hash$1.create(); + this.oHash = hash.create(); // Undo internal XOR && apply outer XOR for(let i = 0; i < pad.length; i++)pad[i] ^= 0x36 ^ 0x5c; this.oHash.update(pad); @@ -201,7 +201,7 @@ hmac.create = (hash, key)=>new HMAC(hash, key); * Could be used to create MD5, RIPEMD, SHA1, SHA2. */ class HashMD extends Hash { update(data) { - exists(this); + aexists(this); const { view, buffer, blockLen } = this; data = toBytes(data); const len = data.length; @@ -226,8 +226,8 @@ hmac.create = (hash, key)=>new HMAC(hash, key); return this; } digestInto(out) { - exists(this); - output(out, this); + aexists(this); + aoutput(out, this); this.finished = true; // Padding // We can avoid allocation of buffer for padding completely if it @@ -380,7 +380,7 @@ class SHA1 extends HashMD { */ const sha1 = /* @__PURE__ */ wrapConstructor(()=>new SHA1()); // SHA2-256 need to try 2^128 hashes to execute birthday attack. -// BTC network is doing 2^67 hashes/sec as per early 2023. +// BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per late 2024. // Round constants: // first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311) // prettier-ignore @@ -574,7 +574,8 @@ class SHA224 extends SHA256 { const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); const _32n = /* @__PURE__ */ BigInt(32); -// We are not using BigUint64Array, because they are extremely slow as per 2022 +// BigUint64Array is too slow as per 2024, so we implement it using Uint32Array. +// TODO: re-check https://issues.chromium.org/issues/42212588 function fromBig(n, le = false) { if (le) return { h: Number(n & U32_MASK64), @@ -1003,7 +1004,7 @@ class Keccak extends Hash { this.pos = 0; } update(data) { - exists(this); + aexists(this); const { blockLen, state } = this; data = toBytes(data); const len = data.length; @@ -1025,8 +1026,8 @@ class Keccak extends Hash { this.keccak(); } writeInto(out) { - exists(this, false); - bytes(out); + aexists(this, false); + abytes(out); this.finish(); const bufferOut = this.state; const { blockLen } = this; @@ -1045,11 +1046,11 @@ class Keccak extends Hash { return this.writeInto(out); } xof(bytes) { - number(bytes); + anumber(bytes); return this.xofInto(new Uint8Array(bytes)); } digestInto(out) { - output(out, this); + aoutput(out, this); if (this.finished) throw new Error('digest() was already called'); this.writeInto(out); this.destroy(); @@ -1090,7 +1091,7 @@ class Keccak extends Hash { this.finished = false; this.destroyed = false; // Can be passed from user as dkLen - number(outputLen); + anumber(outputLen); // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes if (0 >= this.blockLen || this.blockLen >= 200) throw new Error('Sha3 supports only keccak-f1600 function'); this.state = new Uint8Array(200); @@ -1903,6 +1904,6 @@ const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8); /** * Library version. * @type {string} - */ const version = "9.3.5"; + */ const version = "9.3.6"; export { HOTP, Secret, TOTP, URI, version }; diff --git a/dist/otpauth.esm.min.js b/dist/otpauth.esm.min.js index b6e70e5..4fb8e4c 100644 --- a/dist/otpauth.esm.min.js +++ b/dist/otpauth.esm.min.js @@ -1,8 +1,8 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth -//! noble-hashes 1.5.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! noble-hashes 1.6.1 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes /// // @ts-nocheck -function t(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function e(t,...e){if(!((s=t)instanceof Uint8Array||null!=s&&"object"==typeof s&&"Uint8Array"===s.constructor.name))throw new Error("Uint8Array expected");var s;if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function i(t,s){e(t);const i=s.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),n=(t,e)=>t<<32-e|t>>>e,o=(t,e)=>t<>>32-e>>>0,h=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function a(t){for(let s=0;s>>8&65280|e>>>24&255;var e}function l(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),e(t),t}class c{clone(){return this._cloneInto()}}function d(t){const e=e=>t().update(l(e)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}class u extends c{update(t){return s(this),this.iHash.update(t),this}digestInto(t){s(this),e(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return t.finished=i,t.destroyed=r,t.blockLen=n,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=s._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}constructor(e,s){super(),this.finished=!1,this.destroyed=!1,function(e){ +function t(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function e(t,...e){if(!((s=t)instanceof Uint8Array||ArrayBuffer.isView(s)&&"Uint8Array"===s.constructor.name))throw new Error("Uint8Array expected");var s;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function i(t,s){e(t);const i=s.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),n=(t,e)=>t<<32-e|t>>>e,o=(t,e)=>t<>>32-e>>>0,h=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function a(t){for(let s=0;s>>8&65280|e>>>24&255;var e}function l(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),e(t),t}class c{clone(){return this._cloneInto()}}function d(t){const e=e=>t().update(l(e)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}class u extends c{update(t){return s(this),this.iHash.update(t),this}digestInto(t){s(this),e(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return t.finished=i,t.destroyed=r,t.blockLen=n,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=s._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}constructor(e,s){super(),this.finished=!1,this.destroyed=!1,function(e){ if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");t(e.outputLen),t(e.blockLen)}(e);const i=l(s);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);for(let t=0;tnew u(t,e).update(s).digest();f.create=(t,e)=>new u(t,e);const b=(t,e,s)=>t&e^~t&s,g=(t,e,s)=>t&e^t&s^e&s;class p extends c{update(t){s(this);const{view:e,buffer:i,blockLen:n}=this,o=(t=l(t)).length;for(let s=0;so-a&&(this.process(n,0),a=0);for(let t=a;t>r&n),h=Number(s&n),a=i?4:0,l=i?0:4;t.setUint32(e+a,o,i),t.setUint32(e+l,h,i)}(n,o-8,BigInt(8*this.length),h),this.process(n,0);const l=r(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=c/4,u=this.get();if(d>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;tnew x)),H=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),L=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),m=new Uint32Array(64);class I extends p{get(){const{A:t,B:e,C:s,D:i,E:r,F:n,G:o,H:h}=this;return[t,e,s,i,r,n,o,h]}set(t,e,s,i,r,n,o,h){this.A=0|t,this.B=0|e,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|h}process(t,e){for(let s=0;s<16;s++,e+=4)m[s]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=m[t-15],s=m[t-2],i=n(e,7)^n(e,18)^e>>>3,r=n(s,17)^n(s,19)^s>>>10;m[t]=r+m[t-7]+i+m[t-16]|0}let{A:s,B:i,C:r,D:o,E:h,F:a,G:l,H:c}=this;for(let t=0;t<64;t++){const e=c+(n(h,6)^n(h,11)^n(h,25))+b(h,a,l)+H[t]+m[t]|0,d=(n(s,2)^n(s,13)^n(s,22))+g(s,i,r)|0;c=l,l=a,a=h,h=o+e|0,o=r,r=i,i=s,s=e+d|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,o=o+this.D|0,h=h+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(s,i,r,o,h,a,l,c)}roundClean(){m.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}constructor(){super(64,32,8,!1),this.A=0|L[0],this.B=0|L[1],this.C=0|L[2],this.D=0|L[3],this.E=0|L[4],this.F=0|L[5],this.G=0|L[6],this.H=0|L[7]}}class S extends I{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}} @@ -14,6 +14,6 @@ if(!this.enableXOF)throw new Error("XOF is not possible for this instance");retu return"SHA3-384";case/^SHA3-512$/i.test(t):return"SHA3-512";default:throw new TypeError(`Unknown hash algorithm: ${t}`)}},ft="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bt=t=>{let e=(t=t.replace(/ /g,"")).length;for(;"="===t[e-1];)--e;t=(e=8&&(r-=8,i[o++]=n>>>r)}return i},gt=t=>{let e=0,s=0,i="";for(let r=0;r=5;)i+=ft[s>>>e-5&31],e-=5;return e>0&&(i+=ft[s<<5-e&31]),i},pt=t=>{t=t.replace(/ /g,"");const e=new ArrayBuffer(t.length/2),s=new Uint8Array(e);for(let e=0;e{let e="";for(let s=0;s{const e=new ArrayBuffer(t.length),s=new Uint8Array(e);for(let e=0;e{let e="";for(let s=0;s{if(!At)throw new Error("Encoding API not available");return At.encode(t)},mt=t=>{if(!Ht)throw new Error("Encoding API not available");return Ht.decode(t)};class It{static fromLatin1(t){return new It({buffer:yt(t).buffer})}static fromUTF8(t){return new It({buffer:Lt(t).buffer})}static fromBase32(t){return new It({buffer:bt(t).buffer})}static fromHex(t){return new It({buffer:pt(t).buffer})}get buffer(){return this.bytes.buffer}get latin1(){return Object.defineProperty(this,"latin1",{enumerable:!0,writable:!1,configurable:!1,value:xt(this.bytes)}),this.latin1}get utf8(){return Object.defineProperty(this,"utf8",{enumerable:!0,writable:!1,configurable:!1,value:mt(this.bytes)}),this.utf8}get base32(){return Object.defineProperty(this,"base32",{enumerable:!0,writable:!1,configurable:!1,value:gt(this.bytes)}), this.base32}get hex(){return Object.defineProperty(this,"hex",{enumerable:!0,writable:!1,configurable:!1,value:wt(this.bytes)}),this.hex}constructor({buffer:t,size:e=20}={}){this.bytes=void 0===t?(t=>{if(ct.crypto?.getRandomValues)return ct.crypto.getRandomValues(new Uint8Array(t));throw new Error("Cryptography API not available")})(e):new Uint8Array(t),Object.defineProperty(this,"bytes",{enumerable:!0,writable:!1,configurable:!1,value:this.bytes})}}class St{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,counter:0,window:1}}static generate({secret:t,algorithm:e=St.defaults.algorithm,digits:s=St.defaults.digits,counter:i=St.defaults.counter}){const r=((t,e,s)=>{if(f){const i=dt[t]??dt[ut(t)];return f(i,e,s)}throw new Error("Missing HMAC function")})(e,t.bytes,(t=>{const e=new ArrayBuffer(8),s=new Uint8Array(e);let i=t;for(let t=7;t>=0&&0!==i;t--)s[t]=255&i,i-=s[t],i/=256;return s})(i)),n=15&r[r.byteLength-1];return(((127&r[n])<<24|(255&r[n+1])<<16|(255&r[n+2])<<8|255&r[n+3])%10**s).toString().padStart(s,"0")}generate({counter:t=this.counter++}={}){return St.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:t})}static validate({token:t,secret:e,algorithm:s,digits:i=St.defaults.digits,counter:r=St.defaults.counter,window:n=St.defaults.window}){if(t.length!==i)return null;let o=null;const h=n=>{const h=St.generate({secret:e,algorithm:s,digits:i,counter:n});((t,e)=>{{if(t.length!==e.length)throw new TypeError("Input strings must have the same length");let s=-1,i=0;for(;++s0?this.issuerInLabel?`${t(this.issuer)}:${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?`)+`secret=${t(this.secret.base32)}&`+`algorithm=${t(this.algorithm)}&`+`digits=${t(this.digits)}&`+`counter=${t(this.counter)}`}constructor({issuer:t=St.defaults.issuer,label:e=St.defaults.label,issuerInLabel:s=St.defaults.issuerInLabel,secret:i=new It,algorithm:r=St.defaults.algorithm,digits:n=St.defaults.digits,counter:o=St.defaults.counter}={}){this.issuer=t,this.label=e,this.issuerInLabel=s,this.secret="string"==typeof i?It.fromBase32(i):i,this.algorithm=ut(r),this.digits=n,this.counter=o}}class Bt{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,period:30,window:1}}static generate({secret:t,algorithm:e,digits:s,period:i=Bt.defaults.period,timestamp:r=Date.now()}){return St.generate({secret:t,algorithm:e,digits:s,counter:Math.floor(r/1e3/i)})}generate({timestamp:t=Date.now()}={}){return Bt.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:t})}static validate({token:t,secret:e,algorithm:s,digits:i,period:r=Bt.defaults.period,timestamp:n=Date.now(),window:o}){return St.validate({token:t,secret:e,algorithm:s,digits:i,counter:Math.floor(n/1e3/r),window:o})}validate({token:t,timestamp:e,window:s}){return Bt.validate({token:t,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:e,window:s})}toString(){const t=encodeURIComponent;return"otpauth://totp/"+(this.issuer.length>0?this.issuerInLabel?`${t(this.issuer)}:${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?`)+`secret=${t(this.secret.base32)}&`+`algorithm=${t(this.algorithm)}&`+`digits=${t(this.digits)}&`+`period=${t(this.period)}`} -constructor({issuer:t=Bt.defaults.issuer,label:e=Bt.defaults.label,issuerInLabel:s=Bt.defaults.issuerInLabel,secret:i=new It,algorithm:r=Bt.defaults.algorithm,digits:n=Bt.defaults.digits,period:o=Bt.defaults.period}={}){this.issuer=t,this.label=e,this.issuerInLabel=s,this.secret="string"==typeof i?It.fromBase32(i):i,this.algorithm=ut(r),this.digits=n,this.period=o}}const Et=/^otpauth:\/\/([ht]otp)\/(.+)\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i,Ut=/^[2-7A-Z]+=*$/i,Ct=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,vt=/^[+-]?\d+$/,kt=/^\+?[1-9]\d*$/;class Ot{static parse(t){let e;try{e=t.match(Et)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");const s=e[1].toLowerCase(),i=e[2].split(/(?::|%3A) *(.+)/i,2).map(decodeURIComponent),r=e[3].split("&").reduce(((t,e)=>{const s=e.split(/=(.*)/,2).map(decodeURIComponent),i=s[0].toLowerCase(),r=s[1],n=t;return n[i]=r,n}),{});let n;const o={};if("hotp"===s){if(n=St,void 0===r.counter||!vt.test(r.counter))throw new TypeError("Missing or invalid 'counter' parameter");o.counter=parseInt(r.counter,10)}else{if("totp"!==s)throw new TypeError("Unknown OTP type");if(n=Bt,void 0!==r.period){if(!kt.test(r.period))throw new TypeError("Invalid 'period' parameter");o.period=parseInt(r.period,10)}}if(void 0!==r.issuer&&(o.issuer=r.issuer),2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===r.secret||!Ut.test(r.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=r.secret,void 0!==r.algorithm){if(!Ct.test(r.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=r.algorithm}if(void 0!==r.digits){if(!kt.test(r.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(r.digits,10)}return new n(o)}static stringify(t){if(t instanceof St||t instanceof Bt)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}const $t="9.3.5" +constructor({issuer:t=Bt.defaults.issuer,label:e=Bt.defaults.label,issuerInLabel:s=Bt.defaults.issuerInLabel,secret:i=new It,algorithm:r=Bt.defaults.algorithm,digits:n=Bt.defaults.digits,period:o=Bt.defaults.period}={}){this.issuer=t,this.label=e,this.issuerInLabel=s,this.secret="string"==typeof i?It.fromBase32(i):i,this.algorithm=ut(r),this.digits=n,this.period=o}}const Et=/^otpauth:\/\/([ht]otp)\/(.+)\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i,Ut=/^[2-7A-Z]+=*$/i,Ct=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,vt=/^[+-]?\d+$/,kt=/^\+?[1-9]\d*$/;class Ot{static parse(t){let e;try{e=t.match(Et)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");const s=e[1].toLowerCase(),i=e[2].split(/(?::|%3A) *(.+)/i,2).map(decodeURIComponent),r=e[3].split("&").reduce(((t,e)=>{const s=e.split(/=(.*)/,2).map(decodeURIComponent),i=s[0].toLowerCase(),r=s[1],n=t;return n[i]=r,n}),{});let n;const o={};if("hotp"===s){if(n=St,void 0===r.counter||!vt.test(r.counter))throw new TypeError("Missing or invalid 'counter' parameter");o.counter=parseInt(r.counter,10)}else{if("totp"!==s)throw new TypeError("Unknown OTP type");if(n=Bt,void 0!==r.period){if(!kt.test(r.period))throw new TypeError("Invalid 'period' parameter");o.period=parseInt(r.period,10)}}if(void 0!==r.issuer&&(o.issuer=r.issuer),2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===r.secret||!Ut.test(r.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=r.secret,void 0!==r.algorithm){if(!Ct.test(r.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=r.algorithm}if(void 0!==r.digits){if(!kt.test(r.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(r.digits,10)}return new n(o)}static stringify(t){if(t instanceof St||t instanceof Bt)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}const $t="9.3.6" ;export{St as HOTP,It as Secret,Bt as TOTP,Ot as URI,$t as version}; //# sourceMappingURL=otpauth.esm.min.js.map diff --git a/dist/otpauth.esm.min.js.map b/dist/otpauth.esm.min.js.map index c40e446..de660f2 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":["../node_modules/@noble/hashes/esm/_assert.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/hashes/esm/_md.js","../node_modules/@noble/hashes/esm/sha1.js","../node_modules/@noble/hashes/esm/sha256.js","../node_modules/@noble/hashes/esm/_u64.js","../node_modules/@noble/hashes/esm/sha512.js","../node_modules/@noble/hashes/esm/sha3.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/encoding/uint.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["function number(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error(`positive integer expected, not ${n}`);\n}\nfunction bool(b) {\n if (typeof b !== 'boolean')\n throw new Error(`boolean expected, not ${b}`);\n}\n// copied from utils\nexport function isBytes(a) {\n return (a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));\n}\nfunction bytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);\n}\nfunction hash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(h.outputLen);\n number(h.blockLen);\n}\nfunction exists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction output(out, instance) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\nexport { number, bool, bytes, hash, exists, output };\nconst assert = { number, bool, bytes, hash, exists, output };\nexport default assert;\n//# sourceMappingURL=_assert.js.map","/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { bytes as abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a) {\n return (a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));\n}\n// Cast array to different type\nexport const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n// Cast array to view\nexport const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);\nexport const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\n// The byte swap operation for uint32\nexport const byteSwap = (word) => ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };\nfunction asciiToBase16(char) {\n if (char >= asciis._0 && char <= asciis._9)\n return char - asciis._0;\n if (char >= asciis._A && char <= asciis._F)\n return char - (asciis._A - 10);\n if (char >= asciis._a && char <= asciis._f)\n return char - (asciis._a - 10);\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('padded hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2;\n }\n return array;\n}\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => { };\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// For runtime check if class implements interface\nexport class Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nconst toStr = {}.toString;\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nexport function wrapConstructor(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","import { hash as assertHash, bytes as assertBytes, exists as assertExists } from './_assert.js';\nimport { Hash, toBytes } from './utils.js';\n// HMAC (RFC 2104)\nexport class HMAC extends Hash {\n constructor(hash, _key) {\n super();\n this.finished = false;\n this.destroyed = false;\n assertHash(hash);\n const key = toBytes(_key);\n this.iHash = hash.create();\n if (typeof this.iHash.update !== 'function')\n throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create();\n // Undo internal XOR && apply outer XOR\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36 ^ 0x5c;\n this.oHash.update(pad);\n pad.fill(0);\n }\n update(buf) {\n assertExists(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out) {\n assertExists(this);\n assertBytes(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to) {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to || (to = Object.create(Object.getPrototypeOf(this), {}));\n const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n to = to;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n destroy() {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */\nexport const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();\nhmac.create = (hash, key) => new HMAC(hash, key);\n//# sourceMappingURL=hmac.js.map","import { exists, output } from './_assert.js';\nimport { Hash, createView, toBytes } from './utils.js';\n/**\n * Polyfill for Safari 14\n */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/**\n * Choice: a ? b : c\n */\nexport const Chi = (a, b, c) => (a & b) ^ (~a & c);\n/**\n * Majority function, true if any two inputs is true\n */\nexport const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n exists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n exists(this);\n output(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n}\n//# sourceMappingURL=_md.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotl, wrapConstructor } from './utils.js';\n// SHA1 (RFC 3174). It was cryptographically broken: prefer newer algorithms.\n// Initial state\nconst SHA1_IV = /* @__PURE__ */ new Uint32Array([\n 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0,\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA1_W = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA1 extends HashMD {\n constructor() {\n super(64, 20, 8, false);\n this.A = SHA1_IV[0] | 0;\n this.B = SHA1_IV[1] | 0;\n this.C = SHA1_IV[2] | 0;\n this.D = SHA1_IV[3] | 0;\n this.E = SHA1_IV[4] | 0;\n }\n get() {\n const { A, B, C, D, E } = this;\n return [A, B, C, D, E];\n }\n set(A, B, C, D, E) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n SHA1_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 80; i++)\n SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);\n // Compression function main loop, 80 rounds\n let { A, B, C, D, E } = this;\n for (let i = 0; i < 80; i++) {\n let F, K;\n if (i < 20) {\n F = Chi(B, C, D);\n K = 0x5a827999;\n }\n else if (i < 40) {\n F = B ^ C ^ D;\n K = 0x6ed9eba1;\n }\n else if (i < 60) {\n F = Maj(B, C, D);\n K = 0x8f1bbcdc;\n }\n else {\n F = B ^ C ^ D;\n K = 0xca62c1d6;\n }\n const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0;\n E = D;\n D = C;\n C = rotl(B, 30);\n B = A;\n A = T;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n this.set(A, B, C, D, E);\n }\n roundClean() {\n SHA1_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n/**\n * SHA1 (RFC 3174) hash function.\n * It was cryptographically broken: prefer newer algorithms.\n * @param message - data that would be hashed\n */\nexport const sha1 = /* @__PURE__ */ wrapConstructor(() => new SHA1());\n//# sourceMappingURL=sha1.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotr, wrapConstructor } from './utils.js';\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^67 hashes/sec as per early 2023.\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\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// Initial state:\n// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD {\n constructor() {\n super(64, 32, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV[0] | 0;\n this.B = SHA256_IV[1] | 0;\n this.C = SHA256_IV[2] | 0;\n this.D = SHA256_IV[3] | 0;\n this.E = SHA256_IV[4] | 0;\n this.F = SHA256_IV[5] | 0;\n this.G = SHA256_IV[6] | 0;\n this.H = SHA256_IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n constructor() {\n super();\n this.A = 0xc1059ed8 | 0;\n this.B = 0x367cd507 | 0;\n this.C = 0x3070dd17 | 0;\n this.D = 0xf70e5939 | 0;\n this.E = 0xffc00b31 | 0;\n this.F = 0x68581511 | 0;\n this.G = 0x64f98fa7 | 0;\n this.H = 0xbefa4fa4 | 0;\n this.outputLen = 28;\n }\n}\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\n/**\n * SHA2-224 hash function\n */\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n//# sourceMappingURL=sha256.js.map","const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\n// We are not using BigUint64Array, because they are extremely slow as per 2022\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\nfunction split(lst, le = false) {\n let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for (let i = 0; i < lst.length; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// for Shift in [0, 32)\nconst shrSH = (h, _l, s) => h >>> s;\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in [1, 32)\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\n// Right rotate for shift===32 (just swaps l&h)\nconst rotr32H = (_h, l) => l;\nconst rotr32L = (h, _l) => h;\n// Left rotate for Shift in [1, 32)\nconst rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));\nconst rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));\nconst rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n// prettier-ignore\nexport { fromBig, split, toBig, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotr32H, rotr32L, rotlSH, rotlSL, rotlBH, rotlBL, add, add3L, add3H, add4L, add4H, add5H, add5L, };\n// prettier-ignore\nconst u64 = {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\nexport default u64;\n//# sourceMappingURL=_u64.js.map","import { HashMD } from './_md.js';\nimport u64 from './_u64.js';\nimport { wrapConstructor } from './utils.js';\n// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):\n// prettier-ignore\nconst [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\n// Temporary buffer, not used to store anything between runs\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA512 extends HashMD {\n constructor() {\n super(128, 64, 16, false);\n // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.\n // Also looks cleaner and easier to verify with spec.\n // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x6a09e667 | 0;\n this.Al = 0xf3bcc908 | 0;\n this.Bh = 0xbb67ae85 | 0;\n this.Bl = 0x84caa73b | 0;\n this.Ch = 0x3c6ef372 | 0;\n this.Cl = 0xfe94f82b | 0;\n this.Dh = 0xa54ff53a | 0;\n this.Dl = 0x5f1d36f1 | 0;\n this.Eh = 0x510e527f | 0;\n this.El = 0xade682d1 | 0;\n this.Fh = 0x9b05688c | 0;\n this.Fl = 0x2b3e6c1f | 0;\n this.Gh = 0x1f83d9ab | 0;\n this.Gl = 0xfb41bd6b | 0;\n this.Hh = 0x5be0cd19 | 0;\n this.Hl = 0x137e2179 | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n SHA512_W_H.fill(0);\n SHA512_W_L.fill(0);\n }\n destroy() {\n this.buffer.fill(0);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\nexport class SHA512_224 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x8c3d37c8 | 0;\n this.Al = 0x19544da2 | 0;\n this.Bh = 0x73e19966 | 0;\n this.Bl = 0x89dcd4d6 | 0;\n this.Ch = 0x1dfab7ae | 0;\n this.Cl = 0x32ff9c82 | 0;\n this.Dh = 0x679dd514 | 0;\n this.Dl = 0x582f9fcf | 0;\n this.Eh = 0x0f6d2b69 | 0;\n this.El = 0x7bd44da8 | 0;\n this.Fh = 0x77e36f73 | 0;\n this.Fl = 0x04c48942 | 0;\n this.Gh = 0x3f9d85a8 | 0;\n this.Gl = 0x6a1d36c8 | 0;\n this.Hh = 0x1112e6ad | 0;\n this.Hl = 0x91d692a1 | 0;\n this.outputLen = 28;\n }\n}\nexport class SHA512_256 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x22312194 | 0;\n this.Al = 0xfc2bf72c | 0;\n this.Bh = 0x9f555fa3 | 0;\n this.Bl = 0xc84c64c2 | 0;\n this.Ch = 0x2393b86b | 0;\n this.Cl = 0x6f53b151 | 0;\n this.Dh = 0x96387719 | 0;\n this.Dl = 0x5940eabd | 0;\n this.Eh = 0x96283ee2 | 0;\n this.El = 0xa88effe3 | 0;\n this.Fh = 0xbe5e1e25 | 0;\n this.Fl = 0x53863992 | 0;\n this.Gh = 0x2b0199fc | 0;\n this.Gl = 0x2c85b8aa | 0;\n this.Hh = 0x0eb72ddc | 0;\n this.Hl = 0x81c52ca2 | 0;\n this.outputLen = 32;\n }\n}\nexport class SHA384 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0xcbbb9d5d | 0;\n this.Al = 0xc1059ed8 | 0;\n this.Bh = 0x629a292a | 0;\n this.Bl = 0x367cd507 | 0;\n this.Ch = 0x9159015a | 0;\n this.Cl = 0x3070dd17 | 0;\n this.Dh = 0x152fecd8 | 0;\n this.Dl = 0xf70e5939 | 0;\n this.Eh = 0x67332667 | 0;\n this.El = 0xffc00b31 | 0;\n this.Fh = 0x8eb44a87 | 0;\n this.Fl = 0x68581511 | 0;\n this.Gh = 0xdb0c2e0d | 0;\n this.Gl = 0x64f98fa7 | 0;\n this.Hh = 0x47b5481d | 0;\n this.Hl = 0xbefa4fa4 | 0;\n this.outputLen = 48;\n }\n}\nexport const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());\nexport const sha512_224 = /* @__PURE__ */ wrapConstructor(() => new SHA512_224());\nexport const sha512_256 = /* @__PURE__ */ wrapConstructor(() => new SHA512_256());\nexport const sha384 = /* @__PURE__ */ wrapConstructor(() => new SHA384());\n//# sourceMappingURL=sha512.js.map","import { bytes, exists, number, output } from './_assert.js';\nimport { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';\nimport { Hash, u32, toBytes, wrapConstructor, wrapXOFConstructorWithOpts, isLE, byteSwap32, } from './utils.js';\n// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.\n// It's called a sponge function.\n// Various per round constants calculations\nconst SHA3_PI = [];\nconst SHA3_ROTL = [];\nconst _SHA3_IOTA = [];\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nconst _7n = /* @__PURE__ */ BigInt(7);\nconst _256n = /* @__PURE__ */ BigInt(256);\nconst _0x71n = /* @__PURE__ */ BigInt(0x71);\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n)\n t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n// Same as keccakf1600, but allows to skip some rounds\nexport function keccakP(s, rounds = 24) {\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++)\n B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for (let y = 0; y < 50; y += 10) {\n for (let x = 0; x < 10; x++)\n B[x] = s[y + x];\n for (let x = 0; x < 10; x++)\n s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\nexport class Keccak extends Hash {\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {\n super();\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.rounds = rounds;\n this.pos = 0;\n this.posOut = 0;\n this.finished = false;\n this.destroyed = false;\n // Can be passed from user as dkLen\n number(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n if (0 >= this.blockLen || this.blockLen >= 200)\n throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n keccak() {\n if (!isLE)\n byteSwap32(this.state32);\n keccakP(this.state32, this.rounds);\n if (!isLE)\n byteSwap32(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n exists(this);\n const { blockLen, state } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++)\n state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen)\n this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished)\n return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1)\n this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n exists(this, false);\n bytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len;) {\n if (this.posOut >= blockLen)\n this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF)\n throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes) {\n number(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n output(out, this);\n if (this.finished)\n throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest() {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy() {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to) {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nconst gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));\nexport const sha3_224 = /* @__PURE__ */ gen(0x06, 144, 224 / 8);\n/**\n * SHA3-256 hash function\n * @param message - that would be hashed\n */\nexport const sha3_256 = /* @__PURE__ */ gen(0x06, 136, 256 / 8);\nexport const sha3_384 = /* @__PURE__ */ gen(0x06, 104, 384 / 8);\nexport const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);\nexport const keccak_224 = /* @__PURE__ */ gen(0x01, 144, 224 / 8);\n/**\n * keccak-256 hash function. Different from SHA3-256.\n * @param message - that would be hashed\n */\nexport const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);\nexport const keccak_384 = /* @__PURE__ */ gen(0x01, 104, 384 / 8);\nexport const keccak_512 = /* @__PURE__ */ gen(0x01, 72, 512 / 8);\nconst genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));\nexport const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);\nexport const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);\n//# sourceMappingURL=sha3.js.map","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["number","n","Number","isSafeInteger","Error","bytes","b","lengths","a","Uint8Array","constructor","name","length","includes","exists","instance","checkFinished","destroyed","finished","output","out","min","outputLen","createView","arr","DataView","buffer","byteOffset","byteLength","rotr","word","shift","rotl","isLE","Uint32Array","byteSwap32","i","toBytes","data","str","TextEncoder","encode","utf8ToBytes","abytes","Hash","clone","this","_cloneInto","wrapConstructor","hashCons","hashC","msg","update","digest","tmp","blockLen","create","HMAC","buf","assertExists","iHash","digestInto","assertBytes","oHash","destroy","to","Object","getPrototypeOf","hash","_key","super","h","assertHash","key","pad","set","fill","hmac","message","Chi","c","Maj","HashMD","view","len","pos","take","Math","subarray","process","dataView","roundClean","padOffset","value","setBigUint64","_32n","BigInt","_u32_max","wh","wl","l","setUint32","oview","outLen","state","get","res","slice","SHA1_IV","SHA1_W","SHA1","A","B","C","D","E","offset","getUint32","F","K","T","sha1","SHA256_K","SHA256_IV","SHA256_W","SHA256","G","H","W15","W2","s0","s1","T1","T2","SHA224","sha256","sha224","U32_MASK64","fromBig","le","split","lst","Ah","Al","rotlSH","s","rotlSL","rotlBH","rotlBL","u64","toBig","shrSH","_l","shrSL","rotrSH","rotrSL","rotrBH","rotrBL","rotr32H","_h","rotr32L","add","Bh","Bl","add3L","Cl","add3H","low","Ch","add4L","Dl","add4H","Dh","add5H","Eh","add5L","El","SHA512_Kh","SHA512_Kl","map","SHA512_W_H","SHA512_W_L","SHA512","Fh","Fl","Gh","Gl","Hh","Hl","W15h","W15l","s0h","s0l","W2h","W2l","s1h","s1l","SUMl","SUMh","sigma1h","sigma1l","CHIh","CHIl","T1ll","T1h","T1l","sigma0h","sigma0l","MAJh","MAJl","All","SHA384","sha512","sha384","SHA3_PI","SHA3_ROTL","_SHA3_IOTA","_0n","_1n","_2n","_7n","_256n","_0x71n","round","R","x","y","push","t","j","SHA3_IOTA_H","SHA3_IOTA_L","rotlH","rotlL","Keccak","keccak","state32","rounds","idx1","idx0","B0","B1","Th","Tl","curH","curL","PI","keccakP","posOut","finish","suffix","writeInto","bufferOut","xofInto","enableXOF","xof","floor","gen","sha3_224","sha3_256","sha3_384","sha3_512","globalScope","globalThis","defineProperty","prototype","configurable","__GLOBALTHIS__","self","window","global","nobleHashes","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","end","replace","substring","toUpperCase","ArrayBuffer","bits","index","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","DECODER","TextDecoder","utf8Decode","utf8Encode","decode","Secret","fromLatin1","fromUTF8","fromBase32","fromHex","latin1","enumerable","writable","utf8","base32","size","crypto","getRandomValues","randomBytes","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","hmacDigest","num","acc","uintDecode","padStart","validate","token","delta","check","generatedToken","timingSafeEqual","e","encodeURIComponent","TOTP","period","timestamp","Date","now","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp","version"],"mappings":";;;;AAAA,SAASA,EAAOC,GACd,IAAKC,OAA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uW,EAAOlD,MAAQwC,EAAS,QACK,IAAlBU,EAAOnD,QAA4C,KAAlBmD,EAAOnD,OACjDmD,EAAOnD,OAASyC,EAAS,GACA,KAAhBA,EAAS,KAClBU,EAAOjD,eAAgB,KAGzBiD,EAAOlD,MAAQwC,EAAS,QACK,IAAlBU,EAAOnD,QAA4C,KAAlBmD,EAAOnD,SACjDmD,EAAOjD,eAAgB,SAKK,IAArByC,EAAUrC,SAA0BoB,GAAaxE,KAAKyF,EAAUrC,QAGzE,MAAM,IAAInD,UAAU,yCAItB,GANEgG,EAAO7C,OAASqC,EAAUrC,YAMO,IAAxBqC,EAAU1F,UAA2B,CAC9C,IAAI0E,GAAgBzE,KAAKyF,EAAU1F,WAGjC,MAAM,IAAIE,UAAU,iCAFpBgG,EAAOlG,UAAY0F,EAAU1F,SAIjC,CAGA,QAAgC,IAArB0F,EAAUxC,OAAwB,CAC3C,IAAI0B,GAAuB3E,KAAKyF,EAAUxC,QAGxC,MAAM,IAAIhD,UAAU,8BAFpBgG,EAAOhD,OAASlC,SAAS0E,EAAUxC,OAAQ,GAI/C,CAEA,OAAO,IAAI+C,EAAIC,EACjB,CAOA,gBAAOC,CAAUC,GACf,GAAIA,aAAevD,IAAQuD,aAAejC,GACxC,OAAOiC,EAAIjF,WAGb,MAAM,IAAIjB,UAAU,6BACtB,QC1JImG,GAAU;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8]} \ No newline at end of file +{"version":3,"file":"otpauth.esm.min.js","sources":["../node_modules/@noble/hashes/esm/_assert.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/hashes/esm/_md.js","../node_modules/@noble/hashes/esm/sha1.js","../node_modules/@noble/hashes/esm/sha256.js","../node_modules/@noble/hashes/esm/_u64.js","../node_modules/@noble/hashes/esm/sha512.js","../node_modules/@noble/hashes/esm/sha3.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/encoding/uint.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["function anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n// copied from utils\nfunction isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\nfunction abytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\nfunction ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\nfunction aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction aoutput(out, instance) {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\nexport { anumber, anumber as number, abytes, abytes as bytes, ahash, aexists, aoutput };\nconst assert = {\n number: anumber,\n bytes: abytes,\n hash: ahash,\n exists: aexists,\n output: aoutput,\n};\nexport default assert;\n//# sourceMappingURL=_assert.js.map","/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n// Cast array to different type\nexport const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n// Cast array to view\nexport const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n// The byte swap operation for uint32\nexport const byteSwap = (word) => ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => { };\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('utf8ToBytes expected string, got ' + typeof str);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// For runtime check if class implements interface\nexport class Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nexport function wrapConstructor(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","import { ahash, abytes, aexists } from './_assert.js';\nimport { Hash, toBytes } from './utils.js';\n// HMAC (RFC 2104)\nexport class HMAC extends Hash {\n constructor(hash, _key) {\n super();\n this.finished = false;\n this.destroyed = false;\n ahash(hash);\n const key = toBytes(_key);\n this.iHash = hash.create();\n if (typeof this.iHash.update !== 'function')\n throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create();\n // Undo internal XOR && apply outer XOR\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36 ^ 0x5c;\n this.oHash.update(pad);\n pad.fill(0);\n }\n update(buf) {\n aexists(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out) {\n aexists(this);\n abytes(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to) {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to || (to = Object.create(Object.getPrototypeOf(this), {}));\n const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n to = to;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n destroy() {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */\nexport const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();\nhmac.create = (hash, key) => new HMAC(hash, key);\n//# sourceMappingURL=hmac.js.map","import { aexists, aoutput } from './_assert.js';\nimport { Hash, createView, toBytes } from './utils.js';\n/**\n * Polyfill for Safari 14\n */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/**\n * Choice: a ? b : c\n */\nexport const Chi = (a, b, c) => (a & b) ^ (~a & c);\n/**\n * Majority function, true if any two inputs is true\n */\nexport const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n}\n//# sourceMappingURL=_md.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotl, wrapConstructor } from './utils.js';\n// SHA1 (RFC 3174). It was cryptographically broken: prefer newer algorithms.\n// Initial state\nconst SHA1_IV = /* @__PURE__ */ new Uint32Array([\n 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0,\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA1_W = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA1 extends HashMD {\n constructor() {\n super(64, 20, 8, false);\n this.A = SHA1_IV[0] | 0;\n this.B = SHA1_IV[1] | 0;\n this.C = SHA1_IV[2] | 0;\n this.D = SHA1_IV[3] | 0;\n this.E = SHA1_IV[4] | 0;\n }\n get() {\n const { A, B, C, D, E } = this;\n return [A, B, C, D, E];\n }\n set(A, B, C, D, E) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n SHA1_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 80; i++)\n SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);\n // Compression function main loop, 80 rounds\n let { A, B, C, D, E } = this;\n for (let i = 0; i < 80; i++) {\n let F, K;\n if (i < 20) {\n F = Chi(B, C, D);\n K = 0x5a827999;\n }\n else if (i < 40) {\n F = B ^ C ^ D;\n K = 0x6ed9eba1;\n }\n else if (i < 60) {\n F = Maj(B, C, D);\n K = 0x8f1bbcdc;\n }\n else {\n F = B ^ C ^ D;\n K = 0xca62c1d6;\n }\n const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0;\n E = D;\n D = C;\n C = rotl(B, 30);\n B = A;\n A = T;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n this.set(A, B, C, D, E);\n }\n roundClean() {\n SHA1_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n/**\n * SHA1 (RFC 3174) hash function.\n * It was cryptographically broken: prefer newer algorithms.\n * @param message - data that would be hashed\n */\nexport const sha1 = /* @__PURE__ */ wrapConstructor(() => new SHA1());\n//# sourceMappingURL=sha1.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotr, wrapConstructor } from './utils.js';\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per late 2024.\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\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// Initial state:\n// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD {\n constructor() {\n super(64, 32, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV[0] | 0;\n this.B = SHA256_IV[1] | 0;\n this.C = SHA256_IV[2] | 0;\n this.D = SHA256_IV[3] | 0;\n this.E = SHA256_IV[4] | 0;\n this.F = SHA256_IV[5] | 0;\n this.G = SHA256_IV[6] | 0;\n this.H = SHA256_IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n constructor() {\n super();\n this.A = 0xc1059ed8 | 0;\n this.B = 0x367cd507 | 0;\n this.C = 0x3070dd17 | 0;\n this.D = 0xf70e5939 | 0;\n this.E = 0xffc00b31 | 0;\n this.F = 0x68581511 | 0;\n this.G = 0x64f98fa7 | 0;\n this.H = 0xbefa4fa4 | 0;\n this.outputLen = 28;\n }\n}\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\n/**\n * SHA2-224 hash function\n */\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n//# sourceMappingURL=sha256.js.map","const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\n// BigUint64Array is too slow as per 2024, so we implement it using Uint32Array.\n// TODO: re-check https://issues.chromium.org/issues/42212588\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\nfunction split(lst, le = false) {\n let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for (let i = 0; i < lst.length; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// for Shift in [0, 32)\nconst shrSH = (h, _l, s) => h >>> s;\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in [1, 32)\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\n// Right rotate for shift===32 (just swaps l&h)\nconst rotr32H = (_h, l) => l;\nconst rotr32L = (h, _l) => h;\n// Left rotate for Shift in [1, 32)\nconst rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));\nconst rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));\nconst rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n// prettier-ignore\nexport { fromBig, split, toBig, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotr32H, rotr32L, rotlSH, rotlSL, rotlBH, rotlBL, add, add3L, add3H, add4L, add4H, add5H, add5L, };\n// prettier-ignore\nconst u64 = {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\nexport default u64;\n//# sourceMappingURL=_u64.js.map","import { HashMD } from './_md.js';\nimport u64 from './_u64.js';\nimport { wrapConstructor } from './utils.js';\n// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):\n// prettier-ignore\nconst [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\n// Temporary buffer, not used to store anything between runs\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA512 extends HashMD {\n constructor() {\n super(128, 64, 16, false);\n // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.\n // Also looks cleaner and easier to verify with spec.\n // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x6a09e667 | 0;\n this.Al = 0xf3bcc908 | 0;\n this.Bh = 0xbb67ae85 | 0;\n this.Bl = 0x84caa73b | 0;\n this.Ch = 0x3c6ef372 | 0;\n this.Cl = 0xfe94f82b | 0;\n this.Dh = 0xa54ff53a | 0;\n this.Dl = 0x5f1d36f1 | 0;\n this.Eh = 0x510e527f | 0;\n this.El = 0xade682d1 | 0;\n this.Fh = 0x9b05688c | 0;\n this.Fl = 0x2b3e6c1f | 0;\n this.Gh = 0x1f83d9ab | 0;\n this.Gl = 0xfb41bd6b | 0;\n this.Hh = 0x5be0cd19 | 0;\n this.Hl = 0x137e2179 | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n SHA512_W_H.fill(0);\n SHA512_W_L.fill(0);\n }\n destroy() {\n this.buffer.fill(0);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\nexport class SHA512_224 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x8c3d37c8 | 0;\n this.Al = 0x19544da2 | 0;\n this.Bh = 0x73e19966 | 0;\n this.Bl = 0x89dcd4d6 | 0;\n this.Ch = 0x1dfab7ae | 0;\n this.Cl = 0x32ff9c82 | 0;\n this.Dh = 0x679dd514 | 0;\n this.Dl = 0x582f9fcf | 0;\n this.Eh = 0x0f6d2b69 | 0;\n this.El = 0x7bd44da8 | 0;\n this.Fh = 0x77e36f73 | 0;\n this.Fl = 0x04c48942 | 0;\n this.Gh = 0x3f9d85a8 | 0;\n this.Gl = 0x6a1d36c8 | 0;\n this.Hh = 0x1112e6ad | 0;\n this.Hl = 0x91d692a1 | 0;\n this.outputLen = 28;\n }\n}\nexport class SHA512_256 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x22312194 | 0;\n this.Al = 0xfc2bf72c | 0;\n this.Bh = 0x9f555fa3 | 0;\n this.Bl = 0xc84c64c2 | 0;\n this.Ch = 0x2393b86b | 0;\n this.Cl = 0x6f53b151 | 0;\n this.Dh = 0x96387719 | 0;\n this.Dl = 0x5940eabd | 0;\n this.Eh = 0x96283ee2 | 0;\n this.El = 0xa88effe3 | 0;\n this.Fh = 0xbe5e1e25 | 0;\n this.Fl = 0x53863992 | 0;\n this.Gh = 0x2b0199fc | 0;\n this.Gl = 0x2c85b8aa | 0;\n this.Hh = 0x0eb72ddc | 0;\n this.Hl = 0x81c52ca2 | 0;\n this.outputLen = 32;\n }\n}\nexport class SHA384 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0xcbbb9d5d | 0;\n this.Al = 0xc1059ed8 | 0;\n this.Bh = 0x629a292a | 0;\n this.Bl = 0x367cd507 | 0;\n this.Ch = 0x9159015a | 0;\n this.Cl = 0x3070dd17 | 0;\n this.Dh = 0x152fecd8 | 0;\n this.Dl = 0xf70e5939 | 0;\n this.Eh = 0x67332667 | 0;\n this.El = 0xffc00b31 | 0;\n this.Fh = 0x8eb44a87 | 0;\n this.Fl = 0x68581511 | 0;\n this.Gh = 0xdb0c2e0d | 0;\n this.Gl = 0x64f98fa7 | 0;\n this.Hh = 0x47b5481d | 0;\n this.Hl = 0xbefa4fa4 | 0;\n this.outputLen = 48;\n }\n}\nexport const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());\nexport const sha512_224 = /* @__PURE__ */ wrapConstructor(() => new SHA512_224());\nexport const sha512_256 = /* @__PURE__ */ wrapConstructor(() => new SHA512_256());\nexport const sha384 = /* @__PURE__ */ wrapConstructor(() => new SHA384());\n//# sourceMappingURL=sha512.js.map","import { abytes, aexists, anumber, aoutput } from './_assert.js';\nimport { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';\nimport { Hash, u32, toBytes, wrapConstructor, wrapXOFConstructorWithOpts, isLE, byteSwap32, } from './utils.js';\n// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.\n// It's called a sponge function.\n// Various per round constants calculations\nconst SHA3_PI = [];\nconst SHA3_ROTL = [];\nconst _SHA3_IOTA = [];\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nconst _7n = /* @__PURE__ */ BigInt(7);\nconst _256n = /* @__PURE__ */ BigInt(256);\nconst _0x71n = /* @__PURE__ */ BigInt(0x71);\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n)\n t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n// Same as keccakf1600, but allows to skip some rounds\nexport function keccakP(s, rounds = 24) {\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++)\n B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for (let y = 0; y < 50; y += 10) {\n for (let x = 0; x < 10; x++)\n B[x] = s[y + x];\n for (let x = 0; x < 10; x++)\n s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\nexport class Keccak extends Hash {\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {\n super();\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.rounds = rounds;\n this.pos = 0;\n this.posOut = 0;\n this.finished = false;\n this.destroyed = false;\n // Can be passed from user as dkLen\n anumber(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n if (0 >= this.blockLen || this.blockLen >= 200)\n throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n keccak() {\n if (!isLE)\n byteSwap32(this.state32);\n keccakP(this.state32, this.rounds);\n if (!isLE)\n byteSwap32(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n aexists(this);\n const { blockLen, state } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++)\n state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen)\n this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished)\n return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1)\n this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n aexists(this, false);\n abytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len;) {\n if (this.posOut >= blockLen)\n this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF)\n throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes) {\n anumber(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n aoutput(out, this);\n if (this.finished)\n throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest() {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy() {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to) {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nconst gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));\nexport const sha3_224 = /* @__PURE__ */ gen(0x06, 144, 224 / 8);\n/**\n * SHA3-256 hash function\n * @param message - that would be hashed\n */\nexport const sha3_256 = /* @__PURE__ */ gen(0x06, 136, 256 / 8);\nexport const sha3_384 = /* @__PURE__ */ gen(0x06, 104, 384 / 8);\nexport const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);\nexport const keccak_224 = /* @__PURE__ */ gen(0x01, 144, 224 / 8);\n/**\n * keccak-256 hash function. Different from SHA3-256.\n * @param message - that would be hashed\n */\nexport const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);\nexport const keccak_384 = /* @__PURE__ */ gen(0x01, 104, 384 / 8);\nexport const keccak_512 = /* @__PURE__ */ gen(0x01, 72, 512 / 8);\nconst genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));\nexport const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);\nexport const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);\n//# sourceMappingURL=sha3.js.map","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n num *= 256;\n num += arr[i];\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["anumber","n","Number","isSafeInteger","Error","abytes","b","lengths","a","Uint8Array","ArrayBuffer","isView","constructor","name","length","includes","aexists","instance","checkFinished","destroyed","finished","aoutput","out","min","outputLen","createView","arr","DataView","buffer","byteOffset","byteLength","rotr","word","shift","rotl","isLE","Uint32Array","byteSwap32","i","toBytes","data","str","TextEncoder","encode","utf8ToBytes","Hash","clone","this","_cloneInto","wrapConstructor","hashCons","hashC","msg","update","digest","tmp","blockLen","create","HMAC","buf","iHash","digestInto","oHash","destroy","to","Object","getPrototypeOf","hash","_key","super","h","ahash","key","pad","set","fill","hmac","message","Chi","c","Maj","HashMD","view","len","pos","take","Math","subarray","process","dataView","roundClean","padOffset","value","setBigUint64","_32n","BigInt","_u32_max","wh","wl","l","setUint32","oview","outLen","state","get","res","slice","SHA1_IV","SHA1_W","SHA1","A","B","C","D","E","offset","getUint32","F","K","T","sha1","SHA256_K","SHA256_IV","SHA256_W","SHA256","G","H","W15","W2","s0","s1","T1","T2","SHA224","sha256","sha224","U32_MASK64","fromBig","le","split","lst","Ah","Al","rotlSH","s","rotlSL","rotlBH","rotlBL","u64","toBig","shrSH","_l","shrSL","rotrSH","rotrSL","rotrBH","rotrBL","rotr32H","_h","rotr32L","add","Bh","Bl","add3L","Cl","add3H","low","Ch","add4L","Dl","add4H","Dh","add5H","Eh","add5L","El","SHA512_Kh","SHA512_Kl","map","SHA512_W_H","SHA512_W_L","SHA512","Fh","Fl","Gh","Gl","Hh","Hl","W15h","W15l","s0h","s0l","W2h","W2l","s1h","s1l","SUMl","SUMh","sigma1h","sigma1l","CHIh","CHIl","T1ll","T1h","T1l","sigma0h","sigma0l","MAJh","MAJl","All","SHA384","sha512","sha384","SHA3_PI","SHA3_ROTL","_SHA3_IOTA","_0n","_1n","_2n","_7n","_256n","_0x71n","round","R","x","y","push","t","j","SHA3_IOTA_H","SHA3_IOTA_L","rotlH","rotlL","Keccak","keccak","state32","rounds","idx1","idx0","B0","B1","Th","Tl","curH","curL","PI","keccakP","posOut","finish","suffix","writeInto","bufferOut","xofInto","enableXOF","xof","bytes","floor","gen","sha3_224","sha3_256","sha3_384","sha3_512","globalScope","globalThis","defineProperty","prototype","configurable","__GLOBALTHIS__","self","window","global","nobleHashes","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","end","replace","substring","toUpperCase","bits","index","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","DECODER","TextDecoder","utf8Decode","utf8Encode","decode","Secret","fromLatin1","fromUTF8","fromBase32","fromHex","latin1","enumerable","writable","utf8","base32","size","crypto","getRandomValues","randomBytes","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","hmacDigest","num","acc","uintDecode","padStart","validate","token","delta","check","generatedToken","timingSafeEqual","e","encodeURIComponent","TOTP","period","timestamp","Date","now","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp","version"],"mappings":";;;;AAAA,SAASA,EAAQC,GACf,IAAKC,OAAOC,cAAcF,IAAMA,EAAI,EAAG,MAAM,IAAIG,MAAM,kCAAoCH,EAC7F,CAOA,SAASI,EAAOC,KAA8BC,GAC5C,MALeC,EAKFF,aAJOG,YAAcC,YAAaC,OAAOH,IAA6B,eAAvBA,EAAEI,YAAYC,MAIzD,MAAM,IAAIT,MAAM,uBALnC,IAAiBI,EAMf,GAAID,EAAQO,OAAS,IAAMP,EAAQQ,SAAST,EAAEQ,QAC5C,MAAM,IAAIV,MAAM,iCAAmCG,EAAU,gBAAkBD,EAAEQ,OACrF,CAeA,SAASE,EAAQC,EAAeC,GAAgB,GAC9C,GAAID,EAASE,UAAW,MAAM,IAAIf,MAAM,oCACxC,GAAIc,GAAiBD,EAASG,SAAU,MAAM,IAAIhB,MAAM,wCAC1D,CACA,SAASiB,EAAQC,EAAUL,GACzBZ,EAAOiB,GACP,MAAMC,EAAMN,EAASO,UACrB,GAAIF,EAAIR,OAASS,EACf,MAAM,IAAInB,MAAM,yDAA2DmB,EAE/E,CChBO,MAIME,EAAcC,GACzB,IAAIC,SAASD,EAAIE,OAAQF,EAAIG,WAAYH,EAAII,YAGlCC,EAAO,CAACC,EAAcC,IAAmBD,GAAQ,GAAMC,EAAWD,IAASC,EAE3EC,EAAO,CAACF,EAAcC,IACjCD,GAASC,EAA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hB,UAAU,6BACtB,QC1JIkG,GAAU;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8]} \ No newline at end of file diff --git a/dist/otpauth.node.cjs b/dist/otpauth.node.cjs index 8b70e04..8c6c9b8 100644 --- a/dist/otpauth.node.cjs +++ b/dist/otpauth.node.cjs @@ -1,4 +1,4 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth /// // @ts-nocheck 'use strict'; @@ -829,7 +829,7 @@ var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto); /** * Library version. * @type {string} - */ const version = "9.3.5"; + */ const version = "9.3.6"; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.node.min.cjs b/dist/otpauth.node.min.cjs index c9e5791..0fcff2b 100644 --- a/dist/otpauth.node.min.cjs +++ b/dist/otpauth.node.min.cjs @@ -1,9 +1,9 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth /// // @ts-nocheck "use strict";function e(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var t=e(require("node:crypto"));const r=(()=>{if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"__GLOBALTHIS__",{get(){return this},configurable:!0});try{if("undefined"!=typeof __GLOBALTHIS__)return __GLOBALTHIS__}finally{delete Object.prototype.__GLOBALTHIS__}return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0})(),i=e=>{switch(!0){case/^(?:SHA-?1|SSL3-SHA1)$/i.test(e):return"SHA1";case/^SHA(?:2?-)?224$/i.test(e):return"SHA224";case/^SHA(?:2?-)?256$/i.test(e):return"SHA256";case/^SHA(?:2?-)?384$/i.test(e):return"SHA384";case/^SHA(?:2?-)?512$/i.test(e):return"SHA512";case/^SHA3-224$/i.test(e):return"SHA3-224";case/^SHA3-256$/i.test(e):return"SHA3-256";case/^SHA3-384$/i.test(e):return"SHA3-384";case/^SHA3-512$/i.test(e):return"SHA3-512";default:throw new TypeError(`Unknown hash algorithm: ${e}`)}},s="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",n=e=>{let t=(e=e.replace(/ /g,"")).length;for(;"="===e[t-1];)--t;e=(t=8&&(n-=8,i[a++]=o>>>n)}return i},o=e=>{let t=0,r=0,i="";for(let n=0;n=5;)i+=s[r>>>t-5&31],t-=5;return t>0&&(i+=s[r<<5-t&31]),i},a=e=>{e=e.replace(/ /g,"");const t=new ArrayBuffer(e.length/2),r=new Uint8Array(t);for(let t=0;t{let t="";for(let r=0;r{const t=new ArrayBuffer(e.length),r=new Uint8Array(t) ;for(let t=0;t{let t="";for(let r=0;r{if(!c)throw new Error("Encoding API not available");return c.encode(e)},g=e=>{if(!d)throw new Error("Encoding API not available");return d.decode(e)};class p{static fromLatin1(e){return new p({buffer:u(e).buffer})}static fromUTF8(e){return new p({buffer:f(e).buffer})}static fromBase32(e){return new p({buffer:n(e).buffer})}static fromHex(e){return new p({buffer:a(e).buffer})}get buffer(){return this.bytes.buffer}get latin1(){return Object.defineProperty(this,"latin1",{enumerable:!0,writable:!1,configurable:!1,value:h(this.bytes)}),this.latin1}get utf8(){return Object.defineProperty(this,"utf8",{enumerable:!0,writable:!1,configurable:!1,value:g(this.bytes)}),this.utf8}get base32(){return Object.defineProperty(this,"base32",{enumerable:!0,writable:!1,configurable:!1,value:o(this.bytes)}),this.base32}get hex(){return Object.defineProperty(this,"hex",{enumerable:!0,writable:!1,configurable:!1,value:l(this.bytes)}),this.hex}constructor({buffer:e,size:i=20}={}){this.bytes=void 0===e?(e=>{if(t?.randomBytes)return t.randomBytes(e);if(r.crypto?.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));throw new Error("Cryptography API not available")})(i):new Uint8Array(e),Object.defineProperty(this,"bytes",{enumerable:!0,writable:!1,configurable:!1,value:this.bytes})}}class b{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,counter:0,window:1}}static generate({secret:e,algorithm:i=b.defaults.algorithm,digits:s=b.defaults.digits,counter:n=b.defaults.counter}){const o=((e,i,s)=>{if(t?.createHmac){const n=t.createHmac(e,r.Buffer.from(i));return n.update(r.Buffer.from(s)),n.digest()}throw new Error("Missing HMAC function")})(i,e.bytes,(e=>{const t=new ArrayBuffer(8),r=new Uint8Array(t);let i=e;for(let e=7;e>=0&&0!==i;e--)r[e]=255&i,i-=r[e], i/=256;return r})(n)),a=15&o[o.byteLength-1];return(((127&o[a])<<24|(255&o[a+1])<<16|(255&o[a+2])<<8|255&o[a+3])%10**s).toString().padStart(s,"0")}generate({counter:e=this.counter++}={}){return b.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:e})}static validate({token:e,secret:i,algorithm:s,digits:n=b.defaults.digits,counter:o=b.defaults.counter,window:a=b.defaults.window}){if(e.length!==n)return null;let l=null;const u=a=>{const u=b.generate({secret:i,algorithm:s,digits:n,counter:a});((e,i)=>{if(t?.timingSafeEqual)return t.timingSafeEqual(r.Buffer.from(e),r.Buffer.from(i));{if(e.length!==i.length)throw new TypeError("Input strings must have the same length");let t=-1,r=0;for(;++t0?this.issuerInLabel?`${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?`)+`secret=${e(this.secret.base32)}&`+`algorithm=${e(this.algorithm)}&`+`digits=${e(this.digits)}&`+`counter=${e(this.counter)}`}constructor({issuer:e=b.defaults.issuer,label:t=b.defaults.label,issuerInLabel:r=b.defaults.issuerInLabel,secret:s=new p,algorithm:n=b.defaults.algorithm,digits:o=b.defaults.digits,counter:a=b.defaults.counter}={}){this.issuer=e,this.label=t,this.issuerInLabel=r,this.secret="string"==typeof s?p.fromBase32(s):s,this.algorithm=i(n),this.digits=o,this.counter=a}}class w{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,period:30,window:1}}static generate({secret:e,algorithm:t,digits:r,period:i=w.defaults.period,timestamp:s=Date.now()}){return b.generate({secret:e,algorithm:t,digits:r, counter:Math.floor(s/1e3/i)})}generate({timestamp:e=Date.now()}={}){return w.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:e})}static validate({token:e,secret:t,algorithm:r,digits:i,period:s=w.defaults.period,timestamp:n=Date.now(),window:o}){return b.validate({token:e,secret:t,algorithm:r,digits:i,counter:Math.floor(n/1e3/s),window:o})}validate({token:e,timestamp:t,window:r}){return w.validate({token:e,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:t,window:r})}toString(){const e=encodeURIComponent;return"otpauth://totp/"+(this.issuer.length>0?this.issuerInLabel?`${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?`)+`secret=${e(this.secret.base32)}&`+`algorithm=${e(this.algorithm)}&`+`digits=${e(this.digits)}&`+`period=${e(this.period)}`}constructor({issuer:e=w.defaults.issuer,label:t=w.defaults.label,issuerInLabel:r=w.defaults.issuerInLabel,secret:s=new p,algorithm:n=w.defaults.algorithm,digits:o=w.defaults.digits,period:a=w.defaults.period}={}){this.issuer=e,this.label=t,this.issuerInLabel=r,this.secret="string"==typeof s?p.fromBase32(s):s,this.algorithm=i(n),this.digits=o,this.period=a}}const m=/^otpauth:\/\/([ht]otp)\/(.+)\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i,y=/^[2-7A-Z]+=*$/i,A=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,S=/^[+-]?\d+$/,v=/^\+?[1-9]\d*$/;exports.HOTP=b,exports.Secret=p,exports.TOTP=w,exports.URI=class{static parse(e){let t;try{t=e.match(m)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");const r=t[1].toLowerCase(),i=t[2].split(/(?::|%3A) *(.+)/i,2).map(decodeURIComponent),s=t[3].split("&").reduce(((e,t)=>{const r=t.split(/=(.*)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),s=r[1],n=e;return n[i]=s,n}),{});let n;const o={};if("hotp"===r){if(n=b,void 0===s.counter||!S.test(s.counter))throw new TypeError("Missing or invalid 'counter' parameter") -;o.counter=parseInt(s.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=w,void 0!==s.period){if(!v.test(s.period))throw new TypeError("Invalid 'period' parameter");o.period=parseInt(s.period,10)}}if(void 0!==s.issuer&&(o.issuer=s.issuer),2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===s.secret||!y.test(s.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=s.secret,void 0!==s.algorithm){if(!A.test(s.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=s.algorithm}if(void 0!==s.digits){if(!v.test(s.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(s.digits,10)}return new n(o)}static stringify(e){if(e instanceof b||e instanceof w)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}},exports.version="9.3.5"; +;o.counter=parseInt(s.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=w,void 0!==s.period){if(!v.test(s.period))throw new TypeError("Invalid 'period' parameter");o.period=parseInt(s.period,10)}}if(void 0!==s.issuer&&(o.issuer=s.issuer),2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===s.secret||!y.test(s.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=s.secret,void 0!==s.algorithm){if(!A.test(s.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=s.algorithm}if(void 0!==s.digits){if(!v.test(s.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(s.digits,10)}return new n(o)}static stringify(e){if(e instanceof b||e instanceof w)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}},exports.version="9.3.6"; //# sourceMappingURL=otpauth.node.min.cjs.map diff --git a/dist/otpauth.node.min.cjs.map b/dist/otpauth.node.min.cjs.map index 60cc2b2..e8fde5c 100644 --- a/dist/otpauth.node.min.cjs.map +++ b/dist/otpauth.node.min.cjs.map @@ -1 +1 @@ -{"version":3,"file":"otpauth.node.min.cjs","sources":["../src/internal/encoding/uint.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["globalScope","globalThis","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","str","end","replace","length","substring","toUpperCase","buf","ArrayBuffer","arr","Uint8Array","bits","value","index","i","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","TextEncoder","DECODER","TextDecoder","utf8Decode","Error","encode","utf8Encode","decode","Secret","fromLatin1","buffer","fromUTF8","fromBase32","fromHex","bytes","latin1","enumerable","writable","utf8","base32","constructor","size","crypto","randomBytes","getRandomValues","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","digest","key","message","createHmac","hmac","Buffer","from","update","hmacDigest","num","acc","uintDecode","offset","byteLength","padStart","validate","token","delta","check","generatedToken","a","b","timingSafeEqual","out","e","encodeURIComponent","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp"],"mappings":";;;gTAKA,MCAMA,EAAe,MACnB,GAA0B,iBAAfC,WAAyB,OAAOA,WAEzCC,OAAOC,eAAeD,OAAOE,UAAW,iBAAkB,CACxDC,GAAAA,GACE,OAAOC,IACT,EACAC,cAAc,IAEhB,IAGE,GAA8B,oBAAnBC,eAAgC,OAAOA,eAC1C,eAEDN,OAAOE,UAAUI,cAC1B,CAIF,MAAoB,oBAATC,KAA6BA,KACb,oBAAXC,OAA+BA,OACpB,oBAAXC,OAA+BA,YAA1C,CAGP,EAzBqB,GCuBfC,EAAyBC,IAC7B,QAAQ,GACN,IAAK,0BAA0BC,KAAKD,GAClC,MAAO,OACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,S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U,oBARpB,GAHA4H,EAAMjC,OAG0B,IAArB0B,EAAUzB,OAAwB,CAC3C,IAAIU,EAAuBvG,KAAKsH,EAAUzB,QAGxC,MAAM,IAAI5F,UAAU,8BAFpB6H,EAAOjC,OAASvE,SAASgG,EAAUzB,OAAQ,GAI/C,CAGF,CAsBA,QAlBgC,IAArByB,EAAU3D,SACnBmE,EAAOnE,OAAS2D,EAAU3D,QAEJ,IAApBuD,EAAS3G,QACXuH,EAAOlE,MAAQsD,EAAS,QACK,IAAlBY,EAAOnE,QAA4C,KAAlBmE,EAAOnE,OACjDmE,EAAOnE,OAASuD,EAAS,GACA,KAAhBA,EAAS,KAClBY,EAAOjE,eAAgB,KAGzBiE,EAAOlE,MAAQsD,EAAS,QACK,IAAlBY,EAAOnE,QAA4C,KAAlBmE,EAAOnE,SACjDmE,EAAOjE,eAAgB,SAKK,IAArByD,EAAUrD,SAA0BmC,EAAapG,KAAKsH,EAAUrD,QAGzE,MAAM,IAAIhE,UAAU,yCAItB,GANE6H,EAAO7D,OAASqD,EAAUrD,YAMO,IAAxBqD,EAAUvH,UAA2B,CAC9C,IAAIsG,EAAgBrG,KAAKsH,EAAUvH,WAGjC,MAAM,IAAIE,UAAU,iCAFpB6H,EAAO/H,UAAYuH,EAAUvH,SAIjC,CAGA,QAAgC,IAArBuH,EAAUxD,OAAwB,CAC3C,IAAIyC,EAAuBvG,KAAKsH,EAAUxD,QAGxC,MAAM,IAAI7D,UAAU,8BAFpB6H,EAAOhE,OAASxC,SAASgG,EAAUxD,OAAQ,GAI/C,CAEA,OAAO,IAAI+D,EAAIC,EACjB,CAOA,gBAAOC,CAAUC,GACf,GAAIA,aAAevE,GAAQuE,aAAepC,EACxC,OAAOoC,EAAIvG,WAGb,MAAM,IAAIxB,UAAU,6BACtB,mBC1Jc"} \ No newline at end of file +{"version":3,"file":"otpauth.node.min.cjs","sources":["../src/internal/encoding/uint.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n num *= 256;\n num += arr[i];\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["globalScope","globalThis","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","str","end","replace","length","substring","toUpperCase","buf","ArrayBuffer","arr","Uint8Array","bits","value","index","i","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","TextEncoder","DECODER","TextDecoder","utf8Decode","Error","encode","utf8Encode","decode","Secret","fromLatin1","buffer","fromUTF8","fromBase32","fromHex","bytes","latin1","enumerable","writable","utf8","base32","constructor","size","crypto","randomBytes","getRandomValues","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","digest","key","message","createHmac","hmac","Buffer","from","update","hmacDigest","num","acc","uintDecode","offset","byteLength","padStart","validate","token","delta","check","generatedToken","a","b","timingSafeEqual","out","e","encodeURIComponent","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp"],"mappings":";;;gTAKA,MCAMA,EAAe,MACnB,GAA0B,iBAAfC,WAAyB,OAAOA,WAEzCC,OAAOC,eAAeD,OAAOE,UAAW,iBAAkB,CACxDC,GAAAA,GACE,OAAOC,IACT,EACAC,cAAc,IAEhB,IAGE,GAA8B,oBAAnBC,eAAgC,OAAOA,eAC1C,eAEDN,OAAOE,UAAUI,cAC1B,CAIF,MAAoB,oBAATC,KAA6BA,KACb,oBAAXC,OAA+BA,OACpB,oBAAXC,OAA+BA,YAA1C,CAGP,EAzBqB,GCuBfC,EAAyBC,IAC7B,QAAQ,GACN,IAAK,0BAA0BC,KAAKD,GAClC,MAAO,OACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,QACE,MAAM,IAAIE,UAAU,2BAA2BF,KACnD,EC9CIG,EAAW,mCAQXC,EAAgBC,IAKpB,IAAIC,GAHJD,EAAMA,EAAIE,QAAQ,KAAM,KAGVC,OACd,KAAwB,MAAjBH,EAAIC,EAAM,MAAcA,EAC/BD,GAAOC,EAAMD,EAAIG,OAASH,EAAII,UAAU,EAAGH,GAAOD,GAAKK,cAEvD,MAAMC,EAAM,IAAIC,YAA2B,EAAbP,EAAIG,OAAc,EAAK,GAC/CK,EAAM,IAAIC,WAAWH,GAC3B,IAAII,EAAO,EACPC,EAAQ,EACRC,EAAQ,EAEZ,IAAK,IAAIC,EAAI,EAAGA,EAAIb,EAAIG,OAAQU,IAAK,CACnC,MA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AUvH,WAGjC,MAAM,IAAIE,UAAU,iCAFpB6H,EAAO/H,UAAYuH,EAAUvH,SAIjC,CAGA,QAAgC,IAArBuH,EAAUxD,OAAwB,CAC3C,IAAIyC,EAAuBvG,KAAKsH,EAAUxD,QAGxC,MAAM,IAAI7D,UAAU,8BAFpB6H,EAAOhE,OAASxC,SAASgG,EAAUxD,OAAQ,GAI/C,CAEA,OAAO,IAAI+D,EAAIC,EACjB,CAOA,gBAAOC,CAAUC,GACf,GAAIA,aAAevE,GAAQuE,aAAepC,EACxC,OAAOoC,EAAIvG,WAGb,MAAM,IAAIxB,UAAU,6BACtB,mBC1Jc"} \ No newline at end of file diff --git a/dist/otpauth.node.min.mjs b/dist/otpauth.node.min.mjs index 9e4d983..6d5ed53 100644 --- a/dist/otpauth.node.min.mjs +++ b/dist/otpauth.node.min.mjs @@ -1,9 +1,9 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth /// // @ts-nocheck import*as e from"node:crypto";const t=(()=>{if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"__GLOBALTHIS__",{get(){return this},configurable:!0});try{if("undefined"!=typeof __GLOBALTHIS__)return __GLOBALTHIS__}finally{delete Object.prototype.__GLOBALTHIS__}return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0})(),r=e=>{switch(!0){case/^(?:SHA-?1|SSL3-SHA1)$/i.test(e):return"SHA1";case/^SHA(?:2?-)?224$/i.test(e):return"SHA224";case/^SHA(?:2?-)?256$/i.test(e):return"SHA256";case/^SHA(?:2?-)?384$/i.test(e):return"SHA384";case/^SHA(?:2?-)?512$/i.test(e):return"SHA512";case/^SHA3-224$/i.test(e):return"SHA3-224";case/^SHA3-256$/i.test(e):return"SHA3-256";case/^SHA3-384$/i.test(e):return"SHA3-384";case/^SHA3-512$/i.test(e):return"SHA3-512";default:throw new TypeError(`Unknown hash algorithm: ${e}`)}},i="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",s=e=>{let t=(e=e.replace(/ /g,"")).length;for(;"="===e[t-1];)--t;e=(t=8&&(n-=8,s[a++]=o>>>n)}return s},n=e=>{let t=0,r=0,s="";for(let n=0;n=5;)s+=i[r>>>t-5&31],t-=5;return t>0&&(s+=i[r<<5-t&31]),s},o=e=>{e=e.replace(/ /g,"");const t=new ArrayBuffer(e.length/2),r=new Uint8Array(t);for(let t=0;t{let t="";for(let r=0;r{const t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t{let t="";for(let r=0;r{if(!h)throw new Error("Encoding API not available") ;return h.encode(e)},f=e=>{if(!d)throw new Error("Encoding API not available");return d.decode(e)};class g{static fromLatin1(e){return new g({buffer:l(e).buffer})}static fromUTF8(e){return new g({buffer:c(e).buffer})}static fromBase32(e){return new g({buffer:s(e).buffer})}static fromHex(e){return new g({buffer:o(e).buffer})}get buffer(){return this.bytes.buffer}get latin1(){return Object.defineProperty(this,"latin1",{enumerable:!0,writable:!1,configurable:!1,value:u(this.bytes)}),this.latin1}get utf8(){return Object.defineProperty(this,"utf8",{enumerable:!0,writable:!1,configurable:!1,value:f(this.bytes)}),this.utf8}get base32(){return Object.defineProperty(this,"base32",{enumerable:!0,writable:!1,configurable:!1,value:n(this.bytes)}),this.base32}get hex(){return Object.defineProperty(this,"hex",{enumerable:!0,writable:!1,configurable:!1,value:a(this.bytes)}),this.hex}constructor({buffer:r,size:i=20}={}){this.bytes=void 0===r?(r=>{if(e?.randomBytes)return e.randomBytes(r);if(t.crypto?.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(r));throw new Error("Cryptography API not available")})(i):new Uint8Array(r),Object.defineProperty(this,"bytes",{enumerable:!0,writable:!1,configurable:!1,value:this.bytes})}}class p{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,counter:0,window:1}}static generate({secret:r,algorithm:i=p.defaults.algorithm,digits:s=p.defaults.digits,counter:n=p.defaults.counter}){const o=((r,i,s)=>{if(e?.createHmac){const n=e.createHmac(r,t.Buffer.from(i));return n.update(t.Buffer.from(s)),n.digest()}throw new Error("Missing HMAC function")})(i,r.bytes,(e=>{const t=new ArrayBuffer(8),r=new Uint8Array(t);let i=e;for(let e=7;e>=0&&0!==i;e--)r[e]=255&i,i-=r[e],i/=256;return r})(n)),a=15&o[o.byteLength-1];return(((127&o[a])<<24|(255&o[a+1])<<16|(255&o[a+2])<<8|255&o[a+3])%10**s).toString().padStart(s,"0")}generate({counter:e=this.counter++}={}){return p.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:e})} static validate({token:r,secret:i,algorithm:s,digits:n=p.defaults.digits,counter:o=p.defaults.counter,window:a=p.defaults.window}){if(r.length!==n)return null;let l=null;const u=a=>{const u=p.generate({secret:i,algorithm:s,digits:n,counter:a});((r,i)=>{if(e?.timingSafeEqual)return e.timingSafeEqual(t.Buffer.from(r),t.Buffer.from(i));{if(r.length!==i.length)throw new TypeError("Input strings must have the same length");let e=-1,t=0;for(;++e0?this.issuerInLabel?`${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?`)+`secret=${e(this.secret.base32)}&`+`algorithm=${e(this.algorithm)}&`+`digits=${e(this.digits)}&`+`counter=${e(this.counter)}`}constructor({issuer:e=p.defaults.issuer,label:t=p.defaults.label,issuerInLabel:i=p.defaults.issuerInLabel,secret:s=new g,algorithm:n=p.defaults.algorithm,digits:o=p.defaults.digits,counter:a=p.defaults.counter}={}){this.issuer=e,this.label=t,this.issuerInLabel=i,this.secret="string"==typeof s?g.fromBase32(s):s,this.algorithm=r(n),this.digits=o,this.counter=a}}class b{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,period:30,window:1}}static generate({secret:e,algorithm:t,digits:r,period:i=b.defaults.period,timestamp:s=Date.now()}){return p.generate({secret:e,algorithm:t,digits:r,counter:Math.floor(s/1e3/i)})}generate({timestamp:e=Date.now()}={}){return b.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:e})} static validate({token:e,secret:t,algorithm:r,digits:i,period:s=b.defaults.period,timestamp:n=Date.now(),window:o}){return p.validate({token:e,secret:t,algorithm:r,digits:i,counter:Math.floor(n/1e3/s),window:o})}validate({token:e,timestamp:t,window:r}){return b.validate({token:e,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:t,window:r})}toString(){const e=encodeURIComponent;return"otpauth://totp/"+(this.issuer.length>0?this.issuerInLabel?`${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?`)+`secret=${e(this.secret.base32)}&`+`algorithm=${e(this.algorithm)}&`+`digits=${e(this.digits)}&`+`period=${e(this.period)}`}constructor({issuer:e=b.defaults.issuer,label:t=b.defaults.label,issuerInLabel:i=b.defaults.issuerInLabel,secret:s=new g,algorithm:n=b.defaults.algorithm,digits:o=b.defaults.digits,period:a=b.defaults.period}={}){this.issuer=e,this.label=t,this.issuerInLabel=i,this.secret="string"==typeof s?g.fromBase32(s):s,this.algorithm=r(n),this.digits=o,this.period=a}}const m=/^otpauth:\/\/([ht]otp)\/(.+)\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i,w=/^[2-7A-Z]+=*$/i,y=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,A=/^[+-]?\d+$/,S=/^\+?[1-9]\d*$/;class I{static parse(e){let t;try{t=e.match(m)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");const r=t[1].toLowerCase(),i=t[2].split(/(?::|%3A) *(.+)/i,2).map(decodeURIComponent),s=t[3].split("&").reduce(((e,t)=>{const r=t.split(/=(.*)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),s=r[1],n=e;return n[i]=s,n}),{});let n;const o={};if("hotp"===r){if(n=p,void 0===s.counter||!A.test(s.counter))throw new TypeError("Missing or invalid 'counter' parameter");o.counter=parseInt(s.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=b,void 0!==s.period){if(!S.test(s.period))throw new TypeError("Invalid 'period' parameter");o.period=parseInt(s.period,10)}}if(void 0!==s.issuer&&(o.issuer=s.issuer), -2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===s.secret||!w.test(s.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=s.secret,void 0!==s.algorithm){if(!y.test(s.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=s.algorithm}if(void 0!==s.digits){if(!S.test(s.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(s.digits,10)}return new n(o)}static stringify(e){if(e instanceof p||e instanceof b)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}const $="9.3.5";export{p as HOTP,g as Secret,b as TOTP,I as URI,$ as version}; +2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===s.secret||!w.test(s.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=s.secret,void 0!==s.algorithm){if(!y.test(s.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=s.algorithm}if(void 0!==s.digits){if(!S.test(s.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(s.digits,10)}return new n(o)}static stringify(e){if(e instanceof p||e instanceof b)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}const $="9.3.6";export{p as HOTP,g as Secret,b as TOTP,I as URI,$ as version}; //# sourceMappingURL=otpauth.node.min.mjs.map diff --git a/dist/otpauth.node.min.mjs.map b/dist/otpauth.node.min.mjs.map index 85dc521..02d7a30 100644 --- a/dist/otpauth.node.min.mjs.map +++ b/dist/otpauth.node.min.mjs.map @@ -1 +1 @@ -{"version":3,"file":"otpauth.node.min.mjs","sources":["../src/internal/encoding/uint.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["globalScope","globalThis","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","str","end","replace","length","substring","toUpperCase","buf","ArrayBuffer","arr","Uint8Array","bits","value","index","i","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","TextEncoder","DECODER","TextDecoder","utf8Decode","Error","encode","utf8Encode","decode","Secret","fromLatin1","buffer","fromUTF8","fromBase32","fromHex","bytes","latin1","enumerable","writable","utf8","base32","constructor","size","crypto","randomBytes","getRandomValues","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","digest","key","message","createHmac","hmac","Buffer","from","update","hmacDigest","num","acc","uintDecode","offset","byteLength","padStart","validate","token","delta","check","generatedToken","a","b","timingSafeEqual","out","e","encodeURIComponent","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp","version"],"mappings":";;;8BAKA,MCAMA,EAAe,MACnB,GAA0B,iBAAfC,WAAyB,OAAOA,WAEzCC,OAAOC,eAAeD,OAAOE,UAAW,iBAAkB,CACxDC,GAAAA,GACE,OAAOC,IACT,EACAC,cAAc,IAEhB,IAGE,GAA8B,oBAAnBC,eAAgC,OAAOA,eAC1C,eAEDN,OAAOE,UAAUI,cAC1B,CAIF,MAAoB,oBAATC,KAA6BA,KACb,oBAAXC,OAA+BA,OACpB,oBAAXC,OAA+BA,YAA1C,CAGP,EAzBqB,GCuBfC,EAAyBC,IAC7B,QAAQ,GACN,IAAK,0BAA0BC,KAAKD,GAClC,MAAO,OACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,QACE,MAAM,IAAIE,UAAU,2BAA2BF,KACnD,EC9CIG,EAAW,mCAQXC,EAAgBC,IAKpB,IAAIC,GAHJD,EAAMA,EAAIE,QAAQ,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EAAS,GACA,KAAhBA,EAAS,KAClBY,EAAOlE,eAAgB,KAGzBkE,EAAOnE,MAAQuD,EAAS,QACK,IAAlBY,EAAOpE,QAA4C,KAAlBoE,EAAOpE,SACjDoE,EAAOlE,eAAgB,SAKK,IAArB0D,EAAUtD,SAA0BmC,EAAapG,KAAKuH,EAAUtD,QAGzE,MAAM,IAAIhE,UAAU,yCAItB,GANE8H,EAAO9D,OAASsD,EAAUtD,YAMO,IAAxBsD,EAAUxH,UAA2B,CAC9C,IAAIsG,EAAgBrG,KAAKuH,EAAUxH,WAGjC,MAAM,IAAIE,UAAU,iCAFpB8H,EAAOhI,UAAYwH,EAAUxH,SAIjC,CAGA,QAAgC,IAArBwH,EAAUzD,OAAwB,CAC3C,IAAIyC,EAAuBvG,KAAKuH,EAAUzD,QAGxC,MAAM,IAAI7D,UAAU,8BAFpB8H,EAAOjE,OAASxC,SAASiG,EAAUzD,OAAQ,GAI/C,CAEA,OAAO,IAAIgE,EAAIC,EACjB,CAOA,gBAAOC,CAAUC,GACf,GAAIA,aAAexE,GAAQwE,aAAerC,EACxC,OAAOqC,EAAIxG,WAGb,MAAM,IAAIxB,UAAU,6BACtB,QC1JIiI,EAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.node.min.mjs","sources":["../src/internal/encoding/uint.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n num *= 256;\n num += arr[i];\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["globalScope","globalThis","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","str","end","replace","length","substring","toUpperCase","buf","ArrayBuffer","arr","Uint8Array","bits","value","index","i","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","TextEncoder","DECODER","TextDecoder","utf8Decode","Error","encode","utf8Encode","decode","Secret","fromLatin1","buffer","fromUTF8","fromBase32","fromHex","bytes","latin1","enumerable","writable","utf8","base32","constructor","size","crypto","randomBytes","getRandomValues","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","digest","key","message","createHmac","hmac","Buffer","from","update","hmacDigest","num","acc","uintDecode","offset","byteLength","padStart","validate","token","delta","check","generatedToken","a","b","timingSafeEqual","out","e","encodeURIComponent","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp","version"],"mappings":";;;8BAKA,MCAMA,EAAe,MACnB,GAA0B,iBAAfC,WAAyB,OAAOA,WAEzCC,OAAOC,eAAeD,OAAOE,UAAW,iBAAkB,CACxDC,GAAAA,GACE,OAAOC,IACT,EACAC,cAAc,IAEhB,IAGE,GAA8B,oBAAnBC,eAAgC,OAAOA,eAC1C,eAEDN,OAAOE,UAAUI,cAC1B,CAIF,MAAoB,oBAATC,KAA6BA,KACb,oBAAXC,OAA+BA,OACpB,oBAA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AGb,MAAM,IAAIxB,UAAU,6BACtB,QC1JIiI,EAAU"} \ No newline at end of file diff --git a/dist/otpauth.node.mjs b/dist/otpauth.node.mjs index 997c78e..1337600 100644 --- a/dist/otpauth.node.mjs +++ b/dist/otpauth.node.mjs @@ -1,4 +1,4 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth /// // @ts-nocheck import * as crypto from 'node:crypto'; @@ -808,6 +808,6 @@ import * as crypto from 'node:crypto'; /** * Library version. * @type {string} - */ const version = "9.3.5"; + */ const version = "9.3.6"; export { HOTP, Secret, TOTP, URI, version }; diff --git a/dist/otpauth.slim.esm.js b/dist/otpauth.slim.esm.js index 40b09bb..7212535 100644 --- a/dist/otpauth.slim.esm.js +++ b/dist/otpauth.slim.esm.js @@ -1,5 +1,5 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth -//! noble-hashes 1.5.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! noble-hashes 1.6.1 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes /// // @ts-nocheck import { hmac } from '@noble/hashes/hmac'; @@ -821,6 +821,6 @@ import { sha3_224, sha3_256, sha3_384, sha3_512 } from '@noble/hashes/sha3'; /** * Library version. * @type {string} - */ const version = "9.3.5"; + */ const version = "9.3.6"; export { HOTP, Secret, TOTP, URI, version }; diff --git a/dist/otpauth.slim.esm.min.js b/dist/otpauth.slim.esm.min.js index bbb32f6..858821e 100644 --- a/dist/otpauth.slim.esm.min.js +++ b/dist/otpauth.slim.esm.min.js @@ -1,10 +1,10 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth -//! noble-hashes 1.5.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! noble-hashes 1.6.1 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes /// // @ts-nocheck import{hmac as e}from"@noble/hashes/hmac";import{sha1 as t}from"@noble/hashes/sha1";import{sha224 as r,sha256 as i,sha384 as s,sha512 as n}from"@noble/hashes/sha2";import{sha3_224 as o,sha3_256 as a,sha3_384 as l,sha3_512 as u}from"@noble/hashes/sha3";const h=(()=>{if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"__GLOBALTHIS__",{get(){return this},configurable:!0});try{if("undefined"!=typeof __GLOBALTHIS__)return __GLOBALTHIS__}finally{delete Object.prototype.__GLOBALTHIS__}return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0})(),d={SHA1:t,SHA224:r,SHA256:i,SHA384:s,SHA512:n,"SHA3-224":o,"SHA3-256":a,"SHA3-384":l,"SHA3-512":u},c=e=>{switch(!0){case/^(?:SHA-?1|SSL3-SHA1)$/i.test(e):return"SHA1";case/^SHA(?:2?-)?224$/i.test(e):return"SHA224";case/^SHA(?:2?-)?256$/i.test(e):return"SHA256";case/^SHA(?:2?-)?384$/i.test(e):return"SHA384";case/^SHA(?:2?-)?512$/i.test(e):return"SHA512";case/^SHA3-224$/i.test(e):return"SHA3-224";case/^SHA3-256$/i.test(e):return"SHA3-256";case/^SHA3-384$/i.test(e):return"SHA3-384";case/^SHA3-512$/i.test(e):return"SHA3-512";default:throw new TypeError(`Unknown hash algorithm: ${e}`)}},g="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",f=e=>{let t=(e=e.replace(/ /g,"")).length;for(;"="===e[t-1];)--t;e=(t=8&&(s-=8,i[o++]=n>>>s)}return i},p=e=>{let t=0,r=0,i="";for(let s=0;s=5;)i+=g[r>>>t-5&31],t-=5;return t>0&&(i+=g[r<<5-t&31]),i},b=e=>{e=e.replace(/ /g,"");const t=new ArrayBuffer(e.length/2),r=new Uint8Array(t);for(let t=0;t{let t="";for(let r=0;r{ const t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t{let t="";for(let r=0;r{if(!y)throw new Error("Encoding API not available");return y.encode(e)},I=e=>{if(!S)throw new Error("Encoding API not available");return S.decode(e)};class ${static fromLatin1(e){return new $({buffer:m(e).buffer})}static fromUTF8(e){return new $({buffer:H(e).buffer})}static fromBase32(e){return new $({buffer:f(e).buffer})}static fromHex(e){return new $({buffer:b(e).buffer})}get buffer(){return this.bytes.buffer}get latin1(){return Object.defineProperty(this,"latin1",{enumerable:!0,writable:!1,configurable:!1,value:A(this.bytes)}),this.latin1}get utf8(){return Object.defineProperty(this,"utf8",{enumerable:!0,writable:!1,configurable:!1,value:I(this.bytes)}),this.utf8}get base32(){return Object.defineProperty(this,"base32",{enumerable:!0,writable:!1,configurable:!1,value:p(this.bytes)}),this.base32}get hex(){return Object.defineProperty(this,"hex",{enumerable:!0,writable:!1,configurable:!1,value:w(this.bytes)}),this.hex}constructor({buffer:e,size:t=20}={}){this.bytes=void 0===e?(e=>{if(h.crypto?.getRandomValues)return h.crypto.getRandomValues(new Uint8Array(e));throw new Error("Cryptography API not available")})(t):new Uint8Array(e),Object.defineProperty(this,"bytes",{enumerable:!0,writable:!1,configurable:!1,value:this.bytes})}}class v{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,counter:0,window:1}}static generate({secret:t,algorithm:r=v.defaults.algorithm,digits:i=v.defaults.digits,counter:s=v.defaults.counter}){const n=((t,r,i)=>{if(e){const s=d[t]??d[c(t)];return e(s,r,i)}throw new Error("Missing HMAC function")})(r,t.bytes,(e=>{const t=new ArrayBuffer(8),r=new Uint8Array(t);let i=e;for(let e=7;e>=0&&0!==i;e--)r[e]=255&i,i-=r[e],i/=256;return r})(s)),o=15&n[n.byteLength-1] ;return(((127&n[o])<<24|(255&n[o+1])<<16|(255&n[o+2])<<8|255&n[o+3])%10**i).toString().padStart(i,"0")}generate({counter:e=this.counter++}={}){return v.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:e})}static validate({token:e,secret:t,algorithm:r,digits:i=v.defaults.digits,counter:s=v.defaults.counter,window:n=v.defaults.window}){if(e.length!==i)return null;let o=null;const a=n=>{const a=v.generate({secret:t,algorithm:r,digits:i,counter:n});((e,t)=>{{if(e.length!==t.length)throw new TypeError("Input strings must have the same length");let r=-1,i=0;for(;++r0?this.issuerInLabel?`${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?`)+`secret=${e(this.secret.base32)}&`+`algorithm=${e(this.algorithm)}&`+`digits=${e(this.digits)}&`+`counter=${e(this.counter)}`}constructor({issuer:e=v.defaults.issuer,label:t=v.defaults.label,issuerInLabel:r=v.defaults.issuerInLabel,secret:i=new $,algorithm:s=v.defaults.algorithm,digits:n=v.defaults.digits,counter:o=v.defaults.counter}={}){this.issuer=e,this.label=t,this.issuerInLabel=r,this.secret="string"==typeof i?$.fromBase32(i):i,this.algorithm=c(s),this.digits=n,this.counter=o}}class T{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,period:30,window:1}}static generate({secret:e,algorithm:t,digits:r,period:i=T.defaults.period,timestamp:s=Date.now()}){return v.generate({secret:e,algorithm:t,digits:r,counter:Math.floor(s/1e3/i)})}generate({timestamp:e=Date.now()}={}){return T.generate({secret:this.secret,algorithm:this.algorithm, digits:this.digits,period:this.period,timestamp:e})}static validate({token:e,secret:t,algorithm:r,digits:i,period:s=T.defaults.period,timestamp:n=Date.now(),window:o}){return v.validate({token:e,secret:t,algorithm:r,digits:i,counter:Math.floor(n/1e3/s),window:o})}validate({token:e,timestamp:t,window:r}){return T.validate({token:e,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:t,window:r})}toString(){const e=encodeURIComponent;return"otpauth://totp/"+(this.issuer.length>0?this.issuerInLabel?`${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?issuer=${e(this.issuer)}&`:`${e(this.label)}?`)+`secret=${e(this.secret.base32)}&`+`algorithm=${e(this.algorithm)}&`+`digits=${e(this.digits)}&`+`period=${e(this.period)}`}constructor({issuer:e=T.defaults.issuer,label:t=T.defaults.label,issuerInLabel:r=T.defaults.issuerInLabel,secret:i=new $,algorithm:s=T.defaults.algorithm,digits:n=T.defaults.digits,period:o=T.defaults.period}={}){this.issuer=e,this.label=t,this.issuerInLabel=r,this.secret="string"==typeof i?$.fromBase32(i):i,this.algorithm=c(s),this.digits=n,this.period=o}}const L=/^otpauth:\/\/([ht]otp)\/(.+)\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i,E=/^[2-7A-Z]+=*$/i,O=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,U=/^[+-]?\d+$/,_=/^\+?[1-9]\d*$/;class C{static parse(e){let t;try{t=e.match(L)}catch(e){}if(!Array.isArray(t))throw new URIError("Invalid URI format");const r=t[1].toLowerCase(),i=t[2].split(/(?::|%3A) *(.+)/i,2).map(decodeURIComponent),s=t[3].split("&").reduce(((e,t)=>{const r=t.split(/=(.*)/,2).map(decodeURIComponent),i=r[0].toLowerCase(),s=r[1],n=e;return n[i]=s,n}),{});let n;const o={};if("hotp"===r){if(n=v,void 0===s.counter||!U.test(s.counter))throw new TypeError("Missing or invalid 'counter' parameter");o.counter=parseInt(s.counter,10)}else{if("totp"!==r)throw new TypeError("Unknown OTP type");if(n=T,void 0!==s.period){if(!_.test(s.period))throw new TypeError("Invalid 'period' parameter") -;o.period=parseInt(s.period,10)}}if(void 0!==s.issuer&&(o.issuer=s.issuer),2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===s.secret||!E.test(s.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=s.secret,void 0!==s.algorithm){if(!O.test(s.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=s.algorithm}if(void 0!==s.digits){if(!_.test(s.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(s.digits,10)}return new n(o)}static stringify(e){if(e instanceof v||e instanceof T)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}const P="9.3.5";export{v as HOTP,$ as Secret,T as TOTP,C as URI,P as version}; +;o.period=parseInt(s.period,10)}}if(void 0!==s.issuer&&(o.issuer=s.issuer),2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===s.secret||!E.test(s.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=s.secret,void 0!==s.algorithm){if(!O.test(s.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=s.algorithm}if(void 0!==s.digits){if(!_.test(s.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(s.digits,10)}return new n(o)}static stringify(e){if(e instanceof v||e instanceof T)return e.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")}}const P="9.3.6";export{v as HOTP,$ as Secret,T as TOTP,C as URI,P as version}; //# sourceMappingURL=otpauth.slim.esm.min.js.map diff --git a/dist/otpauth.slim.esm.min.js.map b/dist/otpauth.slim.esm.min.js.map index 16d4533..354a320 100644 --- a/dist/otpauth.slim.esm.min.js.map +++ b/dist/otpauth.slim.esm.min.js.map @@ -1 +1 @@ -{"version":3,"file":"otpauth.slim.esm.min.js","sources":["../src/internal/encoding/uint.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["globalScope","globalThis","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","nobleHashes","SHA1","sha1","SHA224","sha224","SHA256","sha256","SHA384","sha384","SHA512","sha512","sha3_224","sha3_256","sha3_384","sha3_512","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","str","end","replace","length","substring","toUpperCase","buf","ArrayBuffer","arr","Uint8Array","bits","value","index","i","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","TextEncoder","DECODER","TextDecoder","utf8Decode","Error","encode","utf8Encode","decode","Secret","fromLatin1","buffer","fromUTF8","fromBase32","fromHex","bytes","latin1","enumerable","writable","utf8","base32","constructor","size","crypto","getRandomValues","randomBytes","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","digest","key","message","hmac","hash","hmacDigest","num","acc","uintDecode","offset","byteLength","padStart","validate","token","delta","check","generatedToken","a","b","out","timingSafeEqual","e","encodeURIComponent","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp","version"],"mappings":";;;;4PAKA,MCAMA,EAAe,MACnB,GAA0B,iBAAfC,WAAyB,OAAOA,WAEzCC,OAAOC,eAAeD,OAAOE,UAAW,iBAAkB,CACxDC,GAAAA,GACE,OAAOC,IACT,EACAC,cAAc,IAEhB,IAGE,GAA8B,oBAAnBC,eAAgC,OAAOA,eAC1C,eAEDN,OAAOE,UAAUI,cAC1B,CAIF,MAAoB,oBAATC,KAA6BA,KACb,oBAAXC,OAA+BA,OACpB,oBAAXC,OAA+BA,YAA1C,CAGP,EAzBqB,GCMfC,EAAc,CAClBC,KAAMC,EACNC,OAAQC,EACRC,OAAQC,EACRC,OAAQC,EACRC,OAAQC,EACR,WAAYC,EACZ,WAAYC,EACZ,WAAYC,EACZ,WAAYC,GAQRC,EAAyBC,IAC7B,QAAQ,GACN,IAAK,0BAA0BC,KAAKD,GAClC,MAAO,OACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,oBAAoBC,KAAKD,GAC5B,MAAO,SACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,IAAK,cAAcC,KAAKD,GACtB,MAAO,WACT,QACE,MAAM,IAAIE,UAAU,2BAA2BF,KACnD,EC9CIG,EAAW,mCAQXC,EAAgBC,IAKpB,IAAIC,GAHJD,EAAMA,EAAIE,QAAQ,KAAM,KAGVC,OACd,KAAwB,MAAj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D,QAGzE,MAAM,IAAIhE,UAAU,yCAItB,GANE2H,EAAO3D,OAASmD,EAAUnD,YAMO,IAAxBmD,EAAUrH,UAA2B,CAC9C,IAAImG,EAAgBlG,KAAKoH,EAAUrH,WAGjC,MAAM,IAAIE,UAAU,iCAFpB2H,EAAO7H,UAAYqH,EAAUrH,SAIjC,CAGA,QAAgC,IAArBqH,EAAUtD,OAAwB,CAC3C,IAAIsC,EAAuBpG,KAAKoH,EAAUtD,QAGxC,MAAM,IAAI7D,UAAU,8BAFpB2H,EAAO9D,OAASxC,SAAS8F,EAAUtD,OAAQ,GAI/C,CAEA,OAAO,IAAI6D,EAAIC,EACjB,CAOA,gBAAOC,CAAUC,GACf,GAAIA,aAAerE,GAAQqE,aAAerC,EACxC,OAAOqC,EAAIrG,WAGb,MAAM,IAAIxB,UAAU,6BACtB,QC1JI8H,EAAU"} \ No newline at end of file +{"version":3,"file":"otpauth.slim.esm.min.js","sources":["../src/internal/encoding/uint.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n num *= 256;\n num += arr[i];\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["globalScope","globalThis","Object","defineProperty","prototype","get","this","configurable","__GLOBALTHIS__","self","window","global","nobleHashes","SHA1","sha1","SHA224","sha224","SHA256","sha256","SHA384","sha384","SHA512","sha512","sha3_224","sha3_256","sha3_384","sha3_512","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","str","end","replace","length","substring","toUpperCase","buf","ArrayBuffer","arr","Uint8Array","bits","value","index","i","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","TextEncoder","DECODER","TextDecoder","utf8Decode","Error","encode","utf8Encode","decode","Secret","fromLatin1","buffer","fromUTF8","fromBase32","fromHex","bytes","latin1","enumerable","writable","utf8","base32","constructor","size","crypto","getRandomValues","randomBytes","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","digest","key","message","hmac","hash","hmacDigest","num","acc","uintDecode","offset","byteLength","padStart","validate","token","delta","check","generatedToken","a","b","out","timingSafeEqual","e","encodeURIComponent","TOTP","period","timestamp","Date","now","Math","floor","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","URI","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","split","map","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp","version"],"mappings":";;;;4PAKA,MCAMA,EAAe,MACnB,GAA0B,iBAAfC,WAAyB,OAAOA,WAEzCC,OAAOC,eAAeD,OAAOE,UAAW,iBAAkB,CACxDC,GAAAA,GACE,OAAOC,IACT,EACAC,cAAc,IAEhB,IAGE,GAA8B,oBAAnBC,eAAgC,OAAOA,eAC1C,eAEDN,OAAOE,UAAUI,cAC1B,CAIF,MAAoB,oBAATC,KAA6BA,KACb,oBAAXC,OAA+BA,OACpB,oBAAXC,OAA+BA,YAA1C,CAGP,EAzBqB,GCMfC,EAAc,CAClBC,KAAMC,EACNC,OAAQC,EACRC,OAAQC,EACRC,OAAQC,EACRC,OAAQC,EACR,WAAY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1,5 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth -//! noble-hashes 1.5.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! noble-hashes 1.6.1 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes /// // @ts-nocheck (function (global, factory) { @@ -25,31 +25,31 @@ return arr; }; - function number(n) { - if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`); + function anumber(n) { + if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n); } // copied from utils function isBytes(a) { - return a instanceof Uint8Array || a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'; + return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array'; } - function bytes(b, ...lengths) { + function abytes(b, ...lengths) { if (!isBytes(b)) throw new Error('Uint8Array expected'); - if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`); + if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length); } - function hash(h) { + function ahash(h) { if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash should be wrapped by utils.wrapConstructor'); - number(h.outputLen); - number(h.blockLen); + anumber(h.outputLen); + anumber(h.blockLen); } - function exists(instance, checkFinished = true) { + function aexists(instance, checkFinished = true) { if (instance.destroyed) throw new Error('Hash instance has been destroyed'); if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called'); } - function output(out, instance) { - bytes(out); + function aoutput(out, instance) { + abytes(out); const min = instance.outputLen; if (out.length < min) { - throw new Error(`digestInto() expects output buffer of length at least ${min}`); + throw new Error('digestInto() expects output buffer of length at least ' + min); } } @@ -66,9 +66,9 @@ const rotr = (word, shift)=>word << 32 - shift | word >>> shift; // The rotate left (circular left shift) operation for uint32 const rotl = (word, shift)=>word << shift | word >>> 32 - shift >>> 0; - const isLE = new Uint8Array(new Uint32Array([ - 0x11223344 - ]).buffer)[0] === 0x44; + const isLE = /* @__PURE__ */ (()=>new Uint8Array(new Uint32Array([ + 0x11223344 + ]).buffer)[0] === 0x44)(); // The byte swap operation for uint32 const byteSwap = (word)=>word << 24 & 0xff000000 | word << 8 & 0xff0000 | word >>> 8 & 0xff00 | word >>> 24 & 0xff; // In place byte swap for Uint32Array @@ -80,7 +80,7 @@ /** * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) */ function utf8ToBytes(str) { - if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`); + if (typeof str !== 'string') throw new Error('utf8ToBytes expected string, got ' + typeof str); return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 } /** @@ -89,7 +89,7 @@ * Keep in mind for future mutable operations. */ function toBytes(data) { if (typeof data === 'string') data = utf8ToBytes(data); - bytes(data); + abytes(data); return data; } // For runtime check if class implements interface @@ -111,13 +111,13 @@ // HMAC (RFC 2104) class HMAC extends Hash { update(buf) { - exists(this); + aexists(this); this.iHash.update(buf); return this; } digestInto(out) { - exists(this); - bytes(out, this.outputLen); + aexists(this); + abytes(out, this.outputLen); this.finished = true; this.iHash.digestInto(out); this.oHash.update(out); @@ -147,24 +147,24 @@ this.oHash.destroy(); this.iHash.destroy(); } - constructor(hash$1, _key){ + constructor(hash, _key){ super(); this.finished = false; this.destroyed = false; - hash(hash$1); + ahash(hash); const key = toBytes(_key); - this.iHash = hash$1.create(); + this.iHash = hash.create(); if (typeof this.iHash.update !== 'function') throw new Error('Expected instance of class which extends utils.Hash'); this.blockLen = this.iHash.blockLen; this.outputLen = this.iHash.outputLen; const blockLen = this.blockLen; const pad = new Uint8Array(blockLen); // blockLen can be bigger than outputLen - pad.set(key.length > blockLen ? hash$1.create().update(key).digest() : key); + pad.set(key.length > blockLen ? hash.create().update(key).digest() : key); for(let i = 0; i < pad.length; i++)pad[i] ^= 0x36; this.iHash.update(pad); // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone - this.oHash = hash$1.create(); + this.oHash = hash.create(); // Undo internal XOR && apply outer XOR for(let i = 0; i < pad.length; i++)pad[i] ^= 0x36 ^ 0x5c; this.oHash.update(pad); @@ -207,7 +207,7 @@ * Could be used to create MD5, RIPEMD, SHA1, SHA2. */ class HashMD extends Hash { update(data) { - exists(this); + aexists(this); const { view, buffer, blockLen } = this; data = toBytes(data); const len = data.length; @@ -232,8 +232,8 @@ return this; } digestInto(out) { - exists(this); - output(out, this); + aexists(this); + aoutput(out, this); this.finished = true; // Padding // We can avoid allocation of buffer for padding completely if it @@ -386,7 +386,7 @@ */ const sha1 = /* @__PURE__ */ wrapConstructor(()=>new SHA1()); // SHA2-256 need to try 2^128 hashes to execute birthday attack. - // BTC network is doing 2^67 hashes/sec as per early 2023. + // BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per late 2024. // Round constants: // first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311) // prettier-ignore @@ -580,7 +580,8 @@ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); const _32n = /* @__PURE__ */ BigInt(32); - // We are not using BigUint64Array, because they are extremely slow as per 2022 + // BigUint64Array is too slow as per 2024, so we implement it using Uint32Array. + // TODO: re-check https://issues.chromium.org/issues/42212588 function fromBig(n, le = false) { if (le) return { h: Number(n & U32_MASK64), @@ -1009,7 +1010,7 @@ this.pos = 0; } update(data) { - exists(this); + aexists(this); const { blockLen, state } = this; data = toBytes(data); const len = data.length; @@ -1031,8 +1032,8 @@ this.keccak(); } writeInto(out) { - exists(this, false); - bytes(out); + aexists(this, false); + abytes(out); this.finish(); const bufferOut = this.state; const { blockLen } = this; @@ -1051,11 +1052,11 @@ return this.writeInto(out); } xof(bytes) { - number(bytes); + anumber(bytes); return this.xofInto(new Uint8Array(bytes)); } digestInto(out) { - output(out, this); + aoutput(out, this); if (this.finished) throw new Error('digest() was already called'); this.writeInto(out); this.destroy(); @@ -1096,7 +1097,7 @@ this.finished = false; this.destroyed = false; // Can be passed from user as dkLen - number(outputLen); + anumber(outputLen); // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes if (0 >= this.blockLen || this.blockLen >= 200) throw new Error('Sha3 supports only keccak-f1600 function'); this.state = new Uint8Array(200); @@ -1909,7 +1910,7 @@ /** * Library version. * @type {string} - */ const version = "9.3.5"; + */ const version = "9.3.6"; exports.HOTP = HOTP; exports.Secret = Secret; diff --git a/dist/otpauth.umd.min.js b/dist/otpauth.umd.min.js index bbf6c14..813cd79 100644 --- a/dist/otpauth.umd.min.js +++ b/dist/otpauth.umd.min.js @@ -1,19 +1,19 @@ -//! otpauth 9.3.5 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth -//! noble-hashes 1.5.0 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes +//! otpauth 9.3.6 | (c) Héctor Molinero Fernández | MIT | https://github.com/hectorm/otpauth +//! noble-hashes 1.6.1 | (c) Paul Miller | MIT | https://github.com/paulmillr/noble-hashes /// // @ts-nocheck -!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(t){"use strict";function e(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function s(t,...e){if(!((s=t)instanceof Uint8Array||null!=s&&"object"==typeof s&&"Uint8Array"===s.constructor.name))throw new Error("Uint8Array expected");var s;if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function i(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function r(t,e){s(t);const i=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),o=(t,e)=>t<<32-e|t>>>e,h=(t,e)=>t<>>32-e>>>0,a=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function l(t){for(let s=0;s>>8&65280|e>>>24&255;var e}function c(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),s(t),t}class d{clone(){return this._cloneInto()}}function u(t){const e=e=>t().update(c(e)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}class f extends d{update(t){return i(this),this.iHash.update(t),this}digestInto(t){i(this),s(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return t.finished=i,t.destroyed=r, +!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(t){"use strict";function e(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function s(t,...e){if(!((s=t)instanceof Uint8Array||ArrayBuffer.isView(s)&&"Uint8Array"===s.constructor.name))throw new Error("Uint8Array expected");var s;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function i(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function r(t,e){s(t);const i=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),o=(t,e)=>t<<32-e|t>>>e,h=(t,e)=>t<>>32-e>>>0,a=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function l(t){for(let s=0;s>>8&65280|e>>>24&255;var e}function c(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),s(t),t}class d{clone(){return this._cloneInto()}}function u(t){const e=e=>t().update(c(e)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}class f extends d{update(t){return i(this),this.iHash.update(t),this}digestInto(t){i(this),s(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return t.finished=i,t.destroyed=r, t.blockLen=n,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=s._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}constructor(t,s){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");e(t.outputLen),e(t.blockLen)}(t);const i=c(s);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?t.create().update(i).digest():i);for(let t=0;tnew f(t,e).update(s).digest();b.create=(t,e)=>new f(t,e);const g=(t,e,s)=>t&e^~t&s,p=(t,e,s)=>t&e^t&s^e&s;class w extends d{update(t){i(this);const{view:e,buffer:s,blockLen:r}=this,o=(t=c(t)).length;for(let i=0;io-a&&(this.process(s,0),a=0);for(let t=a;t>r&n),h=Number(s&n),a=i?4:0,l=i?0:4;t.setUint32(e+a,o,i),t.setUint32(e+l,h,i)}(s,o-8,BigInt(8*this.length),h),this.process(s,0);const l=n(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=c/4,u=this.get();if(d>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;tnew A)),L=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),m=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),I=new Uint32Array(64);class S extends w{get(){const{A:t,B:e,C:s,D:i,E:r,F:n,G:o,H:h}=this;return[t,e,s,i,r,n,o,h]}set(t,e,s,i,r,n,o,h){this.A=0|t,this.B=0|e,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|h}process(t,e){for(let s=0;s<16;s++,e+=4)I[s]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=I[t-15],s=I[t-2],i=o(e,7)^o(e,18)^e>>>3,r=o(s,17)^o(s,19)^s>>>10;I[t]=r+I[t-7]+i+I[t-16]|0}let{A:s,B:i,C:r,D:n,E:h,F:a,G:l,H:c}=this;for(let t=0;t<64;t++){const e=c+(o(h,6)^o(h,11)^o(h,25))+g(h,a,l)+L[t]+I[t]|0,d=(o(s,2)^o(s,13)^o(s,22))+p(s,i,r)|0;c=l,l=a,a=h,h=n+e|0,n=r,r=i,i=s,s=e+d|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,h=h+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(s,i,r,n,h,a,l,c)}roundClean(){I.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}constructor(){super(64,32,8,!1),this.A=0|m[0],this.B=0|m[1],this.C=0|m[2],this.D=0|m[3],this.E=0|m[4],this.F=0|m[5],this.G=0|m[6],this.H=0|m[7]}}class B extends S{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}} -const E=u((()=>new S)),U=u((()=>new B)),C=BigInt(2**32-1),O=BigInt(32);function v(t,e=!1){return e?{h:Number(t&C),l:Number(t>>O&C)}:{h:0|Number(t>>O&C),l:0|Number(t&C)}}function k(t,e=!1){let s=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let r=0;rt<>>32-s,T=(t,e,s)=>e<>>32-s,D=(t,e,s)=>e<>>64-s,_=(t,e,s)=>t<>>64-s,F={fromBig:v,split:k,toBig:(t,e)=>BigInt(t>>>0)<>>0),shrSH:(t,e,s)=>t>>>s,shrSL:(t,e,s)=>t<<32-s|e>>>s,rotrSH:(t,e,s)=>t>>>s|e<<32-s,rotrSL:(t,e,s)=>t<<32-s|e>>>s,rotrBH:(t,e,s)=>t<<64-s|e>>>s-32,rotrBL:(t,e,s)=>t>>>s-32|e<<64-s,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:$,rotlSL:T,rotlBH:D,rotlBL:_,add:function(t,e,s,i){const r=(e>>>0)+(i>>>0);return{h:t+s+(r/2**32|0)|0,l:0|r}},add3L:(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),add3H:(t,e,s,i)=>e+s+i+(t/2**32|0)|0,add4L:(t,e,s,i)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0),add4H:(t,e,s,i,r)=>e+s+i+r+(t/2**32|0)|0,add5H:(t,e,s,i,r,n)=>e+s+i+r+n+(t/2**32|0)|0,add5L:(t,e,s,i,r)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0)+(r>>>0) +const E=u((()=>new S)),U=u((()=>new B)),C=BigInt(2**32-1),O=BigInt(32);function v(t,e=!1){return e?{h:Number(t&C),l:Number(t>>O&C)}:{h:0|Number(t>>O&C),l:0|Number(t&C)}}function k(t,e=!1){let s=new Uint32Array(t.length),i=new Uint32Array(t.length);for(let r=0;rt<>>32-s,$=(t,e,s)=>e<>>32-s,D=(t,e,s)=>e<>>64-s,_=(t,e,s)=>t<>>64-s,F={fromBig:v,split:k,toBig:(t,e)=>BigInt(t>>>0)<>>0),shrSH:(t,e,s)=>t>>>s,shrSL:(t,e,s)=>t<<32-s|e>>>s,rotrSH:(t,e,s)=>t>>>s|e<<32-s,rotrSL:(t,e,s)=>t<<32-s|e>>>s,rotrBH:(t,e,s)=>t<<64-s|e>>>s-32,rotrBL:(t,e,s)=>t>>>s-32|e<<64-s,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:T,rotlSL:$,rotlBH:D,rotlBL:_,add:function(t,e,s,i){const r=(e>>>0)+(i>>>0);return{h:t+s+(r/2**32|0)|0,l:0|r}},add3L:(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),add3H:(t,e,s,i)=>e+s+i+(t/2**32|0)|0,add4L:(t,e,s,i)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0),add4H:(t,e,s,i,r)=>e+s+i+r+(t/2**32|0)|0,add5H:(t,e,s,i,r,n)=>e+s+i+r+n+(t/2**32|0)|0,add5L:(t,e,s,i,r)=>(t>>>0)+(e>>>0)+(s>>>0)+(i>>>0)+(r>>>0) },[G,P]=(()=>F.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((t=>BigInt(t)))))(),j=new Uint32Array(80),M=new Uint32Array(80);class R extends w{get(){const{Ah:t,Al:e,Bh:s,Bl:i,Ch:r,Cl:n,Dh:o,Dl:h,Eh:a,El:l,Fh:c,Fl:d,Gh:u,Gl:f,Hh:b,Hl:g}=this;return[t,e,s,i,r,n,o,h,a,l,c,d,u,f,b,g]}set(t,e,s,i,r,n,o,h,a,l,c,d,u,f,b,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|s,this.Bl=0|i,this.Ch=0|r,this.Cl=0|n,this.Dh=0|o, this.Dl=0|h,this.Eh=0|a,this.El=0|l,this.Fh=0|c,this.Fl=0|d,this.Gh=0|u,this.Gl=0|f,this.Hh=0|b,this.Hl=0|g}process(t,e){for(let s=0;s<16;s++,e+=4)j[s]=t.getUint32(e),M[s]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|j[t-15],s=0|M[t-15],i=F.rotrSH(e,s,1)^F.rotrSH(e,s,8)^F.shrSH(e,s,7),r=F.rotrSL(e,s,1)^F.rotrSL(e,s,8)^F.shrSL(e,s,7),n=0|j[t-2],o=0|M[t-2],h=F.rotrSH(n,o,19)^F.rotrBH(n,o,61)^F.shrSH(n,o,6),a=F.rotrSL(n,o,19)^F.rotrBL(n,o,61)^F.shrSL(n,o,6),l=F.add4L(r,a,M[t-7],M[t-16]),c=F.add4H(l,i,h,j[t-7],j[t-16]);j[t]=0|c,M[t]=0|l}let{Ah:s,Al:i,Bh:r,Bl:n,Ch:o,Cl:h,Dh:a,Dl:l,Eh:c,El:d,Fh:u,Fl:f,Gh:b,Gl:g,Hh:p,Hl:w}=this;for(let t=0;t<80;t++){const e=F.rotrSH(c,d,14)^F.rotrSH(c,d,18)^F.rotrBH(c,d,41),y=F.rotrSL(c,d,14)^F.rotrSL(c,d,18)^F.rotrBL(c,d,41),x=c&u^~c&b,A=d&f^~d&g,H=F.add5L(w,y,A,P[t],M[t]),L=F.add5H(H,p,e,x,G[t],j[t]),m=0|H,I=F.rotrSH(s,i,28)^F.rotrBH(s,i,34)^F.rotrBH(s,i,39),S=F.rotrSL(s,i,28)^F.rotrBL(s,i,34)^F.rotrBL(s,i,39),B=s&r^s&o^r&o,E=i&n^i&h^n&h;p=0|b,w=0|g,b=0|u,g=0|f,u=0|c,f=0|d,({h:c,l:d}=F.add(0|a,0|l,0|L,0|m)),a=0|o,l=0|h,o=0|r,h=0|n,r=0|s,n=0|i;const U=F.add3L(m,S,E);s=F.add3H(U,L,I,B),i=0|U}({h:s,l:i}=F.add(0|this.Ah,0|this.Al,0|s,0|i)),({h:r,l:n}=F.add(0|this.Bh,0|this.Bl,0|r,0|n)),({h:o,l:h}=F.add(0|this.Ch,0|this.Cl,0|o,0|h)),({h:a,l}=F.add(0|this.Dh,0|this.Dl,0|a,0|l)),({h:c,l:d}=F.add(0|this.Eh,0|this.El,0|c,0|d)),({h:u,l:f}=F.add(0|this.Fh,0|this.Fl,0|u,0|f)),({h:b,l:g}=F.add(0|this.Gh,0|this.Gl,0|b,0|g)),({h:p,l:w}=F.add(0|this.Hh,0|this.Hl,0|p,0|w)),this.set(s,i,r,n,o,h,a,l,c,d,u,f,b,g,p,w)}roundClean(){j.fill(0),M.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}}class N extends R{constructor(){super(), -this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const X=u((()=>new R)),V=u((()=>new N)),Z=[],z=[],J=[],K=BigInt(0),Q=BigInt(1),W=BigInt(2),Y=BigInt(7),q=BigInt(256),tt=BigInt(113);for(let t=0,e=Q,s=1,i=0;t<24;t++){[s,i]=[i,(2*s+3*i)%5],Z.push(2*(5*i+s)),z.push((t+1)*(t+2)/2%64);let r=K;for(let t=0;t<7;t++)e=(e<>Y)*tt)%q,e&W&&(r^=Q<<(Q<s>32?D(t,e,s):$(t,e,s),rt=(t,e,s)=>s>32?_(t,e,s):T(t,e,s);class nt extends d{keccak(){a||l(this.state32),function(t,e=24){const s=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let e=0;e<10;e++)s[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const i=(e+8)%10,r=(e+2)%10,n=s[r],o=s[r+1],h=it(n,o,1)^s[i],a=rt(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)t[e+s]^=h,t[e+s+1]^=a}let e=t[2],r=t[3];for(let s=0;s<24;s++){const i=z[s],n=it(e,r,i),o=rt(e,r,i),h=Z[s];e=t[h],r=t[h+1],t[h]=n,t[h+1]=o}for(let e=0;e<50;e+=10){for(let i=0;i<10;i++)s[i]=t[e+i];for(let i=0;i<10;i++)t[e+i]^=~s[(i+2)%10]&s[(i+4)%10]}t[0]^=et[i],t[1]^=st[i]}s.fill(0)}(this.state32,this.rounds),a||l(this.state32),this.posOut=0,this.pos=0}update(t){i(this);const{blockLen:e,state:s}=this,r=(t=c(t)).length;for(let i=0;i=r&&this.keccak();const n=Math.min(r-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return t}xofInto(t){ +this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const X=u((()=>new R)),V=u((()=>new N)),Z=[],z=[],J=[],K=BigInt(0),Q=BigInt(1),W=BigInt(2),Y=BigInt(7),q=BigInt(256),tt=BigInt(113);for(let t=0,e=Q,s=1,i=0;t<24;t++){[s,i]=[i,(2*s+3*i)%5],Z.push(2*(5*i+s)),z.push((t+1)*(t+2)/2%64);let r=K;for(let t=0;t<7;t++)e=(e<>Y)*tt)%q,e&W&&(r^=Q<<(Q<s>32?D(t,e,s):T(t,e,s),rt=(t,e,s)=>s>32?_(t,e,s):$(t,e,s);class nt extends d{keccak(){a||l(this.state32),function(t,e=24){const s=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let e=0;e<10;e++)s[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const i=(e+8)%10,r=(e+2)%10,n=s[r],o=s[r+1],h=it(n,o,1)^s[i],a=rt(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)t[e+s]^=h,t[e+s+1]^=a}let e=t[2],r=t[3];for(let s=0;s<24;s++){const i=z[s],n=it(e,r,i),o=rt(e,r,i),h=Z[s];e=t[h],r=t[h+1],t[h]=n,t[h+1]=o}for(let e=0;e<50;e+=10){for(let i=0;i<10;i++)s[i]=t[e+i];for(let i=0;i<10;i++)t[e+i]^=~s[(i+2)%10]&s[(i+4)%10]}t[0]^=et[i],t[1]^=st[i]}s.fill(0)}(this.state32,this.rounds),a||l(this.state32),this.posOut=0,this.pos=0}update(t){i(this);const{blockLen:e,state:s}=this,r=(t=c(t)).length;for(let i=0;i=r&&this.keccak();const n=Math.min(r-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return t}xofInto(t){ if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return e(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(r(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return t||(t=new nt(e,s,i,n,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=s,t.outputLen=i,t.enableXOF=n,t.destroyed=this.destroyed,t}constructor(t,s,i,r=!1,n=24){if(super(),this.blockLen=t,this.suffix=s,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,e(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}}const ot=(t,e,s)=>u((()=>new nt(e,t,s))),ht=ot(6,144,28),at=ot(6,136,32),lt=ot(6,104,48),ct=ot(6,72,64),dt=(()=>{if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"__GLOBALTHIS__",{get(){return this},configurable:!0});try{if("undefined"!=typeof __GLOBALTHIS__)return __GLOBALTHIS__}finally{delete Object.prototype.__GLOBALTHIS__}return"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0})(),ut={SHA1:H,SHA224:U,SHA256:E,SHA384:V,SHA512:X,"SHA3-224":ht,"SHA3-256":at,"SHA3-384":lt,"SHA3-512":ct},ft=t=>{switch(!0){case/^(?:SHA-?1|SSL3-SHA1)$/i.test(t):return"SHA1";case/^SHA(?:2?-)?224$/i.test(t):return"SHA224";case/^SHA(?:2?-)?256$/i.test(t):return"SHA256";case/^SHA(?:2?-)?384$/i.test(t):return"SHA384";case/^SHA(?:2?-)?512$/i.test(t):return"SHA512";case/^SHA3-224$/i.test(t):return"SHA3-224";case/^SHA3-256$/i.test(t):return"SHA3-256";case/^SHA3-384$/i.test(t): return"SHA3-384";case/^SHA3-512$/i.test(t):return"SHA3-512";default:throw new TypeError(`Unknown hash algorithm: ${t}`)}},bt="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",gt=t=>{let e=(t=t.replace(/ /g,"")).length;for(;"="===t[e-1];)--e;t=(e=8&&(r-=8,i[o++]=n>>>r)}return i},pt=t=>{let e=0,s=0,i="";for(let r=0;r=5;)i+=bt[s>>>e-5&31],e-=5;return e>0&&(i+=bt[s<<5-e&31]),i},wt=t=>{t=t.replace(/ /g,"");const e=new ArrayBuffer(t.length/2),s=new Uint8Array(e);for(let e=0;e{let e="";for(let s=0;s{const e=new ArrayBuffer(t.length),s=new Uint8Array(e);for(let e=0;e{let e="";for(let s=0;s{if(!Ht)throw new Error("Encoding API not available");return Ht.encode(t)},It=t=>{if(!Lt)throw new Error("Encoding API not available");return Lt.decode(t)};class St{static fromLatin1(t){return new St({buffer:xt(t).buffer})}static fromUTF8(t){return new St({buffer:mt(t).buffer})}static fromBase32(t){return new St({buffer:gt(t).buffer})}static fromHex(t){return new St({buffer:wt(t).buffer})}get buffer(){return this.bytes.buffer}get latin1(){return Object.defineProperty(this,"latin1",{enumerable:!0,writable:!1,configurable:!1,value:At(this.bytes)}),this.latin1}get utf8(){return Object.defineProperty(this,"utf8",{enumerable:!0,writable:!1,configurable:!1,value:It(this.bytes)}),this.utf8}get base32(){return Object.defineProperty(this,"base32",{enumerable:!0,writable:!1,configurable:!1,value:pt(this.bytes)}), this.base32}get hex(){return Object.defineProperty(this,"hex",{enumerable:!0,writable:!1,configurable:!1,value:yt(this.bytes)}),this.hex}constructor({buffer:t,size:e=20}={}){this.bytes=void 0===t?(t=>{if(dt.crypto?.getRandomValues)return dt.crypto.getRandomValues(new Uint8Array(t));throw new Error("Cryptography API not available")})(e):new Uint8Array(t),Object.defineProperty(this,"bytes",{enumerable:!0,writable:!1,configurable:!1,value:this.bytes})}}class Bt{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,counter:0,window:1}}static generate({secret:t,algorithm:e=Bt.defaults.algorithm,digits:s=Bt.defaults.digits,counter:i=Bt.defaults.counter}){const r=((t,e,s)=>{if(b){const i=ut[t]??ut[ft(t)];return b(i,e,s)}throw new Error("Missing HMAC function")})(e,t.bytes,(t=>{const e=new ArrayBuffer(8),s=new Uint8Array(e);let i=t;for(let t=7;t>=0&&0!==i;t--)s[t]=255&i,i-=s[t],i/=256;return s})(i)),n=15&r[r.byteLength-1];return(((127&r[n])<<24|(255&r[n+1])<<16|(255&r[n+2])<<8|255&r[n+3])%10**s).toString().padStart(s,"0")}generate({counter:t=this.counter++}={}){return Bt.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,counter:t})}static validate({token:t,secret:e,algorithm:s,digits:i=Bt.defaults.digits,counter:r=Bt.defaults.counter,window:n=Bt.defaults.window}){if(t.length!==i)return null;let o=null;const h=n=>{const h=Bt.generate({secret:e,algorithm:s,digits:i,counter:n});((t,e)=>{{if(t.length!==e.length)throw new TypeError("Input strings must have the same length");let s=-1,i=0;for(;++s0?this.issuerInLabel?`${t(this.issuer)}:${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?`)+`secret=${t(this.secret.base32)}&`+`algorithm=${t(this.algorithm)}&`+`digits=${t(this.digits)}&`+`counter=${t(this.counter)}`}constructor({issuer:t=Bt.defaults.issuer,label:e=Bt.defaults.label,issuerInLabel:s=Bt.defaults.issuerInLabel,secret:i=new St,algorithm:r=Bt.defaults.algorithm,digits:n=Bt.defaults.digits,counter:o=Bt.defaults.counter}={}){this.issuer=t,this.label=e,this.issuerInLabel=s,this.secret="string"==typeof i?St.fromBase32(i):i,this.algorithm=ft(r),this.digits=n,this.counter=o}}class Et{static get defaults(){return{issuer:"",label:"OTPAuth",issuerInLabel:!0,algorithm:"SHA1",digits:6,period:30,window:1}}static generate({secret:t,algorithm:e,digits:s,period:i=Et.defaults.period,timestamp:r=Date.now()}){return Bt.generate({secret:t,algorithm:e,digits:s,counter:Math.floor(r/1e3/i)})}generate({timestamp:t=Date.now()}={}){return Et.generate({secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:t})}static validate({token:t,secret:e,algorithm:s,digits:i,period:r=Et.defaults.period,timestamp:n=Date.now(),window:o}){return Bt.validate({token:t,secret:e,algorithm:s,digits:i,counter:Math.floor(n/1e3/r),window:o})}validate({token:t,timestamp:e,window:s}){return Et.validate({token:t,secret:this.secret,algorithm:this.algorithm,digits:this.digits,period:this.period,timestamp:e,window:s})}toString(){const t=encodeURIComponent;return"otpauth://totp/"+(this.issuer.length>0?this.issuerInLabel?`${t(this.issuer)}:${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?issuer=${t(this.issuer)}&`:`${t(this.label)}?`)+`secret=${t(this.secret.base32)}&`+`algorithm=${t(this.algorithm)}&`+`digits=${t(this.digits)}&`+`period=${t(this.period)}`} constructor({issuer:t=Et.defaults.issuer,label:e=Et.defaults.label,issuerInLabel:s=Et.defaults.issuerInLabel,secret:i=new St,algorithm:r=Et.defaults.algorithm,digits:n=Et.defaults.digits,period:o=Et.defaults.period}={}){this.issuer=t,this.label=e,this.issuerInLabel=s,this.secret="string"==typeof i?St.fromBase32(i):i,this.algorithm=ft(r),this.digits=n,this.period=o}}const Ut=/^otpauth:\/\/([ht]otp)\/(.+)\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i,Ct=/^[2-7A-Z]+=*$/i,Ot=/^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i,vt=/^[+-]?\d+$/,kt=/^\+?[1-9]\d*$/;t.HOTP=Bt,t.Secret=St,t.TOTP=Et,t.URI=class{static parse(t){let e;try{e=t.match(Ut)}catch(t){}if(!Array.isArray(e))throw new URIError("Invalid URI format");const s=e[1].toLowerCase(),i=e[2].split(/(?::|%3A) *(.+)/i,2).map(decodeURIComponent),r=e[3].split("&").reduce(((t,e)=>{const s=e.split(/=(.*)/,2).map(decodeURIComponent),i=s[0].toLowerCase(),r=s[1],n=t;return n[i]=r,n}),{});let n;const o={};if("hotp"===s){if(n=Bt,void 0===r.counter||!vt.test(r.counter))throw new TypeError("Missing or invalid 'counter' parameter");o.counter=parseInt(r.counter,10)}else{if("totp"!==s)throw new TypeError("Unknown OTP type");if(n=Et,void 0!==r.period){if(!kt.test(r.period))throw new TypeError("Invalid 'period' parameter");o.period=parseInt(r.period,10)}}if(void 0!==r.issuer&&(o.issuer=r.issuer),2===i.length?(o.label=i[1],void 0===o.issuer||""===o.issuer?o.issuer=i[0]:""===i[0]&&(o.issuerInLabel=!1)):(o.label=i[0],void 0!==o.issuer&&""!==o.issuer&&(o.issuerInLabel=!1)),void 0===r.secret||!Ct.test(r.secret))throw new TypeError("Missing or invalid 'secret' parameter");if(o.secret=r.secret,void 0!==r.algorithm){if(!Ot.test(r.algorithm))throw new TypeError("Invalid 'algorithm' parameter");o.algorithm=r.algorithm}if(void 0!==r.digits){if(!kt.test(r.digits))throw new TypeError("Invalid 'digits' parameter");o.digits=parseInt(r.digits,10)}return new n(o)}static stringify(t){if(t instanceof Bt||t instanceof Et)return t.toString();throw new TypeError("Invalid 'HOTP/TOTP' object")} -},t.version="9.3.5"})); +},t.version="9.3.6"})); //# sourceMappingURL=otpauth.umd.min.js.map diff --git a/dist/otpauth.umd.min.js.map b/dist/otpauth.umd.min.js.map index 592ddea..9c38740 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":["../node_modules/@noble/hashes/esm/_assert.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/hashes/esm/_md.js","../node_modules/@noble/hashes/esm/sha1.js","../node_modules/@noble/hashes/esm/sha256.js","../node_modules/@noble/hashes/esm/_u64.js","../node_modules/@noble/hashes/esm/sha512.js","../node_modules/@noble/hashes/esm/sha3.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/encoding/uint.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["function number(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error(`positive integer expected, not ${n}`);\n}\nfunction bool(b) {\n if (typeof b !== 'boolean')\n throw new Error(`boolean expected, not ${b}`);\n}\n// copied from utils\nexport function isBytes(a) {\n return (a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));\n}\nfunction bytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);\n}\nfunction hash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(h.outputLen);\n number(h.blockLen);\n}\nfunction exists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction output(out, instance) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\nexport { number, bool, bytes, hash, exists, output };\nconst assert = { number, bool, bytes, hash, exists, output };\nexport default assert;\n//# sourceMappingURL=_assert.js.map","/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { bytes as abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a) {\n return (a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));\n}\n// Cast array to different type\nexport const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n// Cast array to view\nexport const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);\nexport const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\n// The byte swap operation for uint32\nexport const byteSwap = (word) => ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };\nfunction asciiToBase16(char) {\n if (char >= asciis._0 && char <= asciis._9)\n return char - asciis._0;\n if (char >= asciis._A && char <= asciis._F)\n return char - (asciis._A - 10);\n if (char >= asciis._a && char <= asciis._f)\n return char - (asciis._a - 10);\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('padded hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2;\n }\n return array;\n}\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => { };\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// For runtime check if class implements interface\nexport class Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nconst toStr = {}.toString;\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nexport function wrapConstructor(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","import { hash as assertHash, bytes as assertBytes, exists as assertExists } from './_assert.js';\nimport { Hash, toBytes } from './utils.js';\n// HMAC (RFC 2104)\nexport class HMAC extends Hash {\n constructor(hash, _key) {\n super();\n this.finished = false;\n this.destroyed = false;\n assertHash(hash);\n const key = toBytes(_key);\n this.iHash = hash.create();\n if (typeof this.iHash.update !== 'function')\n throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create();\n // Undo internal XOR && apply outer XOR\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36 ^ 0x5c;\n this.oHash.update(pad);\n pad.fill(0);\n }\n update(buf) {\n assertExists(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out) {\n assertExists(this);\n assertBytes(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to) {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to || (to = Object.create(Object.getPrototypeOf(this), {}));\n const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n to = to;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n destroy() {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */\nexport const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();\nhmac.create = (hash, key) => new HMAC(hash, key);\n//# sourceMappingURL=hmac.js.map","import { exists, output } from './_assert.js';\nimport { Hash, createView, toBytes } from './utils.js';\n/**\n * Polyfill for Safari 14\n */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/**\n * Choice: a ? b : c\n */\nexport const Chi = (a, b, c) => (a & b) ^ (~a & c);\n/**\n * Majority function, true if any two inputs is true\n */\nexport const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n exists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n exists(this);\n output(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n}\n//# sourceMappingURL=_md.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotl, wrapConstructor } from './utils.js';\n// SHA1 (RFC 3174). It was cryptographically broken: prefer newer algorithms.\n// Initial state\nconst SHA1_IV = /* @__PURE__ */ new Uint32Array([\n 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0,\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA1_W = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA1 extends HashMD {\n constructor() {\n super(64, 20, 8, false);\n this.A = SHA1_IV[0] | 0;\n this.B = SHA1_IV[1] | 0;\n this.C = SHA1_IV[2] | 0;\n this.D = SHA1_IV[3] | 0;\n this.E = SHA1_IV[4] | 0;\n }\n get() {\n const { A, B, C, D, E } = this;\n return [A, B, C, D, E];\n }\n set(A, B, C, D, E) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n SHA1_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 80; i++)\n SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);\n // Compression function main loop, 80 rounds\n let { A, B, C, D, E } = this;\n for (let i = 0; i < 80; i++) {\n let F, K;\n if (i < 20) {\n F = Chi(B, C, D);\n K = 0x5a827999;\n }\n else if (i < 40) {\n F = B ^ C ^ D;\n K = 0x6ed9eba1;\n }\n else if (i < 60) {\n F = Maj(B, C, D);\n K = 0x8f1bbcdc;\n }\n else {\n F = B ^ C ^ D;\n K = 0xca62c1d6;\n }\n const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0;\n E = D;\n D = C;\n C = rotl(B, 30);\n B = A;\n A = T;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n this.set(A, B, C, D, E);\n }\n roundClean() {\n SHA1_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n/**\n * SHA1 (RFC 3174) hash function.\n * It was cryptographically broken: prefer newer algorithms.\n * @param message - data that would be hashed\n */\nexport const sha1 = /* @__PURE__ */ wrapConstructor(() => new SHA1());\n//# sourceMappingURL=sha1.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotr, wrapConstructor } from './utils.js';\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^67 hashes/sec as per early 2023.\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\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// Initial state:\n// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD {\n constructor() {\n super(64, 32, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV[0] | 0;\n this.B = SHA256_IV[1] | 0;\n this.C = SHA256_IV[2] | 0;\n this.D = SHA256_IV[3] | 0;\n this.E = SHA256_IV[4] | 0;\n this.F = SHA256_IV[5] | 0;\n this.G = SHA256_IV[6] | 0;\n this.H = SHA256_IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n constructor() {\n super();\n this.A = 0xc1059ed8 | 0;\n this.B = 0x367cd507 | 0;\n this.C = 0x3070dd17 | 0;\n this.D = 0xf70e5939 | 0;\n this.E = 0xffc00b31 | 0;\n this.F = 0x68581511 | 0;\n this.G = 0x64f98fa7 | 0;\n this.H = 0xbefa4fa4 | 0;\n this.outputLen = 28;\n }\n}\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\n/**\n * SHA2-224 hash function\n */\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n//# sourceMappingURL=sha256.js.map","const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\n// We are not using BigUint64Array, because they are extremely slow as per 2022\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\nfunction split(lst, le = false) {\n let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for (let i = 0; i < lst.length; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// for Shift in [0, 32)\nconst shrSH = (h, _l, s) => h >>> s;\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in [1, 32)\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\n// Right rotate for shift===32 (just swaps l&h)\nconst rotr32H = (_h, l) => l;\nconst rotr32L = (h, _l) => h;\n// Left rotate for Shift in [1, 32)\nconst rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));\nconst rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));\nconst rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n// prettier-ignore\nexport { fromBig, split, toBig, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotr32H, rotr32L, rotlSH, rotlSL, rotlBH, rotlBL, add, add3L, add3H, add4L, add4H, add5H, add5L, };\n// prettier-ignore\nconst u64 = {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\nexport default u64;\n//# sourceMappingURL=_u64.js.map","import { HashMD } from './_md.js';\nimport u64 from './_u64.js';\nimport { wrapConstructor } from './utils.js';\n// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):\n// prettier-ignore\nconst [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\n// Temporary buffer, not used to store anything between runs\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA512 extends HashMD {\n constructor() {\n super(128, 64, 16, false);\n // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.\n // Also looks cleaner and easier to verify with spec.\n // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x6a09e667 | 0;\n this.Al = 0xf3bcc908 | 0;\n this.Bh = 0xbb67ae85 | 0;\n this.Bl = 0x84caa73b | 0;\n this.Ch = 0x3c6ef372 | 0;\n this.Cl = 0xfe94f82b | 0;\n this.Dh = 0xa54ff53a | 0;\n this.Dl = 0x5f1d36f1 | 0;\n this.Eh = 0x510e527f | 0;\n this.El = 0xade682d1 | 0;\n this.Fh = 0x9b05688c | 0;\n this.Fl = 0x2b3e6c1f | 0;\n this.Gh = 0x1f83d9ab | 0;\n this.Gl = 0xfb41bd6b | 0;\n this.Hh = 0x5be0cd19 | 0;\n this.Hl = 0x137e2179 | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n SHA512_W_H.fill(0);\n SHA512_W_L.fill(0);\n }\n destroy() {\n this.buffer.fill(0);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\nexport class SHA512_224 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x8c3d37c8 | 0;\n this.Al = 0x19544da2 | 0;\n this.Bh = 0x73e19966 | 0;\n this.Bl = 0x89dcd4d6 | 0;\n this.Ch = 0x1dfab7ae | 0;\n this.Cl = 0x32ff9c82 | 0;\n this.Dh = 0x679dd514 | 0;\n this.Dl = 0x582f9fcf | 0;\n this.Eh = 0x0f6d2b69 | 0;\n this.El = 0x7bd44da8 | 0;\n this.Fh = 0x77e36f73 | 0;\n this.Fl = 0x04c48942 | 0;\n this.Gh = 0x3f9d85a8 | 0;\n this.Gl = 0x6a1d36c8 | 0;\n this.Hh = 0x1112e6ad | 0;\n this.Hl = 0x91d692a1 | 0;\n this.outputLen = 28;\n }\n}\nexport class SHA512_256 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x22312194 | 0;\n this.Al = 0xfc2bf72c | 0;\n this.Bh = 0x9f555fa3 | 0;\n this.Bl = 0xc84c64c2 | 0;\n this.Ch = 0x2393b86b | 0;\n this.Cl = 0x6f53b151 | 0;\n this.Dh = 0x96387719 | 0;\n this.Dl = 0x5940eabd | 0;\n this.Eh = 0x96283ee2 | 0;\n this.El = 0xa88effe3 | 0;\n this.Fh = 0xbe5e1e25 | 0;\n this.Fl = 0x53863992 | 0;\n this.Gh = 0x2b0199fc | 0;\n this.Gl = 0x2c85b8aa | 0;\n this.Hh = 0x0eb72ddc | 0;\n this.Hl = 0x81c52ca2 | 0;\n this.outputLen = 32;\n }\n}\nexport class SHA384 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0xcbbb9d5d | 0;\n this.Al = 0xc1059ed8 | 0;\n this.Bh = 0x629a292a | 0;\n this.Bl = 0x367cd507 | 0;\n this.Ch = 0x9159015a | 0;\n this.Cl = 0x3070dd17 | 0;\n this.Dh = 0x152fecd8 | 0;\n this.Dl = 0xf70e5939 | 0;\n this.Eh = 0x67332667 | 0;\n this.El = 0xffc00b31 | 0;\n this.Fh = 0x8eb44a87 | 0;\n this.Fl = 0x68581511 | 0;\n this.Gh = 0xdb0c2e0d | 0;\n this.Gl = 0x64f98fa7 | 0;\n this.Hh = 0x47b5481d | 0;\n this.Hl = 0xbefa4fa4 | 0;\n this.outputLen = 48;\n }\n}\nexport const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());\nexport const sha512_224 = /* @__PURE__ */ wrapConstructor(() => new SHA512_224());\nexport const sha512_256 = /* @__PURE__ */ wrapConstructor(() => new SHA512_256());\nexport const sha384 = /* @__PURE__ */ wrapConstructor(() => new SHA384());\n//# sourceMappingURL=sha512.js.map","import { bytes, exists, number, output } from './_assert.js';\nimport { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';\nimport { Hash, u32, toBytes, wrapConstructor, wrapXOFConstructorWithOpts, isLE, byteSwap32, } from './utils.js';\n// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.\n// It's called a sponge function.\n// Various per round constants calculations\nconst SHA3_PI = [];\nconst SHA3_ROTL = [];\nconst _SHA3_IOTA = [];\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nconst _7n = /* @__PURE__ */ BigInt(7);\nconst _256n = /* @__PURE__ */ BigInt(256);\nconst _0x71n = /* @__PURE__ */ BigInt(0x71);\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n)\n t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n// Same as keccakf1600, but allows to skip some rounds\nexport function keccakP(s, rounds = 24) {\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++)\n B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for (let y = 0; y < 50; y += 10) {\n for (let x = 0; x < 10; x++)\n B[x] = s[y + x];\n for (let x = 0; x < 10; x++)\n s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\nexport class Keccak extends Hash {\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {\n super();\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.rounds = rounds;\n this.pos = 0;\n this.posOut = 0;\n this.finished = false;\n this.destroyed = false;\n // Can be passed from user as dkLen\n number(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n if (0 >= this.blockLen || this.blockLen >= 200)\n throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n keccak() {\n if (!isLE)\n byteSwap32(this.state32);\n keccakP(this.state32, this.rounds);\n if (!isLE)\n byteSwap32(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n exists(this);\n const { blockLen, state } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++)\n state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen)\n this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished)\n return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1)\n this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n exists(this, false);\n bytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len;) {\n if (this.posOut >= blockLen)\n this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF)\n throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes) {\n number(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n output(out, this);\n if (this.finished)\n throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest() {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy() {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to) {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nconst gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));\nexport const sha3_224 = /* @__PURE__ */ gen(0x06, 144, 224 / 8);\n/**\n * SHA3-256 hash function\n * @param message - that would be hashed\n */\nexport const sha3_256 = /* @__PURE__ */ gen(0x06, 136, 256 / 8);\nexport const sha3_384 = /* @__PURE__ */ gen(0x06, 104, 384 / 8);\nexport const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);\nexport const keccak_224 = /* @__PURE__ */ gen(0x01, 144, 224 / 8);\n/**\n * keccak-256 hash function. Different from SHA3-256.\n * @param message - that would be hashed\n */\nexport const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);\nexport const keccak_384 = /* @__PURE__ */ gen(0x01, 104, 384 / 8);\nexport const keccak_512 = /* @__PURE__ */ gen(0x01, 72, 512 / 8);\nconst genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));\nexport const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);\nexport const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);\n//# sourceMappingURL=sha3.js.map","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] !== 0) {\n num *= 256;\n num += arr[i];\n }\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["number","n","Number","isSafeInteger","Error","bytes","b","lengths","a","Uint8Array","constructor","name","length","includes","exists","instance","checkFinished","destroyed","finished","output","out","min","outputLen","createView","arr","DataView","buffer","byteOffset","byteLength","rotr","word","shift","rotl","isLE","Uint32Array","byteSwap32","i","toBytes","data","str","TextEncoder","encode","utf8ToBytes","abytes","Hash","clone","this","_cloneInto","wrapConstructor","hashCons","hashC","msg","update","digest","tmp","blockLen","create","HMAC","buf","assertExists","iHash","digestInto","assertBytes","oHash","destroy","to","Object","getPrototypeOf","hash","_key","super","h","assertHash","key","pad","set","fill","hmac","message","Chi","c","Maj","HashMD","view","len","pos","take","Math","subarray","process","dataView","roundClean","padOffset","value","setBigUint64","_32n","BigInt","_u32_max","wh","wl","l","setUint32","oview","outLen","state","get","res","slice","SHA1_IV","SHA1_W","SHA1","A","B","C","D","E","offset","getUint32","F","K","T","sha1","SHA256_K","SHA256_IV","SHA256_W","SHA256","G","H","W15","W2","s0","s1","T1","T2","SHA224","sha256","sha224","U32_MASK64","fromBig","le","split","lst","Ah","Al","rotlSH","s","rotlSL","rotlBH","rotlBL","u64","toBig","shrSH","_l","shrSL","rotrSH","rotrSL","rotrBH","rotrBL","rotr32H","_h","rotr32L","add","Bh","Bl","add3L","Cl","add3H","low","Ch","add4L","Dl","add4H","Dh","add5H","Eh","add5L","El","SHA512_Kh","SHA512_Kl","map","SHA512_W_H","SHA512_W_L","SHA512","Fh","Fl","Gh","Gl","Hh","Hl","W15h","W15l","s0h","s0l","W2h","W2l","s1h","s1l","SUMl","SUMh","sigma1h","sigma1l","CHIh","CHIl","T1ll","T1h","T1l","sigma0h","sigma0l","MAJh","MAJl","All","SHA384","sha512","sha384","SHA3_PI","SHA3_ROTL","_SHA3_IOTA","_0n","_1n","_2n","_7n","_256n","_0x71n","round","R","x","y","push","t","j","SHA3_IOTA_H","SHA3_IOTA_L","rotlH","rotlL","Keccak","keccak","state32","rounds","idx1","idx0","B0","B1","Th","Tl","curH","curL","PI","keccakP","posOut","finish","suffix","writeInto","bufferOut","xofInto","enableXOF","xof","floor","gen","sha3_224","sha3_256","sha3_384","sha3_512","globalScope","globalThis","defineProperty","prototype","configurable","__GLOBALTHIS__","self","window","global","nobleHashes","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","end","replace","substring","toUpperCase","ArrayBuffer","bits","index","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","DECODER","TextDecoder","utf8Decode","utf8Encode","decode","Secret","fromLatin1","fromUTF8","fromBase32","fromHex","latin1","enumerable","writable","utf8","base32","size","crypto","getRandomValues","randomBytes","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","hmacDigest","num","acc","uintDecode","padStart","validate","token","delta","check","generatedToken","timingSafeEqual","e","encodeURIComponent","TOTP","period","timestamp","Date","now","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp"],"mappings":";;;;+OAAA,SAASA,EAAOC,GACd,IAAKC,OAAOC,cAAcF,IAAMA,EAAI,EAAG,MAAM,IAAIG,MAAM,kCAAkCH,IAC3F,CAcA,SAASI,EAAMC,KAA8BC,GAC3C,MARsBC,EAQTF,aANEG,YACP,MAALD,GAA0B,iBAANA,GAAyC,eAAvBA,EAAEE,YAAYC,MAKtC,MAAM,IAAIP,MAAM,uBAR7B,IAAkBI,EAStB,GAAID,EAAQK,OAAS,IAAML,EAAQM,SAASP,EAAEM,QAC5C,MAAM,IAAIR,MAAM,iCAAiCG,oBAA0BD,EAAEM,SACjF,CAeA,SAASE,EAAOC,EAAeC,GAAgB,GAC7C,GAAID,EAASE,UAAW,MAAM,IAAIb,MAAM,oCACxC,GAAIY,GAAiBD,EAASG,SAAU,MAAM,IAAId,MAAM,wCAC1D,CACA,SAASe,EAAOC,EAAUL,GACxBV,EAAMe,GACN,MAAMC,EAAMN,EAASO,UACrB,GAAIF,EAAIR,OAASS,EACf,MAAM,IAAIjB,MAAM,yDAAyDiB,IAE7E,CCpBO,MAIME,EAAcC,GACzB,IAAIC,SAASD,EAAIE,OAAQF,EAAIG,WAAYH,EAAII,YAGlCC,EAAO,CAACC,EAAcC,IAAkBD,GAAS,GAAMC,EAAWD,IAASC,EAE3EC,EAAO,CAACF,EAAcC,IACjCD,GAASC,EAAUD,IAAU,GAAMC,IAAY,EAEpCE,EAAmE,KAA5D,IAAIxB,WAAW,IAAIyB,YAAY,CAAC,YAAaR,QAAQ,GAWnE,SAAUS,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ources":["../node_modules/@noble/hashes/esm/_assert.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/hashes/esm/hmac.js","../node_modules/@noble/hashes/esm/_md.js","../node_modules/@noble/hashes/esm/sha1.js","../node_modules/@noble/hashes/esm/sha256.js","../node_modules/@noble/hashes/esm/_u64.js","../node_modules/@noble/hashes/esm/sha512.js","../node_modules/@noble/hashes/esm/sha3.js","../src/internal/global-scope.js","../src/internal/crypto/hmac-digest.js","../src/internal/encoding/base32.js","../src/internal/encoding/hex.js","../src/internal/encoding/latin1.js","../src/internal/encoding/utf8.js","../src/secret.js","../src/internal/crypto/random-bytes.js","../src/hotp.js","../src/internal/encoding/uint.js","../src/internal/crypto/timing-safe-equal.js","../src/totp.js","../src/uri.js","../src/version.js"],"sourcesContent":["function anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n// copied from utils\nfunction isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\nfunction abytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\nfunction ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\nfunction aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\nfunction aoutput(out, instance) {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\nexport { anumber, anumber as number, abytes, abytes as bytes, ahash, aexists, aoutput };\nconst assert = {\n number: anumber,\n bytes: abytes,\n hash: ahash,\n exists: aexists,\n output: aoutput,\n};\nexport default assert;\n//# sourceMappingURL=_assert.js.map","/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n// Cast array to different type\nexport const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n// Cast array to view\nexport const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n// The byte swap operation for uint32\nexport const byteSwap = (word) => ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n) => n : (n) => byteSwap(n);\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => { };\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('utf8ToBytes expected string, got ' + typeof str);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// For runtime check if class implements interface\nexport class Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\nexport function wrapConstructor(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","import { ahash, abytes, aexists } from './_assert.js';\nimport { Hash, toBytes } from './utils.js';\n// HMAC (RFC 2104)\nexport class HMAC extends Hash {\n constructor(hash, _key) {\n super();\n this.finished = false;\n this.destroyed = false;\n ahash(hash);\n const key = toBytes(_key);\n this.iHash = hash.create();\n if (typeof this.iHash.update !== 'function')\n throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create();\n // Undo internal XOR && apply outer XOR\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36 ^ 0x5c;\n this.oHash.update(pad);\n pad.fill(0);\n }\n update(buf) {\n aexists(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out) {\n aexists(this);\n abytes(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to) {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to || (to = Object.create(Object.getPrototypeOf(this), {}));\n const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n to = to;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n destroy() {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */\nexport const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();\nhmac.create = (hash, key) => new HMAC(hash, key);\n//# sourceMappingURL=hmac.js.map","import { aexists, aoutput } from './_assert.js';\nimport { Hash, createView, toBytes } from './utils.js';\n/**\n * Polyfill for Safari 14\n */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/**\n * Choice: a ? b : c\n */\nexport const Chi = (a, b, c) => (a & b) ^ (~a & c);\n/**\n * Majority function, true if any two inputs is true\n */\nexport const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport class HashMD extends Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data) {\n aexists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n}\n//# sourceMappingURL=_md.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotl, wrapConstructor } from './utils.js';\n// SHA1 (RFC 3174). It was cryptographically broken: prefer newer algorithms.\n// Initial state\nconst SHA1_IV = /* @__PURE__ */ new Uint32Array([\n 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0,\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA1_W = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA1 extends HashMD {\n constructor() {\n super(64, 20, 8, false);\n this.A = SHA1_IV[0] | 0;\n this.B = SHA1_IV[1] | 0;\n this.C = SHA1_IV[2] | 0;\n this.D = SHA1_IV[3] | 0;\n this.E = SHA1_IV[4] | 0;\n }\n get() {\n const { A, B, C, D, E } = this;\n return [A, B, C, D, E];\n }\n set(A, B, C, D, E) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n }\n process(view, offset) {\n for (let i = 0; i < 16; i++, offset += 4)\n SHA1_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 80; i++)\n SHA1_W[i] = rotl(SHA1_W[i - 3] ^ SHA1_W[i - 8] ^ SHA1_W[i - 14] ^ SHA1_W[i - 16], 1);\n // Compression function main loop, 80 rounds\n let { A, B, C, D, E } = this;\n for (let i = 0; i < 80; i++) {\n let F, K;\n if (i < 20) {\n F = Chi(B, C, D);\n K = 0x5a827999;\n }\n else if (i < 40) {\n F = B ^ C ^ D;\n K = 0x6ed9eba1;\n }\n else if (i < 60) {\n F = Maj(B, C, D);\n K = 0x8f1bbcdc;\n }\n else {\n F = B ^ C ^ D;\n K = 0xca62c1d6;\n }\n const T = (rotl(A, 5) + F + E + K + SHA1_W[i]) | 0;\n E = D;\n D = C;\n C = rotl(B, 30);\n B = A;\n A = T;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n this.set(A, B, C, D, E);\n }\n roundClean() {\n SHA1_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n/**\n * SHA1 (RFC 3174) hash function.\n * It was cryptographically broken: prefer newer algorithms.\n * @param message - data that would be hashed\n */\nexport const sha1 = /* @__PURE__ */ wrapConstructor(() => new SHA1());\n//# sourceMappingURL=sha1.js.map","import { HashMD, Chi, Maj } from './_md.js';\nimport { rotr, wrapConstructor } from './utils.js';\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per late 2024.\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\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// Initial state:\n// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD {\n constructor() {\n super(64, 32, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV[0] | 0;\n this.B = SHA256_IV[1] | 0;\n this.C = SHA256_IV[2] | 0;\n this.D = SHA256_IV[3] | 0;\n this.E = SHA256_IV[4] | 0;\n this.F = SHA256_IV[5] | 0;\n this.G = SHA256_IV[6] | 0;\n this.H = SHA256_IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n constructor() {\n super();\n this.A = 0xc1059ed8 | 0;\n this.B = 0x367cd507 | 0;\n this.C = 0x3070dd17 | 0;\n this.D = 0xf70e5939 | 0;\n this.E = 0xffc00b31 | 0;\n this.F = 0x68581511 | 0;\n this.G = 0x64f98fa7 | 0;\n this.H = 0xbefa4fa4 | 0;\n this.outputLen = 28;\n }\n}\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\n/**\n * SHA2-224 hash function\n */\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n//# sourceMappingURL=sha256.js.map","const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\n// BigUint64Array is too slow as per 2024, so we implement it using Uint32Array.\n// TODO: re-check https://issues.chromium.org/issues/42212588\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\nfunction split(lst, le = false) {\n let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for (let i = 0; i < lst.length; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// for Shift in [0, 32)\nconst shrSH = (h, _l, s) => h >>> s;\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in [1, 32)\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\n// Right rotate for shift===32 (just swaps l&h)\nconst rotr32H = (_h, l) => l;\nconst rotr32L = (h, _l) => h;\n// Left rotate for Shift in [1, 32)\nconst rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));\nconst rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));\nconst rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n// prettier-ignore\nexport { fromBig, split, toBig, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotr32H, rotr32L, rotlSH, rotlSL, rotlBH, rotlBL, add, add3L, add3H, add4L, add4H, add5H, add5L, };\n// prettier-ignore\nconst u64 = {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\nexport default u64;\n//# sourceMappingURL=_u64.js.map","import { HashMD } from './_md.js';\nimport u64 from './_u64.js';\nimport { wrapConstructor } from './utils.js';\n// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):\n// prettier-ignore\nconst [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\n// Temporary buffer, not used to store anything between runs\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA512 extends HashMD {\n constructor() {\n super(128, 64, 16, false);\n // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.\n // Also looks cleaner and easier to verify with spec.\n // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x6a09e667 | 0;\n this.Al = 0xf3bcc908 | 0;\n this.Bh = 0xbb67ae85 | 0;\n this.Bl = 0x84caa73b | 0;\n this.Ch = 0x3c6ef372 | 0;\n this.Cl = 0xfe94f82b | 0;\n this.Dh = 0xa54ff53a | 0;\n this.Dl = 0x5f1d36f1 | 0;\n this.Eh = 0x510e527f | 0;\n this.El = 0xade682d1 | 0;\n this.Fh = 0x9b05688c | 0;\n this.Fl = 0x2b3e6c1f | 0;\n this.Gh = 0x1f83d9ab | 0;\n this.Gl = 0xfb41bd6b | 0;\n this.Hh = 0x5be0cd19 | 0;\n this.Hl = 0x137e2179 | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n SHA512_W_H.fill(0);\n SHA512_W_L.fill(0);\n }\n destroy() {\n this.buffer.fill(0);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\nexport class SHA512_224 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x8c3d37c8 | 0;\n this.Al = 0x19544da2 | 0;\n this.Bh = 0x73e19966 | 0;\n this.Bl = 0x89dcd4d6 | 0;\n this.Ch = 0x1dfab7ae | 0;\n this.Cl = 0x32ff9c82 | 0;\n this.Dh = 0x679dd514 | 0;\n this.Dl = 0x582f9fcf | 0;\n this.Eh = 0x0f6d2b69 | 0;\n this.El = 0x7bd44da8 | 0;\n this.Fh = 0x77e36f73 | 0;\n this.Fl = 0x04c48942 | 0;\n this.Gh = 0x3f9d85a8 | 0;\n this.Gl = 0x6a1d36c8 | 0;\n this.Hh = 0x1112e6ad | 0;\n this.Hl = 0x91d692a1 | 0;\n this.outputLen = 28;\n }\n}\nexport class SHA512_256 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x22312194 | 0;\n this.Al = 0xfc2bf72c | 0;\n this.Bh = 0x9f555fa3 | 0;\n this.Bl = 0xc84c64c2 | 0;\n this.Ch = 0x2393b86b | 0;\n this.Cl = 0x6f53b151 | 0;\n this.Dh = 0x96387719 | 0;\n this.Dl = 0x5940eabd | 0;\n this.Eh = 0x96283ee2 | 0;\n this.El = 0xa88effe3 | 0;\n this.Fh = 0xbe5e1e25 | 0;\n this.Fl = 0x53863992 | 0;\n this.Gh = 0x2b0199fc | 0;\n this.Gl = 0x2c85b8aa | 0;\n this.Hh = 0x0eb72ddc | 0;\n this.Hl = 0x81c52ca2 | 0;\n this.outputLen = 32;\n }\n}\nexport class SHA384 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0xcbbb9d5d | 0;\n this.Al = 0xc1059ed8 | 0;\n this.Bh = 0x629a292a | 0;\n this.Bl = 0x367cd507 | 0;\n this.Ch = 0x9159015a | 0;\n this.Cl = 0x3070dd17 | 0;\n this.Dh = 0x152fecd8 | 0;\n this.Dl = 0xf70e5939 | 0;\n this.Eh = 0x67332667 | 0;\n this.El = 0xffc00b31 | 0;\n this.Fh = 0x8eb44a87 | 0;\n this.Fl = 0x68581511 | 0;\n this.Gh = 0xdb0c2e0d | 0;\n this.Gl = 0x64f98fa7 | 0;\n this.Hh = 0x47b5481d | 0;\n this.Hl = 0xbefa4fa4 | 0;\n this.outputLen = 48;\n }\n}\nexport const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());\nexport const sha512_224 = /* @__PURE__ */ wrapConstructor(() => new SHA512_224());\nexport const sha512_256 = /* @__PURE__ */ wrapConstructor(() => new SHA512_256());\nexport const sha384 = /* @__PURE__ */ wrapConstructor(() => new SHA384());\n//# sourceMappingURL=sha512.js.map","import { abytes, aexists, anumber, aoutput } from './_assert.js';\nimport { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';\nimport { Hash, u32, toBytes, wrapConstructor, wrapXOFConstructorWithOpts, isLE, byteSwap32, } from './utils.js';\n// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size.\n// It's called a sponge function.\n// Various per round constants calculations\nconst SHA3_PI = [];\nconst SHA3_ROTL = [];\nconst _SHA3_IOTA = [];\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nconst _7n = /* @__PURE__ */ BigInt(7);\nconst _256n = /* @__PURE__ */ BigInt(256);\nconst _0x71n = /* @__PURE__ */ BigInt(0x71);\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n)\n t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n// Same as keccakf1600, but allows to skip some rounds\nexport function keccakP(s, rounds = 24) {\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++)\n B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for (let y = 0; y < 50; y += 10) {\n for (let x = 0; x < 10; x++)\n B[x] = s[y + x];\n for (let x = 0; x < 10; x++)\n s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\nexport class Keccak extends Hash {\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {\n super();\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.rounds = rounds;\n this.pos = 0;\n this.posOut = 0;\n this.finished = false;\n this.destroyed = false;\n // Can be passed from user as dkLen\n anumber(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n if (0 >= this.blockLen || this.blockLen >= 200)\n throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n keccak() {\n if (!isLE)\n byteSwap32(this.state32);\n keccakP(this.state32, this.rounds);\n if (!isLE)\n byteSwap32(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n aexists(this);\n const { blockLen, state } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++)\n state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen)\n this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished)\n return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1)\n this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n aexists(this, false);\n abytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len;) {\n if (this.posOut >= blockLen)\n this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF)\n throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes) {\n anumber(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n aoutput(out, this);\n if (this.finished)\n throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest() {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy() {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to) {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nconst gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));\nexport const sha3_224 = /* @__PURE__ */ gen(0x06, 144, 224 / 8);\n/**\n * SHA3-256 hash function\n * @param message - that would be hashed\n */\nexport const sha3_256 = /* @__PURE__ */ gen(0x06, 136, 256 / 8);\nexport const sha3_384 = /* @__PURE__ */ gen(0x06, 104, 384 / 8);\nexport const sha3_512 = /* @__PURE__ */ gen(0x06, 72, 512 / 8);\nexport const keccak_224 = /* @__PURE__ */ gen(0x01, 144, 224 / 8);\n/**\n * keccak-256 hash function. Different from SHA3-256.\n * @param message - that would be hashed\n */\nexport const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8);\nexport const keccak_384 = /* @__PURE__ */ gen(0x01, 104, 384 / 8);\nexport const keccak_512 = /* @__PURE__ */ gen(0x01, 72, 512 / 8);\nconst genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));\nexport const shake128 = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);\nexport const shake256 = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);\n//# sourceMappingURL=sha3.js.map","/**\n * \"globalThis\" ponyfill.\n * @see [A horrifying globalThis polyfill in universal JavaScript](https://mathiasbynens.be/notes/globalthis)\n * @type {Object.}\n */\nconst globalScope = (() => {\n if (typeof globalThis === \"object\") return globalThis;\n else {\n Object.defineProperty(Object.prototype, \"__GLOBALTHIS__\", {\n get() {\n return this;\n },\n configurable: true,\n });\n try {\n // @ts-expect-error\n // eslint-disable-next-line no-undef\n if (typeof __GLOBALTHIS__ !== \"undefined\") return __GLOBALTHIS__;\n } finally {\n // @ts-expect-error\n delete Object.prototype.__GLOBALTHIS__;\n }\n }\n\n // Still unable to determine \"globalThis\", fall back to a naive method.\n if (typeof self !== \"undefined\") return self;\n else if (typeof window !== \"undefined\") return window;\n else if (typeof global !== \"undefined\") return global;\n\n return undefined;\n})();\n\nexport { globalScope };\n","import * as crypto from \"node:crypto\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha1 } from \"@noble/hashes/sha1\";\nimport { sha224, sha256, sha384, sha512 } from \"@noble/hashes/sha2\";\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3\";\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * @noble/hashes hash functions.\n * @type {Object.}\n */\nconst nobleHashes = {\n SHA1: sha1,\n SHA224: sha224,\n SHA256: sha256,\n SHA384: sha384,\n SHA512: sha512,\n \"SHA3-224\": sha3_224,\n \"SHA3-256\": sha3_256,\n \"SHA3-384\": sha3_384,\n \"SHA3-512\": sha3_512,\n};\n\n/**\n * Canonicalizes a hash algorithm name.\n * @param {string} algorithm Hash algorithm name.\n * @returns {\"SHA1\"|\"SHA224\"|\"SHA256\"|\"SHA384\"|\"SHA512\"|\"SHA3-224\"|\"SHA3-256\"|\"SHA3-384\"|\"SHA3-512\"} Canonicalized hash algorithm name.\n */\nconst canonicalizeAlgorithm = (algorithm) => {\n switch (true) {\n case /^(?:SHA-?1|SSL3-SHA1)$/i.test(algorithm):\n return \"SHA1\";\n case /^SHA(?:2?-)?224$/i.test(algorithm):\n return \"SHA224\";\n case /^SHA(?:2?-)?256$/i.test(algorithm):\n return \"SHA256\";\n case /^SHA(?:2?-)?384$/i.test(algorithm):\n return \"SHA384\";\n case /^SHA(?:2?-)?512$/i.test(algorithm):\n return \"SHA512\";\n case /^SHA3-224$/i.test(algorithm):\n return \"SHA3-224\";\n case /^SHA3-256$/i.test(algorithm):\n return \"SHA3-256\";\n case /^SHA3-384$/i.test(algorithm):\n return \"SHA3-384\";\n case /^SHA3-512$/i.test(algorithm):\n return \"SHA3-512\";\n default:\n throw new TypeError(`Unknown hash algorithm: ${algorithm}`);\n }\n};\n\n/**\n * Calculates an HMAC digest.\n * @param {string} algorithm Algorithm.\n * @param {Uint8Array} key Key.\n * @param {Uint8Array} message Message.\n * @returns {Uint8Array} Digest.\n */\nconst hmacDigest = (algorithm, key, message) => {\n if (crypto?.createHmac) {\n const hmac = crypto.createHmac(algorithm, globalScope.Buffer.from(key));\n hmac.update(globalScope.Buffer.from(message));\n return hmac.digest();\n } else if (hmac) {\n const hash = nobleHashes[algorithm] ?? nobleHashes[canonicalizeAlgorithm(algorithm)];\n return hmac(hash, key, message);\n } else {\n throw new Error(\"Missing HMAC function\");\n }\n};\n\nexport { canonicalizeAlgorithm, hmacDigest };\n","/**\n * RFC 4648 base32 alphabet without pad.\n * @type {string}\n */\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\";\n\n/**\n * Converts a base32 string to an Uint8Array (RFC 4648).\n * @see [LinusU/base32-decode](https://github.com/LinusU/base32-decode)\n * @param {string} str Base32 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst base32Decode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n // Canonicalize to all upper case and remove padding if it exists.\n let end = str.length;\n while (str[end - 1] === \"=\") --end;\n str = (end < str.length ? str.substring(0, end) : str).toUpperCase();\n\n const buf = new ArrayBuffer(((str.length * 5) / 8) | 0);\n const arr = new Uint8Array(buf);\n let bits = 0;\n let value = 0;\n let index = 0;\n\n for (let i = 0; i < str.length; i++) {\n const idx = ALPHABET.indexOf(str[i]);\n if (idx === -1) throw new TypeError(`Invalid character found: ${str[i]}`);\n\n value = (value << 5) | idx;\n bits += 5;\n\n if (bits >= 8) {\n bits -= 8;\n arr[index++] = value >>> bits;\n }\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a base32 string (RFC 4648).\n * @see [LinusU/base32-encode](https://github.com/LinusU/base32-encode)\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Base32 string.\n */\nconst base32Encode = (arr) => {\n let bits = 0;\n let value = 0;\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n value = (value << 8) | arr[i];\n bits += 8;\n\n while (bits >= 5) {\n str += ALPHABET[(value >>> (bits - 5)) & 31];\n bits -= 5;\n }\n }\n\n if (bits > 0) {\n str += ALPHABET[(value << (5 - bits)) & 31];\n }\n\n return str;\n};\n\nexport { base32Decode, base32Encode };\n","/**\n * Converts a hexadecimal string to an Uint8Array.\n * @param {string} str Hexadecimal string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst hexDecode = (str) => {\n // Remove spaces (although they are not allowed by the spec, some issuers add them for readability).\n str = str.replace(/ /g, \"\");\n\n const buf = new ArrayBuffer(str.length / 2);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i += 2) {\n arr[i / 2] = parseInt(str.substring(i, i + 2), 16);\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a hexadecimal string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Hexadecimal string.\n */\nconst hexEncode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n const hex = arr[i].toString(16);\n if (hex.length === 1) str += \"0\";\n str += hex;\n }\n\n return str.toUpperCase();\n};\n\nexport { hexDecode, hexEncode };\n","/**\n * Converts a Latin-1 string to an Uint8Array.\n * @param {string} str Latin-1 string.\n * @returns {Uint8Array} Uint8Array.\n */\nconst latin1Decode = (str) => {\n const buf = new ArrayBuffer(str.length);\n const arr = new Uint8Array(buf);\n\n for (let i = 0; i < str.length; i++) {\n arr[i] = str.charCodeAt(i) & 0xff;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to a Latin-1 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} Latin-1 string.\n */\nconst latin1Encode = (arr) => {\n let str = \"\";\n\n for (let i = 0; i < arr.length; i++) {\n str += String.fromCharCode(arr[i]);\n }\n\n return str;\n};\n\nexport { latin1Decode, latin1Encode };\n","import { globalScope } from \"../global-scope.js\";\n\n/**\n * TextEncoder instance.\n * @type {TextEncoder|null}\n */\nconst ENCODER = globalScope.TextEncoder ? new globalScope.TextEncoder() : null;\n\n/**\n * TextDecoder instance.\n * @type {TextDecoder|null}\n */\nconst DECODER = globalScope.TextDecoder ? new globalScope.TextDecoder() : null;\n\n/**\n * Converts an UTF-8 string to an Uint8Array.\n * @param {string} str String.\n * @returns {Uint8Array} Uint8Array.\n */\nconst utf8Decode = (str) => {\n if (!ENCODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return ENCODER.encode(str);\n};\n\n/**\n * Converts an Uint8Array to an UTF-8 string.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {string} String.\n */\nconst utf8Encode = (arr) => {\n if (!DECODER) {\n throw new Error(\"Encoding API not available\");\n }\n\n return DECODER.decode(arr);\n};\n\nexport { utf8Decode, utf8Encode };\n","import { base32Decode, base32Encode } from \"./internal/encoding/base32.js\";\nimport { hexDecode, hexEncode } from \"./internal/encoding/hex.js\";\nimport { latin1Decode, latin1Encode } from \"./internal/encoding/latin1.js\";\nimport { utf8Decode, utf8Encode } from \"./internal/encoding/utf8.js\";\nimport { randomBytes } from \"./internal/crypto/random-bytes.js\";\n\n/**\n * OTP secret key.\n */\nclass Secret {\n /**\n * Creates a secret key object.\n * @param {Object} [config] Configuration options.\n * @param {ArrayBufferLike} [config.buffer] Secret key buffer.\n * @param {number} [config.size=20] Number of random bytes to generate, ignored if 'buffer' is provided.\n */\n constructor({ buffer, size = 20 } = {}) {\n /**\n * Secret key.\n * @type {Uint8Array}\n * @readonly\n */\n this.bytes = typeof buffer === \"undefined\" ? randomBytes(size) : new Uint8Array(buffer);\n\n // Prevent the \"bytes\" property from being modified.\n Object.defineProperty(this, \"bytes\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: this.bytes,\n });\n }\n\n /**\n * Converts a Latin-1 string to a Secret object.\n * @param {string} str Latin-1 string.\n * @returns {Secret} Secret object.\n */\n static fromLatin1(str) {\n return new Secret({ buffer: latin1Decode(str).buffer });\n }\n\n /**\n * Converts an UTF-8 string to a Secret object.\n * @param {string} str UTF-8 string.\n * @returns {Secret} Secret object.\n */\n static fromUTF8(str) {\n return new Secret({ buffer: utf8Decode(str).buffer });\n }\n\n /**\n * Converts a base32 string to a Secret object.\n * @param {string} str Base32 string.\n * @returns {Secret} Secret object.\n */\n static fromBase32(str) {\n return new Secret({ buffer: base32Decode(str).buffer });\n }\n\n /**\n * Converts a hexadecimal string to a Secret object.\n * @param {string} str Hexadecimal string.\n * @returns {Secret} Secret object.\n */\n static fromHex(str) {\n return new Secret({ buffer: hexDecode(str).buffer });\n }\n\n /**\n * Secret key buffer.\n * @deprecated For backward compatibility, the \"bytes\" property should be used instead.\n * @type {ArrayBufferLike}\n */\n get buffer() {\n return this.bytes.buffer;\n }\n\n /**\n * Latin-1 string representation of secret key.\n * @type {string}\n */\n get latin1() {\n Object.defineProperty(this, \"latin1\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: latin1Encode(this.bytes),\n });\n\n return this.latin1;\n }\n\n /**\n * UTF-8 string representation of secret key.\n * @type {string}\n */\n get utf8() {\n Object.defineProperty(this, \"utf8\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: utf8Encode(this.bytes),\n });\n\n return this.utf8;\n }\n\n /**\n * Base32 string representation of secret key.\n * @type {string}\n */\n get base32() {\n Object.defineProperty(this, \"base32\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: base32Encode(this.bytes),\n });\n\n return this.base32;\n }\n\n /**\n * Hexadecimal string representation of secret key.\n * @type {string}\n */\n get hex() {\n Object.defineProperty(this, \"hex\", {\n enumerable: true,\n writable: false,\n configurable: false,\n value: hexEncode(this.bytes),\n });\n\n return this.hex;\n }\n}\n\nexport { Secret };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns random bytes.\n * @param {number} size Size.\n * @returns {Uint8Array} Random bytes.\n */\nconst randomBytes = (size) => {\n if (crypto?.randomBytes) {\n return crypto.randomBytes(size);\n } else if (globalScope.crypto?.getRandomValues) {\n return globalScope.crypto.getRandomValues(new Uint8Array(size));\n } else {\n throw new Error(\"Cryptography API not available\");\n }\n};\n\nexport { randomBytes };\n","import { uintDecode } from \"./internal/encoding/uint.js\";\nimport { canonicalizeAlgorithm, hmacDigest } from \"./internal/crypto/hmac-digest.js\";\nimport { Secret } from \"./secret.js\";\nimport { timingSafeEqual } from \"./internal/crypto/timing-safe-equal.js\";\n\n/**\n * HOTP: An HMAC-based One-time Password Algorithm.\n * @see [RFC 4226](https://datatracker.ietf.org/doc/html/rfc4226)\n */\nclass HOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * counter: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n counter: 0,\n window: 1,\n };\n }\n\n /**\n * Creates an HOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Initial counter value.\n */\n constructor({\n issuer = HOTP.defaults.issuer,\n label = HOTP.defaults.label,\n issuerInLabel = HOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Initial counter value.\n * @type {number}\n */\n this.counter = counter;\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @returns {string} Token.\n */\n static generate({\n secret,\n algorithm = HOTP.defaults.algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n }) {\n const digest = hmacDigest(algorithm, secret.bytes, uintDecode(counter));\n const offset = digest[digest.byteLength - 1] & 15;\n const otp =\n (((digest[offset] & 127) << 24) |\n ((digest[offset + 1] & 255) << 16) |\n ((digest[offset + 2] & 255) << 8) |\n (digest[offset + 3] & 255)) %\n 10 ** digits;\n\n return otp.toString().padStart(digits, \"0\");\n }\n\n /**\n * Generates an HOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.counter=this.counter++] Counter value.\n * @returns {string} Token.\n */\n generate({ counter = this.counter++ } = {}) {\n return HOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n });\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.counter=0] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({\n token,\n secret,\n algorithm,\n digits = HOTP.defaults.digits,\n counter = HOTP.defaults.counter,\n window = HOTP.defaults.window,\n }) {\n // Return early if the token length does not match the digit number.\n if (token.length !== digits) return null;\n\n let delta = null;\n\n const check = (/** @type {number} */ i) => {\n const generatedToken = HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: i,\n });\n if (timingSafeEqual(token, generatedToken)) {\n delta = i - counter;\n }\n };\n\n check(counter);\n for (let i = 1; i <= window && delta === null; ++i) {\n check(counter - i);\n if (delta !== null) break;\n check(counter + i);\n if (delta !== null) break;\n }\n\n return delta;\n }\n\n /**\n * Validates an HOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.counter=this.counter] Counter value.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, counter = this.counter, window }) {\n return HOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n counter,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://hotp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `counter=${e(this.counter)}`\n );\n }\n}\n\nexport { HOTP };\n","/**\n * Converts an integer to an Uint8Array.\n * @param {number} num Integer.\n * @returns {Uint8Array} Uint8Array.\n */\nconst uintDecode = (num) => {\n const buf = new ArrayBuffer(8);\n const arr = new Uint8Array(buf);\n let acc = num;\n\n for (let i = 7; i >= 0; i--) {\n if (acc === 0) break;\n arr[i] = acc & 255;\n acc -= arr[i];\n acc /= 256;\n }\n\n return arr;\n};\n\n/**\n * Converts an Uint8Array to an integer.\n * @param {Uint8Array} arr Uint8Array.\n * @returns {number} Integer.\n */\nconst uintEncode = (arr) => {\n let num = 0;\n\n for (let i = 0; i < arr.length; i++) {\n num *= 256;\n num += arr[i];\n }\n\n return num;\n};\n\nexport { uintDecode, uintEncode };\n","import * as crypto from \"node:crypto\";\n\nimport { globalScope } from \"../global-scope.js\";\n\n/**\n * Returns true if a is equal to b, without leaking timing information that would allow an attacker to guess one of the values.\n * @param {string} a String a.\n * @param {string} b String b.\n * @returns {boolean} Equality result.\n */\nconst timingSafeEqual = (a, b) => {\n if (crypto?.timingSafeEqual) {\n return crypto.timingSafeEqual(globalScope.Buffer.from(a), globalScope.Buffer.from(b));\n } else {\n if (a.length !== b.length) {\n throw new TypeError(\"Input strings must have the same length\");\n }\n let i = -1;\n let out = 0;\n while (++i < a.length) {\n out |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return out === 0;\n }\n};\n\nexport { timingSafeEqual };\n","import { canonicalizeAlgorithm } from \"./internal/crypto/hmac-digest.js\";\nimport { HOTP } from \"./hotp.js\";\nimport { Secret } from \"./secret.js\";\n\n/**\n * TOTP: Time-Based One-Time Password Algorithm.\n * @see [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n */\nclass TOTP {\n /**\n * Default configuration.\n * @type {{\n * issuer: string,\n * label: string,\n * issuerInLabel: boolean,\n * algorithm: string,\n * digits: number,\n * period: number\n * window: number\n * }}\n */\n static get defaults() {\n return {\n issuer: \"\",\n label: \"OTPAuth\",\n issuerInLabel: true,\n algorithm: \"SHA1\",\n digits: 6,\n period: 30,\n window: 1,\n };\n }\n\n /**\n * Creates a TOTP object.\n * @param {Object} [config] Configuration options.\n * @param {string} [config.issuer=''] Account provider.\n * @param {string} [config.label='OTPAuth'] Account label.\n * @param {boolean} [config.issuerInLabel=true] Include issuer prefix in label.\n * @param {Secret|string} [config.secret=Secret] Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n */\n constructor({\n issuer = TOTP.defaults.issuer,\n label = TOTP.defaults.label,\n issuerInLabel = TOTP.defaults.issuerInLabel,\n secret = new Secret(),\n algorithm = TOTP.defaults.algorithm,\n digits = TOTP.defaults.digits,\n period = TOTP.defaults.period,\n } = {}) {\n /**\n * Account provider.\n * @type {string}\n */\n this.issuer = issuer;\n /**\n * Account label.\n * @type {string}\n */\n this.label = label;\n /**\n * Include issuer prefix in label.\n * @type {boolean}\n */\n this.issuerInLabel = issuerInLabel;\n /**\n * Secret key.\n * @type {Secret}\n */\n this.secret = typeof secret === \"string\" ? Secret.fromBase32(secret) : secret;\n /**\n * HMAC hashing algorithm.\n * @type {string}\n */\n this.algorithm = canonicalizeAlgorithm(algorithm);\n /**\n * Token length.\n * @type {number}\n */\n this.digits = digits;\n /**\n * Token time-step duration.\n * @type {number}\n */\n this.period = period;\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n static generate({ secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now() }) {\n return HOTP.generate({\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n });\n }\n\n /**\n * Generates a TOTP token.\n * @param {Object} [config] Configuration options.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @returns {string} Token.\n */\n generate({ timestamp = Date.now() } = {}) {\n return TOTP.generate({\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {Secret} config.secret Secret key.\n * @param {string} [config.algorithm='SHA1'] HMAC hashing algorithm.\n * @param {number} [config.digits=6] Token length.\n * @param {number} [config.period=30] Token time-step duration.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n static validate({ token, secret, algorithm, digits, period = TOTP.defaults.period, timestamp = Date.now(), window }) {\n return HOTP.validate({\n token,\n secret,\n algorithm,\n digits,\n counter: Math.floor(timestamp / 1000 / period),\n window,\n });\n }\n\n /**\n * Validates a TOTP token.\n * @param {Object} config Configuration options.\n * @param {string} config.token Token value.\n * @param {number} [config.timestamp=Date.now] Timestamp value in milliseconds.\n * @param {number} [config.window=1] Window of counter values to test.\n * @returns {number|null} Token delta or null if it is not found in the search window, in which case it should be considered invalid.\n */\n validate({ token, timestamp, window }) {\n return TOTP.validate({\n token,\n secret: this.secret,\n algorithm: this.algorithm,\n digits: this.digits,\n period: this.period,\n timestamp,\n window,\n });\n }\n\n /**\n * Returns a Google Authenticator key URI.\n * @returns {string} URI.\n */\n toString() {\n const e = encodeURIComponent;\n return (\n \"otpauth://totp/\" +\n `${\n this.issuer.length > 0\n ? this.issuerInLabel\n ? `${e(this.issuer)}:${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?issuer=${e(this.issuer)}&`\n : `${e(this.label)}?`\n }` +\n `secret=${e(this.secret.base32)}&` +\n `algorithm=${e(this.algorithm)}&` +\n `digits=${e(this.digits)}&` +\n `period=${e(this.period)}`\n );\n }\n}\n\nexport { TOTP };\n","import { HOTP } from \"./hotp.js\";\nimport { TOTP } from \"./totp.js\";\n\n/**\n * Key URI regex (otpauth://TYPE/[ISSUER:]LABEL?PARAMETERS).\n * @type {RegExp}\n */\nconst OTPURI_REGEX = /^otpauth:\\/\\/([ht]otp)\\/(.+)\\?([A-Z0-9.~_-]+=[^?&]*(?:&[A-Z0-9.~_-]+=[^?&]*)*)$/i;\n\n/**\n * RFC 4648 base32 alphabet with pad.\n * @type {RegExp}\n */\nconst SECRET_REGEX = /^[2-7A-Z]+=*$/i;\n\n/**\n * Regex for supported algorithms.\n * @type {RegExp}\n */\nconst ALGORITHM_REGEX = /^SHA(?:1|224|256|384|512|3-224|3-256|3-384|3-512)$/i;\n\n/**\n * Integer regex.\n * @type {RegExp}\n */\nconst INTEGER_REGEX = /^[+-]?\\d+$/;\n\n/**\n * Positive integer regex.\n * @type {RegExp}\n */\nconst POSITIVE_INTEGER_REGEX = /^\\+?[1-9]\\d*$/;\n\n/**\n * HOTP/TOTP object/string conversion.\n * @see [Key URI Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format)\n */\nclass URI {\n /**\n * Parses a Google Authenticator key URI and returns an HOTP/TOTP object.\n * @param {string} uri Google Authenticator Key URI.\n * @returns {HOTP|TOTP} HOTP/TOTP object.\n */\n static parse(uri) {\n let uriGroups;\n\n try {\n uriGroups = uri.match(OTPURI_REGEX);\n // eslint-disable-next-line no-unused-vars\n } catch (_) {\n /* Handled below */\n }\n\n if (!Array.isArray(uriGroups)) {\n throw new URIError(\"Invalid URI format\");\n }\n\n // Extract URI groups.\n const uriType = uriGroups[1].toLowerCase();\n const uriLabel = uriGroups[2].split(/(?::|%3A) *(.+)/i, 2).map(decodeURIComponent);\n /** @type {Object.} */\n const uriParams = uriGroups[3].split(\"&\").reduce((acc, cur) => {\n const pairArr = cur.split(/=(.*)/, 2).map(decodeURIComponent);\n const pairKey = pairArr[0].toLowerCase();\n const pairVal = pairArr[1];\n /** @type {Object.} */\n const pairAcc = acc;\n\n pairAcc[pairKey] = pairVal;\n return pairAcc;\n }, {});\n\n // 'OTP' will be instantiated with 'config' argument.\n let OTP;\n const config = {};\n\n if (uriType === \"hotp\") {\n OTP = HOTP;\n\n // Counter: required\n if (typeof uriParams.counter !== \"undefined\" && INTEGER_REGEX.test(uriParams.counter)) {\n config.counter = parseInt(uriParams.counter, 10);\n } else {\n throw new TypeError(\"Missing or invalid 'counter' parameter\");\n }\n } else if (uriType === \"totp\") {\n OTP = TOTP;\n\n // Period: optional\n if (typeof uriParams.period !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.period)) {\n config.period = parseInt(uriParams.period, 10);\n } else {\n throw new TypeError(\"Invalid 'period' parameter\");\n }\n }\n } else {\n throw new TypeError(\"Unknown OTP type\");\n }\n\n // Label: required\n // Issuer: optional\n if (typeof uriParams.issuer !== \"undefined\") {\n config.issuer = uriParams.issuer;\n }\n if (uriLabel.length === 2) {\n config.label = uriLabel[1];\n if (typeof config.issuer === \"undefined\" || config.issuer === \"\") {\n config.issuer = uriLabel[0];\n } else if (uriLabel[0] === \"\") {\n config.issuerInLabel = false;\n }\n } else {\n config.label = uriLabel[0];\n if (typeof config.issuer !== \"undefined\" && config.issuer !== \"\") {\n config.issuerInLabel = false;\n }\n }\n\n // Secret: required\n if (typeof uriParams.secret !== \"undefined\" && SECRET_REGEX.test(uriParams.secret)) {\n config.secret = uriParams.secret;\n } else {\n throw new TypeError(\"Missing or invalid 'secret' parameter\");\n }\n\n // Algorithm: optional\n if (typeof uriParams.algorithm !== \"undefined\") {\n if (ALGORITHM_REGEX.test(uriParams.algorithm)) {\n config.algorithm = uriParams.algorithm;\n } else {\n throw new TypeError(\"Invalid 'algorithm' parameter\");\n }\n }\n\n // Digits: optional\n if (typeof uriParams.digits !== \"undefined\") {\n if (POSITIVE_INTEGER_REGEX.test(uriParams.digits)) {\n config.digits = parseInt(uriParams.digits, 10);\n } else {\n throw new TypeError(\"Invalid 'digits' parameter\");\n }\n }\n\n return new OTP(config);\n }\n\n /**\n * Converts an HOTP/TOTP object to a Google Authenticator key URI.\n * @param {HOTP|TOTP} otp HOTP/TOTP object.\n * @returns {string} Google Authenticator Key URI.\n */\n static stringify(otp) {\n if (otp instanceof HOTP || otp instanceof TOTP) {\n return otp.toString();\n }\n\n throw new TypeError(\"Invalid 'HOTP/TOTP' object\");\n }\n}\n\nexport { URI };\n","/**\n * Library version.\n * @type {string}\n */\nconst version = \"__OTPAUTH_VERSION__\";\n\nexport { version };\n"],"names":["anumber","n","Number","isSafeInteger","Error","abytes","b","lengths","a","Uint8Array","ArrayBuffer","isView","constructor","name","length","includes","aexists","instance","checkFinished","destroyed","finished","aoutput","out","min","outputLen","createView","arr","DataView","buffer","byteOffset","byteLength","rotr","word","shift","rotl","isLE","Uint32Array","byteSwap32","i","toBytes","data","str","TextEncoder","encode","utf8ToBytes","Hash","clone","this","_cloneInto","wrapConstructor","hashCons","hashC","msg","update","digest","tmp","blockLen","create","HMAC","buf","iHash","digestInto","oHash","destroy","to","Object","getPrototypeOf","hash","_key","super","h","ahash","key","pad","set","fill","hmac","message","Chi","c","Maj","HashMD","view","len","pos","take","Math","subarray","process","dataView","roundClean","padOffset","value","setBigUint64","_32n","BigInt","_u32_max","wh","wl","l","setUint32","oview","outLen","state","get","res","slice","SHA1_IV","SHA1_W","SHA1","A","B","C","D","E","offset","getUint32","F","K","T","sha1","SHA256_K","SHA256_IV","SHA256_W","SHA256","G","H","W15","W2","s0","s1","T1","T2","SHA224","sha256","sha224","U32_MASK64","fromBig","le","split","lst","Ah","Al","rotlSH","s","rotlSL","rotlBH","rotlBL","u64","toBig","shrSH","_l","shrSL","rotrSH","rotrSL","rotrBH","rotrBL","rotr32H","_h","rotr32L","add","Bh","Bl","add3L","Cl","add3H","low","Ch","add4L","Dl","add4H","Dh","add5H","Eh","add5L","El","SHA512_Kh","SHA512_Kl","map","SHA512_W_H","SHA512_W_L","SHA512","Fh","Fl","Gh","Gl","Hh","Hl","W15h","W15l","s0h","s0l","W2h","W2l","s1h","s1l","SUMl","SUMh","sigma1h","sigma1l","CHIh","CHIl","T1ll","T1h","T1l","sigma0h","sigma0l","MAJh","MAJl","All","SHA384","sha512","sha384","SHA3_PI","SHA3_ROTL","_SHA3_IOTA","_0n","_1n","_2n","_7n","_256n","_0x71n","round","R","x","y","push","t","j","SHA3_IOTA_H","SHA3_IOTA_L","rotlH","rotlL","Keccak","keccak","state32","rounds","idx1","idx0","B0","B1","Th","Tl","curH","curL","PI","keccakP","posOut","finish","suffix","writeInto","bufferOut","xofInto","enableXOF","xof","bytes","floor","gen","sha3_224","sha3_256","sha3_384","sha3_512","globalScope","globalThis","defineProperty","prototype","configurable","__GLOBALTHIS__","self","window","global","nobleHashes","canonicalizeAlgorithm","algorithm","test","TypeError","ALPHABET","base32Decode","end","replace","substring","toUpperCase","bits","index","idx","indexOf","base32Encode","hexDecode","parseInt","hexEncode","hex","toString","latin1Decode","charCodeAt","latin1Encode","String","fromCharCode","ENCODER","DECODER","TextDecoder","utf8Decode","utf8Encode","decode","Secret","fromLatin1","fromUTF8","fromBase32","fromHex","latin1","enumerable","writable","utf8","base32","size","crypto","getRandomValues","randomBytes","HOTP","defaults","issuer","label","issuerInLabel","digits","counter","generate","secret","hmacDigest","num","acc","uintDecode","padStart","validate","token","delta","check","generatedToken","timingSafeEqual","e","encodeURIComponent","TOTP","period","timestamp","Date","now","OTPURI_REGEX","SECRET_REGEX","ALGORITHM_REGEX","INTEGER_REGEX","POSITIVE_INTEGER_REGEX","parse","uri","uriGroups","match","_","Array","isArray","URIError","uriType","toLowerCase","uriLabel","decodeURIComponent","uriParams","reduce","cur","pairArr","pairKey","pairVal","pairAcc","OTP","config","stringify","otp"],"mappings":";;;;+OAAA,SAASA,EAAQC,GACf,IAAKC,OAAOC,cAAcF,IAAMA,EAAI,EAAG,MAAM,IAAIG,MAAM,kCAAoCH,EAC7F,CAOA,SAASI,EAAOC,KAA8BC,GAC5C,MALeC,EAKFF,aAJOG,YAAcC,YAAaC,OAAOH,IAA6B,eAAvBA,EAAEI,YAAYC,MAIzD,MAAM,IAAIT,MAAM,uBALnC,IAAiBI,EAMf,GAAID,EAAQO,OAAS,IAAMP,EAAQQ,SAAST,EAAEQ,QAC5C,MAAM,IAAIV,MAAM,iCAAmCG,EAAU,gBAAkBD,EAAEQ,OACrF,CAeA,SAASE,EAAQC,EAAeC,GAAgB,GAC9C,GAAID,EAASE,UAAW,MAAM,IAAIf,MAAM,oCACxC,GAAIc,GAAiBD,EAASG,SAAU,MAAM,IAAIhB,MAAM,wCAC1D,CACA,SAAS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SAIjC,CAGA,QAAgC,IAArBwF,EAAUvC,OAAwB,CAC3C,IAAI0B,GAAuB1E,KAAKuF,EAAUvC,QAGxC,MAAM,IAAI/C,UAAU,8BAFpB8F,EAAO/C,OAASlC,SAASyE,EAAUvC,OAAQ,GAI/C,CAEA,OAAO,IAAI8C,EAAIC,EACjB,CAOA,gBAAOC,CAAUC,GACf,GAAIA,aAAetD,IAAQsD,aAAehC,GACxC,OAAOgC,EAAIhF,WAGb,MAAM,IAAIhB,UAAU,6BACtB;YC1Jc","x_google_ignoreList":[0,1,2,3,4,5,6,7,8]} \ No newline at end of file diff --git a/docs/assets/hierarchy.js b/docs/assets/hierarchy.js new file mode 100644 index 0000000..fb85f0a --- /dev/null +++ b/docs/assets/hierarchy.js @@ -0,0 +1 @@ +window.hierarchyData = "eJyrVirKzy8pVrKKjtVRKkpNy0lNLsnMzytWsqqurQUAmx4Kpg==" \ No newline at end of file diff --git a/docs/assets/icons.js b/docs/assets/icons.js index 3dfbd32..58882d7 100644 --- a/docs/assets/icons.js +++ b/docs/assets/icons.js @@ -3,7 +3,7 @@ function addIcons() { if (document.readyState === "loading") return document.addEventListener("DOMContentLoaded", addIcons); const svg = document.body.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg")); - svg.innerHTML = `MMNEPVFCICPMFPCPTTAAATR`; + svg.innerHTML = `MMNEPVFCICPMFPCPTTAAATR`; svg.style.display = "none"; if (location.protocol === "file:") updateUseElements(); } diff --git a/docs/assets/icons.svg b/docs/assets/icons.svg index a19417d..50ad579 100644 --- a/docs/assets/icons.svg +++ b/docs/assets/icons.svg @@ -1 +1 @@ -MMNEPVFCICPMFPCPTTAAATR \ No newline at end of file +MMNEPVFCICPMFPCPTTAAATR \ No newline at end of file diff --git a/docs/assets/main.js b/docs/assets/main.js index 99097a0..4f59cd9 100644 --- a/docs/assets/main.js +++ b/docs/assets/main.js @@ -1,9 +1,9 @@ "use strict"; -window.translations={"copy":"Copy","copied":"Copied!","normally_hidden":"This member is normally hidden due to your filter settings."}; -"use strict";(()=>{var Pe=Object.create;var ie=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var Fe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var De=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _e(e))!Me.call(t,i)&&i!==n&&ie(t,i,{get:()=>e[i],enumerable:!(r=Oe(e,i))||r.enumerable});return t};var Ae=(t,e,n)=>(n=t!=null?Pe(Re(t)):{},De(e||!t||!t.__esModule?ie(n,"default",{value:t,enumerable:!0}):n,t));var ue=Fe((ae,le)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i0){var d=t.utils.clone(n)||{};d.position=[a,u],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. -`,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r1&&(oe&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(ol?d+=2:a==l&&(n+=r[u+1]*i[d+1],u+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var u=s.node.edges["*"];else{var u=new t.TokenSet;s.node.edges["*"]=u}s.str.length==1&&(u.final=!0),i.push({node:u,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),p;m in s.node.edges?p=s.node.edges[m]:(p=new t.TokenSet,s.node.edges[m]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof ae=="object"?le.exports=n():e.lunr=n()}(this,function(){return t})})()});var se=[];function G(t,e){se.push({selector:e,constructor:t})}var U=class{constructor(){this.alwaysVisibleMember=null;this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){se.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!Ve(e)){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r,document.querySelector(".col-sidebar").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(!n)return;let r=n.offsetParent==null,i=n;for(;i!==document.body;)i instanceof HTMLDetailsElement&&(i.open=!0),i=i.parentElement;if(n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let s=document.createElement("p");s.classList.add("warning"),s.textContent=window.translations.normally_hidden,n.prepend(s)}r&&e.scrollIntoView()}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent=window.translations.copied,e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent=window.translations.copy},100)},1e3)})})}};function Ve(t){let e=t.getBoundingClientRect(),n=Math.max(document.documentElement.clientHeight,window.innerHeight);return!(e.bottom<0||e.top-n>=0)}var oe=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var pe=Ae(ue());async function ce(t,e){if(!window.searchData)return;let n=await fetch(window.searchData),r=new Blob([await n.arrayBuffer()]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();t.data=i,t.index=pe.Index.load(i.index),e.classList.remove("loading"),e.classList.add("ready")}function fe(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:t.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{ce(e,t)}),ce(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");i.addEventListener("mouseup",()=>{te(t)}),r.addEventListener("focus",()=>t.classList.add("has-focus")),He(t,i,r,e)}function He(t,e,n,r){n.addEventListener("input",oe(()=>{Ne(t,e,n,r)},200)),n.addEventListener("keydown",i=>{i.key=="Enter"?Be(e,t):i.key=="ArrowUp"?(de(e,n,-1),i.preventDefault()):i.key==="ArrowDown"&&(de(e,n,1),i.preventDefault())}),document.body.addEventListener("keypress",i=>{i.altKey||i.ctrlKey||i.metaKey||!n.matches(":focus")&&i.key==="/"&&(i.preventDefault(),n.focus())}),document.body.addEventListener("keyup",i=>{t.classList.contains("has-focus")&&(i.key==="Escape"||!e.matches(":focus-within")&&!n.matches(":focus"))&&(n.blur(),te(t))})}function te(t){t.classList.remove("has-focus")}function Ne(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;oa.score-o.score);for(let o=0,a=Math.min(10,s.length);o`,d=he(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=` - ${he(l.parent,i)}.${d}`);let m=document.createElement("li");m.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=u+d,m.append(p),p.addEventListener("focus",()=>{e.querySelector(".current")?.classList.remove("current"),m.classList.add("current")}),e.appendChild(m)}}function de(t,e,n){let r=t.querySelector(".current");if(!r)r=t.querySelector(n==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let i=r;if(n===1)do i=i.nextElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);else do i=i.previousElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);i?(r.classList.remove("current"),i.classList.add("current")):n===-1&&(r.classList.remove("current"),e.focus())}}function Be(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),te(e)}}function he(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(ee(t.substring(s,o)),`${ee(t.substring(o,o+r.length))}`),s=o+r.length,o=n.indexOf(r,s);return i.push(ee(t.substring(s))),i.join("")}var je={"&":"&","<":"<",">":">","'":"'",'"':"""};function ee(t){return t.replace(/[&<>"'"]/g,e=>je[e])}var I=class{constructor(e){this.el=e.el,this.app=e.app}};var F="mousedown",ye="mousemove",N="mouseup",J={x:0,y:0},me=!1,ne=!1,qe=!1,D=!1,ve=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(ve?"is-mobile":"not-mobile");ve&&"ontouchstart"in document.documentElement&&(qe=!0,F="touchstart",ye="touchmove",N="touchend");document.addEventListener(F,t=>{ne=!0,D=!1;let e=F=="touchstart"?t.targetTouches[0]:t;J.y=e.pageY||0,J.x=e.pageX||0});document.addEventListener(ye,t=>{if(ne&&!D){let e=F=="touchstart"?t.targetTouches[0]:t,n=J.x-(e.pageX||0),r=J.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(N,()=>{ne=!1});document.addEventListener("click",t=>{me&&(t.preventDefault(),t.stopImmediatePropagation(),me=!1)});var X=class extends I{constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(N,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(F,n=>this.onDocumentPointerDown(n)),document.addEventListener(N,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var re;try{re=localStorage}catch{re={getItem(){return null},setItem(){}}}var Q=re;var ge=document.head.appendChild(document.createElement("style"));ge.dataset.for="filters";var Y=class extends I{constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),ge.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } -`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=Q.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){Q.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var Z=class extends I{constructor(e){super(e),this.summary=this.el.querySelector(".tsd-accordion-summary"),this.icon=this.summary.querySelector("svg"),this.key=`tsd-accordion-${this.summary.dataset.key??this.summary.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`;let n=Q.getItem(this.key);this.el.open=n?n==="true":this.el.open,this.el.addEventListener("toggle",()=>this.update());let r=this.summary.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)}),this.update()}update(){this.icon.style.transform=`rotate(${this.el.open?0:-90}deg)`,Q.setItem(this.key,this.el.open.toString())}};function Ee(t){let e=Q.getItem("tsd-theme")||"os";t.value=e,xe(e),t.addEventListener("change",()=>{Q.setItem("tsd-theme",t.value),xe(t.value)})}function xe(t){document.documentElement.dataset.theme=t}var K;function we(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Le),Le())}async function Le(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let n=await(await fetch(window.navigationData)).arrayBuffer(),r=new Blob([n]).stream().pipeThrough(new DecompressionStream("gzip")),i=await new Response(r).json();K=t.dataset.base,K.endsWith("/")||(K+="/"),t.innerHTML="";for(let s of i)Se(s,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Se(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-accordion`:"tsd-accordion";let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.dataset.key=i.join("$"),o.innerHTML='',be(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let u of t.children)Se(u,l,i)}else be(t,r,t.class)}function be(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=K+t.path,n&&(r.className=n),location.pathname===r.pathname&&!r.href.includes("#")&&r.classList.add("current"),t.kind&&(r.innerHTML=``),r.appendChild(document.createElement("span")).textContent=t.text}else{let r=e.appendChild(document.createElement("span"));r.innerHTML='',r.appendChild(document.createElement("span")).textContent=t.text}}G(X,"a[data-toggle]");G(Z,".tsd-accordion");G(Y,".tsd-filter-item input[type=checkbox]");var Te=document.getElementById("tsd-theme");Te&&Ee(Te);var $e=new U;Object.defineProperty(window,"app",{value:$e});fe();we();})(); +window.translations={"copy":"Copy","copied":"Copied!","normally_hidden":"This member is normally hidden due to your filter settings.","hierarchy_expand":"Expand","hierarchy_collapse":"Collapse"}; +"use strict";(()=>{var De=Object.create;var le=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var qe=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var je=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ne(e))!Be.call(t,i)&&i!==n&&le(t,i,{get:()=>e[i],enumerable:!(r=Fe(e,i))||r.enumerable});return t};var $e=(t,e,n)=>(n=t!=null?De(Ve(t)):{},je(e||!t||!t.__esModule?le(n,"default",{value:t,enumerable:!0}):n,t));var pe=qe((de,he)=>{(function(){var t=function(e){var n=new t.Builder;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),n.searchPipeline.add(t.stemmer),e.call(n,n),n.build()};t.version="2.3.9";t.utils={},t.utils.warn=function(e){return function(n){e.console&&console.warn&&console.warn(n)}}(this),t.utils.asString=function(e){return e==null?"":e.toString()},t.utils.clone=function(e){if(e==null)return e;for(var n=Object.create(null),r=Object.keys(e),i=0;i0){var d=t.utils.clone(n)||{};d.position=[a,c],d.index=s.length,s.push(new t.Token(r.slice(a,o),d))}a=o+1}}return s},t.tokenizer.separator=/[\s\-]+/;t.Pipeline=function(){this._stack=[]},t.Pipeline.registeredFunctions=Object.create(null),t.Pipeline.registerFunction=function(e,n){n in this.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[e.label]=e},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index. +`,e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(r){var i=t.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(n){t.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(e);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},t.Pipeline.prototype.remove=function(e){var n=this._stack.indexOf(e);n!=-1&&this._stack.splice(n,1)},t.Pipeline.prototype.run=function(e){for(var n=this._stack.length,r=0;r1&&(oe&&(r=s),o!=e);)i=r-n,s=n+Math.floor(i/2),o=this.elements[s*2];if(o==e||o>e)return s*2;if(ol?d+=2:a==l&&(n+=r[c+1]*i[d+1],c+=2,d+=2);return n},t.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},t.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),n=1,r=0;n0){var o=s.str.charAt(0),a;o in s.node.edges?a=s.node.edges[o]:(a=new t.TokenSet,s.node.edges[o]=a),s.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:s.editsRemaining,str:s.str.slice(1)})}if(s.editsRemaining!=0){if("*"in s.node.edges)var l=s.node.edges["*"];else{var l=new t.TokenSet;s.node.edges["*"]=l}if(s.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:s.editsRemaining-1,str:s.str}),s.str.length>1&&i.push({node:s.node,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)}),s.str.length==1&&(s.node.final=!0),s.str.length>=1){if("*"in s.node.edges)var c=s.node.edges["*"];else{var c=new t.TokenSet;s.node.edges["*"]=c}s.str.length==1&&(c.final=!0),i.push({node:c,editsRemaining:s.editsRemaining-1,str:s.str.slice(1)})}if(s.str.length>1){var d=s.str.charAt(0),m=s.str.charAt(1),p;m in s.node.edges?p=s.node.edges[m]:(p=new t.TokenSet,s.node.edges[m]=p),s.str.length==1&&(p.final=!0),i.push({node:p,editsRemaining:s.editsRemaining-1,str:d+s.str.slice(2)})}}}return r},t.TokenSet.fromString=function(e){for(var n=new t.TokenSet,r=n,i=0,s=e.length;i=e;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};t.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},t.Index.prototype.search=function(e){return this.query(function(n){var r=new t.QueryParser(e,n);r.parse()})},t.Index.prototype.query=function(e){for(var n=new t.Query(this.fields),r=Object.create(null),i=Object.create(null),s=Object.create(null),o=Object.create(null),a=Object.create(null),l=0;l1?this._b=1:this._b=e},t.Builder.prototype.k1=function(e){this._k1=e},t.Builder.prototype.add=function(e,n){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var s=0;s=this.length)return t.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},t.QueryLexer.prototype.width=function(){return this.pos-this.start},t.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},t.QueryLexer.prototype.backup=function(){this.pos-=1},t.QueryLexer.prototype.acceptDigitRun=function(){var e,n;do e=this.next(),n=e.charCodeAt(0);while(n>47&&n<58);e!=t.QueryLexer.EOS&&this.backup()},t.QueryLexer.prototype.more=function(){return this.pos1&&(e.backup(),e.emit(t.QueryLexer.TERM)),e.ignore(),e.more())return t.QueryLexer.lexText},t.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.EDIT_DISTANCE),t.QueryLexer.lexText},t.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(t.QueryLexer.BOOST),t.QueryLexer.lexText},t.QueryLexer.lexEOS=function(e){e.width()>0&&e.emit(t.QueryLexer.TERM)},t.QueryLexer.termSeparator=t.tokenizer.separator,t.QueryLexer.lexText=function(e){for(;;){var n=e.next();if(n==t.QueryLexer.EOS)return t.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){e.escapeCharacter();continue}if(n==":")return t.QueryLexer.lexField;if(n=="~")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexEditDistance;if(n=="^")return e.backup(),e.width()>0&&e.emit(t.QueryLexer.TERM),t.QueryLexer.lexBoost;if(n=="+"&&e.width()===1||n=="-"&&e.width()===1)return e.emit(t.QueryLexer.PRESENCE),t.QueryLexer.lexText;if(n.match(t.QueryLexer.termSeparator))return t.QueryLexer.lexTerm}},t.QueryParser=function(e,n){this.lexer=new t.QueryLexer(e),this.query=n,this.currentClause={},this.lexemeIdx=0},t.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=t.QueryParser.parseClause;e;)e=e(this);return this.query},t.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},t.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},t.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},t.QueryParser.parseClause=function(e){var n=e.peekLexeme();if(n!=null)switch(n.type){case t.QueryLexer.PRESENCE:return t.QueryParser.parsePresence;case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new t.QueryParseError(r,n.start,n.end)}},t.QueryParser.parsePresence=function(e){var n=e.consumeLexeme();if(n!=null){switch(n.str){case"-":e.currentClause.presence=t.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=t.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new t.QueryParseError(r,n.start,n.end)}var i=e.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new t.QueryParseError(r,n.start,n.end)}switch(i.type){case t.QueryLexer.FIELD:return t.QueryParser.parseField;case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new t.QueryParseError(r,i.start,i.end)}}},t.QueryParser.parseField=function(e){var n=e.consumeLexeme();if(n!=null){if(e.query.allFields.indexOf(n.str)==-1){var r=e.query.allFields.map(function(o){return"'"+o+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.fields=[n.str];var s=e.peekLexeme();if(s==null){var i="expecting term, found nothing";throw new t.QueryParseError(i,n.start,n.end)}switch(s.type){case t.QueryLexer.TERM:return t.QueryParser.parseTerm;default:var i="expecting term, found '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseTerm=function(e){var n=e.consumeLexeme();if(n!=null){e.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(r==null){e.nextClause();return}switch(r.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new t.QueryParseError(i,r.start,r.end)}}},t.QueryParser.parseEditDistance=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.editDistance=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},t.QueryParser.parseBoost=function(e){var n=e.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new t.QueryParseError(i,n.start,n.end)}e.currentClause.boost=r;var s=e.peekLexeme();if(s==null){e.nextClause();return}switch(s.type){case t.QueryLexer.TERM:return e.nextClause(),t.QueryParser.parseTerm;case t.QueryLexer.FIELD:return e.nextClause(),t.QueryParser.parseField;case t.QueryLexer.EDIT_DISTANCE:return t.QueryParser.parseEditDistance;case t.QueryLexer.BOOST:return t.QueryParser.parseBoost;case t.QueryLexer.PRESENCE:return e.nextClause(),t.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+s.type+"'";throw new t.QueryParseError(i,s.start,s.end)}}},function(e,n){typeof define=="function"&&define.amd?define(n):typeof de=="object"?he.exports=n():e.lunr=n()}(this,function(){return t})})()});window.translations||={copy:"Copy",copied:"Copied!",normally_hidden:"This member is normally hidden due to your filter settings.",hierarchy_expand:"Expand",hierarchy_collapse:"Collapse"};var ce=[];function G(t,e){ce.push({selector:e,constructor:t})}var J=class{alwaysVisibleMember=null;constructor(){this.createComponents(document.body),this.ensureFocusedElementVisible(),this.listenForCodeCopies(),window.addEventListener("hashchange",()=>this.ensureFocusedElementVisible()),document.body.style.display||(this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}createComponents(e){ce.forEach(n=>{e.querySelectorAll(n.selector).forEach(r=>{r.dataset.hasInstance||(new n.constructor({el:r,app:this}),r.dataset.hasInstance=String(!0))})})}filterChanged(){this.ensureFocusedElementVisible()}showPage(){document.body.style.display&&(document.body.style.removeProperty("display"),this.ensureFocusedElementVisible(),this.updateIndexVisibility(),this.scrollToHash())}scrollToHash(){if(location.hash){let e=document.getElementById(location.hash.substring(1));if(!e)return;e.scrollIntoView({behavior:"instant",block:"start"})}}ensureActivePageVisible(){let e=document.querySelector(".tsd-navigation .current"),n=e?.parentElement;for(;n&&!n.classList.contains(".tsd-navigation");)n instanceof HTMLDetailsElement&&(n.open=!0),n=n.parentElement;if(e&&!ze(e)){let r=e.getBoundingClientRect().top-document.documentElement.clientHeight/4;document.querySelector(".site-menu").scrollTop=r,document.querySelector(".col-sidebar").scrollTop=r}}updateIndexVisibility(){let e=document.querySelector(".tsd-index-content"),n=e?.open;e&&(e.open=!0),document.querySelectorAll(".tsd-index-section").forEach(r=>{r.style.display="block";let i=Array.from(r.querySelectorAll(".tsd-index-link")).every(s=>s.offsetParent==null);r.style.display=i?"none":"block"}),e&&(e.open=n)}ensureFocusedElementVisible(){if(this.alwaysVisibleMember&&(this.alwaysVisibleMember.classList.remove("always-visible"),this.alwaysVisibleMember.firstElementChild.remove(),this.alwaysVisibleMember=null),!location.hash)return;let e=document.getElementById(location.hash.substring(1));if(!e)return;let n=e.parentElement;for(;n&&n.tagName!=="SECTION";)n=n.parentElement;if(!n)return;let r=n.offsetParent==null,i=n;for(;i!==document.body;)i instanceof HTMLDetailsElement&&(i.open=!0),i=i.parentElement;if(n.offsetParent==null){this.alwaysVisibleMember=n,n.classList.add("always-visible");let s=document.createElement("p");s.classList.add("warning"),s.textContent=window.translations.normally_hidden,n.prepend(s)}r&&e.scrollIntoView()}listenForCodeCopies(){document.querySelectorAll("pre > button").forEach(e=>{let n;e.addEventListener("click",()=>{e.previousElementSibling instanceof HTMLElement&&navigator.clipboard.writeText(e.previousElementSibling.innerText.trim()),e.textContent=window.translations.copied,e.classList.add("visible"),clearTimeout(n),n=setTimeout(()=>{e.classList.remove("visible"),n=setTimeout(()=>{e.textContent=window.translations.copy},100)},1e3)})})}};function ze(t){let e=t.getBoundingClientRect(),n=Math.max(document.documentElement.clientHeight,window.innerHeight);return!(e.bottom<0||e.top-n>=0)}var ue=(t,e=100)=>{let n;return()=>{clearTimeout(n),n=setTimeout(()=>t(),e)}};var ge=$e(pe(),1);async function H(t){let e=Uint8Array.from(atob(t),s=>s.charCodeAt(0)),r=new Blob([e]).stream().pipeThrough(new DecompressionStream("deflate")),i=await new Response(r).text();return JSON.parse(i)}async function fe(t,e){if(!window.searchData)return;let n=await H(window.searchData);t.data=n,t.index=ge.Index.load(n.index),e.classList.remove("loading"),e.classList.add("ready")}function ve(){let t=document.getElementById("tsd-search");if(!t)return;let e={base:document.documentElement.dataset.base+"/"},n=document.getElementById("tsd-search-script");t.classList.add("loading"),n&&(n.addEventListener("error",()=>{t.classList.remove("loading"),t.classList.add("failure")}),n.addEventListener("load",()=>{fe(e,t)}),fe(e,t));let r=document.querySelector("#tsd-search input"),i=document.querySelector("#tsd-search .results");if(!r||!i)throw new Error("The input field or the result list wrapper was not found");i.addEventListener("mouseup",()=>{re(t)}),r.addEventListener("focus",()=>t.classList.add("has-focus")),We(t,i,r,e)}function We(t,e,n,r){n.addEventListener("input",ue(()=>{Ue(t,e,n,r)},200)),n.addEventListener("keydown",i=>{i.key=="Enter"?Je(e,t):i.key=="ArrowUp"?(me(e,n,-1),i.preventDefault()):i.key==="ArrowDown"&&(me(e,n,1),i.preventDefault())}),document.body.addEventListener("keypress",i=>{i.altKey||i.ctrlKey||i.metaKey||!n.matches(":focus")&&i.key==="/"&&(i.preventDefault(),n.focus())}),document.body.addEventListener("keyup",i=>{t.classList.contains("has-focus")&&(i.key==="Escape"||!e.matches(":focus-within")&&!n.matches(":focus"))&&(n.blur(),re(t))})}function re(t){t.classList.remove("has-focus")}function Ue(t,e,n,r){if(!r.index||!r.data)return;e.textContent="";let i=n.value.trim(),s;if(i){let o=i.split(" ").map(a=>a.length?`*${a}*`:"").join(" ");s=r.index.search(o)}else s=[];for(let o=0;oa.score-o.score);for(let o=0,a=Math.min(10,s.length);o`,d=ye(l.name,i);globalThis.DEBUG_SEARCH_WEIGHTS&&(d+=` (score: ${s[o].score.toFixed(2)})`),l.parent&&(d=` + ${ye(l.parent,i)}.${d}`);let m=document.createElement("li");m.classList.value=l.classes??"";let p=document.createElement("a");p.href=r.base+l.url,p.innerHTML=c+d,m.append(p),p.addEventListener("focus",()=>{e.querySelector(".current")?.classList.remove("current"),m.classList.add("current")}),e.appendChild(m)}}function me(t,e,n){let r=t.querySelector(".current");if(!r)r=t.querySelector(n==1?"li:first-child":"li:last-child"),r&&r.classList.add("current");else{let i=r;if(n===1)do i=i.nextElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);else do i=i.previousElementSibling??void 0;while(i instanceof HTMLElement&&i.offsetParent==null);i?(r.classList.remove("current"),i.classList.add("current")):n===-1&&(r.classList.remove("current"),e.focus())}}function Je(t,e){let n=t.querySelector(".current");if(n||(n=t.querySelector("li:first-child")),n){let r=n.querySelector("a");r&&(window.location.href=r.href),re(e)}}function ye(t,e){if(e==="")return t;let n=t.toLocaleLowerCase(),r=e.toLocaleLowerCase(),i=[],s=0,o=n.indexOf(r);for(;o!=-1;)i.push(ne(t.substring(s,o)),`${ne(t.substring(o,o+r.length))}`),s=o+r.length,o=n.indexOf(r,s);return i.push(ne(t.substring(s))),i.join("")}var Ge={"&":"&","<":"<",">":">","'":"'",'"':"""};function ne(t){return t.replace(/[&<>"'"]/g,e=>Ge[e])}var I=class{el;app;constructor(e){this.el=e.el,this.app=e.app}};var A="mousedown",Ee="mousemove",B="mouseup",X={x:0,y:0},xe=!1,ie=!1,Xe=!1,D=!1,Le=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);document.documentElement.classList.add(Le?"is-mobile":"not-mobile");Le&&"ontouchstart"in document.documentElement&&(Xe=!0,A="touchstart",Ee="touchmove",B="touchend");document.addEventListener(A,t=>{ie=!0,D=!1;let e=A=="touchstart"?t.targetTouches[0]:t;X.y=e.pageY||0,X.x=e.pageX||0});document.addEventListener(Ee,t=>{if(ie&&!D){let e=A=="touchstart"?t.targetTouches[0]:t,n=X.x-(e.pageX||0),r=X.y-(e.pageY||0);D=Math.sqrt(n*n+r*r)>10}});document.addEventListener(B,()=>{ie=!1});document.addEventListener("click",t=>{xe&&(t.preventDefault(),t.stopImmediatePropagation(),xe=!1)});var Y=class extends I{active;className;constructor(e){super(e),this.className=this.el.dataset.toggle||"",this.el.addEventListener(B,n=>this.onPointerUp(n)),this.el.addEventListener("click",n=>n.preventDefault()),document.addEventListener(A,n=>this.onDocumentPointerDown(n)),document.addEventListener(B,n=>this.onDocumentPointerUp(n))}setActive(e){if(this.active==e)return;this.active=e,document.documentElement.classList.toggle("has-"+this.className,e),this.el.classList.toggle("active",e);let n=(this.active?"to-has-":"from-has-")+this.className;document.documentElement.classList.add(n),setTimeout(()=>document.documentElement.classList.remove(n),500)}onPointerUp(e){D||(this.setActive(!0),e.preventDefault())}onDocumentPointerDown(e){if(this.active){if(e.target.closest(".col-sidebar, .tsd-filter-group"))return;this.setActive(!1)}}onDocumentPointerUp(e){if(!D&&this.active&&e.target.closest(".col-sidebar")){let n=e.target.closest("a");if(n){let r=window.location.href;r.indexOf("#")!=-1&&(r=r.substring(0,r.indexOf("#"))),n.href.substring(0,r.length)==r&&setTimeout(()=>this.setActive(!1),250)}}}};var se;try{se=localStorage}catch{se={getItem(){return null},setItem(){}}}var C=se;var be=document.head.appendChild(document.createElement("style"));be.dataset.for="filters";var Z=class extends I{key;value;constructor(e){super(e),this.key=`filter-${this.el.name}`,this.value=this.el.checked,this.el.addEventListener("change",()=>{this.setLocalStorage(this.el.checked)}),this.setLocalStorage(this.fromLocalStorage()),be.innerHTML+=`html:not(.${this.key}) .tsd-is-${this.el.name} { display: none; } +`,this.app.updateIndexVisibility()}fromLocalStorage(){let e=C.getItem(this.key);return e?e==="true":this.el.checked}setLocalStorage(e){C.setItem(this.key,e.toString()),this.value=e,this.handleValueChange()}handleValueChange(){this.el.checked=this.value,document.documentElement.classList.toggle(this.key,this.value),this.app.filterChanged(),this.app.updateIndexVisibility()}};var oe=new Map,ae=class{open;accordions=[];key;constructor(e,n){this.key=e,this.open=n}add(e){this.accordions.push(e),e.open=this.open,e.addEventListener("toggle",()=>{this.toggle(e.open)})}toggle(e){for(let n of this.accordions)n.open=e;C.setItem(this.key,e.toString())}},K=class extends I{constructor(e){super(e);let n=this.el.querySelector("summary"),r=n.querySelector("a");r&&r.addEventListener("click",()=>{location.assign(r.href)});let i=`tsd-accordion-${n.dataset.key??n.textContent.trim().replace(/\s+/g,"-").toLowerCase()}`,s;if(oe.has(i))s=oe.get(i);else{let o=C.getItem(i),a=o?o==="true":this.el.open;s=new ae(i,a),oe.set(i,s)}s.add(this.el)}};function Se(t){let e=C.getItem("tsd-theme")||"os";t.value=e,we(e),t.addEventListener("change",()=>{C.setItem("tsd-theme",t.value),we(t.value)})}function we(t){document.documentElement.dataset.theme=t}var ee;function Ce(){let t=document.getElementById("tsd-nav-script");t&&(t.addEventListener("load",Te),Te())}async function Te(){let t=document.getElementById("tsd-nav-container");if(!t||!window.navigationData)return;let e=await H(window.navigationData);ee=document.documentElement.dataset.base,ee.endsWith("/")||(ee+="/"),t.innerHTML="";for(let n of e)Ie(n,t,[]);window.app.createComponents(t),window.app.showPage(),window.app.ensureActivePageVisible()}function Ie(t,e,n){let r=e.appendChild(document.createElement("li"));if(t.children){let i=[...n,t.text],s=r.appendChild(document.createElement("details"));s.className=t.class?`${t.class} tsd-accordion`:"tsd-accordion";let o=s.appendChild(document.createElement("summary"));o.className="tsd-accordion-summary",o.dataset.key=i.join("$"),o.innerHTML='',ke(t,o);let a=s.appendChild(document.createElement("div"));a.className="tsd-accordion-details";let l=a.appendChild(document.createElement("ul"));l.className="tsd-nested-navigation";for(let c of t.children)Ie(c,l,i)}else ke(t,r,t.class)}function ke(t,e,n){if(t.path){let r=e.appendChild(document.createElement("a"));r.href=ee+t.path,n&&(r.className=n),location.pathname===r.pathname&&!r.href.includes("#")&&r.classList.add("current"),t.kind&&(r.innerHTML=``),r.appendChild(document.createElement("span")).textContent=t.text}else{let r=e.appendChild(document.createElement("span"));r.innerHTML='',r.appendChild(document.createElement("span")).textContent=t.text}}var te=document.documentElement.dataset.base;te.endsWith("/")||(te+="/");function Pe(){document.querySelector(".tsd-full-hierarchy")?Ye():document.querySelector(".tsd-hierarchy")&&Ze()}function Ye(){document.addEventListener("click",r=>{let i=r.target;for(;i.parentElement&&i.parentElement.tagName!="LI";)i=i.parentElement;i.dataset.dropdown&&(i.dataset.dropdown=String(i.dataset.dropdown!=="true"))});let t=new Map,e=new Set;for(let r of document.querySelectorAll(".tsd-full-hierarchy [data-refl]")){let i=r.querySelector("ul");t.has(r.dataset.refl)?e.add(r.dataset.refl):i&&t.set(r.dataset.refl,i)}for(let r of e)n(r);function n(r){let i=t.get(r).cloneNode(!0);i.querySelectorAll("[id]").forEach(s=>{s.removeAttribute("id")}),i.querySelectorAll("[data-dropdown]").forEach(s=>{s.dataset.dropdown="false"});for(let s of document.querySelectorAll(`[data-refl="${r}"]`)){let o=tt(),a=s.querySelector("ul");s.insertBefore(o,a),o.dataset.dropdown=String(!!a),a||s.appendChild(i.cloneNode(!0))}}}function Ze(){let t=document.getElementById("tsd-hierarchy-script");t&&(t.addEventListener("load",Qe),Qe())}async function Qe(){let t=document.querySelector(".tsd-panel.tsd-hierarchy:has(h4 a)");if(!t||!window.hierarchyData)return;let e=+t.dataset.refl,n=await H(window.hierarchyData),r=t.querySelector("ul"),i=document.createElement("ul");if(i.classList.add("tsd-hierarchy"),Ke(i,n,e),r.querySelectorAll("li").length==i.querySelectorAll("li").length)return;let s=document.createElement("span");s.classList.add("tsd-hierarchy-toggle"),s.textContent=window.translations.hierarchy_expand,t.querySelector("h4 a")?.insertAdjacentElement("afterend",s),s.insertAdjacentText("beforebegin",", "),s.addEventListener("click",()=>{s.textContent===window.translations.hierarchy_expand?(r.insertAdjacentElement("afterend",i),r.remove(),s.textContent=window.translations.hierarchy_collapse):(i.insertAdjacentElement("afterend",r),i.remove(),s.textContent=window.translations.hierarchy_expand)})}function Ke(t,e,n){let r=e.roots.filter(i=>et(e,i,n));for(let i of r)t.appendChild(Oe(e,i,n))}function Oe(t,e,n,r=new Set){if(r.has(e))return;r.add(e);let i=t.reflections[e],s=document.createElement("li");if(s.classList.add("tsd-hierarchy-item"),e===n){let o=s.appendChild(document.createElement("span"));o.textContent=i.name,o.classList.add("tsd-hierarchy-target")}else{for(let a of i.uniqueNameParents||[]){let l=t.reflections[a],c=s.appendChild(document.createElement("a"));c.textContent=l.name,c.href=te+l.url,c.className=l.class+" tsd-signature-type",s.append(document.createTextNode("."))}let o=s.appendChild(document.createElement("a"));o.textContent=t.reflections[e].name,o.href=te+i.url,o.className=i.class+" tsd-signature-type"}if(i.children){let o=s.appendChild(document.createElement("ul"));o.classList.add("tsd-hierarchy");for(let a of i.children){let l=Oe(t,a,n,r);l&&o.appendChild(l)}}return r.delete(e),s}function et(t,e,n){if(e===n)return!0;let r=new Set,i=[t.reflections[e]];for(;i.length;){let s=i.pop();if(!r.has(s)){r.add(s);for(let o of s.children||[]){if(o===n)return!0;i.push(t.reflections[o])}}}return!1}function tt(){let t=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.setAttribute("width","20"),t.setAttribute("height","20"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.innerHTML='',t}G(Y,"a[data-toggle]");G(K,".tsd-accordion");G(Z,".tsd-filter-item input[type=checkbox]");var _e=document.getElementById("tsd-theme");_e&&Se(_e);var nt=new J;Object.defineProperty(window,"app",{value:nt});ve();Ce();Pe();})(); /*! Bundled license information: lunr/lunr.js: diff --git a/docs/assets/navigation.js b/docs/assets/navigation.js index fd293ee..5952976 100644 --- a/docs/assets/navigation.js +++ b/docs/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA4uuVipJrShRslLy8A8JUNJRKkgsyVCyUkrOSSwuTi3WB4nqZZTk5ijpKGVn5qUoWRkaWdTqwHUFpyYXpZZg6oOI49MZgtW+EAL2hQZ5YmoKDfLEp6cstag4Mz8Poa8ssSgzMSkntVgfKoWq29ioNhYAH9hXOhgBAAA=" \ No newline at end of file +window.navigationData = "eJyLrlYqSa0oUbJS8vAPCVDSUSpILMlQslJKzkksLk4t1geJ6mWU5OYo6ShlZ+alKFkZGlnU6sB1BacmF6WWYOqDiOPTGYLVvhAC9oUGeWJqCg3yxKenLLWoODM/D6GvLLEoMzEpJ7VYHyqFqtvYqDYWAM0BWdM=" \ No newline at end of file diff --git a/docs/assets/search.js b/docs/assets/search.js index a058398..7e73510 100644 --- a/docs/assets/search.js +++ b/docs/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA7WaTW/bOBCG/wt7VV1zSMofxz0sGqDALlp1L0ZQOLHSCOvYgSSnLYL894VkSuJ4SGmkdU8KZM47I+rhq5GYV5EffxRivXkV/2aHnVhLWEbisH1KxVp8/Cv5W0TilO/FWtzvt0WRFh+qk7PH8mkvouacWAvxFjUKEIPUuhXZpQ/b074swkLvnCGOYiSet3l6KJtCugyxMSpuE3z7Vv56Thnys+aP93LWBoUTzkicU4KcQ3eJWVGc0nxSBbNz7Hs5spTmAgIV7bd36X5aQXXotes5X+XN4dP0upDEtevb7r8f86x8fJpWWxt+7bp22feMtXQ8RZ1jr13R/fF0KKfCboOvXdOP7LA7/phWUhv7/+qBue5883t6SPNt2edJzZD3wDU9lOFlu892/RmaIfwMRoJzmw9FmZ/uy2PfrcajWEnGGWc7YLz2kAU2v0+tetjMLseNz1Sk93la9qRoB4zX5lieO2Z8hmHzagaM1x62oW7E+OU1YgH/7uU7Sb88finz7PC9R98Zwpt9py9MfH1hcq2+MOH3hcmEvpDKj+gLk2v0hZwKhvtCfymT+kJWQUN94aR6+q10xEQN94WT6gubJKs2Tl84qa6AtbKK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W5eXWyMjSiDmTLc18WRAG5rpUtAWZBSMLJniTdZjKqBD9KmmeJPxoPvJU5brtlgAwAmUgqA6v5P5xOBN1/j5MRSN0m6rl4ztfFJlfzxe3b2/8IWchQ"; \ No newline at end of file diff --git a/docs/assets/style.css b/docs/assets/style.css index 178bfb0..7f80f3d 100644 --- a/docs/assets/style.css +++ b/docs/assets/style.css @@ -1,115 +1,256 @@ -:root { - /* Light */ - --light-color-background: #f2f4f8; - --light-color-background-secondary: #eff0f1; - --light-color-warning-text: #222; - --light-color-background-warning: #e6e600; - --light-color-accent: #c5c7c9; - --light-color-active-menu-item: var(--light-color-accent); - --light-color-text: #222; - --light-color-text-aside: #6e6e6e; - - --light-color-icon-background: var(--light-color-background); - --light-color-icon-text: var(--light-color-text); - - --light-color-comment-tag-text: var(--light-color-text); - --light-color-comment-tag: var(--light-color-background); - - --light-color-link: #1f70c2; - --light-color-focus-outline: #3584e4; - - --light-color-ts-keyword: #056bd6; - --light-color-ts-project: #b111c9; - --light-color-ts-module: var(--light-color-ts-project); - --light-color-ts-namespace: var(--light-color-ts-project); - --light-color-ts-enum: #7e6f15; - --light-color-ts-enum-member: var(--light-color-ts-enum); - --light-color-ts-variable: #4760ec; - --light-color-ts-function: #572be7; - --light-color-ts-class: #1f70c2; - --light-color-ts-interface: #108024; - --light-color-ts-constructor: #4d7fff; - --light-color-ts-property: #ff984d; - --light-color-ts-method: #ff4db8; - --light-color-ts-reference: #ff4d82; - --light-color-ts-call-signature: var(--light-color-ts-method); - --light-color-ts-index-signature: var(--light-color-ts-property); - --light-color-ts-constructor-signature: var(--light-color-ts-constructor); - --light-color-ts-parameter: var(--light-color-ts-variable); - /* type literal not included as links will never be generated to it */ - --light-color-ts-type-parameter: #a55c0e; - --light-color-ts-accessor: #ff4d4d; - --light-color-ts-get-signature: var(--light-color-ts-accessor); - --light-color-ts-set-signature: var(--light-color-ts-accessor); - --light-color-ts-type-alias: #d51270; - /* reference not included as links will be colored with the kind that it points to */ - --light-color-document: #000000; - - --light-external-icon: url("data:image/svg+xml;utf8,"); - --light-color-scheme: light; - - /* Dark */ - --dark-color-background: #2b2e33; - --dark-color-background-secondary: #1e2024; - --dark-color-background-warning: #bebe00; - --dark-color-warning-text: #222; - --dark-color-accent: #9096a2; - --dark-color-active-menu-item: #5d5d6a; - --dark-color-text: #f5f5f5; - --dark-color-text-aside: #dddddd; - - --dark-color-icon-background: var(--dark-color-background-secondary); - --dark-color-icon-text: var(--dark-color-text); - - --dark-color-comment-tag-text: var(--dark-color-text); - --dark-color-comment-tag: var(--dark-color-background); - - --dark-color-link: #00aff4; - --dark-color-focus-outline: #4c97f2; - - --dark-color-ts-keyword: #3399ff; - --dark-color-ts-project: #e358ff; - --dark-color-ts-module: var(--dark-color-ts-project); - --dark-color-ts-namespace: var(--dark-color-ts-project); - --dark-color-ts-enum: #f4d93e; - --dark-color-ts-enum-member: var(--dark-color-ts-enum); - --dark-color-ts-variable: #798dff; - --dark-color-ts-function: #a280ff; - --dark-color-ts-class: #8ac4ff; - --dark-color-ts-interface: #6cff87; - --dark-color-ts-constructor: #4d7fff; - --dark-color-ts-property: #ff984d; - --dark-color-ts-method: #ff4db8; - --dark-color-ts-reference: #ff4d82; - --dark-color-ts-call-signature: var(--dark-color-ts-method); - --dark-color-ts-index-signature: var(--dark-color-ts-property); - --dark-color-ts-constructor-signature: var(--dark-color-ts-constructor); - --dark-color-ts-parameter: var(--dark-color-ts-variable); - /* type literal not included as links will never be generated to it */ - --dark-color-ts-type-parameter: #e07d13; - --dark-color-ts-accessor: #ff4d4d; - --dark-color-ts-get-signature: var(--dark-color-ts-accessor); - --dark-color-ts-set-signature: var(--dark-color-ts-accessor); - --dark-color-ts-type-alias: #ff6492; - /* reference not included as links will be colored with the kind that it points to */ - --dark-color-document: #ffffff; - - --dark-external-icon: url("data:image/svg+xml;utf8,"); - --dark-color-scheme: dark; -} - -@media (prefers-color-scheme: light) { +@layer typedoc { :root { + /* Light */ + --light-color-background: #f2f4f8; + --light-color-background-secondary: #eff0f1; + --light-color-warning-text: #222; + --light-color-background-warning: #e6e600; + --light-color-accent: #c5c7c9; + --light-color-active-menu-item: var(--light-color-accent); + --light-color-text: #222; + --light-color-text-aside: #6e6e6e; + + --light-color-icon-background: var(--light-color-background); + --light-color-icon-text: var(--light-color-text); + + --light-color-comment-tag-text: var(--light-color-text); + --light-color-comment-tag: var(--light-color-background); + + --light-color-link: #1f70c2; + --light-color-focus-outline: #3584e4; + + --light-color-ts-keyword: #056bd6; + --light-color-ts-project: #b111c9; + --light-color-ts-module: var(--light-color-ts-project); + --light-color-ts-namespace: var(--light-color-ts-project); + --light-color-ts-enum: #7e6f15; + --light-color-ts-enum-member: var(--light-color-ts-enum); + --light-color-ts-variable: #4760ec; + --light-color-ts-function: #572be7; + --light-color-ts-class: #1f70c2; + --light-color-ts-interface: #108024; + --light-color-ts-constructor: var(--light-color-ts-class); + --light-color-ts-property: #9f5f30; + --light-color-ts-method: #be3989; + --light-color-ts-reference: #ff4d82; + --light-color-ts-call-signature: var(--light-color-ts-method); + --light-color-ts-index-signature: var(--light-color-ts-property); + --light-color-ts-constructor-signature: var( + --light-color-ts-constructor + ); + --light-color-ts-parameter: var(--light-color-ts-variable); + /* type literal not included as links will never be generated to it */ + --light-color-ts-type-parameter: #a55c0e; + --light-color-ts-accessor: #c73c3c; + --light-color-ts-get-signature: var(--light-color-ts-accessor); + --light-color-ts-set-signature: var(--light-color-ts-accessor); + --light-color-ts-type-alias: #d51270; + /* reference not included as links will be colored with the kind that it points to */ + --light-color-document: #000000; + + --light-color-alert-note: #0969d9; + --light-color-alert-tip: #1a7f37; + --light-color-alert-important: #8250df; + --light-color-alert-warning: #9a6700; + --light-color-alert-caution: #cf222e; + + --light-external-icon: url("data:image/svg+xml;utf8,"); + --light-color-scheme: light; + + /* Dark */ + --dark-color-background: #2b2e33; + --dark-color-background-secondary: #1e2024; + --dark-color-background-warning: #bebe00; + --dark-color-warning-text: #222; + --dark-color-accent: #9096a2; + --dark-color-active-menu-item: #5d5d6a; + --dark-color-text: #f5f5f5; + --dark-color-text-aside: #dddddd; + + --dark-color-icon-background: var(--dark-color-background-secondary); + --dark-color-icon-text: var(--dark-color-text); + + --dark-color-comment-tag-text: var(--dark-color-text); + --dark-color-comment-tag: var(--dark-color-background); + + --dark-color-link: #00aff4; + --dark-color-focus-outline: #4c97f2; + + --dark-color-ts-keyword: #3399ff; + --dark-color-ts-project: #e358ff; + --dark-color-ts-module: var(--dark-color-ts-project); + --dark-color-ts-namespace: var(--dark-color-ts-project); + --dark-color-ts-enum: #f4d93e; + --dark-color-ts-enum-member: var(--dark-color-ts-enum); + --dark-color-ts-variable: #798dff; + --dark-color-ts-function: #a280ff; + --dark-color-ts-class: #8ac4ff; + --dark-color-ts-interface: #6cff87; + --dark-color-ts-constructor: var(--dark-color-ts-class); + --dark-color-ts-property: #ff984d; + --dark-color-ts-method: #ff4db8; + --dark-color-ts-reference: #ff4d82; + --dark-color-ts-call-signature: var(--dark-color-ts-method); + --dark-color-ts-index-signature: var(--dark-color-ts-property); + --dark-color-ts-constructor-signature: var(--dark-color-ts-constructor); + --dark-color-ts-parameter: var(--dark-color-ts-variable); + /* type literal not included as links will never be generated to it */ + --dark-color-ts-type-parameter: #e07d13; + --dark-color-ts-accessor: #ff6060; + --dark-color-ts-get-signature: var(--dark-color-ts-accessor); + --dark-color-ts-set-signature: var(--dark-color-ts-accessor); + --dark-color-ts-type-alias: #ff6492; + /* reference not included as links will be colored with the kind that it points to */ + --dark-color-document: #ffffff; + + --dark-color-alert-note: #0969d9; + --dark-color-alert-tip: #1a7f37; + --dark-color-alert-important: #8250df; + --dark-color-alert-warning: #9a6700; + --dark-color-alert-caution: #cf222e; + + --dark-external-icon: url("data:image/svg+xml;utf8,"); + --dark-color-scheme: dark; + } + + @media (prefers-color-scheme: light) { + :root { + --color-background: var(--light-color-background); + --color-background-secondary: var( + --light-color-background-secondary + ); + --color-background-warning: var(--light-color-background-warning); + --color-warning-text: var(--light-color-warning-text); + --color-accent: var(--light-color-accent); + --color-active-menu-item: var(--light-color-active-menu-item); + --color-text: var(--light-color-text); + --color-text-aside: var(--light-color-text-aside); + + --color-icon-background: var(--light-color-icon-background); + --color-icon-text: var(--light-color-icon-text); + + --color-comment-tag-text: var(--light-color-text); + --color-comment-tag: var(--light-color-background); + + --color-link: var(--light-color-link); + --color-focus-outline: var(--light-color-focus-outline); + + --color-ts-keyword: var(--light-color-ts-keyword); + --color-ts-project: var(--light-color-ts-project); + --color-ts-module: var(--light-color-ts-module); + --color-ts-namespace: var(--light-color-ts-namespace); + --color-ts-enum: var(--light-color-ts-enum); + --color-ts-enum-member: var(--light-color-ts-enum-member); + --color-ts-variable: var(--light-color-ts-variable); + --color-ts-function: var(--light-color-ts-function); + --color-ts-class: var(--light-color-ts-class); + --color-ts-interface: var(--light-color-ts-interface); + --color-ts-constructor: var(--light-color-ts-constructor); + --color-ts-property: var(--light-color-ts-property); + --color-ts-method: var(--light-color-ts-method); + --color-ts-reference: var(--light-color-ts-reference); + --color-ts-call-signature: var(--light-color-ts-call-signature); + --color-ts-index-signature: var(--light-color-ts-index-signature); + --color-ts-constructor-signature: var( + --light-color-ts-constructor-signature + ); + --color-ts-parameter: var(--light-color-ts-parameter); + --color-ts-type-parameter: var(--light-color-ts-type-parameter); + --color-ts-accessor: var(--light-color-ts-accessor); + --color-ts-get-signature: var(--light-color-ts-get-signature); + --color-ts-set-signature: var(--light-color-ts-set-signature); + --color-ts-type-alias: var(--light-color-ts-type-alias); + --color-document: var(--light-color-document); + + --color-alert-note: var(--light-color-alert-note); + --color-alert-tip: var(--light-color-alert-tip); + --color-alert-important: var(--light-color-alert-important); + --color-alert-warning: var(--light-color-alert-warning); + --color-alert-caution: var(--light-color-alert-caution); + + --external-icon: var(--light-external-icon); + --color-scheme: var(--light-color-scheme); + } + } + + @media (prefers-color-scheme: dark) { + :root { + --color-background: var(--dark-color-background); + --color-background-secondary: var( + --dark-color-background-secondary + ); + --color-background-warning: var(--dark-color-background-warning); + --color-warning-text: var(--dark-color-warning-text); + --color-accent: var(--dark-color-accent); + --color-active-menu-item: var(--dark-color-active-menu-item); + --color-text: var(--dark-color-text); + --color-text-aside: var(--dark-color-text-aside); + + --color-icon-background: var(--dark-color-icon-background); + --color-icon-text: var(--dark-color-icon-text); + + --color-comment-tag-text: var(--dark-color-text); + --color-comment-tag: var(--dark-color-background); + + --color-link: var(--dark-color-link); + --color-focus-outline: var(--dark-color-focus-outline); + + --color-ts-keyword: var(--dark-color-ts-keyword); + --color-ts-project: var(--dark-color-ts-project); + --color-ts-module: var(--dark-color-ts-module); + --color-ts-namespace: var(--dark-color-ts-namespace); + --color-ts-enum: var(--dark-color-ts-enum); + --color-ts-enum-member: var(--dark-color-ts-enum-member); + --color-ts-variable: var(--dark-color-ts-variable); + --color-ts-function: var(--dark-color-ts-function); + --color-ts-class: var(--dark-color-ts-class); + --color-ts-interface: var(--dark-color-ts-interface); + --color-ts-constructor: var(--dark-color-ts-constructor); + --color-ts-property: var(--dark-color-ts-property); + --color-ts-method: var(--dark-color-ts-method); + --color-ts-reference: var(--dark-color-ts-reference); + --color-ts-call-signature: var(--dark-color-ts-call-signature); + --color-ts-index-signature: var(--dark-color-ts-index-signature); + --color-ts-constructor-signature: var( + --dark-color-ts-constructor-signature + ); + --color-ts-parameter: var(--dark-color-ts-parameter); + --color-ts-type-parameter: var(--dark-color-ts-type-parameter); + --color-ts-accessor: var(--dark-color-ts-accessor); + --color-ts-get-signature: var(--dark-color-ts-get-signature); + --color-ts-set-signature: var(--dark-color-ts-set-signature); + --color-ts-type-alias: var(--dark-color-ts-type-alias); + --color-document: var(--dark-color-document); + + --color-alert-note: var(--dark-color-alert-note); + --color-alert-tip: var(--dark-color-alert-tip); + --color-alert-important: var(--dark-color-alert-important); + --color-alert-warning: var(--dark-color-alert-warning); + --color-alert-caution: var(--dark-color-alert-caution); + + --external-icon: var(--dark-external-icon); + --color-scheme: var(--dark-color-scheme); + } + } + + html { + color-scheme: var(--color-scheme); + } + + body { + margin: 0; + } + + :root[data-theme="light"] { --color-background: var(--light-color-background); --color-background-secondary: var(--light-color-background-secondary); --color-background-warning: var(--light-color-background-warning); --color-warning-text: var(--light-color-warning-text); + --color-icon-background: var(--light-color-icon-background); --color-accent: var(--light-color-accent); --color-active-menu-item: var(--light-color-active-menu-item); --color-text: var(--light-color-text); --color-text-aside: var(--light-color-text-aside); - - --color-icon-background: var(--light-color-icon-background); --color-icon-text: var(--light-color-icon-text); --color-comment-tag-text: var(--light-color-text); @@ -145,23 +286,26 @@ --color-ts-type-alias: var(--light-color-ts-type-alias); --color-document: var(--light-color-document); + --color-note: var(--light-color-note); + --color-tip: var(--light-color-tip); + --color-important: var(--light-color-important); + --color-warning: var(--light-color-warning); + --color-caution: var(--light-color-caution); + --external-icon: var(--light-external-icon); --color-scheme: var(--light-color-scheme); } -} -@media (prefers-color-scheme: dark) { - :root { + :root[data-theme="dark"] { --color-background: var(--dark-color-background); --color-background-secondary: var(--dark-color-background-secondary); --color-background-warning: var(--dark-color-background-warning); --color-warning-text: var(--dark-color-warning-text); + --color-icon-background: var(--dark-color-icon-background); --color-accent: var(--dark-color-accent); --color-active-menu-item: var(--dark-color-active-menu-item); --color-text: var(--dark-color-text); --color-text-aside: var(--dark-color-text-aside); - - --color-icon-background: var(--dark-color-icon-background); --color-icon-text: var(--dark-color-icon-text); --color-comment-tag-text: var(--dark-color-text); @@ -197,1297 +341,1270 @@ --color-ts-type-alias: var(--dark-color-ts-type-alias); --color-document: var(--dark-color-document); + --color-note: var(--dark-color-note); + --color-tip: var(--dark-color-tip); + --color-important: var(--dark-color-important); + --color-warning: var(--dark-color-warning); + --color-caution: var(--dark-color-caution); + --external-icon: var(--dark-external-icon); --color-scheme: var(--dark-color-scheme); } -} -html { - color-scheme: var(--color-scheme); -} - -body { - margin: 0; -} + *:focus-visible, + .tsd-accordion-summary:focus-visible svg { + outline: 2px solid var(--color-focus-outline); + } -:root[data-theme="light"] { - --color-background: var(--light-color-background); - --color-background-secondary: var(--light-color-background-secondary); - --color-background-warning: var(--light-color-background-warning); - --color-warning-text: var(--light-color-warning-text); - --color-icon-background: var(--light-color-icon-background); - --color-accent: var(--light-color-accent); - --color-active-menu-item: var(--light-color-active-menu-item); - --color-text: var(--light-color-text); - --color-text-aside: var(--light-color-text-aside); - --color-icon-text: var(--light-color-icon-text); - - --color-comment-tag-text: var(--light-color-text); - --color-comment-tag: var(--light-color-background); - - --color-link: var(--light-color-link); - --color-focus-outline: var(--light-color-focus-outline); - - --color-ts-keyword: var(--light-color-ts-keyword); - --color-ts-project: var(--light-color-ts-project); - --color-ts-module: var(--light-color-ts-module); - --color-ts-namespace: var(--light-color-ts-namespace); - --color-ts-enum: var(--light-color-ts-enum); - --color-ts-enum-member: var(--light-color-ts-enum-member); - --color-ts-variable: var(--light-color-ts-variable); - --color-ts-function: var(--light-color-ts-function); - --color-ts-class: var(--light-color-ts-class); - --color-ts-interface: var(--light-color-ts-interface); - --color-ts-constructor: var(--light-color-ts-constructor); - --color-ts-property: var(--light-color-ts-property); - --color-ts-method: var(--light-color-ts-method); - --color-ts-reference: var(--light-color-ts-reference); - --color-ts-call-signature: var(--light-color-ts-call-signature); - --color-ts-index-signature: var(--light-color-ts-index-signature); - --color-ts-constructor-signature: var( - --light-color-ts-constructor-signature - ); - --color-ts-parameter: var(--light-color-ts-parameter); - --color-ts-type-parameter: var(--light-color-ts-type-parameter); - --color-ts-accessor: var(--light-color-ts-accessor); - --color-ts-get-signature: var(--light-color-ts-get-signature); - --color-ts-set-signature: var(--light-color-ts-set-signature); - --color-ts-type-alias: var(--light-color-ts-type-alias); - --color-document: var(--light-color-document); - - --external-icon: var(--light-external-icon); - --color-scheme: var(--light-color-scheme); -} + .always-visible, + .always-visible .tsd-signatures { + display: inherit !important; + } -:root[data-theme="dark"] { - --color-background: var(--dark-color-background); - --color-background-secondary: var(--dark-color-background-secondary); - --color-background-warning: var(--dark-color-background-warning); - --color-warning-text: var(--dark-color-warning-text); - --color-icon-background: var(--dark-color-icon-background); - --color-accent: var(--dark-color-accent); - --color-active-menu-item: var(--dark-color-active-menu-item); - --color-text: var(--dark-color-text); - --color-text-aside: var(--dark-color-text-aside); - --color-icon-text: var(--dark-color-icon-text); - - --color-comment-tag-text: var(--dark-color-text); - --color-comment-tag: var(--dark-color-background); - - --color-link: var(--dark-color-link); - --color-focus-outline: var(--dark-color-focus-outline); - - --color-ts-keyword: var(--dark-color-ts-keyword); - --color-ts-project: var(--dark-color-ts-project); - --color-ts-module: var(--dark-color-ts-module); - --color-ts-namespace: var(--dark-color-ts-namespace); - --color-ts-enum: var(--dark-color-ts-enum); - --color-ts-enum-member: var(--dark-color-ts-enum-member); - --color-ts-variable: var(--dark-color-ts-variable); - --color-ts-function: var(--dark-color-ts-function); - --color-ts-class: var(--dark-color-ts-class); - --color-ts-interface: var(--dark-color-ts-interface); - --color-ts-constructor: var(--dark-color-ts-constructor); - --color-ts-property: var(--dark-color-ts-property); - --color-ts-method: var(--dark-color-ts-method); - --color-ts-reference: var(--dark-color-ts-reference); - --color-ts-call-signature: var(--dark-color-ts-call-signature); - --color-ts-index-signature: var(--dark-color-ts-index-signature); - --color-ts-constructor-signature: var( - --dark-color-ts-constructor-signature - ); - --color-ts-parameter: var(--dark-color-ts-parameter); - --color-ts-type-parameter: var(--dark-color-ts-type-parameter); - --color-ts-accessor: var(--dark-color-ts-accessor); - --color-ts-get-signature: var(--dark-color-ts-get-signature); - --color-ts-set-signature: var(--dark-color-ts-set-signature); - --color-ts-type-alias: var(--dark-color-ts-type-alias); - --color-document: var(--dark-color-document); - - --external-icon: var(--dark-external-icon); - --color-scheme: var(--dark-color-scheme); -} + h1, + h2, + h3, + h4, + h5, + h6 { + line-height: 1.2; + } -*:focus-visible, -.tsd-accordion-summary:focus-visible svg { - outline: 2px solid var(--color-focus-outline); -} + h1 { + font-size: 1.875rem; + margin: 0.67rem 0; + } -.always-visible, -.always-visible .tsd-signatures { - display: inherit !important; -} + h2 { + font-size: 1.5rem; + margin: 0.83rem 0; + } -h1, -h2, -h3, -h4, -h5, -h6 { - line-height: 1.2; -} + h3 { + font-size: 1.25rem; + margin: 1rem 0; + } -h1 { - font-size: 1.875rem; - margin: 0.67rem 0; -} + h4 { + font-size: 1.05rem; + margin: 1.33rem 0; + } -h2 { - font-size: 1.5rem; - margin: 0.83rem 0; -} + h5 { + font-size: 1rem; + margin: 1.5rem 0; + } -h3 { - font-size: 1.25rem; - margin: 1rem 0; -} + h6 { + font-size: 0.875rem; + margin: 2.33rem 0; + } -h4 { - font-size: 1.05rem; - margin: 1.33rem 0; -} + dl, + menu, + ol, + ul { + margin: 1em 0; + } -h5 { - font-size: 1rem; - margin: 1.5rem 0; -} + dd { + margin: 0 0 0 34px; + } -h6 { - font-size: 0.875rem; - margin: 2.33rem 0; -} + .container { + max-width: 1700px; + padding: 0 2rem; + } -dl, -menu, -ol, -ul { - margin: 1em 0; -} + /* Footer */ + footer { + border-top: 1px solid var(--color-accent); + padding-top: 1rem; + padding-bottom: 1rem; + max-height: 3.5rem; + } + footer > p { + margin: 0 1em; + } -dd { - margin: 0 0 0 40px; -} + .container-main { + margin: 0 auto; + /* toolbar, footer, margin */ + min-height: calc(100vh - 41px - 56px - 4rem); + } -.container { - max-width: 1700px; - padding: 0 2rem; -} + @keyframes fade-in { + from { + opacity: 0; + } + to { + opacity: 1; + } + } + @keyframes fade-out { + from { + opacity: 1; + visibility: visible; + } + to { + opacity: 0; + } + } + @keyframes fade-in-delayed { + 0% { + opacity: 0; + } + 33% { + opacity: 0; + } + 100% { + opacity: 1; + } + } + @keyframes fade-out-delayed { + 0% { + opacity: 1; + visibility: visible; + } + 66% { + opacity: 0; + } + 100% { + opacity: 0; + } + } + @keyframes pop-in-from-right { + from { + transform: translate(100%, 0); + } + to { + transform: translate(0, 0); + } + } + @keyframes pop-out-to-right { + from { + transform: translate(0, 0); + visibility: visible; + } + to { + transform: translate(100%, 0); + } + } + body { + background: var(--color-background); + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", + Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; + font-size: 16px; + color: var(--color-text); + } -/* Footer */ -footer { - border-top: 1px solid var(--color-accent); - padding-top: 1rem; - padding-bottom: 1rem; - max-height: 3.5rem; -} -footer > p { - margin: 0 1em; -} + a { + color: var(--color-link); + text-decoration: none; + } + a:hover { + text-decoration: underline; + } + a.external[target="_blank"] { + background-image: var(--external-icon); + background-position: top 3px right; + background-repeat: no-repeat; + padding-right: 13px; + } + a.tsd-anchor-link { + color: var(--color-text); + } -.container-main { - margin: 0 auto; - /* toolbar, footer, margin */ - min-height: calc(100vh - 41px - 56px - 4rem); -} + code, + pre { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + padding: 0.2em; + margin: 0; + font-size: 0.875rem; + border-radius: 0.8em; + } -@keyframes fade-in { - from { + pre { + position: relative; + white-space: pre-wrap; + word-wrap: break-word; + padding: 10px; + border: 1px solid var(--color-accent); + margin-bottom: 8px; + } + pre code { + padding: 0; + font-size: 100%; + } + pre > button { + position: absolute; + top: 10px; + right: 10px; opacity: 0; + transition: opacity 0.1s; + box-sizing: border-box; } - to { + pre:hover > button, + pre > button.visible { opacity: 1; } -} -@keyframes fade-out { - from { - opacity: 1; - visibility: visible; + + blockquote { + margin: 1em 0; + padding-left: 1em; + border-left: 4px solid gray; } - to { - opacity: 0; + + .tsd-typography { + line-height: 1.333em; } -} -@keyframes fade-in-delayed { - 0% { - opacity: 0; + .tsd-typography ul { + list-style: square; + padding: 0 0 0 20px; + margin: 0; } - 33% { - opacity: 0; + .tsd-typography .tsd-index-panel h3, + .tsd-index-panel .tsd-typography h3, + .tsd-typography h4, + .tsd-typography h5, + .tsd-typography h6 { + font-size: 1em; } - 100% { - opacity: 1; + .tsd-typography h5, + .tsd-typography h6 { + font-weight: normal; } -} -@keyframes fade-out-delayed { - 0% { - opacity: 1; - visibility: visible; + .tsd-typography p, + .tsd-typography ul, + .tsd-typography ol { + margin: 1em 0; } - 66% { - opacity: 0; + .tsd-typography table { + border-collapse: collapse; + border: none; } - 100% { - opacity: 0; + .tsd-typography td, + .tsd-typography th { + padding: 6px 13px; + border: 1px solid var(--color-accent); } -} -@keyframes pop-in-from-right { - from { - transform: translate(100%, 0); + .tsd-typography thead, + .tsd-typography tr:nth-child(even) { + background-color: var(--color-background-secondary); } - to { - transform: translate(0, 0); + + .tsd-alert { + padding: 8px 16px; + margin-bottom: 16px; + border-left: 0.25em solid var(--alert-color); } -} -@keyframes pop-out-to-right { - from { - transform: translate(0, 0); - visibility: visible; + .tsd-alert blockquote > :last-child, + .tsd-alert > :last-child { + margin-bottom: 0; } - to { - transform: translate(100%, 0); + .tsd-alert-title { + color: var(--alert-color); + display: inline-flex; + align-items: center; + } + .tsd-alert-title span { + margin-left: 4px; } -} -body { - background: var(--color-background); - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", - Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; - font-size: 16px; - color: var(--color-text); -} -a { - color: var(--color-link); - text-decoration: none; -} -a:hover { - text-decoration: underline; -} -a.external[target="_blank"] { - background-image: var(--external-icon); - background-position: top 3px right; - background-repeat: no-repeat; - padding-right: 13px; -} -a.tsd-anchor-link { - color: var(--color-text); -} + .tsd-alert-note { + --alert-color: var(--color-alert-note); + } + .tsd-alert-tip { + --alert-color: var(--color-alert-tip); + } + .tsd-alert-important { + --alert-color: var(--color-alert-important); + } + .tsd-alert-warning { + --alert-color: var(--color-alert-warning); + } + .tsd-alert-caution { + --alert-color: var(--color-alert-caution); + } -code, -pre { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - padding: 0.2em; - margin: 0; - font-size: 0.875rem; - border-radius: 0.8em; -} + .tsd-breadcrumb { + margin: 0; + padding: 0; + color: var(--color-text-aside); + } + .tsd-breadcrumb a { + color: var(--color-text-aside); + text-decoration: none; + } + .tsd-breadcrumb a:hover { + text-decoration: underline; + } + .tsd-breadcrumb li { + display: inline; + } + .tsd-breadcrumb li:after { + content: " / "; + } -pre { - position: relative; - white-space: pre-wrap; - word-wrap: break-word; - padding: 10px; - border: 1px solid var(--color-accent); -} -pre code { - padding: 0; - font-size: 100%; -} -pre > button { - position: absolute; - top: 10px; - right: 10px; - opacity: 0; - transition: opacity 0.1s; - box-sizing: border-box; -} -pre:hover > button, -pre > button.visible { - opacity: 1; -} + .tsd-comment-tags { + display: flex; + flex-direction: column; + } + dl.tsd-comment-tag-group { + display: flex; + align-items: center; + overflow: hidden; + margin: 0.5em 0; + } + dl.tsd-comment-tag-group dt { + display: flex; + margin-right: 0.5em; + font-size: 0.875em; + font-weight: normal; + } + dl.tsd-comment-tag-group dd { + margin: 0; + } + code.tsd-tag { + padding: 0.25em 0.4em; + border: 0.1em solid var(--color-accent); + margin-right: 0.25em; + font-size: 70%; + } + h1 code.tsd-tag:first-of-type { + margin-left: 0.25em; + } -blockquote { - margin: 1em 0; - padding-left: 1em; - border-left: 4px solid gray; -} + dl.tsd-comment-tag-group dd:before, + dl.tsd-comment-tag-group dd:after { + content: " "; + } + dl.tsd-comment-tag-group dd pre, + dl.tsd-comment-tag-group dd:after { + clear: both; + } + dl.tsd-comment-tag-group p { + margin: 0; + } -.tsd-typography { - line-height: 1.333em; -} -.tsd-typography ul { - list-style: square; - padding: 0 0 0 20px; - margin: 0; -} -.tsd-typography .tsd-index-panel h3, -.tsd-index-panel .tsd-typography h3, -.tsd-typography h4, -.tsd-typography h5, -.tsd-typography h6 { - font-size: 1em; -} -.tsd-typography h5, -.tsd-typography h6 { - font-weight: normal; -} -.tsd-typography p, -.tsd-typography ul, -.tsd-typography ol { - margin: 1em 0; -} -.tsd-typography table { - border-collapse: collapse; - border: none; -} -.tsd-typography td, -.tsd-typography th { - padding: 6px 13px; - border: 1px solid var(--color-accent); -} -.tsd-typography thead, -.tsd-typography tr:nth-child(even) { - background-color: var(--color-background-secondary); -} + .tsd-panel.tsd-comment .lead { + font-size: 1.1em; + line-height: 1.333em; + margin-bottom: 2em; + } + .tsd-panel.tsd-comment .lead:last-child { + margin-bottom: 0; + } -.tsd-breadcrumb { - margin: 0; - padding: 0; - color: var(--color-text-aside); -} -.tsd-breadcrumb a { - color: var(--color-text-aside); - text-decoration: none; -} -.tsd-breadcrumb a:hover { - text-decoration: underline; -} -.tsd-breadcrumb li { - display: inline; -} -.tsd-breadcrumb li:after { - content: " / "; -} + .tsd-filter-visibility h4 { + font-size: 1rem; + padding-top: 0.75rem; + padding-bottom: 0.5rem; + margin: 0; + } + .tsd-filter-item:not(:last-child) { + margin-bottom: 0.5rem; + } + .tsd-filter-input { + display: flex; + width: -moz-fit-content; + width: fit-content; + align-items: center; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + cursor: pointer; + } + .tsd-filter-input input[type="checkbox"] { + cursor: pointer; + position: absolute; + width: 1.5em; + height: 1.5em; + opacity: 0; + } + .tsd-filter-input input[type="checkbox"]:disabled { + pointer-events: none; + } + .tsd-filter-input svg { + cursor: pointer; + width: 1.5em; + height: 1.5em; + margin-right: 0.5em; + border-radius: 0.33em; + /* Leaving this at full opacity breaks event listeners on Firefox. + Don't remove unless you know what you're doing. */ + opacity: 0.99; + } + .tsd-filter-input input[type="checkbox"]:focus-visible + svg { + outline: 2px solid var(--color-focus-outline); + } + .tsd-checkbox-background { + fill: var(--color-accent); + } + input[type="checkbox"]:checked ~ svg .tsd-checkbox-checkmark { + stroke: var(--color-text); + } + .tsd-filter-input input:disabled ~ svg > .tsd-checkbox-background { + fill: var(--color-background); + stroke: var(--color-accent); + stroke-width: 0.25rem; + } + .tsd-filter-input input:disabled ~ svg > .tsd-checkbox-checkmark { + stroke: var(--color-accent); + } -.tsd-comment-tags { - display: flex; - flex-direction: column; -} -dl.tsd-comment-tag-group { - display: flex; - align-items: center; - overflow: hidden; - margin: 0.5em 0; -} -dl.tsd-comment-tag-group dt { - display: flex; - margin-right: 0.5em; - font-size: 0.875em; - font-weight: normal; -} -dl.tsd-comment-tag-group dd { - margin: 0; -} -code.tsd-tag { - padding: 0.25em 0.4em; - border: 0.1em solid var(--color-accent); - margin-right: 0.25em; - font-size: 70%; -} -h1 code.tsd-tag:first-of-type { - margin-left: 0.25em; -} + .settings-label { + font-weight: bold; + text-transform: uppercase; + display: inline-block; + } -dl.tsd-comment-tag-group dd:before, -dl.tsd-comment-tag-group dd:after { - content: " "; -} -dl.tsd-comment-tag-group dd pre, -dl.tsd-comment-tag-group dd:after { - clear: both; -} -dl.tsd-comment-tag-group p { - margin: 0; -} + .tsd-filter-visibility .settings-label { + margin: 0.75rem 0 0.5rem 0; + } -.tsd-panel.tsd-comment .lead { - font-size: 1.1em; - line-height: 1.333em; - margin-bottom: 2em; -} -.tsd-panel.tsd-comment .lead:last-child { - margin-bottom: 0; -} + .tsd-theme-toggle .settings-label { + margin: 0.75rem 0.75rem 0 0; + } -.tsd-filter-visibility h4 { - font-size: 1rem; - padding-top: 0.75rem; - padding-bottom: 0.5rem; - margin: 0; -} -.tsd-filter-item:not(:last-child) { - margin-bottom: 0.5rem; -} -.tsd-filter-input { - display: flex; - width: -moz-fit-content; - width: fit-content; - align-items: center; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - cursor: pointer; -} -.tsd-filter-input input[type="checkbox"] { - cursor: pointer; - position: absolute; - width: 1.5em; - height: 1.5em; - opacity: 0; -} -.tsd-filter-input input[type="checkbox"]:disabled { - pointer-events: none; -} -.tsd-filter-input svg { - cursor: pointer; - width: 1.5em; - height: 1.5em; - margin-right: 0.5em; - border-radius: 0.33em; - /* Leaving this at full opacity breaks event listeners on Firefox. - Don't remove unless you know what you're doing. */ - opacity: 0.99; -} -.tsd-filter-input input[type="checkbox"]:focus-visible + svg { - outline: 2px solid var(--color-focus-outline); -} -.tsd-checkbox-background { - fill: var(--color-accent); -} -input[type="checkbox"]:checked ~ svg .tsd-checkbox-checkmark { - stroke: var(--color-text); -} -.tsd-filter-input input:disabled ~ svg > .tsd-checkbox-background { - fill: var(--color-background); - stroke: var(--color-accent); - stroke-width: 0.25rem; -} -.tsd-filter-input input:disabled ~ svg > .tsd-checkbox-checkmark { - stroke: var(--color-accent); -} + .tsd-hierarchy h4 label:hover span { + text-decoration: underline; + } -.settings-label { - font-weight: bold; - text-transform: uppercase; - display: inline-block; -} + .tsd-hierarchy { + list-style: square; + margin: 0; + } + .tsd-hierarchy-target { + font-weight: bold; + } + .tsd-hierarchy-toggle { + color: var(--color-link); + cursor: pointer; + } -.tsd-filter-visibility .settings-label { - margin: 0.75rem 0 0.5rem 0; -} + .tsd-full-hierarchy:not(:last-child) { + margin-bottom: 1em; + padding-bottom: 1em; + border-bottom: 1px solid var(--color-accent); + } + .tsd-full-hierarchy, + .tsd-full-hierarchy ul { + list-style: none; + margin: 0; + padding: 0; + } + .tsd-full-hierarchy ul { + padding-left: 1.5rem; + } + .tsd-full-hierarchy a { + padding: 0.25rem 0 !important; + font-size: 1rem; + display: inline-flex; + align-items: center; + color: var(--color-text); + } + .tsd-full-hierarchy svg[data-dropdown] { + cursor: pointer; + } + .tsd-full-hierarchy svg[data-dropdown="false"] { + transform: rotate(-90deg); + } + .tsd-full-hierarchy svg[data-dropdown="false"] ~ ul { + display: none; + } -.tsd-theme-toggle .settings-label { - margin: 0.75rem 0.75rem 0 0; -} + .tsd-panel-group.tsd-index-group { + margin-bottom: 0; + } + .tsd-index-panel .tsd-index-list { + list-style: none; + line-height: 1.333em; + margin: 0; + padding: 0.25rem 0 0 0; + overflow: hidden; + display: grid; + grid-template-columns: repeat(3, 1fr); + column-gap: 1rem; + grid-template-rows: auto; + } + @media (max-width: 1024px) { + .tsd-index-panel .tsd-index-list { + grid-template-columns: repeat(2, 1fr); + } + } + @media (max-width: 768px) { + .tsd-index-panel .tsd-index-list { + grid-template-columns: repeat(1, 1fr); + } + } + .tsd-index-panel .tsd-index-list li { + -webkit-page-break-inside: avoid; + -moz-page-break-inside: avoid; + -ms-page-break-inside: avoid; + -o-page-break-inside: avoid; + page-break-inside: avoid; + } -.tsd-hierarchy { - list-style: square; - margin: 0; -} -.tsd-hierarchy .target { - font-weight: bold; -} + .tsd-flag { + display: inline-block; + padding: 0.25em 0.4em; + border-radius: 4px; + color: var(--color-comment-tag-text); + background-color: var(--color-comment-tag); + text-indent: 0; + font-size: 75%; + line-height: 1; + font-weight: normal; + } -.tsd-full-hierarchy:not(:last-child) { - margin-bottom: 1em; - padding-bottom: 1em; - border-bottom: 1px solid var(--color-accent); -} -.tsd-full-hierarchy, -.tsd-full-hierarchy ul { - list-style: none; - margin: 0; - padding: 0; -} -.tsd-full-hierarchy ul { - padding-left: 1.5rem; -} -.tsd-full-hierarchy a { - padding: 0.25rem 0 !important; - font-size: 1rem; - display: inline-flex; - align-items: center; - color: var(--color-text); -} + .tsd-anchor { + position: relative; + top: -100px; + } -.tsd-panel-group.tsd-index-group { - margin-bottom: 0; -} -.tsd-index-panel .tsd-index-list { - list-style: none; - line-height: 1.333em; - margin: 0; - padding: 0.25rem 0 0 0; - overflow: hidden; - display: grid; - grid-template-columns: repeat(3, 1fr); - column-gap: 1rem; - grid-template-rows: auto; -} -@media (max-width: 1024px) { - .tsd-index-panel .tsd-index-list { - grid-template-columns: repeat(2, 1fr); + .tsd-member { + position: relative; } -} -@media (max-width: 768px) { - .tsd-index-panel .tsd-index-list { - grid-template-columns: repeat(1, 1fr); + .tsd-member .tsd-anchor + h3 { + display: flex; + align-items: center; + margin-top: 0; + margin-bottom: 0; + border-bottom: none; } -} -.tsd-index-panel .tsd-index-list li { - -webkit-page-break-inside: avoid; - -moz-page-break-inside: avoid; - -ms-page-break-inside: avoid; - -o-page-break-inside: avoid; - page-break-inside: avoid; -} -.tsd-flag { - display: inline-block; - padding: 0.25em 0.4em; - border-radius: 4px; - color: var(--color-comment-tag-text); - background-color: var(--color-comment-tag); - text-indent: 0; - font-size: 75%; - line-height: 1; - font-weight: normal; -} + .tsd-navigation.settings { + margin: 1rem 0; + } + .tsd-navigation > a, + .tsd-navigation .tsd-accordion-summary { + width: calc(100% - 0.25rem); + display: flex; + align-items: center; + } + .tsd-navigation a, + .tsd-navigation summary > span, + .tsd-page-navigation a { + display: flex; + width: calc(100% - 0.25rem); + align-items: center; + padding: 0.25rem; + color: var(--color-text); + text-decoration: none; + box-sizing: border-box; + } + .tsd-navigation a.current, + .tsd-page-navigation a.current { + background: var(--color-active-menu-item); + } + .tsd-navigation a:hover, + .tsd-page-navigation a:hover { + text-decoration: underline; + } + .tsd-navigation ul, + .tsd-page-navigation ul { + margin-top: 0; + margin-bottom: 0; + padding: 0; + list-style: none; + } + .tsd-navigation li, + .tsd-page-navigation li { + padding: 0; + max-width: 100%; + } + .tsd-navigation .tsd-nav-link { + display: none; + } + .tsd-nested-navigation { + margin-left: 3rem; + } + .tsd-nested-navigation > li > details { + margin-left: -1.5rem; + } + .tsd-small-nested-navigation { + margin-left: 1.5rem; + } + .tsd-small-nested-navigation > li > details { + margin-left: -1.5rem; + } -.tsd-anchor { - position: relative; - top: -100px; -} + .tsd-page-navigation-section { + margin-left: 10px; + } + .tsd-page-navigation-section > summary { + padding: 0.25rem; + } + .tsd-page-navigation-section > div { + margin-left: 20px; + } + .tsd-page-navigation ul { + padding-left: 1.75rem; + } -.tsd-member { - position: relative; -} -.tsd-member .tsd-anchor + h3 { - display: flex; - align-items: center; - margin-top: 0; - margin-bottom: 0; - border-bottom: none; -} + #tsd-sidebar-links a { + margin-top: 0; + margin-bottom: 0.5rem; + line-height: 1.25rem; + } + #tsd-sidebar-links a:last-of-type { + margin-bottom: 0; + } -.tsd-navigation.settings { - margin: 1rem 0; -} -.tsd-navigation > a, -.tsd-navigation .tsd-accordion-summary { - width: calc(100% - 0.25rem); - display: flex; - align-items: center; -} -.tsd-navigation a, -.tsd-navigation summary > span, -.tsd-page-navigation a { - display: flex; - width: calc(100% - 0.25rem); - align-items: center; - padding: 0.25rem; - color: var(--color-text); - text-decoration: none; - box-sizing: border-box; -} -.tsd-navigation a.current, -.tsd-page-navigation a.current { - background: var(--color-active-menu-item); -} -.tsd-navigation a:hover, -.tsd-page-navigation a:hover { - text-decoration: underline; -} -.tsd-navigation ul, -.tsd-page-navigation ul { - margin-top: 0; - margin-bottom: 0; - padding: 0; - list-style: none; -} -.tsd-navigation li, -.tsd-page-navigation li { - padding: 0; - max-width: 100%; -} -.tsd-navigation .tsd-nav-link { - display: none; -} -.tsd-nested-navigation { - margin-left: 3rem; -} -.tsd-nested-navigation > li > details { - margin-left: -1.5rem; -} -.tsd-small-nested-navigation { - margin-left: 1.5rem; -} -.tsd-small-nested-navigation > li > details { - margin-left: -1.5rem; -} - -.tsd-page-navigation-section { - margin-left: 10px; -} -.tsd-page-navigation-section > summary { - padding: 0.25rem; -} -.tsd-page-navigation-section > div { - margin-left: 20px; -} -.tsd-page-navigation ul { - padding-left: 1.75rem; -} - -#tsd-sidebar-links a { - margin-top: 0; - margin-bottom: 0.5rem; - line-height: 1.25rem; -} -#tsd-sidebar-links a:last-of-type { - margin-bottom: 0; -} - -a.tsd-index-link { - padding: 0.25rem 0 !important; - font-size: 1rem; - line-height: 1.25rem; - display: inline-flex; - align-items: center; - color: var(--color-text); -} -.tsd-accordion-summary { - list-style-type: none; /* hide marker on non-safari */ - outline: none; /* broken on safari, so just hide it */ -} -.tsd-accordion-summary::-webkit-details-marker { - display: none; /* hide marker on safari */ -} -.tsd-accordion-summary, -.tsd-accordion-summary a { - -moz-user-select: none; - -webkit-user-select: none; - -ms-user-select: none; - user-select: none; - - cursor: pointer; -} -.tsd-accordion-summary a { - width: calc(100% - 1.5rem); -} -.tsd-accordion-summary > * { - margin-top: 0; - margin-bottom: 0; - padding-top: 0; - padding-bottom: 0; -} -.tsd-accordion .tsd-accordion-summary > svg { - margin-left: 0.25rem; - vertical-align: text-top; -} -.tsd-index-content > :not(:first-child) { - margin-top: 0.75rem; -} -.tsd-index-heading { - margin-top: 1.5rem; - margin-bottom: 0.75rem; -} - -.tsd-no-select { - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.tsd-kind-icon { - margin-right: 0.5rem; - width: 1.25rem; - height: 1.25rem; - min-width: 1.25rem; - min-height: 1.25rem; -} -.tsd-signature > .tsd-kind-icon { - margin-right: 0.8rem; -} - -.tsd-panel { - margin-bottom: 2.5rem; -} -.tsd-panel.tsd-member { - margin-bottom: 4rem; -} -.tsd-panel:empty { - display: none; -} -.tsd-panel > h1, -.tsd-panel > h2, -.tsd-panel > h3 { - margin: 1.5rem -1.5rem 0.75rem -1.5rem; - padding: 0 1.5rem 0.75rem 1.5rem; -} -.tsd-panel > h1.tsd-before-signature, -.tsd-panel > h2.tsd-before-signature, -.tsd-panel > h3.tsd-before-signature { - margin-bottom: 0; - border-bottom: none; -} - -.tsd-panel-group { - margin: 2rem 0; -} -.tsd-panel-group.tsd-index-group { - margin: 2rem 0; -} -.tsd-panel-group.tsd-index-group details { - margin: 2rem 0; -} -.tsd-panel-group > .tsd-accordion-summary { - margin-bottom: 1rem; -} - -#tsd-search { - transition: background-color 0.2s; -} -#tsd-search .title { - position: relative; - z-index: 2; -} -#tsd-search .field { - position: absolute; - left: 0; - top: 0; - right: 2.5rem; - height: 100%; -} -#tsd-search .field input { - box-sizing: border-box; - position: relative; - top: -50px; - z-index: 1; - width: 100%; - padding: 0 10px; - opacity: 0; - outline: 0; - border: 0; - background: transparent; - color: var(--color-text); -} -#tsd-search .field label { - position: absolute; - overflow: hidden; - right: -40px; -} -#tsd-search .field input, -#tsd-search .title, -#tsd-toolbar-links a { - transition: opacity 0.2s; -} -#tsd-search .results { - position: absolute; - visibility: hidden; - top: 40px; - width: 100%; - margin: 0; - padding: 0; - list-style: none; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); -} -#tsd-search .results li { - background-color: var(--color-background); - line-height: initial; - padding: 4px; -} -#tsd-search .results li:nth-child(even) { - background-color: var(--color-background-secondary); -} -#tsd-search .results li.state { - display: none; -} -#tsd-search .results li.current:not(.no-results), -#tsd-search .results li:hover:not(.no-results) { - background-color: var(--color-accent); -} -#tsd-search .results a { - display: flex; - align-items: center; - padding: 0.25rem; - box-sizing: border-box; -} -#tsd-search .results a:before { - top: 10px; -} -#tsd-search .results span.parent { - color: var(--color-text-aside); - font-weight: normal; -} -#tsd-search.has-focus { - background-color: var(--color-accent); -} -#tsd-search.has-focus .field input { - top: 0; - opacity: 1; -} -#tsd-search.has-focus .title, -#tsd-search.has-focus #tsd-toolbar-links a { - z-index: 0; - opacity: 0; -} -#tsd-search.has-focus .results { - visibility: visible; -} -#tsd-search.loading .results li.state.loading { - display: block; -} -#tsd-search.failure .results li.state.failure { - display: block; -} - -#tsd-toolbar-links { - position: absolute; - top: 0; - right: 2rem; - height: 100%; - display: flex; - align-items: center; - justify-content: flex-end; -} -#tsd-toolbar-links a { - margin-left: 1.5rem; -} -#tsd-toolbar-links a:hover { - text-decoration: underline; -} - -.tsd-signature { - margin: 0 0 1rem 0; - padding: 1rem 0.5rem; - border: 1px solid var(--color-accent); - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - font-size: 14px; - overflow-x: auto; -} - -.tsd-signature-keyword { - color: var(--color-ts-keyword); - font-weight: normal; -} - -.tsd-signature-symbol { - color: var(--color-text-aside); - font-weight: normal; -} - -.tsd-signature-type { - font-style: italic; - font-weight: normal; -} - -.tsd-signatures { - padding: 0; - margin: 0 0 1em 0; - list-style-type: none; -} -.tsd-signatures .tsd-signature { - margin: 0; - border-color: var(--color-accent); - border-width: 1px 0; - transition: background-color 0.1s; -} -.tsd-signatures .tsd-index-signature:not(:last-child) { - margin-bottom: 1em; -} -.tsd-signatures .tsd-index-signature .tsd-signature { - border-width: 1px; -} -.tsd-description .tsd-signatures .tsd-signature { - border-width: 1px; -} - -ul.tsd-parameter-list, -ul.tsd-type-parameter-list { - list-style: square; - margin: 0; - padding-left: 20px; -} -ul.tsd-parameter-list > li.tsd-parameter-signature, -ul.tsd-type-parameter-list > li.tsd-parameter-signature { - list-style: none; - margin-left: -20px; -} -ul.tsd-parameter-list h5, -ul.tsd-type-parameter-list h5 { - font-size: 16px; - margin: 1em 0 0.5em 0; -} -.tsd-sources { - margin-top: 1rem; - font-size: 0.875em; -} -.tsd-sources a { - color: var(--color-text-aside); - text-decoration: underline; -} -.tsd-sources ul { - list-style: none; - padding: 0; -} - -.tsd-page-toolbar { - position: sticky; - z-index: 1; - top: 0; - left: 0; - width: 100%; - color: var(--color-text); - background: var(--color-background-secondary); - border-bottom: 1px var(--color-accent) solid; - transition: transform 0.3s ease-in-out; -} -.tsd-page-toolbar a { - color: var(--color-text); - text-decoration: none; -} -.tsd-page-toolbar a.title { - font-weight: bold; -} -.tsd-page-toolbar a.title:hover { - text-decoration: underline; -} -.tsd-page-toolbar .tsd-toolbar-contents { - display: flex; - justify-content: space-between; - height: 2.5rem; - margin: 0 auto; -} -.tsd-page-toolbar .table-cell { - position: relative; - white-space: nowrap; - line-height: 40px; -} -.tsd-page-toolbar .table-cell:first-child { - width: 100%; -} -.tsd-page-toolbar .tsd-toolbar-icon { - box-sizing: border-box; - line-height: 0; - padding: 12px 0; -} - -.tsd-widget { - display: inline-block; - overflow: hidden; - opacity: 0.8; - height: 40px; - transition: - opacity 0.1s, - background-color 0.2s; - vertical-align: bottom; - cursor: pointer; -} -.tsd-widget:hover { - opacity: 0.9; -} -.tsd-widget.active { - opacity: 1; - background-color: var(--color-accent); -} -.tsd-widget.no-caption { - width: 40px; -} -.tsd-widget.no-caption:before { - margin: 0; -} + a.tsd-index-link { + padding: 0.25rem 0 !important; + font-size: 1rem; + line-height: 1.25rem; + display: inline-flex; + align-items: center; + color: var(--color-text); + } + .tsd-accordion-summary { + list-style-type: none; /* hide marker on non-safari */ + outline: none; /* broken on safari, so just hide it */ + } + .tsd-accordion-summary::-webkit-details-marker { + display: none; /* hide marker on safari */ + } + .tsd-accordion-summary, + .tsd-accordion-summary a { + -moz-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + + cursor: pointer; + } + .tsd-accordion-summary a { + width: calc(100% - 1.5rem); + } + .tsd-accordion-summary > * { + margin-top: 0; + margin-bottom: 0; + padding-top: 0; + padding-bottom: 0; + } + .tsd-accordion .tsd-accordion-summary > svg { + margin-left: 0.25rem; + vertical-align: text-top; + } + /* + We need to be careful to target the arrow indicating whether the accordion + is open, but not any other SVGs included in the details element. +*/ + .tsd-accordion:not([open]) > .tsd-accordion-summary > svg:first-child, + .tsd-accordion:not([open]) > .tsd-accordion-summary > h1 > svg:first-child, + .tsd-accordion:not([open]) > .tsd-accordion-summary > h2 > svg:first-child, + .tsd-accordion:not([open]) > .tsd-accordion-summary > h3 > svg:first-child, + .tsd-accordion:not([open]) > .tsd-accordion-summary > h4 > svg:first-child { + transform: rotate(-90deg); + } + .tsd-index-content > :not(:first-child) { + margin-top: 0.75rem; + } + .tsd-index-heading { + margin-top: 1.5rem; + margin-bottom: 0.75rem; + } -.tsd-widget.options, -.tsd-widget.menu { - display: none; -} -input[type="checkbox"] + .tsd-widget:before { - background-position: -120px 0; -} -input[type="checkbox"]:checked + .tsd-widget:before { - background-position: -160px 0; -} + .tsd-no-select { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + .tsd-kind-icon { + margin-right: 0.5rem; + width: 1.25rem; + height: 1.25rem; + min-width: 1.25rem; + min-height: 1.25rem; + } + .tsd-signature > .tsd-kind-icon { + margin-right: 0.8rem; + } -img { - max-width: 100%; -} + .tsd-panel { + margin-bottom: 2.5rem; + } + .tsd-panel.tsd-member { + margin-bottom: 4rem; + } + .tsd-panel:empty { + display: none; + } + .tsd-panel > h1, + .tsd-panel > h2, + .tsd-panel > h3 { + margin: 1.5rem -1.5rem 0.75rem -1.5rem; + padding: 0 1.5rem 0.75rem 1.5rem; + } + .tsd-panel > h1.tsd-before-signature, + .tsd-panel > h2.tsd-before-signature, + .tsd-panel > h3.tsd-before-signature { + margin-bottom: 0; + border-bottom: none; + } -.tsd-anchor-icon { - display: inline-flex; - align-items: center; - margin-left: 0.5rem; - vertical-align: middle; - color: var(--color-text); -} + .tsd-panel-group { + margin: 2rem 0; + } + .tsd-panel-group.tsd-index-group { + margin: 2rem 0; + } + .tsd-panel-group.tsd-index-group details { + margin: 2rem 0; + } + .tsd-panel-group > .tsd-accordion-summary { + margin-bottom: 1rem; + } -.tsd-anchor-icon svg { - width: 1em; - height: 1em; - visibility: hidden; -} + #tsd-search { + transition: background-color 0.2s; + } + #tsd-search .title { + position: relative; + z-index: 2; + } + #tsd-search .field { + position: absolute; + left: 0; + top: 0; + right: 2.5rem; + height: 100%; + } + #tsd-search .field input { + box-sizing: border-box; + position: relative; + top: -50px; + z-index: 1; + width: 100%; + padding: 0 10px; + opacity: 0; + outline: 0; + border: 0; + background: transparent; + color: var(--color-text); + } + #tsd-search .field label { + position: absolute; + overflow: hidden; + right: -40px; + } + #tsd-search .field input, + #tsd-search .title, + #tsd-toolbar-links a { + transition: opacity 0.2s; + } + #tsd-search .results { + position: absolute; + visibility: hidden; + top: 40px; + width: 100%; + margin: 0; + padding: 0; + list-style: none; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + } + #tsd-search .results li { + background-color: var(--color-background); + line-height: initial; + padding: 4px; + } + #tsd-search .results li:nth-child(even) { + background-color: var(--color-background-secondary); + } + #tsd-search .results li.state { + display: none; + } + #tsd-search .results li.current:not(.no-results), + #tsd-search .results li:hover:not(.no-results) { + background-color: var(--color-accent); + } + #tsd-search .results a { + display: flex; + align-items: center; + padding: 0.25rem; + box-sizing: border-box; + } + #tsd-search .results a:before { + top: 10px; + } + #tsd-search .results span.parent { + color: var(--color-text-aside); + font-weight: normal; + } + #tsd-search.has-focus { + background-color: var(--color-accent); + } + #tsd-search.has-focus .field input { + top: 0; + opacity: 1; + } + #tsd-search.has-focus .title, + #tsd-search.has-focus #tsd-toolbar-links a { + z-index: 0; + opacity: 0; + } + #tsd-search.has-focus .results { + visibility: visible; + } + #tsd-search.loading .results li.state.loading { + display: block; + } + #tsd-search.failure .results li.state.failure { + display: block; + } -.tsd-anchor-link:hover > .tsd-anchor-icon svg { - visibility: visible; -} + #tsd-toolbar-links { + position: absolute; + top: 0; + right: 2rem; + height: 100%; + display: flex; + align-items: center; + justify-content: flex-end; + } + #tsd-toolbar-links a { + margin-left: 1.5rem; + } + #tsd-toolbar-links a:hover { + text-decoration: underline; + } -.deprecated { - text-decoration: line-through !important; -} + .tsd-signature { + margin: 0 0 1rem 0; + padding: 1rem 0.5rem; + border: 1px solid var(--color-accent); + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + font-size: 14px; + overflow-x: auto; + } -.warning { - padding: 1rem; - color: var(--color-warning-text); - background: var(--color-background-warning); -} + .tsd-signature-keyword { + color: var(--color-ts-keyword); + font-weight: normal; + } -.tsd-kind-project { - color: var(--color-ts-project); -} -.tsd-kind-module { - color: var(--color-ts-module); -} -.tsd-kind-namespace { - color: var(--color-ts-namespace); -} -.tsd-kind-enum { - color: var(--color-ts-enum); -} -.tsd-kind-enum-member { - color: var(--color-ts-enum-member); -} -.tsd-kind-variable { - color: var(--color-ts-variable); -} -.tsd-kind-function { - color: var(--color-ts-function); -} -.tsd-kind-class { - color: var(--color-ts-class); -} -.tsd-kind-interface { - color: var(--color-ts-interface); -} -.tsd-kind-constructor { - color: var(--color-ts-constructor); -} -.tsd-kind-property { - color: var(--color-ts-property); -} -.tsd-kind-method { - color: var(--color-ts-method); -} -.tsd-kind-reference { - color: var(--color-ts-reference); -} -.tsd-kind-call-signature { - color: var(--color-ts-call-signature); -} -.tsd-kind-index-signature { - color: var(--color-ts-index-signature); -} -.tsd-kind-constructor-signature { - color: var(--color-ts-constructor-signature); -} -.tsd-kind-parameter { - color: var(--color-ts-parameter); -} -.tsd-kind-type-parameter { - color: var(--color-ts-type-parameter); -} -.tsd-kind-accessor { - color: var(--color-ts-accessor); -} -.tsd-kind-get-signature { - color: var(--color-ts-get-signature); -} -.tsd-kind-set-signature { - color: var(--color-ts-set-signature); -} -.tsd-kind-type-alias { - color: var(--color-ts-type-alias); -} + .tsd-signature-symbol { + color: var(--color-text-aside); + font-weight: normal; + } -/* if we have a kind icon, don't color the text by kind */ -.tsd-kind-icon ~ span { - color: var(--color-text); -} + .tsd-signature-type { + font-style: italic; + font-weight: normal; + } -* { - scrollbar-width: thin; - scrollbar-color: var(--color-accent) var(--color-icon-background); -} + .tsd-signatures { + padding: 0; + margin: 0 0 1em 0; + list-style-type: none; + } + .tsd-signatures .tsd-signature { + margin: 0; + border-color: var(--color-accent); + border-width: 1px 0; + transition: background-color 0.1s; + } + .tsd-signatures .tsd-index-signature:not(:last-child) { + margin-bottom: 1em; + } + .tsd-signatures .tsd-index-signature .tsd-signature { + border-width: 1px; + } + .tsd-description .tsd-signatures .tsd-signature { + border-width: 1px; + } -*::-webkit-scrollbar { - width: 0.75rem; -} + ul.tsd-parameter-list, + ul.tsd-type-parameter-list { + list-style: square; + margin: 0; + padding-left: 20px; + } + ul.tsd-parameter-list > li.tsd-parameter-signature, + ul.tsd-type-parameter-list > li.tsd-parameter-signature { + list-style: none; + margin-left: -20px; + } + ul.tsd-parameter-list h5, + ul.tsd-type-parameter-list h5 { + font-size: 16px; + margin: 1em 0 0.5em 0; + } + .tsd-sources { + margin-top: 1rem; + font-size: 0.875em; + } + .tsd-sources a { + color: var(--color-text-aside); + text-decoration: underline; + } + .tsd-sources ul { + list-style: none; + padding: 0; + } -*::-webkit-scrollbar-track { - background: var(--color-icon-background); -} + .tsd-page-toolbar { + position: sticky; + z-index: 1; + top: 0; + left: 0; + width: 100%; + color: var(--color-text); + background: var(--color-background-secondary); + border-bottom: 1px var(--color-accent) solid; + transition: transform 0.3s ease-in-out; + } + .tsd-page-toolbar a { + color: var(--color-text); + text-decoration: none; + } + .tsd-page-toolbar a.title { + font-weight: bold; + } + .tsd-page-toolbar a.title:hover { + text-decoration: underline; + } + .tsd-page-toolbar .tsd-toolbar-contents { + display: flex; + justify-content: space-between; + height: 2.5rem; + margin: 0 auto; + } + .tsd-page-toolbar .table-cell { + position: relative; + white-space: nowrap; + line-height: 40px; + } + .tsd-page-toolbar .table-cell:first-child { + width: 100%; + } + .tsd-page-toolbar .tsd-toolbar-icon { + box-sizing: border-box; + line-height: 0; + padding: 12px 0; + } -*::-webkit-scrollbar-thumb { - background-color: var(--color-accent); - border-radius: 999rem; - border: 0.25rem solid var(--color-icon-background); -} + .tsd-widget { + display: inline-block; + overflow: hidden; + opacity: 0.8; + height: 40px; + transition: + opacity 0.1s, + background-color 0.2s; + vertical-align: bottom; + cursor: pointer; + } + .tsd-widget:hover { + opacity: 0.9; + } + .tsd-widget.active { + opacity: 1; + background-color: var(--color-accent); + } + .tsd-widget.no-caption { + width: 40px; + } + .tsd-widget.no-caption:before { + margin: 0; + } -/* mobile */ -@media (max-width: 769px) { .tsd-widget.options, .tsd-widget.menu { - display: inline-block; + display: none; } - - .container-main { - display: flex; + input[type="checkbox"] + .tsd-widget:before { + background-position: -120px 0; + } + input[type="checkbox"]:checked + .tsd-widget:before { + background-position: -160px 0; } - html .col-content { - float: none; + + img { max-width: 100%; - width: 100%; } - html .col-sidebar { - position: fixed !important; - overflow-y: auto; - -webkit-overflow-scrolling: touch; - z-index: 1024; - top: 0 !important; - bottom: 0 !important; - left: auto !important; - right: 0 !important; - padding: 1.5rem 1.5rem 0 0; - width: 75vw; - visibility: hidden; - background-color: var(--color-background); - transform: translate(100%, 0); + + .tsd-member-summary-name { + display: inline-flex; + align-items: center; + padding: 0.25rem; + text-decoration: none; } - html .col-sidebar > *:last-child { - padding-bottom: 20px; + + .tsd-anchor-icon { + display: inline-flex; + align-items: center; + margin-left: 0.5rem; + color: var(--color-text); } - html .overlay { - content: ""; - display: block; - position: fixed; - z-index: 1023; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: rgba(0, 0, 0, 0.75); + + .tsd-anchor-icon svg { + width: 1em; + height: 1em; visibility: hidden; } - .to-has-menu .overlay { - animation: fade-in 0.4s; + .tsd-member-summary-name:hover > .tsd-anchor-icon svg, + .tsd-anchor-link:hover > .tsd-anchor-icon svg { + visibility: visible; } - .to-has-menu .col-sidebar { - animation: pop-in-from-right 0.4s; + .deprecated { + text-decoration: line-through !important; } - .from-has-menu .overlay { - animation: fade-out 0.4s; + .warning { + padding: 1rem; + color: var(--color-warning-text); + background: var(--color-background-warning); } - .from-has-menu .col-sidebar { - animation: pop-out-to-right 0.4s; + .tsd-kind-project { + color: var(--color-ts-project); } - - .has-menu body { - overflow: hidden; + .tsd-kind-module { + color: var(--color-ts-module); } - .has-menu .overlay { - visibility: visible; + .tsd-kind-namespace { + color: var(--color-ts-namespace); } - .has-menu .col-sidebar { - visibility: visible; - transform: translate(0, 0); - display: flex; - flex-direction: column; - gap: 1.5rem; - max-height: 100vh; - padding: 1rem 2rem; + .tsd-kind-enum { + color: var(--color-ts-enum); } - .has-menu .tsd-navigation { - max-height: 100%; + .tsd-kind-enum-member { + color: var(--color-ts-enum-member); } - #tsd-toolbar-links { - display: none; + .tsd-kind-variable { + color: var(--color-ts-variable); } - .tsd-navigation .tsd-nav-link { - display: flex; + .tsd-kind-function { + color: var(--color-ts-function); } -} - -/* one sidebar */ -@media (min-width: 770px) { - .container-main { - display: grid; - grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); - grid-template-areas: "sidebar content"; - margin: 2rem auto; + .tsd-kind-class { + color: var(--color-ts-class); } - - .col-sidebar { - grid-area: sidebar; + .tsd-kind-interface { + color: var(--color-ts-interface); } - .col-content { - grid-area: content; - padding: 0 1rem; + .tsd-kind-constructor { + color: var(--color-ts-constructor); } -} -@media (min-width: 770px) and (max-width: 1399px) { - .col-sidebar { - max-height: calc(100vh - 2rem - 42px); - overflow: auto; - position: sticky; - top: 42px; - padding-top: 1rem; + .tsd-kind-property { + color: var(--color-ts-property); } - .site-menu { - margin-top: 1rem; + .tsd-kind-method { + color: var(--color-ts-method); + } + .tsd-kind-reference { + color: var(--color-ts-reference); + } + .tsd-kind-call-signature { + color: var(--color-ts-call-signature); + } + .tsd-kind-index-signature { + color: var(--color-ts-index-signature); + } + .tsd-kind-constructor-signature { + color: var(--color-ts-constructor-signature); + } + .tsd-kind-parameter { + color: var(--color-ts-parameter); + } + .tsd-kind-type-parameter { + color: var(--color-ts-type-parameter); + } + .tsd-kind-accessor { + color: var(--color-ts-accessor); + } + .tsd-kind-get-signature { + color: var(--color-ts-get-signature); + } + .tsd-kind-set-signature { + color: var(--color-ts-set-signature); + } + .tsd-kind-type-alias { + color: var(--color-ts-type-alias); } -} -/* two sidebars */ -@media (min-width: 1200px) { - .container-main { - grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) minmax(0, 20rem); - grid-template-areas: "sidebar content toc"; + /* if we have a kind icon, don't color the text by kind */ + .tsd-kind-icon ~ span { + color: var(--color-text); } - .col-sidebar { - display: contents; + * { + scrollbar-width: thin; + scrollbar-color: var(--color-accent) var(--color-icon-background); } - .page-menu { - grid-area: toc; - padding-left: 1rem; + *::-webkit-scrollbar { + width: 0.75rem; } - .site-menu { - grid-area: sidebar; + + *::-webkit-scrollbar-track { + background: var(--color-icon-background); } - .site-menu { - margin-top: 1rem; + *::-webkit-scrollbar-thumb { + background-color: var(--color-accent); + border-radius: 999rem; + border: 0.25rem solid var(--color-icon-background); } - .page-menu, - .site-menu { - max-height: calc(100vh - 2rem - 42px); - overflow: auto; - position: sticky; - top: 42px; + /* mobile */ + @media (max-width: 769px) { + .tsd-widget.options, + .tsd-widget.menu { + display: inline-block; + } + + .container-main { + display: flex; + } + html .col-content { + float: none; + max-width: 100%; + width: 100%; + } + html .col-sidebar { + position: fixed !important; + overflow-y: auto; + -webkit-overflow-scrolling: touch; + z-index: 1024; + top: 0 !important; + bottom: 0 !important; + left: auto !important; + right: 0 !important; + padding: 1.5rem 1.5rem 0 0; + width: 75vw; + visibility: hidden; + background-color: var(--color-background); + transform: translate(100%, 0); + } + html .col-sidebar > *:last-child { + padding-bottom: 20px; + } + html .overlay { + content: ""; + display: block; + position: fixed; + z-index: 1023; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.75); + visibility: hidden; + } + + .to-has-menu .overlay { + animation: fade-in 0.4s; + } + + .to-has-menu .col-sidebar { + animation: pop-in-from-right 0.4s; + } + + .from-has-menu .overlay { + animation: fade-out 0.4s; + } + + .from-has-menu .col-sidebar { + animation: pop-out-to-right 0.4s; + } + + .has-menu body { + overflow: hidden; + } + .has-menu .overlay { + visibility: visible; + } + .has-menu .col-sidebar { + visibility: visible; + transform: translate(0, 0); + display: flex; + flex-direction: column; + gap: 1.5rem; + max-height: 100vh; + padding: 1rem 2rem; + } + .has-menu .tsd-navigation { + max-height: 100%; + } + #tsd-toolbar-links { + display: none; + } + .tsd-navigation .tsd-nav-link { + display: flex; + } + } + + /* one sidebar */ + @media (min-width: 770px) { + .container-main { + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); + grid-template-areas: "sidebar content"; + margin: 2rem auto; + } + + .col-sidebar { + grid-area: sidebar; + } + .col-content { + grid-area: content; + padding: 0 1rem; + } + } + @media (min-width: 770px) and (max-width: 1399px) { + .col-sidebar { + max-height: calc(100vh - 2rem - 42px); + overflow: auto; + position: sticky; + top: 42px; + padding-top: 1rem; + } + .site-menu { + margin-top: 1rem; + } + } + + /* two sidebars */ + @media (min-width: 1200px) { + .container-main { + grid-template-columns: minmax(0, 1fr) minmax(0, 2.5fr) minmax( + 0, + 20rem + ); + grid-template-areas: "sidebar content toc"; + } + + .col-sidebar { + display: contents; + } + + .page-menu { + grid-area: toc; + padding-left: 1rem; + } + .site-menu { + grid-area: sidebar; + } + + .site-menu { + margin-top: 1rem; + } + + .page-menu, + .site-menu { + max-height: calc(100vh - 2rem - 42px); + overflow: auto; + position: sticky; + top: 42px; + } } } diff --git a/docs/classes/HOTP.html b/docs/classes/HOTP.html index 238ce28..d38b903 100644 --- a/docs/classes/HOTP.html +++ b/docs/classes/HOTP.html @@ -1,62 +1,62 @@ -HOTP | otpauth

Class HOTP

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

-

Constructors

constructor +HOTP | otpauth

Class HOTP

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

+

Constructors

  • Creates an HOTP object.

    -

    Parameters

    • Optionalconfig: {
          algorithm: undefined | string;
          counter: undefined | number;
          digits: undefined | number;
          issuer: undefined | string;
          issuerInLabel: undefined | boolean;
          label: undefined | string;
          secret: undefined | string | Secret;
      } = {}

      Configuration options.

      -
      • algorithm: undefined | string

        HMAC hashing algorithm.

        -
      • counter: undefined | number

        Initial counter value.

        -
      • digits: undefined | number

        Token length.

        -
      • issuer: undefined | string

        Account provider.

        -
      • issuerInLabel: undefined | boolean

        Include issuer prefix in label.

        -
      • label: undefined | string

        Account label.

        -
      • secret: undefined | string | Secret

        Secret key.

        -

    Returns HOTP

Properties

algorithm: string

HMAC hashing algorithm.

-
counter: number

Initial counter value.

-
digits: number

Token length.

-
issuer: string

Account provider.

-
issuerInLabel: boolean

Include issuer prefix in label.

-
label: string

Account label.

-
secret: Secret

Secret key.

-

Accessors

  • get defaults(): {
        algorithm: string;
        counter: number;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        window: number;
    }
  • Default configuration.

    -

    Returns {
        algorithm: string;
        counter: number;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        window: number;
    }

    • algorithm: string
    • counter: number
    • digits: number
    • issuer: string
    • issuerInLabel: boolean
    • label: string
    • window: number

Methods

  • Generates an HOTP token.

    -

    Parameters

    • Optionalconfig: {
          counter: undefined | number;
      } = {}

      Configuration options.

      -
      • counter: undefined | number

        Counter value.

        +

Constructors

  • Creates an HOTP object.

    +

    Parameters

    • Optionalconfig: {
          algorithm?: string;
          counter?: number;
          digits?: number;
          issuer?: string;
          issuerInLabel?: boolean;
          label?: string;
          secret?: string | Secret;
      } = {}

      Configuration options.

      +
      • Optionalalgorithm?: string

        HMAC hashing algorithm.

        +
      • Optionalcounter?: number

        Initial counter value.

        +
      • Optionaldigits?: number

        Token length.

        +
      • Optionalissuer?: string

        Account provider.

        +
      • OptionalissuerInLabel?: boolean

        Include issuer prefix in label.

        +
      • Optionallabel?: string

        Account label.

        +
      • Optionalsecret?: string | Secret

        Secret key.

        +

    Returns HOTP

Properties

algorithm: string

HMAC hashing algorithm.

+
counter: number

Initial counter value.

+
digits: number

Token length.

+
issuer: string

Account provider.

+
issuerInLabel: boolean

Include issuer prefix in label.

+
label: string

Account label.

+
secret: Secret

Secret key.

+

Accessors

  • get defaults(): {
        algorithm: string;
        counter: number;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        window: number;
    }
  • Default configuration.

    +

    Returns {
        algorithm: string;
        counter: number;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        window: number;
    }

Methods

  • Generates an HOTP token.

    +

    Parameters

    • Optionalconfig: { counter?: number } = {}

      Configuration options.

      +
      • Optionalcounter?: number

        Counter value.

    Returns string

    Token.

    -
  • Returns a Google Authenticator key URI.

    +
  • Returns a Google Authenticator key URI.

    Returns string

    URI.

    -
  • Validates an HOTP token.

    -

    Parameters

    • config: {
          counter: undefined | number;
          token: string;
          window: undefined | number;
      }

      Configuration options.

      -
      • counter: undefined | number

        Counter value.

        -
      • token: string

        Token value.

        -
      • window: undefined | number

        Window of counter values to test.

        -

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    -
  • Generates an HOTP token.

    -

    Parameters

    • config: {
          algorithm: undefined | string;
          counter: undefined | number;
          digits: undefined | number;
          secret: Secret;
      }

      Configuration options.

      -
      • algorithm: undefined | string

        HMAC hashing algorithm.

        -
      • counter: undefined | number

        Counter value.

        -
      • digits: undefined | number

        Token length.

        -
      • secret: Secret

        Secret key.

        +
  • Validates an HOTP token.

    +

    Parameters

    • config: { counter?: number; token: string; window?: number }

      Configuration options.

      +
      • Optionalcounter?: number

        Counter value.

        +
      • token: string

        Token value.

        +
      • Optionalwindow?: number

        Window of counter values to test.

        +

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    +
  • Generates an HOTP token.

    +

    Parameters

    • config: { algorithm?: string; counter?: number; digits?: number; secret: Secret }

      Configuration options.

      +
      • Optionalalgorithm?: string

        HMAC hashing algorithm.

        +
      • Optionalcounter?: number

        Counter value.

        +
      • Optionaldigits?: number

        Token length.

        +
      • secret: Secret

        Secret key.

    Returns string

    Token.

    -
  • Validates an HOTP token.

    -

    Parameters

    • config: {
          algorithm: undefined | string;
          counter: undefined | number;
          digits: undefined | number;
          secret: Secret;
          token: string;
          window: undefined | number;
      }

      Configuration options.

      -
      • algorithm: undefined | string

        HMAC hashing algorithm.

        -
      • counter: undefined | number

        Counter value.

        -
      • digits: undefined | number

        Token length.

        -
      • secret: Secret

        Secret key.

        -
      • token: string

        Token value.

        -
      • window: undefined | number

        Window of counter values to test.

        -

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    -
+
  • Validates an HOTP token.

    +

    Parameters

    • config: {
          algorithm?: string;
          counter?: number;
          digits?: number;
          secret: Secret;
          token: string;
          window?: number;
      }

      Configuration options.

      +
      • Optionalalgorithm?: string

        HMAC hashing algorithm.

        +
      • Optionalcounter?: number

        Counter value.

        +
      • Optionaldigits?: number

        Token length.

        +
      • secret: Secret

        Secret key.

        +
      • token: string

        Token value.

        +
      • Optionalwindow?: number

        Window of counter values to test.

        +

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    +
diff --git a/docs/classes/Secret.html b/docs/classes/Secret.html index 4da6934..7a0ba78 100644 --- a/docs/classes/Secret.html +++ b/docs/classes/Secret.html @@ -1,36 +1,36 @@ -Secret | otpauth

Class Secret

OTP secret key.

-

Constructors

constructor +Secret | otpauth

Class Secret

OTP secret key.

+

Constructors

Properties

Accessors

Methods

Constructors

  • Creates a secret key object.

    -

    Parameters

    • Optionalconfig: {
          buffer: undefined | ArrayBufferLike;
          size: undefined | number;
      } = {}

      Configuration options.

      -
      • buffer: undefined | ArrayBufferLike

        Secret key buffer.

        -
      • size: undefined | number

        Number of random bytes to generate, ignored if 'buffer' is provided.

        -

    Returns Secret

Properties

bytes: Uint8Array

Secret key.

-

Accessors

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

    -

    Returns string

  • get buffer(): ArrayBufferLike
  • Secret key buffer.

    -

    Returns ArrayBufferLike

    For backward compatibility, the "bytes" property should be used instead.

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

    -

    Returns string

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

    -

    Returns string

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

    -

    Returns string

Methods

  • Converts a base32 string to a Secret object.

    +

Methods

Constructors

  • Creates a secret key object.

    +

    Parameters

    • Optionalconfig: { buffer?: ArrayBufferLike; size?: number } = {}

      Configuration options.

      +
      • Optionalbuffer?: ArrayBufferLike

        Secret key buffer.

        +
      • Optionalsize?: number

        Number of random bytes to generate, ignored if 'buffer' is provided.

        +

    Returns Secret

Properties

bytes: Uint8Array<ArrayBufferLike>

Secret key.

+

Accessors

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

    +

    Returns string

  • get buffer(): ArrayBufferLike
  • Secret key buffer.

    +

    Returns ArrayBufferLike

    For backward compatibility, the "bytes" property should be used instead.

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

    +

    Returns string

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

    +

    Returns string

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

    +

    Returns string

Methods

  • Converts a base32 string to a Secret object.

    Parameters

    • str: string

      Base32 string.

    Returns Secret

    Secret object.

    -
  • Converts a hexadecimal string to a Secret object.

    +
  • Converts a hexadecimal string to a Secret object.

    Parameters

    • str: string

      Hexadecimal string.

    Returns Secret

    Secret object.

    -
  • Converts a Latin-1 string to a Secret object.

    +
  • Converts a Latin-1 string to a Secret object.

    Parameters

    • str: string

      Latin-1 string.

    Returns Secret

    Secret object.

    -
  • Converts an UTF-8 string to a Secret object.

    +
  • Converts an UTF-8 string to a Secret object.

    Parameters

    • str: string

      UTF-8 string.

    Returns Secret

    Secret object.

    -
+
diff --git a/docs/classes/TOTP.html b/docs/classes/TOTP.html index a96f155..ff4be2f 100644 --- a/docs/classes/TOTP.html +++ b/docs/classes/TOTP.html @@ -1,64 +1,64 @@ -TOTP | otpauth

Class TOTP

TOTP: Time-Based One-Time Password Algorithm.

-

Constructors

constructor +TOTP | otpauth

Class TOTP

TOTP: Time-Based One-Time Password Algorithm.

+

Constructors

  • Creates a TOTP object.

    -

    Parameters

    • Optionalconfig: {
          algorithm: undefined | string;
          digits: undefined | number;
          issuer: undefined | string;
          issuerInLabel: undefined | boolean;
          label: undefined | string;
          period: undefined | number;
          secret: undefined | string | Secret;
      } = {}

      Configuration options.

      -
      • algorithm: undefined | string

        HMAC hashing algorithm.

        -
      • digits: undefined | number

        Token length.

        -
      • issuer: undefined | string

        Account provider.

        -
      • issuerInLabel: undefined | boolean

        Include issuer prefix in label.

        -
      • label: undefined | string

        Account label.

        -
      • period: undefined | number

        Token time-step duration.

        -
      • secret: undefined | string | Secret

        Secret key.

        -

    Returns TOTP

Properties

algorithm: string

HMAC hashing algorithm.

-
digits: number

Token length.

-
issuer: string

Account provider.

-
issuerInLabel: boolean

Include issuer prefix in label.

-
label: string

Account label.

-
period: number

Token time-step duration.

-
secret: Secret

Secret key.

-

Accessors

  • get defaults(): {
        algorithm: string;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        period: number;
        window: number;
    }
  • Default configuration.

    -

    Returns {
        algorithm: string;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        period: number;
        window: number;
    }

    • algorithm: string
    • digits: number
    • issuer: string
    • issuerInLabel: boolean
    • label: string
    • period: number
    • window: number

Methods

  • Generates a TOTP token.

    -

    Parameters

    • Optionalconfig: {
          timestamp: undefined | number;
      } = {}

      Configuration options.

      -
      • timestamp: undefined | number

        Timestamp value in milliseconds.

        +

Constructors

  • Creates a TOTP object.

    +

    Parameters

    • Optionalconfig: {
          algorithm?: string;
          digits?: number;
          issuer?: string;
          issuerInLabel?: boolean;
          label?: string;
          period?: number;
          secret?: string | Secret;
      } = {}

      Configuration options.

      +
      • Optionalalgorithm?: string

        HMAC hashing algorithm.

        +
      • Optionaldigits?: number

        Token length.

        +
      • Optionalissuer?: string

        Account provider.

        +
      • OptionalissuerInLabel?: boolean

        Include issuer prefix in label.

        +
      • Optionallabel?: string

        Account label.

        +
      • Optionalperiod?: number

        Token time-step duration.

        +
      • Optionalsecret?: string | Secret

        Secret key.

        +

    Returns TOTP

Properties

algorithm: string

HMAC hashing algorithm.

+
digits: number

Token length.

+
issuer: string

Account provider.

+
issuerInLabel: boolean

Include issuer prefix in label.

+
label: string

Account label.

+
period: number

Token time-step duration.

+
secret: Secret

Secret key.

+

Accessors

  • get defaults(): {
        algorithm: string;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        period: number;
        window: number;
    }
  • Default configuration.

    +

    Returns {
        algorithm: string;
        digits: number;
        issuer: string;
        issuerInLabel: boolean;
        label: string;
        period: number;
        window: number;
    }

Methods

  • Generates a TOTP token.

    +

    Parameters

    • Optionalconfig: { timestamp?: number } = {}

      Configuration options.

      +
      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

    Returns string

    Token.

    -
  • Returns a Google Authenticator key URI.

    +
  • Returns a Google Authenticator key URI.

    Returns string

    URI.

    -
  • Validates a TOTP token.

    -

    Parameters

    • config: {
          timestamp: undefined | number;
          token: string;
          window: undefined | number;
      }

      Configuration options.

      -
      • timestamp: undefined | number

        Timestamp value in milliseconds.

        -
      • token: string

        Token value.

        -
      • window: undefined | number

        Window of counter values to test.

        -

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    -
  • Generates a TOTP token.

    -

    Parameters

    • config: {
          algorithm: undefined | string;
          digits: undefined | number;
          period: undefined | number;
          secret: Secret;
          timestamp: undefined | number;
      }

      Configuration options.

      -
      • algorithm: undefined | string

        HMAC hashing algorithm.

        -
      • digits: undefined | number

        Token length.

        -
      • period: undefined | number

        Token time-step duration.

        -
      • secret: Secret

        Secret key.

        -
      • timestamp: undefined | number

        Timestamp value in milliseconds.

        +
  • Validates a TOTP token.

    +

    Parameters

    • config: { timestamp?: number; token: string; window?: number }

      Configuration options.

      +
      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

        +
      • token: string

        Token value.

        +
      • Optionalwindow?: number

        Window of counter values to test.

        +

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    +
  • Generates a TOTP token.

    +

    Parameters

    • config: {
          algorithm?: string;
          digits?: number;
          period?: number;
          secret: Secret;
          timestamp?: number;
      }

      Configuration options.

      +
      • Optionalalgorithm?: string

        HMAC hashing algorithm.

        +
      • Optionaldigits?: number

        Token length.

        +
      • Optionalperiod?: number

        Token time-step duration.

        +
      • secret: Secret

        Secret key.

        +
      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

    Returns string

    Token.

    -
  • Validates a TOTP token.

    -

    Parameters

    • config: {
          algorithm: undefined | string;
          digits: undefined | number;
          period: undefined | number;
          secret: Secret;
          timestamp: undefined | number;
          token: string;
          window: undefined | number;
      }

      Configuration options.

      -
      • algorithm: undefined | string

        HMAC hashing algorithm.

        -
      • digits: undefined | number

        Token length.

        -
      • period: undefined | number

        Token time-step duration.

        -
      • secret: Secret

        Secret key.

        -
      • timestamp: undefined | number

        Timestamp value in milliseconds.

        -
      • token: string

        Token value.

        -
      • window: undefined | number

        Window of counter values to test.

        -

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    -
+
  • Validates a TOTP token.

    +

    Parameters

    • config: {
          algorithm?: string;
          digits?: number;
          period?: number;
          secret: Secret;
          timestamp?: number;
          token: string;
          window?: number;
      }

      Configuration options.

      +
      • Optionalalgorithm?: string

        HMAC hashing algorithm.

        +
      • Optionaldigits?: number

        Token length.

        +
      • Optionalperiod?: number

        Token time-step duration.

        +
      • secret: Secret

        Secret key.

        +
      • Optionaltimestamp?: number

        Timestamp value in milliseconds.

        +
      • token: string

        Token value.

        +
      • Optionalwindow?: number

        Window of counter values to test.

        +

    Returns null | number

    Token delta or null if it is not found in the search window, in which case it should be considered invalid.

    +
diff --git a/docs/classes/URI.html b/docs/classes/URI.html index 9455b29..f28efc9 100644 --- a/docs/classes/URI.html +++ b/docs/classes/URI.html @@ -1,12 +1,12 @@ -URI | otpauth

Class URI

HOTP/TOTP object/string conversion.

-

Constructors

constructor +URI | otpauth

Class URI

HOTP/TOTP object/string conversion.

+

Constructors

Methods

Constructors

Methods

  • Parses a Google Authenticator key URI and returns an HOTP/TOTP object.

    +

Constructors

Methods

  • Parses a Google Authenticator key URI and returns an HOTP/TOTP object.

    Parameters

    • uri: string

      Google Authenticator Key URI.

      -

    Returns HOTP | TOTP

    HOTP/TOTP object.

    -
  • Converts an HOTP/TOTP object to a Google Authenticator key URI.

    -

    Parameters

    Returns HOTP | TOTP

    HOTP/TOTP object.

    +
  • Converts an HOTP/TOTP object to a Google Authenticator key URI.

    +

    Parameters

    Returns string

    Google Authenticator Key URI.

    -
+
diff --git a/docs/index.html b/docs/index.html index 81ebd90..2b67aac 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,6 +1 @@ -otpauth

otpauth

Index

Classes

Variables

+otpauth

otpauth

Classes

HOTP
Secret
TOTP
URI

Variables

version
diff --git a/docs/variables/version.html b/docs/variables/version.html index 375179c..f0b0d00 100644 --- a/docs/variables/version.html +++ b/docs/variables/version.html @@ -1,2 +1,2 @@ -version | otpauth

Variable versionConst

version: string = "__OTPAUTH_VERSION__"

Library version.

-
+version | otpauth

Variable versionConst

version: string = "__OTPAUTH_VERSION__"

Library version.

+
diff --git a/jsr.json b/jsr.json index 522d98f..e946805 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@hectorm/otpauth", - "version": "9.3.5", + "version": "9.3.6", "exports": { ".": "./dist/otpauth.esm.js" }, diff --git a/package-lock.json b/package-lock.json index b47d7cf..7525f58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "otpauth", - "version": "9.3.5", + "version": "9.3.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "otpauth", - "version": "9.3.5", + "version": "9.3.6", "license": "MIT", "dependencies": { "@noble/hashes": "1.6.1" diff --git a/package.json b/package.json index aae047a..3731502 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "otpauth", - "version": "9.3.5", + "version": "9.3.6", "description": "One Time Password (HOTP/TOTP) library for Node.js, Deno, Bun and browsers", "keywords": [ "otp", diff --git a/types/hotp.d.ts b/types/hotp.d.ts index 886674e..cf2165b 100644 --- a/types/hotp.d.ts +++ b/types/hotp.d.ts @@ -77,7 +77,7 @@ export class HOTP { algorithm?: string | undefined; digits?: number | undefined; counter?: number | undefined; - } | undefined); + }); /** * Account provider. * @type {string} @@ -121,7 +121,7 @@ export class HOTP { */ generate({ counter }?: { counter?: number | undefined; - } | undefined): string; + }): string; /** * Validates an HOTP token. * @param {Object} config Configuration options. diff --git a/types/secret.d.ts b/types/secret.d.ts index d962b0a..adf3ec2 100644 --- a/types/secret.d.ts +++ b/types/secret.d.ts @@ -35,7 +35,7 @@ export class Secret { constructor({ buffer, size }?: { buffer?: ArrayBufferLike | undefined; size?: number | undefined; - } | undefined); + }); /** * Secret key. * @type {Uint8Array} diff --git a/types/totp.d.ts b/types/totp.d.ts index ee0e705..59e6031 100644 --- a/types/totp.d.ts +++ b/types/totp.d.ts @@ -81,7 +81,7 @@ export class TOTP { algorithm?: string | undefined; digits?: number | undefined; period?: number | undefined; - } | undefined); + }); /** * Account provider. * @type {string} @@ -125,7 +125,7 @@ export class TOTP { */ generate({ timestamp }?: { timestamp?: number | undefined; - } | undefined): string; + }): string; /** * Validates a TOTP token. * @param {Object} config Configuration options.