@donotdev/auth 0.0.6 → 0.0.8

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 (49) hide show
  1. package/dist/AuthStore.d.ts.map +1 -1
  2. package/dist/AuthStore.js +1 -1
  3. package/dist/FirebaseAccountLinking.d.ts.map +1 -1
  4. package/dist/FirebaseAccountLinking.js +1 -1
  5. package/dist/FirebaseAuth.d.ts +17 -2
  6. package/dist/FirebaseAuth.d.ts.map +1 -1
  7. package/dist/FirebaseAuth.js +1 -1
  8. package/dist/FirebaseSmartRecovery.d.ts.map +1 -1
  9. package/dist/FirebaseSmartRecovery.js +1 -1
  10. package/dist/components/AccountLinking.d.ts.map +1 -1
  11. package/dist/components/AccountLinking.js +1 -1
  12. package/dist/components/AuthPartnerButton.d.ts.map +1 -1
  13. package/dist/components/AuthPartnerButton.js +2 -2
  14. package/dist/components/DeleteAccountDialogs.js +1 -1
  15. package/dist/components/EmailLinkForm.js +1 -1
  16. package/dist/components/EmailPasswordForm.d.ts.map +1 -1
  17. package/dist/components/EmailPasswordForm.js +1 -1
  18. package/dist/components/EmailVerification.d.ts.map +1 -1
  19. package/dist/components/EmailVerification.js +1 -1
  20. package/dist/components/FeatureGuard.d.ts +1 -1
  21. package/dist/components/FeatureGuard.d.ts.map +1 -1
  22. package/dist/components/FeatureGuard.js +1 -1
  23. package/dist/components/GoogleOneTap.js +1 -1
  24. package/dist/components/MultipleAuthProviders.d.ts +1 -0
  25. package/dist/components/MultipleAuthProviders.d.ts.map +1 -1
  26. package/dist/components/MultipleAuthProviders.js +1 -1
  27. package/dist/components/NetworkStatusIndicator.js +1 -1
  28. package/dist/components/PasswordUpdateDialog.js +1 -1
  29. package/dist/components/__tests__/MultipleAuthProviders.test.d.ts +2 -0
  30. package/dist/components/__tests__/MultipleAuthProviders.test.d.ts.map +1 -0
  31. package/dist/components/__tests__/MultipleAuthProviders.test.js +1 -0
  32. package/dist/constants.d.ts +0 -40
  33. package/dist/constants.d.ts.map +1 -1
  34. package/dist/constants.js +1 -1
  35. package/dist/hooks/useAccountLinking.d.ts.map +1 -1
  36. package/dist/hooks/useAccountLinking.js +1 -1
  37. package/dist/hooks/useEmailLinkAuth.d.ts.map +1 -1
  38. package/dist/hooks/useEmailLinkAuth.js +1 -1
  39. package/dist/hooks/useFedCM.d.ts.map +1 -1
  40. package/dist/hooks/useFedCM.js +1 -1
  41. package/dist/hooks/useGoogleOneTap.d.ts.map +1 -1
  42. package/dist/hooks/useGoogleOneTap.js +1 -1
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/dist/useAuth.d.ts.map +1 -1
  48. package/dist/useAuth.js +1 -1
  49. package/package.json +6 -6
@@ -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;AA0BxB,eAAO,MAAM,YAAY,iIA6LvB,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;AA0BxB,eAAO,MAAM,YAAY,iIAyLvB,CAAC"}
package/dist/AuthStore.js CHANGED
@@ -1 +1 @@
1
- import{createDoNotDevStore as o,FEATURE_STATUS as l}from"@donotdev/core";import{PARTNER_STATE as n}from"./constants";const i={user:null,authenticated:!1,userId:null,loading:!1,error:null,userProfile:null,userSubscription:null,partnerStates:{},partnerError:null,authService:null,emailVerification:{status:"pending"},status:l.INITIALIZING},S=o({name:"auth-store",createStore:(t,u)=>({...i,setStatus:r=>{t({status:r})},setPartnerState:(r,e,s)=>{t(a=>({partnerStates:{...a.partnerStates,[r]:e},partnerError:e==="error"&&s?{partnerId:r,error:s}:a.partnerError?.partnerId===r?null:a.partnerError}))},getPartnerState:r=>u().partnerStates[r]||n.IDLE,clearAllPartnerStates:()=>t(r=>({partnerStates:Object.keys(r.partnerStates).reduce((e,s)=>(e[s]=n.IDLE,e),{}),partnerError:null})),setAuthenticated:(r,e,s)=>{t({user:r,authenticated:!0,userId:r.id,loading:!1,error:null,status:l.READY,userSubscription:e,userProfile:s})},setUnauthenticated:()=>{t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:l.READY,userSubscription:null,userProfile:null})},setAuthLoading:r=>{t({loading:r})},setAuthError:r=>{t({error:r,loading:!1})},clearAuthError:()=>{t({error:null})},getCustomClaim:r=>u().getCustomClaimLocal(r),getCustomClaims:()=>u().getCustomClaimsLocal(),setAuthService:r=>t({authService:r}),getCustomClaimLocal:r=>{const e=u();return e.userProfile?.claims&&r in e.userProfile.claims?e.userProfile.claims[r]:e.userProfile&&r in e.userProfile?e.userProfile[r]:e.user&&r in e.user?e.user[r]:null},getCustomClaimsLocal:()=>{const r=u(),e={};return r.userProfile?.claims&&Object.assign(e,r.userProfile.claims),r.userProfile&&Object.assign(e,r.userProfile),r.user&&Object.assign(e,r.user),e},setEmailVerificationStatus:(r,e)=>t({emailVerification:{status:r,error:e}}),setUserProfile:r=>t({userProfile:r}),setUserSubscription:r=>t({userSubscription:r}),setLoading:r=>t({loading:r}),setError:r=>t({error:r}),clearError:()=>t({error:null}),reset:()=>t(i)})});export{S as useAuthStore};
1
+ import{createDoNotDevStore as i,FEATURE_STATUS as l}from"@donotdev/core";import{PARTNER_STATE as n}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"},status:l.INITIALIZING},S=i({name:"auth-store",createStore:(t,s)=>({...o,setStatus:r=>{t({status:r})},setPartnerState:(r,e,a)=>{t(u=>({partnerStates:{...u.partnerStates,[r]:e},partnerError:e==="error"&&a?{partnerId:r,error:a}:u.partnerError?.partnerId===r?null:u.partnerError}))},getPartnerState:r=>s().partnerStates[r]||n.IDLE,clearAllPartnerStates:()=>t(r=>({partnerStates:Object.keys(r.partnerStates).reduce((e,a)=>(e[a]=n.IDLE,e),{}),partnerError:null})),setAuthenticated:(r,e,a)=>{t({user:r,authenticated:!0,userId:r.id,loading:!1,error:null,status:l.READY,userSubscription:e,userProfile:a})},setUnauthenticated:()=>{t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:l.READY,userSubscription:null,userProfile:null})},setAuthLoading:r=>{t({loading:r})},setAuthError:r=>{t({error:r,loading:!1})},clearAuthError:()=>{t({error:null})},getCustomClaim:r=>s().getCustomClaimLocal(r),getCustomClaims:()=>s().getCustomClaimsLocal(),setAuthService:r=>t({authService:r}),getCustomClaimLocal:r=>{const e=s(),a=e.userProfile;return a?.claims&&typeof a.claims=="object"&&r in a.claims?a.claims[r]:a&&typeof a=="object"&&r in a?a[r]:e.user&&typeof e.user=="object"&&r in e.user?e.user[r]:null},getCustomClaimsLocal:()=>{const r=s(),e={};return r.userProfile?.claims&&Object.assign(e,r.userProfile.claims),Object.freeze({...e})},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};
@@ -1 +1 @@
1
- {"version":3,"file":"FirebaseAccountLinking.d.ts","sourceRoot":"","sources":["../src/FirebaseAccountLinking.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EAEd,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAiB,KAAK,UAAU,EAAE,MAA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EAAE,OAAO,KAAK,UAAU,CAAC;IAC1E,mBAAmB,EAAE,CACnB,GAAG,EAAE,mBAAmB,EACxB,KAAK,EAAE,GAAG,EACV,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,GAAG,EACV,iBAAiB,EAAE,aAAa,EAChC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA4F5B;AAgMD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C"}
@@ -1 +1 @@
1
- import{toast as r}from"@donotdev/components";import{safeSessionStorage as a}from"@donotdev/core";import{OAuthProvider as g}from"@donotdev/firebase";import{getAuthMethod as m}from"./constants";async function v(i,n,c,o){const e=i.customData?.email||i.email;if(!e)throw r("error","Could not determine account email"),i;const l=g.credentialFromError(i);if(l)try{const u=l.toJSON();a.setItem("originalCredential",JSON.stringify(u))}catch{}const t=await o.getExistingProvider(o.sdk,i,e);if(!t)throw r("error","Could not determine existing account type"),i;return t==="password"?await d(e,n,o):t==="emailLink"?await f(e,n,o):n==="password"&&t!=="password"?await p(e,t,c,o):n==="emailLink"&&t!=="emailLink"?await h(e,t,c,o):await k(e,t,c,n,o)}async function d(i,n,c){const o={email:i,existingProvider:"password",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(o)),r("info",`Please sign in with your password to link your ${n} account`),null}async function f(i,n,c){const o={email:i,existingProvider:"emailLink",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(o)),r("info",`Please check your email for a sign-in link to link your ${n} account`),null}async function k(i,n,c,o,e){r("info",`Account linking required. Signing you in with ${n} to link your ${o} account...`);const l={email:i,existingProvider:n,newProvider:o,timestamp:Date.now()};a.setItem("accountLinkingInfo",JSON.stringify(l));const t=e.createProviderFromConfig(n);if(m(c)==="popup"){r("info",`You have an existing ${n} account. Opening popup to link accounts...`);try{const s=await e.sdk.signInWithPopup(t);return e.createAuthResult(s.user,!1)}catch(s){throw s.code==="auth/popup-blocked"||s.code==="auth/popup-closed-by-user"?(r("error","Popup was blocked. Please allow popups for this site and try again, or use a different browser."),a.removeItem("accountLinkingInfo"),a.removeItem("originalCredential"),new Error("Popup blocked. Please allow popups to complete account linking in development mode.")):s}}else return r("info",`You have an existing ${n} account. Redirecting to link accounts...`),await e.sdk.signInWithRedirect(t),null}async function p(i,n,c,o){r("info","We can't automatically link password/email accounts. First sign in using your original method, then go to Profile \u2192 Link accounts to connect this provider.");const e={email:i,existingProvider:"password",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(e)),null}async function h(i,n,c,o){r("info","We can't automatically link password/email accounts. First sign in using your original method, then go to Profile \u2192 Link accounts to connect this provider.");const e={email:i,existingProvider:"emailLink",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(e)),null}function O(){a.removeItem("accountLinkingInfo"),a.removeItem("originalCredential")}export{O as clearAccountLinkingState,v as handleOAuthLinking};
1
+ import{toast as r}from"@donotdev/components";import{safeSessionStorage as a,isDev as l}from"@donotdev/core";import{OAuthProvider as f}from"@donotdev/firebase";import{getAuthMethod as m}from"./constants";async function v(i,n,c,o){const t=i.customData?.email||i.email;if(!t)throw l(),r("error","Could not determine account email"),i;const u=f.credentialFromError(i);if(u)try{const g=u.toJSON();a.setItem("originalCredential",JSON.stringify(g))}catch{l()}else l();const e=await o.getExistingProvider(o.sdk,i,t);if(!e)throw r("error","Could not determine existing account type"),i;return e==="password"?await k(t,n,o):e==="emailLink"?await d(t,n,o):n==="password"&&e!=="password"?await h(t,e,c,o):n==="emailLink"&&e!=="emailLink"?await w(t,e,c,o):await p(t,e,c,n,o)}async function k(i,n,c){const o={email:i,existingProvider:"password",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(o)),r("info",`Please sign in with your password to link your ${n} account`),null}async function d(i,n,c){const o={email:i,existingProvider:"emailLink",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(o)),r("info",`Please check your email for a sign-in link to link your ${n} account`),null}async function p(i,n,c,o,t){r("info",`Account linking required. Signing you in with ${n} to link your ${o} account...`);const u={email:i,existingProvider:n,newProvider:o,timestamp:Date.now()};a.setItem("accountLinkingInfo",JSON.stringify(u));const e=t.createProviderFromConfig(n);if(m(c)==="popup"){r("info",`You have an existing ${n} account. Opening popup to link accounts...`);try{const s=await t.sdk.signInWithPopup(e);return t.createAuthResult(s.user,!1)}catch(s){throw l(),s.code==="auth/popup-blocked"||s.code==="auth/popup-closed-by-user"?(r("error","Popup was blocked. Please allow popups for this site and try again, or use a different browser."),a.removeItem("accountLinkingInfo"),a.removeItem("originalCredential"),new Error("Popup blocked. Please allow popups to complete account linking in development mode.")):s}}else return r("info",`You have an existing ${n} account. Redirecting to link accounts...`),await t.sdk.signInWithRedirect(e),null}async function h(i,n,c,o){r("info","We can't automatically link password/email accounts. First sign in using your original method, then go to Profile \u2192 Link accounts to connect this provider.");const t={email:i,existingProvider:"password",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(t)),null}async function w(i,n,c,o){r("info","We can't automatically link password/email accounts. First sign in using your original method, then go to Profile \u2192 Link accounts to connect this provider.");const t={email:i,existingProvider:"emailLink",newProvider:n,timestamp:Date.now()};return a.setItem("accountLinkingInfo",JSON.stringify(t)),null}function P(){a.removeItem("accountLinkingInfo"),a.removeItem("originalCredential")}export{P as clearAccountLinkingState,v as handleOAuthLinking};
@@ -1,4 +1,4 @@
1
- import type { AuthUser, AuthResult, AuthPartnerId, AuthState, AuthActions } from '@donotdev/core';
1
+ import type { AuthUser, AuthResult, AuthPartnerId, AuthProvider, AuthState, AuthActions } from '@donotdev/core';
2
2
  import { type AuthMethod } from './constants';
3
3
  /**
4
4
  * Firebase Authentication class
@@ -7,7 +7,7 @@ import { type AuthMethod } from './constants';
7
7
  * @since 0.0.1
8
8
  * @author AMBROISE PARK Consulting
9
9
  */
10
- export declare class FirebaseAuth {
10
+ export declare class FirebaseAuth implements AuthProvider {
11
11
  private sdk;
12
12
  private initialized;
13
13
  private store;
@@ -135,6 +135,16 @@ export declare class FirebaseAuth {
135
135
  * @throws DoNotDevError if account creation fails (already wrapped)
136
136
  */
137
137
  createUserWithEmail(email: string, password: string): Promise<AuthResult>;
138
+ /** AuthProvider: sign in with email and password (returns AuthUser) */
139
+ signInWithEmailAndPassword(email: string, password: string): Promise<AuthUser>;
140
+ /** AuthProvider: create user with email and password (returns AuthUser) */
141
+ createUserWithEmailAndPassword(email: string, password: string): Promise<AuthUser>;
142
+ /** AuthProvider: update user profile (displayName, photoURL) */
143
+ updateUserProfile(updates: Partial<AuthUser>): Promise<void>;
144
+ /** AuthProvider: get current access token */
145
+ getAccessToken(): Promise<string | null>;
146
+ /** AuthProvider: refresh token and return it */
147
+ refreshToken(): Promise<string | null>;
138
148
  /**
139
149
  * Sign in with OAuth partner
140
150
  *
@@ -493,6 +503,11 @@ export declare class FirebaseAuth {
493
503
  *
494
504
  * @param email - Email address to check
495
505
  * @returns Array of sign-in method strings
506
+ *
507
+ * @deprecated This method enables email enumeration attacks — an attacker can
508
+ * determine whether an email address is registered by calling it. It will be
509
+ * removed in a future version. Use the account linking flow instead
510
+ * (see `handleAccountLinking`).
496
511
  */
497
512
  fetchSignInMethodsForEmail(email: string): Promise<string[]>;
498
513
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"FirebaseAuth.d.ts","sourceRoot":"","sources":["../src/FirebaseAuth.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EAKb,SAAS,EACT,WAAW,EACZ,MAAM,gBAAgB,CAAC;AA6BxB,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAuE7D;;;;;;GAMG;AAC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AM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjE;;OAEG;IACH,wBAAwB,IAAI,IAAI;IAIhC;;;;;OAKG;IACH,cAAc,IAAI,IAAI;IAetB;;;;;;;;;;;;;OAaG;IACG,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAiBlE;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;;;;;;;OAQG;YACW,oBAAoB;IAalC;;;;;;;;;;OAUG;IACH,OAAO,CAAC,wBAAwB;IAyChC;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAsBzB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;;;;;;OASG;IACH,OAAO,CAAC,8BAA8B;IAgDtC;;;;;;;OAOG;IACH,KAAK,IAAI,IAAI;CAUd;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,oBAA4C,CAAC"}
@@ -1 +1 @@
1
- import{toast as h}from"@donotdev/components";import{createSingleton as I,safeSessionStorage as d,handleError as a,isDev as m,isClient as p,ClaimsCache as R,getAuthPartnerIdByFirebaseId as y,getRoleFromClaims as v}from"@donotdev/core";import{AUTH_PARTNERS as k,SUBSCRIPTION_TIERS as P,USER_ROLES as b,createDefaultUserProfile as T}from"@donotdev/core";import{getFirebaseSDK as C,GoogleAuthProvider as L,GithubAuthProvider as N,FacebookAuthProvider as F,TwitterAuthProvider as D,OAuthProvider as w,EmailAuthProvider as M}from"@donotdev/firebase";import{getAuthMethod as S}from"./constants";import{PARTNER_STATE as n,EMAIL_VERIFICATION_STATUS as A}from"./constants";import{handleOAuthLinking as z,clearAccountLinkingState as W}from"./FirebaseAccountLinking";import{handleSmartRecovery as g}from"./FirebaseSmartRecovery";async function U(E,t,e){const i=w.credentialFromError(t),r=t.customData?._tokenResponse?.verifiedProvider?.[0]||i?.providerId||t.customData?.providerId;return r?y(r):null}class O{sdk;initialized=!1;store=null;popupTimeout=null;claimsCache=null;constructor(){this.sdk=C()}setStore(t){this.store=t}get storeState(){if(!this.store)throw new Error("[FirebaseAuth] Store not set. Call setStore() first.");return this.store}async initialize(){if(!this.initialized)try{await this.sdk.initialize();try{await this.processRedirectResult(!0)}catch(t){a(t,{userMessage:"Redirect processing failed",context:{operation:"processRedirectResult"},severity:"warning",showNotification:!1})}this.initialized=!0}catch(t){throw a(t,{userMessage:"Failed to initialize authentication",showNotification:!1})}}async processRedirectResult(t=!1){this.store&&this.store.setLoading(!0);try{const e=new Promise((r,s)=>setTimeout(()=>s(new Error("Redirect check timeout")),1e4)),i=await Promise.race([this.sdk.getRedirectResult(),e]).catch(r=>{if(r.message==="Redirect check timeout")return null;throw r});i?.user&&(await this.handleAuthStateChange(i.user),await this.checkPendingLinking(),d.removeItem("pendingAuthPartnerId"),h("success","Signed in successfully!"))}catch(e){if(e.code==="auth/account-exists-with-different-credential"){const i=w.credentialFromError(e)?.providerId||e.customData?._tokenResponse?.providerId,r=i?y(i):d.getItem("pendingAuthPartnerId");if(r)try{await g(e,()=>Promise.resolve(),{partnerId:r,method:"redirect"},this.getSmartRecoveryDeps());return}catch(s){a(s,{userMessage:"Failed to link accounts. Please try again.",showNotification:!t})}}if(a(e,{userMessage:"Authentication failed. Please try again.",showNotification:!t,context:{operation:"processRedirectResult"}}),e.code!=="auth/account-exists-with-different-credential")try{this.clearAccountLinkingState(),d.removeItem("pendingAuthPartnerId")}catch(i){a(i)}}finally{this.store&&this.store.setLoading(!1)}}ensureInitialized(){if(!this.initialized)throw new Error("FirebaseAuth not initialized. Call initialize() first.")}getAppConfig(){if(typeof globalThis<"u"){const t=globalThis._DNDEV_APP_CONFIG_;if(t)return t}return null}initializeClaimsCache(){if(this.claimsCache)return;const e=this.getAppConfig()?.features?.offlineTrustEnabled??!1;this.claimsCache=new R({offlineTrustEnabled:e,userId:this.storeState?.userId??null})}onAuthStateChanged(t){return this.sdk.onAuthStateChanged(async e=>{e?await this.handleAuthStateChange(e):this.handleSignOut(),e&&await this.checkPendingLinking();const i=e?this.convertToAuthUser(e):null;t(i)})}async handleAuthStateChange(t){if(!this.store)return;const e=this.convertToAuthUser(t);this.initializeClaimsCache(),this.claimsCache&&this.claimsCache.setUserId(e.id),this.storeState.clearAllPartnerStates();let i={userId:e.id,tier:P.FREE,status:"active",isActive:!0,features:[],subscriptionId:null,customerId:e.id,subscriptionEnd:null,cancelAtPeriodEnd:!1,updatedAt:new Date().toISOString()},r=b.USER;try{const u=(await this.sdk.getIdTokenResult(t,!0))?.claims||{};if(m(),u.subscription){const c=u.subscription;i={userId:e.id,tier:c.tier||P.FREE,status:c.status||"active",isActive:c.status==="active",features:c.features||[],subscriptionId:c.subscriptionId||null,customerId:c.customerId||e.id,subscriptionEnd:c.subscriptionEnd||null,cancelAtPeriodEnd:!!c.cancelAtPeriodEnd,updatedAt:c.updatedAt||new Date().toISOString()}}r=v(u),m()}catch(o){o?.code==="auth/network-request-failed"||o?.originalCode==="auth/network-request-failed"||o?.message?.includes("network")||a(o,{userMessage:"Failed to get custom claims",context:{operation:"getCustomClaims"},severity:"warning"})}e.role=r,m();const s={...T(e.id),role:r};m(),this.storeState.setAuthenticated(e,i,s)}handleSignOut(){this.store&&(this.claimsCache&&this.claimsCache.setUserId(null),this.storeState.clearAllPartnerStates(),this.storeState.setUnauthenticated())}async signInWithEmail(t,e){this.ensureInitialized(),this.storeState.setPartnerState("password",n.LOADING);try{const i=await this.sdk.signInWithEmail(t,e);return h("success","Signed in successfully!"),this.storeState.setPartnerState("password",n.IDLE),this.createAuthResult(i.user)}catch(i){try{return await g(i,()=>this.sdk.signInWithEmail(t,e),{email:t,partnerId:"password"},this.getSmartRecoveryDeps())}catch(r){throw this.storeState.setPartnerState("password",n.ERROR),r}}}async createUserWithEmail(t,e){this.ensureInitialized(),this.storeState.setPartnerState("password",n.LOADING);try{const i=await this.sdk.createUserWithEmail(t,e);return h("success","Account created successfully!"),this.storeState.setPartnerState("password",n.IDLE),this.createAuthResult(i.user,!0)}catch(i){try{const r=await g(i,()=>this.sdk.createUserWithEmail(t,e),{email:t,partnerId:"password"},this.getSmartRecoveryDeps());if(!r)throw new Error("Account creation failed");return r}catch(r){throw this.storeState.setPartnerState("password",n.ERROR),r}}}async signInWithPartner(t,e){const i=S(e);this.ensureInitialized(),this.storeState.setPartnerState(t,n.LOADING);try{const r=this.createProviderFromConfig(t);let s;return i==="popup"?(s=await this.handlePopupAuth(t,async()=>await this.sdk.signInWithPopup(r)),s===null?(this.storeState.setPartnerState(t,n.IDLE),null):(h("success","Signed in successfully!"),this.storeState.setPartnerState(t,n.IDLE),this.createAuthResult(s.user))):(d.setItem("pendingAuthPartnerId",t),await this.sdk.signInWithRedirect(r),null)}catch(r){try{const s=await g(r,()=>{const o=this.createProviderFromConfig(t);return i==="popup"?this.sdk.signInWithPopup(o):this.sdk.signInWithRedirect(o)},{partnerId:t,method:i},this.getSmartRecoveryDeps());return s===null?(this.storeState.setPartnerState(t,n.IDLE),null):s}catch(s){throw this.storeState.setPartnerState(t,n.ERROR),s}}}async linkWithPartner(t,e){const i=S(e);this.ensureInitialized();const r=this.sdk.getCurrentUser();if(!r)throw a(new Error("No authenticated user"),{userMessage:"You must be signed in to link accounts",context:{operation:"linkWithPartner",partnerId:t},showNotification:!0});this.storeState.setPartnerState(t,n.LOADING);try{const s=this.createProviderFromConfig(t);if(i==="popup"){const o=await this.sdk.linkWithPopup(r,s);return h("success",`Successfully linked ${t} account!`),this.storeState.setPartnerState(t,n.IDLE),this.createAuthResult(o.user)}else return await this.sdk.linkWithRedirect(r,s),null}catch(s){const o=s;let u="Failed to link account",c={operation:"linkWithPartner",partnerId:t,errorCode:o.code};switch(o.code){case"auth/operation-not-allowed":u="Account linking is disabled. Contact support for assistance.";break;case"auth/provider-already-linked":u="This account is already linked to your profile.";break;case"auth/credential-already-in-use":u="This account is already linked to another profile.";break;case"auth/requires-recent-login":u="Please sign out and sign back in, then try linking again.";break;default:u=`Failed to link ${t} account. Please try again.`}throw this.storeState.setPartnerState(t,n.ERROR),a(s,{userMessage:u,context:c,showNotification:!0})}}async handlePopupAuth(t,e){this.clearPopupMonitoring(),this.popupTimeout=setTimeout(()=>{this.storeState.setPartnerState(t,n.IDLE),this.clearPopupMonitoring()},3e4);try{const i=await e();return this.clearPopupMonitoring(),i}catch(i){if(this.clearPopupMonitoring(),i.code==="auth/popup-closed-by-user"||i.code==="auth/cancelled-popup-request")return null;throw i}}clearPopupMonitoring(){this.popupTimeout&&(clearTimeout(this.popupTimeout),this.popupTimeout=null)}async signInWithGoogleCredential(t){this.ensureInitialized(),this.storeState.setPartnerState("google",n.LOADING);try{const e=await this.sdk.signInWithGoogleCredential(t);return h("success","Signed in with Google!"),this.storeState.setPartnerState("google",n.IDLE),this.createAuthResult(e.user)}catch(e){try{return await g(e,()=>this.sdk.signInWithGoogleCredential(t),{partnerId:"google",method:"redirect"},this.getSmartRecoveryDeps())}catch(i){throw this.storeState.setPartnerState("google",n.ERROR),i}}}async getRedirectResult(){this.ensureInitialized();try{const t=await this.sdk.getRedirectResult();return t?.user?(h("success","Signed in successfully!"),this.createAuthResult(t.user)):null}catch(t){try{return await g(t,()=>this.sdk.getRedirectResult(),{method:"redirect"},this.getSmartRecoveryDeps())}catch(e){throw e}}}async checkPendingLinking(){const t=d.getItem("accountLinkingInfo"),e=d.getItem("originalCredential");if(!(!t||!e))try{const i=JSON.parse(t),r=JSON.parse(e),s=await this.sdk.getCurrentUser();if(!s)return;const o=this.convertToAuthUser(s),u=k[i.newProvider];if(!u)return;if(o.providerData?.some(f=>f.providerId===u.firebaseProviderId)||!1){this.clearAccountLinkingState();return}const l=this.createCredentialFromStoredData(r);if(!l){this.clearAccountLinkingState();return}await this.sdk.linkWithCredential(s,l),this.clearAccountLinkingState(),h("success","Accounts linked successfully!")}catch(i){throw this.clearAccountLinkingState(),a(i,{userMessage:"Account linking failed",showNotification:!0})}}async sendSignInLinkToEmail(t,e){this.ensureInitialized();try{await this.sdk.sendSignInLinkToEmail(t,e||{url:"",handleCodeInApp:!1}),h("success","Sign-in link sent to your email!")}catch(i){throw a(i,{userMessage:"Failed to send sign-in link",showNotification:!0})}}async signInWithEmailLink(t,e){this.ensureInitialized(),this.storeState.setPartnerState("emailLink",n.LOADING);try{const i=await this.sdk.signInWithEmailLink(t,e);return h("success","Signed in successfully!"),this.storeState.setPartnerState("emailLink",n.IDLE),this.createAuthResult(i.user)}catch(i){try{return await g(i,()=>this.sdk.signInWithEmailLink(t,e),{email:t,partnerId:"emailLink"},this.getSmartRecoveryDeps())}catch(r){throw this.storeState.setPartnerState("emailLink",n.ERROR),r}}}isSignInWithEmailLink(t){if(!t&&!p())return!1;const e=t||(p()?window.location.href:"");return this.sdk.isSignInWithEmailLink(e)}async sendPasswordResetEmail(t){this.ensureInitialized();try{await this.sdk.sendPasswordResetEmail(t),h("success","Password reset email sent!")}catch(e){throw a(e,{userMessage:"Failed to send password reset email",showNotification:!0})}}async updatePassword(t){this.ensureInitialized();const e=await this.sdk.getCurrentUser();if(!e)throw a(new Error("No authenticated user"),{userMessage:"You must be signed in to update your password",showNotification:!0});try{await this.sdk.updatePassword(e,t),h("success","Password updated successfully!")}catch(i){throw a(i,{userMessage:"Failed to update password",showNotification:!0})}}async sendEmailVerification(){this.ensureInitialized();const t=await this.sdk.getCurrentUser();if(!t)throw a(new Error("No authenticated user"),{userMessage:"You must be signed in to verify your email",showNotification:!0});try{this.storeState.setEmailVerificationStatus(A.PENDING),await this.sdk.sendEmailVerification(t),h("success","Verification email sent!")}catch(e){throw this.storeState.setEmailVerificationStatus(A.PENDING),a(e,{userMessage:"Failed to send verification email",showNotification:!0})}}async getEmailVerificationStatus(){this.ensureInitialized();const t=await this.sdk.getCurrentUser();return t?{status:t.emailVerified?"verified":"pending"}:{status:"pending",error:"No authenticated user"}}async isEmailVerificationEnabled(){return!0}async getIdTokenResult(t=!1){this.ensureInitialized();const e=await this.sdk.getCurrentUser();if(!e)return null;try{return await this.sdk.getIdTokenResult(e,t)}catch(i){throw a(i,{userMessage:"Failed to get authentication token"})}}async getCustomClaims(){this.ensureInitialized(),this.initializeClaimsCache();const t=await this.sdk.getCurrentUser();if(!t)return{};if(!this.claimsCache)try{return(await this.sdk.getIdTokenResult(t,!0))?.claims||{}}catch(e){throw a(e,{userMessage:"Failed to get user permissions"})}return this.claimsCache.getClaims(async()=>(await this.sdk.getIdTokenResult(t,!0))?.claims||{})}async getCustomClaim(t){this.ensureInitialized();try{return(await this.getCustomClaims())[t]||null}catch(e){throw a(e,{userMessage:"Failed to get user permission"})}}async hasRole(t){this.ensureInitialized();try{const e=await this.getCustomClaim("role");if(this.store&&e){const i=this.storeState.userProfile;i&&this.storeState.setAuthenticated(this.storeState.user,this.storeState.userSubscription,{...i,role:e})}return e===t}catch(e){throw a(e,{userMessage:"Failed to verify user role"})}}async hasTier(t){this.ensureInitialized(),this.initializeClaimsCache();try{const i=(await this.getCustomClaims()).subscription?.tier;if(this.store&&i){const r=this.storeState.userSubscription;r&&this.storeState.setAuthenticated(this.storeState.user,{...r,tier:i},this.storeState.userProfile)}return i===t}catch(e){const r=this.getAppConfig()?.features?.offlineTrustEnabled??!0,s=p()?navigator.onLine:!1;if(!r&&!s)throw a(e,{userMessage:"Failed to verify subscription tier"});return!1}}async hasFeature(t){this.ensureInitialized(),this.initializeClaimsCache();const i=this.storeState.getCustomClaimsLocal()?.features||[],r=Array.isArray(i)&&i.includes(t);if(!this.claimsCache)try{const l=(await this.getCustomClaims()).features||[];return Array.isArray(l)&&l.includes(t)}catch(c){throw a(c,{userMessage:"Failed to verify feature access"})}const s=p()?navigator.onLine:!1,u=this.getAppConfig()?.features?.offlineTrustEnabled??!1;if(s)try{const l=(await this.getCustomClaims()).features||[],f=Array.isArray(l)&&l.includes(t);return f}catch{return r}else return u?r:!1}async getCurrentUser(){const t=await this.sdk.getCurrentUser();return t?this.convertToAuthUser(t):null}async signOut(){this.ensureInitialized(),this.clearPopupMonitoring();try{d.removeItem("accountLinkingInfo"),await this.clearCachedClaims(),await this.sdk.signOut(),h("info","Signed out successfully")}catch(t){throw a(t,{userMessage:"Failed to sign out",showNotification:!0})}}async reauthenticateWithPassword(t){this.ensureInitialized();const e=this.sdk.getCurrentUser();if(!e||!e.email)throw new Error("No authenticated user");try{const i=M.credential(e.email,t);await this.sdk.reauthenticateWithCredential(e,i)}catch(i){throw a(i,{userMessage:"Re-authentication failed. Please check your password.",showNotification:!0})}}async reauthenticateWithProvider(t,e){this.ensureInitialized();const i=this.sdk.getCurrentUser();if(!i)throw new Error("No authenticated user");const r=S(e);try{const s=this.createProviderFromConfig(t);if(r==="popup")await this.sdk.reauthenticateWithPopup(i,s);else{await this.sdk.reauthenticateWithRedirect(i,s);return}}catch(s){throw s.code==="auth/popup-closed-by-user"||s.code==="auth/cancelled-popup-request"||s.code==="auth/popup-blocked"?new Error("REAUTH_CANCELLED"):a(s,{userMessage:"Re-authentication failed. Please try again.",showNotification:!0})}}getPrimaryProvider(t){if(!t.providerData||t.providerData.length===0)return null;const e=t.providerData[0]?.providerId;return e?e==="password"||e==="emailLink"?"password":e.startsWith("google.com")?"google":e.startsWith("github.com")?"github":e.startsWith("microsoft.com")?"microsoft":e.startsWith("apple.com")?"apple":e.startsWith("facebook.com")?"facebook":e.startsWith("twitter.com")?"twitter":null:null}async deleteAccount(t){this.ensureInitialized();const e=this.sdk.getCurrentUser();if(!e)throw new Error("No authenticated user");const i=async()=>{const r=this.getAppConfig()?.auth,s=r&&typeof r=="object"?r.deleteUserFunction:void 0;if(s)try{await s(e.uid)}catch{}await this.sdk.deleteUser(e),h("success","Account deleted successfully")};try{await i()}catch(r){if(r.code==="auth/requires-recent-login"){const s=this.getPrimaryProvider(e);if(!s)throw a(r,{userMessage:"Unable to determine authentication provider",showNotification:!0});if(s!=="password")try{await this.reauthenticateWithProvider(s),await i();return}catch(o){throw o.message==="REAUTH_CANCELLED"?new Error("REAUTH_CANCELLED"):a(o,{userMessage:"Re-authentication failed. Please try again.",showNotification:!0})}if(!t)throw new Error("REQUIRES_PASSWORD");try{await this.reauthenticateWithPassword(t),await i();return}catch(o){throw a(o,{userMessage:"Re-authentication failed. Please check your password.",showNotification:!0})}}throw a(r,{userMessage:"Failed to delete account",showNotification:!0})}}async clearCachedClaims(){this.claimsCache&&await this.claimsCache.clearClaims()}async setCachedClaims(t){this.initializeClaimsCache(),this.claimsCache&&await this.claimsCache.setClaims(t)}clearAccountLinkingState(){W()}resetAuthState(){this.store&&(Object.keys(k).forEach(t=>{this.storeState.setPartnerState(t,n.IDLE)}),this.storeState.clearAuthError())}async fetchSignInMethodsForEmail(t){this.ensureInitialized();try{return await this.sdk.fetchSignInMethodsForEmail(t)}catch(e){throw a(e,{userMessage:"Failed to check sign-in methods"})}}getSmartRecoveryDeps(){return{sdk:this.sdk,handleAccountLinking:this.handleAccountLinking.bind(this),createAuthResult:this.createAuthResult.bind(this)}}getAccountLinkingDeps(){return{sdk:this.sdk,createProviderFromConfig:this.createProviderFromConfig.bind(this),createAuthResult:this.createAuthResult.bind(this),getExistingProvider:U}}async handleAccountLinking(t,e,i){return await z(t,e,i,this.getAccountLinkingDeps())}createProviderFromConfig(t){const e=k[t];if(!e||!e.firebaseProviderId)throw new Error(`Unsupported partner: ${t}`);let i;switch(t){case"google":i=this.sdk.createGoogleProvider();break;case"github":i=this.sdk.createGithubProvider();break;case"facebook":i=this.sdk.createFacebookProvider();break;case"twitter":i=this.sdk.createTwitterProvider();break;case"microsoft":i=this.sdk.createMicrosoftProvider();break;case"apple":i=this.sdk.createAppleProvider();break;default:i=this.sdk.createOAuthProvider(e.firebaseProviderId)}return e.customParameters&&i.setCustomParameters(e.customParameters),e.scopes&&e.scopes.length>0&&e.scopes.forEach(r=>i.addScope(r)),i}convertToAuthUser(t){return{id:t.uid,email:t.email||null,displayName:t.displayName||null,photoURL:t.photoURL||null,emailVerified:t.emailVerified||!1,lastLoginAt:t.metadata.lastSignInTime||new Date().toISOString(),providerData:t.providerData.map(e=>({providerId:e.providerId,uid:e.uid,displayName:e.displayName,email:e.email,photoURL:e.photoURL,phoneNumber:e.phoneNumber}))}}createAuthResult(t,e=!1){return{user:this.convertToAuthUser(t),success:!0,isNewUser:e}}createCredentialFromStoredData(t){try{if(!t||!t.providerId)return null;switch(t.providerId){case"google.com":return L.credential(t.idToken||null,t.accessToken||null);case"github.com":return N.credential(t.accessToken);case"facebook.com":return F.credential(t.accessToken);case"twitter.com":return D.credential(t.accessToken,t.secret||t.oauthTokenSecret);default:return t.idToken?new w(t.providerId).credential({idToken:t.idToken,accessToken:t.accessToken}):t.accessToken?new w(t.providerId).credential({accessToken:t.accessToken}):null}}catch(e){return a(e,{showNotification:!1,severity:"warning",context:{operation:"_getCredentialFromData"}}),null}}reset(){this.initialized=!1,this.sdk=C(),this.store=null,this.popupTimeout&&(clearTimeout(this.popupTimeout),this.popupTimeout=null)}}const j=I(()=>new O);export{O as FirebaseAuth,j as getFirebaseAuth};
1
+ import{toast as l}from"@donotdev/components";import{createSingleton as A,safeSessionStorage as d,handleError as a,isDev as m,isClient as p,ClaimsCache as R,getAuthPartnerIdByFirebaseId as S,getRoleFromClaims as v}from"@donotdev/core";import{AUTH_PARTNERS as k,SUBSCRIPTION_TIERS as P,USER_ROLES as b,createDefaultUserProfile as T}from"@donotdev/core";import{getFirebaseSDK as C,GoogleAuthProvider as L,GithubAuthProvider as N,FacebookAuthProvider as F,TwitterAuthProvider as D,OAuthProvider as w,EmailAuthProvider as U}from"@donotdev/firebase";import{getAuthMethod as y}from"./constants";import{PARTNER_STATE as o,EMAIL_VERIFICATION_STATUS as E}from"./constants";import{handleOAuthLinking as M,clearAccountLinkingState as W}from"./FirebaseAccountLinking";import{handleSmartRecovery as f}from"./FirebaseSmartRecovery";async function z(I,t,e){const i=w.credentialFromError(t),r=t.customData?._tokenResponse?.verifiedProvider?.[0]||i?.providerId||t.customData?.providerId;return r?S(r):null}class O{sdk;initialized=!1;store=null;popupTimeout=null;claimsCache=null;constructor(){this.sdk=C()}setStore(t){this.store=t}get storeState(){if(!this.store)throw new Error("[FirebaseAuth] Store not set. Call setStore() first.");return this.store}async initialize(){if(!this.initialized)try{await this.sdk.initialize();try{await this.processRedirectResult(!0)}catch(t){a(t,{userMessage:"Redirect processing failed",context:{operation:"processRedirectResult"},severity:"warning",showNotification:!1})}this.initialized=!0}catch(t){throw a(t,{userMessage:"Failed to initialize authentication",showNotification:!1})}}async processRedirectResult(t=!1){this.store&&this.store.setLoading(!0);try{const e=new Promise((r,s)=>setTimeout(()=>s(new Error("Redirect check timeout")),1e4)),i=await Promise.race([this.sdk.getRedirectResult(),e]).catch(r=>{if(r.message==="Redirect check timeout")return null;throw r});i?.user&&(await this.handleAuthStateChange(i.user),await this.checkPendingLinking(),d.removeItem("pendingAuthPartnerId"),l("success","Signed in successfully!"))}catch(e){if(e.code==="auth/account-exists-with-different-credential"){const i=w.credentialFromError(e)?.providerId||e.customData?._tokenResponse?.providerId,r=i?S(i):d.getItem("pendingAuthPartnerId");if(r)try{await f(e,()=>Promise.resolve(),{partnerId:r,method:"redirect"},this.getSmartRecoveryDeps());return}catch(s){a(s,{userMessage:"Failed to link accounts. Please try again.",showNotification:!t})}}if(a(e,{userMessage:"Authentication failed. Please try again.",showNotification:!t,context:{operation:"processRedirectResult"}}),e.code!=="auth/account-exists-with-different-credential")try{this.clearAccountLinkingState(),d.removeItem("pendingAuthPartnerId")}catch(i){a(i)}}finally{this.store&&this.store.setLoading(!1)}}ensureInitialized(){if(!this.initialized)throw new Error("FirebaseAuth not initialized. Call initialize() first.")}getAppConfig(){if(typeof globalThis<"u"){const t=globalThis._DNDEV_APP_CONFIG_;if(t)return t}return null}initializeClaimsCache(){if(this.claimsCache)return;const e=this.getAppConfig()?.features?.offlineTrustEnabled??!1;this.claimsCache=new R({offlineTrustEnabled:e,userId:this.storeState?.userId??null})}onAuthStateChanged(t){return this.sdk.onAuthStateChanged(async e=>{e?await this.handleAuthStateChange(e):this.handleSignOut(),e&&await this.checkPendingLinking();const i=e?this.convertToAuthUser(e):null;t(i)})}async handleAuthStateChange(t){if(!this.store)return;const e=this.convertToAuthUser(t);this.initializeClaimsCache(),this.claimsCache&&this.claimsCache.setUserId(e.id),this.storeState.clearAllPartnerStates();let i={userId:e.id,tier:P.FREE,status:"active",isActive:!0,features:[],subscriptionId:null,customerId:e.id,subscriptionEnd:null,cancelAtPeriodEnd:!1,updatedAt:new Date().toISOString()},r=b.USER;try{const u=(await this.sdk.getIdTokenResult(t,!0))?.claims||{};if(m(),u.subscription){const c=u.subscription;i={userId:e.id,tier:c.tier||P.FREE,status:c.status||"active",isActive:c.status==="active",features:c.features||[],subscriptionId:c.subscriptionId||null,customerId:c.customerId||e.id,subscriptionEnd:c.subscriptionEnd||null,cancelAtPeriodEnd:!!c.cancelAtPeriodEnd,updatedAt:c.updatedAt||new Date().toISOString()}}r=v(u),m()}catch(n){n?.code==="auth/network-request-failed"||n?.originalCode==="auth/network-request-failed"||n?.message?.includes("network")||a(n,{userMessage:"Failed to get custom claims",context:{operation:"getCustomClaims"},severity:"warning"})}e.role=r,m();const s={...T(e.id),role:r};m(),this.storeState.setAuthenticated(e,i,s)}handleSignOut(){this.store&&(this.claimsCache&&this.claimsCache.setUserId(null),this.storeState.clearAllPartnerStates(),this.storeState.setUnauthenticated())}async signInWithEmail(t,e){this.ensureInitialized(),this.storeState.setPartnerState("password",o.LOADING);try{const i=await this.sdk.signInWithEmail(t,e);return l("success","Signed in successfully!"),this.storeState.setPartnerState("password",o.IDLE),this.createAuthResult(i.user)}catch(i){try{return await f(i,()=>this.sdk.signInWithEmail(t,e),{email:t,partnerId:"password"},this.getSmartRecoveryDeps())}catch(r){throw this.storeState.setPartnerState("password",o.ERROR),r}}}async createUserWithEmail(t,e){this.ensureInitialized(),this.storeState.setPartnerState("password",o.LOADING);try{const i=await this.sdk.createUserWithEmail(t,e);return l("success","Account created successfully!"),this.storeState.setPartnerState("password",o.IDLE),this.createAuthResult(i.user,!0)}catch(i){try{const r=await f(i,()=>this.sdk.createUserWithEmail(t,e),{email:t,partnerId:"password"},this.getSmartRecoveryDeps());if(!r)throw new Error("Account creation failed");return r}catch(r){throw this.storeState.setPartnerState("password",o.ERROR),r}}}async signInWithEmailAndPassword(t,e){const i=await this.signInWithEmail(t,e);if(!i)throw new Error("Sign in did not return a result");return i.user}async createUserWithEmailAndPassword(t,e){return(await this.createUserWithEmail(t,e)).user}async updateUserProfile(t){this.ensureInitialized();const e=await this.sdk.getCurrentUser();if(!e)return;const i={};t.displayName!==void 0&&(i.displayName=t.displayName),t.photoURL!==void 0&&(i.photoURL=t.photoURL),Object.keys(i).length!==0&&await this.sdk.updateProfile(e,i)}async getAccessToken(){const t=await this.sdk.getCurrentUser();if(!t)return null;try{return await this.sdk.getIdToken(t,!1)}catch{return null}}async refreshToken(){const t=await this.sdk.getCurrentUser();if(!t)return null;try{return await this.sdk.getIdToken(t,!0)}catch{return null}}async signInWithPartner(t,e){const i=y(e);this.ensureInitialized(),this.storeState.setPartnerState(t,o.LOADING);try{const r=this.createProviderFromConfig(t);let s;return i==="popup"?(s=await this.handlePopupAuth(t,async()=>await this.sdk.signInWithPopup(r)),s===null?(this.storeState.setPartnerState(t,o.IDLE),null):(l("success","Signed in successfully!"),this.storeState.setPartnerState(t,o.IDLE),this.createAuthResult(s.user))):(d.setItem("pendingAuthPartnerId",t),await this.sdk.signInWithRedirect(r),null)}catch(r){try{const s=await f(r,()=>{const n=this.createProviderFromConfig(t);return i==="popup"?this.sdk.signInWithPopup(n):this.sdk.signInWithRedirect(n)},{partnerId:t,method:i},this.getSmartRecoveryDeps());return s===null?(this.storeState.setPartnerState(t,o.IDLE),null):s}catch(s){throw this.storeState.setPartnerState(t,o.ERROR),s}}}async linkWithPartner(t,e){const i=y(e);this.ensureInitialized();const r=await this.sdk.getCurrentUser();if(!r)throw a(new Error("No authenticated user"),{userMessage:"You must be signed in to link accounts",context:{operation:"linkWithPartner",partnerId:t},showNotification:!0});this.storeState.setPartnerState(t,o.LOADING);try{const s=this.createProviderFromConfig(t);if(i==="popup"){const n=await this.sdk.linkWithPopup(r,s);return l("success",`Successfully linked ${t} account!`),this.storeState.setPartnerState(t,o.IDLE),this.createAuthResult(n.user)}else return await this.sdk.linkWithRedirect(r,s),null}catch(s){const n=s;let u="Failed to link account",c={operation:"linkWithPartner",partnerId:t,errorCode:n.code};switch(n.code){case"auth/operation-not-allowed":u="Account linking is disabled. Contact support for assistance.";break;case"auth/provider-already-linked":u="This account is already linked to your profile.";break;case"auth/credential-already-in-use":u="This account is already linked to another profile.";break;case"auth/requires-recent-login":u="Please sign out and sign back in, then try linking again.";break;default:u=`Failed to link ${t} account. Please try again.`}throw this.storeState.setPartnerState(t,o.ERROR),a(s,{userMessage:u,context:c,showNotification:!0})}}async handlePopupAuth(t,e){this.clearPopupMonitoring(),this.popupTimeout=setTimeout(()=>{this.storeState.setPartnerState(t,o.IDLE),this.clearPopupMonitoring()},3e4);try{const i=await e();return this.clearPopupMonitoring(),i}catch(i){if(this.clearPopupMonitoring(),i.code==="auth/popup-closed-by-user"||i.code==="auth/cancelled-popup-request")return null;throw i}}clearPopupMonitoring(){this.popupTimeout&&(clearTimeout(this.popupTimeout),this.popupTimeout=null)}async signInWithGoogleCredential(t){this.ensureInitialized(),this.storeState.setPartnerState("google",o.LOADING);try{const e=await this.sdk.signInWithGoogleCredential(t);return l("success","Signed in with Google!"),this.storeState.setPartnerState("google",o.IDLE),this.createAuthResult(e.user)}catch(e){try{return await f(e,()=>this.sdk.signInWithGoogleCredential(t),{partnerId:"google",method:"redirect"},this.getSmartRecoveryDeps())}catch(i){throw this.storeState.setPartnerState("google",o.ERROR),i}}}async getRedirectResult(){this.ensureInitialized();try{const t=await this.sdk.getRedirectResult();return t?.user?(l("success","Signed in successfully!"),this.createAuthResult(t.user)):null}catch(t){try{return await f(t,()=>this.sdk.getRedirectResult(),{method:"redirect"},this.getSmartRecoveryDeps())}catch(e){throw e}}}async checkPendingLinking(){const t=d.getItem("accountLinkingInfo"),e=d.getItem("originalCredential");if(!(!t||!e))try{const i=JSON.parse(t),r=JSON.parse(e),s=await this.sdk.getCurrentUser();if(!s)return;const n=this.convertToAuthUser(s),u=k[i.newProvider];if(!u)return;if(n.providerData?.some(g=>g.providerId===u.firebaseProviderId)||!1){this.clearAccountLinkingState();return}const h=this.createCredentialFromStoredData(r);if(!h){this.clearAccountLinkingState();return}await this.sdk.linkWithCredential(s,h),this.clearAccountLinkingState(),l("success","Accounts linked successfully!")}catch(i){throw this.clearAccountLinkingState(),a(i,{userMessage:"Account linking failed",showNotification:!0})}}async sendSignInLinkToEmail(t,e){this.ensureInitialized();try{await this.sdk.sendSignInLinkToEmail(t,e||{url:"",handleCodeInApp:!1}),l("success","Sign-in link sent to your email!")}catch(i){throw a(i,{userMessage:"Failed to send sign-in link",showNotification:!0})}}async signInWithEmailLink(t,e){this.ensureInitialized(),this.storeState.setPartnerState("emailLink",o.LOADING);try{const i=await this.sdk.signInWithEmailLink(t,e);return l("success","Signed in successfully!"),this.storeState.setPartnerState("emailLink",o.IDLE),this.createAuthResult(i.user)}catch(i){try{return await f(i,()=>this.sdk.signInWithEmailLink(t,e),{email:t,partnerId:"emailLink"},this.getSmartRecoveryDeps())}catch(r){throw this.storeState.setPartnerState("emailLink",o.ERROR),r}}}isSignInWithEmailLink(t){if(!t&&!p())return!1;const e=t||(p()?window.location.href:"");return this.sdk.isSignInWithEmailLink(e)}async sendPasswordResetEmail(t){this.ensureInitialized();try{await this.sdk.sendPasswordResetEmail(t),l("success","Password reset email sent!")}catch(e){throw a(e,{userMessage:"Failed to send password reset email",showNotification:!0})}}async updatePassword(t){this.ensureInitialized();const e=await this.sdk.getCurrentUser();if(!e)throw a(new Error("No authenticated user"),{userMessage:"You must be signed in to update your password",showNotification:!0});try{await this.sdk.updatePassword(e,t),l("success","Password updated successfully!")}catch(i){throw a(i,{userMessage:"Failed to update password",showNotification:!0})}}async sendEmailVerification(){this.ensureInitialized();const t=await this.sdk.getCurrentUser();if(!t)throw a(new Error("No authenticated user"),{userMessage:"You must be signed in to verify your email",showNotification:!0});try{this.storeState.setEmailVerificationStatus(E.PENDING),await this.sdk.sendEmailVerification(t),l("success","Verification email sent!")}catch(e){throw this.storeState.setEmailVerificationStatus(E.PENDING),a(e,{userMessage:"Failed to send verification email",showNotification:!0})}}async getEmailVerificationStatus(){this.ensureInitialized();const t=await this.sdk.getCurrentUser();return t?{status:t.emailVerified?"verified":"pending"}:{status:"pending",error:"No authenticated user"}}async isEmailVerificationEnabled(){return!0}async getIdTokenResult(t=!1){this.ensureInitialized();const e=await this.sdk.getCurrentUser();if(!e)return null;try{return await this.sdk.getIdTokenResult(e,t)}catch(i){throw a(i,{userMessage:"Failed to get authentication token"})}}async getCustomClaims(){this.ensureInitialized(),this.initializeClaimsCache();const t=await this.sdk.getCurrentUser();if(!t)return{};if(!this.claimsCache)try{return(await this.sdk.getIdTokenResult(t,!0))?.claims||{}}catch(e){throw a(e,{userMessage:"Failed to get user permissions"})}return this.claimsCache.getClaims(async()=>(await this.sdk.getIdTokenResult(t,!0))?.claims||{})}async getCustomClaim(t){this.ensureInitialized();try{return(await this.getCustomClaims())[t]??null}catch(e){throw a(e,{userMessage:"Failed to get user permission"})}}async hasRole(t){this.ensureInitialized();try{const e=await this.getCustomClaim("role");if(this.store&&e){const i=this.storeState.userProfile;i&&this.storeState.setAuthenticated(this.storeState.user,this.storeState.userSubscription,{...i,role:e})}return e===t}catch(e){throw a(e,{userMessage:"Failed to verify user role"})}}async hasTier(t){this.ensureInitialized(),this.initializeClaimsCache();try{const i=(await this.getCustomClaims()).subscription?.tier;if(this.store&&i){const r=this.storeState.userSubscription;r&&this.storeState.setAuthenticated(this.storeState.user,{...r,tier:i},this.storeState.userProfile)}return i===t}catch(e){const r=this.getAppConfig()?.features?.offlineTrustEnabled??!1,s=p()?navigator.onLine:!1;if(!r&&!s)throw a(e,{userMessage:"Failed to verify subscription tier"});return!1}}async hasFeature(t){this.ensureInitialized(),this.initializeClaimsCache();const i=this.storeState.getCustomClaimsLocal()?.features||[],r=Array.isArray(i)&&i.includes(t);if(!this.claimsCache)try{const h=(await this.getCustomClaims()).features||[];return Array.isArray(h)&&h.includes(t)}catch(c){throw a(c,{userMessage:"Failed to verify feature access"})}const s=p()?navigator.onLine:!1,u=this.getAppConfig()?.features?.offlineTrustEnabled??!1;if(s)try{const h=(await this.getCustomClaims()).features||[],g=Array.isArray(h)&&h.includes(t);return g}catch{return r}else return u?r:!1}async getCurrentUser(){const t=await this.sdk.getCurrentUser();return t?this.convertToAuthUser(t):null}async signOut(){this.ensureInitialized(),this.clearPopupMonitoring();try{d.removeItem("accountLinkingInfo"),await this.clearCachedClaims(),await this.sdk.signOut(),l("info","Signed out successfully")}catch(t){throw a(t,{userMessage:"Failed to sign out",showNotification:!0})}}async reauthenticateWithPassword(t){this.ensureInitialized();const e=await this.sdk.getCurrentUser();if(!e||!e.email)throw new Error("No authenticated user");try{const i=U.credential(e.email,t);await this.sdk.reauthenticateWithCredential(e,i)}catch(i){throw a(i,{userMessage:"Re-authentication failed. Please check your password.",showNotification:!0})}}async reauthenticateWithProvider(t,e){this.ensureInitialized();const i=await this.sdk.getCurrentUser();if(!i)throw new Error("No authenticated user");const r=y(e);try{const s=this.createProviderFromConfig(t);if(r==="popup")await this.sdk.reauthenticateWithPopup(i,s);else{await this.sdk.reauthenticateWithRedirect(i,s);return}}catch(s){throw s.code==="auth/popup-closed-by-user"||s.code==="auth/cancelled-popup-request"||s.code==="auth/popup-blocked"?new Error("REAUTH_CANCELLED"):a(s,{userMessage:"Re-authentication failed. Please try again.",showNotification:!0})}}getPrimaryProvider(t){if(!t.providerData||t.providerData.length===0)return null;const e=t.providerData[0]?.providerId;return e?e==="password"||e==="emailLink"?"password":e.startsWith("google.com")?"google":e.startsWith("github.com")?"github":e.startsWith("microsoft.com")?"microsoft":e.startsWith("apple.com")?"apple":e.startsWith("facebook.com")?"facebook":e.startsWith("twitter.com")?"twitter":null:null}async deleteAccount(t){this.ensureInitialized();const e=await this.sdk.getCurrentUser();if(!e)throw new Error("No authenticated user");const i=async()=>{const r=this.getAppConfig()?.auth,s=r&&typeof r=="object"?r.deleteUserFunction:void 0;if(s)try{await s(e.uid)}catch{m()}await this.sdk.deleteUser(e),l("success","Account deleted successfully")};try{await i()}catch(r){if(r.code==="auth/requires-recent-login"){const s=this.getPrimaryProvider(e);if(!s)throw a(r,{userMessage:"Unable to determine authentication provider",showNotification:!0});if(s!=="password")try{await this.reauthenticateWithProvider(s),await i();return}catch(n){throw n.message==="REAUTH_CANCELLED"?new Error("REAUTH_CANCELLED"):a(n,{userMessage:"Re-authentication failed. Please try again.",showNotification:!0})}if(!t)throw new Error("REQUIRES_PASSWORD");try{await this.reauthenticateWithPassword(t),await i();return}catch(n){throw a(n,{userMessage:"Re-authentication failed. Please check your password.",showNotification:!0})}}throw a(r,{userMessage:"Failed to delete account",showNotification:!0})}}async clearCachedClaims(){this.claimsCache&&await this.claimsCache.clearClaims()}async setCachedClaims(t){this.initializeClaimsCache(),this.claimsCache&&await this.claimsCache.setClaims(t)}clearAccountLinkingState(){W()}resetAuthState(){this.store&&(Object.keys(k).forEach(t=>{this.storeState.setPartnerState(t,o.IDLE)}),this.storeState.clearAuthError())}async fetchSignInMethodsForEmail(t){this.ensureInitialized();try{return await this.sdk.fetchSignInMethodsForEmail(t)}catch(e){throw a(e,{userMessage:"Failed to check sign-in methods"})}}getSmartRecoveryDeps(){return{sdk:this.sdk,handleAccountLinking:this.handleAccountLinking.bind(this),createAuthResult:this.createAuthResult.bind(this)}}getAccountLinkingDeps(){return{sdk:this.sdk,createProviderFromConfig:this.createProviderFromConfig.bind(this),createAuthResult:this.createAuthResult.bind(this),getExistingProvider:z}}async handleAccountLinking(t,e,i){return await M(t,e,i,this.getAccountLinkingDeps())}createProviderFromConfig(t){const e=k[t];if(!e||!e.firebaseProviderId)throw new Error(`Unsupported partner: ${t}`);let i;switch(t){case"google":i=this.sdk.createGoogleProvider();break;case"github":i=this.sdk.createGithubProvider();break;case"facebook":i=this.sdk.createFacebookProvider();break;case"twitter":i=this.sdk.createTwitterProvider();break;case"microsoft":i=this.sdk.createMicrosoftProvider();break;case"apple":i=this.sdk.createAppleProvider();break;default:i=this.sdk.createOAuthProvider(e.firebaseProviderId)}return e.customParameters&&i.setCustomParameters(e.customParameters),e.scopes&&e.scopes.length>0&&e.scopes.forEach(r=>i.addScope(r)),i}convertToAuthUser(t){return{id:t.uid,email:t.email||null,displayName:t.displayName||null,photoURL:t.photoURL||null,emailVerified:t.emailVerified||!1,lastLoginAt:t.metadata.lastSignInTime||new Date().toISOString(),providerData:t.providerData.map(e=>({providerId:e.providerId,uid:e.uid,displayName:e.displayName,email:e.email,photoURL:e.photoURL,phoneNumber:e.phoneNumber}))}}createAuthResult(t,e=!1){return{user:this.convertToAuthUser(t),success:!0,isNewUser:e}}createCredentialFromStoredData(t){try{if(!t||!t.providerId)return null;switch(t.providerId){case"google.com":return L.credential(t.idToken||null,t.accessToken||null);case"github.com":return N.credential(t.accessToken);case"facebook.com":return F.credential(t.accessToken);case"twitter.com":return D.credential(t.accessToken,t.secret||t.oauthTokenSecret);default:return t.idToken?new w(t.providerId).credential({idToken:t.idToken,accessToken:t.accessToken}):t.accessToken?new w(t.providerId).credential({accessToken:t.accessToken}):null}}catch(e){return a(e,{showNotification:!1,severity:"warning",context:{operation:"_getCredentialFromData"}}),null}}reset(){this.initialized=!1,this.sdk=C(),this.store=null,this.claimsCache=null,this.popupTimeout&&(clearTimeout(this.popupTimeout),this.popupTimeout=null)}}const $=A(()=>new O);export{O as FirebaseAuth,$ as getFirebaseAuth};
@@ -1 +1 @@
1
- {"version":3,"file":"FirebaseSmartRecovery.d.ts","sourceRoot":"","sources":["../src/FirebaseSmartRecovery.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAiB,KAAK,UAAU,E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iBAAiB,EAAE,aAAa,EAChC,MAAM,EAAE,UAAU,KACf,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAChC,gBAAgB,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,UAAU,CAAC;CAClE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,GAAG,EACV,SAAS,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EAC7B,OAAO,EAAE,oBAAoB,EAC7B,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAkF5B"}
@@ -1 +1 @@
1
- import{toast as c}from"@donotdev/components";import{handleError as s}from"@donotdev/core";import{getAuthMethod as u}from"./constants";async function f(e,o,r,a){if(e.code==="auth/network-request-failed"){c("info","Connection issue - retrying...");try{return await d(o,a)}catch(t){throw s(t,{userMessage:"Network connection failed. Please check your internet and try again.",context:{operation:"network-retry",originalError:e.code},showNotification:!0})}}if(e.code==="auth/too-many-requests"){c("info","Rate limited - retrying with backoff...");try{return await l(o,a)}catch(t){throw s(t,{userMessage:"Too many attempts. Please wait a moment and try again.",context:{operation:"rate-limit-retry",originalError:e.code},showNotification:!0})}}if(e.code==="auth/internal-error"){c("info","Temporary issue - retrying...");try{return await h(o,a)}catch(t){throw s(t,{userMessage:"A temporary error occurred. Please try again.",context:{operation:"internal-error-retry",originalError:e.code},showNotification:!0})}}if(e.code==="auth/account-exists-with-different-credential")try{return await a.handleAccountLinking(e,r.partnerId,r.method?u(r.method):u())}catch(t){throw s(t,{userMessage:"Failed to link accounts. Please try again.",context:{operation:"account-linking",originalError:e.code},showNotification:!0})}if(e.code==="auth/popup-closed-by-user"||e.code==="auth/cancelled-popup-request"||e.code==="auth/popup-blocked"||e.message?.includes("popup")||e.message?.includes("cancelled")||e.message?.includes("closed"))return null;throw s(e,{userMessage:y(e.code),context:{operation:"smart-recovery",errorCode:e.code},showNotification:!0})}async function d(e,o,r=3){for(let a=1;a<=r;a++)try{const t=await e();return o.createAuthResult(t.user)}catch(t){if(a===r||t.code!=="auth/network-request-failed")throw t;const i=a*1e3;await new Promise(n=>setTimeout(n,i))}throw new Error("Max retries exceeded")}async function l(e,o,r=3){for(let a=1;a<=r;a++)try{const t=await e();return o.createAuthResult(t.user)}catch(t){if(a===r||t.code!=="auth/too-many-requests")throw t;const i=Math.pow(2,a)*1e3;await new Promise(n=>setTimeout(n,i))}throw new Error("Max retries exceeded")}async function h(e,o,r=2){for(let a=1;a<=r;a++)try{const t=await e();return o.createAuthResult(t.user)}catch(t){if(a===r||t.code!=="auth/internal-error")throw t;const i=2e3;await new Promise(n=>setTimeout(n,i))}throw new Error("Max retries exceeded")}function y(e){return{"auth/invalid-email":"Invalid email address","auth/user-disabled":"This account has been disabled","auth/user-not-found":"No account found with this email","auth/wrong-password":"Incorrect password","auth/email-already-in-use":"An account already exists with this email","auth/weak-password":"Password is too weak","auth/operation-not-allowed":"This sign-in method is not enabled","auth/invalid-credential":"Invalid credentials provided","auth/invalid-verification-code":"Invalid verification code","auth/invalid-verification-id":"Invalid verification ID","auth/expired-action-code":"This link has expired","auth/invalid-action-code":"Invalid or expired link","auth/credential-already-in-use":"This credential is already associated with another account","auth/requires-recent-login":"Please sign in again to continue","auth/popup-blocked":"Popup was blocked by your browser. Please allow popups and try again."}[e]||"An authentication error occurred"}export{f as handleSmartRecovery};
1
+ import{toast as c}from"@donotdev/components";import{handleError as s,isDev as u}from"@donotdev/core";import{getAuthMethod as d}from"./constants";async function g(e,o,r,a){if(e.code==="auth/network-request-failed"){c("info","Connection issue - retrying...");try{return await l(o,a)}catch(t){throw s(t,{userMessage:"Network connection failed. Please check your internet and try again.",context:{operation:"network-retry",originalError:e.code},showNotification:!0})}}if(e.code==="auth/too-many-requests"){c("info","Rate limited - retrying with backoff...");try{return await h(o,a)}catch(t){throw s(t,{userMessage:"Too many attempts. Please wait a moment and try again.",context:{operation:"rate-limit-retry",originalError:e.code},showNotification:!0})}}if(e.code==="auth/internal-error"){c("info","Temporary issue - retrying...");try{return await y(o,a)}catch(t){throw s(t,{userMessage:"A temporary error occurred. Please try again.",context:{operation:"internal-error-retry",originalError:e.code},showNotification:!0})}}if(e.code==="auth/account-exists-with-different-credential")try{return await a.handleAccountLinking(e,r.partnerId,r.method?d(r.method):d())}catch(t){throw s(t,{userMessage:"Failed to link accounts. Please try again.",context:{operation:"account-linking",originalError:e.code},showNotification:!0})}if(e.code==="auth/popup-closed-by-user"||e.code==="auth/cancelled-popup-request"||e.code==="auth/popup-blocked"||e.message?.includes("popup")||e.message?.includes("cancelled")||e.message?.includes("closed"))return null;throw s(e,{userMessage:w(e.code),context:{operation:"smart-recovery",errorCode:e.code},showNotification:!0})}async function l(e,o,r=3){for(let a=1;a<=r;a++)try{const t=await e();return o.createAuthResult(t.user)}catch(t){if(a===r||t.code!=="auth/network-request-failed")throw t;const i=a*1e3;u(),await new Promise(n=>setTimeout(n,i))}throw new Error("Max retries exceeded")}async function h(e,o,r=3){for(let a=1;a<=r;a++)try{const t=await e();return o.createAuthResult(t.user)}catch(t){if(a===r||t.code!=="auth/too-many-requests")throw t;const i=Math.pow(2,a)*1e3;u(),await new Promise(n=>setTimeout(n,i))}throw new Error("Max retries exceeded")}async function y(e,o,r=2){for(let a=1;a<=r;a++)try{const t=await e();return o.createAuthResult(t.user)}catch(t){if(a===r||t.code!=="auth/internal-error")throw t;const i=2e3;u(),await new Promise(n=>setTimeout(n,i))}throw new Error("Max retries exceeded")}function w(e){return{"auth/invalid-email":"Invalid email address","auth/user-disabled":"This account has been disabled","auth/user-not-found":"No account found with this email","auth/wrong-password":"Incorrect password","auth/email-already-in-use":"An account already exists with this email","auth/weak-password":"Password is too weak","auth/operation-not-allowed":"This sign-in method is not enabled","auth/invalid-credential":"Invalid credentials provided","auth/invalid-verification-code":"Invalid verification code","auth/invalid-verification-id":"Invalid verification ID","auth/expired-action-code":"This link has expired","auth/invalid-action-code":"Invalid or expired link","auth/credential-already-in-use":"This credential is already associated with another account","auth/requires-recent-login":"Please sign in again to continue","auth/popup-blocked":"Popup was blocked by your browser. Please allow popups and try again."}[e]||"An authentication error occurred"}export{g as handleSmartRecovery};
@@ -1 +1 @@
1
- {"version":3,"file":"AccountLinking.d.ts","sourceRoot":"","sources":["../../src/components/AccountLinking.tsx"],"names":[],"mappings":"AAiCA,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAwJD,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CASjD;AAKD,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"AccountLinking.d.ts","sourceRoot":"","sources":["../../src/components/AccountLinking.tsx"],"names":[],"mappings":"AAkCA,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AA8JD,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CASjD;AAKD,eAAe,cAAc,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{Suspense as A,lazy as w}from"react";import{Alert as h,ALERT_VARIANT as p,Button as a,BUTTON_VARIANT as c,Stack as r}from"@donotdev/components";import{useTranslation as I,safeSessionStorage as k,handleError as T}from"@donotdev/core";import{EmailLinkForm as x}from"./EmailLinkForm";import y from"./EmailPasswordForm";import{useAccountLinking as E}from"../hooks/useAccountLinking";const S=({className:o="",id:l})=>{const{t:e}=I("auth"),{isRequired:v,email:d,existingProvider:n,newProvider:m,handleSignInWithExistingProvider:L}=E();if(!v)return null;if(n==="password"||n==="emailLink"){const t=()=>{k.removeItem("accountLinkingInfo")},u=()=>{},g=f=>{T(f)};return i("div",{className:o,id:l,children:i(h,{variant:p.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:s(r,{gap:"medium",children:[i("p",{children:e("accountLinking.message",`An account with email ${d} already exists with ${n==="password"?"email/password":"email link"}. To link your ${m} account, please sign in with your ${n==="password"?"email and password":"email link"} first.`)}),n==="password"?i("div",{style:{marginTop:"var(--gap-md)"},children:i(y,{mode:"signin",onSuccess:u,onError:g})}):i("div",{style:{marginTop:"var(--gap-md)"},children:i(x,{onSuccess:u,onError:g})}),i(r,{direction:"row",justify:"end",children:i(a,{onClick:t,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})})]})})})}else{const t=()=>{k.removeItem("accountLinkingInfo")};return i("div",{className:o,id:l,children:i(h,{variant:p.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:s(r,{gap:"medium",children:[i("p",{children:e("accountLinking.message",`An account with email ${d} already exists with ${n}. To link your ${m} account, please sign in with ${n} first.`)}),s(r,{direction:"row",gap:"medium",children:[i(a,{onClick:L,variant:c.PRIMARY,children:e("accountLinking.signInWith",`Sign in with ${n}`)}),i(a,{onClick:t,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})]})]})})})}},$=w(()=>Promise.resolve({default:S}));function R(o){return i(A,{fallback:null,children:i($,{...o})})}var W=R;export{W as default};
1
+ "use client";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{Suspense as w,lazy as I}from"react";import{Alert as k,ALERT_VARIANT as p,Button as c,BUTTON_VARIANT as a,Stack as r}from"@donotdev/components";import{useTranslation as T,safeSessionStorage as f,handleError as x,isDev as l}from"@donotdev/core";import{EmailLinkForm as y}from"./EmailLinkForm";import E from"./EmailPasswordForm";import{useAccountLinking as S}from"../hooks/useAccountLinking";const $=({className:o="",id:d})=>{const{t:e}=T("auth"),{isRequired:v,email:u,existingProvider:n,newProvider:m,handleSignInWithExistingProvider:L}=S();if(!v)return null;if(n==="password"||n==="emailLink"){l();const t=()=>{f.removeItem("accountLinkingInfo")},g=()=>{l()},h=A=>{x(A)};return i("div",{className:o,id:d,children:i(k,{variant:p.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:s(r,{children:[i("p",{children:e("accountLinking.message",`An account with email ${u} already exists with ${n==="password"?"email/password":"email link"}. To link your ${m} account, please sign in with your ${n==="password"?"email and password":"email link"} first.`)}),n==="password"?i("div",{style:{marginTop:"var(--gap-md)"},children:i(E,{mode:"signin",onSuccess:g,onError:h})}):i("div",{style:{marginTop:"var(--gap-md)"},children:i(y,{onSuccess:g,onError:h})}),i(r,{direction:"row",justify:"end",children:i(c,{onClick:t,variant:a.GHOST,children:e("accountLinking.dismiss","Dismiss")})})]})})})}else{l();const t=()=>{f.removeItem("accountLinkingInfo")};return i("div",{className:o,id:d,children:i(k,{variant:p.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:s(r,{children:[i("p",{children:e("accountLinking.message",`An account with email ${u} already exists with ${n}. To link your ${m} account, please sign in with ${n} first.`)}),s(r,{direction:"row",children:[i(c,{onClick:L,variant:a.PRIMARY,children:e("accountLinking.signInWith",`Sign in with ${n}`)}),i(c,{onClick:t,variant:a.GHOST,children:e("accountLinking.dismiss","Dismiss")})]})]})})})}},R=I(()=>Promise.resolve({default:$}));function N(o){return i(w,{fallback:null,children:i(R,{...o})})}var _=N;export{_ as default};
@@ -1 +1 @@
1
- {"version":3,"file":"AuthPartnerButton.d.ts","sourceRoot":"","sources":["../../src/components/AuthPartnerButton.tsx"],"names":[],"mappings":"AA0CA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,OAAO,CAAC;AAEjE,UAAU,+BAAgC,SAAQ,sBAAsB;IACtE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,MAAM,EACN,SAAS,EACT,OAAO,EACP,SAAc,EACd,QAAQ,EACR,QAAgB,EAChB,OAAsB,EACtB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,+BAA+B,GAChC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,2CAuIvE;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"AuthPartnerButton.d.ts","sourceRoot":"","sources":["../../src/components/AuthPartnerButton.tsx"],"names":[],"mappings":"AA0CA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,OAAO,CAAC;AAEjE,UAAU,+BAAgC,SAAQ,sBAAsB;IACtE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,MAAM,EACN,SAAS,EACT,OAAO,EACP,SAAc,EACd,QAAQ,EACR,QAAgB,EAChB,OAAsB,EACtB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,+BAA+B,GAChC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,2CAyIvE;AAED,eAAe,iBAAiB,CAAC"}
@@ -1,5 +1,5 @@
1
- "use client";import{jsx as i}from"react/jsx-runtime";import{useMemo as C,useState as D}from"react";if(typeof document<"u"&&!document.getElementById("auth-partner-button-styles")){const t=document.createElement("style");t.id="auth-partner-button-styles",t.textContent=`
1
+ "use client";import{jsx as i}from"react/jsx-runtime";import{useMemo as C,useState as D}from"react";if(typeof document<"u"&&!document.getElementById("auth-partner-button-styles")){const n=document.createElement("style");n.id="auth-partner-button-styles",n.textContent=`
2
2
  .dndev-interactive.auth-partner-button-custom[data-variant='outline']:hover {
3
3
  background-color: var(--partner-hover-bg);
4
4
  }
5
- `,document.head.appendChild(t)}import{cn as I,DISPLAY as A,PROVIDER_ICONS as R,DefaultProviderIcon as M,Button as U,BUTTON_VARIANT as W,Spinner as _}from"@donotdev/components";import{AUTH_PARTNERS as $,useTranslation as j}from"@donotdev/core";import{EmailLinkForm as F}from"./EmailLinkForm";import K from"./EmailPasswordForm";import{getAuthMethod as P}from"../constants";import{useAuth as s}from"../useAuth";function V({partnerId:t,method:f,onSuccess:u,onError:l,className:c="",children:b,disabled:h=!1,display:g=A.AUTO,style:p,...H}){const{t:a}=j("auth"),v=s("user"),S=s("signInWithPartner"),T=s("linkWithPartner"),E=s("isAvailable"),[e,k]=D(!1),o=C(()=>$[t],[t]);if(t==="password")return i("div",{className:c,children:i(K,{mode:"signin",onSuccess:()=>u?.(null),onError:l,compact:!0})});if(t==="emailLink")return i("div",{className:c,children:i(F,{onSuccess:()=>u?.(null),onError:l})});const L=C(()=>R[t]||M,[t]),d=!!v?.providerData?.some(n=>n.providerId===t),m=v&&!d,w=async()=>{if(!(e||h)){k(!0);try{let n;if(m)n=await T(t,P(f));else{const O=P(f);n=await S(t,O)}n&&u?.(n)}catch(n){l?.(n instanceof Error?n:new Error(String(n)))}finally{k(!1)}}},r=o?.name,x=()=>{if(b)return b;if(m)return e?a("buttons.linking",{partner:r}):d?a("buttons.linked",{partner:r}):a("buttons.link",{partner:r});if(e)return a("buttons.signingIn",{partner:r});const n=o?.button?.textKey;return n?a(n):`Sign in with ${r}`},B=h||e||!E||m&&d||!1,y=o?.button?{backgroundColor:o.button.backgroundColor,color:o.button.textColor,borderColor:o.button.borderColor,"--partner-hover-bg":o.button.hoverBackgroundColor}:void 0,N=p?{...y,...p}:y;return i(U,{variant:W.OUTLINE,onClick:w,disabled:B,"aria-busy":e,display:g,"aria-label":e?`Signing in with ${r}...`:`Sign in with ${r}`,tooltip:void 0,style:N,className:I(o?.button&&"auth-partner-button-custom",c),icon:e?i(_,{"aria-label":"Loading"}):L,children:g!==A.COMPACT&&x()})}var tt=V;export{tt as default};
5
+ `,document.head.appendChild(n)}import{cn as R,DISPLAY as P,PROVIDER_ICONS as M,DefaultProviderIcon as U,Button as W,BUTTON_VARIANT as _,Spinner as $}from"@donotdev/components";import{AUTH_PARTNERS as j,useTranslation as F}from"@donotdev/core";import{EmailLinkForm as K}from"./EmailLinkForm";import V from"./EmailPasswordForm";import{getAuthMethod as A}from"../constants";import{useAuth as s}from"../useAuth";function H({partnerId:n,method:f,onSuccess:u,onError:l,className:c="",children:b,disabled:h=!1,display:g=P.AUTO,style:p,...Y}){const{t:a}=F("auth"),v=s("user"),S=s("signInWithPartner"),T=s("linkWithPartner"),E=s("isAvailable"),[r,k]=D(!1),o=C(()=>j[n],[n]);if(n==="password")return i("div",{className:c,children:i(V,{mode:"signin",onSuccess:()=>u?.(null),onError:l,compact:!0})});if(n==="emailLink")return i("div",{className:c,children:i(K,{onSuccess:()=>u?.(null),onError:l})});const L=C(()=>M[n]||U,[n]),w=o?.firebaseProviderId,d=!!v?.providerData?.some(t=>t.providerId===w),m=v&&!d,x=async()=>{if(!(r||h)){k(!0);try{let t;if(m)t=await T(n,A(f));else{const O=A(f);t=await S(n,O)}t&&u?.(t)}catch(t){l?.(t instanceof Error?t:new Error(String(t)))}finally{k(!1)}}},e=o?.name,I=()=>{if(b)return b;if(m)return r?a("buttons.linking",{partner:e}):d?a("buttons.linked",{partner:e}):a("buttons.link",{partner:e});if(r)return a("buttons.signingIn",{partner:e});const t=o?.button?.textKey;return t?a(t):`Sign in with ${e}`},B=h||r||!E||m&&d||!1,y=o?.button?{backgroundColor:o.button.backgroundColor,color:o.button.textColor,borderColor:o.button.borderColor,"--partner-hover-bg":o.button.hoverBackgroundColor}:void 0,N=p?{...y,...p}:y;return i(W,{variant:_.OUTLINE,onClick:x,disabled:B,"aria-busy":r,display:g,"aria-label":r?`Signing in with ${e}...`:`Sign in with ${e}`,tooltip:void 0,style:N,className:R(o?.button&&"auth-partner-button-custom",c),icon:r?i($,{"aria-label":"Loading"}):L,children:g!==P.COMPACT&&I()})}var nt=H;export{nt as default};
@@ -1 +1 @@
1
- "use client";import{jsx as t,jsxs as c,Fragment as f}from"react/jsx-runtime";import{Trash2 as x}from"lucide-react";import{useState as A}from"react";import{Dialog as g,Button as d,BUTTON_VARIANT as s,Input as R,Label as w,Checkbox as k,Alert as b,ALERT_VARIANT as C,Stack as r,Text as v,List as T}from"@donotdev/components";import{useTranslation as y}from"@donotdev/core";function N({open:u,isLoading:n,error:l,onReauth:h,onCancel:a}){const{t:e}=y("auth"),[o,m]=A(""),p=async()=>{await h(o)};return t(g,{open:u,onOpenChange:i=>!i&&a(),title:e("deleteAccount.reauth.title","Confirm Your Identity"),description:e("deleteAccount.reauth.description","For security, please re-enter your password to continue."),footer:c(f,{children:[t(d,{variant:s.OUTLINE,onClick:a,disabled:n,children:e("deleteAccount.reauth.cancel","Cancel")}),t(d,{variant:s.DEFAULT,onClick:p,disabled:n||!o,children:n?e("deleteAccount.reauth.verifying","Verifying..."):e("deleteAccount.reauth.continue","Continue")})]}),children:c(r,{gap:"medium",children:[c(r,{gap:"tight",children:[t(w,{htmlFor:"reauth-password",children:e("deleteAccount.reauth.password","Password")}),t(R,{id:"reauth-password",type:"password",value:o,onChange:i=>m(i.target.value),disabled:n,placeholder:e("deleteAccount.reauth.passwordPlaceholder","Enter your password"),required:!0})]}),l&&t(b,{variant:C.ERROR,description:l})]})})}function U({open:u,isLoading:n,error:l,onConfirm:h,onCancel:a}){const{t:e}=y("auth"),[o,m]=A(!1),p=async()=>{o&&await h()};return t(g,{open:u,onOpenChange:i=>!i&&a(),"data-content-size":"text",title:e("deleteAccount.confirm.title","Delete Your Account?"),description:e("deleteAccount.confirm.description","This action cannot be undone. This will permanently delete your account."),footer:c(f,{children:[t(d,{variant:s.OUTLINE,onClick:a,disabled:n,children:e("deleteAccount.confirm.cancel","Cancel")}),t(d,{variant:s.DESTRUCTIVE,icon:x,onClick:p,disabled:n||!o,children:n?e("deleteAccount.confirm.deleting","Deleting..."):e("deleteAccount.confirm.delete","Delete My Account")})]}),children:c(r,{gap:"large",children:[c(r,{gap:"medium",children:[t(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatDeleted","What will be deleted:")}),t(T,{items:[e("deleteAccount.confirm.credentials","Your account and authentication credentials"),e("deleteAccount.confirm.profile","Your profile information"),e("deleteAccount.confirm.oauth","All connected OAuth providers"),e("deleteAccount.confirm.subscriptions","Active subscriptions (will be canceled)")]})]}),c(r,{gap:"medium",children:[t(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatKept","What will be kept (anonymized):")}),t(T,{items:[e("deleteAccount.confirm.billing","Billing history for tax/accounting purposes"),e("deleteAccount.confirm.invoices","Past invoices and transaction records")]})]}),c(r,{direction:"row",align:"start",gap:"medium",children:[t(k,{id:"confirm-delete",checked:o,onCheckedChange:i=>m(i===!0)}),t(w,{htmlFor:"confirm-delete",children:e("deleteAccount.confirm.checkbox","I understand this action cannot be undone")})]}),l&&t(b,{variant:C.ERROR,description:l})]})})}export{U as ConfirmDeleteDialog,N as ReauthDialog};
1
+ "use client";import{jsx as t,jsxs as c,Fragment as f}from"react/jsx-runtime";import{Trash2 as x}from"lucide-react";import{useState as A}from"react";import{Dialog as w,Button as d,BUTTON_VARIANT as s,Input as R,Label as b,Checkbox as k,Alert as g,ALERT_VARIANT as C,Stack as r,Text as v,List as T}from"@donotdev/components";import{useTranslation as y}from"@donotdev/core";function N({open:u,isLoading:n,error:l,onReauth:h,onCancel:a}){const{t:e}=y("auth"),[o,m]=A(""),p=async()=>{await h(o)};return t(w,{open:u,onOpenChange:i=>!i&&a(),title:e("deleteAccount.reauth.title","Confirm Your Identity"),description:e("deleteAccount.reauth.description","For security, please re-enter your password to continue."),footer:c(f,{children:[t(d,{variant:s.OUTLINE,onClick:a,disabled:n,children:e("deleteAccount.reauth.cancel","Cancel")}),t(d,{variant:s.DEFAULT,onClick:p,disabled:n||!o,children:n?e("deleteAccount.reauth.verifying","Verifying..."):e("deleteAccount.reauth.continue","Continue")})]}),children:c(r,{children:[c(r,{gap:"tight",children:[t(b,{htmlFor:"reauth-password",children:e("deleteAccount.reauth.password","Password")}),t(R,{id:"reauth-password",type:"password",value:o,onChange:i=>m(i.target.value),disabled:n,placeholder:e("deleteAccount.reauth.passwordPlaceholder","Enter your password"),required:!0})]}),l&&t(g,{variant:C.ERROR,description:l})]})})}function U({open:u,isLoading:n,error:l,onConfirm:h,onCancel:a}){const{t:e}=y("auth"),[o,m]=A(!1),p=async()=>{o&&await h()};return t(w,{open:u,onOpenChange:i=>!i&&a(),"data-content-size":"text",title:e("deleteAccount.confirm.title","Delete Your Account?"),description:e("deleteAccount.confirm.description","This action cannot be undone. This will permanently delete your account."),footer:c(f,{children:[t(d,{variant:s.OUTLINE,onClick:a,disabled:n,children:e("deleteAccount.confirm.cancel","Cancel")}),t(d,{variant:s.DESTRUCTIVE,icon:x,onClick:p,disabled:n||!o,children:n?e("deleteAccount.confirm.deleting","Deleting..."):e("deleteAccount.confirm.delete","Delete My Account")})]}),children:c(r,{gap:"large",children:[c(r,{children:[t(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatDeleted","What will be deleted:")}),t(T,{items:[e("deleteAccount.confirm.credentials","Your account and authentication credentials"),e("deleteAccount.confirm.profile","Your profile information"),e("deleteAccount.confirm.oauth","All connected OAuth providers"),e("deleteAccount.confirm.subscriptions","Active subscriptions (will be canceled)")]})]}),c(r,{children:[t(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatKept","What will be kept (anonymized):")}),t(T,{items:[e("deleteAccount.confirm.billing","Billing history for tax/accounting purposes"),e("deleteAccount.confirm.invoices","Past invoices and transaction records")]})]}),c(r,{direction:"row",align:"start",children:[t(k,{id:"confirm-delete",checked:o,onCheckedChange:i=>m(i===!0)}),t(b,{htmlFor:"confirm-delete",children:e("deleteAccount.confirm.checkbox","I understand this action cannot be undone")})]}),l&&t(g,{variant:C.ERROR,description:l})]})})}export{U as ConfirmDeleteDialog,N as ReauthDialog};
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as m,CheckCircle as v}from"lucide-react";import{Button as d,BUTTON_VARIANT as y,Input as E,Label as S,Alert as x,ALERT_VARIANT as A,Spinner as R,Stack as a}from"@donotdev/components";import{useTranslation as b}from"@donotdev/core";import{useEmailLinkForm as T}from"../hooks/useEmailLinkForm";function N({className:l="",onSuccess:s,onError:c,actionCodeSettings:u}){const{t:i}=b("auth"),{email:t,setEmail:h,isLoading:r,isSent:g,error:o,handleSendLink:p,handleResend:k,canSubmit:f}=T({onSuccess:s,onError:c,actionCodeSettings:u});return g?n(a,{gap:"medium",className:l,children:[n("div",{style:{textAlign:"center"},children:[e(v,{style:{width:"var(--icon-touch)",height:"var(--icon-touch)",marginBottom:"var(--gap-md)",marginLeft:"auto",marginRight:"auto",color:"var(--primary)"}}),e("h3",{style:{marginBottom:"var(--gap-sm)",fontSize:"var(--font-size-lg)",fontWeight:600,color:"var(--foreground)"},children:i("emailLink.checkEmail","Check Your Email")}),e("p",{style:{marginBottom:"var(--gap-md)",color:"var(--muted-foreground)"},children:i("emailLink.sentMessage",`We've sent a sign-in link to ${t}. Click the link in your email to complete sign-in.`)})]}),e(a,{direction:"row",justify:"center",gap:"medium",children:e(d,{variant:y.OUTLINE,onClick:k,icon:m,iconEnd:!1,children:i("emailLink.resend","Resend Link")})})]}):e("form",{onSubmit:p,className:l,children:n(a,{gap:"medium",children:[n(a,{gap:"tight",children:[e(S,{htmlFor:"email",children:i("emailLink.emailLabel","Email Address")}),e(E,{id:"email",type:"email",value:t,onChange:L=>h(L.target.value),placeholder:i("emailLink.emailPlaceholder","Enter your email address"),required:!0,disabled:r,className:"dndev-w-full"})]}),o&&e(x,{variant:A.ERROR,description:o}),e(d,{type:"submit",disabled:!f,icon:r?e(R,{"aria-label":"Loading"}):m,iconEnd:!1,className:"dndev-w-full",children:r?i("emailLink.sending","Sending Link..."):i("emailLink.sendLink","Send Sign-In Link")}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",textAlign:"center"},children:i("emailLink.helpText","We'll send you a secure link to sign in without a password.")})]})})}var _=N;export{N as EmailLinkForm,_ as default};
1
+ "use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import{Mail as s,CheckCircle as v}from"lucide-react";import{Button as m,BUTTON_VARIANT as y,Input as E,Label as S,Alert as x,ALERT_VARIANT as A,Spinner as R,Stack as r}from"@donotdev/components";import{useTranslation as b}from"@donotdev/core";import{useEmailLinkForm as T}from"../hooks/useEmailLinkForm";function N({className:l="",onSuccess:d,onError:c,actionCodeSettings:u}){const{t:i}=b("auth"),{email:t,setEmail:h,isLoading:a,isSent:g,error:o,handleSendLink:k,handleResend:f,canSubmit:p}=T({onSuccess:d,onError:c,actionCodeSettings:u});return g?n(r,{className:l,children:[n("div",{style:{textAlign:"center"},children:[e(v,{style:{width:"var(--icon-touch)",height:"var(--icon-touch)",marginBottom:"var(--gap-md)",marginLeft:"auto",marginRight:"auto",color:"var(--primary)"}}),e("h3",{style:{marginBottom:"var(--gap-sm)",fontSize:"var(--font-size-lg)",fontWeight:600,color:"var(--foreground)"},children:i("emailLink.checkEmail","Check Your Email")}),e("p",{style:{marginBottom:"var(--gap-md)",color:"var(--muted-foreground)"},children:i("emailLink.sentMessage",`We've sent a sign-in link to ${t}. Click the link in your email to complete sign-in.`)})]}),e(r,{direction:"row",justify:"center",children:e(m,{variant:y.OUTLINE,onClick:f,icon:s,iconEnd:!1,children:i("emailLink.resend","Resend Link")})})]}):e("form",{onSubmit:k,className:l,children:n(r,{children:[n(r,{gap:"tight",children:[e(S,{htmlFor:"email",children:i("emailLink.emailLabel","Email Address")}),e(E,{id:"email",type:"email",value:t,onChange:L=>h(L.target.value),placeholder:i("emailLink.emailPlaceholder","Enter your email address"),required:!0,disabled:a,className:"dndev-w-full"})]}),o&&e(x,{variant:A.ERROR,description:o}),e(m,{type:"submit",disabled:!p,icon:a?e(R,{"aria-label":"Loading"}):s,iconEnd:!1,className:"dndev-w-full",children:a?i("emailLink.sending","Sending Link..."):i("emailLink.sendLink","Send Sign-In Link")}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",textAlign:"center"},children:i("emailLink.helpText","We'll send you a secure link to sign in without a password.")})]})})}var _=N;export{N as EmailLinkForm,_ as default};
@@ -1 +1 @@
1
- {"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"AAsCA,OAAO,KAAK,EAAE,sBAAsB,EAAY,MAAM,cAAc,CAAC;AAQrE;;;;;;;;;;;;;;GAcG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAc,GACf,EAAE,sBAAsB,2CAmaxB;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,sBAAsB,EAAY,MAAM,cAAc,CAAC;AAQrE;;;;;;;;;;;;;;GAcG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAc,GACf,EAAE,sBAAsB,2CA0axB;AAED,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import*as L from"firebase/auth";import{Info as D}from"lucide-react";import{useState as u}from"react";import{useForm as Y,Controller as v,useWatch as k}from"react-hook-form";import{Alert as P,ALERT_VARIANT as R,Button as p,BUTTON_VARIANT as w,Checkbox as Z,HoverCard as J,Input as Q,Label as X,PasswordInput as F,Stack as t,Text as l,cn as ee}from"@donotdev/components";import{useTranslation as re}from"@donotdev/core";import{getFirebaseSDK as se}from"@donotdev/firebase";import{useAuth as g}from"../useAuth";import{PasswordStrengthIndicator as ae}from"./PasswordStrengthIndicator";function ie({mode:M="signin",onSuccess:_,onError:x,className:q=""}){const{t:e}=re("auth"),T=g("signInWithEmail"),U=g("createUserWithEmail"),O=g("sendPasswordResetEmail"),W=g("isAvailable"),V=g("loading"),[y,E]=u(M),d=y==="signup",[S,j]=u(!1),[$,H]=u(""),[c,I]=u(!1),[h,A]=u(!1),{control:m,handleSubmit:K,formState:{errors:a,isSubmitting:z},setError:b}=Y({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),C=k({control:m,name:"password"}),f=k({control:m,name:"email"}),B=async s=>{try{y==="signin"?(await se().setPersistence(S?L.browserLocalPersistence:L.browserSessionPersistence),await T(s.email,s.password)):await U(s.email,s.password),_?.(void 0)}catch(i){const N=i instanceof Error?i.message:String(i);b("root",{message:N}),x?.(i instanceof Error?i:new Error(N))}},G=async()=>{if(!f||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f)){b("email",{message:e("emailRequired","Email is required")});return}I(!0);try{await O(f),A(!0),H(f)}catch(s){const i=s instanceof Error?s.message:String(s);b("root",{message:i})}finally{I(!1)}};if(!W)return r("div",{className:q,children:r(P,{variant:R.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Please accept cookies to enable authentication.")})});const n=V||z;return r("form",{onSubmit:K(B),className:ee("dndev-auth-form",q),noValidate:!0,children:o(t,{gap:"medium",children:[a.root&&r(P,{variant:R.ERROR,description:a.root.message}),h&&r(P,{variant:R.SUCCESS,title:e("forgotPassword.sent","Password reset email sent"),description:e("forgotPassword.checkEmail",`Check your email at ${$} for password reset instructions.`)}),r(v,{name:"email",control:m,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:s})=>o(t,{gap:"tight",children:[r(Q,{...s,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),disabled:n||c,"aria-invalid":!!a.email,"aria-describedby":a.email?"email-error":void 0,className:"dndev-w-full","data-variant":a.email?"destructive":void 0,onChange:i=>{s.onChange(i),h&&A(!1)}}),a.email&&r(l,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:a.email.message})]})}),r(v,{name:"password",control:m,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:s=>{if(!s)return!0;if(d){if(!/[A-Z]/.test(s))return e("passwordRequirement.uppercase","Password must contain at least one uppercase letter");if(!/[a-z]/.test(s))return e("passwordRequirement.lowercase","Password must contain at least one lowercase letter");if(!/[0-9]/.test(s))return e("passwordRequirement.number","Password must contain at least one number")}return!0}},render:({field:s})=>{const i=`password-${s.name}`;return o(t,{gap:"tight",children:[r(F,{...s,id:i,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),disabled:n||c,"aria-invalid":!!a.password,"aria-describedby":a.password?"password-error":void 0,className:"dndev-w-full","data-variant":a.password?"destructive":void 0}),a.password&&r(l,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:a.password.message})]})}}),d&&r(v,{name:"confirmPassword",control:m,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:s=>s!==C?e("confirmPasswordMismatch","Passwords do not match"):!0},render:({field:s})=>o(t,{gap:"tight",children:[r(F,{...s,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),disabled:n,"aria-invalid":!!a.confirmPassword,"aria-describedby":a.confirmPassword?"confirm-password-error":void 0,className:"dndev-w-full","data-variant":a.confirmPassword?"destructive":void 0}),a.confirmPassword&&r(l,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:a.confirmPassword.message})]})}),d&&r(ae,{password:C||"",minLength:8,showRequirements:!1}),d&&r(J,{trigger:r(p,{type:"button",variant:w.GHOST,className:"dndev-w-fit dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0},children:o(t,{direction:"row",align:"center",gap:"tight",children:[r(l,{as:"span",level:"caption",variant:"muted",children:e("passwordRequirements","Password requirements")}),r(D,{className:"dndev-size-xs"})]})}),side:"bottom",align:"start",children:o(t,{gap:"tight",className:"dndev-text-sm",children:[r(l,{as:"strong",level:"small",children:e("passwordRequirements.title","Password Requirements")}),o(t,{gap:"tight",as:"ul",className:"dndev-m-0 dndev-ps-md",children:[r("li",{children:e("passwordRequirement.length","At least 8 characters")}),r("li",{children:e("passwordRequirement.uppercase","One uppercase letter")}),r("li",{children:e("passwordRequirement.lowercase","One lowercase letter")}),r("li",{children:e("passwordRequirement.number","One number")}),r("li",{children:e("passwordRequirement.special","One special character (!@#$%^&*)")})]})]})}),!d&&!h&&o(t,{direction:"row",gap:"tight",align:"center",children:[r(Z,{id:"remember-me",checked:S,onCheckedChange:s=>j(s===!0),disabled:n||c}),r(X,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),r(p,{type:"submit",variant:w.PRIMARY,disabled:n,fullWidth:!0,children:n?e("loading","Loading..."):d?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!d&&!h&&o(t,{direction:"row",gap:"tight",justify:"center",align:"center",children:[r(p,{type:"button",variant:w.LINK,disabled:n||c,onClick:G,children:c?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),r(l,{as:"span",variant:"muted",children:"|"}),r(p,{type:"button",variant:w.LINK,disabled:n,onClick:()=>E("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),d&&r(t,{align:"center",children:r(p,{type:"button",variant:w.LINK,disabled:n,onClick:()=>E("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})})}var we=ie;export{we as default};
1
+ "use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{Info as G}from"lucide-react";import{useState as u}from"react";import{useForm as D,Controller as R,useWatch as L}from"react-hook-form";import{Alert as q,ALERT_VARIANT as y,Button as p,BUTTON_VARIANT as w,Checkbox as Y,HoverCard as Z,Input as J,Label as Q,PasswordInput as k,Stack as t,Text as l,cn as X}from"@donotdev/components";import{useTranslation as ee,hasProvider as re}from"@donotdev/core";import{useAuth as g}from"../useAuth";import{PasswordStrengthIndicator as se}from"./PasswordStrengthIndicator";function ae({mode:F="signin",onSuccess:M,onError:_,className:E=""}){const{t:e}=ee("auth"),x=g("signInWithEmail"),T=g("createUserWithEmail"),U=g("sendPasswordResetEmail"),O=g("isAvailable"),W=g("loading"),[S,I]=u(F),d=S==="signup",[b,V]=u(!1),[j,$]=u(""),[c,A]=u(!1),[h,C]=u(!1),{control:m,handleSubmit:H,formState:{errors:a,isSubmitting:K},setError:P}=D({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),N=L({control:m,name:"password"}),f=L({control:m,name:"email"}),z=async s=>{try{if(S==="signin"){if(!re("auth")&&b!==void 0){const[i,{getFirebaseSDK:v}]=await Promise.all([import("firebase/auth"),import("@donotdev/firebase")]);await v().setPersistence(b?i.browserLocalPersistence:i.browserSessionPersistence)}await x(s.email,s.password)}else await T(s.email,s.password);M?.(void 0)}catch(i){const v=i instanceof Error?i.message:String(i);P("root",{message:v}),_?.(i instanceof Error?i:new Error(v))}},B=async()=>{if(!f||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f)){P("email",{message:e("emailRequired","Email is required")});return}A(!0);try{await U(f),C(!0),$(f)}catch(s){const i=s instanceof Error?s.message:String(s);P("root",{message:i})}finally{A(!1)}};if(!O)return r("div",{className:E,children:r(q,{variant:y.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Please accept cookies to enable authentication.")})});const n=W||K;return r("form",{onSubmit:H(z),className:X("dndev-auth-form",E),noValidate:!0,children:o(t,{children:[a.root&&r(q,{variant:y.ERROR,description:a.root.message}),h&&r(q,{variant:y.SUCCESS,title:e("forgotPassword.sent","Password reset email sent"),description:e("forgotPassword.checkEmail",`Check your email at ${j} for password reset instructions.`)}),r(R,{name:"email",control:m,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:s})=>o(t,{gap:"tight",children:[r(J,{...s,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),disabled:n||c,"aria-invalid":!!a.email,"aria-describedby":a.email?"email-error":void 0,className:"dndev-w-full","data-variant":a.email?"destructive":void 0,onChange:i=>{s.onChange(i),h&&C(!1)}}),a.email&&r(l,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:a.email.message})]})}),r(R,{name:"password",control:m,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:s=>{if(!s)return!0;if(d){if(!/[A-Z]/.test(s))return e("passwordRequirement.uppercase","Password must contain at least one uppercase letter");if(!/[a-z]/.test(s))return e("passwordRequirement.lowercase","Password must contain at least one lowercase letter");if(!/[0-9]/.test(s))return e("passwordRequirement.number","Password must contain at least one number")}return!0}},render:({field:s})=>{const i=`password-${s.name}`;return o(t,{gap:"tight",children:[r(k,{...s,id:i,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),disabled:n||c,"aria-invalid":!!a.password,"aria-describedby":a.password?"password-error":void 0,className:"dndev-w-full","data-variant":a.password?"destructive":void 0}),a.password&&r(l,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:a.password.message})]})}}),d&&r(R,{name:"confirmPassword",control:m,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:s=>s!==N?e("confirmPasswordMismatch","Passwords do not match"):!0},render:({field:s})=>o(t,{gap:"tight",children:[r(k,{...s,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),disabled:n,"aria-invalid":!!a.confirmPassword,"aria-describedby":a.confirmPassword?"confirm-password-error":void 0,className:"dndev-w-full","data-variant":a.confirmPassword?"destructive":void 0}),a.confirmPassword&&r(l,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:a.confirmPassword.message})]})}),d&&r(se,{password:N||"",minLength:8,showRequirements:!1}),d&&r(Z,{trigger:r(p,{type:"button",variant:w.GHOST,className:"dndev-w-fit dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0},children:o(t,{direction:"row",align:"center",gap:"tight",children:[r(l,{as:"span",level:"caption",variant:"muted",children:e("passwordRequirements","Password requirements")}),r(G,{className:"dndev-size-xs"})]})}),side:"bottom",align:"start",children:o(t,{gap:"tight",className:"dndev-text-sm",children:[r(l,{as:"strong",level:"small",children:e("passwordRequirements.title","Password Requirements")}),o(t,{gap:"tight",as:"ul",className:"dndev-m-0 dndev-ps-md",children:[r("li",{children:e("passwordRequirement.length","At least 8 characters")}),r("li",{children:e("passwordRequirement.uppercase","One uppercase letter")}),r("li",{children:e("passwordRequirement.lowercase","One lowercase letter")}),r("li",{children:e("passwordRequirement.number","One number")}),r("li",{children:e("passwordRequirement.special","One special character (!@#$%^&*)")})]})]})}),!d&&!h&&o(t,{direction:"row",gap:"tight",align:"center",children:[r(Y,{id:"remember-me",checked:b,onCheckedChange:s=>V(s===!0),disabled:n||c}),r(Q,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),r(p,{type:"submit",variant:w.PRIMARY,disabled:n,fullWidth:!0,children:n?e("loading","Loading..."):d?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!d&&!h&&o(t,{direction:"row",gap:"tight",justify:"center",align:"center",children:[r(p,{type:"button",variant:w.LINK,disabled:n||c,onClick:B,children:c?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),r(l,{as:"span",variant:"muted",children:"|"}),r(p,{type:"button",variant:w.LINK,disabled:n,onClick:()=>I("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),d&&r(t,{align:"center",children:r(p,{type:"button",variant:w.LINK,disabled:n,onClick:()=>I("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})})}var pe=ae;export{pe as default};
@@ -1 +1 @@
1
- {"version":3,"file":"EmailVerification.d.ts","sourceRoot":"","sources":["../../src/components/EmailVerification.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,iBAAS,iBAAiB,CAAC,EACzB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,YAAY,EACZ,EAAE,GACH,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAmG7C;AAKD,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"EmailVerification.d.ts","sourceRoot":"","sources":["../../src/components/EmailVerification.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,iBAAS,iBAAiB,CAAC,EACzB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,YAAY,EACZ,EAAE,GACH,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAmG7C;AAKD,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{Card as h,Button as V,BUTTON_VARIANT as v,Alert as y,Spinner as A,Stack as d}from"@donotdev/components";import{useTranslation as b,handleError as I}from"@donotdev/core";import{useAuth as a}from"../useAuth";function M({verifyButtonText:S,successMessage:x,sendingMessage:j,alreadyVerifiedMessage:E,notSignedInMessage:T,errorMessage:w,id:c}){const{t:i}=b("auth"),n=a("user"),e=a("emailVerification"),u=a("sendEmailVerification"),s=n?.id,t=c||`email-verification-${Math.random().toString(36).slice(2,9)}`,l=`${t}-heading`,f=`${t}-button`,m=async()=>{if(!(!n||!s))try{await u()}catch(p){I(p)}};if(!n||!s)return null;const g=()=>{if(e.status!=="pending"&&e.status==="error")return"error"};return r(h,{id:t,title:r("span",{id:l,children:i("emailVerification.title")}),children:o(d,{gap:"medium",children:[o(d,{direction:"row",justify:"between",align:"center",children:[r("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:i("emailVerification.status.unknown")}),r(V,{id:f,onClick:m,disabled:e.status==="pending","aria-busy":e.status==="pending",variant:v.PRIMARY,icon:e.status==="pending"?r(A,{"aria-label":"Loading"}):void 0,iconEnd:!1,children:e.status==="pending"?i("status.verifying"):i("buttons.verify","Verify")})]}),e.status!=="verified"&&r(y,{variant:g(),title:e.status==="error"?i("aria.errorAlert"):i("status.verifying"),description:e.status==="error"?("error"in e?e.error:void 0)||i("emailVerification.error","An error occurred"):i("emailVerification.sending","Sending verification email...")})]})})}var $=M;export{$ as default};
1
+ "use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{Card as h,Button as v,BUTTON_VARIANT as y,Alert as I,Spinner as A,Stack as d}from"@donotdev/components";import{useTranslation as b,handleError as x}from"@donotdev/core";import{useAuth as a}from"../useAuth";import{useId as M}from"react";function S({verifyButtonText:j,successMessage:E,sendingMessage:T,alreadyVerifiedMessage:w,notSignedInMessage:k,errorMessage:B,id:c}){const{t:i}=b("auth"),n=a("user"),e=a("emailVerification"),u=a("sendEmailVerification"),s=n?.id,f=M(),t=c||`email-verification-${f}`,l=`${t}-heading`,m=`${t}-button`,g=async()=>{if(!(!n||!s))try{await u()}catch(V){x(V)}};if(!n||!s)return null;const p=()=>{if(e.status!=="pending"&&e.status==="error")return"error"};return r(h,{id:t,title:r("span",{id:l,children:i("emailVerification.title")}),children:o(d,{children:[o(d,{direction:"row",justify:"between",align:"center",children:[r("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:i("emailVerification.status.unknown")}),r(v,{id:m,onClick:g,disabled:e.status==="pending","aria-busy":e.status==="pending",variant:y.PRIMARY,icon:e.status==="pending"?r(A,{"aria-label":"Loading"}):void 0,iconEnd:!1,children:e.status==="pending"?i("status.verifying"):i("buttons.verify","Verify")})]}),e.status!=="verified"&&r(I,{variant:p(),title:e.status==="error"?i("aria.errorAlert"):i("status.verifying"),description:e.status==="error"?("error"in e?e.error:void 0)||i("emailVerification.error","An error occurred"):i("emailVerification.sending","Sending verification email...")})]})})}var N=S;export{N as default};
@@ -3,7 +3,7 @@ import type { ReactNode, ComponentType } from 'react';
3
3
  /**
4
4
  * Props for FeatureGuard component
5
5
  */
6
- interface FeatureGuardProps {
6
+ export interface FeatureGuardProps {
7
7
  /** Children to render if access is granted */
8
8
  children: ReactNode;
9
9
  /** Required role(s) - user must have at least one */
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureGuard.d.ts","sourceRoot":"","sources":["../../src/components/FeatureGuard.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMjE,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtD;;GAEG;AACH,UAAU,iBAAiB;IACzB,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,CAAC;IAEpB,qDAAqD;IACrD,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAE7B,iCAAiC;IACjC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB,8CAA8C;IAC9C,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,gBAAgB,KAAK,OAAO,CAAC;IAE/D,uDAAuD;IACvD,QAAQ,CAAC,EAAE,aAAa,CAAC;QACvB,YAAY,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;QACrC,YAAY,CAAC,EAAE,gBAAgB,CAAC;QAChC,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,QAA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AAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,WAEV,CAAC,6CAOnC;AAGD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as o,Fragment as x}from"react/jsx-runtime";import{Stack as p}from"@donotdev/components";import{hasTierAccess as g}from"@donotdev/core";import{useAuth as n}from"../useAuth";import{AuthFallback as z}from"./AuthFallback";function R({requiredTier:e,userTier:i}){return r("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:o(p,{direction:"row",align:"center",gap:"medium",children:[r("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),o("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:e==="pro"?"Pro Feature":"Premium Feature"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",e," to access this feature",i&&` (current: ${i})`]})]})]})})}function v({requiredRole:e,userRole:i}){const s=Array.isArray(e)?e.join(" or "):e;return r("div",{className:"dndev-surface","data-variant":"destructive","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--destructive)",backgroundColor:"var(--muted)"},children:o(p,{direction:"row",align:"center",gap:"medium",children:[r("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),o("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive-foreground)"},children:"Access Denied"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",s," role",i&&` (current: ${i})`]})]})]})})}function b(){return r("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:o(p,{direction:"row",align:"center",gap:"medium",children:[r("span",{style:{color:"var(--accent)"},children:"\u23F0"}),o("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:"Subscription Required"}),r("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:"This feature requires an active subscription"})]})]})})}function T({children:e,role:i,tier:s,subscription:a,validate:d,fallback:t,message:h,showUpgradePrompt:m=!0,showLoginPrompt:l=!0}){const y=n("user"),A=n("loading"),S=n("userProfile"),f=n("userSubscription"),D=n("hasRole"),P=n("hasTier"),u=S?.role,c=f?.tier;return A?r("div",{style:{height:"2rem",borderRadius:"var(--radius)",backgroundColor:"var(--muted)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}):!y&&(i||s||a)?l?r(z,{message:h||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(q=>u===q)?t?r(t,{requiredRole:i,userRole:u||void 0}):r(v,{requiredRole:i,userRole:u||void 0}):s&&!g(c,s)?t?r(t,{requiredTier:s,userTier:c||"free"}):m?r(R,{requiredTier:s,userTier:c||"free"}):null:a&&!f?.isActive?t?r(t,{requiresSubscription:!0,hasSubscription:f?.isActive||!1}):r(b,{}):d&&u&&c&&!d(u,c)?t?r(t,{userRole:u,userTier:c}):r(v,{userRole:u}):r(x,{children:e})}function G(e){const i=n("user"),s=n("userProfile"),a=n("userSubscription"),d=s?.role,t=a?.tier;return!(!i&&(e.role||e.tier||e.subscription)||e.role&&!(Array.isArray(e.role)?e.role:[e.role]).some(l=>d===l)||e.tier&&!g(t,e.tier)||e.subscription&&!a?.isActive||e.validate&&d&&t&&!e.validate(d,t))}function U(e,i){return a=>r(T,{...i,children:r(e,{...a})})}export{v as AccessDenied,T as FeatureGuard,b as SubscriptionExpired,R as UpgradePrompt,G as useCanAccessFeature,U as withFeatureGuard};
1
+ "use client";import{jsx as r,jsxs as o,Fragment as x}from"react/jsx-runtime";import{Stack as p}from"@donotdev/components";import{hasTierAccess as g}from"@donotdev/core";import{useAuth as n}from"../useAuth";import{AuthFallback as z}from"./AuthFallback";function R({requiredTier:e,userTier:i}){return r("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:o(p,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),o("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:e==="pro"?"Pro Feature":"Premium Feature"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",e," to access this feature",i&&` (current: ${i})`]})]})]})})}function v({requiredRole:e,userRole:i}){const s=Array.isArray(e)?e.join(" or "):e;return r("div",{className:"dndev-surface","data-variant":"destructive","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--destructive)",backgroundColor:"var(--muted)"},children:o(p,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),o("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive-foreground)"},children:"Access Denied"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",s," role",i&&` (current: ${i})`]})]})]})})}function b(){return r("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:o(p,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u23F0"}),o("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:"Subscription Required"}),r("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:"This feature requires an active subscription"})]})]})})}function T({children:e,role:i,tier:s,subscription:a,validate:d,fallback:t,message:h,showUpgradePrompt:m=!0,showLoginPrompt:l=!0}){const y=n("user"),A=n("loading"),S=n("userProfile"),f=n("userSubscription"),D=n("hasRole"),P=n("hasTier"),u=S?.role,c=f?.tier;return A?r("div",{style:{height:"2rem",borderRadius:"var(--radius)",backgroundColor:"var(--muted)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}):!y&&(i||s||a)?l?r(z,{message:h||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(q=>u===q)?t?r(t,{requiredRole:i,userRole:u||void 0}):r(v,{requiredRole:i,userRole:u||void 0}):s&&!g(c,s)?t?r(t,{requiredTier:s,userTier:c||"free"}):m?r(R,{requiredTier:s,userTier:c||"free"}):null:a&&!f?.isActive?t?r(t,{requiresSubscription:!0,hasSubscription:f?.isActive||!1}):r(b,{}):d&&u&&c&&!d(u,c)?t?r(t,{userRole:u,userTier:c}):r(v,{userRole:u}):r(x,{children:e})}function G(e){const i=n("user"),s=n("userProfile"),a=n("userSubscription"),d=s?.role,t=a?.tier;return!(!i&&(e.role||e.tier||e.subscription)||e.role&&!(Array.isArray(e.role)?e.role:[e.role]).some(l=>d===l)||e.tier&&!g(t,e.tier)||e.subscription&&!a?.isActive||e.validate&&d&&t&&!e.validate(d,t))}function U(e,i){return a=>r(T,{...i,children:r(e,{...a})})}export{v as AccessDenied,T as FeatureGuard,b as SubscriptionExpired,R as UpgradePrompt,G as useCanAccessFeature,U as withFeatureGuard};
@@ -1 +1 @@
1
- "use client";import{jsx as e,jsxs as N}from"react/jsx-runtime";import{Card as i,Spinner as j,Stack as w}from"@donotdev/components";import{useTranslation as z}from"@donotdev/core";import{useGoogleOneTap as C}from"../hooks/useGoogleOneTap";function T({clientId:s,onSuccess:p,onError:l,autoSelect:m=!0,cancelOnTapOutside:c=!0,className:g="",disabled:o=!1,promptParentId:f,allowedParentOrigins:r,cspNonce:u,clientOnly:a=!1,showErrorDetails:I=!1,loadingComponent:t,errorComponent:G,browserNotSupportedComponent:L}){const{t:h}=z("auth"),{shouldShow:v,isLoaded:E,isLoading:x,error:y,containerRef:S,fedcmSupported:d,isHydrated:n,browserInfo:_}=C({clientId:s,autoSelect:m,cancelOnTapOutside:c,promptParentId:f,disabled:o,onSuccess:p,onError:l,allowedParentOrigins:r,cspNonce:u,clientOnly:a});return o||!v||a&&!n?null:x?t?e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:e(t,{})})}):e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:N(w,{direction:"row",align:"center",gap:"medium",children:[e(j,{}),e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:h("googleOneTapLoading","Loading Google One Tap...")})]})})}):!d||y?null:e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e("div",{ref:S,className:`google-one-tap-container ${g}`.trim(),"data-testid":"google-one-tap","data-fedcm-supported":d,"data-hydrated":n,...r&&{"data-allowed-parent-origins":r.join(",")}})})}var H=T;export{H as default};
1
+ "use client";import{jsx as e,jsxs as N}from"react/jsx-runtime";import{Card as i,Spinner as j,Stack as w}from"@donotdev/components";import{useTranslation as z}from"@donotdev/core";import{useGoogleOneTap as C}from"../hooks/useGoogleOneTap";function T({clientId:s,onSuccess:p,onError:l,autoSelect:m=!0,cancelOnTapOutside:c=!0,className:g="",disabled:o=!1,promptParentId:f,allowedParentOrigins:r,cspNonce:h,clientOnly:a=!1,showErrorDetails:I=!1,loadingComponent:t,errorComponent:G,browserNotSupportedComponent:L}){const{t:u}=z("auth"),{shouldShow:v,isLoaded:E,isLoading:x,error:y,containerRef:S,fedcmSupported:n,isHydrated:d,browserInfo:_}=C({clientId:s,autoSelect:m,cancelOnTapOutside:c,promptParentId:f,disabled:o,onSuccess:p,onError:l,allowedParentOrigins:r,cspNonce:h,clientOnly:a});return o||!v||a&&!d?null:x?t?e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:e(t,{})})}):e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:N(w,{direction:"row",align:"center",children:[e(j,{}),e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:u("googleOneTapLoading","Loading Google One Tap...")})]})})}):!n||y?null:e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e("div",{ref:S,className:`google-one-tap-container ${g}`.trim(),"data-testid":"google-one-tap","data-fedcm-supported":n,"data-hydrated":d,...r&&{"data-allowed-parent-origins":r.join(",")}})})}var H=T;export{H as default};
@@ -38,4 +38,5 @@ export interface MultipleAuthProvidersProps {
38
38
  */
39
39
  declare const MultipleAuthProviders: (props: MultipleAuthProvidersProps) => import("react/jsx-runtime").JSX.Element;
40
40
  export default MultipleAuthProviders;
41
+ export { MultipleAuthProviders };
41
42
  //# sourceMappingURL=MultipleAuthProviders.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultipleAuthProviders.d.ts","sourceRoot":"","sources":["../../src/components/MultipleAuthProviders.tsx"],"names":[],"mappings":"AAeA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAK9D;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,iEAAiE;IACjE,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yCAAyC;IACzC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mGAAmG;IACnG,MAAM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AAG,YAAY,GAAG,MAAM,CAAC;IAC5C,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAChD,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAsID;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,gFAGzB,CAAC;AAGH,eAAe,qBAAqB,CAAC;AAGrC,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -1 +1 @@
1
- "use client";import{jsx as r,jsxs as z}from"react/jsx-runtime";import{Suspense as L,lazy as M}from"react";import{Alert as N,ALERT_VARIANT as S,Stack as T,Grid as $}from"@donotdev/components";import{useTranslation as j,getEnabledAuthPartners as E}from"@donotdev/core";import{useAuth as c}from"../useAuth";import{withAuthFallback as I}from"./AuthFallback";import _ from"./AuthPartnerButton";import{getAuthMethod as q}from"../constants";import{useAccountLinking as y}from"../hooks/useAccountLinking";const B=({providers:u,containerClassName:t="",providerClassName:m="",method:h,size:O="md",layout:e="vertical",showLabels:p=!0,spacing:o="medium",ariaLabel:g,id:f,fullWidth:v=!0,onSuccess:A})=>{const{t:a}=j("auth"),s=f||`auth-providers-${Math.random().toString(36).slice(2,9)}`,{isRequired:b}=y(),x=M(()=>import("./AccountLinking")),P=q(h),i=u||E();if(!i||i.length===0)return r("div",{className:t,children:r("p",{children:"No authentication providers are configured"})});const d=c("error"),R=c("isAvailable"),k=()=>{const l=i.map((n,w)=>r(_,{partnerId:n,method:P,className:`${m} ${v?"dndev-w-full":""}`,tabIndex:w===0?0:void 0,id:`${s}-${n}-button`,onSuccess:A,children:p?void 0:null},n));return e==="grid"?r($,{cols:2,gap:o,className:t,children:l}):r(T,{direction:e==="horizontal"?"row":"column",wrap:e==="horizontal"?"wrap":void 0,gap:o,align:e==="horizontal"?"center":"stretch",className:t,children:l})};return z("div",{className:"dndev-mx-auto",id:s,role:"region","aria-label":g||a("aria.signInOptions","Sign in options"),children:[k(),d&&R&&r(N,{variant:S.ERROR,style:{marginTop:"var(--gap-md)"},description:d.message||a("errorGeneric","Authentication failed. Please try again.")}),b&&r("div",{style:{marginTop:"var(--gap-md)"},children:r(L,{fallback:null,children:r(x,{})})})]})},G=I(B,{message:"Authentication providers are not configured",showLoginButton:!0});var X=G;export{X as default};
1
+ "use client";import{jsx as e,jsxs as L}from"react/jsx-runtime";import{Suspense as I,lazy as N,useId as T}from"react";import{Alert as j,ALERT_VARIANT as E,Stack as M,Grid as S}from"@donotdev/components";import{useTranslation as $,getEnabledAuthPartners as _}from"@donotdev/core";import{useAuth as l}from"../useAuth";import{withAuthFallback as q}from"./AuthFallback";import y from"./AuthPartnerButton";import{getAuthMethod as B}from"../constants";import{useAccountLinking as G}from"../hooks/useAccountLinking";const O=N(()=>import("./AccountLinking")),F=({providers:m,containerClassName:t="",providerClassName:h="",method:p,size:V="md",layout:r="vertical",showLabels:g=!0,spacing:o="medium",ariaLabel:f,id:v,fullWidth:A=!0,onSuccess:b})=>{const{t:s}=$("auth"),x=T(),a=v||x,{isRequired:P}=G(),d=l("error"),R=l("isAvailable"),k=B(p),n=m||_();if(!n||n.length===0)return e("div",{className:t,children:e("p",{children:"No authentication providers are configured"})});const w=()=>{const c=n.map((i,z)=>e(y,{partnerId:i,method:k,className:`${h} ${A?"dndev-w-full":""}`,tabIndex:z===0?0:void 0,id:`${a}-${i}-button`,onSuccess:b,children:g?void 0:null},i));return r==="grid"?e(S,{cols:2,gap:o,className:t,children:c}):e(M,{direction:r==="horizontal"?"row":"column",wrap:r==="horizontal"?"wrap":void 0,gap:o,align:r==="horizontal"?"center":"stretch",className:t,children:c})};return L("div",{className:"dndev-mx-auto",id:a,role:"region","aria-label":f||s("aria.signInOptions","Sign in options"),children:[w(),d&&R&&e(j,{variant:E.ERROR,style:{marginTop:"var(--gap-md)"},description:d.message||s("errorGeneric","Authentication failed. Please try again.")}),P&&e("div",{style:{marginTop:"var(--gap-md)"},children:e(I,{fallback:null,children:e(O,{})})})]})},u=q(F,{message:"Authentication providers are not configured",showLoginButton:!0});var Z=u;export{u as MultipleAuthProviders,Z as default};
@@ -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,{gap:"medium",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 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 +1 @@
1
- "use client";import{jsx as r,jsxs as i,Fragment as U}from"react/jsx-runtime";import"lucide-react";import{useState as o}from"react";import{Button as p,BUTTON_VARIANT as h,Input as m,Label as P,Alert as v,ALERT_VARIANT as A,Dialog as E,Stack as c}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";function I({updatePassword:y}){const{t:s}=N("profile"),[C,n]=o(!1),[e,w]=o(""),[d,g]=o(""),[l,f]=o(!1),[u,t]=o(null),T=async()=>{if(e!==d){t("Passwords do not match");return}if(e.length<6){t("Password must be at least 6 characters long");return}f(!0),t(null);try{await y(e),n(!1),w(""),g("")}catch(a){t(a.message||"Failed to update password")}finally{f(!1)}};return r(E,{open:C,onOpenChange:n,trigger:r(p,{variant:h.OUTLINE,children:s("profile.security.password.change","Change Password")}),title:s("profile.security.password.dialog.title","Change Password"),description:s("profile.security.password.dialog.description","Enter your new password below"),footer:i(U,{children:[r(p,{variant:h.OUTLINE,onClick:()=>n(!1),disabled:l,children:s("profile.security.password.dialog.cancel","Cancel")}),r(p,{onClick:T,disabled:l||!e||!d,children:l?s("profile.security.password.dialog.updating","Updating..."):s("profile.security.password.dialog.update","Update Password")})]}),children:i(c,{gap:"medium",children:[i(c,{gap:"tight",children:[r(P,{htmlFor:"newPassword",children:s("profile.security.password.dialog.newPassword","New Password")}),r(m,{id:"newPassword",type:"password",value:e,onChange:a=>w(a.target.value),placeholder:"Enter new password"})]}),i(c,{gap:"tight",children:[r(P,{htmlFor:"confirmPassword",children:s("profile.security.password.dialog.confirmPassword","Confirm Password")}),r(m,{id:"confirmPassword",type:"password",value:d,onChange:a=>g(a.target.value),placeholder:"Confirm new password"})]}),u&&r(v,{variant:A.ERROR,description:u})]})})}var j=I;export{j as default};
1
+ "use client";import{jsx as r,jsxs as i,Fragment as U}from"react/jsx-runtime";import"lucide-react";import{useState as o}from"react";import{Button as p,BUTTON_VARIANT as h,Input as m,Label as P,Alert as v,ALERT_VARIANT as A,Dialog as E,Stack as c}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";function I({updatePassword:y}){const{t:s}=N("profile"),[C,n]=o(!1),[e,w]=o(""),[d,g]=o(""),[l,f]=o(!1),[u,t]=o(null),T=async()=>{if(e!==d){t("Passwords do not match");return}if(e.length<8){t("Password must be at least 8 characters long");return}f(!0),t(null);try{await y(e),n(!1),w(""),g("")}catch(a){t(a.message||"Failed to update password")}finally{f(!1)}};return r(E,{open:C,onOpenChange:n,trigger:r(p,{variant:h.OUTLINE,children:s("profile.security.password.change","Change Password")}),title:s("profile.security.password.dialog.title","Change Password"),description:s("profile.security.password.dialog.description","Enter your new password below"),footer:i(U,{children:[r(p,{variant:h.OUTLINE,onClick:()=>n(!1),disabled:l,children:s("profile.security.password.dialog.cancel","Cancel")}),r(p,{onClick:T,disabled:l||!e||!d,children:l?s("profile.security.password.dialog.updating","Updating..."):s("profile.security.password.dialog.update","Update Password")})]}),children:i(c,{children:[i(c,{gap:"tight",children:[r(P,{htmlFor:"newPassword",children:s("profile.security.password.dialog.newPassword","New Password")}),r(m,{id:"newPassword",type:"password",value:e,onChange:a=>w(a.target.value),placeholder:"Enter new password"})]}),i(c,{gap:"tight",children:[r(P,{htmlFor:"confirmPassword",children:s("profile.security.password.dialog.confirmPassword","Confirm Password")}),r(m,{id:"confirmPassword",type:"password",value:d,onChange:a=>g(a.target.value),placeholder:"Confirm new password"})]}),u&&r(v,{variant:A.ERROR,description:u})]})})}var j=I;export{j as default};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MultipleAuthProviders.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultipleAuthProviders.test.d.ts","sourceRoot":"","sources":["../../../src/components/__tests__/MultipleAuthProviders.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ import{jsx as t}from"react/jsx-runtime";import{describe as b,it as i,expect as u,vi as r,beforeEach as m}from"vitest";import{render as n,screen as c,fireEvent as h}from"@testing-library/react";import l from"../MultipleAuthProviders";const d=r.fn();r.mock("../../hooks/useAuth",()=>({useAuth:()=>({signInWithProvider:d})})),r.mock("@donotdev/components",()=>({Button:({children:e,onClick:o,...s})=>t("button",{onClick:o,...s,children:e}),Stack:({children:e,...o})=>t("div",{...o,children:e})})),b("MultipleAuthProviders",()=>{const e=["google","github"];m(()=>{r.clearAllMocks()}),i("renders all provided auth providers",()=>{n(t(l,{providers:e})),u(c.getByRole("button")).toBeDefined()}),i("calls signInWithProvider when provider button clicked",()=>{n(t(l,{providers:e}));const s=c.getAllByRole("button")[0];s&&(h.click(s),u(d).toHaveBeenCalled())}),i("calls onSuccess callback after successful auth",async()=>{const o=r.fn();d.mockResolvedValue({user:{id:"123"}}),n(t(l,{providers:e,onSuccess:o}));const a=c.getAllByRole("button")[0];a&&(h.click(a),await new Promise(v=>setTimeout(v,100)))}),i("shows labels when showLabels is true",()=>{n(t(l,{providers:e,showLabels:!0})),u(c.getAllByRole("button").length).toBeGreaterThan(0)})});