@inner-dj/server 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/styles.css +1 -1
- package/assets/js/totp.js +1 -1
- package/lib/src/browser/totp.js +3 -16
- package/lib/src/browser/totp.js.map +1 -1
- package/lib/src/config.d.ts +2 -3
- package/lib/src/config.js +3 -4
- package/lib/src/config.js.map +1 -1
- package/lib/src/web.d.ts +3 -12
- package/lib/src/web.js +12 -102
- package/lib/src/web.js.map +1 -1
- package/package.json +4 -4
- package/assets/images/avif/favicon/apple-touch-icon.avif +0 -0
- package/assets/images/avif/favicon/favicon-96x96.avif +0 -0
- package/assets/images/avif/favicon/web-app-manifest-192x192.avif +0 -0
- package/assets/images/avif/favicon/web-app-manifest-512x512.avif +0 -0
- package/assets/images/webp/favicon/apple-touch-icon.webp +0 -0
- package/assets/images/webp/favicon/favicon-96x96.webp +0 -0
- package/assets/images/webp/favicon/web-app-manifest-192x192.webp +0 -0
- package/assets/images/webp/favicon/web-app-manifest-512x512.webp +0 -0
- package/assets/js/controls.js +0 -1
- package/assets/js/index.global.js +0 -1
- package/assets/js/qr.js +0 -1
- package/lib/src/browser/controls.d.ts +0 -1
- package/lib/src/browser/controls.js +0 -86
- package/lib/src/browser/controls.js.map +0 -1
- package/lib/src/browser/index.global.js +0 -10
- package/lib/src/browser/qr.js +0 -1636
- package/lib/src/cwd-checker.d.ts +0 -1
- package/lib/src/cwd-checker.js +0 -7
- package/lib/src/cwd-checker.js.map +0 -1
- package/lib/src/receivers/ireceiver.d.ts +0 -17
- package/lib/src/receivers/ireceiver.js +0 -18
- package/lib/src/receivers/ireceiver.js.map +0 -1
- package/lib/src/receivers/smtp-receiver.d.ts +0 -10
- package/lib/src/receivers/smtp-receiver.js +0 -38
- package/lib/src/receivers/smtp-receiver.js.map +0 -1
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
document.addEventListener("DOMContentLoaded", function () {
|
|
2
|
-
const container = document.getElementById('controlContainer');
|
|
3
|
-
const rows = {};
|
|
4
|
-
const NOW_PLAYING = 1;
|
|
5
|
-
const NOT_PLAYING = '-';
|
|
6
|
-
function emptyElement(el) {
|
|
7
|
-
while (el?.firstChild) {
|
|
8
|
-
el.removeChild(el.lastChild);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function createNowPlayingContent(filename) {
|
|
12
|
-
const possibleVid = filename?.split('.')[0];
|
|
13
|
-
const isMatch = possibleVid?.length === 11;
|
|
14
|
-
const textNode = document.createTextNode(filename || NOT_PLAYING);
|
|
15
|
-
if (!isMatch) {
|
|
16
|
-
return textNode;
|
|
17
|
-
}
|
|
18
|
-
const anchor = document.createElement('a');
|
|
19
|
-
anchor.href = `https://www.youtube.com/watch?v=${possibleVid}`;
|
|
20
|
-
anchor.appendChild(textNode);
|
|
21
|
-
return anchor;
|
|
22
|
-
}
|
|
23
|
-
const removeRow = (row) => {
|
|
24
|
-
row.forEach(el => container?.removeChild(el));
|
|
25
|
-
};
|
|
26
|
-
const addRow = (client) => {
|
|
27
|
-
if (!container || !client.clientId) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const clientId = document.createElement('div');
|
|
31
|
-
clientId.appendChild(document.createTextNode(client.clientId));
|
|
32
|
-
container.appendChild(clientId);
|
|
33
|
-
const nowPlaying = document.createElement('div');
|
|
34
|
-
nowPlaying.classList.add('break-all');
|
|
35
|
-
nowPlaying.appendChild(createNowPlayingContent(client.nowPlaying));
|
|
36
|
-
container.appendChild(nowPlaying);
|
|
37
|
-
const skipBtn = document.createElement('button');
|
|
38
|
-
skipBtn.classList.add('button', 'is-info');
|
|
39
|
-
skipBtn.appendChild(document.createTextNode('⏩️ Skip'));
|
|
40
|
-
container.appendChild(skipBtn);
|
|
41
|
-
rows[client.clientId] = [clientId, nowPlaying, skipBtn];
|
|
42
|
-
skipBtn.addEventListener('click', _ => {
|
|
43
|
-
fetch(`/admin/controls/skip?clientId=${encodeURIComponent(client.clientId)}`, {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
headers: {
|
|
46
|
-
'Content-Type': 'application/json',
|
|
47
|
-
},
|
|
48
|
-
body: JSON.stringify({})
|
|
49
|
-
}).catch(e => {
|
|
50
|
-
console.log(e);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const connect = () => {
|
|
55
|
-
const ws = new WebSocket('/admin/controls');
|
|
56
|
-
ws.onerror = (err) => {
|
|
57
|
-
console.log(err);
|
|
58
|
-
};
|
|
59
|
-
ws.onclose = () => {
|
|
60
|
-
setTimeout(connect, 3000);
|
|
61
|
-
};
|
|
62
|
-
ws.onmessage = (msg) => {
|
|
63
|
-
const payload = JSON.parse(msg.data);
|
|
64
|
-
const ids = payload.map(p => p.clientId);
|
|
65
|
-
for (let id in rows) {
|
|
66
|
-
if (ids.indexOf(id) < 0) {
|
|
67
|
-
removeRow(rows[id]);
|
|
68
|
-
delete rows[id];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
payload.forEach(p => {
|
|
72
|
-
if (p.clientId in rows) {
|
|
73
|
-
const row = rows[p.clientId];
|
|
74
|
-
emptyElement(row[NOW_PLAYING]);
|
|
75
|
-
row[NOW_PLAYING].appendChild(createNowPlayingContent(p.nowPlaying));
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
addRow(p);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
connect();
|
|
84
|
-
});
|
|
85
|
-
export {};
|
|
86
|
-
//# sourceMappingURL=controls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controls.js","sourceRoot":"","sources":["../../../src/browser/controls.ts"],"names":[],"mappings":"AAEA,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE;IAC1C,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,kBAAkB,CAAuB,CAAC;IACpF,MAAM,IA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@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";var otplib=(()=>{var Rt=Object.defineProperty;var Nr=Object.getOwnPropertyDescriptor;var $r=Object.getOwnPropertyNames;var qr=Object.prototype.hasOwnProperty;var Fr=(t,e)=>{for(var r in e)Rt(t,r,{get:e[r],enumerable:!0})},jr=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $r(e))!qr.call(t,n)&&n!==r&&Rt(t,n,{get:()=>e[n],enumerable:!(o=Nr(e,n))||o.enumerable});return t};var Wr=t=>jr(Rt({},"__esModule",{value:!0}),t);var un={};Fr(un,{HOTP:()=>Ne,NobleCryptoPlugin:()=>Ke,OTP:()=>wt,ScureBase32Plugin:()=>je,TOTP:()=>qe,createGuardrails:()=>m,generate:()=>Tt,generateSecret:()=>Lr,generateSync:()=>Ot,generateURI:()=>bt,stringToBytes:()=>De,verify:()=>Et,verifySync:()=>Pt,wrapResult:()=>_t,wrapResultAsync:()=>Gt});var P=class extends Error{constructor(e,r){super(e,r),this.name="OTPError"}},oe=class extends P{constructor(e){super(e),this.name="SecretError"}},se=class extends oe{constructor(e,r){super(`Secret must be at least ${e} bytes (${e*8} bits), got ${r} bytes`),this.name="SecretTooShortError"}},ie=class extends oe{constructor(e,r){super(`Secret must not exceed ${e} bytes, got ${r} bytes`),this.name="SecretTooLongError"}},K=class extends P{constructor(e){super(e),this.name="CounterError"}},ae=class extends K{constructor(){super("Counter must be non-negative"),this.name="CounterNegativeError"}},J=class extends K{constructor(){super("Counter exceeds maximum safe integer value"),this.name="CounterOverflowError"}},ce=class extends K{constructor(){super("Counter must be a finite integer"),this.name="CounterNotIntegerError"}},ue=class extends P{constructor(e){super(e),this.name="TimeError"}},le=class extends ue{constructor(){super("Time must be non-negative"),this.name="TimeNegativeError"}},pe=class extends ue{constructor(){super("Time must be a finite number"),this.name="TimeNotFiniteError"}},fe=class extends P{constructor(e){super(e),this.name="PeriodError"}},de=class extends fe{constructor(e){super(`Period must be at least ${e} second(s)`),this.name="PeriodTooSmallError"}},he=class extends fe{constructor(e){super(`Period must not exceed ${e} seconds`),this.name="PeriodTooLargeError"}};var ge=class extends P{constructor(e){super(e),this.name="TokenError"}},xe=class extends ge{constructor(e,r){super(`Token must be ${e} digits, got ${r}`),this.name="TokenLengthError"}},ye=class extends ge{constructor(){super("Token must contain only digits"),this.name="TokenFormatError"}},me=class extends P{constructor(e,r){super(e,r),this.name="CryptoError"}},v=class extends me{constructor(e,r){super(`HMAC computation failed: ${e}`,r),this.name="HMACError"}},be=class extends me{constructor(e,r){super(`Random byte generation failed: ${e}`,r),this.name="RandomBytesError"}};var V=class extends P{constructor(e){super(e),this.name="CounterToleranceError"}},Te=class extends V{constructor(e,r){super(`Counter tolerance validation failed: total checks (${r}) exceeds MAX_WINDOW (${e})`),this.name="CounterToleranceTooLargeError"}},Oe=class extends V{constructor(){super("Counter tolerance cannot contain negative values"),this.name="CounterToleranceNegativeError"}},N=class extends P{constructor(e){super(e),this.name="EpochToleranceError"}},Ee=class extends N{constructor(){super("Epoch tolerance cannot contain negative values"),this.name="EpochToleranceNegativeError"}},Pe=class extends N{constructor(e,r){super(`Epoch tolerance must not exceed ${e} seconds, got ${r}. Large tolerances can cause performance issues.`),this.name="EpochToleranceTooLargeError"}},we=class extends P{constructor(e){super(e),this.name="PluginError"}},Ae=class extends we{constructor(){super("Crypto plugin is required."),this.name="CryptoPluginMissingError"}},Se=class extends we{constructor(){super("Base32 plugin is required."),this.name="Base32PluginMissingError"}},T=class extends P{constructor(e){super(e),this.name="ConfigurationError"}},Ce=class extends T{constructor(){super("Secret is required. Use generateSecret() to create one, or provide via { secret: 'YOUR_BASE32_SECRET' }"),this.name="SecretMissingError"}},Be=class extends T{constructor(){super("Label is required for URI generation. Example: { label: 'user@example.com' }"),this.name="LabelMissingError"}},Re=class extends T{constructor(){super("Issuer is required for URI generation. Example: { issuer: 'MyApp' }"),this.name="IssuerMissingError"}},Ie=class extends T{constructor(){super("Class API requires secret to be a Base32 string, not Uint8Array. Use generateSecret() or provide a Base32-encoded string."),this.name="SecretTypeError"}},Q=class extends P{constructor(e){super(e),this.name="AfterTimeStepError"}},He=class extends Q{constructor(){super("afterTimeStep must be >= 0"),this.name="AfterTimeStepNegativeError"}},Ue=class extends Q{constructor(){super("Invalid afterTimeStep: non-integer value"),this.name="AfterTimeStepNotIntegerError"}},ve=class extends Q{constructor(){super("Invalid afterTimeStep: cannot be greater than current time step plus window"),this.name="AfterTimeStepRangeExceededError"}};var Xr=new TextEncoder,hn=new TextDecoder,tr=16,rr=64,nr=20,or=1,sr=3600,ir=30,ar=Number.MAX_SAFE_INTEGER,cr=99,ur=Symbol("otplib.guardrails.override");function Z(t,e,r){if(typeof e!="number"||!Number.isSafeInteger(e))throw new T(`Guardrail '${t}' must be a safe integer`);if(e<r)throw new T(`Guardrail '${t}' must be >= ${r}`)}var $=Object.freeze({MIN_SECRET_BYTES:tr,MAX_SECRET_BYTES:rr,MIN_PERIOD:or,MAX_PERIOD:sr,MAX_COUNTER:ar,MAX_WINDOW:cr,[ur]:!1});function m(t){if(!t)return $;t.MIN_SECRET_BYTES!==void 0&&Z("MIN_SECRET_BYTES",t.MIN_SECRET_BYTES,1),t.MAX_SECRET_BYTES!==void 0&&Z("MAX_SECRET_BYTES",t.MAX_SECRET_BYTES,1),t.MIN_PERIOD!==void 0&&Z("MIN_PERIOD",t.MIN_PERIOD,1),t.MAX_PERIOD!==void 0&&Z("MAX_PERIOD",t.MAX_PERIOD,1),t.MAX_COUNTER!==void 0&&Z("MAX_COUNTER",t.MAX_COUNTER,0),t.MAX_WINDOW!==void 0&&Z("MAX_WINDOW",t.MAX_WINDOW,1);let e={...$,...t};if(e.MIN_SECRET_BYTES>e.MAX_SECRET_BYTES)throw new T("Guardrail 'MIN_SECRET_BYTES' must be <= 'MAX_SECRET_BYTES'");if(e.MIN_PERIOD>e.MAX_PERIOD)throw new T("Guardrail 'MIN_PERIOD' must be <= 'MAX_PERIOD'");return Object.freeze({...e,[ur]:!0})}function q(t,e=$){if(t.length<e.MIN_SECRET_BYTES)throw new se(e.MIN_SECRET_BYTES,t.length);if(t.length>e.MAX_SECRET_BYTES)throw new ie(e.MAX_SECRET_BYTES,t.length)}function et(t,e=$){if(typeof t=="number"){if(!Number.isFinite(t)||!Number.isInteger(t))throw new ce;if(!Number.isSafeInteger(t))throw new J}let r=typeof t=="bigint"?t:BigInt(t);if(r<0n)throw new ae;if(r>BigInt(e.MAX_COUNTER))throw new J}function tt(t){if(!Number.isFinite(t))throw new pe;if(t<0)throw new le}function rt(t,e=$){if(!Number.isInteger(t)||t<e.MIN_PERIOD)throw new de(e.MIN_PERIOD);if(t>e.MAX_PERIOD)throw new he(e.MAX_PERIOD)}function _e(t,e){if(t.length!==e)throw new xe(e,t.length);if(!/^\d+$/.test(t))throw new ye}function It(t,e=$){let[r,o]=st(t);if(!Number.isSafeInteger(r)||!Number.isSafeInteger(o))throw new V("Counter tolerance values must be safe integers");if(r<0||o<0)throw new Oe;let n=r+o+1;if(n>e.MAX_WINDOW)throw new Te(e.MAX_WINDOW,n)}function Ht(t,e=ir,r=$){let[o,n]=Array.isArray(t)?t:[t,t];if(!Number.isSafeInteger(o)||!Number.isSafeInteger(n))throw new N("Epoch tolerance values must be safe integers");if(o<0||n<0)throw new Ee;let s=(r.MAX_WINDOW-1)*e,i=o+n;if(i>s)throw new Pe(s,i)}function Ut(t){let e=typeof t=="bigint"?t:BigInt(t),r=new ArrayBuffer(8);return new DataView(r).setBigUint64(0,e,!1),new Uint8Array(r)}function nt(t){let e=t[t.length-1]&15;return(t[e]&127)<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function ot(t,e){let r=10**e;return(t%r).toString().padStart(e,"0")}function lr(t,e){return t.length===e.length}function vt(t,e){let r=De(t),o=De(e);if(!lr(r,o))return!1;let n=0;for(let s=0;s<r.length;s++)n|=r[s]^o[s];return n===0}function De(t){return typeof t=="string"?Xr.encode(t):t}function F(t,e){return typeof t=="string"?(j(e),e.decode(t)):t}function I(t){let{crypto:e,base32:r,length:o=nr}=t;b(e),j(r);let n=e.randomBytes(o);return r.encode(n,{padding:!1})}function st(t=0){return Array.isArray(t)?t:[0,t]}function Dt(t=0){return Array.isArray(t)?t:[t,t]}function b(t){if(!t)throw new Ae}function j(t){if(!t)throw new Se}function O(t){if(!t)throw new Ce}function Ge(t){if(!t)throw new Be}function ke(t){if(!t)throw new Re}function Me(t){if(typeof t!="string")throw new Ie}function pr(t){return{ok:!0,value:t}}function fr(t){return{ok:!1,error:t}}function _t(t){return(...e)=>{try{return pr(t(...e))}catch(r){return fr(r)}}}function Gt(t){return async(...e)=>{try{return pr(await t(...e))}catch(r){return fr(r)}}}var it=class{constructor(e){this.crypto=e}get plugin(){return this.crypto}async hmac(e,r,o){try{let n=this.crypto.hmac(e,r,o);return n instanceof Promise?await n:n}catch(n){let s=n instanceof Error?n.message:String(n);throw new v(s,{cause:n})}}hmacSync(e,r,o){try{let n=this.crypto.hmac(e,r,o);if(n instanceof Promise)throw new v("Crypto plugin does not support synchronous HMAC operations");return n}catch(n){if(n instanceof v)throw n;let s=n instanceof Error?n.message:String(n);throw new v(s,{cause:n})}}randomBytes(e){try{return this.crypto.randomBytes(e)}catch(r){let o=r instanceof Error?r.message:String(r);throw new be(o,{cause:r})}}};function kt(t){return new it(t)}function Mt(t){let{type:e,label:r,params:o}=t,n=r.split(":").map(a=>encodeURIComponent(a)).join(":"),s=`otpauth://${e}/${n}?`,i=[];return o.secret&&i.push(`secret=${encodeURIComponent(o.secret)}`),o.issuer&&i.push(`issuer=${encodeURIComponent(o.issuer)}`),o.algorithm&&o.algorithm!=="sha1"&&i.push(`algorithm=${o.algorithm.toUpperCase()}`),o.digits&&o.digits!==6&&i.push(`digits=${o.digits}`),e==="hotp"&&o.counter!==void 0&&i.push(`counter=${o.counter}`),e==="totp"&&o.period!==void 0&&o.period!==30&&i.push(`period=${o.period}`),s+=i.join("&"),s}function Le(t){let{issuer:e,label:r,secret:o,algorithm:n="sha1",digits:s=6,period:i=30}=t,a=e?`${e}:${r}`:r;return Mt({type:"totp",label:a,params:{secret:o,issuer:e,algorithm:n,digits:s,period:i}})}function Ve(t){let{issuer:e,label:r,secret:o,counter:n=0,algorithm:s="sha1",digits:i=6}=t,a=e?`${e}:${r}`:r;return Mt({type:"hotp",label:a,params:{secret:o,issuer:e,algorithm:s,digits:i,counter:n}})}var Ne=class{options;guardrails;constructor(e={}){this.options=e,this.guardrails=m(e.guardrails)}generateSecret(){let{crypto:e,base32:r}=this.options;return b(e),j(r),I({crypto:e,base32:r})}async generate(e,r){let o={...this.options,...r},{secret:n,crypto:s,base32:i,algorithm:a="sha1",digits:c=6}=o;O(n),b(s);let u=r?.guardrails??this.guardrails;return W({secret:n,counter:e,algorithm:a,digits:c,crypto:s,base32:i,guardrails:u,hooks:o.hooks})}async verify(e,r){let o={...this.options,...r},{secret:n,crypto:s,base32:i,algorithm:a="sha1",digits:c=6,counterTolerance:u=0}=o;O(n),b(s);let l=r?.guardrails??this.guardrails;return at({secret:n,token:e.token,counter:e.counter,algorithm:a,digits:c,counterTolerance:u,crypto:s,base32:i,guardrails:l,hooks:o.hooks})}toURI(e=0){let{issuer:r,label:o,secret:n,algorithm:s="sha1",digits:i=6}=this.options;return O(n),Ge(o),ke(r),Me(n),Ve({issuer:r,label:o,secret:n,algorithm:s,digits:i,counter:e})}};function dr(t){let{secret:e,counter:r,algorithm:o="sha1",digits:n=6,crypto:s,base32:i,guardrails:a,hooks:c}=t;O(e),b(s);let u=F(e,i);q(u,a),et(r,a);let l=kt(s),p=Ut(r);return{ctx:l,algorithm:o,digits:n,secretBytes:u,counterBytes:p,hooks:c}}async function W(t){let{ctx:e,algorithm:r,digits:o,secretBytes:n,counterBytes:s,hooks:i}=dr(t),a=await e.hmac(r,n,s),c=i?.truncateDigest?i.truncateDigest(a):nt(a);return i?.encodeToken?i.encodeToken(c,o):ot(c,o)}function $e(t){let{ctx:e,algorithm:r,digits:o,secretBytes:n,counterBytes:s,hooks:i}=dr(t),a=e.hmacSync(r,n,s),c=i?.truncateDigest?i.truncateDigest(a):nt(a);return i?.encodeToken?i.encodeToken(c,o):ot(c,o)}function hr(t){let{secret:e,counter:r,token:o,algorithm:n="sha1",digits:s=6,crypto:i,base32:a,counterTolerance:c=0,guardrails:u=m(),hooks:l}=t;O(e),b(i);let p=F(e,a);q(p,u),et(r,u),l?.validateToken?l.validateToken(o,s):_e(o,s),It(c,u);let f=typeof r=="bigint"?Number(r):r,[h,g]=st(c),x=h+g+1;return{token:o,counterNum:f,past:h,future:g,totalChecks:x,crypto:i,getGenerateOptions:E=>({secret:p,counter:E,algorithm:n,digits:s,crypto:i,guardrails:u,hooks:l})}}async function at(t){let{token:e,counterNum:r,past:o,totalChecks:n,crypto:s,getGenerateOptions:i}=hr(t),a=Math.max(0,o-r);for(let c=a;c<n;c++){let u=c-o,l=r+u,p=await W(i(l));if(s.constantTimeEqual(p,e))return{valid:!0,delta:u|0}}return{valid:!1}}function gr(t){let{token:e,counterNum:r,past:o,totalChecks:n,crypto:s,getGenerateOptions:i}=hr(t),a=Math.max(0,o-r);for(let c=a;c<n;c++){let u=c-o,l=r+u,p=$e(i(l));if(s.constantTimeEqual(p,e))return{valid:!0,delta:u|0}}return{valid:!1}}var qe=class{options;guardrails;constructor(e={}){this.options=e,this.guardrails=m(e.guardrails)}generateSecret(){let{crypto:e,base32:r}=this.options;return b(e),j(r),I({crypto:e,base32:r})}async generate(e){let r={...this.options,...e},{secret:o,crypto:n,base32:s,algorithm:i="sha1",digits:a=6,period:c=30,epoch:u,t0:l=0}=r;O(o),b(n);let p=e?.guardrails??this.guardrails;return Fe({secret:o,algorithm:i,digits:a,period:c,epoch:u??Math.floor(Date.now()/1e3),t0:l,crypto:n,base32:s,guardrails:p,hooks:r.hooks})}async verify(e,r){let o={...this.options,...r},{secret:n,crypto:s,base32:i,algorithm:a="sha1",digits:c=6,period:u=30,epoch:l,t0:p=0,epochTolerance:f=0,afterTimeStep:h}=o;O(n),b(s);let g=r?.guardrails??this.guardrails;return ct({secret:n,token:e,algorithm:a,digits:c,period:u,epoch:l??Math.floor(Date.now()/1e3),t0:p,epochTolerance:f,afterTimeStep:h,crypto:s,base32:i,guardrails:g,hooks:o.hooks})}toURI(e){let{issuer:r,label:o,secret:n,algorithm:s="sha1",digits:i=6,period:a=30}=this.options,c=e?.label??o,u=e?.issuer??r,l=e?.secret??n;return O(l),Ge(c),ke(u),Me(l),Le({issuer:u,label:c,secret:l,algorithm:s,digits:i,period:a})}};function xr(t){let{secret:e,epoch:r=Math.floor(Date.now()/1e3),t0:o=0,period:n=30,algorithm:s="sha1",digits:i=6,crypto:a,base32:c,guardrails:u=m(),hooks:l}=t;O(e),b(a);let p=F(e,c);q(p,u),tt(r),rt(n,u);let f=Math.floor((r-o)/n);return{secret:p,counter:f,algorithm:s,digits:i,crypto:a,guardrails:u,hooks:l}}async function Fe(t){let e=xr(t);return W(e)}function Lt(t){let e=xr(t);return $e(e)}function Yr(t,e){if(t!==void 0){if(t<0)throw new He;if(!Number.isSafeInteger(t))throw new Ue;if(t>e)throw new ve}}function yr(t,e){return e!==void 0&&t<=e}function mr(t){let{secret:e,token:r,epoch:o=Math.floor(Date.now()/1e3),t0:n=0,period:s=30,algorithm:i="sha1",digits:a=6,crypto:c,base32:u,epochTolerance:l=0,afterTimeStep:p,guardrails:f=m(),hooks:h}=t;O(e),b(c);let g=F(e,u);q(g,f),tt(o),rt(s,f),h?.validateToken?h.validateToken(r,a):_e(r,a),Ht(l,s,f);let x=Math.floor((o-n)/s),[E,M]=Dt(l),L=Math.max(0,Math.floor((o-E-n)/s)),d=Math.floor((o+M-n)/s);return Yr(p,d),{token:r,crypto:c,minCounter:L,maxCounter:d,currentCounter:x,t0:n,period:s,afterTimeStep:p,getGenerateOptions:S=>({secret:g,epoch:S*s+n,t0:n,period:s,algorithm:i,digits:a,crypto:c,guardrails:f,hooks:h})}}async function ct(t){let{token:e,crypto:r,minCounter:o,maxCounter:n,currentCounter:s,t0:i,period:a,afterTimeStep:c,getGenerateOptions:u}=mr(t);for(let l=o;l<=n;l++){if(yr(l,c))continue;let p=await Fe(u(l));if(r.constantTimeEqual(p,e))return{valid:!0,delta:l-s,epoch:l*a+i,timeStep:l}}return{valid:!1}}function br(t){let{token:e,crypto:r,minCounter:o,maxCounter:n,currentCounter:s,t0:i,period:a,afterTimeStep:c,getGenerateOptions:u}=mr(t);for(let l=o;l<=n;l++){if(yr(l,c))continue;let p=Lt(u(l));if(r.constantTimeEqual(p,e))return{valid:!0,delta:l-s,epoch:l*a+i,timeStep:l}}return{valid:!1}}function zr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Or(t,e){return Array.isArray(e)?e.length===0?!0:t?e.every(r=>typeof r=="string"):e.every(r=>Number.isSafeInteger(r)):!1}function ut(t,e){if(typeof e!="string")throw new Error(`${t}: string expected`);return!0}function $t(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Nt(t){if(!Array.isArray(t))throw new Error("array expected")}function lt(t,e){if(!Or(!0,e))throw new Error(`${t}: array of strings expected`)}function Kr(t,e){if(!Or(!1,e))throw new Error(`${t}: array of numbers expected`)}function Jr(...t){let e=s=>s,r=(s,i)=>a=>s(i(a)),o=t.map(s=>s.encode).reduceRight(r,e),n=t.map(s=>s.decode).reduce(r,e);return{encode:o,decode:n}}function Qr(t){let e=typeof t=="string"?t.split(""):t,r=e.length;lt("alphabet",e);let o=new Map(e.map((n,s)=>[n,s]));return{encode:n=>(Nt(n),n.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${t}`);return e[s]})),decode:n=>(Nt(n),n.map(s=>{ut("alphabet.decode",s);let i=o.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${t}`);return i}))}}function Zr(t=""){return ut("join",t),{encode:e=>(lt("join.decode",e),e.join(t)),decode:e=>(ut("join.decode",e),e.split(t))}}function en(t,e="="){return $t(t),ut("padding",e),{encode(r){for(lt("padding.encode",r);r.length*t%8;)r.push(e);return r},decode(r){lt("padding.decode",r);let o=r.length;if(o*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===e;o--)if((o-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}var Er=(t,e)=>e===0?t:Er(e,t%e),pt=(t,e)=>t+(e-Er(t,e)),Vt=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Tr(t,e,r,o){if(Nt(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(pt(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${pt(e,r)}`);let n=0,s=0,i=Vt[e],a=Vt[r]-1,c=[];for(let u of t){if($t(u),u>=i)throw new Error(`convertRadix2: invalid data word=${u} from=${e}`);if(n=n<<e|u,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=r;s-=r)c.push((n>>s-r&a)>>>0);let l=Vt[s];if(l===void 0)throw new Error("invalid carry");n&=l-1}if(n=n<<r-s&a,!o&&s>=e)throw new Error("Excess padding");if(!o&&n>0)throw new Error(`Non-zero padding: ${n}`);return o&&s>0&&c.push(n>>>0),c}function tn(t,e=!1){if($t(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(pt(8,t)>32||pt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!zr(r))throw new Error("radix2.encode input should be Uint8Array");return Tr(Array.from(r),8,t,!e)},decode:r=>(Kr("radix2.decode",r),Uint8Array.from(Tr(r,t,8,e)))}}var qt=Jr(tn(5),Qr("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),en(5),Zr(""));var je=class{name="scure";encode(e,r={}){let{padding:o=!1}=r,n=qt.encode(e);return o?n:n.replace(/=+$/,"")}decode(e){try{let r=e.toUpperCase(),o=r.padEnd(Math.ceil(r.length/8)*8,"=");return qt.decode(o)}catch(r){throw r instanceof Error?new Error(`Invalid Base32 string: ${r.message}`):new Error("Invalid Base32 string")}}},ee=Object.freeze(new je);function rn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pr(t,e=""){if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function te(t,e,r=""){let o=rn(t),n=t?.length,s=e!==void 0;if(!o||s&&n!==e){let i=r&&`"${r}" `,a=s?` of length ${e}`:"",c=o?`length=${n}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return t}function wr(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash must wrapped by utils.createHasher");Pr(t.outputLen),Pr(t.blockLen)}function re(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 Ar(t,e){te(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function w(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ft(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function A(t,e){return t<<32-e|t>>>e}function dt(t,e){return t<<e|t>>>32-e>>>0}function We(t,e={}){let r=(n,s)=>t(s).update(n).digest(),o=t(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=n=>t(n),Object.assign(r,e),Object.freeze(r)}function Sr(t=32){let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}var Ft=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});var ht=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,r){if(wr(e),te(r,void 0,"key"),this.iHash=e.create(),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;let o=this.blockLen,n=new Uint8Array(o);n.set(r.length>o?e.create().update(r).digest():r);for(let s=0;s<n.length;s++)n[s]^=54;this.iHash.update(n),this.oHash=e.create();for(let s=0;s<n.length;s++)n[s]^=106;this.oHash.update(n),w(n)}update(e){return re(this),this.iHash.update(e),this}digestInto(e){re(this),te(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:o,finished:n,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=s,e.blockLen=i,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=o._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},jt=(t,e,r)=>new ht(t,e).update(r).digest();jt.create=(t,e)=>new ht(t,e);function gt(t,e,r){return t&e^~t&r}function xt(t,e,r){return t&e^t&r^e&r}var X=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,o,n){this.blockLen=e,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(e),this.view=ft(this.buffer)}update(e){re(this),te(e);let{view:r,buffer:o,blockLen:n}=this,s=e.length;for(let i=0;i<s;){let a=Math.min(n-this.pos,s-i);if(a===n){let c=ft(e);for(;n<=s-i;i+=n)this.process(c,i);continue}o.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){re(this),Ar(e,this),this.finished=!0;let{buffer:r,view:o,blockLen:n,isLE:s}=this,{pos:i}=this;r[i++]=128,w(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let p=i;p<n;p++)r[p]=0;o.setBigUint64(n-8,BigInt(this.length*8),s),this.process(o,0);let a=ft(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<u;p++)a.setUint32(4*p,l[p],s)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let o=e.slice(0,r);return this.destroy(),o}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:o,length:n,finished:s,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=s,e.length=n,e.pos=a,n%r&&e.buffer.set(o),e}clone(){return this._cloneInto()}},H=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var y=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Xe=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),D=new Uint32Array(80),Wt=class extends X{A=Xe[0]|0;B=Xe[1]|0;C=Xe[2]|0;D=Xe[3]|0;E=Xe[4]|0;constructor(){super(64,20,8,!1)}get(){let{A:e,B:r,C:o,D:n,E:s}=this;return[e,r,o,n,s]}set(e,r,o,n,s){this.A=e|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0}process(e,r){for(let c=0;c<16;c++,r+=4)D[c]=e.getUint32(r,!1);for(let c=16;c<80;c++)D[c]=dt(D[c-3]^D[c-8]^D[c-14]^D[c-16],1);let{A:o,B:n,C:s,D:i,E:a}=this;for(let c=0;c<80;c++){let u,l;c<20?(u=gt(n,s,i),l=1518500249):c<40?(u=n^s^i,l=1859775393):c<60?(u=xt(n,s,i),l=2400959708):(u=n^s^i,l=3395469782);let p=dt(o,5)+u+a+l+D[c]|0;a=i,i=s,s=dt(n,30),n=o,o=p}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,this.set(o,n,s,i,a)}roundClean(){w(D)}destroy(){this.set(0,0,0,0,0),w(this.buffer)}},Cr=We(()=>new Wt);var yt=BigInt(4294967295),Br=BigInt(32);function nn(t,e=!1){return e?{h:Number(t&yt),l:Number(t>>Br&yt)}:{h:Number(t>>Br&yt)|0,l:Number(t&yt)|0}}function Rr(t,e=!1){let r=t.length,o=new Uint32Array(r),n=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=nn(t[s],e);[o[s],n[s]]=[i,a]}return[o,n]}var Xt=(t,e,r)=>t>>>r,Yt=(t,e,r)=>t<<32-r|e>>>r,Y=(t,e,r)=>t>>>r|e<<32-r,z=(t,e,r)=>t<<32-r|e>>>r,Ye=(t,e,r)=>t<<64-r|e>>>r-32,ze=(t,e,r)=>t>>>r-32|e<<64-r;function C(t,e,r,o){let n=(e>>>0)+(o>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}var Ir=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),Hr=(t,e,r,o)=>e+r+o+(t/2**32|0)|0,Ur=(t,e,r,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(o>>>0),vr=(t,e,r,o,n)=>e+r+o+n+(t/2**32|0)|0,Dr=(t,e,r,o,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(o>>>0)+(n>>>0),_r=(t,e,r,o,n,s)=>e+r+o+n+s+(t/2**32|0)|0;var sn=Uint32Array.from([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]),_=new Uint32Array(64),zt=class extends X{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:o,D:n,E:s,F:i,G:a,H:c}=this;return[e,r,o,n,s,i,a,c]}set(e,r,o,n,s,i,a,c){this.A=e|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,r){for(let p=0;p<16;p++,r+=4)_[p]=e.getUint32(r,!1);for(let p=16;p<64;p++){let f=_[p-15],h=_[p-2],g=A(f,7)^A(f,18)^f>>>3,x=A(h,17)^A(h,19)^h>>>10;_[p]=x+_[p-7]+g+_[p-16]|0}let{A:o,B:n,C:s,D:i,E:a,F:c,G:u,H:l}=this;for(let p=0;p<64;p++){let f=A(a,6)^A(a,11)^A(a,25),h=l+f+gt(a,c,u)+sn[p]+_[p]|0,x=(A(o,2)^A(o,13)^A(o,22))+xt(o,n,s)|0;l=u,u=c,c=a,a=i+h|0,i=s,s=n,n=o,o=h+x|0}o=o+this.A|0,n=n+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(o,n,s,i,a,c,u,l)}roundClean(){w(_)}destroy(){this.set(0,0,0,0,0,0,0,0),w(this.buffer)}},Kt=class extends zt{A=H[0]|0;B=H[1]|0;C=H[2]|0;D=H[3]|0;E=H[4]|0;F=H[5]|0;G=H[6]|0;H=H[7]|0;constructor(){super(32)}};var Gr=Rr(["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))),an=Gr[0],cn=Gr[1],G=new Uint32Array(80),k=new Uint32Array(80),Jt=class extends X{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:r,Bh:o,Bl:n,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:p,Fl:f,Gh:h,Gl:g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e,Ze,Vr);o=Hr(er,R,Ct,Bt),n=er|0}({h:o,l:n}=C(this.Ah|0,this.Al|0,o|0,n|0)),{h:s,l:i}=C(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=C(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=C(this.Dh|0,this.Dl|0,u|0,l|0),{h:p,l:f}=C(this.Eh|0,this.El|0,p|0,f|0),{h,l:g}=C(this.Fh|0,this.Fl|0,h|0,g|0),{h:x,l:E}=C(this.Gh|0,this.Gl|0,x|0,E|0),{h:M,l:L}=C(this.Hh|0,this.Hl|0,M|0,L|0),this.set(o,n,s,i,a,c,u,l,p,f,h,g,x,E,M,L)}roundClean(){w(G,k)}destroy(){w(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Qt=class extends Jt{Ah=y[0]|0;Al=y[1]|0;Bh=y[2]|0;Bl=y[3]|0;Ch=y[4]|0;Cl=y[5]|0;Dh=y[6]|0;Dl=y[7]|0;Eh=y[8]|0;El=y[9]|0;Fh=y[10]|0;Fl=y[11]|0;Gh=y[12]|0;Gl=y[13]|0;Hh=y[14]|0;Hl=y[15]|0;constructor(){super(64)}};var kr=We(()=>new Kt,Ft(1));var Mr=We(()=>new Qt,Ft(3));var Ke=class{name="noble";hmac(e,r,o){return jt(e==="sha1"?Cr:e==="sha256"?kr:Mr,r,o)}randomBytes(e){return Sr(e)}constantTimeEqual(e,r){return vt(e,r)}},ne=Object.freeze(new Ke);function mt(t){return{secret:t.secret,strategy:t.strategy??"totp",crypto:t.crypto??ne,base32:t.base32??ee,algorithm:t.algorithm??"sha1",digits:t.digits??6,period:t.period??30,epoch:t.epoch??Math.floor(Date.now()/1e3),t0:t.t0??0,counter:t.counter,guardrails:t.guardrails??m(),hooks:t.hooks}}function Zt(t){return{...mt(t),token:t.token,epochTolerance:t.epochTolerance??0,counterTolerance:t.counterTolerance??0,afterTimeStep:t.afterTimeStep}}function Je(t,e,r){if(t==="totp")return r.totp();if(t==="hotp"){if(e===void 0)throw new T("Counter is required for HOTP strategy. Example: { strategy: 'hotp', counter: 0 }");return r.hotp(e)}throw new T(`Unknown OTP strategy: ${t}. Valid strategies are 'totp' or 'hotp'.`)}function Lr(t){let{crypto:e=ne,base32:r=ee,length:o=20}=t||{};return I({crypto:e,base32:r,length:o})}function bt(t){let{strategy:e="totp",issuer:r,label:o,secret:n,algorithm:s="sha1",digits:i=6,period:a=30,counter:c}=t;return Je(e,c,{totp:()=>Le({issuer:r,label:o,secret:n,algorithm:s,digits:i,period:a}),hotp:u=>Ve({issuer:r,label:o,secret:n,algorithm:s,digits:i,counter:u})})}async function Tt(t){let e=mt(t),{secret:r,crypto:o,base32:n,algorithm:s,digits:i,hooks:a}=e,c={secret:r,crypto:o,base32:n,algorithm:s,digits:i,hooks:a};return Je(e.strategy,e.counter,{totp:()=>Fe({...c,period:e.period,epoch:e.epoch,t0:e.t0,guardrails:e.guardrails}),hotp:u=>W({...c,counter:u,guardrails:e.guardrails})})}function Ot(t){let e=mt(t),{secret:r,crypto:o,base32:n,algorithm:s,digits:i}=e,a={secret:r,crypto:o,base32:n,algorithm:s,digits:i};return Je(e.strategy,e.counter,{totp:()=>Lt({...a,period:e.period,epoch:e.epoch,t0:e.t0,guardrails:e.guardrails}),hotp:c=>$e({...a,counter:c,guardrails:e.guardrails})})}async function Et(t){let e=Zt(t),{secret:r,token:o,crypto:n,base32:s,algorithm:i,digits:a,hooks:c}=e,u={secret:r,token:o,crypto:n,base32:s,algorithm:i,digits:a,hooks:c};return Je(e.strategy,e.counter,{totp:()=>ct({...u,period:e.period,epoch:e.epoch,t0:e.t0,epochTolerance:e.epochTolerance,afterTimeStep:e.afterTimeStep,guardrails:e.guardrails}),hotp:l=>at({...u,counter:l,counterTolerance:e.counterTolerance,guardrails:e.guardrails})})}function Pt(t){let e=Zt(t),{secret:r,token:o,crypto:n,base32:s,algorithm:i,digits:a,hooks:c}=e,u={secret:r,token:o,crypto:n,base32:s,algorithm:i,digits:a,hooks:c};return Je(e.strategy,e.counter,{totp:()=>br({...u,period:e.period,epoch:e.epoch,t0:e.t0,epochTolerance:e.epochTolerance,afterTimeStep:e.afterTimeStep,guardrails:e.guardrails}),hotp:l=>gr({...u,counter:l,counterTolerance:e.counterTolerance,guardrails:e.guardrails})})}var wt=class{strategy;crypto;base32;guardrails;constructor(e={}){let{strategy:r="totp",crypto:o=ne,base32:n=ee,guardrails:s}=e;this.strategy=r,this.crypto=o,this.base32=n,this.guardrails=m(s)}getStrategy(){return this.strategy}generateSecret(e=20){return I({crypto:this.crypto,base32:this.base32,length:e})}async generate(e){return Tt({...e,strategy:this.strategy,crypto:this.crypto,base32:this.base32,guardrails:e.guardrails??this.guardrails})}generateSync(e){return Ot({...e,strategy:this.strategy,crypto:this.crypto,base32:this.base32,guardrails:e.guardrails??this.guardrails})}async verify(e){return Et({...e,strategy:this.strategy,crypto:this.crypto,base32:this.base32,guardrails:e.guardrails??this.guardrails})}verifySync(e){return Pt({...e,strategy:this.strategy,crypto:this.crypto,base32:this.base32,guardrails:e.guardrails??this.guardrails})}generateURI(e){return bt({...e,strategy:this.strategy})}};return Wr(un);})();
|
|
2
|
-
/*! Bundled license information:
|
|
3
|
-
|
|
4
|
-
@scure/base/index.js:
|
|
5
|
-
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
6
|
-
|
|
7
|
-
@noble/hashes/utils.js:
|
|
8
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
9
|
-
*/
|
|
10
|
-
//# sourceMappingURL=index.global.js.map
|