@donotdev/auth 0.0.22 → 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.
- package/LICENSE.md +3 -3
- package/dist/AuthStore.d.ts +1 -1
- package/dist/AuthStore.js +1 -1
- package/dist/authHelpers.js +1 -1
- package/dist/components/AccountLinking.js +1 -1
- package/dist/components/AuthFallback.d.ts +3 -3
- package/dist/components/AuthFallback.js +1 -1
- package/dist/components/AuthPartnerButton.d.ts +1 -1
- package/dist/components/AuthPartnerButton.js +2 -2
- package/dist/components/DeleteAccountDialogs.d.ts +4 -4
- package/dist/components/DeleteAccountDialogs.js +1 -1
- package/dist/components/EmailLinkForm.d.ts +1 -1
- package/dist/components/EmailLinkForm.js +1 -1
- package/dist/components/EmailPasswordForm.d.ts +1 -1
- package/dist/components/EmailPasswordForm.js +1 -1
- package/dist/components/EmailVerification.d.ts +1 -1
- package/dist/components/EmailVerification.js +1 -1
- package/dist/components/Feature.d.ts +6 -6
- package/dist/components/Feature.js +1 -1
- package/dist/components/FeatureGuard.d.ts +3 -3
- package/dist/components/FeatureGuard.js +1 -1
- package/dist/components/FeaturePlaceholder.d.ts +3 -3
- package/dist/components/FeaturePlaceholder.js +1 -1
- package/dist/components/GoogleOneTap.d.ts +1 -1
- package/dist/components/GoogleOneTap.js +1 -1
- package/dist/components/LoginModal.js +1 -1
- package/dist/components/MultipleAuthProviders.d.ts +1 -1
- package/dist/components/MultipleAuthProviders.js +1 -1
- package/dist/components/NetworkStatusIndicator.d.ts +1 -1
- package/dist/components/NetworkStatusIndicator.js +1 -1
- package/dist/components/PasswordStrengthIndicator.d.ts +1 -1
- package/dist/components/PasswordStrengthIndicator.js +1 -1
- package/dist/components/PasswordUpdateDialog.d.ts +1 -1
- package/dist/components/PasswordUpdateDialog.js +1 -1
- package/dist/components/RateLimitAlert.d.ts +1 -1
- package/dist/components/RateLimitAlert.js +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants.d.ts +20 -20
- package/dist/constants.js +1 -1
- package/dist/hooks/useAccountLinking.d.ts +1 -1
- package/dist/hooks/useAccountLinking.js +1 -1
- package/dist/hooks/useAuthMethodToggle.d.ts +1 -1
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.d.ts +1 -1
- package/dist/hooks/useAuthPartner.js +1 -1
- package/dist/hooks/useDeleteAccount.d.ts +2 -2
- package/dist/hooks/useDeleteAccount.js +1 -1
- package/dist/hooks/useEmailLinkAuth.d.ts +1 -1
- package/dist/hooks/useEmailLinkAuth.js +1 -1
- package/dist/hooks/useEmailLinkForm.d.ts +3 -3
- 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.d.ts +1 -1
- package/dist/hooks/useNetworkStatus.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
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
|
|
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
|
|
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};
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./AuthFallback";import{default as
|
|
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};
|
package/dist/constants.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as
|
|
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
|
|
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
|
|
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
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as g,useState as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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};
|
package/dist/hooks/useFedCM.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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};
|