You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var f=require("node:crypto"),h=(e,r)=>a=>a.replace(e,r),y=h(/=/g,""),b=e=>e.split("."),l=(e,r)=>a=>a.slice(e,r),w=e=>[l(0,2)(e),l(2)(e)],p=e=>y(btoa(m(e))),d=e=>D(atob(e)),x=e=>e/1e3,c=e=>Math.floor(x(e.now())),S=e=>c(Date)+e,m=JSON.stringify,D=JSON.parse,s=class extends Error{constructor(r){super(r),this.name="TokenError"}},H=e=>r=>a=>f.createHmac(e,r).update(a).digest("base64url"),v=e=>{var[r,a]=w(e);return{HS:i=>H("sha"+i)}[r](a)},k=e=>p({alg:e,typ:"JWT"});function J({exp:e,...r},a,i="HS256"){var t=k(i),n=p({...r,iat:c(Date),...e&&{exp:S(e)}}),o=v(i)(a);return`${t}.${n}.${o(t+"."+n)}`}function $(e,r){var[a,i,t]=b(e),{alg:n}=d(a),o=v(n)(r),u=t!==o(a+"."+i),g=d(i).exp<=c(Date);if(u)throw new s("Invalid signature");if(g)throw new s("Token expired");return{...d(i)}}module.exports={sign:J,verify:$};