@donotdev/auth 0.1.0 → 0.1.42

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 (50) hide show
  1. package/LICENSE.md +21 -242
  2. package/README.md +0 -0
  3. package/dist/AuthStore.d.ts.map +1 -1
  4. package/dist/AuthStore.js +1 -1
  5. package/dist/authHelpers.js +1 -1
  6. package/dist/components/AccountLinking.js +1 -1
  7. package/dist/components/AuthFallback.js +1 -1
  8. package/dist/components/AuthPartnerButton.js +2 -2
  9. package/dist/components/DeleteAccountDialogs.js +1 -1
  10. package/dist/components/EmailLinkForm.js +1 -1
  11. package/dist/components/EmailPasswordForm.d.ts +11 -4
  12. package/dist/components/EmailPasswordForm.d.ts.map +1 -1
  13. package/dist/components/EmailPasswordForm.js +2 -1
  14. package/dist/components/EmailVerification.js +1 -1
  15. package/dist/components/Feature.js +1 -1
  16. package/dist/components/FeatureGuard.js +1 -1
  17. package/dist/components/FeaturePlaceholder.js +1 -1
  18. package/dist/components/GoogleOneTap.js +1 -1
  19. package/dist/components/LoginModal.js +1 -1
  20. package/dist/components/MultipleAuthProviders.js +1 -1
  21. package/dist/components/NetworkStatusIndicator.js +1 -1
  22. package/dist/components/PasswordResetCallback.d.ts +12 -0
  23. package/dist/components/PasswordResetCallback.d.ts.map +1 -0
  24. package/dist/components/PasswordResetCallback.js +2 -0
  25. package/dist/components/PasswordStrengthIndicator.js +1 -1
  26. package/dist/components/PasswordUpdateDialog.js +1 -1
  27. package/dist/components/RateLimitAlert.js +1 -1
  28. package/dist/components/index.d.ts +1 -0
  29. package/dist/components/index.d.ts.map +1 -1
  30. package/dist/components/index.js +1 -1
  31. package/dist/constants.d.ts +22 -0
  32. package/dist/constants.d.ts.map +1 -1
  33. package/dist/constants.js +1 -1
  34. package/dist/hooks/useAccountLinking.js +1 -1
  35. package/dist/hooks/useAuthMethodToggle.js +1 -1
  36. package/dist/hooks/useAuthPartner.js +1 -1
  37. package/dist/hooks/useDeleteAccount.js +1 -1
  38. package/dist/hooks/useEmailLinkAuth.js +1 -1
  39. package/dist/hooks/useEmailLinkForm.js +1 -1
  40. package/dist/hooks/useFedCM.js +1 -1
  41. package/dist/hooks/useGoogleOneTap.js +1 -1
  42. package/dist/hooks/useNetworkStatus.js +1 -1
  43. package/dist/index.d.ts +1 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/symbol-index.json +1 -0
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/dist/useAuth.d.ts.map +1 -1
  49. package/dist/useAuth.js +1 -1
  50. package/package.json +6 -6
@@ -1 +1 @@
1
- "use client";import{jsx as t,jsxs as r}from"react/jsx-runtime";import{Alert as s,Button as l,BUTTON_VARIANT as u,Stack as c}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";import{useNetworkStatus as d}from"../hooks/useNetworkStatus";function k({showWhenOnline:i=!1,className:a=""}){const{t:e}=f("auth"),{online:n,connectionType:o,isSlowConnection:w}=d();return n&&!i?null:t(s,{variant:n?void 0:"error",className:a,role:"status","aria-live":n?"polite":"assertive",title:n?e("networkStatus.online",{defaultValue:"You are online"}):e("networkStatus.offline",{defaultValue:"You are offline"}),description:n?t("span",{children:e("networkStatus.connectedVia",{connectionType:o||"unknown",defaultValue:`Connected via ${o||"unknown"}`})}):r(c,{children:[t("p",{children:e("networkStatus.offlineMessage",{defaultValue:"Authentication requires an internet connection. Please check your network settings."})}),t(l,{variant:u.GHOST,onClick:()=>{typeof window<"u"&&window.location.reload()},style:{fontSize:"var(--font-size-sm)",textDecoration:"underline",fontWeight:500},children:e("networkStatus.checkAgain",{defaultValue:"Check again"})})]})})}var T=k;export{T as default};
1
+ "use client";import{jsx as t,jsxs as r}from"react/jsx-runtime";import{Alert as s,Button as l,BUTTON_VARIANT as u,Stack as c}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";import{useNetworkStatus as d}from"../hooks/useNetworkStatus";function w({showWhenOnline:a=!1,className:i=""}){const{t:e}=f("auth"),{online:n,connectionType:o,isSlowConnection:h}=d();return n&&!a?null:t(s,{variant:n?void 0:"error",className:i,role:"status","aria-live":n?"polite":"assertive",title:n?e("networkStatus.online",{defaultValue:"You are online"}):e("networkStatus.offline",{defaultValue:"You are offline"}),description:n?t("span",{children:e("networkStatus.connectedVia",{connectionType:o||"unknown",defaultValue:`Connected via ${o||"unknown"}`})}):r(c,{children:[t("p",{children:e("networkStatus.offlineMessage",{defaultValue:"Authentication requires an internet connection. Please check your network settings."})}),t(l,{variant:u.GHOST,onClick:()=>{typeof window<"u"&&window.location.reload()},style:{fontSize:"var(--font-size-sm)",textDecoration:"underline",fontWeight:500},children:e("networkStatus.checkAgain",{defaultValue:"Check again"})})]})})}var k=w;export{k as default};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * PasswordResetCallback - Zero-config overlay
3
+ *
4
+ * Mount once at layout/provider level. Renders nothing until a password reset
5
+ * callback is detected (URL hash, store state, or query params).
6
+ * Then renders a full-screen Dialog with the appropriate UI.
7
+ *
8
+ * @component
9
+ * @version 0.2.0
10
+ */
11
+ export declare function PasswordResetCallback(): import("react/jsx-runtime").JSX.Element | null;
12
+ //# sourceMappingURL=PasswordResetCallback.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordResetCallback.d.ts","sourceRoot":"","sources":["../../src/components/PasswordResetCallback.tsx"],"names":[],"mappings":"AAoJA;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,mDAgXpC"}
@@ -0,0 +1,2 @@
1
+ "use client";import{jsx as s,jsxs as w}from"react/jsx-runtime";import{useCallback as L,useEffect as D,useState as h}from"react";import{useForm as B,Controller as N,useWatch as z}from"react-hook-form";import{Alert as R,ALERT_VARIANT as S,Button as C,BUTTON_VARIANT as x,Dialog as F,PasswordInput as O,Spinner as Z,Stack as m,Text as g}from"@donotdev/components";import{useTranslation as $}from"@donotdev/core";import{useAuth as f}from"../useAuth";import{useAuthStore as V}from"../AuthStore";import{PasswordStrengthIndicator as G}from"./PasswordStrengthIndicator";function H(){if(typeof window>"u")return{type:null};const r=window.location.hash.slice(1);if(r){const i=new URLSearchParams(r),l=i.get("error_code");if(l){const p={type:"supabase_error",errorCode:l,errorDescription:i.get("error_description")?.replace(/\+/g," ")||void 0};return window.history.replaceState(null,"",window.location.pathname+window.location.search),p}if(i.get("type")==="recovery")return window.history.replaceState(null,"",window.location.pathname+window.location.search),{type:"supabase_recovery"}}const n=new URLSearchParams(window.location.search),d=n.get("oobCode");return d&&n.get("mode")==="resetPassword"?{type:"firebase",oobCode:d}:{type:null}}async function X(r){try{const n=new TextEncoder().encode(r),d=await crypto.subtle.digest("SHA-1",n),i=Array.from(new Uint8Array(d)).map(o=>o.toString(16).padStart(2,"0")).join("").toUpperCase(),l=i.slice(0,5),p=i.slice(5),a=await fetch(`https://api.pwnedpasswords.com/range/${l}`,{headers:{"Add-Padding":"true"},credentials:"omit"});return a.ok?(await a.text()).split(`
2
+ `).some(o=>{const[c]=o.split(":");return c?.trim()===p}):!1}catch{return!1}}function J(){const{t:r}=$("auth"),n=f("passwordResetPending"),d=f("verifyPasswordResetCode"),i=f("confirmPasswordReset"),l=f("updatePassword"),p=f("signInWithEmail"),[a,o]=h("idle"),[c,A]=h(null),[v,_]=h(null),[k,W]=h(!1),[U,q]=h(null),{control:y,handleSubmit:M,getValues:Y,formState:{errors:t,isSubmitting:P},setError:E}=B({mode:"onChange",defaultValues:{password:"",confirmPassword:""}}),I=z({control:y,name:"password"});D(()=>{if(a!=="idle")return;const e=H();if(e.type==="supabase_error"){e.errorCode==="otp_expired"?o("expired"):(q(e.errorDescription||null),o("invalid"));return}if(e.type==="firebase"&&e.oobCode){W(!0),_(e.oobCode),o("loading"),d(e.oobCode).then(u=>{u?(A(u),o("ready")):o("expired")});return}n&&o("ready")},[n,a,d]);const j=L(async e=>{try{if(k&&v){if(await i(v,e.password),c)try{await p(c,e.password)}catch{}}else await l(e.password),V.getState().setPasswordResetPending(!1);o("idle")}catch(u){const T=u instanceof Error?u.message:String(u);T.includes("expired")||T.includes("EXPIRED")?o("expired"):E("root",{message:r("resetPassword.error","Failed to reset password. Please try again.")})}},[k,v,c,i,l,p,E,r]),b=L(()=>{o("idle"),A(null),_(null),q(null),V.getState().setPasswordResetPending(!1),typeof window<"u"&&window.history.replaceState(null,"",window.location.pathname)},[]);return a==="idle"?null:w(F,{open:!0,onOpenChange:e=>{e||b()},style:{maxWidth:"min(28rem, 90vw)"},title:a==="success"?r("resetPassword.success_title","Password updated"):a==="expired"||a==="invalid"?r("resetPassword.expired_title","Link expired"):a==="loading"?r("resetPassword.verifying","Verifying..."):r("resetPassword.title","Set new password"),showClose:!0,children:[a==="loading"&&w(m,{align:"center",justify:"center",children:[s(Z,{}),s(g,{level:"body",variant:"muted",children:r("resetPassword.verifying","Verifying reset link...")})]}),(a==="expired"||a==="invalid")&&w(m,{children:[s(R,{variant:S.WARNING,description:a==="expired"?r("resetPassword.expired_description","This password reset link has expired. Please request a new one."):U||r("resetPassword.invalid_description","This password reset link is invalid. Please request a new one.")}),s(C,{variant:x.PRIMARY,onClick:b,fullWidth:!0,children:r("resetPassword.back_to_signin","Back to Sign In")})]}),a==="success"&&w(m,{children:[s(R,{variant:S.SUCCESS,description:r("resetPassword.success_description","Your password has been reset successfully. You are now signed in.")}),s(C,{variant:x.PRIMARY,onClick:b,fullWidth:!0,children:r("resetPassword.continue","Continue")})]}),a==="ready"&&s("form",{onSubmit:M(j),noValidate:!0,children:w(m,{children:[c&&s(g,{level:"small",variant:"muted",children:r("resetPassword.for_email",`Enter a new password for ${c}`)}),t.root&&s(R,{variant:S.ERROR,description:t.root.message}),s(N,{name:"password",control:y,rules:{required:r("passwordRequired","Password is required"),minLength:{value:8,message:r("passwordMinLength","Password must be at least 8 characters")},validate:{uppercase:e=>!e||/[A-Z]/.test(e)||r("passwordRequirement.uppercase","One uppercase letter"),lowercase:e=>!e||/[a-z]/.test(e)||r("passwordRequirement.lowercase","One lowercase letter"),number:e=>!e||/[0-9]/.test(e)||r("passwordRequirement.number","One number"),special:e=>!e||/[^a-zA-Z0-9]/.test(e)||r("passwordRequirement.special","One special character"),breached:async e=>!e||e.length<8?!0:!await X(e)||r("errors.breached_password","This password has appeared in a data breach.")}},render:({field:e})=>w(m,{gap:"tight",children:[s(O,{...e,label:r("resetPassword.new_password","New password"),placeholder:r("passwordPlaceholder","Enter your password"),autoComplete:"new-password",disabled:P,"aria-invalid":!!t.password,"aria-describedby":t.password?"reset-password-error":void 0,className:"dndev-w-full","data-variant":t.password?"destructive":void 0}),t.password&&s(g,{as:"span",level:"caption",variant:"destructive",id:"reset-password-error",role:"alert",children:t.password.message})]})}),s(N,{name:"confirmPassword",control:y,rules:{required:r("confirmPasswordRequired","Please confirm your password"),validate:e=>e===Y("password")||r("confirmPasswordMismatch","Passwords do not match")},render:({field:e})=>w(m,{gap:"tight",children:[s(O,{...e,label:r("confirmPassword","Confirm password"),placeholder:r("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:P,"aria-invalid":!!t.confirmPassword,"aria-describedby":t.confirmPassword?"reset-confirm-error":void 0,className:"dndev-w-full","data-variant":t.confirmPassword?"destructive":void 0}),t.confirmPassword&&s(g,{as:"span",level:"caption",variant:"destructive",id:"reset-confirm-error",role:"alert",children:t.confirmPassword.message})]})}),I&&s(G,{password:I,minLength:8,showRequirements:!0}),s(C,{type:"submit",variant:x.PRIMARY,disabled:P,fullWidth:!0,children:P?r("loading","Loading..."):r("resetPassword.submit","Reset Password")})]})})]})}export{J as PasswordResetCallback};
@@ -1 +1 @@
1
- "use client";import{jsxs as n,jsx as s}from"react/jsx-runtime";import{Check as v,Circle as w}from"lucide-react";import{useMemo as g}from"react";import{Progress as b,Stack as i,Text as l,cn as k}from"@donotdev/components";import{useTranslation as S}from"@donotdev/core";function q(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 x(e,t,a){return[{label:a("passwordRequirement.length",`At least ${t} characters`),met:e.length>=t},{label:a("passwordRequirement.uppercase","One uppercase letter"),met:/[A-Z]/.test(e)},{label:a("passwordRequirement.lowercase","One lowercase letter"),met:/[a-z]/.test(e)},{label:a("passwordRequirement.number","One number"),met:/[0-9]/.test(e)},{label:a("passwordRequirement.special","One special character (!@#$%^&*)"),met:/[^a-zA-Z0-9]/.test(e)}]}const P={weak:25,fair:50,good:75,strong:100},u={weak:"destructive",fair:"warning",good:"accent",strong:"success"};function O({password:e,minLength:t=8,showRequirements:a=!0,className:m}){const{t:r}=S("auth"),c=g(()=>q(e),[e]),h=g(()=>x(e,t,(d,f)=>r(d,f||"")),[e,t,r]),p={weak:r("passwordStrength.weak","Weak"),fair:r("passwordStrength.fair","Fair"),good:r("passwordStrength.good","Good"),strong:r("passwordStrength.strong","Strong")};return n(i,{gap:"tight",className:k("dndev-password-strength",m),children:[n(i,{gap:"tight",children:[n(i,{direction:"row",align:"center",justify:"between",gap:"tight",children:[n(l,{as:"span",level:"caption",variant:"muted",children:[r("passwordStrength.label","Password strength"),":"]}),s(l,{as:"strong",level:"caption",variant:u[c],children:p[c]})]}),s(b,{value:P[c],variant:u[c],className:"dndev-password-strength-bar"})]}),a&&n(i,{gap:"tight",className:"dndev-password-requirements",children:[n(l,{as:"strong",level:"caption",variant:"muted",children:[r("passwordRequirements","Password requirements"),":"]}),s(i,{gap:"tight","data-inset":"true",children:h.map((o,d)=>n(i,{direction:"row",align:"center",gap:"tight",className:"dndev-password-requirement-item",children:[o.met?s(v,{className:"dndev-size-xs","data-variant":"success"}):s(w,{className:"dndev-size-xs","data-variant":"muted"}),s(l,{as:"span",level:"caption",variant:o.met?"success":"muted","data-opacity":o.met?void 0:"70",children:o.label})]},d))})]})]})}export{O as PasswordStrengthIndicator};
1
+ "use client";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Check as w,Circle as v}from"lucide-react";import{useMemo as m}from"react";import{Progress as f,Stack as o,Text as l,cn as b}from"@donotdev/components";import{useTranslation as q}from"@donotdev/core";function k(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 S(e,t,a){return[{label:a("passwordRequirement.length",`At least ${t} characters`),met:e.length>=t},{label:a("passwordRequirement.uppercase","One uppercase letter"),met:/[A-Z]/.test(e)},{label:a("passwordRequirement.lowercase","One lowercase letter"),met:/[a-z]/.test(e)},{label:a("passwordRequirement.number","One number"),met:/[0-9]/.test(e)},{label:a("passwordRequirement.special","One special character (!@#$%^&*)"),met:/[^a-zA-Z0-9]/.test(e)}]}const x={weak:25,fair:50,good:75,strong:100},g={weak:"destructive",fair:"warning",good:"accent",strong:"success"};function N({password:e,minLength:t=8,showRequirements:a=!0,className:p}){const{t:s}=q("auth"),d=m(()=>k(e),[e]),u=m(()=>S(e,t,(n,c)=>s(n,c||"")),[e,t,s]),h={weak:s("passwordStrength.weak","Weak"),fair:s("passwordStrength.fair","Fair"),good:s("passwordStrength.good","Good"),strong:s("passwordStrength.strong","Strong")};return r(o,{gap:"tight",className:b("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:[s("passwordStrength.label","Password strength"),":"]}),i(l,{as:"strong",level:"caption",variant:g[d],children:h[d]})]}),i(f,{value:x[d],variant:g[d],className:"dndev-password-strength-bar"})]}),a&&r(o,{gap:"tight",className:"dndev-password-requirements",children:[r(l,{as:"strong",level:"caption",variant:"muted",children:[s("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(w,{className:"dndev-size-xs","data-variant":"success"}):i(v,{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{N as PasswordStrengthIndicator};
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as i,Fragment as P}from"react/jsx-runtime";import{useState as C}from"react";import{useForm as S,Controller as T,useWatch as E}from"react-hook-form";import{Alert as N,ALERT_VARIANT as x,Button as d,BUTTON_VARIANT as u,Dialog as A,PasswordInput as I,Stack as g,Text as L}from"@donotdev/components";import{useTranslation as O}from"@donotdev/core";import{PasswordStrengthIndicator as R}from"./PasswordStrengthIndicator";function U({updatePassword:m}){const{t:r}=O("profile"),[f,n]=C(!1),{control:l,handleSubmit:h,formState:{errors:s,isSubmitting:o},setError:y,reset:p}=S({mode:"onChange",defaultValues:{password:""}}),c=E({control:l,name:"password"}),b=async a=>{try{await m(a.password),n(!1),p()}catch(t){const v=t instanceof Error?t.message:String(t);y("root",{message:v||r("profile.security.password.dialog.error","Failed to update password")})}},w=a=>{n(a),a||p()};return e(A,{open:f,onOpenChange:w,trigger:e(d,{variant:u.OUTLINE,children:r("profile.security.password.change","Change Password")}),title:r("profile.security.password.dialog.title","Change Password"),description:r("profile.security.password.dialog.description","Enter your new password below"),footer:i(P,{children:[e(d,{variant:u.OUTLINE,onClick:()=>w(!1),disabled:o,children:r("profile.security.password.dialog.cancel","Cancel")}),e(d,{onClick:h(b),disabled:o||!c,children:o?r("profile.security.password.dialog.updating","Updating..."):r("profile.security.password.dialog.update","Update Password")})]}),children:i(g,{children:[s.root&&e(N,{variant:x.ERROR,description:s.root.message}),e(T,{name:"password",control:l,rules:{required:r("profile.security.password.dialog.required","Password is required"),minLength:{value:8,message:r("profile.security.password.dialog.minLength","Password must be at least 8 characters")}},render:({field:a})=>i(g,{gap:"tight",children:[e(I,{...a,label:r("profile.security.password.dialog.newPassword","New Password"),placeholder:r("profile.security.password.dialog.placeholder","Enter new password"),disabled:o,"aria-invalid":!!s.password,"aria-describedby":s.password?"password-update-error":void 0,className:"dndev-w-full","data-variant":s.password?"destructive":void 0}),s.password&&e(L,{as:"span",level:"caption",variant:"destructive",id:"password-update-error",role:"alert",children:s.password.message})]})}),e(R,{password:c||"",minLength:8})]})})}var q=U;export{q as default};
1
+ "use client";import{jsx as s,jsxs as t,Fragment as P}from"react/jsx-runtime";import{useState as T}from"react";import{useForm as C,Controller as E,useWatch as N}from"react-hook-form";import{Alert as S,ALERT_VARIANT as A,Button as d,BUTTON_VARIANT as u,Dialog as I,PasswordInput as L,Stack as g,Text as R}from"@donotdev/components";import{useTranslation as O}from"@donotdev/core";import{PasswordStrengthIndicator as U}from"./PasswordStrengthIndicator";function x({updatePassword:m}){const{t:r}=O("profile"),[f,l]=T(!1),{control:n,handleSubmit:h,formState:{errors:a,isSubmitting:o},setError:y,reset:p}=C({mode:"onChange",defaultValues:{password:""}}),c=N({control:n,name:"password"}),v=async e=>{try{await m(e.password),l(!1),p()}catch(i){const b=i instanceof Error?i.message:String(i);y("root",{message:b||r("profile.security.password.dialog.error","Failed to update password")})}},w=e=>{l(e),e||p()};return s(I,{open:f,onOpenChange:w,trigger:s(d,{variant:u.OUTLINE,children:r("profile.security.password.change","Change Password")}),title:r("profile.security.password.dialog.title","Change Password"),description:r("profile.security.password.dialog.description","Enter your new password below"),footer:t(P,{children:[s(d,{variant:u.OUTLINE,onClick:()=>w(!1),disabled:o,children:r("profile.security.password.dialog.cancel","Cancel")}),s(d,{onClick:h(v),disabled:o||!c,children:o?r("profile.security.password.dialog.updating","Updating..."):r("profile.security.password.dialog.update","Update Password")})]}),children:t(g,{children:[a.root&&s(S,{variant:A.ERROR,description:a.root.message}),s(E,{name:"password",control:n,rules:{required:r("profile.security.password.dialog.required","Password is required"),minLength:{value:8,message:r("profile.security.password.dialog.minLength","Password must be at least 8 characters")}},render:({field:e})=>t(g,{gap:"tight",children:[s(L,{...e,label:r("profile.security.password.dialog.newPassword","New Password"),placeholder:r("profile.security.password.dialog.placeholder","Enter new password"),disabled:o,"aria-invalid":!!a.password,"aria-describedby":a.password?"password-update-error":void 0,className:"dndev-w-full","data-variant":a.password?"destructive":void 0}),a.password&&s(R,{as:"span",level:"caption",variant:"destructive",id:"password-update-error",role:"alert",children:a.password.message})]})}),s(U,{password:c||"",minLength:8})]})})}var q=x;export{q as default};
@@ -1 +1 @@
1
- "use client";import{useTranslation as t}from"@donotdev/core";const e=({identifier:i,className:n=""})=>{const{t:r}=t("auth");return null};var l=e;export{l as default};
1
+ "use client";import{useTranslation as t}from"@donotdev/core";const e=({identifier:n,className:r=""})=>{const{t:s}=t("auth");return null};var a=e;export{a as default};
@@ -18,6 +18,7 @@ export { default as LoginModal } from './LoginModal';
18
18
  export { default as MultipleAuthProviders } from './MultipleAuthProviders';
19
19
  export { default as NetworkStatusIndicator } from './NetworkStatusIndicator';
20
20
  export { default as PasswordUpdateDialog } from './PasswordUpdateDialog';
21
+ export { PasswordResetCallback } from './PasswordResetCallback';
21
22
  export { PasswordStrengthIndicator } from './PasswordStrengthIndicator';
22
23
  export { default as RateLimitAlert } from './RateLimitAlert';
23
24
  export * from './DeleteAccountDialogs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,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AyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,cAAc,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- export*from"./AuthFallback";import{default as e}from"./EmailPasswordForm";import{default as f}from"./AuthPartnerButton";import{default as p}from"./EmailVerification";export*from"./Feature";export*from"./FeatureGuard";export*from"./FeaturePlaceholder";import{default as u}from"./GoogleOneTap";import{default as n}from"./LoginModal";import{default as g}from"./MultipleAuthProviders";import{default as c}from"./NetworkStatusIndicator";import{default as A}from"./PasswordUpdateDialog";import{PasswordStrengthIndicator as I}from"./PasswordStrengthIndicator";import{default as M}from"./RateLimitAlert";export*from"./DeleteAccountDialogs";export{f as AuthPartnerButton,e as EmailPasswordForm,p as EmailVerification,u as GoogleOneTap,n as LoginModal,g as MultipleAuthProviders,c as NetworkStatusIndicator,I as PasswordStrengthIndicator,A as PasswordUpdateDialog,M as RateLimitAlert};
1
+ export*from"./AuthFallback";import{default as a}from"./EmailPasswordForm";import{default as o}from"./AuthPartnerButton";import{default as r}from"./EmailVerification";export*from"./Feature";export*from"./FeatureGuard";export*from"./FeaturePlaceholder";import{default as t}from"./GoogleOneTap";import{default as s}from"./LoginModal";import{default as e}from"./MultipleAuthProviders";import{default as m}from"./NetworkStatusIndicator";import{default as f}from"./PasswordUpdateDialog";import{PasswordResetCallback as i}from"./PasswordResetCallback";import{PasswordStrengthIndicator as d}from"./PasswordStrengthIndicator";import{default as l}from"./RateLimitAlert";export*from"./DeleteAccountDialogs";export{o as AuthPartnerButton,a as EmailPasswordForm,r as EmailVerification,t as GoogleOneTap,s as LoginModal,e as MultipleAuthProviders,m as NetworkStatusIndicator,i as PasswordResetCallback,d as PasswordStrengthIndicator,f as PasswordUpdateDialog,l as RateLimitAlert};
@@ -127,6 +127,28 @@ export interface EmailPasswordFormProps extends BaseComponentProps, AuthCallback
127
127
  /** Form mode - defaults to 'signin' */
128
128
  mode?: FormMode;
129
129
  compact?: boolean;
130
+ /**
131
+ * Terms of Service path or content (signup only - GDPR/French law).
132
+ * - Omit: auto-detects from app config legalLinks, falls back to '/legal/terms'
133
+ * - `string`: path opened in popup window
134
+ * - `ReactNode`: rendered inline in a Dialog modal
135
+ * - `false`: explicitly disable ToS requirement
136
+ */
137
+ tos?: string | React.ReactNode | false;
138
+ /**
139
+ * Privacy Policy path or content (signup only - GDPR/French law).
140
+ * - Omit: auto-detects from app config legalLinks, falls back to '/legal/privacy'
141
+ * - `string`: path opened in popup window
142
+ * - `ReactNode`: rendered inline in a Dialog modal
143
+ * - `false`: explicitly disable Privacy requirement
144
+ */
145
+ privacy?: string | React.ReactNode | false;
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.
150
+ */
151
+ captchaToken?: string;
130
152
  }
131
153
  /**
132
154
  * 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;AA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AED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,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"}
package/dist/constants.js CHANGED
@@ -1 +1 @@
1
- import{getAuthMethod as E,EMAIL_VERIFICATION_STATUS as o}from"@donotdev/core";import{AUTH_PARTNER_STATE as R}from"@donotdev/core";export{o as EMAIL_VERIFICATION_STATUS,R as PARTNER_STATE,E as getAuthMethod};
1
+ import{getAuthMethod as A,EMAIL_VERIFICATION_STATUS as T}from"@donotdev/core";import{AUTH_PARTNER_STATE as t}from"@donotdev/core";export{T as EMAIL_VERIFICATION_STATUS,t as PARTNER_STATE,A as getAuthMethod};
@@ -1 +1 @@
1
- "use client";import{useState as h,useEffect as v,useCallback as a}from"react";import{safeSessionStorage as e,handleError as I,isClient as t,isDev as r}from"@donotdev/core";import{getAuthMethod as L}from"../constants";import{useAuth as l}from"../useAuth";function S(){const o=l("signInWithPartner"),s=l("user"),[i,c]=h(null);v(()=>{if(t()){try{const n=e.getItem("accountLinkingInfo");if(n){const u=JSON.parse(n);c(u)}}catch{r()}return()=>{if(!t())return;const n=e.getItem("accountLinkingInfo");if(n)try{JSON.parse(n).isRequired||e.removeItem("accountLinkingInfo")}catch{}}}},[s]);const g=a(async()=>{if(!(!i||!i.isRequired))try{const{existingProvider:n}=i;if(n==="password"||n==="emailLink"){r();return}r(),await o(n,L())}catch(n){I(n)}},[i,o]),f=a(()=>{t()&&(e.removeItem("accountLinkingInfo"),c(null))},[]),d=i?.isRequired||!1,m=i?.email||null,k=i?.existingProvider||null,p=i?.newProvider||null;return{accountLinking:i,isRequired:d,email:m,existingProvider:k,newProvider:p,handleSignInWithExistingProvider:g,clearAccountLinking:f}}export{S as useAccountLinking};
1
+ "use client";import{useState as k,useEffect as v,useCallback as a}from"react";import{safeSessionStorage as e,handleError as p,isClient as t,isDev as r}from"@donotdev/core";import{getAuthMethod as L}from"../constants";import{useAuth as c}from"../useAuth";function P(){const s=c("signInWithPartner"),u=c("user"),[i,o]=k(null);v(()=>{if(t()){try{const n=e.getItem("accountLinkingInfo");if(n){const I=JSON.parse(n);o(I)}}catch{r()}return()=>{if(!t())return;const n=e.getItem("accountLinkingInfo");if(n)try{JSON.parse(n).isRequired||e.removeItem("accountLinkingInfo")}catch{}}}},[u]);const l=a(async()=>{if(!(!i||!i.isRequired))try{const{existingProvider:n}=i;if(n==="password"||n==="emailLink"){r();return}r(),await s(n,L())}catch(n){p(n)}},[i,s]),f=a(()=>{t()&&(e.removeItem("accountLinkingInfo"),o(null))},[]),g=i?.isRequired||!1,m=i?.email||null,d=i?.existingProvider||null,h=i?.newProvider||null;return{accountLinking:i,isRequired:g,email:m,existingProvider:d,newProvider:h,handleSignInWithExistingProvider:l,clearAccountLinking:f}}export{P as useAccountLinking};
@@ -1 +1 @@
1
- "use client";import{useState as h,useCallback as t}from"react";function g({defaultValue:c="popup"}={}){const[o,e]=h(c),r=o==="redirect",d=o==="popup",s=t(()=>{e(p=>p==="redirect"?"popup":"redirect")},[]),u=t(()=>{e("redirect")},[]),n=t(()=>{e("popup")},[]),i=t(p=>{e(p?"redirect":"popup")},[]);return{isRedirectMode:r,isPopupMode:d,authMethod:o,toggleMode:s,setRedirectMode:u,setPopupMode:n,handleToggleChange:i}}export{g as useAuthMethodToggle};
1
+ "use client";import{useState as l,useCallback as t}from"react";function g({defaultValue:r="popup"}={}){const[o,e]=l(r),u=o==="redirect",d=o==="popup",i=t(()=>{e(p=>p==="redirect"?"popup":"redirect")},[]),s=t(()=>{e("redirect")},[]),a=t(()=>{e("popup")},[]),c=t(p=>{e(p?"redirect":"popup")},[]);return{isRedirectMode:u,isPopupMode:d,authMethod:o,toggleMode:i,setRedirectMode:s,setPopupMode:a,handleToggleChange:c}}export{g as useAuthMethodToggle};
@@ -1 +1 @@
1
- "use client";import{useCallback as e}from"react";import"../constants";import{useAuth as s}from"../useAuth";function x(t,h={}){const f=s("getPartnerState"),r=s("setPartnerState"),g=s("signInWithPartner"),i=s("partnerError"),{onSuccess:c,onError:a}=h,l=f(t),P=l==="authenticated",S=l==="loading",n=i?.partnerId===t,m=n&&i?.error?new Error(i.error):null,u=e(()=>{n&&r(t,"idle")},[n,t,r]),E=e(()=>{r(t,"loading")},[t,r]),A=e(()=>{r(t,"idle")},[t,r]),w=e(async y=>{n&&u();try{r(t,"loading");const o=await g(t,y);if(o===null){r(t,"idle");return}o&&c&&c(o)}catch(o){r(t,"error",o),a&&a(o)}},[t,n,u,r,g,c,a]);return{partnerState:l,isAuthenticated:P,isAuthenticating:S,hasError:n,error:m,handleSignIn:w,clearError:u,setLoading:E,setIdle:A}}export{x as useAuthPartner};
1
+ "use client";import{useCallback as t}from"react";import"../constants";import{useAuth as o}from"../useAuth";function I(r,g={}){const h=o("getPartnerState"),e=o("setPartnerState"),d=o("signInWithPartner"),i=o("partnerError"),{onSuccess:s,onError:l}=g,u=h(r),p=u==="authenticated",m=u==="loading",n=i?.partnerId===r,E=n&&i?.error?new Error(i.error):null,c=t(()=>{n&&e(r,"idle")},[n,r,e]),S=t(()=>{e(r,"loading")},[r,e]),f=t(()=>{e(r,"idle")},[r,e]),A=t(async P=>{n&&c();try{e(r,"loading");const a=await d(r,P);if(a===null){e(r,"idle");return}a&&s&&s(a)}catch(a){e(r,"error",a),l&&l(a)}},[r,n,c,e,d,s,l]);return{partnerState:u,isAuthenticated:p,isAuthenticating:m,hasError:n,error:E,handleSignIn:A,clearError:c,setLoading:S,setIdle:f}}export{I as useAuthPartner};
@@ -1 +1 @@
1
- "use client";import{useState as l}from"react";import{useAuth as m}from"../useAuth";function E(){const r=m("deleteAccount"),[c,e]=l(!1),[f,s]=l(!1),[i,a]=l(!1),[u,t]=l(null);return{showConfirmDialog:c,showPasswordDialog:f,isDeleting:i,error:u,startDeleteFlow:()=>{t(null),e(!0)},confirmDelete:async D=>{a(!0),t(null);try{await r(D),e(!1),s(!1)}catch(n){const o=n.message||n.message;o==="REQUIRES_PASSWORD"?(e(!1),s(!0)):o==="REAUTH_CANCELLED"?(e(!1),s(!1)):t(o||"Failed to delete account")}finally{a(!1)}},cancel:()=>{e(!1),s(!1),t(null)}}}export{E as useDeleteAccount};
1
+ "use client";import{useState as o}from"react";import{useAuth as f}from"../useAuth";function A(){const c=f("deleteAccount"),[r,e]=o(!1),[u,t]=o(!1),[i,n]=o(!1),[m,l]=o(null);return{showConfirmDialog:r,showPasswordDialog:u,isDeleting:i,error:m,startDeleteFlow:()=>{l(null),e(!0)},confirmDelete:async D=>{n(!0),l(null);try{await c(D),e(!1),t(!1)}catch(a){const s=a.message||a.message;s==="REQUIRES_PASSWORD"?(e(!1),t(!0)):s==="REAUTH_CANCELLED"?(e(!1),t(!1)):l(s||"Failed to delete account")}finally{n(!1)}},cancel:()=>{e(!1),t(!1),l(null)}}}export{A as useDeleteAccount};
@@ -1 +1 @@
1
- "use client";import{useEffect as g,useState as l,useCallback as E}from"react";import{handleError as k,isDev as o}from"@donotdev/core";import{useAuth as r}from"../useAuth";function p(){const a=r("isSignInWithEmailLink"),n=r("signInWithEmailLink"),[m,e]=l(!1),[c,t]=l(null),u=a();g(()=>{if(typeof window<"u"){const i=localStorage.getItem("emailForSignIn");i&&t(i)}},[]);const f=E(async i=>{if(!i){o();return}e(!0);try{o(),(await n(i))?.success&&(localStorage.removeItem("emailForSignIn"),t(null))}catch(s){k(s)}finally{e(!1)}},[n]);return{isEmailLink:u,isProcessing:m,email:c,completeEmailLinkSignIn:f}}export{p as useEmailLinkAuth};
1
+ "use client";import{useEffect as g,useState as t,useCallback as E}from"react";import{handleError as k,isDev as s}from"@donotdev/core";import{useAuth as l}from"../useAuth";function p(){const o=l("isSignInWithEmailLink"),n=l("signInWithEmailLink"),[r,e]=t(!1),[m,a]=t(null),c=o();g(()=>{if(typeof window<"u"){const i=localStorage.getItem("emailForSignIn");i&&a(i)}},[]);const u=E(async i=>{if(!i){s();return}e(!0);try{s(),(await n(i))?.success&&(localStorage.removeItem("emailForSignIn"),a(null))}catch(f){k(f)}finally{e(!1)}},[n]);return{isEmailLink:c,isProcessing:r,email:m,completeEmailLinkSignIn:u}}export{p as useEmailLinkAuth};
@@ -1 +1 @@
1
- "use client";import{useState as i,useCallback as r}from"react";import{handleError as w}from"@donotdev/core";import{useAuth as f}from"../useAuth";function T(g={}){const o=f("sendSignInLinkToEmail"),S=f("isAvailable"),{onSuccess:a,onError:l,actionCodeSettings:c}=g,[e,E]=i(""),[d,m]=i(!1),[h,u]=i(!1),[k,n]=i(null),s=e.trim().length>0&&e.includes("@"),p=s&&!d&&S,I=r(()=>{n(null)},[]),L=r(async v=>{if(v.preventDefault(),!s){n("Please enter a valid email address");return}m(!0),n(null);try{typeof window<"u"&&localStorage.setItem("emailForSignIn",e.trim()),await o(e.trim(),c),u(!0),a?.()}catch(t){const y=t instanceof Error?t.message:"Failed to send sign-in link";n(y),l?.(t),w(t)}finally{m(!1)}},[e,s,o,c,a,l]),b=r(()=>{u(!1),n(null)},[]);return{email:e,setEmail:E,isLoading:d,isSent:h,error:k,handleSendLink:L,handleResend:b,clearError:I,isValid:s,canSubmit:p}}export{T as useEmailLinkForm};
1
+ "use client";import{useState as r,useCallback as l}from"react";import{handleError as v}from"@donotdev/core";import{useAuth as f}from"../useAuth";function F(S={}){const t=f("sendSignInLinkToEmail"),g=f("isAvailable"),{onSuccess:s,onError:o,actionCodeSettings:m}=S,[e,E]=r(""),[u,c]=r(!1),[h,d]=r(!1),[p,n]=r(null),i=e.trim().length>0&&e.includes("@"),k=i&&!u&&g,y=l(()=>{n(null)},[]),L=l(async w=>{if(w.preventDefault(),!i){n("Please enter a valid email address");return}c(!0),n(null);try{typeof window<"u"&&localStorage.setItem("emailForSignIn",e.trim()),await t(e.trim(),m),d(!0),s?.()}catch(a){const I=a instanceof Error?a.message:"Failed to send sign-in link";n(I),o?.(a),v(a)}finally{c(!1)}},[e,i,t,m,s,o]),b=l(()=>{d(!1),n(null)},[]);return{email:e,setEmail:E,isLoading:u,isSent:h,error:p,handleSendLink:L,handleResend:b,clearError:y,isValid:i,canSubmit:k}}export{F as useEmailLinkForm};
@@ -1 +1 @@
1
- "use client";import{useState as i,useEffect as y,useMemo as E,useRef as S}from"react";import{handleError as I,isClient as l}from"@donotdev/core";function F({checkGoogleServices:a=!0,onError:d}={}){const[n,p]=i(!1),[m,u]=i(!1),[f,g]=i(null),c=S(d);c.current=d,y(()=>{if(!l())return;(async()=>{try{const t="IdentityCredential"in window;let e=!0;if(a){const h=new Promise(s=>setTimeout(s,2e3));await Promise.race([new Promise(s=>{const C=setInterval(()=>{window.google?.accounts?.id&&(clearInterval(C),s(!0))},100)}),h]),e=!!window.google?.accounts?.id}p(t&&e),u(!0)}catch(t){const e=I(t,{userMessage:"Failed to detect FedCM support",context:{operation:"fedcm_detection"},severity:"warning"});g(e),u(!0),c.current?.(e)}})()},[a]);const w=E(()=>{if(!l())return{name:"Unknown",isSupported:!1,recommendation:"Loading..."};const r=navigator.userAgent;let t="Unknown",e="Please update your browser";if(r.includes("Chrome/")){const o=parseInt(r.match(/Chrome\/(\d+)/)?.[1]||"0");t=`Chrome ${o}`,e=o>=116?"Supported":"Please update to Chrome 116 or later"}else if(r.includes("Edg/")){const o=parseInt(r.match(/Edg\/(\d+)/)?.[1]||"0");t=`Edge ${o}`,e=o>=116?"Supported":"Please update to Edge 116 or later"}else r.includes("Safari/")&&!r.includes("Chrome")?(t="Safari",e="Not supported yet. Please use Chrome or Edge"):r.includes("Firefox/")&&(t="Firefox",e="Not supported yet. Please use Chrome or Edge");return{name:t,isSupported:n,recommendation:e}},[n]);return{isSupported:n,isReady:m,error:f,browserInfo:w}}export{F as useFedCM};
1
+ "use client";import{useState as s,useEffect as h,useMemo as C,useRef as E}from"react";import{handleError as S,isClient as u}from"@donotdev/core";function y({checkGoogleServices:a=!0,onError:i}={}){const[n,l]=s(!1),[m,c]=s(!1),[p,f]=s(null),d=E(i);d.current=i,h(()=>{u()&&(async()=>{try{const e="IdentityCredential"in window;let o=!0;if(a){const r=new Promise(t=>setTimeout(t,2e3));await Promise.race([new Promise(t=>{const w=setInterval(()=>{window.google?.accounts?.id&&(clearInterval(w),t(!0))},100)}),r]),o=!!window.google?.accounts?.id}l(e&&o),c(!0)}catch(e){const o=S(e,{userMessage:"Failed to detect FedCM support",context:{operation:"fedcm_detection"},severity:"warning"});f(o),c(!0),d.current?.(o)}})()},[a]);const g=C(()=>{if(!u())return{name:"Unknown",isSupported:!1,recommendation:"Loading..."};const e=navigator.userAgent;let o="Unknown",r="Please update your browser";if(e.includes("Chrome/")){const t=parseInt(e.match(/Chrome\/(\d+)/)?.[1]||"0");o=`Chrome ${t}`,r=t>=116?"Supported":"Please update to Chrome 116 or later"}else if(e.includes("Edg/")){const t=parseInt(e.match(/Edg\/(\d+)/)?.[1]||"0");o=`Edge ${t}`,r=t>=116?"Supported":"Please update to Edge 116 or later"}else e.includes("Safari/")&&!e.includes("Chrome")?(o="Safari",r="Not supported yet. Please use Chrome or Edge"):e.includes("Firefox/")&&(o="Firefox",r="Not supported yet. Please use Chrome or Edge");return{name:o,isSupported:n,recommendation:r}},[n]);return{isSupported:n,isReady:m,error:p,browserInfo:g}}export{y as useFedCM};
@@ -1 +1 @@
1
- "use client";import{useState as b,useEffect as k,useRef as _,useCallback as K,startTransition as y,useMemo as j}from"react";import{useIsDark as re}from"@donotdev/components";import{handleError as p,getOAuthClientId as oe,getEnabledAuthPartners as ne,isClient as ie,useTranslation as se,useScriptLoader as ae}from"@donotdev/core";import{useAuth as B}from"../useAuth";import{useFedCM as ce}from"./useFedCM";function me({clientId:J,autoSelect:v=!0,cancelOnTapOutside:x=!0,promptParentId:T,disabled:u=!1,onSuccess:O,onError:s,allowedParentOrigins:z,cspNonce:S,clientOnly:A=!1}={}){const{t:o}=se("auth"),E=B("user"),N=B("signInWithGoogleCredential"),L=re(),a=J||oe("google"),I=ne().includes("google"),{isSupported:r,isReady:d,error:U,browserInfo:Q}=ce({checkGoogleServices:!0,onError:e=>{const l=p(e,{userMessage:o("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});s?.(l)}}),{isLoading:V,isLoaded:D,error:F,isReady:P,load:X,loadTriggered:Z}=ae("https://accounts.google.com/gsi/client",{enabled:I&&!!a&&!u&&d&&r,nonce:S,checkExisting:!0,isLoaded:()=>!!window.google?.accounts?.id,onError:e=>{const l=p(e,{userMessage:o("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});s?.(l)}}),[M,$]=b(!1),[W,q]=b(null),ee=_(null),i=_(!1),c=_(null),C=_(0),[H,f]=b(!1),m="gsi_hide_until",h=600*1e3,G=j(()=>I&&!!a&&!u&&!E&&r&&(A?M:!0)&&!H,[I,a,u,E,r,A,M,H]),te=j(()=>!r&&d?new Error(o("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):F||U||W,[F,U,W,r,d,o]),w=K(async e=>{try{if(!e||typeof e!="string")throw new Error("Invalid credential format");await N(e),y(()=>{O?.(e)})}catch(l){const n=p(l,{userMessage:o("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:e?.length||0},severity:"error"});throw y(()=>{q(n)}),s?.(n),n}},[N,O,s,o]),R=K(()=>{if(!ie()||!P||!a||!window.google?.accounts?.id||!r||i.current)return;const e=Date.now();if(!(e-C.current<h&&C.current>0))try{i.current=!0,C.current=e;const n={client_id:a,callback:async t=>{try{await w(t.credential)}catch(Y){p(Y,{userMessage:"Google One Tap credential handling failed",context:{operation:"google_one_tap_callback"},severity:"error"})}},auto_select:v,cancel_on_tap_outside:x,context:"signin",ux_mode:"popup",itp_support:!0,state:L?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:z,csp_nonce:S,moment_callback:t=>{const Y=t.getMomentType();if(t.isDisplayMoment?.()){if(!t.isDisplayed?.()){if(t.getNotDisplayedReason){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}}}else if(t.isSkippedMoment?.()){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}else if(t.isDismissedMoment?.()){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}}};T&&(n.prompt_parent_id=T),window.google.accounts.id.initialize(n),c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{window.google?.accounts?.id?.prompt(t=>{t?.credential&&w(t.credential)}),c.current=null},100)}catch(n){const t=p(n,{userMessage:o("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});y(()=>{q(t)}),s?.(t),i.current=!1}},[P,a,r,v,x,T,L,w,s,z,S,o]);return k(()=>{if(typeof window<"u"){y(()=>{$(!0)});try{const e=Number(localStorage.getItem(m)||0);f(e>Date.now())}catch{}}},[]),k(()=>{D&&!u&&G&&d&&R()},[D,u,G,d,R]),k(()=>()=>{c.current&&window.clearTimeout(c.current),i.current=!1},[]),{isLoaded:D,isLoading:V,error:te,user:E,isDark:L,fedcmSupported:r,isHydrated:M,containerRef:ee,initialize:R,handleCredential:w,shouldShow:G,browserInfo:Q,triggerLoad:X,loadTriggered:Z}}export{me as useGoogleOneTap};
1
+ "use client";import{useState as G,useEffect as L,useRef as h,useCallback as j,startTransition as _,useMemo as B}from"react";import{useIsDark as oe}from"@donotdev/components";import{handleError as u,getOAuthClientId as te,getEnabledAuthPartners as re,isClient as ne,useTranslation as ae,useScriptLoader as ie}from"@donotdev/core";import{useAuth as K}from"../useAuth";import{useFedCM as se}from"./useFedCM";function ce({clientId:Q,autoSelect:x=!0,cancelOnTapOutside:C=!0,promptParentId:y,disabled:l=!1,onSuccess:v,onError:i,allowedParentOrigins:R,cspNonce:S,clientOnly:N=!1}={}){const{t:n}=ae("auth"),I=K("user"),F=K("signInWithGoogleCredential"),T=oe(),s=Q||te("google"),E=re().includes("google"),{isSupported:r,isReady:d,error:P,browserInfo:U}=se({checkGoogleServices:!0,onError:o=>{const t=u(o,{userMessage:n("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});i?.(t)}}),{isLoading:V,isLoaded:b,error:q,isReady:z,load:X,loadTriggered:Z}=ie("https://accounts.google.com/gsi/client",{enabled:E&&!!s&&!l&&d&&r,nonce:S,checkExisting:!0,isLoaded:()=>!!window.google?.accounts?.id,onError:o=>{const t=u(o,{userMessage:n("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});i?.(t)}}),[D,$]=G(!1),[Y,A]=G(null),J=h(null),a=h(!1),c=h(null),M=h(0),[H,p]=G(!1),m="gsi_hide_until",w=600*1e3,O=B(()=>E&&!!s&&!l&&!I&&r&&(N?D:!0)&&!H,[E,s,l,I,r,N,D,H]),ee=B(()=>!r&&d?new Error(n("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):q||P||Y,[q,P,Y,r,d,n]),f=j(async o=>{try{if(!o||typeof o!="string")throw new Error("Invalid credential format");await F(o),_(()=>{v?.(o)})}catch(t){const e=u(t,{userMessage:n("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:o?.length||0},severity:"error"});throw _(()=>{A(e)}),i?.(e),e}},[F,v,i,n]),k=j(()=>{if(!ne()||!z||!s||!window.google?.accounts?.id||!r||a.current)return;const o=Date.now();if(!(o-M.current<w&&M.current>0))try{a.current=!0,M.current=o;const t={client_id:s,callback:async e=>{try{await f(e.credential)}catch(W){u(W,{userMessage:"Google One Tap credential handling failed",context:{operation:"google_one_tap_callback"},severity:"error"})}},auto_select:x,cancel_on_tap_outside:C,context:"signin",ux_mode:"popup",itp_support:!0,state:T?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:R,csp_nonce:S,moment_callback:e=>{const W=e.getMomentType();if(e.isDisplayMoment?.()){if(!e.isDisplayed?.()&&e.getNotDisplayedReason){a.current=!1;try{const g=Date.now()+w;localStorage.setItem(m,String(g)),p(!0)}catch{}}}else if(e.isSkippedMoment?.()){a.current=!1;try{const g=Date.now()+w;localStorage.setItem(m,String(g)),p(!0)}catch{}}else if(e.isDismissedMoment?.()){a.current=!1;try{const g=Date.now()+w;localStorage.setItem(m,String(g)),p(!0)}catch{}}}};y&&(t.prompt_parent_id=y),window.google.accounts.id.initialize(t),c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{window.google?.accounts?.id?.prompt(e=>{e?.credential&&f(e.credential)}),c.current=null},100)}catch(t){const e=u(t,{userMessage:n("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});_(()=>{A(e)}),i?.(e),a.current=!1}},[z,s,r,x,C,y,T,f,i,R,S,n]);return L(()=>{if(typeof window<"u"){_(()=>{$(!0)});try{const o=Number(localStorage.getItem(m)||0);p(o>Date.now())}catch{}}},[]),L(()=>{b&&!l&&O&&d&&k()},[b,l,O,d,k]),L(()=>()=>{c.current&&window.clearTimeout(c.current),a.current=!1},[]),{isLoaded:b,isLoading:V,error:ee,user:I,isDark:T,fedcmSupported:r,isHydrated:D,containerRef:J,initialize:k,handleCredential:f,shouldShow:O,browserInfo:U,triggerLoad:X,loadTriggered:Z}}export{ce as useGoogleOneTap};
@@ -1 +1 @@
1
- "use client";import{useState as s,useEffect as u}from"react";import{isClient as c}from"@donotdev/core";function O(){const[n,o]=s(()=>c()?navigator.onLine:!0),[e,r]=s("unknown");return u(()=>{if(!c())return;const t=()=>o(!0),i=()=>o(!1),f=()=>{if("connection"in navigator){const l=navigator.connection;r(l.effectiveType||"unknown")}};return window.addEventListener("online",t),window.addEventListener("offline",i),f(),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}},[]),{online:n,connectionType:e,isSlowConnection:e==="slow-2g"||e==="2g",isOnline:n,isOffline:!n}}export{O as useNetworkStatus};
1
+ "use client";import{useState as r,useEffect as w}from"react";import{isClient as s}from"@donotdev/core";function l(){const[n,o]=r(()=>s()?navigator.onLine:!0),[e,f]=r("unknown");return w(()=>{if(!s())return;const i=()=>o(!0),t=()=>o(!1),c=()=>{if("connection"in navigator){const a=navigator.connection;f(a.effectiveType||"unknown")}};return window.addEventListener("online",i),window.addEventListener("offline",t),c(),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",t)}},[]),{online:n,connectionType:e,isSlowConnection:e==="slow-2g"||e==="2g",isOnline:n,isOffline:!n}}export{l as useNetworkStatus};
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { useDeleteAccount } from './hooks/useDeleteAccount';
10
10
  export type { DeleteAccountState } from './hooks/useDeleteAccount';
11
11
  export { getAuthState, subscribeToAuth } from './authHelpers';
12
12
  export { AuthPartnerButton, ConfirmDeleteDialog, FeatureGuard, GoogleOneTap, LoginModal, MultipleAuthProviders, // Added for AuthHeader and future LoginTemplate
13
- ReauthDialog, } from './components';
13
+ PasswordResetCallback, ReauthDialog, } from './components';
14
14
  export type { AuthError, // Explicitly import AuthError from core
15
15
  AuthUser as User, // Rename AuthUser to User for public API simplicity
16
16
  UserRole, SubscriptionTier, } from '@donotdev/core';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGnE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,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gB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,aAAa,EACb,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,YAAY,EACV,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{useAuth as o}from"./useAuth";import{useDeleteAccount as u}from"./hooks/useDeleteAccount";import{getAuthState as a,subscribeToAuth as h}from"./authHelpers";import{AuthPartnerButton as T,ConfirmDeleteDialog as i,FeatureGuard as p,GoogleOneTap as f,LoginModal as g,MultipleAuthProviders as m,ReauthDialog as n}from"./components";import{getAuthMethod as x,PARTNER_STATE as d,EMAIL_VERIFICATION_STATUS as D}from"./constants";export{T as AuthPartnerButton,i as ConfirmDeleteDialog,D as EMAIL_VERIFICATION_STATUS,p as FeatureGuard,f as GoogleOneTap,g as LoginModal,m as MultipleAuthProviders,d as PARTNER_STATE,n as ReauthDialog,x as getAuthMethod,a as getAuthState,h as subscribeToAuth,o as useAuth,u as useDeleteAccount};
1
+ import{useAuth as a}from"./useAuth";import{useDeleteAccount as t}from"./hooks/useDeleteAccount";import{getAuthState as e,subscribeToAuth as s}from"./authHelpers";import{AuthPartnerButton as o,ConfirmDeleteDialog as u,FeatureGuard as r,GoogleOneTap as A,LoginModal as l,MultipleAuthProviders as i,PasswordResetCallback as T,ReauthDialog as h}from"./components";import{getAuthMethod as g,PARTNER_STATE as m,EMAIL_VERIFICATION_STATUS as n}from"./constants";export{o as AuthPartnerButton,u as ConfirmDeleteDialog,n as EMAIL_VERIFICATION_STATUS,r as FeatureGuard,A as GoogleOneTap,l as LoginModal,i as MultipleAuthProviders,m as PARTNER_STATE,T as PasswordResetCallback,h as ReauthDialog,g as getAuthMethod,e as getAuthState,s as subscribeToAuth,a as useAuth,t as useDeleteAccount};
@@ -0,0 +1 @@
1
+ {"useAuth":"/**\n * React hook for authentication with property-based access\n *\n * Single entry point for all authentication operations.\n * Lazy loads FirebaseAuth on first call and connects to store.\n * Uses unified FeatureStatus enum for lifecycle management.\n *\n * **Property-based access (clean and simple):**\n * ```typescript\n * // ✅ State from store (reactive, re-renders on change)\n * const user = useAuth('user');\n * const status = useAuth('status'); // 'initializing' | 'ready' | 'degraded' | 'error'\n * const loading = useAuth('loading');\n * const error = useAuth('error');\n *\n * // ✅ Methods from instance (stable, never re-renders)\n * const signIn = useAuth('signInWithEmail');\n * const signOut = useAuth('signOut');\n * ```\n *\n * **How it works:**\n * - Store properties (user, status, loading, etc.) → Subscribe via Zustand (reactive)\n * - Methods (signInWithEmail, etc.) → Get from FirebaseAuth instance (stable)\n *\n * **Status-based behavior:**\n * - `initializing`: Auth is loading (returns degraded API until ready)\n * - `ready`: Auth fully operational (returns real API)\n * - `degraded`: Auth unavailable (returns degraded API)\n * - `error`: Auth encountered error (returns degraded API)\n *\n * **Error Handling:**\n * All async methods throw DoNotDevError (already wrapped by FirebaseAuth/SmartRecovery).\n *\n * @template K - The property key from AuthAPI\n * @param key - Property name to access\n * @returns The value of the specified property\n *\n * @example\n * ```typescript\n * // Get status (re-renders when status changes)\n * const status = useAuth('status');\n * if (status === 'initializing') return <Spinner overlay />;\n * if (status === 'degraded') return <Error>Auth unavailable</Error>;\n *\n * // Get user (re-renders when user changes)\n * const user = useAuth('user');\n * if (!user) return <LoginButton />;\n *\n * // Get sign-in method (stable, never re-renders)\n * const signIn = useAuth('signInWithEmail');\n * await signIn(email, password);\n * ```\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport declare function useAuth<K extends keyof AuthAPI>(key: K): AuthAPI[K];","useDeleteAccount":"/**\n * Hook for managing account deletion flow\n *\n * Handles:\n * - Confirmation dialog\n * - Password dialog (when password is required for reauthentication)\n * - Error states\n * - Loading states\n *\n * Reauthentication is handled internally by FirebaseAuth.deleteAccount():\n * - OAuth providers: Automatically triggers popup\n * - Password providers: Requires password parameter\n *\n * @example\n * ```tsx\n * const deletion = useDeleteAccount();\n *\n * // Start flow\n * <Button onClick={deletion.startDeleteFlow}>Delete Account</Button>\n *\n * // Dialogs\n * <ReauthDialog\n * open={deletion.showPasswordDialog}\n * onReauth={(password) => deletion.confirmDelete(password)}\n * onCancel={deletion.cancel}\n * />\n * <ConfirmDeleteDialog\n * open={deletion.showConfirmDialog}\n * onConfirm={() => deletion.confirmDelete()}\n * onCancel={deletion.cancel}\n * />\n * ```\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n * @returns Account deletion state and actions\n */\nexport declare function useDeleteAccount(): DeleteAccountState;","DeleteAccountState":"/**\n * Account deletion state and actions\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport interface DeleteAccountState {\n /** Whether confirmation dialog is visible */\n showConfirmDialog: boolean;\n /** Whether account deletion is in progress */\n isDeleting: boolean;\n /** Whether password re-authentication dialog is visible */\n showPasswordDialog: boolean;\n /** Error message if any */\n error: string | null;\n /** Start the deletion flow (shows confirmation dialog) */\n startDeleteFlow: () => void;\n /** Confirm deletion (executes actual deletion, handles reauthentication internally) */\n confirmDelete: (password?: string) => Promise<void>;\n /** Cancel deletion flow (closes dialogs) */\n cancel: () => void;\n}","getAuthState":"/**\n * Get current auth state synchronously\n * Use this in Zustand stores or other non-React contexts\n *\n * **Behavior:**\n * - Always returns valid state (never throws)\n * - Returns initial state if auth is not initialized: `{ user: null, initialized: false, ... }`\n * - Works in both client and server contexts (server returns initial state)\n * - No graceful degradation needed - store always exists with valid initial state\n *\n * @returns Current auth state (or initial state if not initialized)\n *\n * @example\n * ```typescript\n * const authState = getAuthState();\n * const userId = authState.userId; // null if not authenticated\n * const user = authState.user; // null if not authenticated\n * const isInitialized = authState.initialized; // false until auth initializes\n * ```\n */\nexport declare function getAuthState(): AuthState & AuthActions;","subscribeToAuth":"/**\n * Subscribe to auth state changes\n * Use this in Zustand stores or other non-React contexts\n *\n * **Behavior:**\n * - Always returns unsubscribe function (never throws)\n * - Subscriptions work even if auth is not initialized\n * - On server, subscription is a no-op (returns empty unsubscribe function)\n * - Listener receives initial state immediately, then updates as auth state changes\n *\n * **Important:** Always call the returned unsubscribe function to prevent memory leaks.\n *\n * @param listener - Callback function that receives (state, prevState)\n * @returns Unsubscribe function (call to remove listener)\n *\n * @example\n * ```typescript\n * const unsubscribe = subscribeToAuth((state, prevState) => {\n * if (state.user?.id !== prevState.user?.id) {\n * // User changed - handle accordingly\n * if (state.user) {\n * console.log('User signed in:', state.user.id);\n * } else {\n * console.log('User signed out');\n * }\n * }\n * });\n *\n * // Later, cleanup\n * unsubscribe();\n * ```\n */\nexport declare function subscribeToAuth(listener: (state: AuthState & AuthActions, prevState: AuthState & AuthActions) => void): () => void;","AuthPartnerButton":"/**\n * AuthPartnerButton - Authentication button component\n *\n * Provides a unified button interface for authentication with various partners\n * (Google, Facebook, etc.) and methods (OAuth, email/password, email link).\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\ndeclare function AuthPartnerButton({ partnerId, method, onSuccess, onError, className, children, disabled, display, style, ...props }","ConfirmDeleteDialog":"/**\n * Confirmation dialog for account deletion\n *\n * Shows warning, lists what will be deleted, and requires explicit confirmation.\n *\n * @example\n * ```tsx\n * <ConfirmDeleteDialog\n * open={showConfirmDialog}\n * isLoading={isDeleting}\n * error={error}\n * onConfirm={confirmDelete}\n * onCancel={cancel}\n * />\n * ```\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport declare function ConfirmDeleteDialog({ open, isLoading, error, onConfirm, onCancel, }","FeatureGuard":"/**\n * FeatureGuard component that protects individual components based on user permissions\n *\n * Provides granular feature access control within pages, allowing developers to show/hide\n * features based on user permissions without manual hook management. This complements\n * the route-level AuthGuard by providing component-level protection within pages.\n *\n * **Key Features:**\n * - Role-based access control (user, admin)\n * - Subscription tier validation (free, pro, premium)\n * - Active subscription requirement checking\n * - Custom validation functions\n * - Automatic fallback components with context\n * - Graceful degradation when auth unavailable\n * - Loading state handling\n *\n * **Fallback Behavior:**\n * - Shows loading skeleton while auth state loads\n * - Displays AuthFallback for unauthenticated users (if showLoginPrompt=true)\n * - Shows UpgradePrompt for tier restrictions (if showUpgradePrompt=true)\n * - Displays AccessDenied for role restrictions\n * - Shows SubscriptionExpired for subscription requirements\n * - Renders custom fallback if provided\n * - Returns null if no fallback should be shown\n *\n * **Performance:**\n * - Uses useAuth() hook for reactive updates\n * - Memoizes permission checks\n * - Minimal re-renders on auth state changes\n * - Lazy loading compatible\n *\n * @param props - FeatureGuard configuration\n * @returns Protected component or fallback component\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport declare function FeatureGuard({ children, role, tier, subscription, validate, fallback: CustomFallback, message, showUpgradePrompt, showLoginPrompt, }","GoogleOneTap":"/**\n * Google One Tap authentication component\n *\n * @description\n * Displays Google One Tap prompt for seamless authentication.\n * As of October 2024, FedCM is mandatory - shows clear browser\n * compatibility message if not supported.\n *\n * **Positioning:**\n * Fixed to top-right, below header/breadcrumbs automatically.\n *\n * **States:**\n * - Loading: Shows spinner while initializing\n * - Error: Shows error message with details\n * - Not Supported: Shows browser upgrade message\n * - Ready: Invisible container for Google prompt\n *\n * @param props - Component configuration\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\ndeclare function GoogleOneTap({ clientId, onSuccess, onError, autoSelect, cancelOnTapOutside, className, disabled, promptParentId, allowedParentOrigins, cspNonce, clientOnly, showErrorDetails, loadingComponent: LoadingComponent, errorComponent: ErrorComponent, browserNotSupportedComponent: BrowserNotSupportedComponent, }","LoginModal":"declare const LoginModal: (props: LoginModalProps) => import(\"react/jsx-runtime\").JSX.Element;","MultipleAuthProviders":"/**\n * Multiple auth providers component with automatic fallback handling\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\ndeclare const MultipleAuthProviders: (props: MultipleAuthProvidersProps) => import(\"react/jsx-runtime\").JSX.Element;","ReauthDialog":"/**\n * Re-authentication dialog for account deletion\n *\n * Prompts user to re-enter password for security before account deletion.\n *\n * @example\n * ```tsx\n * <ReauthDialog\n * open={showReauthDialog}\n * isLoading={isReauthenticating}\n * error={error}\n * onReauth={reauthenticate}\n * onCancel={cancel}\n * />\n * ```\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport declare function ReauthDialog({ open, isLoading, error, onReauth, onCancel, }","AuthMethod":"type AuthMethod } from '../constants';","AuthPartnerButtonProps":"/**\n * Props for auth partner button\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport interface AuthPartnerButtonProps extends AuthCallbackProps, BaseComponentProps {\n partnerId: AuthPartnerId;\n method?: AuthMethod | null;\n children?: React.ReactNode;\n disabled?: boolean;\n /**\n * Display - controls button presentation in preset layouts\n * - 'compact': Icon-only\n * - 'full': Icon + label\n * - 'auto': Responsive (default)\n * @default 'auto'\n */\n display?: (typeof DISPLAY)[keyof typeof DISPLAY];\n}","GoogleOneTapProps":"/**\n * Props for Google One Tap component\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport interface GoogleOneTapProps extends AuthCallbackProps {\n /** Custom client ID (defaults to env variable) */\n clientId?: string;\n}","LoginModalProps":"/**\n * Props for login modal\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport interface LoginModalProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}","MultipleAuthProvidersProps":"/**\n * Props for multiple auth providers\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport interface MultipleAuthProvidersProps extends BaseComponentProps {\n /** Providers to display (defaults to all available providers) */\n providers?: AuthPartnerId[];\n /** CSS class for each provider button */\n buttonClassName?: string;\n}","FeatureGuardProps":"/**\n * Props for FeatureGuard component\n */\nexport interface FeatureGuardProps {\n /** Children to render if access is granted */\n children: ReactNode;\n /** Required role(s) - user must have at least one */\n role?: UserRole | UserRole[];\n /** Required subscription tier */\n tier?: SubscriptionTier;\n /** Whether active subscription is required */\n subscription?: boolean;\n /** Custom validation function */\n validate?: (role: UserRole | undefined, tier: SubscriptionTier | undefined) => boolean;\n /** Fallback component to show when access is denied */\n fallback?: ComponentType<{\n requiredRole?: UserRole | UserRole[];\n requiredTier?: SubscriptionTier;\n requiresSubscription?: boolean;\n userRole?: UserRole;\n userTier?: SubscriptionTier;\n hasSubscription?: boolean;\n }>;\n /** Custom message for fallback */\n message?: string;\n /** Whether to show upgrade prompt for tier restrictions */\n showUpgradePrompt?: boolean;\n /** Whether to show login prompt for auth restrictions */\n showLoginPrompt?: boolean;\n}","ConfirmDeleteDialogProps":"/**\n * Confirmation dialog props\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport interface ConfirmDeleteDialogProps {\n /** Whether dialog is open */\n open: boolean;\n /** Whether deletion is in progress */\n isLoading: boolean;\n /** Error message if any */\n error: string | null;\n /** Confirm deletion handler */\n onConfirm: () => Promise<void>;\n /** Cancel handler */\n onCancel: () => void;\n}","ReauthDialogProps":"/**\n * Re-authentication dialog props\n *\n * @version 0.1.0\n * @since 0.0.1\n * @author AMBROISE PARK Consulting\n */\nexport interface ReauthDialogProps {\n /** Whether dialog is open */\n open: boolean;\n /** Whether re-authentication is in progress */\n isLoading: boolean;\n /** Error message if any */\n error: string | null;\n /** Re-authentication handler */\n onReauth: (password: string) => Promise<void>;\n /** Cancel handler */\n onCancel: () => void;\n}"}