authhero 0.90.0 → 0.91.0

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/dist/authhero.cjs CHANGED
@@ -217,9 +217,9 @@ PERFORMANCE OF THIS SOFTWARE.
217
217
  `])))]})},br=({children:t})=>y("div",{className:"mb-2 text-sm text-red",children:t}),u1=t=>t==="small"?"text-base":t==="medium"?"text-2xl":t==="large"?"text-3xl":"",d1=({size:t})=>{const e=u1(t);return y("div",{className:"relative inline-block leading-[0]",children:[y(gt,{className:Et("text-gray-200 dark:text-[#201a41]",{[e]:e}),name:"spinner-circle"}),y(gt,{className:Et("absolute inset-0 animate-spin text-primary",{[e]:e}),name:"spinner-inner"})]})},ti=({children:t,className:e,Component:n="button",variant:r="primary",href:i,disabled:s,isLoading:o,id:c})=>{const l=n==="a"?{href:i}:{};return y(n,{class:Et("relative w-full rounded-lg text-center",e,{"px-4 py-5":r!=="custom","bg-primary text-textOnPrimary hover:bg-primaryHover":r==="primary","border border-gray-300 bg-white text-black":r==="secondary","pointer-events-none cursor-not-allowed opacity-40":s},"focus:outline-none focus:ring"),type:"submit",disabled:s,id:c,...l,children:[y("span",{className:`
218
218
  flex items-center justify-center space-x-2
219
219
  ${o?"invisible h-0":"visible h-auto"}
220
- `,children:t}),o&&y("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(d1,{size:"medium"})})]})},Ti=({connection:t,text:e,icon:n=null,canResize:r=!1,session:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.login_id);const o=`/authorize?${s.toString()}`;return y(ti,{className:Et("border border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-400 dark:bg-black dark:hover:bg-black/90",{"px-0 py-3 sm:px-10 sm:py-4 short:px-0 short:py-3":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:o,children:[n||"",y("div",{className:Et("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},p1=({...t})=>y("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[y("path",{d:"M44.1035 23.0123C44.1054 21.4791 43.9758 19.9486 43.716 18.4375H22.498V27.1028H34.6507C34.4021 28.4868 33.8757 29.8061 33.1034 30.9812C32.3311 32.1562 31.3289 33.1628 30.1571 33.9401V39.5649H37.41C41.6567 35.6494 44.1035 29.859 44.1035 23.0123Z",fill:"#4285F4"}),y("path",{d:"M22.4982 44.9997C28.5698 44.9997 33.6821 43.0061 37.4101 39.5687L30.1573 33.9439C28.1386 35.3126 25.5387 36.0938 22.4982 36.0938C16.6296 36.0938 11.6485 32.1377 9.86736 26.8066H2.39575V32.6033C4.26839 36.3297 7.13989 39.4622 10.6896 41.6512C14.2394 43.8402 18.3277 44.9995 22.4982 44.9997Z",fill:"#34A853"}),y("path",{d:"M9.86737 26.8073C8.92572 24.0138 8.92572 20.9886 9.86737 18.1951V12.3984H2.39576C0.820432 15.5332 0 18.9929 0 22.5012C0 26.0095 0.820432 29.4692 2.39576 32.604L9.86737 26.8073Z",fill:"#FBBC04"}),y("path",{d:"M22.4982 8.90741C25.7068 8.85499 28.8071 10.0673 31.1291 12.2823L37.5507 5.86064C33.4788 2.03602 28.0843 -0.0637686 22.4982 0.00147616C18.3277 0.00166623 14.2394 1.16098 10.6896 3.34999C7.13989 5.539 4.26839 8.67155 2.39575 12.3979L9.86736 18.1946C11.6485 12.8635 16.6296 8.90741 22.4982 8.90741Z",fill:"#EA4335"})]}),Pn=({children:t,className:e})=>y(pu,{children:[y(ti,{className:e,id:"initial-btn",children:t}),y(ti,{className:Et(e,"hidden"),isLoading:!0,id:"loading-btn",disabled:!0,children:" "})]}),Rn=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),f1=({...t})=>y("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 48 48",enableBackground:"new 0 0 48 48",width:"45",height:"45",...t,children:[y("path",{fill:"#FF5B24",d:"M3.5,8h41c1.9,0,3.5,1.6,3.5,3.5v25c0,1.9-1.6,3.5-3.5,3.5h-41C1.6,40,0,38.4,0,36.5v-25C0,9.6,1.6,8,3.5,8z"}),y("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FFFFFF",d:`M27.9,20.3c1.4,0,2.6-1,2.6-2.5h0c0-1.5-1.2-2.5-2.6-2.5c-1.4,0-2.6,1-2.6,2.5C25.3,19.2,26.5,20.3,27.9,20.3z
220
+ `,children:t}),o&&y("div",{className:"absolute left-0 top-0 flex h-full w-full items-center justify-center",children:y(d1,{size:"medium"})})]})},Ti=({connection:t,text:e,icon:n=null,canResize:r=!1,loginSession:i})=>{const s=new URLSearchParams({client_id:i.authParams.client_id,connection:t});i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.redirect_uri&&s.set("redirect_uri",i.authParams.redirect_uri),i.authParams.scope&&s.set("scope",i.authParams.scope),i.authParams.nonce&&s.set("nonce",i.authParams.nonce),i.authParams.response_type&&s.set("response_type",i.authParams.response_type),i.authParams.state&&s.set("state",i.id);const o=`/authorize?${s.toString()}`;return y(ti,{className:Et("border border-gray-200 bg-white hover:bg-gray-100 dark:border-gray-400 dark:bg-black dark:hover:bg-black/90",{"px-0 py-3 sm:px-10 sm:py-4 short:px-0 short:py-3":r,"px-10 py-3":!r}),variant:"custom","aria-label":e,Component:"a",href:o,children:[n||"",y("div",{className:Et("text-left text-black dark:text-white sm:text-base",{"hidden sm:inline short:hidden":r}),children:e})]})},p1=({...t})=>y("svg",{width:"45",height:"45",viewBox:"0 0 45 45",xmlns:"http://www.w3.org/2000/svg",...t,children:[y("path",{d:"M44.1035 23.0123C44.1054 21.4791 43.9758 19.9486 43.716 18.4375H22.498V27.1028H34.6507C34.4021 28.4868 33.8757 29.8061 33.1034 30.9812C32.3311 32.1562 31.3289 33.1628 30.1571 33.9401V39.5649H37.41C41.6567 35.6494 44.1035 29.859 44.1035 23.0123Z",fill:"#4285F4"}),y("path",{d:"M22.4982 44.9997C28.5698 44.9997 33.6821 43.0061 37.4101 39.5687L30.1573 33.9439C28.1386 35.3126 25.5387 36.0938 22.4982 36.0938C16.6296 36.0938 11.6485 32.1377 9.86736 26.8066H2.39575V32.6033C4.26839 36.3297 7.13989 39.4622 10.6896 41.6512C14.2394 43.8402 18.3277 44.9995 22.4982 44.9997Z",fill:"#34A853"}),y("path",{d:"M9.86737 26.8073C8.92572 24.0138 8.92572 20.9886 9.86737 18.1951V12.3984H2.39576C0.820432 15.5332 0 18.9929 0 22.5012C0 26.0095 0.820432 29.4692 2.39576 32.604L9.86737 26.8073Z",fill:"#FBBC04"}),y("path",{d:"M22.4982 8.90741C25.7068 8.85499 28.8071 10.0673 31.1291 12.2823L37.5507 5.86064C33.4788 2.03602 28.0843 -0.0637686 22.4982 0.00147616C18.3277 0.00166623 14.2394 1.16098 10.6896 3.34999C7.13989 5.539 4.26839 8.67155 2.39575 12.3979L9.86736 18.1946C11.6485 12.8635 16.6296 8.90741 22.4982 8.90741Z",fill:"#EA4335"})]}),Pn=({children:t,className:e})=>y(pu,{children:[y(ti,{className:e,id:"initial-btn",children:t}),y(ti,{className:Et(e,"hidden"),isLoading:!0,id:"loading-btn",disabled:!0,children:" "})]}),Rn=({children:t,className:e})=>y("form",{id:"form",method:"post",className:e,children:t}),f1=({...t})=>y("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 48 48",enableBackground:"new 0 0 48 48",width:"45",height:"45",...t,children:[y("path",{fill:"#FF5B24",d:"M3.5,8h41c1.9,0,3.5,1.6,3.5,3.5v25c0,1.9-1.6,3.5-3.5,3.5h-41C1.6,40,0,38.4,0,36.5v-25C0,9.6,1.6,8,3.5,8z"}),y("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"#FFFFFF",d:`M27.9,20.3c1.4,0,2.6-1,2.6-2.5h0c0-1.5-1.2-2.5-2.6-2.5c-1.4,0-2.6,1-2.6,2.5C25.3,19.2,26.5,20.3,27.9,20.3z
221
221
  M31.2,24.4c-1.7,2.2-3.5,3.8-6.7,3.8h0c-3.2,0-5.8-2-7.7-4.8c-0.8-1.2-2-1.4-2.9-0.8c-0.8,0.6-1,1.8-0.3,2.9
222
- c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),Mp=({error:t,vendorSettings:e,session:n,email:r,client:i,impersonation:s})=>{const o=i.connections.map(({name:m})=>m),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),h=c||l||u||p;return y(Nt,{title:U.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:U.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"mb-7",children:[y("input",{type:"email",name:"username",placeholder:U.t("email_placeholder"),className:Et("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:r||""}),s&&y("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:Et("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&y(br,{children:t}),y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("continue")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})]}),h&&y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:U.t("continue_social_login")})]}),y("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&y(Ti,{connection:"facebook",text:U.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(gt,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),session:n}),l&&y(Ti,{connection:"google-oauth2",text:U.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(p1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n}),u&&y(Ti,{connection:"apple",text:U.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(gt,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),session:n}),p&&y(Ti,{connection:"vipps",text:U.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(f1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),session:n})]})]})]})},h1=["Auth0.swift"];function g1(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return h1.includes(n.name)?"code":"link"}const m1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i,client:s}=await Ke(t,e);return t.html(y(Mp,{vendorSettings:r,session:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,loginSession:s,vendorSettings:o}=await Ke(t,n);t.set("client_id",i.id);const c=r.username,l=await no({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await ay(t,i,t.env.data,r.username)}catch{const v=ve(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,v),t.html(y(Mp,{vendorSettings:o,session:s,error:U.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,s.authParams.act_as=r.act_as,await e.data.loginSessions.update(i.tenant.id,s.id,s),await t1(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=or(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=or(),p=await e.data.codes.get(i.tenant.id,u,"otp");const h=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Ca).toISOString()});return g1(s.auth0Client)==="link"&&!r.username.includes("online.no")?et(t,su(t,r.username,h.code_id,s.authParams)):et(t,Fg(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)}),tn=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:U.t("go_back")});var ni="_hp",_1={Change:"Input",DoubleClick:"DblClick"},y1={svg:"2000/svg",math:"1998/Math/MathML"},ri=[],Xc=new WeakMap,cr=void 0,v1=()=>cr,jt=t=>"t"in t,ya={onClick:["click",!1]},Dp=t=>{if(!t.startsWith("on"))return;if(ya[t])return ya[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return ya[t]=[(_1[n]||n).toLowerCase(),!!r]}},Hp=(t,e)=>cr&&t instanceof SVGElement&&/[A-Z]/.test(e)&&(e in t.style||e.match(/^(?:o|pai|str|u|ve)/))?e.replace(/([A-Z])/g,"-$1").toLowerCase():e,w1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Ks(i);const o=Dp(i);if(o){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(o[0],n[i],o[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(o[0],s,o[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),Xc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&Qg(s,c.setProperty.bind(c)))}else{if(i==="value"){const l=t.nodeName;if(l==="INPUT"||l==="TEXTAREA"||l==="SELECT"){if(t.value=s==null||s===!1?null:s,l==="TEXTAREA"){t.textContent=s;continue}else if(l==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Hp(t,i);s==null||s===!1?t.removeAttribute(c):s===!0?t.setAttribute(c,""):typeof s=="string"||typeof s=="number"?t.setAttribute(c,s):t.setAttribute(c,s.toString())}}}if(n)for(let i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Ks(i);const o=Dp(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=Xc.get(t))==null||r():t.removeAttribute(Hp(t,i))}}},b1=(t,e)=>{e[Ae][0]=0,ri.push([t,e]);const n=e.tag[lu]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{ri.pop()}},rm=(t,e,n,r,i)=>{var s,o;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((o=t[Ae][1][am])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(jt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(rm(c,e,n,r,i),c.s){for(let p=u;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},k1=t=>{for(;;t=t.tag===ni||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ni&&t.e)return t.e}},im=t=>{var e,n,r,i,s,o;jt(t)||((n=(e=t[Ae])==null?void 0:e[1][am])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Xc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(im)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(Nr.delete(t),Gi.delete(t),delete t[Ae][3],t.a=!0)},sm=(t,e,n)=>{t.c=e,om(t,e,n)},Fp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Kp=Symbol(),om=(t,e,n)=>{var u;const r=[],i=[],s=[];rm(t,e,r,i,s),i.forEach(im);const o=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!o.length)c=0;else{const p=Fp(o,k1(t.nN));p!==void 0?(l=o[p],c=p):c=Fp(o,(u=r.find(h=>h.tag!==ni&&h.e))==null?void 0:u.e)??-1,c===-1&&(n=!0)}for(let p=0,h=r.length;p<h;p++,c++){const m=r[p];let v;if(m.s&&m.e)v=m.e,m.s=!1;else{const f=n||!m.e;jt(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,v=m.e||(m.e=document.createTextNode(m.t))):(v=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),w1(v,m.props,m.pP),om(m,v,f))}m.tag===ni?c--:n?v.parentNode||e.appendChild(v):o[c]!==v&&o[c-1]!==v&&(o[c+1]===v?e.appendChild(o[c]):e.insertBefore(v,l||o[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],h=[];s.forEach(([,m,,v,f])=>{m&&p.push(m),v&&h.push(v),f==null||f()}),p.forEach(m=>m()),h.length&&requestAnimationFrame(()=>{h.forEach(m=>m())})}},Gi=new WeakMap,Qc=(t,e,n)=>{var s,o,c,l,u,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?b1(t,e):Si(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Zc]&&(i=n[0][Zc],t[5].push([t,i,e]));const h=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let v;for(let f=0;f<n.length;f++){Array.isArray(n[f])&&n.splice(f,1,...n[f].flat());let _=x1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Gg]&&(ar.length>0&&(_[Ae][2]=ar.map(S=>[S,S.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Ae][3]=t[5].at(-1)));let w;if(h&&h.length){const S=h.findIndex(jt(_)?C=>jt(C):_.key!==void 0?C=>C.key===_.key&&C.tag===_.tag:C=>C.tag===_.tag);S!==-1&&(w=h[S],h.splice(S,1))}if(w)if(jt(_))w.t!==_.t&&(w.t=_.t,w.d=!0),_=w;else{const S=w.pP=w.props;w.props=_.props,w.f||(w.f=_.f||e.f),typeof _.tag=="function"&&(w[Ae][2]=_[Ae][2]||[],w[Ae][3]=_[Ae][3],!w.f&&((w.o||w)===_.o||(l=(c=w.tag)[Ub])!=null&&l.call(c,S,w.props))&&(w.s=!0)),_=w}else if(!jt(_)&&cr){const S=wr(cr);S&&(_.n=S)}if(!jt(_)&&!_.s&&(Qc(t,_),delete _.f),m.push(_),v&&!v.s&&!_.s)for(let S=v;S&&!jt(S);S=(u=S.vC)==null?void 0:u.at(-1))S.nN=_;v=_}}e.vR=r?[...e.vC,...h||[]]:h||[],e.vC=m,r&&delete e.pC}catch(h){if(e.f=!0,h===Kp){if(i)return;throw h}const[m,v,f]=((p=e[Ae])==null?void 0:p[3])||[];if(v){const _=()=>Ji([0,!1,t[2]],f),w=Gi.get(f)||[];w.push(_),Gi.set(f,w);const S=v(h,()=>{const C=Gi.get(f);if(C){const B=C.indexOf(_);if(B!==-1)return C.splice(B,1),_()}});if(S){if(t[0]===1)t[1]=!0;else if(Qc(t,f,[S]),(v.length===1||t!==m)&&f.c){sm(f,f.c,!1);return}throw Kp}}throw h}finally{i&&t[5].pop()}},x1=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Ae]=[0,[]];else{const e=y1[t.tag];e&&(cr||(cr=Zg("")),t.props.children=[{tag:cr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Wp=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Qc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&sm(e,e.c,!1)},Nr=new WeakMap,Gp=[],Ji=async(t,e)=>{t[5]||(t[5]=[]);const n=Nr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(Nr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Wp(s,e)}).then(()=>r(e)):(Wp(t,e),r(e))}]),Gp.length)Gp.at(-1).add(e);else{await Promise.resolve();const s=Nr.get(e);s&&(Nr.delete(e),s[1]())}return i},S1=(t,e,n)=>({tag:ni,props:{children:t},key:n,e,p:1}),va=0,am=1,wa=2,ba=3,ka=new WeakMap,cm=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),A1=void 0,Jp=[],E1=t=>{var o;const e=()=>typeof t=="function"?t():t,n=ri.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Ae][1])[va]||(o[va]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const l=A1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Jp.length){const[p,h]=Jp.at(-1);Promise.all([p===3?r:Ji([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const v=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{v===m.vC&&Ji([p===3?1:0,!1,l],m)})})})}else Ji([0,!1,l],r)}])},fu=(t,e)=>{var c;const n=ri.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[wa]||(c[wa]=[]),s=r[Ae][0]++,o=i[s];return cm(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},I1=t=>{const e=ka.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>ka.set(t,[n]),n=>ka.set(t,[void 0,n])),t},z1=(t,e)=>{var c;const n=ri.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[ba]||(c[ba]=[]),s=r[Ae][0]++,o=i[s];return cm(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},C1=Zg({pending:!1,data:null,method:null,action:null}),Zp=new Set,N1=t=>{Zp.add(t),t.finally(()=>Zp.delete(t))},hu=(t,e)=>z1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),qn=Object.create(null),Pi=Object.create(null),Ii=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:o,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const v=Fi[t];let f;if(v.length>0){const C=s.querySelectorAll(t);e:for(const B of C)for(const R of Fi[t])if(B.getAttribute(R)===e[R]){h=B;break e}if(!h){const B=v.reduce((R,Q)=>e[Q]===void 0?R:`${R}-${Q}-${e[Q]}`,t);m=!Pi[B],h=Pi[B]||(Pi[B]=(()=>{const R=document.createElement(t);for(const Q of v)e[Q]!==void 0&&R.setAttribute(Q,e[Q]),e.rel&&R.setAttribute("rel",e.rel);return R})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Ki]=l);const _=fu(C=>{if(v.length>0){let B=!1;for(const R of s.querySelectorAll(t)){if(B&&R.getAttribute(Ki)!==l){s.insertBefore(C,R);return}R.getAttribute(Ki)===l&&(B=!0)}s.appendChild(C)}else if(f){let B=!1;for(const R of f)if(R===C){B=!0;break}B||s.insertBefore(C,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),w=hu(e.ref,C=>{var Q;const B=v[0];if(n===2&&(C.innerHTML=""),(m||f)&&_(C),!c&&!o)return;let R=qn[Q=C.getAttribute(B)]||(qn[Q]=new Promise((ae,ce)=>{C.addEventListener("load",ae),C.addEventListener("error",ce)}));o&&(R=R.then(o)),c&&(R=R.catch(c)),R.catch(()=>{})});if(i&&u==="render"){const C=Fi[t][0];if(e[C]){const B=e[C],R=qn[B]||(qn[B]=new Promise((Q,ae)=>{_(h),h.addEventListener("load",Q),h.addEventListener("error",ae)}));I1(R)}}const S={tag:t,type:t,props:{...p,ref:w},ref:w};return S.p=n,h&&(S.e=h),S1(S,s)},j1=t=>{const e=v1(),n=e&&wr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Ii("title",t,void 0,!1,!1)},$1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Ii("script",t,1,!1,!0),O1=t=>!t||!["href","precedence"].every(e=>e in t)?{tag:"style",props:t,type:"style",ref:t.ref}:(t["data-href"]=t.href,delete t.href,Ii("style",t,2,!0,!0)),B1=t=>!t||["onLoad","onError"].some(e=>e in t)||t.rel==="stylesheet"&&(!("precedence"in t)||"disabled"in t)?{tag:"link",props:t,type:"link",ref:t.ref}:Ii("link",t,1,"precedence"in t,!0),T1=t=>Ii("meta",t,void 0,!1,!1),lm=Symbol(),P1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=E1([null,!1]),s=fu(async u=>{const p=u.isTrusted?e:u.detail[lm];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(N1(m),await m),i([null,!0])},[]),o=hu(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:C1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:o},type:"form",ref:o}},f:l}},um=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=fu(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[lm]:e}}))},[]);n.ref=hu(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},R1=t=>um("input",t),L1=t=>um("button",t);Object.assign(Yc,{title:j1,script:$1,style:O1,link:B1,meta:T1,form:P1,input:R1,button:L1});new TextEncoder;const dm=t=>{const{i18nKey:e,values:n,components:r}=t,i=U.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&o.push(h);const m=parseInt(u,10);o.push(e1(r[m],{},p)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),y(pu,{children:o})},Yp=6,Xp=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return y(Nt,{title:U.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:U.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(dm,{i18nKey:"we_sent_a_code_to",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:Yp,inputMode:"numeric",name:"code",placeholder:"******",className:Et("mb-2 w-full rounded-lg border bg-gray-100 px-4 pb-2 pt-2.5 text-center indent-[5px] font-mono text-3xl placeholder:text-gray-300 dark:bg-gray-600 md:text-3xl",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),minLength:Yp,required:!0,id:"code-input"}),t&&y(br,{children:t}),y("div",{className:"text-center sm:mt-2",children:y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]}),l&&y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:U.t("or")})]}),y(ti,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:U.t("enter_your_password_btn")})]})]}),y(tn,{state:r})]})]})},U1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ke(t,e);if(!r.authParams.username)throw new N(400,{message:"Username not found in state"});const s=await cs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Xp,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({code:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{loginSession:r,client:i,vendorSettings:s}=await Ke(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new N(400,{message:"Username not found in state"});try{return await au(t,i,r.authParams,r.authParams.username,n)}catch(o){const c=o,l=await cs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Xp,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),V1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:U.t("unverified_email"),vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:U.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]}),y(tn,{state:n})]}),y(tn,{state:n})]})},xa=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Nt,{title:U.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:U.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:U.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),y("input",{type:"password",name:"password",placeholder:U.t("password")||"",className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),e&&y(br,{children:e}),y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:U.t("forgot_password_link")}),y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:U.t("or")})]}),y("form",{method:"post",action:`/u/enter-email?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(ti,{variant:"secondary",className:"block",children:U.t("enter_a_code_btn")})]})]}),y(tn,{state:i})]})]})},q1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ke(t,e);if(!i.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(xa,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,loginSession:o}=await Ke(t,e),{username:c}=o.authParams;if(!c)throw new N(400,{message:"Username required"});try{return await cu(t,s,{...o.authParams,password:r},o)}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(y(xa,{vendorSettings:i,email:c,error:U.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(y(V1,{vendorSettings:i,state:e}),400):t.html(y(xa,{vendorSettings:i,email:c,error:u.message,state:e,client:s}),400)}}),zr=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Nt,{title:U.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:U.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:U.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:i,disabled:!!i}),y("input",{type:"password",name:"password",placeholder:U.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:U.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),n&&y(br,{children:n}),y(Pn,{className:"text-base sm:mt-2 md:text-base",children:U.t("continue")})]}),y(tn,{state:e})]})]})},pm=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Nt,{title:"Login",vendorSettings:n,children:[r?y("div",{className:"mb-6 text-gray-300",children:r}):"",y("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?y(tn,{state:i}):""]})},M1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().optional().openapi({description:"The code parameter from an email verification link"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i}=await Ke(t,e),{username:s}=i.authParams;if(!s)throw new N(400,{message:"Username required"});return n?t.html(y(zr,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(zr,{state:e,vendorSettings:r,email:s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.z.string(),code:a.z.string().optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{env:r}=t,{vendorSettings:i,client:s,loginSession:o}=await Ke(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const l=o.authParams.username;if(!l)throw new N(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(zr,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_passwords_didnt_match"),email:o.authParams.username}),400);if(!iu(n.password))return t.html(y(zr,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_weak_password"),email:o.authParams.username}),400);const u=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,p=u?await r.data.loginSessions.get(s.tenant.id,u.login_id):void 0;try{if(await si({userAdapter:t.env.data.users,tenant_id:s.tenant.id,email:l,provider:"auth2"}))throw new N(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,v=await Uf(t).users.create(s.tenant.id,{user_id:`auth2|${Ys()}`,email:l,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:v.user_id,password:await ii.hash(n.password,10),algorithm:"bcrypt"}),m?await cu(t,s,{...o.authParams,password:n.password},o):(await ou(t,v),t.html(y(pm,{message:U.t("validate_email_body"),pageTitle:U.t("validate_email_title"),vendorSettings:i,state:e})))}catch(h){const m=await tm(r,s.id,o.authParams.vendor_id),v=h;return t.html(y(zr,{state:e,vendorSettings:m,error:v.message,email:l}),400)}}),Cr=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Nt,{title:U.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${U.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Rn,{children:[y("input",{type:"password",name:"password",placeholder:U.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:U.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),e&&y(br,{children:e}),y(Pn,{className:"text-base sm:mt-2 md:text-base",children:U.t("reset_password_cta")})]})})]})},D1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ke(t,e);if(!r.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(Cr,{vendorSettings:n,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{password:r,"re-enter-password":i}=t.req.valid("form"),{env:s}=t,{vendorSettings:o,client:c,loginSession:l}=await Ke(t,e);if(!l.authParams.username)throw new N(400,{message:"Username required"});if(r!==i)return t.html(y(Cr,{error:U.t("create_account_passwords_didnt_match"),vendorSettings:o,email:l.authParams.username}),400);if(!iu(r))return t.html(y(Cr,{error:U.t("create_account_weak_password"),vendorSettings:o,email:l.authParams.username}),400);const u=await si({userAdapter:s.data.users,tenant_id:c.tenant.id,email:l.authParams.username,provider:"auth2"});if(!u)throw new N(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(Cr,{error:"Code not found or expired",vendorSettings:o,email:l.authParams.username}),400);const h={user_id:u.user_id,password:await ii.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,u.user_id)?await s.data.passwords.update(c.tenant.id,h):await s.data.passwords.create(c.tenant.id,h),u.email_verified||await s.data.users.update(c.tenant.id,u.user_id,{email_verified:!0})}catch{return t.html(y(Cr,{error:"The password could not be reset",vendorSettings:o,email:l.authParams.username}),400)}return t.html(y(pm,{message:U.t("password_has_been_reset"),vendorSettings:o,state:e}))}),H1=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Nt,{title:U.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:U.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:U.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r,disabled:!!r}),e&&y(br,{children:e}),y(Pn,{className:"sm:mt-4",children:U.t("forgot_password_cta")})]}),y(tn,{state:i})]})]})},F1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:U.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]})]}),y(tn,{state:n})]})},K1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ke(t,e);return t.html(y(H1,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ke(t,e);return await Ib(t,r,i.authParams.username,i.id),t.html(y(F1,{vendorSettings:n,state:e}))}),W1=({vendorSettings:t,state:e,user:n})=>y(Nt,{title:pe("check_email_title"),vendorSettings:t,children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-8 text-gray-700 dark:text-gray-300",children:[y(dm,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email}}),y("br",{}),pe("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Rn,{children:y(Pn,{className:"w-full text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center justify-center space-x-2",children:y("span",{children:U.t("yes_continue_with_existing_account")})})})}),y("a",{className:"block text-center text-primary hover:text-primaryHover focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:focus:ring-offset-gray-900",href:`/u/enter-email?state=${encodeURIComponent(e)}`,children:U.t("no_use_another")})]})]})}),G1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{vendorSettings:r,client:i}=await Ke(t,n),s=as(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?t.html(y(W1,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/enter-email?state=${n}`)}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{302:{description:"Redirect"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{loginSession:r,client:i}=await Ke(t,n),s=as(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?on(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/enter-email?state=${n}`)});function J1(t){const e=new a.OpenAPIHono;e.use(async(r,i)=>(r.env.data=to(r,t.dataAdapter),i()));const n=e.route("/check-account",G1).route("/enter-email",m1).route("/enter-code",U1).route("/enter-password",q1).route("/reset-password",D1).route("/forgot-password",K1).route("/signup",M1);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const Z1="Account detected",Y1="We have detected that you have already created an account through",X1="By signing in, you agree to our",Q1="and",ek="Callback URL mismatch",tk="The provided redirect_uri is not in the list of allowed callback URLs.",nk="continue with user",rk="Please click the button to create a new password account.",ik="Enter the code at {{vendorName}} to complete the login",sk="Welcome to {{vendorName}}! {{code}} is the login code",ok="Welcome to {{vendorName}}! {{code}} is the login code",ak="The code is valid for 30 minutes",ck="Confirm password",lk="Need Help?",uk="Contact us",dk="or continue with social account",pk="Continue with {{provider}}",fk="Would you like to continue with your existing account?",hk="Copyright © 2023 SESAMY. All rights reserved.",gk="©2023 Sesamy",mk="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",_k="Please enter a valid email address.",yk="The passwords didn't match. Try again.",vk="Choose password",wk="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",bk="Create new account",kk="Sign up with password",xk="You are currently logged in as <0>{{email}}</0>",Sk="Email",Ak="Email address",Ek="Your email address has been validated",Ik="Now enter your password to login again",zk="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",Ck="Email verification sent",Nk="Enter a code",jk="We'll send you a verification link to ensure you own this email address.",$k="Enter new password",Ok="Enter password",Bk="Enter your email address and password to login.",Tk="Enter your password",Pk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",Rk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",Lk="Send password reset email",Uk="Click the button below and we’ll send instructions on how to reset your password.",Vk="Password reset email sent",qk="Forgot password?",Mk="Forgot password?",Dk="Go back",Hk="Invalid password",Fk=`The link is no longer valid.
222
+ c2.7,4.1,6.5,6.6,10.9,6.6c4,0,7.2-2,9.6-5.2c0.9-1.2,0.9-2.5,0-3.1C33.3,22.9,32.1,23.2,31.2,24.4z`})]}),Mp=({error:t,vendorSettings:e,loginSession:n,email:r,client:i,impersonation:s})=>{const o=i.connections.map(({name:m})=>m),c=o.includes("facebook"),l=o.includes("google-oauth2"),u=o.includes("apple"),p=o.includes("vipps"),h=c||l||u||p;return y(Nt,{title:U.t("welcome"),vendorSettings:e,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("welcome")}),y("div",{className:"mb-8 text-gray-300",children:U.t("login_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"mb-7",children:[y("input",{type:"email",name:"username",placeholder:U.t("email_placeholder"),className:Et("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:r||""}),s&&y("input",{type:"email",name:"act_as",placeholder:"Impersonate as",className:Et("mb-2 w-full rounded-lg border bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),required:!0,value:""}),t&&y(br,{children:t}),y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("continue")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})]}),h&&y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:U.t("continue_social_login")})]}),y("div",{className:"flex space-x-4 sm:flex-col sm:space-x-0 sm:space-y-4 short:flex-row short:space-x-4 short:space-y-0",children:[c&&y(Ti,{connection:"facebook",text:U.t("continue_with",{provider:"Facebook"}),canResize:!0,icon:y(gt,{className:"text-xl text-[#1196F5] sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"facebook"}),loginSession:n}),l&&y(Ti,{connection:"google-oauth2",text:U.t("continue_with",{provider:"Google"}),canResize:!0,icon:y(p1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n}),u&&y(Ti,{connection:"apple",text:U.t("continue_with",{provider:"Apple"}),canResize:!0,icon:y(gt,{className:"text-xl text-black dark:text-white sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2 sm:text-2xl short:static short:left-auto short:top-auto short:translate-y-0 short:text-xl",name:"apple"}),loginSession:n}),p&&y(Ti,{connection:"vipps",text:U.t("continue_with",{provider:"Vipps"}),canResize:!0,icon:y(f1,{className:"h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0"}),loginSession:n})]})]})]})},h1=["Auth0.swift"];function g1(t){if(!t)return"code";const e=atob(t),n=JSON.parse(e);return h1.includes(n.name)?"code":"link"}const m1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),impersonation:a.z.string().optional()})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,impersonation:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i,client:s}=await Ke(t,e);return t.html(y(Mp,{vendorSettings:r,loginSession:i,client:s,email:i.authParams.username,impersonation:n==="true"}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({username:a.z.string().transform(t=>t.toLowerCase()),act_as:a.z.string().transform(t=>t.toLowerCase()).optional(),login_selection:a.z.enum(["code","password"]).optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),r=t.req.valid("form");t.set("body",r),t.set("username",r.username);const{client:i,loginSession:s,vendorSettings:o}=await Ke(t,n);t.set("client_id",i.id);const c=r.username,l=await no({userAdapter:e.data.users,tenant_id:i.tenant.id,email:c});if(l&&t.set("user_id",l.user_id),!l)try{await ay(t,i,t.env.data,r.username)}catch{const v=ve(t,{type:he.FAILED_SIGNUP,description:"Public signup is disabled"});return await t.env.data.logs.create(i.tenant.id,v),t.html(y(Mp,{vendorSettings:o,loginSession:s,error:U.t("user_account_does_not_exist"),email:r.username,client:i}),400)}if(s.authParams.username=r.username,s.authParams.act_as=r.act_as,await e.data.loginSessions.update(i.tenant.id,s.id,s),await t1(t,i,r.username,r.login_selection))return t.redirect(`/u/enter-password?state=${n}`);let u=or(),p=await e.data.codes.get(i.tenant.id,u,"otp");for(;p;)u=or(),p=await e.data.codes.get(i.tenant.id,u,"otp");const h=await t.env.data.codes.create(i.tenant.id,{code_id:u,code_type:"otp",login_id:s.id,expires_at:new Date(Date.now()+Ca).toISOString()});return g1(s.auth0Client)==="link"&&!r.username.includes("online.no")?et(t,su(t,r.username,h.code_id,s.authParams)):et(t,Fg(t,r.username,h.code_id)),t.redirect(`/u/enter-code?state=${n}`)}),tn=t=>y("a",{className:"block text-primary hover:text-primaryHover text-center",href:`/u/enter-email?state=${t.state}`,children:U.t("go_back")});var ni="_hp",_1={Change:"Input",DoubleClick:"DblClick"},y1={svg:"2000/svg",math:"1998/Math/MathML"},ri=[],Xc=new WeakMap,cr=void 0,v1=()=>cr,jt=t=>"t"in t,ya={onClick:["click",!1]},Dp=t=>{if(!t.startsWith("on"))return;if(ya[t])return ya[t];const e=t.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);if(e){const[,n,r]=e;return ya[t]=[(_1[n]||n).toLowerCase(),!!r]}},Hp=(t,e)=>cr&&t instanceof SVGElement&&/[A-Z]/.test(e)&&(e in t.style||e.match(/^(?:o|pai|str|u|ve)/))?e.replace(/([A-Z])/g,"-$1").toLowerCase():e,w1=(t,e,n)=>{var r;e||(e={});for(let i in e){const s=e[i];if(i!=="children"&&(!n||n[i]!==s)){i=Ks(i);const o=Dp(i);if(o){if((n==null?void 0:n[i])!==s&&(n&&t.removeEventListener(o[0],n[i],o[1]),s!=null)){if(typeof s!="function")throw new Error(`Event handler for "${i}" is not a function`);t.addEventListener(o[0],s,o[1])}}else if(i==="dangerouslySetInnerHTML"&&s)t.innerHTML=s.__html;else if(i==="ref"){let c;typeof s=="function"?c=s(t)||(()=>s(null)):s&&"current"in s&&(s.current=t,c=()=>s.current=null),Xc.set(t,c)}else if(i==="style"){const c=t.style;typeof s=="string"?c.cssText=s:(c.cssText="",s!=null&&Qg(s,c.setProperty.bind(c)))}else{if(i==="value"){const l=t.nodeName;if(l==="INPUT"||l==="TEXTAREA"||l==="SELECT"){if(t.value=s==null||s===!1?null:s,l==="TEXTAREA"){t.textContent=s;continue}else if(l==="SELECT"){t.selectedIndex===-1&&(t.selectedIndex=0);continue}}}else(i==="checked"&&t.nodeName==="INPUT"||i==="selected"&&t.nodeName==="OPTION")&&(t[i]=s);const c=Hp(t,i);s==null||s===!1?t.removeAttribute(c):s===!0?t.setAttribute(c,""):typeof s=="string"||typeof s=="number"?t.setAttribute(c,s):t.setAttribute(c,s.toString())}}}if(n)for(let i in n){const s=n[i];if(i!=="children"&&!(i in e)){i=Ks(i);const o=Dp(i);o?t.removeEventListener(o[0],s,o[1]):i==="ref"?(r=Xc.get(t))==null||r():t.removeAttribute(Hp(t,i))}}},b1=(t,e)=>{e[Ae][0]=0,ri.push([t,e]);const n=e.tag[lu]||e.tag,r=n.defaultProps?{...n.defaultProps,...e.props}:e.props;try{return[n.call(null,r)]}finally{ri.pop()}},rm=(t,e,n,r,i)=>{var s,o;(s=t.vR)!=null&&s.length&&(r.push(...t.vR),delete t.vR),typeof t.tag=="function"&&((o=t[Ae][1][am])==null||o.forEach(c=>i.push(c))),t.vC.forEach(c=>{var l;if(jt(c))n.push(c);else if(typeof c.tag=="function"||c.tag===""){c.c=e;const u=n.length;if(rm(c,e,n,r,i),c.s){for(let p=u;p<n.length;p++)n[p].s=!0;c.s=!1}}else n.push(c),(l=c.vR)!=null&&l.length&&(r.push(...c.vR),delete c.vR)})},k1=t=>{for(;;t=t.tag===ni||!t.vC||!t.pP?t.nN:t.vC[0]){if(!t)return null;if(t.tag!==ni&&t.e)return t.e}},im=t=>{var e,n,r,i,s,o;jt(t)||((n=(e=t[Ae])==null?void 0:e[1][am])==null||n.forEach(c=>{var l;return(l=c[2])==null?void 0:l.call(c)}),(r=Xc.get(t.e))==null||r(),t.p===2&&((i=t.vC)==null||i.forEach(c=>c.p=2)),(s=t.vC)==null||s.forEach(im)),t.p||((o=t.e)==null||o.remove(),delete t.e),typeof t.tag=="function"&&(Nr.delete(t),Gi.delete(t),delete t[Ae][3],t.a=!0)},sm=(t,e,n)=>{t.c=e,om(t,e,n)},Fp=(t,e)=>{if(e){for(let n=0,r=t.length;n<r;n++)if(t[n]===e)return n}},Kp=Symbol(),om=(t,e,n)=>{var u;const r=[],i=[],s=[];rm(t,e,r,i,s),i.forEach(im);const o=n?void 0:e.childNodes;let c,l=null;if(n)c=-1;else if(!o.length)c=0;else{const p=Fp(o,k1(t.nN));p!==void 0?(l=o[p],c=p):c=Fp(o,(u=r.find(h=>h.tag!==ni&&h.e))==null?void 0:u.e)??-1,c===-1&&(n=!0)}for(let p=0,h=r.length;p<h;p++,c++){const m=r[p];let v;if(m.s&&m.e)v=m.e,m.s=!1;else{const f=n||!m.e;jt(m)?(m.e&&m.d&&(m.e.textContent=m.t),m.d=!1,v=m.e||(m.e=document.createTextNode(m.t))):(v=m.e||(m.e=m.n?document.createElementNS(m.n,m.tag):document.createElement(m.tag)),w1(v,m.props,m.pP),om(m,v,f))}m.tag===ni?c--:n?v.parentNode||e.appendChild(v):o[c]!==v&&o[c-1]!==v&&(o[c+1]===v?e.appendChild(o[c]):e.insertBefore(v,l||o[c]||null))}if(t.pP&&delete t.pP,s.length){const p=[],h=[];s.forEach(([,m,,v,f])=>{m&&p.push(m),v&&h.push(v),f==null||f()}),p.forEach(m=>m()),h.length&&requestAnimationFrame(()=>{h.forEach(m=>m())})}},Gi=new WeakMap,Qc=(t,e,n)=>{var s,o,c,l,u,p;const r=!n&&e.pC;n&&(e.pC||(e.pC=e.vC));let i;try{n||(n=typeof e.tag=="function"?b1(t,e):Si(e.props.children)),((s=n[0])==null?void 0:s.tag)===""&&n[0][Zc]&&(i=n[0][Zc],t[5].push([t,i,e]));const h=r?[...e.pC]:e.vC?[...e.vC]:void 0,m=[];let v;for(let f=0;f<n.length;f++){Array.isArray(n[f])&&n.splice(f,1,...n[f].flat());let _=x1(n[f]);if(_){typeof _.tag=="function"&&!_.tag[Gg]&&(ar.length>0&&(_[Ae][2]=ar.map(S=>[S,S.values.at(-1)])),(o=t[5])!=null&&o.length&&(_[Ae][3]=t[5].at(-1)));let w;if(h&&h.length){const S=h.findIndex(jt(_)?C=>jt(C):_.key!==void 0?C=>C.key===_.key&&C.tag===_.tag:C=>C.tag===_.tag);S!==-1&&(w=h[S],h.splice(S,1))}if(w)if(jt(_))w.t!==_.t&&(w.t=_.t,w.d=!0),_=w;else{const S=w.pP=w.props;w.props=_.props,w.f||(w.f=_.f||e.f),typeof _.tag=="function"&&(w[Ae][2]=_[Ae][2]||[],w[Ae][3]=_[Ae][3],!w.f&&((w.o||w)===_.o||(l=(c=w.tag)[Ub])!=null&&l.call(c,S,w.props))&&(w.s=!0)),_=w}else if(!jt(_)&&cr){const S=wr(cr);S&&(_.n=S)}if(!jt(_)&&!_.s&&(Qc(t,_),delete _.f),m.push(_),v&&!v.s&&!_.s)for(let S=v;S&&!jt(S);S=(u=S.vC)==null?void 0:u.at(-1))S.nN=_;v=_}}e.vR=r?[...e.vC,...h||[]]:h||[],e.vC=m,r&&delete e.pC}catch(h){if(e.f=!0,h===Kp){if(i)return;throw h}const[m,v,f]=((p=e[Ae])==null?void 0:p[3])||[];if(v){const _=()=>Ji([0,!1,t[2]],f),w=Gi.get(f)||[];w.push(_),Gi.set(f,w);const S=v(h,()=>{const C=Gi.get(f);if(C){const B=C.indexOf(_);if(B!==-1)return C.splice(B,1),_()}});if(S){if(t[0]===1)t[1]=!0;else if(Qc(t,f,[S]),(v.length===1||t!==m)&&f.c){sm(f,f.c,!1);return}throw Kp}}throw h}finally{i&&t[5].pop()}},x1=t=>{if(!(t==null||typeof t=="boolean")){if(typeof t=="string"||typeof t=="number")return{t:t.toString(),d:!0};if("vR"in t&&(t={tag:t.tag,props:t.props,key:t.key,f:t.f,type:t.tag,ref:t.props.ref,o:t.o||t}),typeof t.tag=="function")t[Ae]=[0,[]];else{const e=y1[t.tag];e&&(cr||(cr=Zg("")),t.props.children=[{tag:cr,props:{value:t.n=`http://www.w3.org/${e}`,children:t.props.children}}])}return t}},Wp=(t,e)=>{var n,r;(n=e[Ae][2])==null||n.forEach(([i,s])=>{i.values.push(s)});try{Qc(t,e,void 0)}catch{return}if(e.a){delete e.a;return}(r=e[Ae][2])==null||r.forEach(([i])=>{i.values.pop()}),(t[0]!==1||!t[1])&&sm(e,e.c,!1)},Nr=new WeakMap,Gp=[],Ji=async(t,e)=>{t[5]||(t[5]=[]);const n=Nr.get(e);n&&n[0](void 0);let r;const i=new Promise(s=>r=s);if(Nr.set(e,[r,()=>{t[2]?t[2](t,e,s=>{Wp(s,e)}).then(()=>r(e)):(Wp(t,e),r(e))}]),Gp.length)Gp.at(-1).add(e);else{await Promise.resolve();const s=Nr.get(e);s&&(Nr.delete(e),s[1]())}return i},S1=(t,e,n)=>({tag:ni,props:{children:t},key:n,e,p:1}),va=0,am=1,wa=2,ba=3,ka=new WeakMap,cm=(t,e)=>!t||!e||t.length!==e.length||e.some((n,r)=>n!==t[r]),A1=void 0,Jp=[],E1=t=>{var o;const e=()=>typeof t=="function"?t():t,n=ri.at(-1);if(!n)return[e(),()=>{}];const[,r]=n,i=(o=r[Ae][1])[va]||(o[va]=[]),s=r[Ae][0]++;return i[s]||(i[s]=[e(),c=>{const l=A1,u=i[s];if(typeof c=="function"&&(c=c(u[0])),!Object.is(c,u[0]))if(u[0]=c,Jp.length){const[p,h]=Jp.at(-1);Promise.all([p===3?r:Ji([p,!1,l],r),h]).then(([m])=>{if(!m||!(p===2||p===3))return;const v=m.vC;requestAnimationFrame(()=>{setTimeout(()=>{v===m.vC&&Ji([p===3?1:0,!1,l],m)})})})}else Ji([0,!1,l],r)}])},fu=(t,e)=>{var c;const n=ri.at(-1);if(!n)return t;const[,r]=n,i=(c=r[Ae][1])[wa]||(c[wa]=[]),s=r[Ae][0]++,o=i[s];return cm(o==null?void 0:o[1],e)?i[s]=[t,e]:t=i[s][0],t},I1=t=>{const e=ka.get(t);if(e){if(e.length===2)throw e[1];return e[0]}throw t.then(n=>ka.set(t,[n]),n=>ka.set(t,[void 0,n])),t},z1=(t,e)=>{var c;const n=ri.at(-1);if(!n)return t();const[,r]=n,i=(c=r[Ae][1])[ba]||(c[ba]=[]),s=r[Ae][0]++,o=i[s];return cm(o==null?void 0:o[1],e)&&(i[s]=[t(),e]),i[s][0]},C1=Zg({pending:!1,data:null,method:null,action:null}),Zp=new Set,N1=t=>{Zp.add(t),t.finally(()=>Zp.delete(t))},hu=(t,e)=>z1(()=>n=>{let r;t&&(typeof t=="function"?r=t(n)||(()=>{t(null)}):t&&"current"in t&&(t.current=n,r=()=>{t.current=null}));const i=e(n);return()=>{i==null||i(),r==null||r()}},[t]),qn=Object.create(null),Pi=Object.create(null),Ii=(t,e,n,r,i)=>{if(e!=null&&e.itemProp)return{tag:t,props:e,type:t,ref:e.ref};const s=document.head;let{onLoad:o,onError:c,precedence:l,blocking:u,...p}=e,h=null,m=!1;const v=Fi[t];let f;if(v.length>0){const C=s.querySelectorAll(t);e:for(const B of C)for(const R of Fi[t])if(B.getAttribute(R)===e[R]){h=B;break e}if(!h){const B=v.reduce((R,Q)=>e[Q]===void 0?R:`${R}-${Q}-${e[Q]}`,t);m=!Pi[B],h=Pi[B]||(Pi[B]=(()=>{const R=document.createElement(t);for(const Q of v)e[Q]!==void 0&&R.setAttribute(Q,e[Q]),e.rel&&R.setAttribute("rel",e.rel);return R})())}}else f=s.querySelectorAll(t);l=r?l??"":void 0,r&&(p[Ki]=l);const _=fu(C=>{if(v.length>0){let B=!1;for(const R of s.querySelectorAll(t)){if(B&&R.getAttribute(Ki)!==l){s.insertBefore(C,R);return}R.getAttribute(Ki)===l&&(B=!0)}s.appendChild(C)}else if(f){let B=!1;for(const R of f)if(R===C){B=!0;break}B||s.insertBefore(C,s.contains(f[0])?f[0]:s.querySelector(t)),f=void 0}},[l]),w=hu(e.ref,C=>{var Q;const B=v[0];if(n===2&&(C.innerHTML=""),(m||f)&&_(C),!c&&!o)return;let R=qn[Q=C.getAttribute(B)]||(qn[Q]=new Promise((ae,ce)=>{C.addEventListener("load",ae),C.addEventListener("error",ce)}));o&&(R=R.then(o)),c&&(R=R.catch(c)),R.catch(()=>{})});if(i&&u==="render"){const C=Fi[t][0];if(e[C]){const B=e[C],R=qn[B]||(qn[B]=new Promise((Q,ae)=>{_(h),h.addEventListener("load",Q),h.addEventListener("error",ae)}));I1(R)}}const S={tag:t,type:t,props:{...p,ref:w},ref:w};return S.p=n,h&&(S.e=h),S1(S,s)},j1=t=>{const e=v1(),n=e&&wr(e);return n!=null&&n.endsWith("svg")?{tag:"title",props:t,type:"title",ref:t.ref}:Ii("title",t,void 0,!1,!1)},$1=t=>!t||["src","async"].some(e=>!t[e])?{tag:"script",props:t,type:"script",ref:t.ref}:Ii("script",t,1,!1,!0),O1=t=>!t||!["href","precedence"].every(e=>e in t)?{tag:"style",props:t,type:"style",ref:t.ref}:(t["data-href"]=t.href,delete t.href,Ii("style",t,2,!0,!0)),B1=t=>!t||["onLoad","onError"].some(e=>e in t)||t.rel==="stylesheet"&&(!("precedence"in t)||"disabled"in t)?{tag:"link",props:t,type:"link",ref:t.ref}:Ii("link",t,1,"precedence"in t,!0),T1=t=>Ii("meta",t,void 0,!1,!1),lm=Symbol(),P1=t=>{const{action:e,...n}=t;typeof e!="function"&&(n.action=e);const[r,i]=E1([null,!1]),s=fu(async u=>{const p=u.isTrusted?e:u.detail[lm];if(typeof p!="function")return;u.preventDefault();const h=new FormData(u.target);i([h,!0]);const m=p(h);m instanceof Promise&&(N1(m),await m),i([null,!0])},[]),o=hu(t.ref,u=>(u.addEventListener("submit",s),()=>{u.removeEventListener("submit",s)})),[c,l]=r;return r[1]=!1,{tag:C1,props:{value:{pending:c!==null,data:c,method:c?"post":null,action:c?e:null},children:{tag:"form",props:{...n,ref:o},type:"form",ref:o}},f:l}},um=(t,{formAction:e,...n})=>{if(typeof e=="function"){const r=fu(i=>{i.preventDefault(),i.currentTarget.form.dispatchEvent(new CustomEvent("submit",{detail:{[lm]:e}}))},[]);n.ref=hu(n.ref,i=>(i.addEventListener("click",r),()=>{i.removeEventListener("click",r)}))}return{tag:t,props:n,type:t,ref:n.ref}},R1=t=>um("input",t),L1=t=>um("button",t);Object.assign(Yc,{title:j1,script:$1,style:O1,link:B1,meta:T1,form:P1,input:R1,button:L1});new TextEncoder;const dm=t=>{const{i18nKey:e,values:n,components:r}=t,i=U.t(e,n),s=/<(\d+)>(.*?)<\/\d+>/g,o=[];let c=0,l;for(;(l=s.exec(i))!==null;){const[,u,p]=l,h=i.substring(c,l.index);h&&o.push(h);const m=parseInt(u,10);o.push(e1(r[m],{},p)),c=s.lastIndex}return c<i.length&&o.push(i.substring(c)),y(pu,{children:o})},Yp=6,Xp=({error:t,vendorSettings:e,email:n,state:r,client:i,hasPasswordLogin:s})=>{const o=new URLSearchParams({state:r}),l=i.connections.map(({name:u})=>u).includes("auth2");return y(Nt,{title:U.t("verify_your_email"),vendorSettings:e,children:[y("div",{className:"mb-4 text-2xl font-medium",children:U.t("verify_your_email")}),y("div",{className:"mb-8 text-gray-300",children:y(dm,{i18nKey:"we_sent_a_code_to",components:[y("span",{className:"text-black dark:text-white"},"span")],values:{email:n}})}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"pt-2",children:[y("input",{autoFocus:!0,type:"text",pattern:"[0-9]*",maxLength:Yp,inputMode:"numeric",name:"code",placeholder:"******",className:Et("mb-2 w-full rounded-lg border bg-gray-100 px-4 pb-2 pt-2.5 text-center indent-[5px] font-mono text-3xl placeholder:text-gray-300 dark:bg-gray-600 md:text-3xl",{"border-red":t,"border-gray-100 dark:border-gray-500":!t}),minLength:Yp,required:!0,id:"code-input"}),t&&y(br,{children:t}),y("div",{className:"text-center sm:mt-2",children:y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]}),l&&y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:U.t("or")})]}),y(ti,{Component:"a",href:`/u/${s?"enter-password":"pre-signup"}?${o.toString()}`,variant:"secondary",className:"block",children:U.t("enter_your_password_btn")})]})]}),y(tn,{state:r})]})]})},U1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r,client:i}=await Ke(t,e);if(!r.authParams.username)throw new N(400,{message:"Username not found in state"});const s=await cs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Xp,{vendorSettings:n,email:r.authParams.username,state:e,client:i,hasPasswordLogin:!!s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({code:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{code:n}=t.req.valid("form"),{loginSession:r,client:i,vendorSettings:s}=await Ke(t,e);if(t.set("client_id",i.id),!r.authParams.username)throw new N(400,{message:"Username not found in state"});try{return await au(t,i,r.authParams,r.authParams.username,n)}catch(o){const c=o,l=await cs({userAdapter:t.env.data.users,tenant_id:i.tenant.id,email:r.authParams.username,provider:"auth2"});return t.html(y(Xp,{vendorSettings:s,email:r.authParams.username,state:e,client:i,error:c.message,hasPasswordLogin:!!l}),400)}}),V1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:U.t("unverified_email"),vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("p",{className:"mb-8 text-gray-300 text-lg",children:U.t("unverified_email")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]}),y(tn,{state:n})]}),y(tn,{state:n})]})},xa=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t,s=new URLSearchParams({state:i});return y(Nt,{title:U.t("enter_password"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("enter_password")}),y("div",{className:"mb-6 text-gray-300",children:U.t("enter_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"mb-7",children:[y("input",{type:"text",name:"username",placeholder:U.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r}),y("input",{type:"password",name:"password",placeholder:U.t("password")||"",className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0}),e&&y(br,{children:e}),y(Pn,{className:"text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center space-x-2",children:[y("span",{children:U.t("login")}),y(gt,{className:"text-xs",name:"arrow-right"})]})})]}),y("a",{href:`/u/forgot-password?${s.toString()}`,className:"text-primary hover:underline mb-4",children:U.t("forgot_password_link")}),y("div",{className:"text-center mb-12",children:[y("div",{className:"relative mb-5 block text-center text-gray-300 dark:text-gray-300",children:[y("div",{className:"absolute left-0 right-0 top-1/2 border-b border-gray-200 dark:border-gray-600"}),y("div",{className:"relative inline-block bg-white px-2 dark:bg-gray-800",children:U.t("or")})]}),y("form",{method:"post",action:`/u/enter-email?${s.toString()}`,children:[y("input",{type:"hidden",name:"login_selection",value:"code"}),y("input",{type:"hidden",name:"username",value:r}),y(ti,{variant:"secondary",className:"block",children:U.t("enter_a_code_btn")})]})]}),y(tn,{state:i})]})]})},q1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ke(t,e);if(!i.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(xa,{vendorSettings:n,email:i.authParams.username,state:e,client:r}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{password:r}=n,{vendorSettings:i,client:s,loginSession:o}=await Ke(t,e),{username:c}=o.authParams;if(!c)throw new N(400,{message:"Username required"});try{return await cu(t,s,{...o.authParams,password:r},o)}catch(l){const u=l;return u.code==="INVALID_PASSWORD"||u.code==="USER_NOT_FOUND"?t.html(y(xa,{vendorSettings:i,email:c,error:U.t("invalid_password"),state:e,client:s}),400):u.code==="EMAIL_NOT_VERIFIED"?t.html(y(V1,{vendorSettings:i,state:e}),400):t.html(y(xa,{vendorSettings:i,email:c,error:u.message,state:e,client:s}),400)}}),zr=t=>{const{state:e,error:n,vendorSettings:r,email:i,code:s}=t;return y(Nt,{title:U.t("create_account_title"),vendorSettings:r,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("create_account_title")}),y("div",{className:"mb-6 text-gray-300",children:U.t("create_account_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{children:[y("input",{type:"hidden",name:"code",value:s}),y("input",{type:"email",name:"username",placeholder:U.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",required:!0,value:i,disabled:!!i}),y("input",{type:"password",name:"password",placeholder:U.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:U.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),n&&y(br,{children:n}),y(Pn,{className:"text-base sm:mt-2 md:text-base",children:U.t("continue")})]}),y(tn,{state:e})]})]})},pm=t=>{const{message:e,vendorSettings:n,pageTitle:r,state:i}=t;return y(Nt,{title:"Login",vendorSettings:n,children:[r?y("div",{className:"mb-6 text-gray-300",children:r}):"",y("div",{className:"flex flex-1 flex-col justify-center",children:e}),i?y(tn,{state:i}):""]})},M1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().optional().openapi({description:"The code parameter from an email verification link"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{vendorSettings:r,loginSession:i}=await Ke(t,e),{username:s}=i.authParams;if(!s)throw new N(400,{message:"Username required"});return n?t.html(y(zr,{state:e,vendorSettings:r,email:s,code:n})):t.html(y(zr,{state:e,vendorSettings:r,email:s}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.z.string(),code:a.z.string().optional()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),n=t.req.valid("form"),{env:r}=t,{vendorSettings:i,client:s,loginSession:o}=await Ke(t,e),c="Username-Password-Authentication";t.set("client_id",s.id),t.set("connection",c);const l=o.authParams.username;if(!l)throw new N(400,{message:"Username required"});if(n.password!==n["re-enter-password"])return t.html(y(zr,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_passwords_didnt_match"),email:o.authParams.username}),400);if(!iu(n.password))return t.html(y(zr,{state:e,code:n.code,vendorSettings:i,error:U.t("create_account_weak_password"),email:o.authParams.username}),400);const u=n.code?await r.data.codes.get(s.tenant.id,n.code,"email_verification"):void 0,p=u?await r.data.loginSessions.get(s.tenant.id,u.login_id):void 0;try{if(await si({userAdapter:t.env.data.users,tenant_id:s.tenant.id,email:l,provider:"auth2"}))throw new N(400,{message:"Invalid sign up"});const m=(p==null?void 0:p.authParams.username)===l,v=await Uf(t).users.create(s.tenant.id,{user_id:`auth2|${Ys()}`,email:l,email_verified:m,provider:"auth2",connection:c,is_social:!1});return await r.data.passwords.create(s.tenant.id,{user_id:v.user_id,password:await ii.hash(n.password,10),algorithm:"bcrypt"}),m?await cu(t,s,{...o.authParams,password:n.password},o):(await ou(t,v),t.html(y(pm,{message:U.t("validate_email_body"),pageTitle:U.t("validate_email_title"),vendorSettings:i,state:e})))}catch(h){const m=await tm(r,s.id,o.authParams.vendor_id),v=h;return t.html(y(zr,{state:e,vendorSettings:m,error:v.message,email:l}),400)}}),Cr=t=>{const{error:e,vendorSettings:n,email:r}=t;return y(Nt,{title:U.t("reset_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("reset_password_title")}),y("div",{className:"mb-6 text-gray-300",children:`${U.t("reset_password_description")} ${r}`}),y("div",{className:"flex flex-1 flex-col justify-center",children:y(Rn,{children:[y("input",{type:"password",name:"password",placeholder:U.t("enter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),y("input",{type:"password",name:"re-enter-password",placeholder:U.t("reenter_new_password_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base"}),e&&y(br,{children:e}),y(Pn,{className:"text-base sm:mt-2 md:text-base",children:U.t("reset_password_cta")})]})})]})},D1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().openapi({description:"The code parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ke(t,e);if(!r.authParams.username)throw new N(400,{message:"Username required"});return t.html(y(Cr,{vendorSettings:n,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"}),code:a.z.string().openapi({description:"The code parameter from the authorization request"})}),body:{content:{"application/x-www-form-urlencoded":{schema:a.z.object({password:a.z.string(),"re-enter-password":a.z.string()})}}}},responses:{200:{description:"Response"}}}),async t=>{const{state:e,code:n}=t.req.valid("query"),{password:r,"re-enter-password":i}=t.req.valid("form"),{env:s}=t,{vendorSettings:o,client:c,loginSession:l}=await Ke(t,e);if(!l.authParams.username)throw new N(400,{message:"Username required"});if(r!==i)return t.html(y(Cr,{error:U.t("create_account_passwords_didnt_match"),vendorSettings:o,email:l.authParams.username}),400);if(!iu(r))return t.html(y(Cr,{error:U.t("create_account_weak_password"),vendorSettings:o,email:l.authParams.username}),400);const u=await si({userAdapter:s.data.users,tenant_id:c.tenant.id,email:l.authParams.username,provider:"auth2"});if(!u)throw new N(400,{message:"User not found"});try{if(!await s.data.codes.get(c.tenant.id,n,"password_reset"))return t.html(y(Cr,{error:"Code not found or expired",vendorSettings:o,email:l.authParams.username}),400);const h={user_id:u.user_id,password:await ii.hash(r,10),algorithm:"bcrypt"};await s.data.passwords.get(c.tenant.id,u.user_id)?await s.data.passwords.update(c.tenant.id,h):await s.data.passwords.create(c.tenant.id,h),u.email_verified||await s.data.users.update(c.tenant.id,u.user_id,{email_verified:!0})}catch{return t.html(y(Cr,{error:"The password could not be reset",vendorSettings:o,email:l.authParams.username}),400)}return t.html(y(pm,{message:U.t("password_has_been_reset"),vendorSettings:o,state:e}))}),H1=t=>{const{error:e,vendorSettings:n,email:r,state:i}=t;return y(Nt,{title:U.t("forgot_password_title"),vendorSettings:n,children:[y("div",{className:"mb-4 text-lg font-medium sm:text-2xl",children:U.t("forgot_password_title")}),y("div",{className:"mb-6 text-gray-300",children:U.t("forgot_password_description")}),y("div",{className:"flex flex-1 flex-col justify-center",children:[y(Rn,{className:"pt-2",children:[y("input",{type:"email",name:"username",placeholder:U.t("email_placeholder"),className:"mb-2 w-full rounded-lg bg-gray-100 px-4 py-5 text-base placeholder:text-gray-300 dark:bg-gray-600 md:text-base",value:r,disabled:!!r}),e&&y(br,{children:e}),y(Pn,{className:"sm:mt-4",children:U.t("forgot_password_cta")})]}),y(tn,{state:i})]})]})},F1=t=>{const{vendorSettings:e,state:n}=t;return y(Nt,{title:"Login",vendorSettings:e,children:[y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{children:U.t("forgot_password_email_sent")}),y("div",{className:"my-4 flex space-x-2 text-sm text-[#B2B2B2]",children:[y(gt,{className:"text-base",name:"info-bubble"}),y("div",{className:"text-sm text-gray-300 md:text-sm",children:U.t("sent_code_spam")})]})]}),y(tn,{state:n})]})},K1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,loginSession:r}=await Ke(t,e);return t.html(y(H1,{vendorSettings:n,state:e,email:r.authParams.username}))}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{state:e}=t.req.valid("query"),{vendorSettings:n,client:r,loginSession:i}=await Ke(t,e);return await Ib(t,r,i.authParams.username,i.id),t.html(y(F1,{vendorSettings:n,state:e}))}),W1=({vendorSettings:t,state:e,user:n})=>y(Nt,{title:pe("check_email_title"),vendorSettings:t,children:y("div",{className:"flex flex-1 flex-col justify-center",children:[y("div",{className:"mb-8 text-gray-700 dark:text-gray-300",children:[y(dm,{i18nKey:"currently_logged_in_as",components:[y("span",{className:"font-semibold text-gray-900 dark:text-white"},"span")],values:{email:n.email}}),y("br",{}),pe("continue_with_sso_provider_headline")]}),y("div",{className:"space-y-6",children:[y(Rn,{children:y(Pn,{className:"w-full text-base sm:mt-4 md:text-base",children:y("div",{className:"flex items-center justify-center space-x-2",children:y("span",{children:U.t("yes_continue_with_existing_account")})})})}),y("a",{className:"block text-center text-primary hover:text-primaryHover focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 dark:focus:ring-offset-gray-900",href:`/u/enter-email?state=${encodeURIComponent(e)}`,children:U.t("no_use_another")})]})]})}),G1=new a.OpenAPIHono().openapi(a.createRoute({tags:["login"],method:"get",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{200:{description:"Response"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{vendorSettings:r,client:i}=await Ke(t,n),s=as(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?t.html(y(W1,{vendorSettings:r,state:n,user:c})):t.redirect(`/u/enter-email?state=${n}`)}).openapi(a.createRoute({tags:["login"],method:"post",path:"/",request:{query:a.z.object({state:a.z.string().openapi({description:"The state parameter from the authorization request"})})},responses:{302:{description:"Redirect"}}}),async t=>{const{env:e}=t,{state:n}=t.req.valid("query"),{loginSession:r,client:i}=await Ke(t,n),s=as(i.tenant.id,t.req.header("cookie")),o=s?await e.data.sessions.get(i.tenant.id,s):null;if(!o)return t.redirect(`/u/enter-email?state=${n}`);const c=await e.data.users.get(i.tenant.id,o.user_id);return c?on(t,{user:c,authParams:r.authParams,client:i,loginSession:r}):t.redirect(`/u/enter-email?state=${n}`)});function J1(t){const e=new a.OpenAPIHono;e.use(async(r,i)=>(r.env.data=to(r,t.dataAdapter),i()));const n=e.route("/check-account",G1).route("/enter-email",m1).route("/enter-code",U1).route("/enter-password",q1).route("/reset-password",D1).route("/forgot-password",K1).route("/signup",M1);return n.doc("/u/spec",{openapi:"3.0.0",info:{version:"1.0.0",title:"Universal login"}}),n}const Z1="Account detected",Y1="We have detected that you have already created an account through",X1="By signing in, you agree to our",Q1="and",ek="Callback URL mismatch",tk="The provided redirect_uri is not in the list of allowed callback URLs.",nk="continue with user",rk="Please click the button to create a new password account.",ik="Enter the code at {{vendorName}} to complete the login",sk="Welcome to {{vendorName}}! {{code}} is the login code",ok="Welcome to {{vendorName}}! {{code}} is the login code",ak="The code is valid for 30 minutes",ck="Confirm password",lk="Need Help?",uk="Contact us",dk="or continue with social account",pk="Continue with {{provider}}",fk="Would you like to continue with your existing account?",hk="Copyright © 2023 SESAMY. All rights reserved.",gk="©2023 Sesamy",mk="Choose a password with a mix of uppercase and lowercase letters, numbers, and symbols.",_k="Please enter a valid email address.",yk="The passwords didn't match. Try again.",vk="Choose password",wk="Password must be at least 8 characters long and contain at least one lowercase letter, one uppercase letter, one number and one symbol.",bk="Create new account",kk="Sign up with password",xk="You are currently logged in as <0>{{email}}</0>",Sk="Email",Ak="Email address",Ek="Your email address has been validated",Ik="Now enter your password to login again",zk="An email has been sent to <0>{{email}}</0> with a verification link. Please click the link to verify your email address and set a password.",Ck="Email verification sent",Nk="Enter a code",jk="We'll send you a verification link to ensure you own this email address.",$k="Enter new password",Ok="Enter password",Bk="Enter your email address and password to login.",Tk="Enter your password",Pk="The magic link has expired. Please click on the button below to receive a new link in your inbox.",Rk="Hey! We updated our login experience. <0>Click here to learn more about it.</0>",Lk="Send password reset email",Uk="Click the button below and we’ll send instructions on how to reset your password.",Vk="Password reset email sent",qk="Forgot password?",Mk="Forgot password?",Dk="Go back",Hk="Invalid password",Fk=`The link is no longer valid.
223
223
 
224
224
  Please make sure to open the login link in the same browser you started the login with.
225
225
 
package/dist/authhero.mjs CHANGED
@@ -20914,13 +20914,13 @@ const r1 = (t) => {
20914
20914
  text: e,
20915
20915
  icon: n = null,
20916
20916
  canResize: r = !1,
20917
- session: i
20917
+ loginSession: i
20918
20918
  }) => {
20919
20919
  const s = new URLSearchParams({
20920
20920
  client_id: i.authParams.client_id,
20921
20921
  connection: t
20922
20922
  });
20923
- i.authParams.response_type && s.set("response_type", i.authParams.response_type), i.authParams.redirect_uri && s.set("redirect_uri", i.authParams.redirect_uri), i.authParams.scope && s.set("scope", i.authParams.scope), i.authParams.nonce && s.set("nonce", i.authParams.nonce), i.authParams.response_type && s.set("response_type", i.authParams.response_type), i.authParams.state && s.set("state", i.login_id);
20923
+ i.authParams.response_type && s.set("response_type", i.authParams.response_type), i.authParams.redirect_uri && s.set("redirect_uri", i.authParams.redirect_uri), i.authParams.scope && s.set("scope", i.authParams.scope), i.authParams.nonce && s.set("nonce", i.authParams.nonce), i.authParams.response_type && s.set("response_type", i.authParams.response_type), i.authParams.state && s.set("state", i.id);
20924
20924
  const o = `/authorize?${s.toString()}`;
20925
20925
  return /* @__PURE__ */ y(
20926
20926
  ni,
@@ -21041,7 +21041,7 @@ const r1 = (t) => {
21041
21041
  ), Vp = ({
21042
21042
  error: t,
21043
21043
  vendorSettings: e,
21044
- session: n,
21044
+ loginSession: n,
21045
21045
  email: r,
21046
21046
  client: i,
21047
21047
  impersonation: s
@@ -21110,7 +21110,7 @@ const r1 = (t) => {
21110
21110
  name: "facebook"
21111
21111
  }
21112
21112
  ),
21113
- session: n
21113
+ loginSession: n
21114
21114
  }
21115
21115
  ),
21116
21116
  l && /* @__PURE__ */ y(
@@ -21120,7 +21120,7 @@ const r1 = (t) => {
21120
21120
  text: V.t("continue_with", { provider: "Google" }),
21121
21121
  canResize: !0,
21122
21122
  icon: /* @__PURE__ */ y(a1, { className: "h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0" }),
21123
- session: n
21123
+ loginSession: n
21124
21124
  }
21125
21125
  ),
21126
21126
  u && /* @__PURE__ */ y(
@@ -21136,7 +21136,7 @@ const r1 = (t) => {
21136
21136
  name: "apple"
21137
21137
  }
21138
21138
  ),
21139
- session: n
21139
+ loginSession: n
21140
21140
  }
21141
21141
  ),
21142
21142
  p && /* @__PURE__ */ y(
@@ -21146,7 +21146,7 @@ const r1 = (t) => {
21146
21146
  text: V.t("continue_with", { provider: "Vipps" }),
21147
21147
  canResize: !0,
21148
21148
  icon: /* @__PURE__ */ y(c1, { className: "h-5 w-5 sm:absolute sm:left-4 sm:top-1/2 sm:h-6 sm:w-6 sm:-translate-y-1/2 short:static short:left-auto short:top-auto short:h-5 short:w-5 short:translate-y-0" }),
21149
- session: n
21149
+ loginSession: n
21150
21150
  }
21151
21151
  )
21152
21152
  ] })
@@ -21188,7 +21188,7 @@ const d1 = new de().openapi(
21188
21188
  Vp,
21189
21189
  {
21190
21190
  vendorSettings: r,
21191
- session: i,
21191
+ loginSession: i,
21192
21192
  client: s,
21193
21193
  email: i.authParams.username,
21194
21194
  impersonation: n === "true"
@@ -21251,7 +21251,7 @@ const d1 = new de().openapi(
21251
21251
  Vp,
21252
21252
  {
21253
21253
  vendorSettings: o,
21254
- session: s,
21254
+ loginSession: s,
21255
21255
  error: V.t("user_account_does_not_exist"),
21256
21256
  email: r.username,
21257
21257
  client: i
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authhero",
3
- "version": "0.90.0",
3
+ "version": "0.91.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],