"use strict";var T=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var r in e)T(t,r,{get:e[r],enumerable:!0})},v=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of x(e))!H.call(t,o)&&o!==r&&T(t,o,{get:()=>e[o],enumerable:!(n=V(e,o))||n.enumerable});return t};var G=t=>v(T({},"__esModule",{value:!0}),t);var j={};R(j,{generate:()=>D,generateSecret:()=>w,generateSync:()=>z,generateURI:()=>C,verify:()=>B,verifySync:()=>k});module.exports=G(j);var l=require("@otplib/core"),c=require("@otplib/hotp"),g=require("@otplib/totp"),O=require("@otplib/uri");var P=require("@otplib/core"),S=require("@otplib/plugin-base32-scure"),b=require("@otplib/plugin-crypto-noble"),m=Object.freeze(new b.NobleCryptoPlugin),d=Object.freeze(new S.ScureBase32Plugin);function f(t){return{secret:t.secret,strategy:t.strategy??"totp",crypto:t.crypto??m,base32:t.base32??d,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??(0,P.createGuardrails)()}}function h(t){return{...f(t),token:t.token,epochTolerance:t.epochTolerance??0,counterTolerance:t.counterTolerance??0}}function y(t,e,r){if(t==="totp")return r.totp();if(t==="hotp"){if(e===void 0)throw new l.ConfigurationError("Counter is required for HOTP strategy. Example: { strategy: 'hotp', counter: 0 }");return r.hotp(e)}throw new l.ConfigurationError(`Unknown OTP strategy: ${t}. Valid strategies are 'totp' or 'hotp'.`)}function w(t){let{crypto:e=m,base32:r=d,length:n=20}=t||{};return(0,l.generateSecret)({crypto:e,base32:r,length:n})}function C(t){let{strategy:e="totp",issuer:r,label:n,secret:o,algorithm:s="sha1",digits:p=6,period:i=30,counter:a}=t;return y(e,a,{totp:()=>(0,O.generateTOTP)({issuer:r,label:n,secret:o,algorithm:s,digits:p,period:i}),hotp:u=>(0,O.generateHOTP)({issuer:r,label:n,secret:o,algorithm:s,digits:p,counter:u})})}async function D(t){let e=f(t),{secret:r,crypto:n,base32:o,algorithm:s,digits:p}=e,i={secret:r,crypto:n,base32:o,algorithm:s,digits:p};return y(e.strategy,e.counter,{totp:()=>(0,g.generate)({...i,period:e.period,epoch:e.epoch,t0:e.t0,guardrails:e.guardrails}),hotp:a=>(0,c.generate)({...i,counter:a,guardrails:e.guardrails})})}function z(t){let e=f(t),{secret:r,crypto:n,base32:o,algorithm:s,digits:p}=e,i={secret:r,crypto:n,base32:o,algorithm:s,digits:p};return y(e.strategy,e.counter,{totp:()=>(0,g.generateSync)({...i,period:e.period,epoch:e.epoch,t0:e.t0,guardrails:e.guardrails}),hotp:a=>(0,c.generateSync)({...i,counter:a,guardrails:e.guardrails})})}async function B(t){let e=h(t),{secret:r,token:n,crypto:o,base32:s,algorithm:p,digits:i}=e,a={secret:r,token:n,crypto:o,base32:s,algorithm:p,digits:i};return y(e.strategy,e.counter,{totp:()=>(0,g.verify)({...a,period:e.period,epoch:e.epoch,t0:e.t0,epochTolerance:e.epochTolerance,guardrails:e.guardrails}),hotp:u=>(0,c.verify)({...a,counter:u,counterTolerance:e.counterTolerance,guardrails:e.guardrails})})}function k(t){let e=h(t),{secret:r,token:n,crypto:o,base32:s,algorithm:p,digits:i}=e,a={secret:r,token:n,crypto:o,base32:s,algorithm:p,digits:i};return y(e.strategy,e.counter,{totp:()=>(0,g.verifySync)({...a,period:e.period,epoch:e.epoch,t0:e.t0,epochTolerance:e.epochTolerance,guardrails:e.guardrails}),hotp:u=>(0,c.verifySync)({...a,counter:u,counterTolerance:e.counterTolerance,guardrails:e.guardrails})})}0&&(module.exports={generate,generateSecret,generateSync,generateURI,verify,verifySync});
//# sourceMappingURL=functional.cjs.map