@donotdev/auth 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/AuthStore.d.ts +4 -9
  2. package/dist/AuthStore.d.ts.map +1 -1
  3. package/dist/AuthStore.js +1 -1
  4. package/dist/FirebaseAccountLinking.js +1 -1
  5. package/dist/FirebaseAuth.js +1 -1
  6. package/dist/FirebaseSmartRecovery.js +1 -1
  7. package/dist/authHelpers.js +1 -1
  8. package/dist/components/AccountLinking.js +1 -1
  9. package/dist/components/AuthFallback.js +1 -1
  10. package/dist/components/AuthPartnerButton.js +2 -2
  11. package/dist/components/DeleteAccountDialogs.js +1 -1
  12. package/dist/components/EmailLinkForm.js +1 -1
  13. package/dist/components/EmailPasswordForm.js +1 -1
  14. package/dist/components/EmailVerification.js +1 -1
  15. package/dist/components/Feature.js +1 -1
  16. package/dist/components/FeatureGuard.js +1 -1
  17. package/dist/components/FeaturePlaceholder.js +1 -1
  18. package/dist/components/GoogleOneTap.js +1 -1
  19. package/dist/components/LoginModal.js +1 -1
  20. package/dist/components/MultipleAuthProviders.js +1 -1
  21. package/dist/components/NetworkStatusIndicator.js +1 -1
  22. package/dist/components/PasswordUpdateDialog.js +1 -1
  23. package/dist/components/RateLimitAlert.js +1 -1
  24. package/dist/components/index.js +1 -1
  25. package/dist/constants.js +1 -1
  26. package/dist/hooks/useAccountLinking.js +1 -1
  27. package/dist/hooks/useAuthMethodToggle.js +1 -1
  28. package/dist/hooks/useAuthPartner.js +1 -1
  29. package/dist/hooks/useDeleteAccount.js +1 -1
  30. package/dist/hooks/useEmailLinkAuth.js +1 -1
  31. package/dist/hooks/useEmailLinkForm.js +1 -1
  32. package/dist/hooks/useFedCM.js +1 -1
  33. package/dist/hooks/useGoogleOneTap.d.ts +0 -91
  34. package/dist/hooks/useGoogleOneTap.d.ts.map +1 -1
  35. package/dist/hooks/useGoogleOneTap.js +1 -1
  36. package/dist/hooks/useNetworkStatus.js +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/dist/useAuth.d.ts +15 -6
  40. package/dist/useAuth.d.ts.map +1 -1
  41. package/dist/useAuth.js +1 -1
  42. package/package.json +5 -5
@@ -1,94 +1,3 @@
1
- /**
2
- * Google credential response from One Tap
3
- */
4
- interface GoogleCredentialResponse {
5
- /** JWT credential token */
6
- credential: string;
7
- /** How the user selected the credential */
8
- select_by: string;
9
- }
10
- /**
11
- * Google One Tap configuration (October 2025)
12
- */
13
- interface GoogleOneTapConfig {
14
- /** OAuth 2.0 client ID */
15
- client_id: string;
16
- /** Callback for successful authentication */
17
- callback: (response: GoogleCredentialResponse) => void;
18
- /** Whether to cancel on tap outside */
19
- cancel_on_tap_outside?: boolean;
20
- /** Whether to auto-select returning users */
21
- auto_select?: boolean;
22
- /** Authentication context */
23
- context?: 'signin' | 'signup' | 'use';
24
- /** UX mode */
25
- ux_mode?: 'popup' | 'redirect';
26
- /** ITP support for Safari (though Safari doesn't support FedCM yet) */
27
- itp_support?: boolean;
28
- /** Optional nonce for security */
29
- nonce?: string;
30
- /** Optional parent element ID */
31
- prompt_parent_id?: string;
32
- /** Optional state parameter */
33
- state?: string;
34
- /** MANDATORY: Always true for October 2025 */
35
- use_fedcm_for_prompt: true;
36
- /** Optional allowed parent origins */
37
- allowed_parent_origins?: string[];
38
- /** Optional CSP nonce */
39
- csp_nonce?: string;
40
- /**
41
- * Moment callback - THE ONLY place for status handling (October 2025)
42
- *
43
- * @description
44
- * All display, skip, and dismiss status must be handled here.
45
- * The prompt() callback should only handle credentials.
46
- */
47
- moment_callback: (notification: GoogleMomentNotification) => void;
48
- }
49
- /**
50
- * Google One Tap moment notification (October 2025)
51
- *
52
- * @description
53
- * Replaces all deprecated status methods in prompt() callback.
54
- * Use these methods exclusively in moment_callback.
55
- */
56
- interface GoogleMomentNotification {
57
- /** Get the moment type */
58
- getMomentType: () => 'display' | 'skipped' | 'dismissed';
59
- /** Get skip reason (only for skipped moment) */
60
- getSkippedReason?: () => string;
61
- /** Get not displayed reason (only for display moment when not displayed) */
62
- getNotDisplayedReason?: () => string;
63
- /** Get dismissed reason (only for dismissed moment) */
64
- getDismissedReason?: () => string;
65
- /** Check if this is a display moment */
66
- isDisplayMoment?: () => boolean;
67
- /** Check if displayed (only for display moment) */
68
- isDisplayed?: () => boolean;
69
- /** Check if this is a skipped moment */
70
- isSkippedMoment?: () => boolean;
71
- /** Check if this is a dismissed moment */
72
- isDismissedMoment?: () => boolean;
73
- }
74
- /**
75
- * Global window interface extensions
76
- */
77
- declare global {
78
- interface Window {
79
- google?: {
80
- accounts?: {
81
- id: {
82
- initialize: (config: GoogleOneTapConfig) => void;
83
- prompt: (callback?: (notification: any) => void) => void;
84
- cancel?: () => void;
85
- disableAutoSelect?: () => void;
86
- };
87
- };
88
- };
89
- IdentityCredential?: any;
90
- }
91
- }
92
1
  /**
93
2
  * Hook options
94
3
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useGoogleOneTap.d.ts","sourceRoot":"","sources":["../../src/hooks/useGoogleOneTap.ts"],"names":[],"mappings":"AA8CA;;GAEG;AACH,UAAU,wBAAwB;IAChC,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,UAAU,kBAAkB;IAC1B,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAElB,6CAA6C;IAC7C,QAAQ,EAAE,CAAC,QAAQ,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAEvD,uCAAuC;IACvC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,6CAA6C;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,6BAA6B;IAC7B,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;IAEtC,cAAc;IACd,OAAO,CAAC,EAAE,OAAO,G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c,EACd,QAAgB,EAChB,SAAS,EACT,OAAO,EACP,oBAAoB,EACpB,QAAQ,EACR,UAAkB,GACnB,GAAE,sBAA2B,GAAG,qBAAqB,CAmWrD"}
@@ -1 +1 @@
1
- "use client";import{useState as L,useEffect as k,useRef as _,useCallback as B,startTransition as y,useMemo as K}from"react";import{handleError as p,getOAuthClientId as te,getEnabledAuthPartners as re,isClient as ne,useTranslation as ie,useScriptLoader as ae}from"@donotdev/core";import{useIsDark as se}from"@donotdev/components";import{useAuth as Q}from"../useAuth";import{useFedCM as ce}from"./useFedCM";function le({clientId:U,autoSelect:x=!0,cancelOnTapOutside:C=!0,promptParentId:S,disabled:d=!1,onSuccess:R,onError:s,allowedParentOrigins:A,cspNonce:I,clientOnly:F=!1}={}){const{t:r}=ie("dndev"),T=Q("user"),P=Q("signInWithGoogleCredential"),b=se(),c=U||te("google"),D=re().includes("google"),{isSupported:t,isReady:g,error:q,browserInfo:V}=ce({checkGoogleServices:!0,onError:e=>{const a=p(e,{userMessage:r("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});s?.(a)}}),{isLoading:X,isLoaded:M,error:z,isReady:N,load:Z,loadTriggered:$}=ae("https://accounts.google.com/gsi/client",{enabled:D&&!!c&&!d&&g&&t,nonce:I,checkExisting:!0,isLoaded:()=>!!window.google?.accounts?.id,onError:e=>{const a=p(e,{userMessage:r("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});s?.(a)}}),[O,J]=L(!1),[Y,H]=L(null),ee=_(null),i=_(!1),l=_(null),E=_(0),[W,m]=L(!1),w="gsi_hide_until",de=600*1e3,v=K(()=>D&&!!c&&!d&&!T&&t&&(F?O:!0)&&!W,[D,c,d,T,t,F,O,W]),oe=K(()=>!t&&g?new Error(r("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):z||q||Y,[z,q,Y,t,g,r]),f=B(async e=>{try{if(!e||typeof e!="string")throw new Error("Invalid credential format");await P(e),y(()=>{R?.(e)})}catch(a){const n=p(a,{userMessage:r("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:e?.length||0},severity:"error"});throw y(()=>{H(n)}),s?.(n),n}},[P,R,s,r]),G=B(()=>{if(!ne()||!N||!c||!window.google?.accounts?.id||!t||i.current)return;const e=Date.now(),a=e-E.current,n=600*1e3;if(!(a<n&&E.current>0))try{i.current=!0,E.current=e;const h={client_id:c,callback:async o=>{try{await f(o.credential)}catch(j){p(j,{userMessage:"Google One Tap credential handling failed",context:{operation:"google_one_tap_callback"},severity:"error"})}},auto_select:x,cancel_on_tap_outside:C,context:"signin",ux_mode:"popup",itp_support:!0,state:b?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:A,csp_nonce:I,moment_callback:o=>{const j=o.getMomentType();if(o.isDisplayMoment?.()){if(!o.isDisplayed?.()&&o.getNotDisplayedReason){i.current=!1;try{const u=Date.now()+n;localStorage.setItem(w,String(u)),m(!0)}catch{}}}else if(o.isSkippedMoment?.()){i.current=!1;try{const u=Date.now()+n;localStorage.setItem(w,String(u)),m(!0)}catch{}}else if(o.isDismissedMoment?.()){i.current=!1;try{const u=Date.now()+n;localStorage.setItem(w,String(u)),m(!0)}catch{}}}};S&&(h.prompt_parent_id=S),window.google.accounts.id.initialize(h),l.current&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{window.google?.accounts?.id.prompt(o=>{o?.credential&&f(o.credential)}),l.current=null},100)}catch(h){const o=p(h,{userMessage:r("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:t},severity:"error"});y(()=>{H(o)}),s?.(o),i.current=!1}},[N,c,t,x,C,S,b,f,s,A,I,r]);return k(()=>{if(typeof window<"u"){y(()=>{J(!0)});try{const e=Number(localStorage.getItem(w)||0);m(e>Date.now())}catch{}}},[]),k(()=>{M&&!d&&v&&g&&G()},[M,d,v,g,G]),k(()=>()=>{l.current&&window.clearTimeout(l.current),i.current=!1},[]),{isLoaded:M,isLoading:X,error:oe,user:T,isDark:b,fedcmSupported:t,isHydrated:O,containerRef:ee,initialize:G,handleCredential:f,shouldShow:v,browserInfo:V,triggerLoad:Z,loadTriggered:$}}export{le as useGoogleOneTap};
1
+ "use client";import{useState as R,useEffect as b,useRef as _,useCallback as K,startTransition as y,useMemo as j}from"react";import{handleError as p,getOAuthClientId as re,getEnabledAuthPartners as oe,isClient as ne,useTranslation as ie,useScriptLoader as se}from"@donotdev/core";import{useIsDark as ae}from"@donotdev/components";import{useAuth as B}from"../useAuth";import{useFedCM as ce}from"./useFedCM";function he({clientId:J,autoSelect:k=!0,cancelOnTapOutside:x=!0,promptParentId:T,disabled:u=!1,onSuccess:O,onError:a,allowedParentOrigins:N,cspNonce:E,clientOnly:z=!1}={}){const{t:o}=ie("dndev"),S=B("user"),A=B("signInWithGoogleCredential"),I=ae(),c=J||re("google"),L=oe().includes("google"),{isSupported:r,isReady:d,error:U,browserInfo:Q}=ce({checkGoogleServices:!0,onError:e=>{const s=p(e,{userMessage:o("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});a?.(s)}}),{isLoading:V,isLoaded:M,error:F,isReady:W,load:X,loadTriggered:Z}=se("https://accounts.google.com/gsi/client",{enabled:L&&!!c&&!u&&d&&r,nonce:E,checkExisting:!0,isLoaded:()=>!!window.google?.accounts?.id,onError:e=>{const s=p(e,{userMessage:o("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});a?.(s)}}),[D,$]=R(!1),[q,H]=R(null),ee=_(null),i=_(!1),l=_(null),v=_(0),[P,f]=R(!1),m="gsi_hide_until",ue=600*1e3,C=j(()=>L&&!!c&&!u&&!S&&r&&(z?D:!0)&&!P,[L,c,u,S,r,z,D,P]),te=j(()=>!r&&d?new Error(o("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):F||U||q,[F,U,q,r,d,o]),h=K(async e=>{try{if(!e||typeof e!="string")throw new Error("Invalid credential format");await A(e),y(()=>{O?.(e)})}catch(s){const n=p(s,{userMessage:o("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:e?.length||0},severity:"error"});throw y(()=>{H(n)}),a?.(n),n}},[A,O,a,o]),G=K(()=>{if(!ne()||!W||!c||!window.google?.accounts?.id||!r||i.current)return;const e=Date.now(),s=e-v.current,n=600*1e3;if(!(s<n&&v.current>0))try{i.current=!0,v.current=e;const w={client_id:c,callback:async t=>{try{await h(t.credential)}catch(Y){p(Y,{userMessage:"Google One Tap credential handling failed",context:{operation:"google_one_tap_callback"},severity:"error"})}},auto_select:k,cancel_on_tap_outside:x,context:"signin",ux_mode:"popup",itp_support:!0,state:I?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:N,csp_nonce:E,moment_callback:t=>{const Y=t.getMomentType();if(t.isDisplayMoment?.()){if(!t.isDisplayed?.()){if(t.getNotDisplayedReason){i.current=!1;try{const g=Date.now()+n;localStorage.setItem(m,String(g)),f(!0)}catch{}}}}else if(t.isSkippedMoment?.()){i.current=!1;try{const g=Date.now()+n;localStorage.setItem(m,String(g)),f(!0)}catch{}}else if(t.isDismissedMoment?.()){i.current=!1;try{const g=Date.now()+n;localStorage.setItem(m,String(g)),f(!0)}catch{}}}};T&&(w.prompt_parent_id=T),window.google.accounts.id.initialize(w),l.current&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{window.google?.accounts?.id?.prompt(t=>{t?.credential&&h(t.credential)}),l.current=null},100)}catch(w){const t=p(w,{userMessage:o("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});y(()=>{H(t)}),a?.(t),i.current=!1}},[W,c,r,k,x,T,I,h,a,N,E,o]);return b(()=>{if(typeof window<"u"){y(()=>{$(!0)});try{const e=Number(localStorage.getItem(m)||0);f(e>Date.now())}catch{}}},[]),b(()=>{M&&!u&&C&&d&&G()},[M,u,C,d,G]),b(()=>()=>{l.current&&window.clearTimeout(l.current),i.current=!1},[]),{isLoaded:M,isLoading:V,error:te,user:S,isDark:I,fedcmSupported:r,isHydrated:D,containerRef:ee,initialize:G,handleCredential:h,shouldShow:C,browserInfo:Q,triggerLoad:X,loadTriggered:Z}}export{he as useGoogleOneTap};
@@ -1 +1 @@
1
- "use client";import{useState as r,useEffect as w}from"react";import{isClient as s}from"@donotdev/core";function l(){const[n,o]=r(()=>s()?navigator.onLine:!0),[e,f]=r("unknown");return w(()=>{if(!s())return;const i=()=>o(!0),t=()=>o(!1),c=()=>{if("connection"in navigator){const a=navigator.connection;f(a.effectiveType||"unknown")}};return window.addEventListener("online",i),window.addEventListener("offline",t),c(),()=>{window.removeEventListener("online",i),window.removeEventListener("offline",t)}},[]),{online:n,connectionType:e,isSlowConnection:e==="slow-2g"||e==="2g",isOnline:n,isOffline:!n}}export{l as useNetworkStatus};
1
+ "use client";import{useState as s,useEffect as u}from"react";import{isClient as c}from"@donotdev/core";function O(){const[n,o]=s(()=>c()?navigator.onLine:!0),[e,r]=s("unknown");return u(()=>{if(!c())return;const t=()=>o(!0),i=()=>o(!1),f=()=>{if("connection"in navigator){const l=navigator.connection;r(l.effectiveType||"unknown")}};return window.addEventListener("online",t),window.addEventListener("offline",i),f(),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}},[]),{online:n,connectionType:e,isSlowConnection:e==="slow-2g"||e==="2g",isOnline:n,isOffline:!n}}export{O as useNetworkStatus};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{useAuth as a}from"./useAuth";import{useDeleteAccount as e}from"./hooks/useDeleteAccount";import{getAuthState as t,subscribeToAuth as s}from"./authHelpers";import{AuthPartnerButton as o,ConfirmDeleteDialog as u,FeatureGuard as r,GoogleOneTap as i,LoginModal as l,MultipleAuthProviders as n,ReauthDialog as A}from"./components";export{o as AuthPartnerButton,u as ConfirmDeleteDialog,r as FeatureGuard,i as GoogleOneTap,l as LoginModal,n as MultipleAuthProviders,A as ReauthDialog,t as getAuthState,s as subscribeToAuth,a as useAuth,e as useDeleteAccount};
1
+ import{useAuth as o}from"./useAuth";import{useDeleteAccount as u}from"./hooks/useDeleteAccount";import{getAuthState as l,subscribeToAuth as i}from"./authHelpers";import{AuthPartnerButton as n,ConfirmDeleteDialog as p,FeatureGuard as A,GoogleOneTap as f,LoginModal as g,MultipleAuthProviders as m,ReauthDialog as s}from"./components";export{n as AuthPartnerButton,p as ConfirmDeleteDialog,A as FeatureGuard,f as GoogleOneTap,g as LoginModal,m as MultipleAuthProviders,s as ReauthDialog,l as getAuthState,i as subscribeToAuth,o as useAuth,u as useDeleteAccount};