rootdo/content/totp/js/otpauth-9.1.3.min.js

4 lines
30 KiB
JavaScript
Raw Normal View History

2024-10-04 12:44:59 +00:00
/// <reference types="./otpauth.d.ts" />
(function(L,P){typeof exports=="object"&&typeof module!="undefined"?P(exports):typeof define=="function"&&define.amd?define(["exports"],P):(L=typeof globalThis!="undefined"?globalThis:L||self,P(L.OTPAuth={}))})(this,function(L){"use strict";const P=i=>{const e=new ArrayBuffer(8),n=new Uint8Array(e);let t=i;for(let r=7;r>=0&&t!==0;r--)n[r]=t&255,t-=n[r],t/=256;return e};var Z=Object.freeze({__proto__:null,createHmac:void 0,randomBytes:void 0,timingSafeEqual:void 0});const W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function _(i,e,n,t){let r,s,u;const c=e||[0],a=(n=n||0)>>>3,l=t===-1?3:0;for(r=0;r<i.length;r+=1)u=r+a,s=u>>>2,c.length<=s&&c.push(0),c[s]|=i[r]<<8*(l+t*(u%4));return{value:c,binLen:8*i.length+n}}function F(i,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(i){case"HEX":return function(t,r,s){return function(u,c,a,l){let w,f,h,g;if(u.length%2!=0)throw new Error("String of HEX type must be in byte increments");const m=c||[0],p=(a=a||0)>>>3,A=l===-1?3:0;for(w=0;w<u.length;w+=2){if(f=parseInt(u.substr(w,2),16),isNaN(f))throw new Error("String of HEX type contains invalid characters");for(g=(w>>>1)+p,h=g>>>2;m.length<=h;)m.push(0);m[h]|=f<<8*(A+l*(g%4))}return{value:m,binLen:4*u.length+a}}(t,r,s,n)};case"TEXT":return function(t,r,s){return function(u,c,a,l,w){let f,h,g,m,p,A,b,C,I=0;const H=a||[0],S=(l=l||0)>>>3;if(c==="UTF8")for(b=w===-1?3:0,g=0;g<u.length;g+=1)for(f=u.charCodeAt(g),h=[],128>f?h.push(f):2048>f?(h.push(192|f>>>6),h.push(128|63&f)):55296>f||57344<=f?h.push(224|f>>>12,128|f>>>6&63,128|63&f):(g+=1,f=65536+((1023&f)<<10|1023&u.charCodeAt(g)),h.push(240|f>>>18,128|f>>>12&63,128|f>>>6&63,128|63&f)),m=0;m<h.length;m+=1){for(A=I+S,p=A>>>2;H.length<=p;)H.push(0);H[p]|=h[m]<<8*(b+w*(A%4)),I+=1}else for(b=w===-1?2:0,C=c==="UTF16LE"&&w!==1||c!=="UTF16LE"&&w===1,g=0;g<u.length;g+=1){for(f=u.charCodeAt(g),C===!0&&(m=255&f,f=m<<8|f>>>8),A=I+S,p=A>>>2;H.length<=p;)H.push(0);H[p]|=f<<8*(b+w*(A%4)),I+=2}return{value:H,binLen:8*I+l}}(t,e,r,s,n)};case"B64":return function(t,r,s){return function(u,c,a,l){let w,f,h,g,m,p,A,b=0;const C=c||[0],I=(a=a||0)>>>3,H=l===-1?3:0,S=u.indexOf("=");if(u.search(/^[a-zA-Z0-9=+/]+$/)===-1)throw new Error("Invalid character in base-64 string");if(u=u.replace(/=/g,""),S!==-1&&S<u.length)throw new Error("Invalid '=' found in base-64 string");for(f=0;f<u.length;f+=4){for(m=u.substr(f,4),g=0,h=0;h<m.length;h+=1)w=W.indexOf(m.charAt(h)),g|=w<<18-6*h;for(h=0;h<m.length-1;h+=1){for(A=b+I,p=A>>>2;C.length<=p;)C.push(0);C[p]|=(g>>>16-8*h&255)<<8*(H+l*(A%4)),b+=1}}return{value:C,binLen:8*b+a}}(t,r,s,n)};case"BYTES":return function(t,r,s){return function(u,c,a,l){let w,f,h,g;const m=c||[0],p=(a=a||0)>>>3,A=l===-1?3:0;for(f=0;f<u.length;f+=1)w=u.charCodeAt(f),g=f+p,h=g>>>2,m.length<=h&&m.push(0),m[h]|=w<<8*(A+l*(g%4));return{value:m,binLen:8*u.length+a}}(t,r,s,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,r,s){return function(u,c,a,l){return _(new Uint8Array(u),c,a,l)}(t,r,s,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,r,s){return _(t,r,s,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function ee(i,e,n,t){switch(i){case"HEX":return function(r){return function(s,u,c,a){const l="0123456789abcdef";let w,f,h="";const g=u/8,m=c===-1?3:0;for(w=0;w<g;w+=1)f=s[w>>>2]>>>8*(m+c*(w%4)),h+=l.charAt(f>>>4&15)+l.charAt(15&f);return a.outputUpper?h.toUpperCase():h}(r,e,n,t)};case"B64":return function(r){return function(s,u,c,a){let l,w,f,h,g,m="";const p=u/8,A=c===-1?3:0;for(l=0;l<p;l+=3)for(h=l+1<p?s[l+1>>>2]:0,g=l+2<p?s[l+2>>>2]:0,f=(s[l>>>2]>>>8*(A+c*(l%4))&255)<<16|(h>>>8*(A+c*((l+1)%4))&255)<<8|g>>>8*(A+c*((l+2)%4))&255,w=0;w<4;w+=1)m+=8*l+6*w<=u?W.charAt(f>>>6*(3-w)&63):a.b64Pad;return m}(r,e,n,t)};case"BYTES":return function(r){return function(s,u,c){let a,l,w="";const
//# sourceMappingURL=otpauth.umd.min.js.map