@donotdev/auth 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AuthStore.d.ts.map +1 -1
- package/dist/AuthStore.js +1 -1
- package/dist/components/EmailPasswordForm.d.ts +11 -4
- package/dist/components/EmailPasswordForm.d.ts.map +1 -1
- package/dist/components/EmailPasswordForm.js +2 -1
- package/dist/components/PasswordResetCallback.d.ts +12 -0
- package/dist/components/PasswordResetCallback.d.ts.map +1 -0
- package/dist/components/PasswordResetCallback.js +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants.d.ts +22 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/symbol-index.json +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts.map +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +5 -5
package/dist/AuthStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthStore.d.ts","sourceRoot":"","sources":["../src/AuthStore.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthStore.d.ts","sourceRoot":"","sources":["../src/AuthStore.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,gBAAgB,CAAC;AA2BxB,eAAO,MAAM,YAAY,iIAgMvB,CAAC"}
|
package/dist/AuthStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as i,FEATURE_STATUS as
|
|
1
|
+
import{createDoNotDevStore as i,FEATURE_STATUS as u}from"@donotdev/core";import{PARTNER_STATE as l}from"./constants";const o={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:u.INITIALIZING},S=i({name:"auth-store",createStore:(t,a)=>({...o,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]||l.IDLE,clearAllPartnerStates:()=>t(r=>({partnerStates:Object.keys(r.partnerStates).reduce((e,s)=>(e[s]=l.IDLE,e),{}),partnerError:null})),setAuthenticated:(r,e,s)=>{t({user:r,authenticated:!0,userId:r.id,loading:!1,error:null,status:u.READY,userSubscription:e,userProfile:s})},setUnauthenticated:()=>{t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:u.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(o)})});export{S as useAuthStore};
|
|
@@ -4,16 +4,23 @@ import type { EmailPasswordFormProps } from '../constants';
|
|
|
4
4
|
*
|
|
5
5
|
* Best-in-class email/password authentication form with:
|
|
6
6
|
* - Real-time validation with react-hook-form
|
|
7
|
-
* - Password strength indicator
|
|
7
|
+
* - Password strength indicator with inline requirements
|
|
8
|
+
* - Breached password detection (NIST 800-63B / HaveIBeenPwned)
|
|
9
|
+
* - Client-side rate limiting
|
|
10
|
+
* - Anti-enumeration (signup + forgot password)
|
|
11
|
+
* - CAPTCHA-ready (consumer passes token via prop)
|
|
12
|
+
* - autoComplete hints for password managers
|
|
8
13
|
* - Remember me persistence
|
|
9
14
|
* - Forgot password flow
|
|
10
|
-
* -
|
|
15
|
+
* - Resend verification email
|
|
16
|
+
* - Terms of Service / Privacy Policy consent (GDPR)
|
|
17
|
+
* - Sign in / Sign up mode switching with form reset
|
|
11
18
|
* - Full i18n support
|
|
12
19
|
* - Accessible with proper ARIA
|
|
13
20
|
*
|
|
14
21
|
* @component
|
|
15
|
-
* @version 0.
|
|
22
|
+
* @version 0.2.0
|
|
16
23
|
*/
|
|
17
|
-
declare function EmailPasswordForm({ mode, onSuccess, onError, className, }: EmailPasswordFormProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, }: EmailPasswordFormProps): import("react/jsx-runtime").JSX.Element;
|
|
18
25
|
export default EmailPasswordForm;
|
|
19
26
|
//# sourceMappingURL=EmailPasswordForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,sBAAsB,EAAY,MAAM,cAAc,CAAC;AAiKrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAc,EACd,GAAG,EACH,OAAO,EACP,YAAY,GACb,EAAE,sBAAsB,2CAqoBxB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as a,jsxs as i,Fragment as le}from"react/jsx-runtime";import{useCallback as V,useEffect as Ne,useRef as xe,useState as p}from"react";import{useForm as qe,Controller as B,useWatch as ce}from"react-hook-form";import{Alert as L,ALERT_VARIANT as T,Button as f,BUTTON_VARIANT as h,Checkbox as de,Dialog as ue,Input as Oe,Label as me,PasswordInput as pe,Stack as o,Text as v,cn as Ue}from"@donotdev/components";import{useTranslation as De,useAppConfig as We}from"@donotdev/core";import{useAuth as b}from"../useAuth";import{PasswordStrengthIndicator as Fe}from"./PasswordStrengthIndicator";const Ve=6e4,Be=5,je=3e4;function Ke(){const r=xe([]),[n,w]=p(null),g=V(()=>!!(n&&Date.now()<n),[n]),u=V(()=>{const l=Date.now();r.current=r.current.filter(y=>l-y<Ve),r.current.push(l),r.current.length>=Be&&(w(l+je),r.current=[])},[]);return Ne(()=>{if(!n)return;const l=n-Date.now();if(l<=0){w(null);return}const y=setTimeout(()=>w(null),l);return()=>clearTimeout(y)},[n]),{isRateLimited:g,recordAttempt:u,cooldownUntil:n}}async function He(r){try{const w=new TextEncoder().encode(r),g=await crypto.subtle.digest("SHA-1",w),l=Array.from(new Uint8Array(g)).map(k=>k.toString(16).padStart(2,"0")).join("").toUpperCase(),y=l.slice(0,5),e=l.slice(5),P=await fetch(`https://api.pwnedpasswords.com/range/${y}`,{headers:{"Add-Padding":"true"},credentials:"omit"});return P.ok?(await P.text()).split(`
|
|
2
|
+
`).some(k=>{const[N]=k.split(":");return N?.trim()===e}):!1}catch{return!1}}const $e=[{test:r=>r.includes("429")||r.includes("rate")||r.includes("too_many_requests"),key:"errors.rate_limit",fallback:"Too many attempts. Please wait a moment and try again."},{test:r=>r.includes("email_not_confirmed")||r.includes("email not confirmed")||r.includes("auth/unverified-email"),key:"errors.email_not_confirmed",fallback:"Please verify your email before signing in."},{test:r=>r.includes("invalid_credentials")||r.includes("invalid login credentials")||r.includes("invalid-credential")||r.includes("auth/wrong-password")||r.includes("auth/user-not-found")||r.includes("invalid")&&r.includes("credential"),key:"errors.invalid_credentials",fallback:"Invalid email or password."},{test:r=>r.includes("already")||r.includes("exists")||r.includes("user_already_exists")||r.includes("user already registered")||r.includes("auth/email-already-in-use"),key:"signup.check_email",fallback:"Check your email to confirm your account."},{test:r=>r.includes("weak_password")||r.includes("weak password")||r.includes("auth/weak-password"),key:"errors.weak_password",fallback:"Password is too weak. Please choose a stronger password."},{test:r=>r.includes("network")||r.includes("fetch"),key:"networkError",fallback:"Network error. Please check your connection and try again."}];function Ge(r,n){const g=(r instanceof Error?r.message:String(r)).toLowerCase();for(const u of $e)if(u.test(g))return n(u.key,u.fallback);return n("errorGeneric","Authentication failed. Please try again.")}function ze({mode:r="signin",onSuccess:n,onError:w,className:g="",tos:u,privacy:l,captchaToken:y}){const{t:e}=De("auth"),P=We("app"),j=b("signInWithEmail"),k=b("createUserWithEmail"),N=b("sendPasswordResetEmail"),fe=b("sendEmailVerification"),he=b("setRememberMe"),we=b("isAvailable"),ge=b("loading"),[x,ye]=p(r),m=x==="signup",[q,be]=p(!1),[K,O]=p(!1),[_,H]=p(!1),[$,U]=p(!1),[G,z]=p(!1),[ve,Z]=p(!1),[Pe,X]=p(!1),C=u!==void 0?u:P?.footer?.legalLinks?.find(t=>t.path.includes("terms"))?.path??"/legal/terms",S=l!==void 0?l:P?.footer?.legalLinks?.find(t=>t.path.includes("privacy"))?.path??"/legal/privacy",R=C!==!1,E=S!==!1,Y=R&&typeof C!="string",J=E&&typeof S!="string",Q=R&&typeof C=="string"?C:null,ee=E&&typeof S=="string"?S:null,{isRateLimited:D,recordAttempt:ke,cooldownUntil:re}=Ke(),{control:A,handleSubmit:_e,getValues:Ce,reset:te,formState:{errors:s,isSubmitting:Se},setError:W,clearErrors:ae}=qe({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),se=ce({control:A,name:"password"}),I=ce({control:A,name:"email"}),F=V(t=>{te({email:I||"",password:"",confirmPassword:""}),ae(),U(!1),O(!1),z(!1),ye(t)},[te,ae,I]),Re=async t=>{if(D()){W("root",{message:e("errors.rate_limit","Too many attempts. Please wait a moment and try again.")});return}ke();try{x==="signin"?(q!==void 0&&await he(q),await j(t.email,t.password),n?.(void 0)):(await k(t.email,t.password),U(!0),n?.(void 0))}catch(c){const Te=x==="signup",oe=c instanceof Error?c.message:String(c),M=oe.toLowerCase();if(Te&&(M.includes("already")||M.includes("exists")||M.includes("user_already_exists")||M.includes("auth/email-already-in-use"))){U(!0);return}const Me=Ge(c,e);W("root",{message:Me}),w?.(c instanceof Error?c:new Error(oe))}},Ee=async()=>{if(!I||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I)){W("email",{message:e("emailRequired","Email is required")});return}H(!0);try{await N(I)}catch{}finally{O(!0),H(!1)}},Ae=async()=>{try{await fe()}catch{}};if(!we)return a(o,{className:g,children:a(L,{variant:T.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Please accept cookies to enable authentication.")})});const d=ge||Se,ne=m&&(R||E),Ie=y!==void 0&&!y,Le=d||D()||Ie||ne&&!G,ie=re?Math.max(0,Math.ceil((re-Date.now())/1e3)):0;return a("form",{onSubmit:_e(Re),className:Ue("dndev-auth-form",g),noValidate:!0,children:i(o,{children:[s.root&&a(L,{variant:T.ERROR,description:s.root.message}),D()&&ie>0&&a(L,{variant:T.WARNING,description:e("errors.rate_limit_cooldown",`Too many attempts. Please wait ${ie} seconds.`)}),$&&i(o,{children:[a(L,{variant:T.SUCCESS,title:e("signup.success_title","Check your email"),description:e("signup.check_email","If an account was created, you will receive a confirmation email. Check your inbox and spam folder.")}),i(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[a(f,{type:"button",variant:h.GHOST,onClick:Ae,children:e("signup.resend_verification","Resend verification email")}),a(v,{as:"span",variant:"muted",children:"|"}),a(f,{type:"button",variant:h.LINK,onClick:()=>F("signin"),children:e("actions.sign_in_submit","Sign In")})]})]}),K&&i(o,{children:[a(L,{variant:T.SUCCESS,title:e("forgotPassword.sent","Password reset email sent"),description:e("forgotPassword.check_email_safe","If an account exists with this email, you will receive password reset instructions.")}),a(o,{align:"center",children:a(f,{type:"button",variant:h.LINK,onClick:()=>{O(!1)},children:e("back","Back")})})]}),!$&&!K&&i(o,{children:[a(B,{name:"email",control:A,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:t})=>i(o,{gap:"tight",children:[a(Oe,{...t,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),autoComplete:"email webauthn",disabled:d||_,"aria-invalid":!!s.email,"aria-describedby":s.email?"email-error":void 0,className:"dndev-w-full","data-variant":s.email?"destructive":void 0}),s.email&&a(v,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:s.email.message})]})}),a(B,{name:"password",control:A,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:m?{uppercase:t=>t?/[A-Z]/.test(t)?!0:e("passwordRequirement.uppercase","Password must contain at least one uppercase letter"):!0,lowercase:t=>t?/[a-z]/.test(t)?!0:e("passwordRequirement.lowercase","Password must contain at least one lowercase letter"):!0,number:t=>t?/[0-9]/.test(t)?!0:e("passwordRequirement.number","Password must contain at least one number"):!0,special:t=>t?/[^a-zA-Z0-9]/.test(t)?!0:e("passwordRequirement.special","Password must contain at least one special character"):!0,breached:async t=>!t||t.length<8?!0:await He(t)?e("errors.breached_password","This password has appeared in a data breach. Please choose a different password."):!0}:void 0},render:({field:t})=>{const c=`password-${t.name}`;return i(o,{gap:"tight",children:[a(pe,{...t,id:c,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),autoComplete:m?"new-password":"current-password",disabled:d||_,"aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,className:"dndev-w-full","data-variant":s.password?"destructive":void 0}),s.password&&a(v,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:s.password.message})]})}}),m&&a(B,{name:"confirmPassword",control:A,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:t=>{const c=Ce("password");return t!==c?e("confirmPasswordMismatch","Passwords do not match"):!0}},render:({field:t})=>i(o,{gap:"tight",children:[a(pe,{...t,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:d,"aria-invalid":!!s.confirmPassword,"aria-describedby":s.confirmPassword?"confirm-password-error":void 0,className:"dndev-w-full","data-variant":s.confirmPassword?"destructive":void 0}),s.confirmPassword&&a(v,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:s.confirmPassword.message})]})}),m&&se&&a(Fe,{password:se,minLength:8,showRequirements:!0}),ne&&i(le,{children:[i(o,{direction:"row",gap:"tight",align:"start",children:[a(de,{id:"tos-accept",checked:G,onCheckedChange:t=>z(t===!0),disabled:d}),a(me,{htmlFor:"tos-accept",children:i(v,{as:"span",level:"caption",children:[e("terms.accept_prefix","I accept the")," ",R&&a(f,{type:"button",variant:h.LINK,onClick:()=>{Y?Z(!0):Q&&window.open(Q,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.tos","Terms of Service")}),R&&E&&i(le,{children:[" ",e("terms.and","and")," "]}),E&&a(f,{type:"button",variant:h.LINK,onClick:()=>{J?X(!0):ee&&window.open(ee,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.privacy","Privacy Policy")})]})})]}),Y&&a(ue,{open:ve,onOpenChange:Z,title:e("terms.tos","Terms of Service"),showClose:!0,children:C}),J&&a(ue,{open:Pe,onOpenChange:X,title:e("terms.privacy","Privacy Policy"),showClose:!0,children:S})]}),!m&&i(o,{direction:"row",gap:"tight",align:"center",children:[a(de,{id:"remember-me",checked:q,onCheckedChange:t=>be(t===!0),disabled:d||_}),a(me,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),a(f,{type:"submit",variant:h.PRIMARY,disabled:Le,fullWidth:!0,children:d?e("loading","Loading..."):m?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!m&&i(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[a(f,{type:"button",variant:h.LINK,disabled:d||_,onClick:Ee,children:_?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),a(v,{as:"span",variant:"muted",children:"|"}),a(f,{type:"button",variant:h.LINK,disabled:d,onClick:()=>F("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),m&&a(o,{align:"center",children:a(f,{type:"button",variant:h.LINK,disabled:d,onClick:()=>F("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})]})})}var tr=ze;export{tr 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":"AA2IA;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,mDAgTpC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{jsx as s,jsxs as p}from"react/jsx-runtime";import{useCallback as L,useEffect as j,useState as f}from"react";import{useForm as M,Controller as N,useWatch as Y}from"react-hook-form";import{Alert as x,ALERT_VARIANT as C,Button as A,BUTTON_VARIANT as _,Dialog as z,PasswordInput as V,Spinner as H,Stack as h,Text as b}from"@donotdev/components";import{useTranslation as Z}from"@donotdev/core";import{useAuth as P}from"../useAuth";import{useAuthStore as W}from"../AuthStore";import{PasswordStrengthIndicator as $}from"./PasswordStrengthIndicator";function G(){if(typeof window>"u")return{type:null};const r=window.location.hash.slice(1);if(r){const n=new URLSearchParams(r),m=n.get("error_code");if(m){const l={type:"supabase_error",errorCode:m,errorDescription:n.get("error_description")?.replace(/\+/g," ")||void 0};return window.history.replaceState(null,"",window.location.pathname+window.location.search),l}if(n.get("type")==="recovery")return window.history.replaceState(null,"",window.location.pathname+window.location.search),{type:"supabase_recovery"}}const u=new URLSearchParams(window.location.search),d=u.get("oobCode");return d&&u.get("mode")==="resetPassword"?{type:"firebase",oobCode:d}:{type:null}}async function X(r){try{const d=new TextEncoder().encode(r),n=await crypto.subtle.digest("SHA-1",d),l=Array.from(new Uint8Array(n)).map(c=>c.toString(16).padStart(2,"0")).join("").toUpperCase(),t=l.slice(0,5),o=l.slice(5),i=await fetch(`https://api.pwnedpasswords.com/range/${t}`,{headers:{"Add-Padding":"true"},credentials:"omit"});return i.ok?(await i.text()).split(`
|
|
2
|
+
`).some(c=>{const[g]=c.split(":");return g?.trim()===o}):!1}catch{return!1}}function oe(){const{t:r}=Z("auth"),u=P("passwordResetPending"),d=P("verifyPasswordResetCode"),n=P("confirmPasswordReset"),m=P("updatePassword"),l=P("signInWithEmail"),[t,o]=f("idle"),[i,R]=f(null),[c,g]=f(null),[E,B]=f(!1),[D,k]=f(null),{control:v,handleSubmit:F,getValues:O,formState:{errors:a,isSubmitting:y},setError:q}=M({mode:"onChange",defaultValues:{password:"",confirmPassword:""}}),I=Y({control:v,name:"password"});j(()=>{if(t!=="idle")return;const e=G();if(e.type==="supabase_error"){e.errorCode==="otp_expired"?o("expired"):(k(e.errorDescription||null),o("invalid"));return}if(e.type==="firebase"&&e.oobCode){B(!0),g(e.oobCode),o("loading"),d(e.oobCode).then(w=>{w?(R(w),o("ready")):o("expired")});return}u&&o("ready")},[u,t,d]);const U=L(async e=>{try{if(E&&c){if(await n(c,e.password),i)try{await l(i,e.password)}catch{}}else await m(e.password),W.getState().setPasswordResetPending(!1);o("idle")}catch(w){const T=w instanceof Error?w.message:String(w);T.includes("expired")||T.includes("EXPIRED")?o("expired"):q("root",{message:r("resetPassword.error","Failed to reset password. Please try again.")})}},[E,c,i,n,m,l,q,r]),S=L(()=>{o("idle"),R(null),g(null),k(null),W.getState().setPasswordResetPending(!1),typeof window<"u"&&window.history.replaceState(null,"",window.location.pathname)},[]);return t==="idle"?null:p(z,{open:!0,onOpenChange:e=>{e||S()},style:{maxWidth:"min(28rem, 90vw)"},title:t==="success"?r("resetPassword.success_title","Password updated"):t==="expired"||t==="invalid"?r("resetPassword.expired_title","Link expired"):t==="loading"?r("resetPassword.verifying","Verifying..."):r("resetPassword.title","Set new password"),showClose:!0,children:[t==="loading"&&p(h,{align:"center",justify:"center",children:[s(H,{}),s(b,{level:"body",variant:"muted",children:r("resetPassword.verifying","Verifying reset link...")})]}),(t==="expired"||t==="invalid")&&p(h,{children:[s(x,{variant:C.WARNING,description:t==="expired"?r("resetPassword.expired_description","This password reset link has expired. Please request a new one."):D||r("resetPassword.invalid_description","This password reset link is invalid. Please request a new one.")}),s(A,{variant:_.PRIMARY,onClick:S,fullWidth:!0,children:r("resetPassword.back_to_signin","Back to Sign In")})]}),t==="success"&&p(h,{children:[s(x,{variant:C.SUCCESS,description:r("resetPassword.success_description","Your password has been reset successfully. You are now signed in.")}),s(A,{variant:_.PRIMARY,onClick:S,fullWidth:!0,children:r("resetPassword.continue","Continue")})]}),t==="ready"&&s("form",{onSubmit:F(U),noValidate:!0,children:p(h,{children:[i&&s(b,{level:"small",variant:"muted",children:r("resetPassword.for_email",`Enter a new password for ${i}`)}),a.root&&s(x,{variant:C.ERROR,description:a.root.message}),s(N,{name:"password",control:v,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})=>p(h,{gap:"tight",children:[s(V,{...e,label:r("resetPassword.new_password","New password"),placeholder:r("passwordPlaceholder","Enter your password"),autoComplete:"new-password",disabled:y,"aria-invalid":!!a.password,"aria-describedby":a.password?"reset-password-error":void 0,className:"dndev-w-full","data-variant":a.password?"destructive":void 0}),a.password&&s(b,{as:"span",level:"caption",variant:"destructive",id:"reset-password-error",role:"alert",children:a.password.message})]})}),s(N,{name:"confirmPassword",control:v,rules:{required:r("confirmPasswordRequired","Please confirm your password"),validate:e=>e===O("password")||r("confirmPasswordMismatch","Passwords do not match")},render:({field:e})=>p(h,{gap:"tight",children:[s(V,{...e,label:r("confirmPassword","Confirm password"),placeholder:r("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:y,"aria-invalid":!!a.confirmPassword,"aria-describedby":a.confirmPassword?"reset-confirm-error":void 0,className:"dndev-w-full","data-variant":a.confirmPassword?"destructive":void 0}),a.confirmPassword&&s(b,{as:"span",level:"caption",variant:"destructive",id:"reset-confirm-error",role:"alert",children:a.confirmPassword.message})]})}),I&&s($,{password:I,minLength:8,showRequirements:!0}),s(A,{type:"submit",variant:_.PRIMARY,disabled:y,fullWidth:!0,children:y?r("loading","Loading..."):r("resetPassword.submit","Reset Password")})]})})]})}export{oe as PasswordResetCallback};
|
|
@@ -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,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,cAAc,wBAAwB,CAAC"}
|
|
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,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,cAAc,wBAAwB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./AuthFallback";import{default as e}from"./EmailPasswordForm";import{default as f}from"./AuthPartnerButton";import{default as
|
|
1
|
+
export*from"./AuthFallback";import{default as e}from"./EmailPasswordForm";import{default as f}from"./AuthPartnerButton";import{default as s}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 w}from"./MultipleAuthProviders";import{default as g}from"./NetworkStatusIndicator";import{default as A}from"./PasswordUpdateDialog";import{PasswordResetCallback as E}from"./PasswordResetCallback";import{PasswordStrengthIndicator as L}from"./PasswordStrengthIndicator";import{default as R}from"./RateLimitAlert";export*from"./DeleteAccountDialogs";export{f as AuthPartnerButton,e as EmailPasswordForm,s as EmailVerification,u as GoogleOneTap,n as LoginModal,w as MultipleAuthProviders,g as NetworkStatusIndicator,E as PasswordResetCallback,L as PasswordStrengthIndicator,A as PasswordUpdateDialog,R as RateLimitAlert};
|
package/dist/constants.d.ts
CHANGED
|
@@ -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
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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;IAC5C,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,I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kB;IAC7C,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;CAClD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;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/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';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,eAAe,CAAC;AAG9D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,qBAAqB,EAAE,gDAAgD;AACvE,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,SAAS,EAAE,wCAAwC;AACnD,QAAQ,IAAI,IAAI,EAAE,oDAAoD;AACtE,QAAQ,EACR,gBAAgB,GACjB,MAAM,gBAAgB,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"}
|
|
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,eAAe,CAAC;AAG9D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,qBAAqB,EAAE,gDAAgD;AACvE,qBAAqB,EACrB,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,SAAS,EAAE,wCAAwC;AACnD,QAAQ,IAAI,IAAI,EAAE,oDAAoD;AACtE,QAAQ,EACR,gBAAgB,GACjB,MAAM,gBAAgB,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
|
|
1
|
+
import{useAuth as o}from"./useAuth";import{useDeleteAccount as u}from"./hooks/useDeleteAccount";import{getAuthState as A,subscribeToAuth as l}from"./authHelpers";import{AuthPartnerButton as s,ConfirmDeleteDialog as T,FeatureGuard as i,GoogleOneTap as p,LoginModal as f,MultipleAuthProviders as g,PasswordResetCallback as m,ReauthDialog as n}from"./components";import{getAuthMethod as x,PARTNER_STATE as R,EMAIL_VERIFICATION_STATUS as c}from"./constants";export{s as AuthPartnerButton,T as ConfirmDeleteDialog,c as EMAIL_VERIFICATION_STATUS,i as FeatureGuard,p as GoogleOneTap,f as LoginModal,g as MultipleAuthProviders,R as PARTNER_STATE,m as PasswordResetCallback,n as ReauthDialog,x as getAuthMethod,A as getAuthState,l as subscribeToAuth,o as useAuth,u 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}"}
|