@donotdev/auth 0.0.21 → 0.1.0

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 (62) hide show
  1. package/LICENSE.md +3 -3
  2. package/dist/AuthStore.d.ts +1 -1
  3. package/dist/AuthStore.js +1 -1
  4. package/dist/authHelpers.js +1 -1
  5. package/dist/components/AccountLinking.js +1 -1
  6. package/dist/components/AuthFallback.d.ts +3 -3
  7. package/dist/components/AuthFallback.js +1 -1
  8. package/dist/components/AuthPartnerButton.d.ts +1 -1
  9. package/dist/components/AuthPartnerButton.js +2 -2
  10. package/dist/components/DeleteAccountDialogs.d.ts +4 -4
  11. package/dist/components/DeleteAccountDialogs.js +1 -1
  12. package/dist/components/EmailLinkForm.d.ts +1 -1
  13. package/dist/components/EmailLinkForm.js +1 -1
  14. package/dist/components/EmailPasswordForm.d.ts +1 -1
  15. package/dist/components/EmailPasswordForm.js +1 -1
  16. package/dist/components/EmailVerification.d.ts +1 -1
  17. package/dist/components/EmailVerification.js +1 -1
  18. package/dist/components/Feature.d.ts +6 -6
  19. package/dist/components/Feature.js +1 -1
  20. package/dist/components/FeatureGuard.d.ts +3 -3
  21. package/dist/components/FeatureGuard.js +1 -1
  22. package/dist/components/FeaturePlaceholder.d.ts +3 -3
  23. package/dist/components/FeaturePlaceholder.js +1 -1
  24. package/dist/components/GoogleOneTap.d.ts +1 -1
  25. package/dist/components/GoogleOneTap.js +1 -1
  26. package/dist/components/LoginModal.js +1 -1
  27. package/dist/components/MultipleAuthProviders.d.ts +1 -1
  28. package/dist/components/MultipleAuthProviders.js +1 -1
  29. package/dist/components/NetworkStatusIndicator.d.ts +1 -1
  30. package/dist/components/NetworkStatusIndicator.js +1 -1
  31. package/dist/components/PasswordStrengthIndicator.d.ts +1 -1
  32. package/dist/components/PasswordStrengthIndicator.js +1 -1
  33. package/dist/components/PasswordUpdateDialog.d.ts +1 -1
  34. package/dist/components/PasswordUpdateDialog.js +1 -1
  35. package/dist/components/RateLimitAlert.d.ts +1 -1
  36. package/dist/components/RateLimitAlert.js +1 -1
  37. package/dist/components/index.d.ts +1 -1
  38. package/dist/components/index.js +1 -1
  39. package/dist/constants.d.ts +20 -20
  40. package/dist/constants.js +1 -1
  41. package/dist/hooks/useAccountLinking.d.ts +1 -1
  42. package/dist/hooks/useAccountLinking.js +1 -1
  43. package/dist/hooks/useAuthMethodToggle.d.ts +1 -1
  44. package/dist/hooks/useAuthMethodToggle.js +1 -1
  45. package/dist/hooks/useAuthPartner.d.ts +1 -1
  46. package/dist/hooks/useAuthPartner.js +1 -1
  47. package/dist/hooks/useDeleteAccount.d.ts +2 -2
  48. package/dist/hooks/useDeleteAccount.js +1 -1
  49. package/dist/hooks/useEmailLinkAuth.d.ts +1 -1
  50. package/dist/hooks/useEmailLinkAuth.js +1 -1
  51. package/dist/hooks/useEmailLinkForm.d.ts +3 -3
  52. package/dist/hooks/useEmailLinkForm.js +1 -1
  53. package/dist/hooks/useFedCM.js +1 -1
  54. package/dist/hooks/useGoogleOneTap.js +1 -1
  55. package/dist/hooks/useNetworkStatus.d.ts +1 -1
  56. package/dist/hooks/useNetworkStatus.js +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/dist/useAuth.d.ts +1 -1
  61. package/dist/useAuth.js +1 -1
  62. package/package.json +5 -5
@@ -1 +1 @@
1
- "use client";import{jsx as s,jsxs as t,Fragment as P}from"react/jsx-runtime";import{useState as T}from"react";import{useForm as C,Controller as E,useWatch as N}from"react-hook-form";import{Alert as S,ALERT_VARIANT as A,Button as d,BUTTON_VARIANT as u,Dialog as I,PasswordInput as L,Stack as g,Text as R}from"@donotdev/components";import{useTranslation as O}from"@donotdev/core";import{PasswordStrengthIndicator as U}from"./PasswordStrengthIndicator";function x({updatePassword:m}){const{t:r}=O("profile"),[f,l]=T(!1),{control:n,handleSubmit:h,formState:{errors:a,isSubmitting:o},setError:y,reset:p}=C({mode:"onChange",defaultValues:{password:""}}),c=N({control:n,name:"password"}),v=async e=>{try{await m(e.password),l(!1),p()}catch(i){const b=i instanceof Error?i.message:String(i);y("root",{message:b||r("profile.security.password.dialog.error","Failed to update password")})}},w=e=>{l(e),e||p()};return s(I,{open:f,onOpenChange:w,trigger:s(d,{variant:u.OUTLINE,children:r("profile.security.password.change","Change Password")}),title:r("profile.security.password.dialog.title","Change Password"),description:r("profile.security.password.dialog.description","Enter your new password below"),footer:t(P,{children:[s(d,{variant:u.OUTLINE,onClick:()=>w(!1),disabled:o,children:r("profile.security.password.dialog.cancel","Cancel")}),s(d,{onClick:h(v),disabled:o||!c,children:o?r("profile.security.password.dialog.updating","Updating..."):r("profile.security.password.dialog.update","Update Password")})]}),children:t(g,{children:[a.root&&s(S,{variant:A.ERROR,description:a.root.message}),s(E,{name:"password",control:n,rules:{required:r("profile.security.password.dialog.required","Password is required"),minLength:{value:8,message:r("profile.security.password.dialog.minLength","Password must be at least 8 characters")}},render:({field:e})=>t(g,{gap:"tight",children:[s(L,{...e,label:r("profile.security.password.dialog.newPassword","New Password"),placeholder:r("profile.security.password.dialog.placeholder","Enter new password"),disabled:o,"aria-invalid":!!a.password,"aria-describedby":a.password?"password-update-error":void 0,className:"dndev-w-full","data-variant":a.password?"destructive":void 0}),a.password&&s(R,{as:"span",level:"caption",variant:"destructive",id:"password-update-error",role:"alert",children:a.password.message})]})}),s(U,{password:c||"",minLength:8})]})})}var q=x;export{q as default};
1
+ "use client";import{jsx as e,jsxs as i,Fragment as P}from"react/jsx-runtime";import{useState as C}from"react";import{useForm as S,Controller as T,useWatch as E}from"react-hook-form";import{Alert as N,ALERT_VARIANT as x,Button as d,BUTTON_VARIANT as u,Dialog as A,PasswordInput as I,Stack as g,Text as L}from"@donotdev/components";import{useTranslation as O}from"@donotdev/core";import{PasswordStrengthIndicator as R}from"./PasswordStrengthIndicator";function U({updatePassword:m}){const{t:r}=O("profile"),[f,n]=C(!1),{control:l,handleSubmit:h,formState:{errors:s,isSubmitting:o},setError:y,reset:p}=S({mode:"onChange",defaultValues:{password:""}}),c=E({control:l,name:"password"}),b=async a=>{try{await m(a.password),n(!1),p()}catch(t){const v=t instanceof Error?t.message:String(t);y("root",{message:v||r("profile.security.password.dialog.error","Failed to update password")})}},w=a=>{n(a),a||p()};return e(A,{open:f,onOpenChange:w,trigger:e(d,{variant:u.OUTLINE,children:r("profile.security.password.change","Change Password")}),title:r("profile.security.password.dialog.title","Change Password"),description:r("profile.security.password.dialog.description","Enter your new password below"),footer:i(P,{children:[e(d,{variant:u.OUTLINE,onClick:()=>w(!1),disabled:o,children:r("profile.security.password.dialog.cancel","Cancel")}),e(d,{onClick:h(b),disabled:o||!c,children:o?r("profile.security.password.dialog.updating","Updating..."):r("profile.security.password.dialog.update","Update Password")})]}),children:i(g,{children:[s.root&&e(N,{variant:x.ERROR,description:s.root.message}),e(T,{name:"password",control:l,rules:{required:r("profile.security.password.dialog.required","Password is required"),minLength:{value:8,message:r("profile.security.password.dialog.minLength","Password must be at least 8 characters")}},render:({field:a})=>i(g,{gap:"tight",children:[e(I,{...a,label:r("profile.security.password.dialog.newPassword","New Password"),placeholder:r("profile.security.password.dialog.placeholder","Enter new password"),disabled:o,"aria-invalid":!!s.password,"aria-describedby":s.password?"password-update-error":void 0,className:"dndev-w-full","data-variant":s.password?"destructive":void 0}),s.password&&e(L,{as:"span",level:"caption",variant:"destructive",id:"password-update-error",role:"alert",children:s.password.message})]})}),e(R,{password:c||"",minLength:8})]})})}var q=U;export{q as default};
@@ -11,7 +11,7 @@ interface RateLimitAlertProps {
11
11
  * Shows warnings when users are approaching or have exceeded rate limits.
12
12
  * Currently not implemented in the new API but kept for future use.
13
13
  *
14
- * @version 0.0.1
14
+ * @version 0.1.0
15
15
  * @since 0.0.1
16
16
  * @author AMBROISE PARK Consulting
17
17
  */
@@ -1 +1 @@
1
- "use client";import{useTranslation as t}from"@donotdev/core";const a=({identifier:s,className:n=""})=>{const{t:r}=t("auth");return null};var e=a;export{e as default};
1
+ "use client";import{useTranslation as t}from"@donotdev/core";const e=({identifier:i,className:n=""})=>{const{t:r}=t("auth");return null};var l=e;export{l as default};
@@ -2,7 +2,7 @@
2
2
  * @fileoverview Auth components
3
3
  * @description Authentication UI components
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -1 +1 @@
1
- export*from"./AuthFallback";import{default as o}from"./EmailPasswordForm";import{default as r}from"./AuthPartnerButton";import{default as a}from"./EmailVerification";export*from"./Feature";export*from"./FeatureGuard";export*from"./FeaturePlaceholder";import{default as t}from"./GoogleOneTap";import{default as s}from"./LoginModal";import{default as m}from"./MultipleAuthProviders";import{default as e}from"./NetworkStatusIndicator";import{default as f}from"./PasswordUpdateDialog";import{PasswordStrengthIndicator as i}from"./PasswordStrengthIndicator";import{default as p}from"./RateLimitAlert";export*from"./DeleteAccountDialogs";export{r as AuthPartnerButton,o as EmailPasswordForm,a as EmailVerification,t as GoogleOneTap,s as LoginModal,m as MultipleAuthProviders,e as NetworkStatusIndicator,i as PasswordStrengthIndicator,f as PasswordUpdateDialog,p as RateLimitAlert};
1
+ export*from"./AuthFallback";import{default as e}from"./EmailPasswordForm";import{default as f}from"./AuthPartnerButton";import{default as p}from"./EmailVerification";export*from"./Feature";export*from"./FeatureGuard";export*from"./FeaturePlaceholder";import{default as u}from"./GoogleOneTap";import{default as n}from"./LoginModal";import{default as g}from"./MultipleAuthProviders";import{default as c}from"./NetworkStatusIndicator";import{default as A}from"./PasswordUpdateDialog";import{PasswordStrengthIndicator as I}from"./PasswordStrengthIndicator";import{default as M}from"./RateLimitAlert";export*from"./DeleteAccountDialogs";export{f as AuthPartnerButton,e as EmailPasswordForm,p as EmailVerification,u as GoogleOneTap,n as LoginModal,g as MultipleAuthProviders,c as NetworkStatusIndicator,I as PasswordStrengthIndicator,A as PasswordUpdateDialog,M as RateLimitAlert};
@@ -2,7 +2,7 @@
2
2
  * @fileoverview Authentication Constants
3
3
  * @description Authentication constants - single source of truth for default behavior. Industry standard: redirect as default in production, popup in development. Defines auth method types and default configuration values.
4
4
  *
5
- * @version 0.0.1
5
+ * @version 0.1.0
6
6
  * @since 0.0.1
7
7
  * @author AMBROISE PARK Consulting
8
8
  */
@@ -14,7 +14,7 @@ export { AUTH_PARTNER_STATE as PARTNER_STATE, type AuthPartnerState as PartnerSt
14
14
  /**
15
15
  * Common size variants for UI components
16
16
  *
17
- * @version 0.0.1
17
+ * @version 0.1.0
18
18
  * @since 0.0.1
19
19
  * @author AMBROISE PARK Consulting
20
20
  */
@@ -22,7 +22,7 @@ export type ComponentSize = 'sm' | 'md' | 'lg' | 'icon';
22
22
  /**
23
23
  * Common form modes
24
24
  *
25
- * @version 0.0.1
25
+ * @version 0.1.0
26
26
  * @since 0.0.1
27
27
  * @author AMBROISE PARK Consulting
28
28
  */
@@ -30,7 +30,7 @@ export type FormMode = 'signin' | 'signup';
30
30
  /**
31
31
  * Common role types for access control
32
32
  *
33
- * @version 0.0.1
33
+ * @version 0.1.0
34
34
  * @since 0.0.1
35
35
  * @author AMBROISE PARK Consulting
36
36
  */
@@ -38,7 +38,7 @@ export type AccessRole = 'user' | 'admin';
38
38
  /**
39
39
  * Base props that most components share
40
40
  *
41
- * @version 0.0.1
41
+ * @version 0.1.0
42
42
  * @since 0.0.1
43
43
  * @author AMBROISE PARK Consulting
44
44
  */
@@ -51,7 +51,7 @@ export interface BaseComponentProps {
51
51
  /**
52
52
  * Props for components that handle authentication callbacks
53
53
  *
54
- * @version 0.0.1
54
+ * @version 0.1.0
55
55
  * @since 0.0.1
56
56
  * @author AMBROISE PARK Consulting
57
57
  */
@@ -64,7 +64,7 @@ export interface AuthCallbackProps {
64
64
  /**
65
65
  * Props for components that render children conditionally
66
66
  *
67
- * @version 0.0.1
67
+ * @version 0.1.0
68
68
  * @since 0.0.1
69
69
  * @author AMBROISE PARK Consulting
70
70
  */
@@ -77,7 +77,7 @@ export interface ConditionalRenderProps {
77
77
  /**
78
78
  * Props for network status indicator
79
79
  *
80
- * @version 0.0.1
80
+ * @version 0.1.0
81
81
  * @since 0.0.1
82
82
  * @author AMBROISE PARK Consulting
83
83
  */
@@ -87,7 +87,7 @@ export interface NetworkStatusIndicatorProps extends BaseComponentProps {
87
87
  /**
88
88
  * Props for login modal
89
89
  *
90
- * @version 0.0.1
90
+ * @version 0.1.0
91
91
  * @since 0.0.1
92
92
  * @author AMBROISE PARK Consulting
93
93
  */
@@ -98,7 +98,7 @@ export interface LoginModalProps {
98
98
  /**
99
99
  * Props for email verification component
100
100
  *
101
- * @version 0.0.1
101
+ * @version 0.1.0
102
102
  * @since 0.0.1
103
103
  * @author AMBROISE PARK Consulting
104
104
  */
@@ -119,7 +119,7 @@ export interface EmailVerificationProps extends BaseComponentProps {
119
119
  /**
120
120
  * Props for email/password form
121
121
  *
122
- * @version 0.0.1
122
+ * @version 0.1.0
123
123
  * @since 0.0.1
124
124
  * @author AMBROISE PARK Consulting
125
125
  */
@@ -131,7 +131,7 @@ export interface EmailPasswordFormProps extends BaseComponentProps, AuthCallback
131
131
  /**
132
132
  * Props for account linking component
133
133
  *
134
- * @version 0.0.1
134
+ * @version 0.1.0
135
135
  * @since 0.0.1
136
136
  * @author AMBROISE PARK Consulting
137
137
  */
@@ -140,7 +140,7 @@ export interface AccountLinkingProps extends BaseComponentProps {
140
140
  /**
141
141
  * Props for Google One Tap component
142
142
  *
143
- * @version 0.0.1
143
+ * @version 0.1.0
144
144
  * @since 0.0.1
145
145
  * @author AMBROISE PARK Consulting
146
146
  */
@@ -151,7 +151,7 @@ export interface GoogleOneTapProps extends AuthCallbackProps {
151
151
  /**
152
152
  * Props for rate limit alert
153
153
  *
154
- * @version 0.0.1
154
+ * @version 0.1.0
155
155
  * @since 0.0.1
156
156
  * @author AMBROISE PARK Consulting
157
157
  */
@@ -162,7 +162,7 @@ export interface RateLimitAlertProps extends BaseComponentProps {
162
162
  /**
163
163
  * Props for password update dialog
164
164
  *
165
- * @version 0.0.1
165
+ * @version 0.1.0
166
166
  * @since 0.0.1
167
167
  * @author AMBROISE PARK Consulting
168
168
  */
@@ -172,7 +172,7 @@ export interface PasswordUpdateDialogProps {
172
172
  /**
173
173
  * Props for auth partner button
174
174
  *
175
- * @version 0.0.1
175
+ * @version 0.1.0
176
176
  * @since 0.0.1
177
177
  * @author AMBROISE PARK Consulting
178
178
  */
@@ -193,7 +193,7 @@ export interface AuthPartnerButtonProps extends AuthCallbackProps, BaseComponent
193
193
  /**
194
194
  * Props for feature placeholder
195
195
  *
196
- * @version 0.0.1
196
+ * @version 0.1.0
197
197
  * @since 0.0.1
198
198
  * @author AMBROISE PARK Consulting
199
199
  */
@@ -206,7 +206,7 @@ export interface FeaturePlaceholderProps extends BaseComponentProps {
206
206
  /**
207
207
  * Props for tier placeholder
208
208
  *
209
- * @version 0.0.1
209
+ * @version 0.1.0
210
210
  * @since 0.0.1
211
211
  * @author AMBROISE PARK Consulting
212
212
  */
@@ -219,7 +219,7 @@ export interface TierPlaceholderProps extends BaseComponentProps {
219
219
  /**
220
220
  * Props for auth fallback
221
221
  *
222
- * @version 0.0.1
222
+ * @version 0.1.0
223
223
  * @since 0.0.1
224
224
  * @author AMBROISE PARK Consulting
225
225
  */
@@ -232,7 +232,7 @@ export interface AuthFallbackProps extends BaseComponentProps {
232
232
  /**
233
233
  * Props for multiple auth providers
234
234
  *
235
- * @version 0.0.1
235
+ * @version 0.1.0
236
236
  * @since 0.0.1
237
237
  * @author AMBROISE PARK Consulting
238
238
  */
package/dist/constants.js CHANGED
@@ -1 +1 @@
1
- import{getAuthMethod as A,EMAIL_VERIFICATION_STATUS as T}from"@donotdev/core";import{AUTH_PARTNER_STATE as t}from"@donotdev/core";export{T as EMAIL_VERIFICATION_STATUS,t as PARTNER_STATE,A as getAuthMethod};
1
+ import{getAuthMethod as E,EMAIL_VERIFICATION_STATUS as o}from"@donotdev/core";import{AUTH_PARTNER_STATE as R}from"@donotdev/core";export{o as EMAIL_VERIFICATION_STATUS,R as PARTNER_STATE,E as getAuthMethod};
@@ -24,7 +24,7 @@ interface UseAccountLinkingReturn {
24
24
  * - Provides sign-in actions
25
25
  * - SSR-safe initialization
26
26
  *
27
- * @version 0.0.1
27
+ * @version 0.1.0
28
28
  * @since 0.0.1
29
29
  * @author AMBROISE PARK Consulting
30
30
  * **Usage:**
@@ -1 +1 @@
1
- "use client";import{useState as k,useEffect as v,useCallback as a}from"react";import{safeSessionStorage as e,handleError as p,isClient as t,isDev as r}from"@donotdev/core";import{getAuthMethod as L}from"../constants";import{useAuth as c}from"../useAuth";function P(){const s=c("signInWithPartner"),u=c("user"),[i,o]=k(null);v(()=>{if(t()){try{const n=e.getItem("accountLinkingInfo");if(n){const I=JSON.parse(n);o(I)}}catch{r()}return()=>{if(!t())return;const n=e.getItem("accountLinkingInfo");if(n)try{JSON.parse(n).isRequired||e.removeItem("accountLinkingInfo")}catch{}}}},[u]);const l=a(async()=>{if(!(!i||!i.isRequired))try{const{existingProvider:n}=i;if(n==="password"||n==="emailLink"){r();return}r(),await s(n,L())}catch(n){p(n)}},[i,s]),f=a(()=>{t()&&(e.removeItem("accountLinkingInfo"),o(null))},[]),g=i?.isRequired||!1,m=i?.email||null,d=i?.existingProvider||null,h=i?.newProvider||null;return{accountLinking:i,isRequired:g,email:m,existingProvider:d,newProvider:h,handleSignInWithExistingProvider:l,clearAccountLinking:f}}export{P as useAccountLinking};
1
+ "use client";import{useState as h,useEffect as v,useCallback as a}from"react";import{safeSessionStorage as e,handleError as I,isClient as t,isDev as r}from"@donotdev/core";import{getAuthMethod as L}from"../constants";import{useAuth as l}from"../useAuth";function S(){const o=l("signInWithPartner"),s=l("user"),[i,c]=h(null);v(()=>{if(t()){try{const n=e.getItem("accountLinkingInfo");if(n){const u=JSON.parse(n);c(u)}}catch{r()}return()=>{if(!t())return;const n=e.getItem("accountLinkingInfo");if(n)try{JSON.parse(n).isRequired||e.removeItem("accountLinkingInfo")}catch{}}}},[s]);const g=a(async()=>{if(!(!i||!i.isRequired))try{const{existingProvider:n}=i;if(n==="password"||n==="emailLink"){r();return}r(),await o(n,L())}catch(n){I(n)}},[i,o]),f=a(()=>{t()&&(e.removeItem("accountLinkingInfo"),c(null))},[]),d=i?.isRequired||!1,m=i?.email||null,k=i?.existingProvider||null,p=i?.newProvider||null;return{accountLinking:i,isRequired:d,email:m,existingProvider:k,newProvider:p,handleSignInWithExistingProvider:g,clearAccountLinking:f}}export{S as useAccountLinking};
@@ -18,7 +18,7 @@ interface UseAuthMethodToggleReturn {
18
18
  * - Simple component state (no persistence)
19
19
  * - Clean toggle API
20
20
  *
21
- * @version 0.0.1
21
+ * @version 0.1.0
22
22
  * @since 0.0.1
23
23
  * @author AMBROISE PARK Consulting
24
24
  * **Usage:**
@@ -1 +1 @@
1
- "use client";import{useState as l,useCallback as t}from"react";function g({defaultValue:r="popup"}={}){const[o,e]=l(r),d=o==="redirect",u=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:u,authMethod:o,toggleMode:i,setRedirectMode:s,setPopupMode:a,handleToggleChange:c}}export{g as useAuthMethodToggle};
1
+ "use client";import{useState as h,useCallback as t}from"react";function g({defaultValue:c="popup"}={}){const[o,e]=h(c),r=o==="redirect",d=o==="popup",s=t(()=>{e(p=>p==="redirect"?"popup":"redirect")},[]),u=t(()=>{e("redirect")},[]),n=t(()=>{e("popup")},[]),i=t(p=>{e(p?"redirect":"popup")},[]);return{isRedirectMode:r,isPopupMode:d,authMethod:o,toggleMode:s,setRedirectMode:u,setPopupMode:n,handleToggleChange:i}}export{g as useAuthMethodToggle};
@@ -24,7 +24,7 @@ interface UseAuthPartnerReturn {
24
24
  * - Loading state management
25
25
  * - Clean sign-in API
26
26
  *
27
- * @version 0.0.1
27
+ * @version 0.1.0
28
28
  * @since 0.0.1
29
29
  * @author AMBROISE PARK Consulting
30
30
  * **Usage:**
@@ -1 +1 @@
1
- "use client";import{useCallback as t}from"react";import"../constants";import{useAuth as o}from"../useAuth";function I(r,g={}){const h=o("getPartnerState"),e=o("setPartnerState"),d=o("signInWithPartner"),i=o("partnerError"),{onSuccess:s,onError:l}=g,u=h(r),p=u==="authenticated",m=u==="loading",n=i?.partnerId===r,E=n&&i?.error?new Error(i.error):null,c=t(()=>{n&&e(r,"idle")},[n,r,e]),S=t(()=>{e(r,"loading")},[r,e]),f=t(()=>{e(r,"idle")},[r,e]),A=t(async P=>{n&&c();try{e(r,"loading");const a=await d(r,P);if(a===null){e(r,"idle");return}a&&s&&s(a)}catch(a){e(r,"error",a),l&&l(a)}},[r,n,c,e,d,s,l]);return{partnerState:u,isAuthenticated:p,isAuthenticating:m,hasError:n,error:E,handleSignIn:A,clearError:c,setLoading:S,setIdle:f}}export{I as useAuthPartner};
1
+ "use client";import{useCallback as e}from"react";import"../constants";import{useAuth as s}from"../useAuth";function x(t,h={}){const f=s("getPartnerState"),r=s("setPartnerState"),g=s("signInWithPartner"),i=s("partnerError"),{onSuccess:c,onError:a}=h,l=f(t),P=l==="authenticated",S=l==="loading",n=i?.partnerId===t,m=n&&i?.error?new Error(i.error):null,u=e(()=>{n&&r(t,"idle")},[n,t,r]),E=e(()=>{r(t,"loading")},[t,r]),A=e(()=>{r(t,"idle")},[t,r]),w=e(async y=>{n&&u();try{r(t,"loading");const o=await g(t,y);if(o===null){r(t,"idle");return}o&&c&&c(o)}catch(o){r(t,"error",o),a&&a(o)}},[t,n,u,r,g,c,a]);return{partnerState:l,isAuthenticated:P,isAuthenticating:S,hasError:n,error:m,handleSignIn:w,clearError:u,setLoading:E,setIdle:A}}export{x as useAuthPartner};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Account deletion state and actions
3
3
  *
4
- * @version 0.0.1
4
+ * @version 0.1.0
5
5
  * @since 0.0.1
6
6
  * @author AMBROISE PARK Consulting
7
7
  */
@@ -54,7 +54,7 @@ export interface DeleteAccountState {
54
54
  * />
55
55
  * ```
56
56
  *
57
- * @version 0.0.1
57
+ * @version 0.1.0
58
58
  * @since 0.0.1
59
59
  * @author AMBROISE PARK Consulting
60
60
  * @returns Account deletion state and actions
@@ -1 +1 @@
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
+ "use client";import{useState as l}from"react";import{useAuth as m}from"../useAuth";function E(){const r=m("deleteAccount"),[c,e]=l(!1),[f,s]=l(!1),[i,a]=l(!1),[u,t]=l(null);return{showConfirmDialog:c,showPasswordDialog:f,isDeleting:i,error:u,startDeleteFlow:()=>{t(null),e(!0)},confirmDelete:async D=>{a(!0),t(null);try{await r(D),e(!1),s(!1)}catch(n){const o=n.message||n.message;o==="REQUIRES_PASSWORD"?(e(!1),s(!0)):o==="REAUTH_CANCELLED"?(e(!1),s(!1)):t(o||"Failed to delete account")}finally{a(!1)}},cancel:()=>{e(!1),s(!1),t(null)}}}export{E as useDeleteAccount};
@@ -16,7 +16,7 @@ export interface UseEmailLinkAuthReturn {
16
16
  * - Provides completion method
17
17
  * - Handles account linking scenarios
18
18
  *
19
- * @version 0.0.1
19
+ * @version 0.1.0
20
20
  * @since 0.0.1
21
21
  * @author AMBROISE PARK Consulting
22
22
  * **Usage:**
@@ -1 +1 @@
1
- "use client";import{useEffect as g,useState as t,useCallback as E}from"react";import{handleError as k,isDev as s}from"@donotdev/core";import{useAuth as l}from"../useAuth";function p(){const o=l("isSignInWithEmailLink"),n=l("signInWithEmailLink"),[r,e]=t(!1),[m,a]=t(null),c=o();g(()=>{if(typeof window<"u"){const i=localStorage.getItem("emailForSignIn");i&&a(i)}},[]);const u=E(async i=>{if(!i){s();return}e(!0);try{s(),(await n(i))?.success&&(localStorage.removeItem("emailForSignIn"),a(null))}catch(f){k(f)}finally{e(!1)}},[n]);return{isEmailLink:c,isProcessing:r,email:m,completeEmailLinkSignIn:u}}export{p as useEmailLinkAuth};
1
+ "use client";import{useEffect as g,useState as l,useCallback as E}from"react";import{handleError as k,isDev as o}from"@donotdev/core";import{useAuth as r}from"../useAuth";function p(){const a=r("isSignInWithEmailLink"),n=r("signInWithEmailLink"),[m,e]=l(!1),[c,t]=l(null),u=a();g(()=>{if(typeof window<"u"){const i=localStorage.getItem("emailForSignIn");i&&t(i)}},[]);const f=E(async i=>{if(!i){o();return}e(!0);try{o(),(await n(i))?.success&&(localStorage.removeItem("emailForSignIn"),t(null))}catch(s){k(s)}finally{e(!1)}},[n]);return{isEmailLink:u,isProcessing:m,email:c,completeEmailLinkSignIn:f}}export{p as useEmailLinkAuth};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Use email link form return interface
3
3
  *
4
- * @version 0.0.1
4
+ * @version 0.1.0
5
5
  * @since 0.0.1
6
6
  * @author AMBROISE PARK Consulting
7
7
  */
@@ -20,7 +20,7 @@ export interface UseEmailLinkFormReturn {
20
20
  /**
21
21
  * Use email link form options interface
22
22
  *
23
- * @version 0.0.1
23
+ * @version 0.1.0
24
24
  * @since 0.0.1
25
25
  * @author AMBROISE PARK Consulting
26
26
  */
@@ -42,7 +42,7 @@ export interface UseEmailLinkFormOptions {
42
42
  * 4. Success/error handling
43
43
  * 5. Resend functionality
44
44
  *
45
- * @version 0.0.1
45
+ * @version 0.1.0
46
46
  * @since 0.0.1
47
47
  * @author AMBROISE PARK Consulting
48
48
  *
@@ -1 +1 @@
1
- "use client";import{useState as r,useCallback as l}from"react";import{handleError as I}from"@donotdev/core";import{useAuth as f}from"../useAuth";function v(S={}){const t=f("sendSignInLinkToEmail"),g=f("isAvailable"),{onSuccess:s,onError:o,actionCodeSettings:m}=S,[e,E]=r(""),[u,c]=r(!1),[h,d]=r(!1),[p,n]=r(null),i=e.trim().length>0&&e.includes("@"),k=i&&!u&&g,y=l(()=>{n(null)},[]),L=l(async w=>{if(w.preventDefault(),!i){n("Please enter a valid email address");return}c(!0),n(null);try{typeof window<"u"&&localStorage.setItem("emailForSignIn",e.trim()),await t(e.trim(),m),d(!0),s?.()}catch(a){const F=a instanceof Error?a.message:"Failed to send sign-in link";n(F),o?.(a),I(a)}finally{c(!1)}},[e,i,t,m,s,o]),b=l(()=>{d(!1),n(null)},[]);return{email:e,setEmail:E,isLoading:u,isSent:h,error:p,handleSendLink:L,handleResend:b,clearError:y,isValid:i,canSubmit:k}}export{v as useEmailLinkForm};
1
+ "use client";import{useState as i,useCallback as r}from"react";import{handleError as w}from"@donotdev/core";import{useAuth as f}from"../useAuth";function T(g={}){const o=f("sendSignInLinkToEmail"),S=f("isAvailable"),{onSuccess:a,onError:l,actionCodeSettings:c}=g,[e,E]=i(""),[d,m]=i(!1),[h,u]=i(!1),[k,n]=i(null),s=e.trim().length>0&&e.includes("@"),p=s&&!d&&S,I=r(()=>{n(null)},[]),L=r(async v=>{if(v.preventDefault(),!s){n("Please enter a valid email address");return}m(!0),n(null);try{typeof window<"u"&&localStorage.setItem("emailForSignIn",e.trim()),await o(e.trim(),c),u(!0),a?.()}catch(t){const y=t instanceof Error?t.message:"Failed to send sign-in link";n(y),l?.(t),w(t)}finally{m(!1)}},[e,s,o,c,a,l]),b=r(()=>{u(!1),n(null)},[]);return{email:e,setEmail:E,isLoading:d,isSent:h,error:k,handleSendLink:L,handleResend:b,clearError:I,isValid:s,canSubmit:p}}export{T as useEmailLinkForm};
@@ -1 +1 @@
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
+ "use client";import{useState as i,useEffect as y,useMemo as E,useRef as S}from"react";import{handleError as I,isClient as l}from"@donotdev/core";function F({checkGoogleServices:a=!0,onError:d}={}){const[n,p]=i(!1),[m,u]=i(!1),[f,g]=i(null),c=S(d);c.current=d,y(()=>{if(!l())return;(async()=>{try{const t="IdentityCredential"in window;let e=!0;if(a){const h=new Promise(s=>setTimeout(s,2e3));await Promise.race([new Promise(s=>{const C=setInterval(()=>{window.google?.accounts?.id&&(clearInterval(C),s(!0))},100)}),h]),e=!!window.google?.accounts?.id}p(t&&e),u(!0)}catch(t){const e=I(t,{userMessage:"Failed to detect FedCM support",context:{operation:"fedcm_detection"},severity:"warning"});g(e),u(!0),c.current?.(e)}})()},[a]);const w=E(()=>{if(!l())return{name:"Unknown",isSupported:!1,recommendation:"Loading..."};const r=navigator.userAgent;let t="Unknown",e="Please update your browser";if(r.includes("Chrome/")){const o=parseInt(r.match(/Chrome\/(\d+)/)?.[1]||"0");t=`Chrome ${o}`,e=o>=116?"Supported":"Please update to Chrome 116 or later"}else if(r.includes("Edg/")){const o=parseInt(r.match(/Edg\/(\d+)/)?.[1]||"0");t=`Edge ${o}`,e=o>=116?"Supported":"Please update to Edge 116 or later"}else r.includes("Safari/")&&!r.includes("Chrome")?(t="Safari",e="Not supported yet. Please use Chrome or Edge"):r.includes("Firefox/")&&(t="Firefox",e="Not supported yet. Please use Chrome or Edge");return{name:t,isSupported:n,recommendation:e}},[n]);return{isSupported:n,isReady:m,error:f,browserInfo:w}}export{F as useFedCM};
@@ -1 +1 @@
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 oe}from"@donotdev/components";import{handleError as g,getOAuthClientId as te,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:Q,autoSelect:x=!0,cancelOnTapOutside:v=!0,promptParentId:y,disabled:l=!1,onSuccess:C,onError:i,allowedParentOrigins:N,cspNonce:S,clientOnly:R=!1}={}){const{t:n}=ae("auth"),T=J("user"),A=J("signInWithGoogleCredential"),I=oe(),s=Q||te("google"),E=re().includes("google"),{isSupported:r,isReady:d,error:F,browserInfo:U}=se({checkGoogleServices:!0,onError:o=>{const t=g(o,{userMessage:n("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});i?.(t)}}),{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:o=>{const t=g(o,{userMessage:n("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});i?.(t)}}),[b,$]=G(!1),[z,Y]=G(null),K=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||z,[P,F,z,r,d,n]),h=j(async o=>{try{if(!o||typeof o!="string")throw new Error("Invalid credential format");await A(o),_(()=>{C?.(o)})}catch(t){const e=g(t,{userMessage:n("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:o?.length||0},severity:"error"});throw _(()=>{Y(e)}),i?.(e),e}},[A,C,i,n]),k=j(()=>{if(!ne()||!q||!s||!window.google?.accounts?.id||!r||a.current)return;const o=Date.now();if(!(o-D.current<w&&D.current>0))try{a.current=!0,D.current=o;const t={client_id:s,callback:async e=>{try{await h(e.credential)}catch(W){g(W,{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:N,csp_nonce:S,moment_callback:e=>{const W=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&&(t.prompt_parent_id=y),window.google.accounts.id.initialize(t),c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{window.google?.accounts?.id?.prompt(e=>{e?.credential&&h(e.credential)}),c.current=null},100)}catch(t){const e=g(t,{userMessage:n("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});_(()=>{Y(e)}),i?.(e),a.current=!1}},[q,s,r,x,v,y,I,h,i,N,S,n]);return L(()=>{if(typeof window<"u"){_(()=>{$(!0)});try{const o=Number(localStorage.getItem(m)||0);p(o>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:K,initialize:k,handleCredential:h,shouldShow:M,browserInfo:U,triggerLoad:X,loadTriggered:Z}}export{ce as useGoogleOneTap};
1
+ "use client";import{useState as b,useEffect as k,useRef as _,useCallback as K,startTransition as y,useMemo as j}from"react";import{useIsDark as re}from"@donotdev/components";import{handleError as p,getOAuthClientId as oe,getEnabledAuthPartners as ne,isClient as ie,useTranslation as se,useScriptLoader as ae}from"@donotdev/core";import{useAuth as B}from"../useAuth";import{useFedCM as ce}from"./useFedCM";function me({clientId:J,autoSelect:v=!0,cancelOnTapOutside:x=!0,promptParentId:T,disabled:u=!1,onSuccess:O,onError:s,allowedParentOrigins:z,cspNonce:S,clientOnly:A=!1}={}){const{t:o}=se("auth"),E=B("user"),N=B("signInWithGoogleCredential"),L=re(),a=J||oe("google"),I=ne().includes("google"),{isSupported:r,isReady:d,error:U,browserInfo:Q}=ce({checkGoogleServices:!0,onError:e=>{const l=p(e,{userMessage:o("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});s?.(l)}}),{isLoading:V,isLoaded:D,error:F,isReady:P,load:X,loadTriggered:Z}=ae("https://accounts.google.com/gsi/client",{enabled:I&&!!a&&!u&&d&&r,nonce:S,checkExisting:!0,isLoaded:()=>!!window.google?.accounts?.id,onError:e=>{const l=p(e,{userMessage:o("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});s?.(l)}}),[M,$]=b(!1),[W,q]=b(null),ee=_(null),i=_(!1),c=_(null),C=_(0),[H,f]=b(!1),m="gsi_hide_until",h=600*1e3,G=j(()=>I&&!!a&&!u&&!E&&r&&(A?M:!0)&&!H,[I,a,u,E,r,A,M,H]),te=j(()=>!r&&d?new Error(o("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):F||U||W,[F,U,W,r,d,o]),w=K(async e=>{try{if(!e||typeof e!="string")throw new Error("Invalid credential format");await N(e),y(()=>{O?.(e)})}catch(l){const n=p(l,{userMessage:o("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:e?.length||0},severity:"error"});throw y(()=>{q(n)}),s?.(n),n}},[N,O,s,o]),R=K(()=>{if(!ie()||!P||!a||!window.google?.accounts?.id||!r||i.current)return;const e=Date.now();if(!(e-C.current<h&&C.current>0))try{i.current=!0,C.current=e;const n={client_id:a,callback:async t=>{try{await w(t.credential)}catch(Y){p(Y,{userMessage:"Google One Tap credential handling failed",context:{operation:"google_one_tap_callback"},severity:"error"})}},auto_select:v,cancel_on_tap_outside:x,context:"signin",ux_mode:"popup",itp_support:!0,state:L?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:z,csp_nonce:S,moment_callback:t=>{const Y=t.getMomentType();if(t.isDisplayMoment?.()){if(!t.isDisplayed?.()){if(t.getNotDisplayedReason){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}}}else if(t.isSkippedMoment?.()){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}else if(t.isDismissedMoment?.()){i.current=!1;try{const g=Date.now()+h;localStorage.setItem(m,String(g)),f(!0)}catch{}}}};T&&(n.prompt_parent_id=T),window.google.accounts.id.initialize(n),c.current&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{window.google?.accounts?.id?.prompt(t=>{t?.credential&&w(t.credential)}),c.current=null},100)}catch(n){const t=p(n,{userMessage:o("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});y(()=>{q(t)}),s?.(t),i.current=!1}},[P,a,r,v,x,T,L,w,s,z,S,o]);return k(()=>{if(typeof window<"u"){y(()=>{$(!0)});try{const e=Number(localStorage.getItem(m)||0);f(e>Date.now())}catch{}}},[]),k(()=>{D&&!u&&G&&d&&R()},[D,u,G,d,R]),k(()=>()=>{c.current&&window.clearTimeout(c.current),i.current=!1},[]),{isLoaded:D,isLoading:V,error:te,user:E,isDark:L,fedcmSupported:r,isHydrated:M,containerRef:ee,initialize:R,handleCredential:w,shouldShow:G,browserInfo:Q,triggerLoad:X,loadTriggered:Z}}export{me as useGoogleOneTap};
@@ -11,7 +11,7 @@ interface UseNetworkStatusReturn {
11
11
  * **SSR Safe:** Returns safe defaults on server
12
12
  * **CSR Safe:** Monitors real network status on client
13
13
  *
14
- * @version 0.0.1
14
+ * @version 0.1.0
15
15
  * @since 0.0.1
16
16
  * @author AMBROISE PARK Consulting
17
17
  * **Usage:**
@@ -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),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};
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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Auth package
3
3
  * @description Authentication package for DoNotDev framework. Provides authentication hooks, stores, components, and utilities for user authentication.
4
- * @version 0.0.1
4
+ * @version 0.1.0
5
5
  * @since 0.0.1
6
6
  * @author AMBROISE PARK Consulting
7
7
  */
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{useAuth as a}from"./useAuth";import{useDeleteAccount as t}from"./hooks/useDeleteAccount";import{getAuthState as e,subscribeToAuth as s}from"./authHelpers";import{AuthPartnerButton as o,ConfirmDeleteDialog as u,FeatureGuard as r,GoogleOneTap as A,LoginModal as i,MultipleAuthProviders as h,ReauthDialog as l}from"./components";import{getAuthMethod as T,PARTNER_STATE as g,EMAIL_VERIFICATION_STATUS as m}from"./constants";export{o as AuthPartnerButton,u as ConfirmDeleteDialog,m as EMAIL_VERIFICATION_STATUS,r as FeatureGuard,A as GoogleOneTap,i as LoginModal,h as MultipleAuthProviders,g as PARTNER_STATE,l as ReauthDialog,T as getAuthMethod,e as getAuthState,s as subscribeToAuth,a as useAuth,t as useDeleteAccount};
1
+ import{useAuth as o}from"./useAuth";import{useDeleteAccount as u}from"./hooks/useDeleteAccount";import{getAuthState as a,subscribeToAuth as h}from"./authHelpers";import{AuthPartnerButton as T,ConfirmDeleteDialog as i,FeatureGuard as p,GoogleOneTap as f,LoginModal as g,MultipleAuthProviders as m,ReauthDialog as n}from"./components";import{getAuthMethod as x,PARTNER_STATE as d,EMAIL_VERIFICATION_STATUS as D}from"./constants";export{T as AuthPartnerButton,i as ConfirmDeleteDialog,D as EMAIL_VERIFICATION_STATUS,p as FeatureGuard,f as GoogleOneTap,g as LoginModal,m as MultipleAuthProviders,d as PARTNER_STATE,n as ReauthDialog,x as getAuthMethod,a as getAuthState,h as subscribeToAuth,o as useAuth,u as useDeleteAccount};