@donotdev/auth 0.3.2 → 0.3.4

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.
Files changed (54) hide show
  1. package/README.md +6 -1
  2. package/dist/AuthStore.js +1 -1
  3. package/dist/authHelpers.js +1 -1
  4. package/dist/components/AccountLinking.js +1 -1
  5. package/dist/components/AuthFallback.js +1 -1
  6. package/dist/components/AuthPartnerButton.js +1 -1
  7. package/dist/components/DeleteAccountDialogs.js +1 -1
  8. package/dist/components/EmailLinkForm.d.ts.map +1 -1
  9. package/dist/components/EmailLinkForm.js +1 -1
  10. package/dist/components/EmailPasswordForm.d.ts +4 -2
  11. package/dist/components/EmailPasswordForm.d.ts.map +1 -1
  12. package/dist/components/EmailPasswordForm.js +1 -1
  13. package/dist/components/EmailVerification.js +1 -1
  14. package/dist/components/Feature.js +1 -1
  15. package/dist/components/FeatureGuard.js +1 -1
  16. package/dist/components/LoginModal.js +1 -1
  17. package/dist/components/MultipleAuthProviders.js +1 -1
  18. package/dist/components/PasswordStrengthIndicator.d.ts +8 -2
  19. package/dist/components/PasswordStrengthIndicator.d.ts.map +1 -1
  20. package/dist/components/PasswordStrengthIndicator.js +1 -1
  21. package/dist/constants.d.ts +7 -4
  22. package/dist/constants.d.ts.map +1 -1
  23. package/dist/emailAuth/captcha.d.ts +9 -0
  24. package/dist/emailAuth/captcha.d.ts.map +1 -0
  25. package/dist/emailAuth/captcha.js +1 -0
  26. package/dist/emailAuth/fields.d.ts +74 -4
  27. package/dist/emailAuth/fields.d.ts.map +1 -1
  28. package/dist/emailAuth/fields.js +1 -1
  29. package/dist/emailAuth/flows.d.ts +195 -19
  30. package/dist/emailAuth/flows.d.ts.map +1 -1
  31. package/dist/emailAuth/flows.js +1 -1
  32. package/dist/emailAuth/rules.d.ts +42 -5
  33. package/dist/emailAuth/rules.d.ts.map +1 -1
  34. package/dist/emailAuth/rules.js +2 -2
  35. package/dist/emailAuth/signUpFlow.d.ts +78 -0
  36. package/dist/emailAuth/signUpFlow.d.ts.map +1 -0
  37. package/dist/emailAuth/signUpFlow.js +1 -0
  38. package/dist/hooks/useAuthMethodToggle.js +1 -1
  39. package/dist/hooks/useAuthPartner.js +1 -1
  40. package/dist/hooks/useAuthUsers.d.ts +34 -0
  41. package/dist/hooks/useAuthUsers.d.ts.map +1 -0
  42. package/dist/hooks/useAuthUsers.js +1 -0
  43. package/dist/hooks/useDeleteAccount.js +1 -1
  44. package/dist/hooks/useEmailLinkForm.js +1 -1
  45. package/dist/hooks/useGoogleOneTap.js +1 -1
  46. package/dist/index.d.ts +11 -5
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +1 -1
  49. package/dist/symbol-index.json +1 -1
  50. package/dist/tsconfig.tsbuildinfo +1 -1
  51. package/dist/useAuth.d.ts.map +1 -1
  52. package/dist/useAuth.js +1 -1
  53. package/guidelines/AUTH.md +119 -0
  54. package/package.json +5 -5
package/README.md CHANGED
@@ -63,7 +63,12 @@ TypeScript autocomplete shows you everything available.
63
63
  - **`signInWithPartner(partnerId, method?)`** - OAuth sign in
64
64
  - **`signOut()`** - Sign out
65
65
  - **`sendPasswordResetEmail(email)`** - Reset password
66
- - **`sendEmailVerification()`** - Verify email
66
+ - **`sendEmailVerification(email?)`** - Send (again) the confirmation email or code
67
+ - **`verifyEmailCode(email, code)`** - Confirm a sign-up address with the emailed code; signs the user in (providers implementing it: Supabase)
68
+
69
+ **Admin:**
70
+
71
+ - **`listUsers()`** - Every auth account (`AuthUserSummary[]`); needs the admin-only `listAuthUsers` server function deployed (Supabase, Firebase). `useAuthUsers()` wraps it: `{ users, loading, error, reload }`
67
72
 
68
73
  **Security (Firebase-verified):**
69
74
 
package/dist/AuthStore.js CHANGED
@@ -1 +1 @@
1
- import{createDoNotDevStore as c,FEATURE_STATUS as l,syncQueryCacheIdentity as o}from"@donotdev/core";import{PARTNER_STATE as u}from"./constants";const i={user:null,authenticated:!1,userId:null,loading:!1,error:null,userProfile:null,userSubscription:null,partnerStates:{},partnerError:null,authService:null,emailVerification:{status:"pending"},passwordResetPending:!1,status:l.INITIALIZING},d=c({name:"auth-store",createStore:(t,a)=>({...i,setStatus:r=>{t({status:r})},setPartnerState:(r,e,s)=>{t(n=>({partnerStates:{...n.partnerStates,[r]:e},partnerError:e==="error"&&s?{partnerId:r,error:s}:n.partnerError?.partnerId===r?null:n.partnerError}))},getPartnerState:r=>a().partnerStates[r]||u.IDLE,clearAllPartnerStates:()=>t(r=>({partnerStates:Object.keys(r.partnerStates).reduce((e,s)=>(e[s]=u.IDLE,e),{}),partnerError:null})),setAuthenticated:(r,e,s)=>{o(r.id),t({user:r,authenticated:!0,userId:r.id,loading:!1,error:null,status:l.READY,userSubscription:e,userProfile:s})},setUnauthenticated:()=>{o(null),t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:l.READY,userSubscription:null,userProfile:null})},setAuthLoading:r=>{t({loading:r})},setAuthError:r=>{t({error:r,loading:!1})},clearAuthError:()=>{t({error:null})},getCustomClaim:r=>a().getCustomClaimLocal(r),getCustomClaims:()=>a().getCustomClaimsLocal(),setAuthService:r=>t({authService:r}),getCustomClaimLocal:r=>{const e=a(),s=e.userProfile;return s?.claims&&typeof s.claims=="object"&&r in s.claims?s.claims[r]:s&&typeof s=="object"&&r in s?s[r]:e.user&&typeof e.user=="object"&&r in e.user?e.user[r]:null},getCustomClaimsLocal:()=>{const r=a(),e={};return r.userProfile?.claims&&Object.assign(e,r.userProfile.claims),Object.freeze({...e})},setPasswordResetPending:r=>t({passwordResetPending:r}),setEmailVerificationStatus:(r,e)=>t({emailVerification:{status:r,error:e}}),setUserProfile:r=>t({userProfile:r}),setUserSubscription:r=>t({userSubscription:r}),setLoading:r=>t({loading:r}),setError:r=>t({error:r}),clearError:()=>t({error:null}),reset:()=>t(i)})});export{d as useAuthStore};
1
+ import{createDoNotDevStore as c,FEATURE_STATUS as l,syncQueryCacheIdentity as o}from"@donotdev/core";import{PARTNER_STATE as n}from"./constants";const i={user:null,authenticated:!1,userId:null,loading:!1,error:null,userProfile:null,userSubscription:null,partnerStates:{},partnerError:null,authService:null,emailVerification:{status:"pending"},passwordResetPending:!1,status:l.INITIALIZING},d=c({name:"auth-store",createStore:(t,a)=>({...i,setStatus:e=>{t({status:e})},setPartnerState:(e,r,s)=>{t(u=>({partnerStates:{...u.partnerStates,[e]:r},partnerError:r==="error"&&s?{partnerId:e,error:s}:u.partnerError?.partnerId===e?null:u.partnerError}))},getPartnerState:e=>a().partnerStates[e]||n.IDLE,clearAllPartnerStates:()=>t(e=>({partnerStates:Object.keys(e.partnerStates).reduce((r,s)=>(r[s]=n.IDLE,r),{}),partnerError:null})),setAuthenticated:(e,r,s)=>{o(e.id),t({user:e,authenticated:!0,userId:e.id,loading:!1,error:null,status:l.READY,userSubscription:r,userProfile:s})},setUnauthenticated:()=>{o(null),t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:l.READY,userSubscription:null,userProfile:null})},setAuthLoading:e=>{t({loading:e})},setAuthError:e=>{t({error:e,loading:!1})},clearAuthError:()=>{t({error:null})},getCustomClaim:e=>a().getCustomClaimLocal(e),getCustomClaims:()=>a().getCustomClaimsLocal(),setAuthService:e=>t({authService:e}),getCustomClaimLocal:e=>{const r=a(),s=r.userProfile;return s?.claims&&typeof s.claims=="object"&&e in s.claims?s.claims[e]:s&&typeof s=="object"&&e in s?s[e]:r.user&&typeof r.user=="object"&&e in r.user?r.user[e]:null},getCustomClaimsLocal:()=>{const e=a(),r={};return e.userProfile?.claims&&Object.assign(r,e.userProfile.claims),Object.freeze({...r})},setPasswordResetPending:e=>t({passwordResetPending:e}),setEmailVerificationStatus:(e,r)=>t({emailVerification:{status:e,error:r}}),setUserProfile:e=>t({userProfile:e}),setUserSubscription:e=>t({userSubscription:e}),setLoading:e=>t({loading:e}),setError:e=>t({error:e}),clearError:()=>t({error:null}),reset:()=>t(i)})});export{d as useAuthStore};
@@ -1 +1 @@
1
- import{isClient as e}from"@donotdev/core";import{useAuthStore as t}from"./AuthStore";function s(){return t.getState()}function u(r){return e()?t.subscribe(r):()=>{}}export{s as getAuthState,u as subscribeToAuth};
1
+ import{isClient as r}from"@donotdev/core";import{useAuthStore as t}from"./AuthStore";function s(){return t.getState()}function u(e){return r()?t.subscribe(e):()=>{}}export{s as getAuthState,u as subscribeToAuth};
@@ -1 +1 @@
1
- "use client";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{Suspense as L,lazy as T}from"react";import{Alert as h,ALERT_VARIANT as k,Button as o,BUTTON_VARIANT as c,Stack as a}from"@donotdev/components";import{useTranslation as I,safeSessionStorage as v,handleError as N,isDev as l}from"@donotdev/core";import{EmailLinkForm as R}from"./EmailLinkForm";import S from"./EmailPasswordForm";import{useAccountLinking as y}from"../hooks/useAccountLinking";const $=({className:r="",id:d})=>{const{t:e}=I("auth"),{isRequired:f,email:m,existingProvider:n,newProvider:u,handleSignInWithExistingProvider:w}=y();if(!f)return null;if(n==="password"||n==="emailLink"){l();const s=()=>{v.removeItem("accountLinkingInfo")},g=()=>{l()},p=A=>{N(A)};return i("div",{className:r,id:d,children:i(h,{variant:k.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:t(a,{children:[i("p",{children:e("accountLinking.message",`An account with email ${m} already exists with ${n==="password"?"email/password":"email link"}. To link your ${u} account, please sign in with your ${n==="password"?"email and password":"email link"} first.`)}),n==="password"?i("div",{style:{marginTop:"var(--gap-md)"},children:i(S,{mode:"signin",onSuccess:g,onError:p})}):i("div",{style:{marginTop:"var(--gap-md)"},children:i(R,{onSuccess:g,onError:p})}),i(a,{direction:"row",justify:"end",children:i(o,{onClick:s,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})})]})})})}else{l();const s=()=>{v.removeItem("accountLinkingInfo")};return i("div",{className:r,id:d,children:i(h,{variant:k.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:t(a,{children:[i("p",{children:e("accountLinking.message",`An account with email ${m} already exists with ${n}. To link your ${u} account, please sign in with ${n} first.`)}),t(a,{direction:"row",children:[i(o,{onClick:w,variant:c.PRIMARY,children:e("accountLinking.signInWith",`Sign in with ${n}`)}),i(o,{onClick:s,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})]})]})})})}},x=T(()=>Promise.resolve({default:$}));function E(r){return i(L,{fallback:null,children:i(x,{...r})})}var P=E;export{P as default};
1
+ "use client";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{Suspense as A,lazy as T}from"react";import{Alert as h,ALERT_VARIANT as k,Button as o,BUTTON_VARIANT as c,Stack as a}from"@donotdev/components";import{useTranslation as I,safeSessionStorage as v,handleError as N,isDev as l}from"@donotdev/core";import{EmailLinkForm as R}from"./EmailLinkForm";import S from"./EmailPasswordForm";import{useAccountLinking as y}from"../hooks/useAccountLinking";const $=({className:r="",id:d})=>{const{t:e}=I("auth"),{isRequired:f,email:m,existingProvider:n,newProvider:u,handleSignInWithExistingProvider:w}=y();if(!f)return null;if(n==="password"||n==="emailLink"){l();const s=()=>{v.removeItem("accountLinkingInfo")},g=()=>{l()},p=L=>{N(L)};return i("div",{className:r,id:d,children:i(h,{variant:k.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:t(a,{children:[i("p",{children:e("accountLinking.message",`An account with email ${m} already exists with ${n==="password"?"email/password":"email link"}. To link your ${u} account, please sign in with your ${n==="password"?"email and password":"email link"} first.`)}),n==="password"?i("div",{style:{marginTop:"var(--gap-md)"},children:i(S,{mode:"signin",onSuccess:g,onError:p})}):i("div",{style:{marginTop:"var(--gap-md)"},children:i(R,{onSuccess:g,onError:p})}),i(a,{direction:"row",justify:"end",children:i(o,{onClick:s,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})})]})})})}else{l();const s=()=>{v.removeItem("accountLinkingInfo")};return i("div",{className:r,id:d,children:i(h,{variant:k.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:t(a,{children:[i("p",{children:e("accountLinking.message",`An account with email ${m} already exists with ${n}. To link your ${u} account, please sign in with ${n} first.`)}),t(a,{direction:"row",children:[i(o,{onClick:w,variant:c.PRIMARY,children:e("accountLinking.signInWith",`Sign in with ${n}`)}),i(o,{onClick:s,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})]})]})})})}},x=T(()=>Promise.resolve({default:$}));function E(r){return i(A,{fallback:null,children:i(x,{...r})})}var P=E;export{P as default};
@@ -1 +1 @@
1
- import{jsx as a}from"react/jsx-runtime";import{FeatureFallback as s,withFeatureFallback as r}from"@donotdev/components";import{isFeatureAvailable as n,FRAMEWORK_FEATURES as i}from"@donotdev/core";function o({message:t="Authentication is not available",showLoginButton:e=!1,className:u=""}){return a(s,{featureName:"Authentication",message:t,icon:"\u{1F512}",showActionButton:e,actionButtonText:"Sign In (Unavailable)",className:u,helpText:"This feature requires authentication to be configured."})}function l(t,e){return r(t,"Authentication",()=>n(i.AUTH),{message:e?.message,showActionButton:e?.showLoginButton,actionButtonText:"Sign In (Unavailable)",icon:"\u{1F512}",helpText:"This feature requires authentication to be configured."})}function c(t){return{isAuthAvailable:n(i.AUTH),AuthFallbackComponent:()=>a(o,{...t})}}export{o as AuthFallback,c as useAuthComponent,l as withAuthFallback};
1
+ import{jsx as e}from"react/jsx-runtime";import{FeatureFallback as s,withFeatureFallback as r}from"@donotdev/components";import{isFeatureAvailable as n,FRAMEWORK_FEATURES as i}from"@donotdev/core";function o({message:t="Authentication is not available",showLoginButton:a=!1,className:u=""}){return e(s,{featureName:"Authentication",message:t,icon:"\u{1F512}",showActionButton:a,actionButtonText:"Sign In (Unavailable)",className:u,helpText:"This feature requires authentication to be configured."})}function l(t,a){return r(t,"Authentication",()=>n(i.AUTH),{message:a?.message,showActionButton:a?.showLoginButton,actionButtonText:"Sign In (Unavailable)",icon:"\u{1F512}",helpText:"This feature requires authentication to be configured."})}function c(t){return{isAuthAvailable:n(i.AUTH),AuthFallbackComponent:()=>e(o,{...t})}}export{o as AuthFallback,c as useAuthComponent,l as withAuthFallback};
@@ -2,4 +2,4 @@
2
2
  .dndev-interactive.auth-partner-button-custom[data-variant='outline']:hover {
3
3
  background-color: var(--partner-hover-bg);
4
4
  }
5
- `,document.head.appendChild(r)}import{cn as D,DISPLAY as S,PROVIDER_ICONS as U,DefaultProviderIcon as M,Button as _,BUTTON_VARIANT as $,Spinner as V}from"@donotdev/components";import{AUTH_PARTNERS as W,useTranslation as j}from"@donotdev/core";import{EmailLinkForm as F}from"./EmailLinkForm";import H from"./EmailPasswordForm";import{getAuthMethod as k}from"../constants";import{useAuth as s}from"../useAuth";function K({partnerId:r,method:p,onSuccess:u,onError:l,className:c="",children:b,disabled:h=!1,display:f=S.AUTO,style:g,...q}){const{t:i}=j("auth"),v=s("user"),E=s("signInWithPartner"),A=s("linkWithPartner"),N=s("isAvailable"),[o,y]=B(!1),n=I(()=>W[r],[r]);if(r==="password")return a("div",{className:c,children:a(H,{mode:"signin",onSuccess:()=>u?.(null),onError:l,compact:!0})});if(r==="emailLink")return a("div",{className:c,children:a(F,{onSuccess:()=>u?.(null),onError:l})});const T=I(()=>U[r]||M,[r]),P=n?.firebaseProviderId,d=!!v?.providerData?.some(t=>t.providerId===P),m=v&&!d,w=async()=>{if(!(o||h)){y(!0);try{let t;if(m)t=await A(r,k(p));else{const R=k(p);t=await E(r,R)}t&&u?.(t)}catch(t){l?.(t instanceof Error?t:new Error(String(t)))}finally{y(!1)}}},e=n?.name,O=()=>{if(b)return b;if(m)return o?i("buttons.linking",{partner:e}):d?i("buttons.linked",{partner:e}):i("buttons.link",{partner:e});if(o)return i("buttons.signingIn",{partner:e});const t=n?.button?.textKey;return t?i(t):`Sign in with ${e}`},x=h||o||!N||m&&d||!1,C=n?.button?{backgroundColor:n.button.backgroundColor,color:n.button.textColor,borderColor:n.button.borderColor,"--partner-hover-bg":n.button.hoverBackgroundColor}:void 0,L=g?{...C,...g}:C;return a(_,{variant:$.OUTLINE,onClick:w,disabled:x,"aria-busy":o,display:f,"aria-label":o?`Signing in with ${e}...`:`Sign in with ${e}`,tooltip:void 0,style:L,className:D(n?.button&&"auth-partner-button-custom",c),icon:o?a(V,{"aria-label":"Loading"}):T,children:f!==S.COMPACT&&O()})}var Y=K;export{Y as default};
5
+ `,document.head.appendChild(r)}import{cn as D,DISPLAY as S,PROVIDER_ICONS as U,DefaultProviderIcon as M,Button as _,BUTTON_VARIANT as $,Spinner as V}from"@donotdev/components";import{AUTH_PARTNERS as W,useTranslation as j}from"@donotdev/core";import{EmailLinkForm as F}from"./EmailLinkForm";import H from"./EmailPasswordForm";import{getAuthMethod as k}from"../constants";import{useAuth as s}from"../useAuth";function K({partnerId:r,method:p,onSuccess:u,onError:l,className:d="",children:b,disabled:h=!1,display:f=S.AUTO,style:v,...q}){const{t:i}=j("auth"),g=s("user"),E=s("signInWithPartner"),A=s("linkWithPartner"),N=s("isAvailable"),[o,y]=B(!1),n=I(()=>W[r],[r]);if(r==="password")return a("div",{className:d,children:a(H,{mode:"signin",onSuccess:()=>u?.(null),onError:l,compact:!0})});if(r==="emailLink")return a("div",{className:d,children:a(F,{onSuccess:()=>u?.(null),onError:l})});const T=I(()=>U[r]||M,[r]),P=n?.firebaseProviderId,c=!!g?.providerData?.some(t=>t.providerId===P),m=g&&!c,w=async()=>{if(!(o||h)){y(!0);try{let t;if(m)t=await A(r,k(p));else{const R=k(p);t=await E(r,R)}t&&u?.(t)}catch(t){l?.(t instanceof Error?t:new Error(String(t)))}finally{y(!1)}}},e=n?.name,O=()=>{if(b)return b;if(m)return o?i("buttons.linking",{partner:e}):c?i("buttons.linked",{partner:e}):i("buttons.link",{partner:e});if(o)return i("buttons.signingIn",{partner:e});const t=n?.button?.textKey;return t?i(t):`Sign in with ${e}`},x=h||o||!N||m&&c||!1,C=n?.button?{backgroundColor:n.button.backgroundColor,color:n.button.textColor,borderColor:n.button.borderColor,"--partner-hover-bg":n.button.hoverBackgroundColor}:void 0,L=v?{...C,...v}:C;return a(_,{variant:$.OUTLINE,onClick:w,disabled:x,"aria-busy":o,display:f,"aria-label":o?`Signing in with ${e}...`:`Sign in with ${e}`,tooltip:void 0,style:L,className:D(n?.button&&"auth-partner-button-custom",d),icon:o?a(V,{"aria-label":"Loading"}):T,children:f!==S.COMPACT&&O()})}var Y=K;export{Y as default};
@@ -1 +1 @@
1
- "use client";import{jsx as n,jsxs as o,Fragment as f}from"react/jsx-runtime";import{Trash2 as y}from"lucide-react";import{useState as A}from"react";import{Dialog as g,Button as s,BUTTON_VARIANT as u,PasswordInput as R,Label as D,Checkbox as k,Alert as C,ALERT_VARIANT as b,Stack as l,Text as v,List as w}from"@donotdev/components";import{useTranslation as T}from"@donotdev/core";function E({open:h,isLoading:c,error:r,onReauth:m,onCancel:a}){const{t:e}=T("auth"),[i,p]=A(""),d=async()=>{await m(i)};return n(g,{open:h,onOpenChange:t=>!t&&a(),title:e("deleteAccount.reauth.title","Confirm Your Identity"),description:e("deleteAccount.reauth.description","For security, please re-enter your password to continue."),footer:o(f,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:c,children:e("deleteAccount.reauth.cancel","Cancel")}),n(s,{variant:u.DEFAULT,onClick:d,disabled:c||!i,children:c?e("deleteAccount.reauth.verifying","Verifying..."):e("deleteAccount.reauth.continue","Continue")})]}),children:n("form",{onSubmit:t=>{t.preventDefault(),d()},children:o(l,{children:[n(R,{value:i,onChange:t=>p(t.target.value),label:e("deleteAccount.reauth.password","Password"),disabled:c,placeholder:e("deleteAccount.reauth.passwordPlaceholder","Enter your password"),required:!0,className:"dndev-w-full"}),r&&n(C,{variant:b.ERROR,description:r})]})})})}function x({open:h,isLoading:c,error:r,onConfirm:m,onCancel:a}){const{t:e}=T("auth"),[i,p]=A(!1),d=async()=>{i&&await m()};return n(g,{open:h,onOpenChange:t=>!t&&a(),"data-content-size":"text",title:e("deleteAccount.confirm.title","Delete Your Account?"),description:e("deleteAccount.confirm.description","This action cannot be undone. This will permanently delete your account."),footer:o(f,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:c,children:e("deleteAccount.confirm.cancel","Cancel")}),n(s,{variant:u.DESTRUCTIVE,icon:y,onClick:d,disabled:c||!i,children:c?e("deleteAccount.confirm.deleting","Deleting..."):e("deleteAccount.confirm.delete","Delete My Account")})]}),children:o(l,{gap:"large",children:[o(l,{children:[n(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatDeleted","What will be deleted:")}),n(w,{items:[e("deleteAccount.confirm.credentials","Your account and authentication credentials"),e("deleteAccount.confirm.profile","Your profile information"),e("deleteAccount.confirm.oauth","All connected OAuth providers"),e("deleteAccount.confirm.subscriptions","Active subscriptions (will be canceled)")]})]}),o(l,{children:[n(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatKept","What will be kept (anonymized):")}),n(w,{items:[e("deleteAccount.confirm.billing","Billing history for tax/accounting purposes"),e("deleteAccount.confirm.invoices","Past invoices and transaction records")]})]}),o(l,{direction:"row",align:"start",children:[n(k,{id:"confirm-delete",checked:i,onCheckedChange:t=>p(t===!0)}),n(D,{htmlFor:"confirm-delete",children:e("deleteAccount.confirm.checkbox","I understand this action cannot be undone")})]}),r&&n(C,{variant:b.ERROR,description:r})]})})}export{x as ConfirmDeleteDialog,E as ReauthDialog};
1
+ "use client";import{jsx as n,jsxs as c,Fragment as f}from"react/jsx-runtime";import{Trash2 as y}from"lucide-react";import{useState as A}from"react";import{Dialog as g,Button as s,BUTTON_VARIANT as u,PasswordInput as R,Label as D,Checkbox as k,Alert as C,ALERT_VARIANT as b,Stack as l,Text as v,List as w}from"@donotdev/components";import{useTranslation as T}from"@donotdev/core";function E({open:h,isLoading:o,error:r,onReauth:m,onCancel:a}){const{t:e}=T("auth"),[i,p]=A(""),d=async()=>{await m(i)};return n(g,{open:h,onOpenChange:t=>!t&&a(),title:e("deleteAccount.reauth.title","Confirm Your Identity"),description:e("deleteAccount.reauth.description","For security, please re-enter your password to continue."),footer:c(f,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:o,children:e("deleteAccount.reauth.cancel","Cancel")}),n(s,{variant:u.DEFAULT,onClick:d,disabled:o||!i,children:o?e("deleteAccount.reauth.verifying","Verifying..."):e("deleteAccount.reauth.continue","Continue")})]}),children:n("form",{onSubmit:t=>{t.preventDefault(),d()},children:c(l,{children:[n(R,{value:i,onChange:t=>p(t.target.value),label:e("deleteAccount.reauth.password","Password"),disabled:o,placeholder:e("deleteAccount.reauth.passwordPlaceholder","Enter your password"),required:!0,className:"dndev-w-full"}),r&&n(C,{variant:b.ERROR,description:r})]})})})}function x({open:h,isLoading:o,error:r,onConfirm:m,onCancel:a}){const{t:e}=T("auth"),[i,p]=A(!1),d=async()=>{i&&await m()};return n(g,{open:h,onOpenChange:t=>!t&&a(),"data-content-size":"text",title:e("deleteAccount.confirm.title","Delete Your Account?"),description:e("deleteAccount.confirm.description","This action cannot be undone. This will permanently delete your account."),footer:c(f,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:o,children:e("deleteAccount.confirm.cancel","Cancel")}),n(s,{variant:u.DESTRUCTIVE,icon:y,onClick:d,disabled:o||!i,children:o?e("deleteAccount.confirm.deleting","Deleting..."):e("deleteAccount.confirm.delete","Delete My Account")})]}),children:c(l,{gap:"large",children:[c(l,{children:[n(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatDeleted","What will be deleted:")}),n(w,{items:[e("deleteAccount.confirm.credentials","Your account and authentication credentials"),e("deleteAccount.confirm.profile","Your profile information"),e("deleteAccount.confirm.oauth","All connected OAuth providers"),e("deleteAccount.confirm.subscriptions","Active subscriptions (will be canceled)")]})]}),c(l,{children:[n(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatKept","What will be kept (anonymized):")}),n(w,{items:[e("deleteAccount.confirm.billing","Billing history for tax/accounting purposes"),e("deleteAccount.confirm.invoices","Past invoices and transaction records")]})]}),c(l,{direction:"row",align:"start",children:[n(k,{id:"confirm-delete",checked:i,onCheckedChange:t=>p(t===!0)}),n(D,{htmlFor:"confirm-delete",children:e("deleteAccount.confirm.checkbox","I understand this action cannot be undone")})]}),r&&n(C,{variant:b.ERROR,description:r})]})})}export{x as ConfirmDeleteDialog,E as ReauthDialog};
@@ -1 +1 @@
1
- {"version":3,"file":"EmailLinkForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailLinkForm.tsx"],"names":[],"mappings":"AA4BA,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAc,EACd,SAAS,EACT,OAAO,EACP,kBAAkB,GACnB,EAAE,kBAAkB,+BA0FpB;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"EmailLinkForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailLinkForm.tsx"],"names":[],"mappings":"AA6BA,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAc,EACd,SAAS,EACT,OAAO,EACP,kBAAkB,GACnB,EAAE,kBAAkB,+BA2FpB;AAED,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Mail as o,CheckCircle as S}from"lucide-react";import{Button as c,BUTTON_VARIANT as f,Input as T,Alert as b,ALERT_VARIANT as C,Spinner as R,Stack as n,Text as s}from"@donotdev/components";import{useTranslation as x}from"@donotdev/core";import{useEmailLinkForm as A}from"../hooks/useEmailLinkForm";function m({className:r="",onSuccess:u,onError:h,actionCodeSettings:k}){const{t:i}=x("auth"),{email:t,setEmail:L,isLoading:a,isSent:v,error:d,handleSendLink:p,handleResend:g,canSubmit:E}=A({onSuccess:u,onError:h,actionCodeSettings:k});return v?l(n,{className:r,children:[l(n,{align:"center",children:[e(S,{className:"dndev-size-touch"}),e(s,{as:"h3",level:"h3",children:i("emailLink.checkEmail","Check Your Email")}),e(s,{level:"small",variant:"muted",className:"dndev-text-center",children:i("emailLink.sentMessage",`We've sent a sign-in link to ${t}. Click the link in your email to complete sign-in.`)})]}),e(n,{direction:"row",justify:"center",children:e(c,{variant:f.OUTLINE,onClick:g,icon:o,iconEnd:!1,children:i("emailLink.resend","Resend Link")})})]}):e("form",{onSubmit:p,className:r,children:l(n,{children:[e(T,{type:"email",label:i("emailLink.emailLabel","Email Address"),value:t,onChange:N=>L(N.target.value),placeholder:i("emailLink.emailPlaceholder","Enter your email address"),required:!0,disabled:a,className:"dndev-w-full"}),d&&e(b,{variant:C.ERROR,description:d}),e(c,{type:"submit",disabled:!E,icon:a?e(R,{"aria-label":"Loading"}):o,iconEnd:!1,className:"dndev-w-full",children:a?i("emailLink.sending","Sending Link..."):i("emailLink.sendLink","Send Sign-In Link")}),e(s,{level:"small",variant:"muted",className:"dndev-text-center",children:i("emailLink.helpText","We'll send you a secure link to sign in without a password.")})]})})}var y=m;export{m as EmailLinkForm,y as default};
1
+ "use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Mail as d,CheckCircle as N}from"lucide-react";import{Button as c,BUTTON_VARIANT as f,Input as C,Alert as T,ALERT_VARIANT as b,Spinner as A,Stack as n,Text as s}from"@donotdev/components";import{useTranslation as R}from"@donotdev/core";import{AuthCaptcha as x}from"../emailAuth/captcha";import{useEmailLinkForm as y}from"../hooks/useEmailLinkForm";function m({className:r="",onSuccess:u,onError:h,actionCodeSettings:k}){const{t:i}=R("auth"),{email:t,setEmail:L,isLoading:a,isSent:p,error:o,handleSendLink:v,handleResend:g,canSubmit:E}=y({onSuccess:u,onError:h,actionCodeSettings:k});return p?l(n,{className:r,children:[l(n,{align:"center",children:[e(N,{className:"dndev-size-touch"}),e(s,{as:"h3",level:"h3",children:i("emailLink.checkEmail","Check Your Email")}),e(s,{level:"small",variant:"muted",className:"dndev-text-center",children:i("emailLink.sentMessage",`We've sent a sign-in link to ${t}. Click the link in your email to complete sign-in.`)})]}),e(n,{direction:"row",justify:"center",children:e(c,{variant:f.OUTLINE,onClick:g,icon:d,iconEnd:!1,children:i("emailLink.resend","Resend Link")})})]}):e("form",{onSubmit:v,className:r,children:l(n,{children:[e(C,{type:"email",label:i("emailLink.emailLabel","Email Address"),value:t,onChange:S=>L(S.target.value),placeholder:i("emailLink.emailPlaceholder","Enter your email address"),required:!0,disabled:a,className:"dndev-w-full"}),o&&e(T,{variant:b.ERROR,description:o}),e(x,{}),e(c,{type:"submit",disabled:!E,icon:a?e(A,{"aria-label":"Loading"}):d,iconEnd:!1,className:"dndev-w-full",children:a?i("emailLink.sending","Sending Link..."):i("emailLink.sendLink","Send Sign-In Link")}),e(s,{level:"small",variant:"muted",className:"dndev-text-center",children:i("emailLink.helpText","We'll send you a secure link to sign in without a password.")})]})})}var w=m;export{m as EmailLinkForm,w as default};
@@ -3,7 +3,9 @@ import type { EmailPasswordFormProps } from '../constants';
3
3
  * Email/password form with three views: sign in (remember me, forgot password),
4
4
  * sign up (password policy + strength, breached-password check, confirmation,
5
5
  * consent) and forgot password. Success calls `onSuccess` at once; what the user must
6
- * still do arrives as a toast that stays until dismissed.
6
+ * still do arrives as a toast that stays until dismissed. With `confirmation="code"`,
7
+ * a sign-up (or a sign-in of an unconfirmed address) shows the code step instead, and
8
+ * `onSuccess` runs once the code signed the user in.
7
9
  *
8
10
  * @component
9
11
  * @example
@@ -11,6 +13,6 @@ import type { EmailPasswordFormProps } from '../constants';
11
13
  * <EmailPasswordForm onSuccess={() => setOpen(false)} />
12
14
  * ```
13
15
  */
14
- declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, }: EmailPasswordFormProps): import("react").JSX.Element;
16
+ declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, confirmation, }: EmailPasswordFormProps): import("react").JSX.Element;
15
17
  export default EmailPasswordForm;
16
18
  //# sourceMappingURL=EmailPasswordForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAQ3D;;;;;;;;;;;GAWG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAS,EACT,GAAG,EACH,OAAO,EACP,YAAY,GACb,EAAE,sBAAsB,+BAiFxB;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAQ3D;;;;;;;;;;;;;GAaG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAS,EACT,GAAG,EACH,OAAO,EACP,YAAsB,GACvB,EAAE,sBAAsB,+BAyGxB;AAED,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useState as A}from"react";import{Button as x,BUTTON_VARIANT as B,Stack as m,Text as w}from"@donotdev/components";import{useTranslation as L}from"@donotdev/core";import{AuthConfirmPasswordField as R,AuthConsentField as U,AuthEmailField as d,AuthForm as h,AuthFormAlerts as p,AuthPasswordField as v,AuthRememberMeField as V,AuthSubmitButton as g}from"../emailAuth/fields";import{AUTH_FIELD as _,useEmailSignIn as j,useEmailSignUp as C,usePasswordResetRequest as H}from"../emailAuth/flows";const M=r=>{const s=r.currentTarget.form?.elements.namedItem(_.EMAIL);return s instanceof HTMLInputElement?s.value:""};function q({mode:r="signin",onSuccess:s,onError:F,className:o,tos:T,privacy:E,captchaToken:I}){const{t:a}=L("auth"),[f,S]=A(r),[i,k]=A(""),l={onSuccess:()=>s?.(void 0),onError:F,captchaToken:I},y=j(l),N=C(l),b=H(l),P=u=>c=>{k(M(c)),S(u)},t=(u,c)=>e(x,{type:"button",variant:B.LINK,onClick:P(c),children:u});return f==="reset"?n(h,{flow:b,className:o,children:[e(w,{variant:"muted",children:a("forgotPassword.intro","Enter your email and we will send you a reset link.")}),e(d,{defaultValue:i}),e(p,{}),e(g,{}),e(m,{align:"center",children:t(a("back","Back"),"signin")})]},"reset"):f==="signup"?n(h,{flow:N,className:o,children:[e(d,{defaultValue:i}),e(v,{}),e(R,{}),e(U,{tos:T,privacy:E}),e(p,{}),e(g,{}),e(m,{align:"center",children:t(a("alreadyHaveAccount","Already have an account? Sign In"),"signin")})]},"signup"):n(h,{flow:y,className:o,children:[e(d,{defaultValue:i}),e(v,{}),e(V,{}),e(p,{}),e(g,{}),n(m,{direction:"row",gap:"tight",justify:"center",align:"center",children:[t(a("forgotPassword","Forgot password?"),"reset"),e(w,{as:"span",variant:"muted",children:"|"}),t(a("actions.sign_up_submit","Sign Up"),"signup")]})]},"signin")}var D=q;export{D as default};
1
+ "use client";import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useState as g}from"react";import{Button as B,BUTTON_VARIANT as L,Stack as r,Text as F}from"@donotdev/components";import{useTranslation as R}from"@donotdev/core";import{AuthCodeStep as V,AuthConfirmPasswordField as _,AuthConsentField as j,AuthEmailField as p,AuthForm as A,AuthFormAlerts as w,AuthPasswordField as C,AuthRememberMeField as H,AuthSubmitButton as v}from"../emailAuth/fields";import{AUTH_FIELD as M,useEmailSignIn as U,useEmailSignUp as q,usePasswordResetRequest as D}from"../emailAuth/flows";const K=l=>{const a=l.currentTarget.form?.elements.namedItem(M.EMAIL);return a instanceof HTMLInputElement?a.value:""};function O({mode:l="signin",onSuccess:a,onError:N,className:s,tos:y,privacy:I,confirmation:c="toast"}){const{t}=R("auth"),[S,T]=g(l),[u,E]=g(""),[m,d]=g(null),f={onSuccess:()=>a?.(void 0),onError:N},b=U({...f,confirmation:c,onCodeSent:d}),k=q({...f,confirmation:c,onSuccess:n=>{c==="code"&&n.awaitingConfirmation?d(n.email):a?.(void 0)}}),P=D(f);if(m!==null)return e(r,{className:s,children:e(V,{email:m,onSuccess:()=>a?.(void 0),onChangeEmail:()=>{E(m),d(null)}})});const x=n=>h=>{E(K(h)),T(n)},i=(n,h)=>e(B,{type:"button",variant:L.LINK,onClick:x(h),children:n});return S==="reset"?o(A,{flow:P,className:s,children:[e(F,{variant:"muted",children:t("forgotPassword.intro","Enter your email and we will send you a reset link.")}),e(p,{defaultValue:u}),e(w,{}),e(v,{}),e(r,{align:"center",children:i(t("back","Back"),"signin")})]},"reset"):S==="signup"?o(A,{flow:k,className:s,children:[e(p,{defaultValue:u}),e(C,{}),e(_,{}),e(j,{tos:y,privacy:I}),e(w,{}),e(v,{}),e(r,{align:"center",children:i(t("alreadyHaveAccount","Already have an account? Sign In"),"signin")})]},"signup"):o(A,{flow:b,className:s,children:[e(p,{defaultValue:u}),e(C,{}),e(H,{}),e(w,{}),e(v,{}),o(r,{direction:"row",gap:"tight",justify:"center",align:"center",children:[i(t("forgotPassword","Forgot password?"),"reset"),e(F,{as:"span",variant:"muted",children:"|"}),i(t("actions.sign_up_submit","Create account"),"signup")]})]},"signin")}var Y=O;export{Y as default};
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useId as h}from"react";import{Card as y,Button as V,BUTTON_VARIANT as A,Alert as b,Spinner as M,Stack as d,Text as T}from"@donotdev/components";import{useTranslation as x,handleError as w}from"@donotdev/core";import{useAuth as n}from"../useAuth";function I({verifyButtonText:j,successMessage:k,sendingMessage:B,alreadyVerifiedMessage:E,notSignedInMessage:R,errorMessage:$,id:u}){const{t:e}=x("auth"),t=n("user"),i=n("emailVerification"),l=n("sendEmailVerification"),s=t?.id,c=h(),a=u||`email-verification-${c}`,f=`${a}-heading`,m=`${a}-button`,g=async()=>{if(!(!t||!s))try{await l()}catch(v){w(v)}};if(!t||!s)return null;const p=()=>{if(i.status!=="pending"&&i.status==="error")return"error"};return r(y,{id:a,title:r("span",{id:f,children:e("emailVerification.title")}),children:o(d,{children:[o(d,{direction:"row",justify:"between",align:"center",children:[r(T,{level:"small",variant:"muted",children:e("emailVerification.status.unknown")}),r(V,{id:m,onClick:g,disabled:i.status==="pending","aria-busy":i.status==="pending",variant:A.PRIMARY,icon:i.status==="pending"?r(M,{"aria-label":"Loading"}):void 0,iconEnd:!1,children:i.status==="pending"?e("status.verifying"):e("buttons.verify","Verify")})]}),i.status!=="verified"&&r(b,{variant:p(),title:i.status==="error"?e("aria.errorAlert"):e("status.verifying"),description:i.status==="error"?("error"in i?i.error:void 0)||e("emailVerification.error","An error occurred"):e("emailVerification.sending","Sending verification email...")})]})})}var S=I;export{S as default};
1
+ "use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useId as h}from"react";import{Card as y,Button as V,BUTTON_VARIANT as A,Alert as b,Spinner as M,Stack as d,Text as T}from"@donotdev/components";import{useTranslation as x,handleError as w}from"@donotdev/core";import{useAuth as n}from"../useAuth";function I({verifyButtonText:j,successMessage:k,sendingMessage:B,alreadyVerifiedMessage:E,notSignedInMessage:R,errorMessage:$,id:l}){const{t:e}=x("auth"),t=n("user"),i=n("emailVerification"),u=n("sendEmailVerification"),s=t?.id,c=h(),a=l||`email-verification-${c}`,f=`${a}-heading`,m=`${a}-button`,g=async()=>{if(!(!t||!s))try{await u()}catch(v){w(v)}};if(!t||!s)return null;const p=()=>{if(i.status!=="pending"&&i.status==="error")return"error"};return r(y,{id:a,title:r("span",{id:f,children:e("emailVerification.title")}),children:o(d,{children:[o(d,{direction:"row",justify:"between",align:"center",children:[r(T,{level:"small",variant:"muted",children:e("emailVerification.status.unknown")}),r(V,{id:m,onClick:g,disabled:i.status==="pending","aria-busy":i.status==="pending",variant:A.PRIMARY,icon:i.status==="pending"?r(M,{"aria-label":"Loading"}):void 0,iconEnd:!1,children:i.status==="pending"?e("status.verifying"):e("buttons.verify","Verify")})]}),i.status!=="verified"&&r(b,{variant:p(),title:i.status==="error"?e("aria.errorAlert"):e("status.verifying"),description:i.status==="error"?("error"in i?i.error:void 0)||e("emailVerification.error","An error occurred"):e("emailVerification.sending","Sending verification email...")})]})})}var S=I;export{S as default};
@@ -1 +1 @@
1
- "use client";import{Fragment as t,jsx as s}from"react/jsx-runtime";import{useImperativeHandle as o,forwardRef as i}from"react";import{hasTierAccess as f}from"@donotdev/core";import{useAuth as c}from"../useAuth";const p=i(({featureId:e,fallback:r=null,children:l},n)=>{const a=c("userSubscription")?.features?.includes(e)||!1;return o(n,()=>({enabled:a}),[a]),a?s(t,{children:l}):r?s(t,{children:r}):null}),m=i(({tier:e,fallback:r=null,children:l},n)=>{const a=c("userSubscription"),d=e||"pro",u=f(a?.tier,d);return o(n,()=>({enabled:u}),[u]),u?s(t,{children:l}):r?s(t,{children:r}):null}),h=i((e,r)=>s(m,{ref:r,tier:"pro",...e})),b=i((e,r)=>s(m,{ref:r,tier:"premium",...e}));export{p as Feature,b as PremiumFeature,h as ProFeature};
1
+ "use client";import{Fragment as t,jsx as a}from"react/jsx-runtime";import{useImperativeHandle as o,forwardRef as i}from"react";import{hasTierAccess as f}from"@donotdev/core";import{useAuth as c}from"../useAuth";const p=i(({featureId:r,fallback:e=null,children:l},n)=>{const s=c("userSubscription")?.features?.includes(r)||!1;return o(n,()=>({enabled:s}),[s]),s?a(t,{children:l}):e?a(t,{children:e}):null}),m=i(({tier:r,fallback:e=null,children:l},n)=>{const s=c("userSubscription"),d=r||"pro",u=f(s?.tier,d);return o(n,()=>({enabled:u}),[u]),u?a(t,{children:l}):e?a(t,{children:e}):null}),h=i((r,e)=>a(m,{ref:e,tier:"pro",...r})),b=i((r,e)=>a(m,{ref:e,tier:"premium",...r}));export{p as Feature,b as PremiumFeature,h as ProFeature};
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as a,Fragment as w}from"react/jsx-runtime";import{Stack as f}from"@donotdev/components";import{hasRoleAccess as h,hasTierAccess as m}from"@donotdev/core";import{useAuth as t}from"../useAuth";import{AuthFallback as F}from"./AuthFallback";function g({requiredTier:e,userTier:i}){return r("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:a(f,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),a("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:e==="pro"?"Pro Feature":"Premium Feature"}),a("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",e," to access this feature",i&&` (current: ${i})`]})]})]})})}function p({requiredRole:e,userRole:i}){const o=Array.isArray(e)?e.join(" or "):e;return r("div",{className:"dndev-surface","data-variant":"destructive","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--destructive)",backgroundColor:"var(--muted)"},children:a(f,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),a("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive-foreground)"},children:"Access Denied"}),a("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",o," role",i&&` (current: ${i})`]})]})]})})}function b(){return r("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:a(f,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u23F0"}),a("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:"Subscription Required"}),r("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:"This feature requires an active subscription"})]})]})})}function y({children:e,role:i,tier:o,subscription:u,validate:n,fallback:s,message:l,showUpgradePrompt:A=!0,showLoginPrompt:S=!0}){const z=t("user"),R=t("loading"),q=t("userProfile"),v=t("userSubscription"),d=q?.role,c=v?.tier;return R?r("div",{style:{height:"2rem",borderRadius:"var(--radius)",backgroundColor:"var(--muted)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}):!z&&(i||o||u)?S?r(F,{message:l||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(T=>h(d,T))?s?r(s,{requiredRole:i,userRole:d||void 0}):r(p,{requiredRole:i,userRole:d||void 0}):o&&!m(c,o)?s?r(s,{requiredTier:o,userTier:c||"free"}):A?r(g,{requiredTier:o,userTier:c||"free"}):null:u&&!v?.isActive?s?r(s,{requiresSubscription:!0,hasSubscription:v?.isActive||!1}):r(b,{}):n&&!n(d,c)?s?r(s,{userRole:d,userTier:c}):r(p,{userRole:d}):r(w,{children:e})}function P(e){const i=t("user"),o=t("userProfile"),u=t("userSubscription"),n=o?.role,s=u?.tier;return!(!i&&(e.role||e.tier||e.subscription)||e.role&&!(Array.isArray(e.role)?e.role:[e.role]).some(l=>h(n,l))||e.tier&&!m(s,e.tier)||e.subscription&&!u?.isActive||e.validate&&n&&s&&!e.validate(n,s))}function k(e,i){return o=>r(y,{...i,children:r(e,{...o})})}export{p as AccessDenied,y as FeatureGuard,b as SubscriptionExpired,g as UpgradePrompt,P as useCanAccessFeature,k as withFeatureGuard};
1
+ "use client";import{jsx as e,jsxs as s,Fragment as w}from"react/jsx-runtime";import{Stack as f}from"@donotdev/components";import{hasRoleAccess as h,hasTierAccess as m}from"@donotdev/core";import{useAuth as t}from"../useAuth";import{AuthFallback as T}from"./AuthFallback";function g({requiredTier:r,userTier:i}){return e("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:s(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),s("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:r==="pro"?"Pro Feature":"Premium Feature"}),s("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",r," to access this feature",i&&` (current: ${i})`]})]})]})})}function p({requiredRole:r,userRole:i}){const o=Array.isArray(r)?r.join(" or "):r;return e("div",{className:"dndev-surface","data-variant":"destructive","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--destructive)",backgroundColor:"var(--muted)"},children:s(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),s("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive)"},children:"Access Denied"}),s("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",o," role",i&&` (current: ${i})`]})]})]})})}function b(){return e("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:s(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u23F0"}),s("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:"Subscription Required"}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:"This feature requires an active subscription"})]})]})})}function y({children:r,role:i,tier:o,subscription:u,validate:n,fallback:a,message:l,showUpgradePrompt:A=!0,showLoginPrompt:z=!0}){const S=t("user"),R=t("loading"),q=t("userProfile"),v=t("userSubscription"),d=q?.role,c=v?.tier;return R?e("div",{style:{height:"2rem",borderRadius:"var(--radius)",backgroundColor:"var(--muted)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}):!S&&(i||o||u)?z?e(T,{message:l||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(F=>h(d,F))?a?e(a,{requiredRole:i,userRole:d||void 0}):e(p,{requiredRole:i,userRole:d||void 0}):o&&!m(c,o)?a?e(a,{requiredTier:o,userTier:c||"free"}):A?e(g,{requiredTier:o,userTier:c||"free"}):null:u&&!v?.isActive?a?e(a,{requiresSubscription:!0,hasSubscription:v?.isActive||!1}):e(b,{}):n&&!n(d,c)?a?e(a,{userRole:d,userTier:c}):e(p,{userRole:d}):e(w,{children:r})}function P(r){const i=t("user"),o=t("userProfile"),u=t("userSubscription"),n=o?.role,a=u?.tier;return!(!i&&(r.role||r.tier||r.subscription)||r.role&&!(Array.isArray(r.role)?r.role:[r.role]).some(l=>h(n,l))||r.tier&&!m(a,r.tier)||r.subscription&&!u?.isActive||r.validate&&n&&a&&!r.validate(n,a))}function k(r,i){return o=>e(y,{...i,children:e(r,{...o})})}export{p as AccessDenied,y as FeatureGuard,b as SubscriptionExpired,g as UpgradePrompt,P as useCanAccessFeature,k as withFeatureGuard};
@@ -1 +1 @@
1
- "use client";import{jsx as t}from"react/jsx-runtime";import{Dialog as a}from"@donotdev/components";import{useTranslation as e}from"@donotdev/core";import{withAuthFallback as s}from"./AuthFallback";import r from"./MultipleAuthProviders";function p({open:n,onOpenChange:i}){const{t:o}=e("auth");return t(a,{open:n,onOpenChange:i,title:o("signIn","Sign In"),description:o("choosePlatform","Choose a platform to sign in with"),children:t(r,{layout:"vertical",showLabels:!0,method:"popup"})})}const m=s(p,{message:"Authentication is not configured",showLoginButton:!0});var l=m;export{l as default};
1
+ "use client";import{jsx as t}from"react/jsx-runtime";import{Dialog as i}from"@donotdev/components";import{useTranslation as a}from"@donotdev/core";import{withAuthFallback as s}from"./AuthFallback";import r from"./MultipleAuthProviders";function p({open:n,onOpenChange:e}){const{t:o}=a("auth");return t(i,{open:n,onOpenChange:e,title:o("signIn","Sign In"),description:o("choosePlatform","Choose a platform to sign in with"),children:t(r,{layout:"vertical",showLabels:!0,method:"popup"})})}const m=s(p,{message:"Authentication is not configured",showLoginButton:!0});var l=m;export{l as default};
@@ -1 +1 @@
1
- "use client";import{jsx as a,jsxs as k}from"react/jsx-runtime";import{Suspense as S,lazy as $,useId as y}from"react";import{Alert as E,ALERT_VARIANT as P,Stack as c,Grid as T}from"@donotdev/components";import{useTranslation as j,getEnabledAuthPartners as C}from"@donotdev/core";import{useAuth as m}from"../useAuth";import{withAuthFallback as G}from"./AuthFallback";import M from"./AuthPartnerButton";import{getAuthMethod as O}from"../constants";import{useAccountLinking as q}from"../hooks/useAccountLinking";const B=$(()=>import("./AccountLinking")),F=({providers:h,containerClassName:e="",providerClassName:p="",method:g,size:_="md",layout:r="vertical",showLabels:f=!0,spacing:o="medium",ariaLabel:v,id:A,fullWidth:b=!0,onSuccess:N})=>{const{t:s}=j("auth"),w=y(),n=A||w,{isRequired:R}=q(),l=m("error"),x=m("isAvailable"),z=O(g),i=h||C();if(!i||i.length===0)return a("div",{className:e,children:a("p",{children:"No authentication providers are configured"})});const I=()=>{const d=i.map((t,L)=>a(M,{partnerId:t,method:z,className:`${p} ${b?"dndev-w-full":""}`,tabIndex:L===0?0:void 0,id:`${n}-${t}-button`,onSuccess:N,children:f?void 0:null},t));return r==="grid"?a(T,{cols:2,gap:o,className:e,children:d}):a(c,{direction:r==="horizontal"?"row":"column",wrap:r==="horizontal"?"wrap":void 0,gap:o,align:r==="horizontal"?"center":"stretch",className:e,children:d})};return k(c,{className:"dndev-mx-auto",id:n,role:"region","aria-label":v||s("aria.signInOptions","Sign in options"),children:[I(),l&&x&&a(E,{variant:P.ERROR,description:l.message||s("errorGeneric","Authentication failed. Please try again.")}),R&&a(S,{fallback:null,children:a(B,{})})]})},u=G(F,{message:"Authentication providers are not configured",showLoginButton:!0});var V=u;export{u as MultipleAuthProviders,V as default};
1
+ "use client";import{jsx as a,jsxs as k}from"react/jsx-runtime";import{Suspense as L,lazy as $,useId as y}from"react";import{Alert as E,ALERT_VARIANT as P,Stack as c,Grid as T}from"@donotdev/components";import{useTranslation as j,getEnabledAuthPartners as C}from"@donotdev/core";import{useAuth as m}from"../useAuth";import{withAuthFallback as G}from"./AuthFallback";import M from"./AuthPartnerButton";import{getAuthMethod as O}from"../constants";import{useAccountLinking as q}from"../hooks/useAccountLinking";const B=$(()=>import("./AccountLinking")),F=({providers:h,containerClassName:r="",providerClassName:p="",method:g,size:_="md",layout:e="vertical",showLabels:f=!0,spacing:o="medium",ariaLabel:v,id:A,fullWidth:b=!0,onSuccess:N})=>{const{t}=j("auth"),w=y(),n=A||w,{isRequired:R}=q(),l=m("error"),x=m("isAvailable"),z=O(g),i=h||C();if(!i||i.length===0)return a("div",{className:r,children:a("p",{children:"No authentication providers are configured"})});const I=()=>{const d=i.map((s,S)=>a(M,{partnerId:s,method:z,className:`${p} ${b?"dndev-w-full":""}`,tabIndex:S===0?0:void 0,id:`${n}-${s}-button`,onSuccess:N,children:f?void 0:null},s));return e==="grid"?a(T,{cols:2,gap:o,className:r,children:d}):a(c,{direction:e==="horizontal"?"row":"column",wrap:e==="horizontal"?"wrap":void 0,gap:o,align:e==="horizontal"?"center":"stretch",className:r,children:d})};return k(c,{className:"dndev-mx-auto",id:n,role:"region","aria-label":v||t("aria.signInOptions","Sign in options"),children:[I(),l&&x&&a(E,{variant:P.ERROR,description:l.message||t("errorGeneric","Authentication failed. Please try again.")}),R&&a(L,{fallback:null,children:a(B,{})})]})},u=G(F,{message:"Authentication providers are not configured",showLoginButton:!0});var V=u;export{u as MultipleAuthProviders,V as default};
@@ -1,5 +1,9 @@
1
1
  export interface PasswordStrengthIndicatorProps {
2
- /** Current password value */
2
+ /**
3
+ * Current password value. Empty: idle state (empty bar, muted placeholder label,
4
+ * unmet checklist) with exactly the layout of the typed state, so the slot can stay
5
+ * mounted before the first keystroke without shifting the form when typing starts.
6
+ */
3
7
  password: string;
4
8
  /** Minimum password length */
5
9
  minLength?: number;
@@ -13,7 +17,9 @@ export type PasswordStrength = 'weak' | 'fair' | 'good' | 'strong';
13
17
  * PasswordStrengthIndicator Component
14
18
  *
15
19
  * Displays visual password strength indicator and optional requirements checklist.
16
- * Uses Progress component for the strength bar and Text for labels.
20
+ * Uses Progress component for the strength bar and Text for labels. The bar is named
21
+ * after its visible label and announces the strength in words (`aria-valuetext`), not
22
+ * a bare percentage.
17
23
  *
18
24
  * @component
19
25
  * @version 0.1.0
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordStrengthIndicator.d.ts","sourceRoot":"","sources":["../../src/components/PasswordStrengthIndicator.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,8BAA8B;IAC7C,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AA6FnE;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,EACR,SAAa,EACb,gBAAuB,EACvB,SAAS,GACV,EAAE,8BAA8B,+BAkFhC"}
1
+ {"version":3,"file":"PasswordStrengthIndicator.d.ts","sourceRoot":"","sources":["../../src/components/PasswordStrengthIndicator.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AA6FnE;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,EACR,SAAa,EACb,gBAAuB,EACvB,SAAS,GACV,EAAE,8BAA8B,+BAsFhC"}
@@ -1 +1 @@
1
- "use client";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Check as v,Circle as f}from"lucide-react";import{useMemo as m}from"react";import{Progress as b,Stack as o,Text as l,cn as q}from"@donotdev/components";import{useTranslation as k}from"@donotdev/core";function S(e){if(!e)return"weak";let t=0;return e.length>=8&&(t+=1),e.length>=12&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[^a-zA-Z0-9]/.test(e)&&(t+=1),t<=2?"weak":t<=4?"fair":t<=5?"good":"strong"}function N(e,t,s){return[{label:s("passwordRequirement.length",`At least ${t} characters`,{count:t}),met:e.length>=t},{label:s("passwordRequirement.uppercase","One uppercase letter"),met:/[A-Z]/.test(e)},{label:s("passwordRequirement.lowercase","One lowercase letter"),met:/[a-z]/.test(e)},{label:s("passwordRequirement.number","One number"),met:/[0-9]/.test(e)},{label:s("passwordRequirement.special","One special character (!@#$%^&*)"),met:/[^a-zA-Z0-9]/.test(e)}]}const R={weak:25,fair:50,good:75,strong:100},g={weak:"destructive",fair:"warning",good:"accent",strong:"success"};function x({password:e,minLength:t=8,showRequirements:s=!0,className:p}){const{t:a}=k("auth"),d=m(()=>S(e),[e]),u=m(()=>N(e,t,(n,c,w)=>a(n,{defaultValue:c||"",...w})),[e,t,a]),h={weak:a("passwordStrength.weak","Weak"),fair:a("passwordStrength.fair","Fair"),good:a("passwordStrength.good","Good"),strong:a("passwordStrength.strong","Strong")};return r(o,{gap:"tight",className:q("dndev-password-strength",p),children:[r(o,{gap:"tight",children:[r(o,{direction:"row",align:"center",justify:"between",gap:"tight",children:[r(l,{as:"span",level:"caption",variant:"muted",children:[a("passwordStrength.label","Password strength"),":"]}),i(l,{as:"strong",level:"caption",variant:g[d],children:h[d]})]}),i(b,{value:R[d],variant:g[d],className:"dndev-password-strength-bar"})]}),s&&r(o,{gap:"tight",className:"dndev-password-requirements",children:[r(l,{as:"strong",level:"caption",variant:"muted",children:[a("passwordRequirements","Password requirements"),":"]}),i(o,{gap:"tight","data-inset":"true",children:u.map((n,c)=>r(o,{direction:"row",align:"center",gap:"tight",className:"dndev-password-requirement-item",children:[n.met?i(v,{className:"dndev-size-xs","data-variant":"success"}):i(f,{className:"dndev-size-xs","data-variant":"muted"}),i(l,{as:"span",level:"caption",variant:n.met?"success":"muted","data-opacity":n.met?void 0:"70",children:n.label})]},c))})]})]})}export{x as PasswordStrengthIndicator};
1
+ "use client";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Check as f,Circle as b}from"lucide-react";import{useMemo as p}from"react";import{Progress as q,Stack as o,Text as c,cn as k}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";function x(e){if(!e)return"weak";let t=0;return e.length>=8&&(t+=1),e.length>=12&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[^a-zA-Z0-9]/.test(e)&&(t+=1),t<=2?"weak":t<=4?"fair":t<=5?"good":"strong"}function N(e,t,s){return[{label:s("passwordRequirement.length",`At least ${t} characters`,{count:t}),met:e.length>=t},{label:s("passwordRequirement.uppercase","One uppercase letter"),met:/[A-Z]/.test(e)},{label:s("passwordRequirement.lowercase","One lowercase letter"),met:/[a-z]/.test(e)},{label:s("passwordRequirement.number","One number"),met:/[0-9]/.test(e)},{label:s("passwordRequirement.special","One special character (!@#$%^&*)"),met:/[^a-zA-Z0-9]/.test(e)}]}const R={weak:25,fair:50,good:75,strong:100},u={weak:"destructive",fair:"warning",good:"accent",strong:"success"};function z({password:e,minLength:t=8,showRequirements:s=!0,className:h}){const{t:a}=S("auth"),d=p(()=>x(e),[e]),w=p(()=>N(e,t,(n,m,v)=>a(n,{defaultValue:m||"",...v})),[e,t,a]),l=e==="",g={weak:a("passwordStrength.weak","Weak"),fair:a("passwordStrength.fair","Fair"),good:a("passwordStrength.good","Good"),strong:a("passwordStrength.strong","Strong")};return r(o,{gap:"tight",className:k("dndev-password-strength",h),children:[r(o,{gap:"tight",children:[r(o,{direction:"row",align:"center",justify:"between",gap:"tight",children:[r(c,{as:"span",level:"caption",variant:"muted",children:[a("passwordStrength.label","Password strength"),":"]}),i(c,{as:"strong",level:"caption",variant:l?"muted":u[d],children:l?"\u2013":g[d]})]}),i(q,{"aria-label":a("passwordStrength.label","Password strength"),"aria-valuetext":l?void 0:g[d],value:l?0:R[d],variant:l?"default":u[d],className:"dndev-password-strength-bar"})]}),s&&r(o,{gap:"tight",className:"dndev-password-requirements",children:[r(c,{as:"strong",level:"caption",variant:"muted",children:[a("passwordRequirements","Password requirements"),":"]}),i(o,{gap:"tight","data-inset":"true",children:w.map((n,m)=>r(o,{direction:"row",align:"center",gap:"tight",className:"dndev-password-requirement-item",children:[n.met?i(f,{className:"dndev-size-xs","data-variant":"success"}):i(b,{className:"dndev-size-xs","data-variant":"muted"}),i(c,{as:"span",level:"caption",variant:n.met?"success":"muted","data-opacity":n.met?void 0:"70",children:n.label})]},m))})]})]})}export{z as PasswordStrengthIndicator};
@@ -144,11 +144,14 @@ export interface EmailPasswordFormProps extends BaseComponentProps, AuthCallback
144
144
  */
145
145
  privacy?: string | React.ReactNode | false;
146
146
  /**
147
- * CAPTCHA token to include with auth requests.
148
- * Consumer is responsible for rendering the CAPTCHA widget (e.g. Turnstile)
149
- * and passing the token here. When provided, submit is blocked until token is truthy.
147
+ * How a sign-up (or a sign-in of an unconfirmed address) confirms the email
148
+ * (default `'toast'`: the "check your email" toast with Resend). `'code'`: the form
149
+ * shows `AuthCodeStep` (a 6-character emailed code), then calls `onSuccess` once
150
+ * signed in. Needs a provider with `verifyEmailCode` (Supabase) and a code email
151
+ * template.
152
+ * @default 'toast'
150
153
  */
151
- captchaToken?: string;
154
+ confirmation?: 'toast' | 'code';
152
155
  }
153
156
  /**
154
157
  * Props for account linking component
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EACL,kBAAkB,IAAI,aAAa,EACnC,KAAK,gBAAgB,IAAI,YAAY,GACtC,MAAM,gBAAgB,CAAC;AAMxB;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAE5C,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,yCAAyC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wDAAwD;IACxD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,iEAAiE;IACjE,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,yCAAyC;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The Turnstile widget (theme `auto`, the app's language, full width). Hidden until
3
+ * Cloudflare asks the visitor to interact (Managed widget); an Invisible widget never
4
+ * shows. Renders nothing without `TURNSTILE_SITE_KEY`.
5
+ *
6
+ * @returns The widget container, or nothing
7
+ */
8
+ export declare function AuthCaptcha(): import("react").JSX.Element | null;
9
+ //# sourceMappingURL=captcha.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captcha.d.ts","sourceRoot":"","sources":["../../src/emailAuth/captcha.tsx"],"names":[],"mappings":"AA0BA;;;;;;GAMG;AACH,wBAAgB,WAAW,uCAc1B"}
@@ -0,0 +1 @@
1
+ "use client";import{jsx as n}from"react/jsx-runtime";import{useEffect as u,useRef as s}from"react";import{Stack as o}from"@donotdev/components";import{getCaptchaSiteKey as c,mountCaptchaWidget as i,useTranslation as l}from"@donotdev/core";function f(){const{language:r}=l("auth"),t=s(null),e=c();return u(()=>{if(!e||!t.current)return;const a=i(t.current,{language:r});return()=>a.remove()},[e,r]),e?n(o,{ref:t,children:null}):null}export{f as AuthCaptcha};
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode } from 'react';
2
- import type { EmailAuthFlow } from './flows';
2
+ import type { AuthUser } from '@donotdev/core';
3
+ import type { EmailAuthFlow, EmailCodeConfirmation } from './flows';
3
4
  /** Props of {@link AuthForm}. */
4
5
  export interface AuthFormProps {
5
6
  /** The flow this form runs (`useEmailSignIn()`, `useEmailSignUp()`, ...) */
@@ -34,9 +35,26 @@ export interface AuthTextFieldProps {
34
35
  * @returns The field
35
36
  */
36
37
  export declare function AuthEmailField({ label, placeholder, defaultValue, }: AuthTextFieldProps): import("react").JSX.Element;
38
+ /** Props of {@link AuthNameField}. */
39
+ export interface AuthNameFieldProps extends AuthTextFieldProps {
40
+ /** Help text: an (i) after the label shows it on hover, focus or tap */
41
+ info?: string;
42
+ }
43
+ /**
44
+ * Name field (`name="displayName"`, `autocomplete="name"`): the name the user wants in
45
+ * emails. Optional, never validated: sign-up stores it trimmed as the display name
46
+ * (metadata `full_name`) when filled, nothing when empty.
47
+ *
48
+ * @param props - AuthNameFieldProps
49
+ * @returns The field
50
+ */
51
+ export declare function AuthNameField({ label, placeholder, defaultValue, info, }: AuthNameFieldProps): import("react").JSX.Element;
37
52
  /**
38
53
  * Password field. Sign-in: `current-password`. Sign-up: `new-password` and a strength
39
- * meter with the policy requirements.
54
+ * meter, with the policy requirements unless the flow's `passwordComposition` is
55
+ * `false`. The meter's slot is always mounted (idle until the first keystroke), so
56
+ * typing never shifts the layout. It also reports each change to
57
+ * `flow.watchPassword`, which runs the breached-password pre-check.
40
58
  *
41
59
  * @param props - AuthTextFieldProps
42
60
  * @returns The field
@@ -98,11 +116,63 @@ export interface AuthSubmitButtonProps {
98
116
  children?: ReactNode;
99
117
  }
100
118
  /**
101
- * Submit button: full width, loading while the flow runs, disabled until the provider
102
- * is ready and while CAPTCHA / throttle block.
119
+ * Submit button: full width, loading while the flow runs (including the wait for a
120
+ * CAPTCHA token), disabled until the provider is ready and while throttled. With the
121
+ * env var `TURNSTILE_SITE_KEY` set, the CAPTCHA widget renders just above it (hidden
122
+ * unless Cloudflare asks the visitor to interact); every flow call of the form takes its
123
+ * token there.
103
124
  *
104
125
  * @param props - AuthSubmitButtonProps
105
126
  * @returns The button
106
127
  */
107
128
  export declare function AuthSubmitButton({ children }: AuthSubmitButtonProps): import("react").JSX.Element;
129
+ /** Props of {@link AuthCodeField}. */
130
+ export interface AuthCodeFieldProps {
131
+ /** The code step (`useEmailCodeConfirmation(...)`) */
132
+ confirmation: EmailCodeConfirmation;
133
+ /** Label (default: translated "Confirmation code") */
134
+ label?: string;
135
+ }
136
+ /**
137
+ * The sign-up code step: one box per character (`autocomplete="one-time-code"`,
138
+ * paste of the whole code), submitted as soon as the last character is typed, the
139
+ * error under it, "A new code has been sent." under it after a resend (no toast), and
140
+ * a Resend button with its countdown; after a resend the code input has focus again.
141
+ * With `TURNSTILE_SITE_KEY` set, the CAPTCHA widget renders above Resend (a resend is a
142
+ * gated call).
143
+ * Render it outside the
144
+ * sign-up `AuthForm` (it is not a form field).
145
+ *
146
+ * @param props - AuthCodeFieldProps
147
+ * @returns The code field
148
+ */
149
+ export declare function AuthCodeField({ confirmation, label }: AuthCodeFieldProps): import("react").JSX.Element;
150
+ /** Props of {@link AuthCodeStep}. */
151
+ export interface AuthCodeStepProps {
152
+ /** The address the code was sent to */
153
+ email: string;
154
+ /**
155
+ * Characters of the code: match the provider (Supabase: `mailer_otp_length`).
156
+ * @default 6
157
+ */
158
+ length?: number;
159
+ /** Called with the signed-in user once the code is confirmed */
160
+ onSuccess?: (user: AuthUser) => void;
161
+ /** Shows a "Change address" link that calls this (back to the form) */
162
+ onChangeEmail?: () => void;
163
+ }
164
+ /**
165
+ * The whole code step of a `confirmation: 'code'` sign-up or sign-in: "Enter the code
166
+ * sent to {email}", the code field (auto-submit, error, inline "new code sent",
167
+ * Resend with countdown) and, with `onChangeEmail`, a "Change address" link. No toast.
168
+ *
169
+ * @param props - AuthCodeStepProps
170
+ * @returns The code step
171
+ *
172
+ * @example
173
+ * ```tsx
174
+ * <AuthCodeStep email={email} onSuccess={next} onChangeEmail={() => setEmail(null)} />
175
+ * ```
176
+ */
177
+ export declare function AuthCodeStep({ email, length, onSuccess, onChangeEmail, }: AuthCodeStepProps): import("react").JSX.Element;
108
178
  //# sourceMappingURL=fields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/emailAuth/fields.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAA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CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE,qBAAqB,+BAuBnE;AAED,sCAAsC;AACtC,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,YAAY,EAAE,qBAAqB,CAAC;IACpC,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,kBAAkB,+BAuDxE;AAED,qCAAqC;AACrC,MAAM,WAAW,iBAAiB;IAChC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrC,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,SAAS,EACT,aAAa,GACd,EAAE,iBAAiB,+BAmBnB"}
@@ -1 +1 @@
1
- "use client";import{jsx as t,jsxs as u,Fragment as A}from"react/jsx-runtime";import{createContext as L,use as M,useId as m,useState as R}from"react";import{Alert as E,ALERT_VARIANT as P,Button as w,BUTTON_VARIANT as y,Checkbox as C,Dialog as x,Input as O,Label as V,PasswordInput as I,Stack as h,Text as N,cn as B}from"@donotdev/components";import{useAppConfig as D,useTranslation as p}from"@donotdev/core";import{useAuth as U}from"../useAuth";import{PasswordStrengthIndicator as W}from"../components/PasswordStrengthIndicator";import{AUTH_FIELD as v}from"./flows";const S=L(null);function b(){const i=M(S);if(!i)throw new Error("Auth fields must be rendered inside <AuthForm>");return i}function j({flow:i,children:e,className:a}){const{t:r}=p("auth");return i.unavailable?t(E,{variant:P.WARNING,title:r("unavailable.title","Authentication Unavailable"),description:r("unavailable.description","Sign-in is temporarily unavailable. Please try again later.")}):t(S,{value:i,children:t("form",{noValidate:!0,onSubmit:i.onSubmit,className:B("dndev-auth-form",a),children:t(h,{children:e})})})}function g({id:i,message:e}){return e?t(N,{as:"span",level:"caption",variant:"destructive",id:i,role:"alert",children:e}):null}function H({label:i,placeholder:e,defaultValue:a}){const{t:r}=p("auth"),n=b(),l=m(),s=m(),o=n.fieldErrors.email;return u(h,{gap:"tight",children:[t(O,{id:l,name:v.EMAIL,type:"email",autoComplete:"username",label:i??r("email","Email"),placeholder:e??r("emailPlaceholder","Enter your email"),defaultValue:a,disabled:n.busy,"aria-invalid":!!o,"aria-describedby":o?s:void 0,"data-variant":o?"destructive":void 0,className:"dndev-w-full"}),t(g,{id:s,message:o})]})}function K({label:i,placeholder:e}){const{t:a}=p("auth"),r=b(),n=m(),l=m(),[s,o]=R(""),c=r.mode==="signup",d=r.fieldErrors.password;return u(h,{gap:"tight",children:[t(I,{id:n,name:v.PASSWORD,autoComplete:c?"new-password":"current-password",label:i??a("password","Password"),placeholder:e??a("passwordPlaceholder","Enter your password"),onInput:c?f=>o(f.target.value):void 0,disabled:r.busy,"aria-invalid":!!d,"aria-describedby":d?l:void 0,"data-variant":d?"destructive":void 0,className:"dndev-w-full"}),t(g,{id:l,message:d}),c&&s!==""&&t(W,{password:s,minLength:r.passwordMinLength,showRequirements:!0})]})}function q({label:i,placeholder:e}){const{t:a}=p("auth"),r=b(),n=m(),l=m(),s=r.fieldErrors.confirmPassword;return u(h,{gap:"tight",children:[t(I,{id:n,name:v.CONFIRM_PASSWORD,autoComplete:"new-password",label:i??a("confirmPassword","Confirm Password"),placeholder:e??a("confirmPasswordPlaceholder","Re-enter your password"),disabled:r.busy,"aria-invalid":!!s,"aria-describedby":s?l:void 0,"data-variant":s?"destructive":void 0,className:"dndev-w-full"}),t(g,{id:l,message:s})]})}function G({label:i,defaultChecked:e=!0}){const{t:a}=p("auth"),r=b(),n=U("canRememberMe");return!r.ready||!n()?null:t(C,{name:v.REMEMBER_ME,defaultChecked:e,disabled:r.busy,label:i??a("rememberMe","Remember me")})}const Y={minHeight:"auto",padding:0,display:"inline"};function F({label:i,document:e}){const[a,r]=R(!1),n=typeof e=="string";return u(A,{children:[t(w,{type:"button",variant:y.LINK,onClick:()=>n?window.open(e,"_blank","noopener,noreferrer"):r(!0),className:"dndev-p-0 dndev-h-auto",style:Y,children:i}),!n&&t(x,{open:a,onOpenChange:r,title:i,showClose:!0,children:e})]})}function Q({tos:i,privacy:e}){const{t:a}=p("auth"),r=b(),n=D("app"),l=m(),s=m(),o=(_,T)=>n?.footer?.legalLinks?.find(k=>k.path.includes(_))?.path??T,c=i===void 0?o("terms","/legal/terms"):i,d=e===void 0?o("privacy","/legal/privacy"):e;if(c===!1&&d===!1)return null;const f=r.fieldErrors.consent;return u(h,{gap:"tight",children:[u(h,{direction:"row",gap:"tight",align:"start",children:[t(C,{id:l,name:v.CONSENT,disabled:r.busy,"aria-invalid":!!f,"aria-describedby":f?s:void 0}),t(V,{htmlFor:l,children:u(N,{as:"span",level:"caption",children:[a("terms.accept_prefix","I accept the")," ",c!==!1&&t(F,{label:a("terms.tos","Terms of Service"),document:c}),c!==!1&&d!==!1&&u(A,{children:[" ",a("terms.and","and")," "]}),d!==!1&&t(F,{label:a("terms.privacy","Privacy Policy"),document:d})]})})]}),t(g,{id:s,message:f})]})}function X(){const{t:i}=p("auth"),e=b();if(!e.error)return null;const a=e.unconfirmedEmail;return u(h,{gap:"tight",children:[t(E,{variant:P.ERROR,description:e.error}),a&&t(w,{type:"button",variant:y.LINK,onClick:()=>{e.resendVerification(a)},children:i("signup.resend_verification","Resend verification email")})]})}function Z({children:i}){const{t:e}=p("auth"),a=b(),r=a.mode==="signup"?e("actions.sign_up_submit","Sign Up"):a.mode==="reset"?e("forgotPassword.submit","Send reset link"):e("actions.sign_in_submit","Sign In");return t(w,{type:"submit",variant:y.PRIMARY,fullWidth:!0,loading:a.busy,disabled:!a.ready||a.blocked,children:i??r})}export{q as AuthConfirmPasswordField,Q as AuthConsentField,H as AuthEmailField,j as AuthForm,X as AuthFormAlerts,K as AuthPasswordField,G as AuthRememberMeField,Z as AuthSubmitButton};
1
+ "use client";import{jsx as t,jsxs as c,Fragment as E}from"react/jsx-runtime";import{createContext as x,use as D,useId as p,useRef as B,useState as N}from"react";import{Alert as P,ALERT_VARIANT as I,Button as v,BUTTON_VARIANT as w,Checkbox as S,Dialog as K,Input as V,Label as W,PasswordInput as F,PinInput as $,Stack as h,Text as A,cn as H}from"@donotdev/components";import{useAppConfig as U,useTranslation as m}from"@donotdev/core";import{useAuth as j}from"../useAuth";import{PasswordStrengthIndicator as Y}from"../components/PasswordStrengthIndicator";import{AuthCaptcha as L}from"./captcha";import{AUTH_FIELD as b,useEmailCodeConfirmation as q}from"./flows";const _=x(null);function f(){const e=D(_);if(!e)throw new Error("Auth fields must be rendered inside <AuthForm>");return e}function G({flow:e,children:n,className:a}){const{t:i}=m("auth");return e.unavailable?t(P,{variant:I.WARNING,title:i("unavailable.title","Authentication Unavailable"),description:i("unavailable.description","Sign-in is temporarily unavailable. Please try again later.")}):t(_,{value:e,children:t("form",{noValidate:!0,onSubmit:e.onSubmit,className:H("dndev-auth-form",a),children:t(h,{children:n})})})}function y({id:e,message:n}){return n?t(A,{as:"span",level:"caption",variant:"destructive",id:e,role:"alert",children:n}):null}function z({label:e,placeholder:n,defaultValue:a}){const{t:i}=m("auth"),r=f(),o=p(),l=p(),s=r.fieldErrors.email;return c(h,{gap:"tight",children:[t(V,{id:o,name:b.EMAIL,type:"email",autoComplete:"username",label:e??i("email","Email"),placeholder:n??i("emailPlaceholder","Enter your email"),defaultValue:a,readOnly:r.busy,"aria-invalid":!!s,"aria-describedby":s?l:void 0,"data-variant":s?"destructive":void 0,className:"dndev-w-full"}),t(y,{id:l,message:s})]})}function J({label:e,placeholder:n,defaultValue:a,info:i}){const{t:r}=m("auth"),o=f();return t(V,{name:b.DISPLAY_NAME,type:"text",autoComplete:"name",label:e??r("name","Name"),placeholder:n,defaultValue:a,info:i,readOnly:o.busy,className:"dndev-w-full"})}function k(){const{t:e}=m("auth");return{show:e("passwordToggle.show",{defaultValue:"Show password"}),hide:e("passwordToggle.hide",{defaultValue:"Hide password"})}}function Q({label:e,placeholder:n}){const{t:a}=m("auth"),i=f(),r=p(),o=p(),[l,s]=N(""),d=i.mode==="signup",u=i.fieldErrors.password,g=k();return c(h,{gap:"tight",children:[t(F,{id:r,name:b.PASSWORD,autoComplete:d?"new-password":"current-password",revealAriaLabel:g,label:e??a("password","Password"),placeholder:n??a("passwordPlaceholder","Enter your password"),onInput:d?R=>{const C=R.target.value;s(C),i.watchPassword?.(C)}:void 0,readOnly:i.busy,"aria-invalid":!!u,"aria-describedby":u?o:void 0,"data-variant":u?"destructive":void 0,className:"dndev-w-full"}),t(y,{id:o,message:u}),d&&t(Y,{password:l,minLength:i.passwordMinLength,showRequirements:i.passwordComposition!==!1})]})}function X({label:e,placeholder:n}){const{t:a}=m("auth"),i=f(),r=p(),o=p(),l=i.fieldErrors.confirmPassword,s=k();return c(h,{gap:"tight",children:[t(F,{id:r,name:b.CONFIRM_PASSWORD,autoComplete:"new-password",revealAriaLabel:s,label:e??a("confirmPassword","Confirm Password"),placeholder:n??a("confirmPasswordPlaceholder","Re-enter your password"),readOnly:i.busy,"aria-invalid":!!l,"aria-describedby":l?o:void 0,"data-variant":l?"destructive":void 0,className:"dndev-w-full"}),t(y,{id:o,message:l})]})}function Z({label:e,defaultChecked:n=!0}){const{t:a}=m("auth"),i=f(),r=j("canRememberMe");return!i.ready||!r()?null:t(S,{name:b.REMEMBER_ME,defaultChecked:n,label:e??a("rememberMe","Remember me")})}const ee={minHeight:"auto",padding:0,display:"inline"};function T({label:e,document:n}){const[a,i]=N(!1),r=typeof n=="string";return c(E,{children:[t(v,{type:"button",variant:w.LINK,onClick:()=>r?window.open(n,"_blank","noopener,noreferrer"):i(!0),className:"dndev-p-0 dndev-h-auto",style:ee,children:e}),!r&&t(K,{open:a,onOpenChange:i,title:e,showClose:!0,children:n})]})}function ae({tos:e,privacy:n}){const{t:a}=m("auth"),i=f(),r=U("app"),o=p(),l=p(),s=(R,C)=>r?.footer?.legalLinks?.find(O=>O.path.includes(R))?.path??C,d=e===void 0?s("terms","/legal/terms"):e,u=n===void 0?s("privacy","/legal/privacy"):n;if(d===!1&&u===!1)return null;const g=i.fieldErrors.consent;return c(h,{gap:"tight",children:[c(h,{direction:"row",gap:"tight",align:"start",children:[t(S,{id:o,name:b.CONSENT,"aria-invalid":!!g,"aria-describedby":g?l:void 0}),t(W,{htmlFor:o,children:c(A,{as:"span",level:"caption",children:[a("terms.accept_prefix","I accept the")," ",d!==!1&&t(T,{label:a("terms.tos","Terms of Service"),document:d}),d!==!1&&u!==!1&&c(E,{children:[" ",a("terms.and","and")," "]}),u!==!1&&t(T,{label:a("terms.privacy","Privacy Policy"),document:u})]})})]}),t(y,{id:l,message:g})]})}function ne(){const{t:e}=m("auth"),n=f();if(!n.error)return null;const a=n.unconfirmedEmail;return c(h,{gap:"tight",children:[t(P,{variant:I.ERROR,description:n.error}),a&&t(v,{type:"button",variant:w.LINK,onClick:()=>{n.resendVerification(a)},children:e("signup.resend_verification","Resend verification email")})]})}function te({children:e}){const{t:n}=m("auth"),a=f(),i=a.mode==="signup"?n("actions.sign_up_submit","Create account"):a.mode==="reset"?n("forgotPassword.submit","Send reset link"):n("actions.sign_in_submit","Sign In");return c(h,{gap:"tight",children:[t(L,{}),t(v,{type:"submit",variant:w.PRIMARY,fullWidth:!0,loading:a.busy,disabled:!a.ready||a.blocked,children:e??i})]})}function M({confirmation:e,label:n}){const{t:a}=m("auth"),i=p(),r=B(null),{error:o,resent:l,resendIn:s}=e;return c(h,{gap:"tight",children:[t($,{ref:r,value:e.code,onChange:e.setCode,onComplete:d=>{e.submit(d)},length:e.length,mask:!1,autoFocus:!0,label:n??a("codeConfirmation.label",{defaultValue:"Confirmation code"}),disabled:e.busy||!e.ready,digitAriaLabel:(d,u)=>a("codeConfirmation.digit",{defaultValue:`Digit ${d} of ${u}`,index:d,length:u}),"aria-invalid":!!o,"aria-describedby":o?i:void 0}),t(y,{id:i,message:o??void 0}),l&&t(A,{as:"span",level:"caption",variant:"success",role:"status",children:a("codeConfirmation.sent",{defaultValue:"A new code has been sent."})}),t(L,{}),t(v,{type:"button",variant:w.LINK,loading:e.resending,disabled:s>0||!e.ready,onClick:()=>{e.resend().then(()=>r.current?.focus())},children:s>0?a("codeConfirmation.resend_in",{defaultValue:`Resend code in ${s} s`,seconds:s}):a("codeConfirmation.resend",{defaultValue:"Resend code"})})]})}function ie({email:e,length:n,onSuccess:a,onChangeEmail:i}){const{t:r}=m("auth"),o=q({email:e,length:n,onSuccess:a});return c(h,{children:[t(A,{variant:"muted",children:r("codeConfirmation.intro",{defaultValue:`Enter the code sent to ${e}`,email:e})}),t(M,{confirmation:o}),i&&t(v,{type:"button",variant:w.LINK,onClick:i,children:r("codeConfirmation.change_email",{defaultValue:"Change address"})})]})}export{M as AuthCodeField,ie as AuthCodeStep,X as AuthConfirmPasswordField,ae as AuthConsentField,z as AuthEmailField,G as AuthForm,ne as AuthFormAlerts,J as AuthNameField,Q as AuthPasswordField,Z as AuthRememberMeField,te as AuthSubmitButton};