@donotdev/auth 0.0.16 → 0.0.17
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/authHelpers.js +1 -1
- package/dist/components/AccountLinking.js +1 -1
- package/dist/components/AuthFallback.js +1 -1
- package/dist/components/AuthPartnerButton.js +1 -1
- 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.js +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/PasswordStrengthIndicator.js +1 -1
- package/dist/components/RateLimitAlert.js +1 -1
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.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.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +14 -7
package/dist/AuthStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as i,FEATURE_STATUS as o}from"@donotdev/core";import{PARTNER_STATE as
|
|
1
|
+
import{createDoNotDevStore as i,FEATURE_STATUS as o}from"@donotdev/core";import{PARTNER_STATE as u}from"./constants";const n={user:null,authenticated:!1,userId:null,loading:!1,error:null,userProfile:null,userSubscription:null,partnerStates:{},partnerError:null,authService:null,emailVerification:{status:"pending"},status:o.INITIALIZING},c=i({name:"auth-store",createStore:(t,s)=>({...n,setStatus:r=>{t({status:r})},setPartnerState:(r,e,a)=>{t(l=>({partnerStates:{...l.partnerStates,[r]:e},partnerError:e==="error"&&a?{partnerId:r,error:a}:l.partnerError?.partnerId===r?null:l.partnerError}))},getPartnerState:r=>s().partnerStates[r]||u.IDLE,clearAllPartnerStates:()=>t(r=>({partnerStates:Object.keys(r.partnerStates).reduce((e,a)=>(e[a]=u.IDLE,e),{}),partnerError:null})),setAuthenticated:(r,e,a)=>{t({user:r,authenticated:!0,userId:r.id,loading:!1,error:null,status:o.READY,userSubscription:e,userProfile:a})},setUnauthenticated:()=>{t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:o.READY,userSubscription:null,userProfile:null})},setAuthLoading:r=>{t({loading:r})},setAuthError:r=>{t({error:r,loading:!1})},clearAuthError:()=>{t({error:null})},getCustomClaim:r=>s().getCustomClaimLocal(r),getCustomClaims:()=>s().getCustomClaimsLocal(),setAuthService:r=>t({authService:r}),getCustomClaimLocal:r=>{const e=s(),a=e.userProfile;return a?.claims&&typeof a.claims=="object"&&r in a.claims?a.claims[r]:a&&typeof a=="object"&&r in a?a[r]:e.user&&typeof e.user=="object"&&r in e.user?e.user[r]:null},getCustomClaimsLocal:()=>{const r=s(),e={};return r.userProfile?.claims&&Object.assign(e,r.userProfile.claims),Object.freeze({...e})},setEmailVerificationStatus:(r,e)=>t({emailVerification:{status:r,error:e}}),setUserProfile:r=>t({userProfile:r}),setUserSubscription:r=>t({userSubscription:r}),setLoading:r=>t({loading:r}),setError:r=>t({error:r}),clearError:()=>t({error:null}),reset:()=>t(n)})});export{c as useAuthStore};
|
package/dist/authHelpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isClient as
|
|
1
|
+
import{isClient as r}from"@donotdev/core";import{useAuthStore as t}from"./AuthStore";function s(){return t.getState()}function u(e){return r()?t.subscribe(e):()=>{}}export{s as getAuthState,u as subscribeToAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{Suspense as
|
|
1
|
+
"use client";import{jsx as i,jsxs as t}from"react/jsx-runtime";import{Suspense as A,lazy as T}from"react";import{Alert as h,ALERT_VARIANT as k,Button as o,BUTTON_VARIANT as c,Stack as a}from"@donotdev/components";import{useTranslation as I,safeSessionStorage as v,handleError as N,isDev as l}from"@donotdev/core";import{EmailLinkForm as R}from"./EmailLinkForm";import S from"./EmailPasswordForm";import{useAccountLinking as y}from"../hooks/useAccountLinking";const $=({className:r="",id:d})=>{const{t:e}=I("auth"),{isRequired:f,email:m,existingProvider:n,newProvider:u,handleSignInWithExistingProvider:w}=y();if(!f)return null;if(n==="password"||n==="emailLink"){l();const s=()=>{v.removeItem("accountLinkingInfo")},g=()=>{l()},p=L=>{N(L)};return i("div",{className:r,id:d,children:i(h,{variant:k.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:t(a,{children:[i("p",{children:e("accountLinking.message",`An account with email ${m} already exists with ${n==="password"?"email/password":"email link"}. To link your ${u} account, please sign in with your ${n==="password"?"email and password":"email link"} first.`)}),n==="password"?i("div",{style:{marginTop:"var(--gap-md)"},children:i(S,{mode:"signin",onSuccess:g,onError:p})}):i("div",{style:{marginTop:"var(--gap-md)"},children:i(R,{onSuccess:g,onError:p})}),i(a,{direction:"row",justify:"end",children:i(o,{onClick:s,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})})]})})})}else{l();const s=()=>{v.removeItem("accountLinkingInfo")};return i("div",{className:r,id:d,children:i(h,{variant:k.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:t(a,{children:[i("p",{children:e("accountLinking.message",`An account with email ${m} already exists with ${n}. To link your ${u} account, please sign in with ${n} first.`)}),t(a,{direction:"row",children:[i(o,{onClick:w,variant:c.PRIMARY,children:e("accountLinking.signInWith",`Sign in with ${n}`)}),i(o,{onClick:s,variant:c.GHOST,children:e("accountLinking.dismiss","Dismiss")})]})]})})})}},x=T(()=>Promise.resolve({default:$}));function E(r){return i(A,{fallback:null,children:i(x,{...r})})}var P=E;export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{FeatureFallback as s,withFeatureFallback as r}from"@donotdev/components";import{isFeatureAvailable as n,FRAMEWORK_FEATURES as i}from"@donotdev/core";function o({message:t="Authentication is not available",showLoginButton:a=!1,className:u=""}){return e(s,{featureName:"Authentication",message:t,icon:"\u{1F512}",showActionButton:a,actionButtonText:"Sign In (Unavailable)",className:u,helpText:"This feature requires authentication to be configured."})}function l(t,a){return r(t,"Authentication",()=>n(i.AUTH),{message:a?.message,showActionButton:a?.showLoginButton,actionButtonText:"Sign In (Unavailable)",icon:"\u{1F512}",helpText:"This feature requires authentication to be configured."})}function c(t){return{isAuthAvailable:n(i.AUTH),AuthFallbackComponent:()=>e(o,{...t})}}export{o as AuthFallback,c as useAuthComponent,l as withAuthFallback};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
.dndev-interactive.auth-partner-button-custom[data-variant='outline']:hover {
|
|
3
3
|
background-color: var(--partner-hover-bg);
|
|
4
4
|
}
|
|
5
|
-
`,document.head.appendChild(r)}import{cn as D,DISPLAY as S,PROVIDER_ICONS as U,DefaultProviderIcon as M,Button as _,BUTTON_VARIANT as $,Spinner as V}from"@donotdev/components";import{AUTH_PARTNERS as W,useTranslation as j}from"@donotdev/core";import{EmailLinkForm as F}from"./EmailLinkForm";import H from"./EmailPasswordForm";import{getAuthMethod as k}from"../constants";import{useAuth as s}from"../useAuth";function K({partnerId:r,method:p,onSuccess:u,onError:l,className:
|
|
5
|
+
`,document.head.appendChild(r)}import{cn as D,DISPLAY as S,PROVIDER_ICONS as U,DefaultProviderIcon as M,Button as _,BUTTON_VARIANT as $,Spinner as V}from"@donotdev/components";import{AUTH_PARTNERS as W,useTranslation as j}from"@donotdev/core";import{EmailLinkForm as F}from"./EmailLinkForm";import H from"./EmailPasswordForm";import{getAuthMethod as k}from"../constants";import{useAuth as s}from"../useAuth";function K({partnerId:r,method:p,onSuccess:u,onError:l,className:d="",children:b,disabled:h=!1,display:f=S.AUTO,style:v,...q}){const{t:i}=j("auth"),g=s("user"),E=s("signInWithPartner"),A=s("linkWithPartner"),N=s("isAvailable"),[n,y]=B(!1),o=I(()=>W[r],[r]);if(r==="password")return a("div",{className:d,children:a(H,{mode:"signin",onSuccess:()=>u?.(null),onError:l,compact:!0})});if(r==="emailLink")return a("div",{className:d,children:a(F,{onSuccess:()=>u?.(null),onError:l})});const T=I(()=>U[r]||M,[r]),P=o?.firebaseProviderId,c=!!g?.providerData?.some(t=>t.providerId===P),m=g&&!c,w=async()=>{if(!(n||h)){y(!0);try{let t;if(m)t=await A(r,k(p));else{const R=k(p);t=await E(r,R)}t&&u?.(t)}catch(t){l?.(t instanceof Error?t:new Error(String(t)))}finally{y(!1)}}},e=o?.name,O=()=>{if(b)return b;if(m)return n?i("buttons.linking",{partner:e}):c?i("buttons.linked",{partner:e}):i("buttons.link",{partner:e});if(n)return i("buttons.signingIn",{partner:e});const t=o?.button?.textKey;return t?i(t):`Sign in with ${e}`},x=h||n||!N||m&&c||!1,C=o?.button?{backgroundColor:o.button.backgroundColor,color:o.button.textColor,borderColor:o.button.borderColor,"--partner-hover-bg":o.button.hoverBackgroundColor}:void 0,L=v?{...C,...v}:C;return a(_,{variant:$.OUTLINE,onClick:w,disabled:x,"aria-busy":n,display:f,"aria-label":n?`Signing in with ${e}...`:`Sign in with ${e}`,tooltip:void 0,style:L,className:D(o?.button&&"auth-partner-button-custom",d),icon:n?a(V,{"aria-label":"Loading"}):T,children:f!==S.COMPACT&&O()})}var Y=K;export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as n,jsxs as
|
|
1
|
+
"use client";import{jsx as n,jsxs as c,Fragment as p}from"react/jsx-runtime";import{Trash2 as y}from"lucide-react";import{useState as A}from"react";import{Dialog as g,Button as s,BUTTON_VARIANT as u,PasswordInput as R,Label as D,Checkbox as k,Alert as C,ALERT_VARIANT as b,Stack as l,Text as v,List as w}from"@donotdev/components";import{useTranslation as T}from"@donotdev/core";function x({open:h,isLoading:o,error:r,onReauth:f,onCancel:a}){const{t:e}=T("auth"),[i,m]=A(""),d=async()=>{await f(i)};return n(g,{open:h,onOpenChange:t=>!t&&a(),title:e("deleteAccount.reauth.title","Confirm Your Identity"),description:e("deleteAccount.reauth.description","For security, please re-enter your password to continue."),footer:c(p,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:o,children:e("deleteAccount.reauth.cancel","Cancel")}),n(s,{variant:u.DEFAULT,onClick:d,disabled:o||!i,children:o?e("deleteAccount.reauth.verifying","Verifying..."):e("deleteAccount.reauth.continue","Continue")})]}),children:n("form",{onSubmit:t=>{t.preventDefault(),d()},children:c(l,{children:[n(R,{value:i,onChange:t=>m(t.target.value),label:e("deleteAccount.reauth.password","Password"),disabled:o,placeholder:e("deleteAccount.reauth.passwordPlaceholder","Enter your password"),required:!0,className:"dndev-w-full"}),r&&n(C,{variant:b.ERROR,description:r})]})})})}function E({open:h,isLoading:o,error:r,onConfirm:f,onCancel:a}){const{t:e}=T("auth"),[i,m]=A(!1),d=async()=>{i&&await f()};return n(g,{open:h,onOpenChange:t=>!t&&a(),"data-content-size":"text",title:e("deleteAccount.confirm.title","Delete Your Account?"),description:e("deleteAccount.confirm.description","This action cannot be undone. This will permanently delete your account."),footer:c(p,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:o,children:e("deleteAccount.confirm.cancel","Cancel")}),n(s,{variant:u.DESTRUCTIVE,icon:y,onClick:d,disabled:o||!i,children:o?e("deleteAccount.confirm.deleting","Deleting..."):e("deleteAccount.confirm.delete","Delete My Account")})]}),children:c(l,{gap:"large",children:[c(l,{children:[n(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatDeleted","What will be deleted:")}),n(w,{items:[e("deleteAccount.confirm.credentials","Your account and authentication credentials"),e("deleteAccount.confirm.profile","Your profile information"),e("deleteAccount.confirm.oauth","All connected OAuth providers"),e("deleteAccount.confirm.subscriptions","Active subscriptions (will be canceled)")]})]}),c(l,{children:[n(v,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatKept","What will be kept (anonymized):")}),n(w,{items:[e("deleteAccount.confirm.billing","Billing history for tax/accounting purposes"),e("deleteAccount.confirm.invoices","Past invoices and transaction records")]})]}),c(l,{direction:"row",align:"start",children:[n(k,{id:"confirm-delete",checked:i,onCheckedChange:t=>m(t===!0)}),n(D,{htmlFor:"confirm-delete",children:e("deleteAccount.confirm.checkbox","I understand this action cannot be undone")})]}),r&&n(C,{variant:b.ERROR,description:r})]})})}export{E as ConfirmDeleteDialog,x as ReauthDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Mail as o,CheckCircle as
|
|
1
|
+
"use client";import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Mail as o,CheckCircle as N}from"lucide-react";import{Button as c,BUTTON_VARIANT as f,Input as T,Alert as b,ALERT_VARIANT as R,Spinner as x,Stack as n,Text as s}from"@donotdev/components";import{useTranslation as A}from"@donotdev/core";import{useEmailLinkForm as C}from"../hooks/useEmailLinkForm";function m({className:r="",onSuccess:u,onError:h,actionCodeSettings:k}){const{t:i}=A("auth"),{email:t,setEmail:L,isLoading:a,isSent:v,error:d,handleSendLink:p,handleResend:E,canSubmit:g}=C({onSuccess:u,onError:h,actionCodeSettings:k});return v?l(n,{className:r,children:[l(n,{align:"center",children:[e(N,{className:"dndev-size-touch"}),e(s,{as:"h3",level:"h3",children:i("emailLink.checkEmail","Check Your Email")}),e(s,{level:"small",variant:"muted",className:"dndev-text-center",children:i("emailLink.sentMessage",`We've sent a sign-in link to ${t}. Click the link in your email to complete sign-in.`)})]}),e(n,{direction:"row",justify:"center",children:e(c,{variant:f.OUTLINE,onClick:E,icon:o,iconEnd:!1,children:i("emailLink.resend","Resend Link")})})]}):e("form",{onSubmit:p,className:r,children:l(n,{children:[e(T,{type:"email",label:i("emailLink.emailLabel","Email Address"),value:t,onChange:S=>L(S.target.value),placeholder:i("emailLink.emailPlaceholder","Enter your email address"),required:!0,disabled:a,className:"dndev-w-full"}),d&&e(b,{variant:R.ERROR,description:d}),e(c,{type:"submit",disabled:!g,icon:a?e(x,{"aria-label":"Loading"}):o,iconEnd:!1,className:"dndev-w-full",children:a?i("emailLink.sending","Sending Link..."):i("emailLink.sendLink","Send Sign-In Link")}),e(s,{level:"small",variant:"muted",className:"dndev-text-center",children:i("emailLink.helpText","We'll send you a secure link to sign in without a password.")})]})})}var y=m;export{m as EmailLinkForm,y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{Info as G}from"lucide-react";import{useState as u}from"react";import{useForm as D,Controller as R,useWatch as L}from"react-hook-form";import{Alert as q,ALERT_VARIANT as y,Button as p,BUTTON_VARIANT as w,Checkbox as Y,HoverCard as Z,Input as J,Label as Q,PasswordInput as k,Stack as t,Text as l,cn as X}from"@donotdev/components";import{useTranslation as ee,hasProvider as ae}from"@donotdev/core";import{useAuth as h}from"../useAuth";import{PasswordStrengthIndicator as re}from"./PasswordStrengthIndicator";function se({mode:
|
|
1
|
+
"use client";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{Info as G}from"lucide-react";import{useState as u}from"react";import{useForm as D,Controller as R,useWatch as L}from"react-hook-form";import{Alert as q,ALERT_VARIANT as y,Button as p,BUTTON_VARIANT as w,Checkbox as Y,HoverCard as Z,Input as J,Label as Q,PasswordInput as k,Stack as t,Text as l,cn as X}from"@donotdev/components";import{useTranslation as ee,hasProvider as ae}from"@donotdev/core";import{useAuth as h}from"../useAuth";import{PasswordStrengthIndicator as re}from"./PasswordStrengthIndicator";function se({mode:T="signin",onSuccess:x,onError:O,className:S=""}){const{t:e}=ee("auth"),_=h("signInWithEmail"),U=h("createUserWithEmail"),W=h("sendPasswordResetEmail"),$=h("isAvailable"),H=h("loading"),[N,E]=u(T),d=N==="signup",[b,K]=u(!1),[V,j]=u(""),[c,I]=u(!1),[g,A]=u(!1),{control:m,handleSubmit:F,formState:{errors:s,isSubmitting:M},setError:P}=D({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),C=L({control:m,name:"password"}),v=L({control:m,name:"email"}),z=async r=>{try{if(N==="signin"){if(!ae("auth")&&b!==void 0){const[i,{getFirebaseSDK:f}]=await Promise.all([import("firebase/auth"),import("@donotdev/firebase")]);await f().setPersistence(b?i.browserLocalPersistence:i.browserSessionPersistence)}await _(r.email,r.password)}else await U(r.email,r.password);x?.(void 0)}catch(i){const f=i instanceof Error?i.message:String(i);P("root",{message:f}),O?.(i instanceof Error?i:new Error(f))}},B=async()=>{if(!v||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v)){P("email",{message:e("emailRequired","Email is required")});return}I(!0);try{await W(v),A(!0),j(v)}catch(r){const i=r instanceof Error?r.message:String(r);P("root",{message:i})}finally{I(!1)}};if(!$)return a("div",{className:S,children:a(q,{variant:y.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Please accept cookies to enable authentication.")})});const n=H||M;return a("form",{onSubmit:F(z),className:X("dndev-auth-form",S),noValidate:!0,children:o(t,{children:[s.root&&a(q,{variant:y.ERROR,description:s.root.message}),g&&a(q,{variant:y.SUCCESS,title:e("forgotPassword.sent","Password reset email sent"),description:e("forgotPassword.checkEmail",`Check your email at ${V} for password reset instructions.`)}),a(R,{name:"email",control:m,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:r})=>o(t,{gap:"tight",children:[a(J,{...r,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),disabled:n||c,"aria-invalid":!!s.email,"aria-describedby":s.email?"email-error":void 0,className:"dndev-w-full","data-variant":s.email?"destructive":void 0,onChange:i=>{r.onChange(i),g&&A(!1)}}),s.email&&a(l,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:s.email.message})]})}),a(R,{name:"password",control:m,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:r=>{if(!r)return!0;if(d){if(!/[A-Z]/.test(r))return e("passwordRequirement.uppercase","Password must contain at least one uppercase letter");if(!/[a-z]/.test(r))return e("passwordRequirement.lowercase","Password must contain at least one lowercase letter");if(!/[0-9]/.test(r))return e("passwordRequirement.number","Password must contain at least one number")}return!0}},render:({field:r})=>{const i=`password-${r.name}`;return o(t,{gap:"tight",children:[a(k,{...r,id:i,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),disabled:n||c,"aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,className:"dndev-w-full","data-variant":s.password?"destructive":void 0}),s.password&&a(l,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:s.password.message})]})}}),d&&a(R,{name:"confirmPassword",control:m,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:r=>r!==C?e("confirmPasswordMismatch","Passwords do not match"):!0},render:({field:r})=>o(t,{gap:"tight",children:[a(k,{...r,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),disabled:n,"aria-invalid":!!s.confirmPassword,"aria-describedby":s.confirmPassword?"confirm-password-error":void 0,className:"dndev-w-full","data-variant":s.confirmPassword?"destructive":void 0}),s.confirmPassword&&a(l,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:s.confirmPassword.message})]})}),d&&a(re,{password:C||"",minLength:8,showRequirements:!1}),d&&a(Z,{trigger:a(p,{type:"button",variant:w.GHOST,className:"dndev-w-fit dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0},children:o(t,{direction:"row",align:"center",gap:"tight",children:[a(l,{as:"span",level:"caption",variant:"muted",children:e("passwordRequirements","Password requirements")}),a(G,{className:"dndev-size-xs"})]})}),side:"bottom",align:"start",children:o(t,{gap:"tight",className:"dndev-text-sm",children:[a(l,{as:"strong",level:"small",children:e("passwordRequirements.title","Password Requirements")}),o(t,{gap:"tight",as:"ul",className:"dndev-m-0 dndev-ps-md",children:[a("li",{children:e("passwordRequirement.length","At least 8 characters")}),a("li",{children:e("passwordRequirement.uppercase","One uppercase letter")}),a("li",{children:e("passwordRequirement.lowercase","One lowercase letter")}),a("li",{children:e("passwordRequirement.number","One number")}),a("li",{children:e("passwordRequirement.special","One special character (!@#$%^&*)")})]})]})}),!d&&!g&&o(t,{direction:"row",gap:"tight",align:"center",children:[a(Y,{id:"remember-me",checked:b,onCheckedChange:r=>K(r===!0),disabled:n||c}),a(Q,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),a(p,{type:"submit",variant:w.PRIMARY,disabled:n,fullWidth:!0,children:n?e("loading","Loading..."):d?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!d&&!g&&o(t,{direction:"row",gap:"tight",justify:"center",align:"center",children:[a(p,{type:"button",variant:w.LINK,disabled:n||c,onClick:B,children:c?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),a(l,{as:"span",variant:"muted",children:"|"}),a(p,{type:"button",variant:w.LINK,disabled:n,onClick:()=>E("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),d&&a(t,{align:"center",children:a(p,{type:"button",variant:w.LINK,disabled:n,onClick:()=>E("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})})}var ie=se;export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useId as h}from"react";import{Card as y,Button as V,BUTTON_VARIANT as A,Alert as b,Spinner as M,Stack as d,Text as T}from"@donotdev/components";import{useTranslation as x,handleError as w}from"@donotdev/core";import{useAuth as n}from"../useAuth";function I({verifyButtonText:j,successMessage:k,sendingMessage:B,alreadyVerifiedMessage:E,notSignedInMessage:R,errorMessage:$,id:
|
|
1
|
+
"use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useId as h}from"react";import{Card as y,Button as V,BUTTON_VARIANT as A,Alert as b,Spinner as M,Stack as d,Text as T}from"@donotdev/components";import{useTranslation as x,handleError as w}from"@donotdev/core";import{useAuth as n}from"../useAuth";function I({verifyButtonText:j,successMessage:k,sendingMessage:B,alreadyVerifiedMessage:E,notSignedInMessage:R,errorMessage:$,id:l}){const{t:e}=x("auth"),t=n("user"),i=n("emailVerification"),u=n("sendEmailVerification"),s=t?.id,c=h(),a=l||`email-verification-${c}`,f=`${a}-heading`,m=`${a}-button`,g=async()=>{if(!(!t||!s))try{await u()}catch(v){w(v)}};if(!t||!s)return null;const p=()=>{if(i.status!=="pending"&&i.status==="error")return"error"};return r(y,{id:a,title:r("span",{id:f,children:e("emailVerification.title")}),children:o(d,{children:[o(d,{direction:"row",justify:"between",align:"center",children:[r(T,{level:"small",variant:"muted",children:e("emailVerification.status.unknown")}),r(V,{id:m,onClick:g,disabled:i.status==="pending","aria-busy":i.status==="pending",variant:A.PRIMARY,icon:i.status==="pending"?r(M,{"aria-label":"Loading"}):void 0,iconEnd:!1,children:i.status==="pending"?e("status.verifying"):e("buttons.verify","Verify")})]}),i.status!=="verified"&&r(b,{variant:p(),title:i.status==="error"?e("aria.errorAlert"):e("status.verifying"),description:i.status==="error"?("error"in i?i.error:void 0)||e("emailVerification.error","An error occurred"):e("emailVerification.sending","Sending verification email...")})]})})}var S=I;export{S as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as t,jsx as
|
|
1
|
+
"use client";import{Fragment as t,jsx as a}from"react/jsx-runtime";import{useImperativeHandle as c,forwardRef as n}from"react";import{hasTierAccess as d}from"@donotdev/core";import{useAuth as o}from"../useAuth";const p=n(({featureId:r,fallback:e=null,children:i},l)=>{const s=o("userSubscription")?.features?.includes(r)||!1;return c(l,()=>({enabled:s}),[s]),s?a(t,{children:i}):e?a(t,{children:e}):null}),m=n(({tier:r,fallback:e=null,children:i},l)=>{const s=o("userSubscription"),f=r||"pro",u=d(s?.tier,f);return c(l,()=>({enabled:u}),[u]),u?a(t,{children:i}):e?a(t,{children:e}):null}),h=n((r,e)=>a(m,{ref:e,tier:"pro",...r})),b=n((r,e)=>a(m,{ref:e,tier:"premium",...r}));export{p as Feature,b as PremiumFeature,h as ProFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as e,jsxs as o,Fragment as T}from"react/jsx-runtime";import{Stack as f}from"@donotdev/components";import{hasRoleAccess as h,hasTierAccess as m}from"@donotdev/core";import{useAuth as n}from"../useAuth";import{AuthFallback as w}from"./AuthFallback";function g({requiredTier:r,userTier:i}){return e("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:o(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),o("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:r==="pro"?"Pro Feature":"Premium Feature"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",r," to access this feature",i&&` (current: ${i})`]})]})]})})}function p({requiredRole:r,userRole:i}){const s=Array.isArray(r)?r.join(" or "):r;return e("div",{className:"dndev-surface","data-variant":"destructive","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--destructive)",backgroundColor:"var(--muted)"},children:o(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),o("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive-foreground)"},children:"Access Denied"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",s," role",i&&` (current: ${i})`]})]})]})})}function b(){return e("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:o(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u23F0"}),o("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:"Subscription Required"}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:"This feature requires an active subscription"})]})]})})}function y({children:r,role:i,tier:s,subscription:c,validate:d,fallback:a,message:l,showUpgradePrompt:A=!0,showLoginPrompt:z=!0}){const S=n("user"),R=n("loading"),q=n("userProfile"),v=n("userSubscription"),t=q?.role,u=v?.tier;return R?e("div",{style:{height:"2rem",borderRadius:"var(--radius)",backgroundColor:"var(--muted)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}):!S&&(i||s||c)?z?e(w,{message:l||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(F=>h(t,F))?a?e(a,{requiredRole:i,userRole:t||void 0}):e(p,{requiredRole:i,userRole:t||void 0}):s&&!m(u,s)?a?e(a,{requiredTier:s,userTier:u||"free"}):A?e(g,{requiredTier:s,userTier:u||"free"}):null:c&&!v?.isActive?a?e(a,{requiresSubscription:!0,hasSubscription:v?.isActive||!1}):e(b,{}):d&&t&&u&&!d(t,u)?a?e(a,{userRole:t,userTier:u}):e(p,{userRole:t}):e(T,{children:r})}function P(r){const i=n("user"),s=n("userProfile"),c=n("userSubscription"),d=s?.role,a=c?.tier;return!(!i&&(r.role||r.tier||r.subscription)||r.role&&!(Array.isArray(r.role)?r.role:[r.role]).some(l=>h(d,l))||r.tier&&!m(a,r.tier)||r.subscription&&!c?.isActive||r.validate&&d&&a&&!r.validate(d,a))}function k(r,i){return s=>e(y,{...i,children:e(r,{...s})})}export{p as AccessDenied,y as FeatureGuard,b as SubscriptionExpired,g as UpgradePrompt,P as useCanAccessFeature,k as withFeatureGuard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as o,jsx as
|
|
1
|
+
"use client";import{jsxs as o,jsx as d}from"react/jsx-runtime";import{cn as s}from"@donotdev/components";import{hasTierAccess as m}from"@donotdev/core";import{useAuth as i}from"../useAuth";function f({featureId:e,featureName:r,className:a="",children:t}){if(i("userSubscription")?.features?.includes(e))return null;const n=d("div",{className:s("dndev-surface",a),"data-variant":"muted","data-shadow":"none","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px dashed var(--border)",backgroundColor:"var(--muted)"},children:o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",textAlign:"center"},children:[r," is not available on your current plan."]})});return t||n}function u(e,r){return function({featureName:a,className:t="",children:n}){const l=i("userSubscription");if(m(l?.tier,e))return null;const c=d("div",{className:s("dndev-surface",t),"data-variant":"muted","data-shadow":"none","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px dashed var(--border)",backgroundColor:"var(--muted)"},children:o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",textAlign:"center"},children:[a," is only available on ",r," tier."]})});return n||c}}const p=u("pro","Pro"),v=u("premium","Premium");export{f as FeaturePlaceholder,v as PremiumFeaturePlaceholder,p as ProFeaturePlaceholder};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as S}from"react/jsx-runtime";import{Card as i,Spinner as w,Stack as I}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";import{useGoogleOneTap as T}from"../hooks/useGoogleOneTap";function z({clientId:s,onSuccess:l,onError:c,autoSelect:p=!0,cancelOnTapOutside:m=!0,className:g="",disabled:r=!1,promptParentId:h,allowedParentOrigins:a,cspNonce:u,clientOnly:n=!1,showErrorDetails:
|
|
1
|
+
"use client";import{jsx as e,jsxs as S}from"react/jsx-runtime";import{Card as i,Spinner as w,Stack as I}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";import{useGoogleOneTap as T}from"../hooks/useGoogleOneTap";function z({clientId:s,onSuccess:l,onError:c,autoSelect:p=!0,cancelOnTapOutside:m=!0,className:g="",disabled:r=!1,promptParentId:h,allowedParentOrigins:a,cspNonce:u,clientOnly:n=!1,showErrorDetails:L=!1,loadingComponent:o,errorComponent:b,browserNotSupportedComponent:j}){const{t:v}=N("auth"),{shouldShow:f,isLoaded:E,isLoading:x,error:y,containerRef:O,fedcmSupported:d,isHydrated:t,browserInfo:P}=T({clientId:s,autoSelect:p,cancelOnTapOutside:m,promptParentId:h,disabled:r,onSuccess:l,onError:c,allowedParentOrigins:a,cspNonce:u,clientOnly:n});return r||!f||n&&!t?null:x?o?e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:e(o,{})})}):e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:S(I,{direction:"row",align:"center",children:[e(w,{}),e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:v("googleOneTapLoading","Loading Google One Tap...")})]})})}):!d||y?null:e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e("div",{ref:O,className:`google-one-tap-container ${g}`.trim(),"data-testid":"google-one-tap","data-fedcm-supported":d,"data-hydrated":t,...a&&{"data-allowed-parent-origins":a.join(",")}})})}var C=z;export{C as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t}from"react/jsx-runtime";import{Dialog as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Dialog as i}from"@donotdev/components";import{useTranslation as a}from"@donotdev/core";import{withAuthFallback as s}from"./AuthFallback";import r from"./MultipleAuthProviders";function p({open:n,onOpenChange:e}){const{t:o}=a("auth");return t(i,{open:n,onOpenChange:e,title:o("signIn","Sign In"),description:o("choosePlatform","Choose a platform to sign in with"),children:t(r,{layout:"vertical",showLabels:!0,method:"popup"})})}const l=s(p,{message:"Authentication is not configured",showLoginButton:!0});var m=l;export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as
|
|
1
|
+
"use client";import{jsx as a,jsxs as x}from"react/jsx-runtime";import{Suspense as L,lazy as $,useId as y}from"react";import{Alert as E,ALERT_VARIANT as P,Stack as c,Grid as T}from"@donotdev/components";import{useTranslation as j,getEnabledAuthPartners as G}from"@donotdev/core";import{useAuth as m}from"../useAuth";import{withAuthFallback as M}from"./AuthFallback";import O from"./AuthPartnerButton";import{getAuthMethod as q}from"../constants";import{useAccountLinking as B}from"../hooks/useAccountLinking";const C=$(()=>import("./AccountLinking")),F=({providers:h,containerClassName:r="",providerClassName:p="",method:g,size:_="md",layout:e="vertical",showLabels:f=!0,spacing:o="medium",ariaLabel:v,id:A,fullWidth:N=!0,onSuccess:b})=>{const{t}=j("auth"),w=y(),n=A||w,{isRequired:R}=B(),l=m("error"),z=m("isAvailable"),I=q(g),i=h||G();if(!i||i.length===0)return a("div",{className:r,children:a("p",{children:"No authentication providers are configured"})});const S=()=>{const d=i.map((s,k)=>a(O,{partnerId:s,method:I,className:`${p} ${N?"dndev-w-full":""}`,tabIndex:k===0?0:void 0,id:`${n}-${s}-button`,onSuccess:b,children:f?void 0:null},s));return e==="grid"?a(T,{cols:2,gap:o,className:r,children:d}):a(c,{direction:e==="horizontal"?"row":"column",wrap:e==="horizontal"?"wrap":void 0,gap:o,align:e==="horizontal"?"center":"stretch",className:r,children:d})};return x(c,{className:"dndev-mx-auto",id:n,role:"region","aria-label":v||t("aria.signInOptions","Sign in options"),children:[S(),l&&z&&a(E,{variant:P.ERROR,description:l.message||t("errorGeneric","Authentication failed. Please try again.")}),R&&a(L,{fallback:null,children:a(C,{})})]})},u=M(F,{message:"Authentication providers are not configured",showLoginButton:!0});var V=u;export{u as MultipleAuthProviders,V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Check as w,Circle as v}from"lucide-react";import{useMemo as m}from"react";import{Progress as f,Stack as o,Text as l,cn as b}from"@donotdev/components";import{useTranslation as q}from"@donotdev/core";function k(e){if(!e)return"weak";let t=0;return e.length>=8&&(t+=1),e.length>=12&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[^a-zA-Z0-9]/.test(e)&&(t+=1),t<=2?"weak":t<=4?"fair":t<=5?"good":"strong"}function S(e,t,a){return[{label:a("passwordRequirement.length",`At least ${t} characters`),met:e.length>=t},{label:a("passwordRequirement.uppercase","One uppercase letter"),met:/[A-Z]/.test(e)},{label:a("passwordRequirement.lowercase","One lowercase letter"),met:/[a-z]/.test(e)},{label:a("passwordRequirement.number","One number"),met:/[0-9]/.test(e)},{label:a("passwordRequirement.special","One special character (!@#$%^&*)"),met:/[^a-zA-Z0-9]/.test(e)}]}const
|
|
1
|
+
"use client";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Check as w,Circle as v}from"lucide-react";import{useMemo as m}from"react";import{Progress as f,Stack as o,Text as l,cn as b}from"@donotdev/components";import{useTranslation as q}from"@donotdev/core";function k(e){if(!e)return"weak";let t=0;return e.length>=8&&(t+=1),e.length>=12&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[^a-zA-Z0-9]/.test(e)&&(t+=1),t<=2?"weak":t<=4?"fair":t<=5?"good":"strong"}function S(e,t,a){return[{label:a("passwordRequirement.length",`At least ${t} characters`),met:e.length>=t},{label:a("passwordRequirement.uppercase","One uppercase letter"),met:/[A-Z]/.test(e)},{label:a("passwordRequirement.lowercase","One lowercase letter"),met:/[a-z]/.test(e)},{label:a("passwordRequirement.number","One number"),met:/[0-9]/.test(e)},{label:a("passwordRequirement.special","One special character (!@#$%^&*)"),met:/[^a-zA-Z0-9]/.test(e)}]}const x={weak:25,fair:50,good:75,strong:100},g={weak:"destructive",fair:"warning",good:"accent",strong:"success"};function N({password:e,minLength:t=8,showRequirements:a=!0,className:p}){const{t:s}=q("auth"),d=m(()=>k(e),[e]),u=m(()=>S(e,t,(n,c)=>s(n,c||"")),[e,t,s]),h={weak:s("passwordStrength.weak","Weak"),fair:s("passwordStrength.fair","Fair"),good:s("passwordStrength.good","Good"),strong:s("passwordStrength.strong","Strong")};return r(o,{gap:"tight",className:b("dndev-password-strength",p),children:[r(o,{gap:"tight",children:[r(o,{direction:"row",align:"center",justify:"between",gap:"tight",children:[r(l,{as:"span",level:"caption",variant:"muted",children:[s("passwordStrength.label","Password strength"),":"]}),i(l,{as:"strong",level:"caption",variant:g[d],children:h[d]})]}),i(f,{value:x[d],variant:g[d],className:"dndev-password-strength-bar"})]}),a&&r(o,{gap:"tight",className:"dndev-password-requirements",children:[r(l,{as:"strong",level:"caption",variant:"muted",children:[s("passwordRequirements","Password requirements"),":"]}),i(o,{gap:"tight","data-inset":"true",children:u.map((n,c)=>r(o,{direction:"row",align:"center",gap:"tight",className:"dndev-password-requirement-item",children:[n.met?i(w,{className:"dndev-size-xs","data-variant":"success"}):i(v,{className:"dndev-size-xs","data-variant":"muted"}),i(l,{as:"span",level:"caption",variant:n.met?"success":"muted","data-opacity":n.met?void 0:"70",children:n.label})]},c))})]})]})}export{N as PasswordStrengthIndicator};
|
|
@@ -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:n,className:r=""})=>{const{t:s}=t("auth");return null};var a=e;export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as l,useCallback as t}from"react";function g({defaultValue:
|
|
1
|
+
"use client";import{useState as l,useCallback as t}from"react";function g({defaultValue:r="popup"}={}){const[o,e]=l(r),u=o==="redirect",d=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:u,isPopupMode:d,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 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 +1 @@
|
|
|
1
|
-
"use client";import{useState as r,useCallback as l}from"react";import{handleError as
|
|
1
|
+
"use client";import{useState as r,useCallback as l}from"react";import{handleError as v}from"@donotdev/core";import{useAuth as f}from"../useAuth";function F(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 I=a instanceof Error?a.message:"Failed to send sign-in link";n(I),o?.(a),v(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{F as useEmailLinkForm};
|
package/dist/hooks/useFedCM.js
CHANGED
|
@@ -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,
|
|
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,c]=s(!1),[p,f]=s(null),d=E(i);d.current=i,h(()=>{u()&&(async()=>{try{const e="IdentityCredential"in window;let o=!0;if(a){const r=new Promise(t=>setTimeout(t,2e3));await Promise.race([new Promise(t=>{const w=setInterval(()=>{window.google?.accounts?.id&&(clearInterval(w),t(!0))},100)}),r]),o=!!window.google?.accounts?.id}l(e&&o),c(!0)}catch(e){const o=S(e,{userMessage:"Failed to detect FedCM support",context:{operation:"fedcm_detection"},severity:"warning"});f(o),c(!0),d.current?.(o)}})()},[a]);const g=C(()=>{if(!u())return{name:"Unknown",isSupported:!1,recommendation:"Loading..."};const e=navigator.userAgent;let o="Unknown",r="Please update your browser";if(e.includes("Chrome/")){const t=parseInt(e.match(/Chrome\/(\d+)/)?.[1]||"0");o=`Chrome ${t}`,r=t>=116?"Supported":"Please update to Chrome 116 or later"}else if(e.includes("Edg/")){const t=parseInt(e.match(/Edg\/(\d+)/)?.[1]||"0");o=`Edge ${t}`,r=t>=116?"Supported":"Please update to Edge 116 or later"}else e.includes("Safari/")&&!e.includes("Chrome")?(o="Safari",r="Not supported yet. Please use Chrome or Edge"):e.includes("Firefox/")&&(o="Firefox",r="Not supported yet. Please use Chrome or Edge");return{name:o,isSupported:n,recommendation:r}},[n]);return{isSupported:n,isReady:m,error:p,browserInfo:g}}export{y as useFedCM};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as G,useEffect as L,useRef as
|
|
1
|
+
"use client";import{useState as G,useEffect as L,useRef as h,useCallback as j,startTransition as _,useMemo as B}from"react";import{useIsDark as oe}from"@donotdev/components";import{handleError as u,getOAuthClientId as te,getEnabledAuthPartners as re,isClient as ne,useTranslation as ae,useScriptLoader as ie}from"@donotdev/core";import{useAuth as K}from"../useAuth";import{useFedCM as se}from"./useFedCM";function ce({clientId:Q,autoSelect:x=!0,cancelOnTapOutside:C=!0,promptParentId:y,disabled:l=!1,onSuccess:v,onError:i,allowedParentOrigins:R,cspNonce:S,clientOnly:N=!1}={}){const{t:n}=ae("auth"),I=K("user"),F=K("signInWithGoogleCredential"),T=oe(),s=Q||te("google"),E=re().includes("google"),{isSupported:r,isReady:d,error:P,browserInfo:U}=se({checkGoogleServices:!0,onError:o=>{const t=u(o,{userMessage:n("auth.fedcmNotSupported","Your browser does not support Google One Tap"),context:{operation:"fedcm_detection"},severity:"warning"});i?.(t)}}),{isLoading:V,isLoaded:b,error:q,isReady:z,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=u(o,{userMessage:n("auth.googleScriptLoadError","Failed to load Google Identity Services"),context:{operation:"google_script_load"},severity:"error"});i?.(t)}}),[D,$]=G(!1),[Y,A]=G(null),J=h(null),a=h(!1),c=h(null),M=h(0),[H,p]=G(!1),m="gsi_hide_until",w=600*1e3,O=B(()=>E&&!!s&&!l&&!I&&r&&(N?D:!0)&&!H,[E,s,l,I,r,N,D,H]),ee=B(()=>!r&&d?new Error(n("auth.fedcmRequired","Google One Tap requires a modern browser (Chrome 116+ or Edge 116+)")):q||P||Y,[q,P,Y,r,d,n]),f=j(async o=>{try{if(!o||typeof o!="string")throw new Error("Invalid credential format");await F(o),_(()=>{v?.(o)})}catch(t){const e=u(t,{userMessage:n("auth.googleOneTapError","Google One Tap authentication failed"),context:{operation:"google_one_tap_signin",credentialLength:o?.length||0},severity:"error"});throw _(()=>{A(e)}),i?.(e),e}},[F,v,i,n]),k=j(()=>{if(!ne()||!z||!s||!window.google?.accounts?.id||!r||a.current)return;const o=Date.now();if(!(o-M.current<w&&M.current>0))try{a.current=!0,M.current=o;const t={client_id:s,callback:async e=>{try{await f(e.credential)}catch(W){u(W,{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:T?"dark":"light",use_fedcm_for_prompt:!0,allowed_parent_origins:R,csp_nonce:S,moment_callback:e=>{const W=e.getMomentType();if(e.isDisplayMoment?.()){if(!e.isDisplayed?.()&&e.getNotDisplayedReason){a.current=!1;try{const g=Date.now()+w;localStorage.setItem(m,String(g)),p(!0)}catch{}}}else if(e.isSkippedMoment?.()){a.current=!1;try{const g=Date.now()+w;localStorage.setItem(m,String(g)),p(!0)}catch{}}else if(e.isDismissedMoment?.()){a.current=!1;try{const g=Date.now()+w;localStorage.setItem(m,String(g)),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&&f(e.credential)}),c.current=null},100)}catch(t){const e=u(t,{userMessage:n("auth.googleOneTapInitError","Failed to initialize Google One Tap"),context:{operation:"google_one_tap_initialize",fedcmSupported:r},severity:"error"});_(()=>{A(e)}),i?.(e),a.current=!1}},[z,s,r,x,C,y,T,f,i,R,S,n]);return L(()=>{if(typeof window<"u"){_(()=>{$(!0)});try{const o=Number(localStorage.getItem(m)||0);p(o>Date.now())}catch{}}},[]),L(()=>{b&&!l&&O&&d&&k()},[b,l,O,d,k]),L(()=>()=>{c.current&&window.clearTimeout(c.current),a.current=!1},[]),{isLoaded:b,isLoading:V,error:ee,user:I,isDark:T,fedcmSupported:r,isHydrated:D,containerRef:J,initialize:k,handleCredential:f,shouldShow:O,browserInfo:U,triggerLoad:X,loadTriggered:Z}}export{ce 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),
|
|
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};
|
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
|
|
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 T}from"./components";import{getAuthMethod as l,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,T as ReauthDialog,l as getAuthMethod,e as getAuthState,s as subscribeToAuth,a as useAuth,t as useDeleteAccount};
|