@donotdev/auth 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AuthStore.js +1 -1
- package/dist/FirebaseAccountLinking.js +1 -1
- package/dist/FirebaseAuth.d.ts.map +1 -1
- package/dist/FirebaseAuth.js +1 -1
- package/dist/FirebaseSmartRecovery.js +1 -1
- package/dist/authHelpers.js +1 -1
- package/dist/components/AccountLinking.js +1 -1
- package/dist/components/AuthFallback.js +1 -1
- package/dist/components/AuthPartnerButton.js +2 -2
- package/dist/components/DeleteAccountDialogs.js +1 -1
- package/dist/components/EmailLinkForm.js +1 -1
- package/dist/components/EmailPasswordForm.js +1 -1
- package/dist/components/EmailVerification.js +1 -1
- package/dist/components/Feature.d.ts.map +1 -1
- package/dist/components/Feature.js +1 -1
- package/dist/components/FeatureGuard.d.ts.map +1 -1
- package/dist/components/FeatureGuard.js +1 -1
- package/dist/components/FeaturePlaceholder.js +1 -1
- package/dist/components/GoogleOneTap.js +1 -1
- package/dist/components/LoginModal.js +1 -1
- package/dist/components/MultipleAuthProviders.js +1 -1
- package/dist/components/NetworkStatusIndicator.js +1 -1
- package/dist/components/PasswordStrengthIndicator.js +1 -1
- package/dist/components/PasswordUpdateDialog.js +1 -1
- package/dist/components/RateLimitAlert.js +1 -1
- package/dist/components/__tests__/MultipleAuthProviders.test.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/hooks/useAccountLinking.js +1 -1
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.js +1 -1
- package/dist/hooks/useDeleteAccount.js +1 -1
- package/dist/hooks/useEmailLinkAuth.js +1 -1
- package/dist/hooks/useEmailLinkForm.js +1 -1
- package/dist/hooks/useFedCM.js +1 -1
- package/dist/hooks/useGoogleOneTap.js +1 -1
- package/dist/hooks/useNetworkStatus.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts.map +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as l,useCallback as t}from"react";function g({defaultValue:u="popup"}={}){const[o,e]=l(u),d=o==="redirect",r=o==="popup",i=t(()=>{e(p=>p==="redirect"?"popup":"redirect")},[]),s=t(()=>{e("redirect")},[]),a=t(()=>{e("popup")},[]),c=t(p=>{e(p?"redirect":"popup")},[]);return{isRedirectMode:d,isPopupMode:r,authMethod:o,toggleMode:i,setRedirectMode:s,setPopupMode:a,handleToggleChange:c}}export{g as useAuthMethodToggle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
1
|
+
"use client";import{useCallback as a}from"react";import"../constants";import{useAuth as o}from"../useAuth";function P(t,h={}){const g=o("getPartnerState"),r=o("setPartnerState"),d=o("signInWithPartner"),i=o("partnerError"),{onSuccess:s,onError:l}=h,u=g(t),p=u==="authenticated",m=u==="loading",e=i?.partnerId===t,E=e&&i?.error?new Error(i.error):null,c=a(()=>{e&&r(t,"idle")},[e,t,r]),S=a(()=>{r(t,"loading")},[t,r]),f=a(()=>{r(t,"idle")},[t,r]),A=a(async I=>{e&&c();try{r(t,"loading");const n=await d(t,I);if(n===null){r(t,"idle");return}n&&s&&s(n)}catch(n){r(t,"error",n),l&&l(n)}},[t,e,c,r,d,s,l]);return{partnerState:u,isAuthenticated:p,isAuthenticating:m,hasError:e,error:E,handleSignIn:A,clearError:c,setLoading:S,setIdle:f}}export{P as useAuthPartner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as o}from"react";import{useAuth as f}from"../useAuth";function A(){const c=f("deleteAccount"),[r,e]=o(!1),[u,t]=o(!1),[i,n]=o(!1),[m,l]=o(null);return{showConfirmDialog:r,showPasswordDialog:u,isDeleting:i,error:m,startDeleteFlow:()=>{l(null),e(!0)},confirmDelete:async D=>{n(!0),l(null);try{await c(D),e(!1),t(!1)}catch(a){const s=a.message||a.message;s==="REQUIRES_PASSWORD"?(e(!1),t(!0)):s==="REAUTH_CANCELLED"?(e(!1),t(!1)):l(s||"Failed to delete account")}finally{n(!1)}},cancel:()=>{e(!1),t(!1),l(null)}}}export{A as useDeleteAccount};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as
|
|
1
|
+
"use client";import{useEffect as E,useState as t,useCallback as I}from"react";import{handleError as h,isDev as s}from"@donotdev/core";import{useAuth as l}from"../useAuth";function o(){const r=l("isSignInWithEmailLink"),a=l("signInWithEmailLink"),[m,e]=t(!1),[c,n]=t(null),u=r();E(()=>{if(typeof window<"u"){const i=localStorage.getItem("emailForSignIn");i&&n(i)}},[]);const f=I(async i=>{if(!i){s();return}e(!0);try{s(),(await a(i))?.success&&(localStorage.removeItem("emailForSignIn"),n(null))}catch(g){h(g)}finally{e(!1)}},[a]);return{isEmailLink:u,isProcessing:m,email:c,completeEmailLinkSignIn:f}}var k=o;export{k as default,o as useEmailLinkAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as r,useCallback as l}from"react";import{handleError as w}from"@donotdev/core";import{useAuth as f}from"../useAuth";function S(g={}){const t=f("sendSignInLinkToEmail"),E=f("isAvailable"),{onSuccess:s,onError:o,actionCodeSettings:m}=g,[e,h]=r(""),[u,d]=r(!1),[p,c]=r(!1),[k,n]=r(null),a=e.trim().length>0&&e.includes("@"),v=a&&!u&&E,y=l(()=>{n(null)},[]),L=l(async F=>{if(F.preventDefault(),!a){n("Please enter a valid email address");return}d(!0),n(null);try{typeof window<"u"&&localStorage.setItem("emailForSignIn",e.trim()),await t(e.trim(),m),c(!0),s?.()}catch(i){const I=i instanceof Error?i.message:"Failed to send sign-in link";n(I),o?.(i),w(i)}finally{d(!1)}},[e,a,t,m,s,o]),b=l(()=>{c(!1),n(null)},[]);return{email:e,setEmail:h,isLoading:u,isSent:p,error:k,handleSendLink:L,handleResend:b,clearError:y,isValid:a,canSubmit:v}}var A=S;export{A as default,S as useEmailLinkForm};
|
package/dist/hooks/useFedCM.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as s,useEffect as h,useMemo as C,useRef as E}from"react";import{handleError as S,isClient as u}from"@donotdev/core";function y({checkGoogleServices:a=!0,onError:i}={}){const[n,l]=s(!1),[m,d]=s(!1),[p,f]=s(null),c=E(i);c.current=i,h(()=>{u()&&(async()=>{try{const e="IdentityCredential"in window;let o=!0;if(a){const t=new Promise(r=>setTimeout(r,2e3));await Promise.race([new Promise(r=>{const w=setInterval(()=>{window.google?.accounts?.id&&(clearInterval(w),r(!0))},100)}),t]),o=!!window.google?.accounts?.id}l(e&&o),d(!0)}catch(e){const o=S(e,{userMessage:"Failed to detect FedCM support",context:{operation:"fedcm_detection"},severity:"warning"});f(o),d(!0),c.current?.(o)}})()},[a]);const g=C(()=>{if(!u())return{name:"Unknown",isSupported:!1,recommendation:"Loading..."};const e=navigator.userAgent;let o="Unknown",t="Please update your browser";if(e.includes("Chrome/")){const r=parseInt(e.match(/Chrome\/(\d+)/)?.[1]||"0");o=`Chrome ${r}`,t=r>=116?"Supported":"Please update to Chrome 116 or later"}else if(e.includes("Edg/")){const r=parseInt(e.match(/Edg\/(\d+)/)?.[1]||"0");o=`Edge ${r}`,t=r>=116?"Supported":"Please update to Edge 116 or later"}else e.includes("Safari/")&&!e.includes("Chrome")?(o="Safari",t="Not supported yet. Please use Chrome or Edge"):e.includes("Firefox/")&&(o="Firefox",t="Not supported yet. Please use Chrome or Edge");return{name:o,isSupported:n,recommendation:t}},[n]);return{isSupported:n,isReady:m,error:p,browserInfo:g}}export{y as useFedCM};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as G,useEffect as L,useRef as f,useCallback as j,startTransition as _,useMemo as B}from"react";import{useIsDark as te}from"@donotdev/components";import{handleError as g,getOAuthClientId as oe,getEnabledAuthPartners as re,isClient as ne,useTranslation as ae,useScriptLoader as ie}from"@donotdev/core";import{useAuth as J}from"../useAuth";import{useFedCM as se}from"./useFedCM";function ce({clientId:K,autoSelect:x=!0,cancelOnTapOutside:v=!0,promptParentId:y,disabled:l=!1,onSuccess:C,onError:i,allowedParentOrigins:z,cspNonce:S,clientOnly:R=!1}={}){const{t:n}=ae("auth"),T=J("user"),A=J("signInWithGoogleCredential"),I=te(),s=K||oe("google"),E=re().includes("google"),{isSupported:r,isReady:d,error:F,browserInfo:U}=se({checkGoogleServices:!0,onError:t=>{const o=g(t,{userMessage:n("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});i?.(o)}}),{isLoading:V,isLoaded:O,error:P,isReady:q,load:X,loadTriggered:Z}=ie("https://accounts.google.com/gsi/client",{enabled:E&&!!s&&!l&&d&&r,nonce:S,checkExisting:!0,isLoaded:()=>!!window.google?.accounts?.id,onError:t=>{const o=g(t,{userMessage:n("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});i?.(o)}}),[b,$]=G(!1),[N,W]=G(null),Q=f(null),a=f(!1),c=f(null),D=f(0),[H,p]=G(!1),m="gsi_hide_until",w=600*1e3,M=B(()=>E&&!!s&&!l&&!T&&r&&(R?b:!0)&&!H,[E,s,l,T,r,R,b,H]),ee=B(()=>!r&&d?new Error(n("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):P||F||N,[P,F,N,r,d,n]),h=j(async t=>{try{if(!t||typeof t!="string")throw new Error("Invalid credential format");await A(t),_(()=>{C?.(t)})}catch(o){const e=g(o,{userMessage:n("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:t?.length||0},severity:"error"});throw _(()=>{W(e)}),i?.(e),e}},[A,C,i,n]),k=j(()=>{if(!ne()||!q||!s||!window.google?.accounts?.id||!r||a.current)return;const t=Date.now();if(!(t-D.current<w&&D.current>0))try{a.current=!0,D.current=t;const o={client_id:s,callback:async e=>{try{await h(e.credential)}catch(Y){g(Y,{userMessage:"Google One Tap credential handling failed",context:{operation:"google_one_tap_callback"},severity:"error"})}},auto_select:x,cancel_on_tap_outside:v,context:"signin",ux_mode:"popup",itp_support:!0,state:I?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:z,csp_nonce:S,moment_callback:e=>{const Y=e.getMomentType();if(e.isDisplayMoment?.()){if(!e.isDisplayed?.()&&e.getNotDisplayedReason){a.current=!1;try{const u=Date.now()+w;localStorage.setItem(m,String(u)),p(!0)}catch{}}}else if(e.isSkippedMoment?.()){a.current=!1;try{const u=Date.now()+w;localStorage.setItem(m,String(u)),p(!0)}catch{}}else if(e.isDismissedMoment?.()){a.current=!1;try{const u=Date.now()+w;localStorage.setItem(m,String(u)),p(!0)}catch{}}}};y&&(o.prompt_parent_id=y),window.google.accounts.id.initialize(o),c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{window.google?.accounts?.id?.prompt(e=>{e?.credential&&h(e.credential)}),c.current=null},100)}catch(o){const e=g(o,{userMessage:n("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});_(()=>{W(e)}),i?.(e),a.current=!1}},[q,s,r,x,v,y,I,h,i,z,S,n]);return L(()=>{if(typeof window<"u"){_(()=>{$(!0)});try{const t=Number(localStorage.getItem(m)||0);p(t>Date.now())}catch{}}},[]),L(()=>{O&&!l&&M&&d&&k()},[O,l,M,d,k]),L(()=>()=>{c.current&&window.clearTimeout(c.current),a.current=!1},[]),{isLoaded:O,isLoading:V,error:ee,user:T,isDark:I,fedcmSupported:r,isHydrated:b,containerRef:Q,initialize:k,handleCredential:h,shouldShow:M,browserInfo:U,triggerLoad:X,loadTriggered:Z}}export{ce as useGoogleOneTap};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as r,useEffect as w}from"react";import{isClient as s}from"@donotdev/core";function l(){const[n,o]=r(()=>s()?navigator.onLine:!0),[e,f]=r("unknown");return w(()=>{if(!s())return;const i=()=>o(!0),t=()=>o(!1),a=()=>{if("connection"in navigator){const c=navigator.connection;f(c.effectiveType||"unknown")}};return window.addEventListener("online",i),window.addEventListener("offline",t),a(),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",t)}},[]),{online:n,connectionType:e,isSlowConnection:e==="slow-2g"||e==="2g",isOnline:n,isOffline:!n}}export{l as useNetworkStatus};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,8 @@ AuthUser as User, // Rename AuthUser to User for public API simplicity
|
|
|
16
16
|
UserRole, SubscriptionTier, } from '@donotdev/core';
|
|
17
17
|
export { getAuthMethod } from './constants';
|
|
18
18
|
export type { AuthMethod } from './constants';
|
|
19
|
-
export type { AuthPartnerButtonProps, GoogleOneTapProps, LoginModalProps,
|
|
19
|
+
export type { AuthPartnerButtonProps, GoogleOneTapProps, LoginModalProps, } from './constants';
|
|
20
|
+
export type { MultipleAuthProvidersProps } from './components/MultipleAuthProviders';
|
|
20
21
|
export type { FeatureGuardProps } from './components/FeatureGuard';
|
|
21
22
|
export type { ConfirmDeleteDialogProps, ReauthDialogProps, } from './components/DeleteAccountDialogs';
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG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AC;AACrB,YAAY,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrF,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,YAAY,EACV,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useAuth as
|
|
1
|
+
import{useAuth as t}from"./useAuth";import{useDeleteAccount as e}from"./hooks/useDeleteAccount";import{getAuthState as a,subscribeToAuth as o}from"./authHelpers";import{AuthPartnerButton as s,ConfirmDeleteDialog as u,FeatureGuard as r,GoogleOneTap as i,LoginModal as h,MultipleAuthProviders as l,ReauthDialog as A}from"./components";import{getAuthMethod as g}from"./constants";export{s as AuthPartnerButton,u as ConfirmDeleteDialog,r as FeatureGuard,i as GoogleOneTap,h as LoginModal,l as MultipleAuthProviders,A as ReauthDialog,g as getAuthMethod,a as getAuthState,o as subscribeToAuth,t as useAuth,e as useDeleteAccount};
|