@donotdev/auth 0.2.1 → 0.2.3
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.d.ts.map +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.js +1 -1
- package/dist/components/AuthPartnerButton.d.ts.map +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.d.ts +8 -18
- package/dist/components/EmailPasswordForm.d.ts.map +1 -1
- package/dist/components/EmailPasswordForm.js +1 -2
- package/dist/components/EmailVerification.js +1 -1
- package/dist/components/Feature.js +1 -1
- package/dist/components/FeatureGuard.js +1 -1
- package/dist/components/LoginModal.js +1 -1
- package/dist/components/MultipleAuthProviders.js +1 -1
- package/dist/components/PasswordResetCallback.d.ts.map +1 -1
- package/dist/components/PasswordResetCallback.js +1 -2
- package/dist/components/PasswordStrengthIndicator.d.ts.map +1 -1
- package/dist/components/PasswordStrengthIndicator.js +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/emailAuth/fields.d.ts +108 -0
- package/dist/emailAuth/fields.d.ts.map +1 -0
- package/dist/emailAuth/fields.js +1 -0
- package/dist/emailAuth/flows.d.ts +120 -0
- package/dist/emailAuth/flows.d.ts.map +1 -0
- package/dist/emailAuth/flows.js +1 -0
- package/dist/emailAuth/rules.d.ts +36 -0
- package/dist/emailAuth/rules.d.ts.map +1 -0
- package/dist/emailAuth/rules.js +2 -0
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.d.ts.map +1 -1
- package/dist/hooks/useAuthPartner.js +1 -1
- package/dist/hooks/useDeleteAccount.d.ts +15 -1
- package/dist/hooks/useDeleteAccount.d.ts.map +1 -1
- package/dist/hooks/useDeleteAccount.js +1 -1
- package/dist/hooks/useEmailLinkForm.js +1 -1
- package/dist/hooks/useGoogleOneTap.d.ts +2 -1
- package/dist/hooks/useGoogleOneTap.d.ts.map +1 -1
- package/dist/hooks/useGoogleOneTap.js +1 -1
- package/dist/hooks/useNetworkStatus.d.ts.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/symbol-index.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts.map +1 -1
- package/dist/useAuth.js +1 -1
- package/guidelines/AUTH.md +14 -0
- package/package.json +5 -5
package/dist/AuthStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthStore.d.ts","sourceRoot":"","sources":["../src/AuthStore.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,gBAAgB,CAAC;AA2BxB,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"AuthStore.d.ts","sourceRoot":"","sources":["../src/AuthStore.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,gBAAgB,CAAC;AA2BxB,eAAO,MAAM,YAAY,iIAwMvB,CAAC"}
|
package/dist/AuthStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as
|
|
1
|
+
import{createDoNotDevStore as c,FEATURE_STATUS as l,syncQueryCacheIdentity as o}from"@donotdev/core";import{PARTNER_STATE as u}from"./constants";const i={user:null,authenticated:!1,userId:null,loading:!1,error:null,userProfile:null,userSubscription:null,partnerStates:{},partnerError:null,authService:null,emailVerification:{status:"pending"},passwordResetPending:!1,status:l.INITIALIZING},d=c({name:"auth-store",createStore:(t,a)=>({...i,setStatus:r=>{t({status:r})},setPartnerState:(r,e,s)=>{t(n=>({partnerStates:{...n.partnerStates,[r]:e},partnerError:e==="error"&&s?{partnerId:r,error:s}:n.partnerError?.partnerId===r?null:n.partnerError}))},getPartnerState:r=>a().partnerStates[r]||u.IDLE,clearAllPartnerStates:()=>t(r=>({partnerStates:Object.keys(r.partnerStates).reduce((e,s)=>(e[s]=u.IDLE,e),{}),partnerError:null})),setAuthenticated:(r,e,s)=>{o(r.id),t({user:r,authenticated:!0,userId:r.id,loading:!1,error:null,status:l.READY,userSubscription:e,userProfile:s})},setUnauthenticated:()=>{o(null),t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:l.READY,userSubscription:null,userProfile:null})},setAuthLoading:r=>{t({loading:r})},setAuthError:r=>{t({error:r,loading:!1})},clearAuthError:()=>{t({error:null})},getCustomClaim:r=>a().getCustomClaimLocal(r),getCustomClaims:()=>a().getCustomClaimsLocal(),setAuthService:r=>t({authService:r}),getCustomClaimLocal:r=>{const e=a(),s=e.userProfile;return s?.claims&&typeof s.claims=="object"&&r in s.claims?s.claims[r]:s&&typeof s=="object"&&r in s?s[r]:e.user&&typeof e.user=="object"&&r in e.user?e.user[r]:null},getCustomClaimsLocal:()=>{const r=a(),e={};return r.userProfile?.claims&&Object.assign(e,r.userProfile.claims),Object.freeze({...e})},setPasswordResetPending:r=>t({passwordResetPending:r}),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(i)})});export{d as useAuthStore};
|
package/dist/authHelpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isClient as
|
|
1
|
+
import{isClient as e}from"@donotdev/core";import{useAuthStore as t}from"./AuthStore";function s(){return t.getState()}function u(r){return e()?t.subscribe(r):()=>{}}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 L,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=A=>{N(A)};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(L,{fallback:null,children:i(x,{...r})})}var P=E;export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a}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:e=!1,className:u=""}){return a(s,{featureName:"Authentication",message:t,icon:"\u{1F512}",showActionButton:e,actionButtonText:"Sign In (Unavailable)",className:u,helpText:"This feature requires authentication to be configured."})}function l(t,e){return r(t,"Authentication",()=>n(i.AUTH),{message:e?.message,showActionButton:e?.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:()=>a(o,{...t})}}export{o as AuthFallback,c as useAuthComponent,l as withAuthFallback};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthPartnerButton.d.ts","sourceRoot":"","sources":["../../src/components/AuthPartnerButton.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,OAAO,CAAC;AAejE,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;AAGtB,UAAU,+BAAgC,SAAQ,sBAAsB;
|
|
1
|
+
{"version":3,"file":"AuthPartnerButton.d.ts","sourceRoot":"","sources":["../../src/components/AuthPartnerButton.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,OAAO,CAAC;AAejE,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;AAGtB,UAAU,+BAAgC,SAAQ,sBAAsB;IAEtE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,MAAM,EACN,SAAS,EACT,OAAO,EACP,SAAc,EACd,QAAQ,EACR,QAAgB,EAChB,OAAsB,EACtB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,+BAA+B,GAChC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,+BAyIvE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -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:c="",children:b,disabled:h=!1,display:f=S.AUTO,style:g,...q}){const{t:i}=j("auth"),v=s("user"),E=s("signInWithPartner"),A=s("linkWithPartner"),N=s("isAvailable"),[o,y]=B(!1),n=I(()=>W[r],[r]);if(r==="password")return a("div",{className:c,children:a(H,{mode:"signin",onSuccess:()=>u?.(null),onError:l,compact:!0})});if(r==="emailLink")return a("div",{className:c,children:a(F,{onSuccess:()=>u?.(null),onError:l})});const T=I(()=>U[r]||M,[r]),P=n?.firebaseProviderId,d=!!v?.providerData?.some(t=>t.providerId===P),m=v&&!d,w=async()=>{if(!(o||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=n?.name,O=()=>{if(b)return b;if(m)return o?i("buttons.linking",{partner:e}):d?i("buttons.linked",{partner:e}):i("buttons.link",{partner:e});if(o)return i("buttons.signingIn",{partner:e});const t=n?.button?.textKey;return t?i(t):`Sign in with ${e}`},x=h||o||!N||m&&d||!1,C=n?.button?{backgroundColor:n.button.backgroundColor,color:n.button.textColor,borderColor:n.button.borderColor,"--partner-hover-bg":n.button.hoverBackgroundColor}:void 0,L=g?{...C,...g}:C;return a(_,{variant:$.OUTLINE,onClick:w,disabled:x,"aria-busy":o,display:f,"aria-label":o?`Signing in with ${e}...`:`Sign in with ${e}`,tooltip:void 0,style:L,className:D(n?.button&&"auth-partner-button-custom",c),icon:o?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 o,Fragment as f}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 E({open:h,isLoading:c,error:r,onReauth:m,onCancel:a}){const{t:e}=T("auth"),[i,p]=A(""),d=async()=>{await m(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:o(f,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:c,children:e("deleteAccount.reauth.cancel","Cancel")}),n(s,{variant:u.DEFAULT,onClick:d,disabled:c||!i,children:c?e("deleteAccount.reauth.verifying","Verifying..."):e("deleteAccount.reauth.continue","Continue")})]}),children:n("form",{onSubmit:t=>{t.preventDefault(),d()},children:o(l,{children:[n(R,{value:i,onChange:t=>p(t.target.value),label:e("deleteAccount.reauth.password","Password"),disabled:c,placeholder:e("deleteAccount.reauth.passwordPlaceholder","Enter your password"),required:!0,className:"dndev-w-full"}),r&&n(C,{variant:b.ERROR,description:r})]})})})}function x({open:h,isLoading:c,error:r,onConfirm:m,onCancel:a}){const{t:e}=T("auth"),[i,p]=A(!1),d=async()=>{i&&await m()};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:o(f,{children:[n(s,{variant:u.OUTLINE,onClick:a,disabled:c,children:e("deleteAccount.confirm.cancel","Cancel")}),n(s,{variant:u.DESTRUCTIVE,icon:y,onClick:d,disabled:c||!i,children:c?e("deleteAccount.confirm.deleting","Deleting..."):e("deleteAccount.confirm.delete","Delete My Account")})]}),children:o(l,{gap:"large",children:[o(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)")]})]}),o(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")]})]}),o(l,{direction:"row",align:"start",children:[n(k,{id:"confirm-delete",checked:i,onCheckedChange:t=>p(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{x as ConfirmDeleteDialog,E 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 S}from"lucide-react";import{Button as c,BUTTON_VARIANT as f,Input as T,Alert as b,ALERT_VARIANT as C,Spinner as R,Stack as n,Text as s}from"@donotdev/components";import{useTranslation as x}from"@donotdev/core";import{useEmailLinkForm as A}from"../hooks/useEmailLinkForm";function m({className:r="",onSuccess:u,onError:h,actionCodeSettings:k}){const{t:i}=x("auth"),{email:t,setEmail:L,isLoading:a,isSent:v,error:d,handleSendLink:p,handleResend:g,canSubmit:E}=A({onSuccess:u,onError:h,actionCodeSettings:k});return v?l(n,{className:r,children:[l(n,{align:"center",children:[e(S,{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:g,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:N=>L(N.target.value),placeholder:i("emailLink.emailPlaceholder","Enter your email address"),required:!0,disabled:a,className:"dndev-w-full"}),d&&e(b,{variant:C.ERROR,description:d}),e(c,{type:"submit",disabled:!E,icon:a?e(R,{"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,25 +1,15 @@
|
|
|
1
1
|
import type { EmailPasswordFormProps } from '../constants';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* - Password strength indicator with inline requirements
|
|
8
|
-
* - Breached password detection (NIST 800-63B / HaveIBeenPwned)
|
|
9
|
-
* - Client-side rate limiting
|
|
10
|
-
* - Anti-enumeration (signup + forgot password)
|
|
11
|
-
* - CAPTCHA-ready (consumer passes token via prop)
|
|
12
|
-
* - autoComplete hints for password managers
|
|
13
|
-
* - Remember me persistence
|
|
14
|
-
* - Forgot password flow
|
|
15
|
-
* - Resend verification email
|
|
16
|
-
* - Terms of Service / Privacy Policy consent (GDPR)
|
|
17
|
-
* - Sign in / Sign up mode switching with form reset
|
|
18
|
-
* - Full i18n support
|
|
19
|
-
* - Accessible with proper ARIA
|
|
3
|
+
* Email/password form with three views: sign in (remember me, forgot password),
|
|
4
|
+
* sign up (password policy + strength, breached-password check, confirmation,
|
|
5
|
+
* consent) and forgot password. Success calls `onSuccess` at once; what the user must
|
|
6
|
+
* still do arrives as a toast that stays until dismissed.
|
|
20
7
|
*
|
|
21
8
|
* @component
|
|
22
|
-
* @
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <EmailPasswordForm onSuccess={() => setOpen(false)} />
|
|
12
|
+
* ```
|
|
23
13
|
*/
|
|
24
14
|
declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, }: EmailPasswordFormProps): import("react").JSX.Element;
|
|
25
15
|
export default EmailPasswordForm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmailPasswordForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailPasswordForm.tsx"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAQ3D;;;;;;;;;;;GAWG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAS,EACT,GAAG,EACH,OAAO,EACP,YAAY,GACb,EAAE,sBAAsB,+BAiFxB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
2
|
-
`).some(e=>{const[E]=e.split(":");return E?.trim()===d}):!1}catch{return!1}}const ze=[{test:a=>a.includes("429")||a.includes("rate")||a.includes("too_many_requests"),key:"errors.rate_limit",fallback:"Too many attempts. Please wait a moment and try again."},{test:a=>a.includes("email_not_confirmed")||a.includes("email not confirmed")||a.includes("auth/unverified-email"),key:"errors.email_not_confirmed",fallback:"Please verify your email before signing in."},{test:a=>a.includes("invalid_credentials")||a.includes("invalid login credentials")||a.includes("invalid-credential")||a.includes("auth/wrong-password")||a.includes("auth/user-not-found")||a.includes("invalid")&&a.includes("credential"),key:"errors.invalid_credentials",fallback:"Invalid email or password."},{test:a=>a.includes("already")||a.includes("exists")||a.includes("user_already_exists")||a.includes("user already registered")||a.includes("auth/email-already-in-use"),key:"signup.check_email",fallback:"Check your email to confirm your account."},{test:a=>a.includes("weak_password")||a.includes("weak password")||a.includes("auth/weak-password"),key:"errors.weak_password",fallback:"Password is too weak. Please choose a stronger password."},{test:a=>a.includes("network")||a.includes("fetch"),key:"networkError",fallback:"Network error. Please check your connection and try again."}];function Ze(a,t){const m=(a instanceof Error?a.message:String(a)).toLowerCase();for(const l of ze)if(l.test(m))return t(l.key,l.fallback);return t("errorGeneric","Authentication failed. Please try again.")}function Xe({mode:a="signin",onSuccess:t,onError:m,className:l="",tos:y,privacy:d,captchaToken:p}){const{t:e}=Ve("auth"),E=We("app"),me=v("signInWithEmail"),pe=v("createUserWithEmail"),we=v("sendPasswordResetEmail"),he=v("sendEmailVerification"),ge=v("setRememberMe"),fe=v("isAvailable"),j=v("status"),ve=v("loading"),ye=j==="degraded"||j==="error",[T,be]=h(a),w=T==="signup",[q,ke]=h(!1),[F,x]=h(!1),[k,H]=h(!1),[$,U]=h(!1),[K,G]=h(!1),[Pe,B]=h(!1),[_e,z]=h(!1),P=y!==void 0?y:E?.footer?.legalLinks?.find(r=>r.path.includes("terms"))?.path??"/legal/terms",_=d!==void 0?d:E?.footer?.legalLinks?.find(r=>r.path.includes("privacy"))?.path??"/legal/privacy",C=P!==!1,S=_!==!1,Z=C&&typeof P!="string",X=S&&typeof _!="string",Y=C&&typeof P=="string"?P:null,J=S&&typeof _=="string"?_:null,{isRateLimited:M,recordAttempt:Ce,cooldownUntil:Q}=Ge(),{control:R,handleSubmit:Se,getValues:Re,reset:ee,formState:{errors:s,isSubmitting:Ie},setError:D,clearErrors:ae}=Me({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),re=oe({control:R,name:"password"}),I=oe({control:R,name:"email"}),O=V(r=>{ee({email:I||"",password:"",confirmPassword:""}),ae(),U(!1),x(!1),G(!1),be(r)},[ee,ae,I]),Ae=async r=>{if(M()){D("root",{message:e("errors.rate_limit","Too many attempts. Please wait a moment and try again.")});return}Ce();try{T==="signin"?(q!==void 0&&await ge(q),await me(r.email,r.password),t?.(void 0)):(await pe(r.email,r.password,K?{gdpr_consent_at:new Date().toISOString()}:void 0),U(!0),t?.(void 0))}catch(u){const qe=T==="signup",te=u instanceof Error?u.message:String(u),L=te.toLowerCase();if(qe&&(L.includes("already")||L.includes("exists")||L.includes("user_already_exists")||L.includes("auth/email-already-in-use"))){U(!0);return}const xe=Ze(u,e);D("root",{message:xe}),m?.(u instanceof Error?u:new Error(te))}},Ne=async()=>{if(!I||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I)){D("email",{message:e("emailRequired","Email is required")});return}H(!0);try{await we(I)}catch{}finally{x(!0),H(!1)}},Ee=async()=>{try{await he()}catch{}};if(ye)return i(o,{className:l,children:i(A,{variant:N.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Sign-in is temporarily unavailable. Please try again later.")})});const c=ve||Ie||!fe,ie=w&&(C||S),Le=p!==void 0&&!p,Te=c||M()||Le||ie&&!K,se=Q?Math.max(0,Math.ceil((Q-Date.now())/1e3)):0;return i("form",{onSubmit:Se(Ae),className:Oe("dndev-auth-form",l),noValidate:!0,children:n(o,{children:[s.root&&i(A,{variant:N.ERROR,description:s.root.message}),M()&&se>0&&i(A,{variant:N.WARNING,description:e("errors.rate_limit_cooldown",`Too many attempts. Please wait ${se} seconds.`)}),$&&n(o,{children:[i(A,{variant:N.SUCCESS,title:e("signup.success_title","Check your email"),description:e("signup.check_email","If an account was created, you will receive a confirmation email. Check your inbox and spam folder.")}),n(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[i(g,{type:"button",variant:f.GHOST,onClick:Ee,children:e("signup.resend_verification","Resend verification email")}),i(b,{as:"span",variant:"muted",children:"|"}),i(g,{type:"button",variant:f.LINK,onClick:()=>O("signin"),children:e("actions.sign_in_submit","Sign In")})]})]}),F&&n(o,{children:[i(A,{variant:N.SUCCESS,title:e("forgotPassword.sent","Password reset email sent"),description:e("forgotPassword.check_email_safe","If an account exists with this email, you will receive password reset instructions.")}),i(o,{align:"center",children:i(g,{type:"button",variant:f.LINK,onClick:()=>{x(!1)},children:e("back","Back")})})]}),!$&&!F&&n(o,{children:[i(W,{name:"email",control:R,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:r})=>n(o,{gap:"tight",children:[i(De,{...r,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),autoComplete:"username webauthn",disabled:c||k,"aria-invalid":!!s.email,"aria-describedby":s.email?"email-error":void 0,className:"dndev-w-full","data-variant":s.email?"destructive":void 0}),s.email&&i(b,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:s.email.message})]})}),i(W,{name:"password",control:R,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:w?{uppercase:r=>r?/[A-Z]/.test(r)?!0:e("passwordRequirement.uppercase","Password must contain at least one uppercase letter"):!0,lowercase:r=>r?/[a-z]/.test(r)?!0:e("passwordRequirement.lowercase","Password must contain at least one lowercase letter"):!0,number:r=>r?/[0-9]/.test(r)?!0:e("passwordRequirement.number","Password must contain at least one number"):!0,special:r=>r?/[^a-zA-Z0-9]/.test(r)?!0:e("passwordRequirement.special","Password must contain at least one special character"):!0,breached:async r=>!r||r.length<8?!0:await Be(r)?e("errors.breached_password","This password has appeared in a data breach. Please choose a different password."):!0}:void 0},render:({field:r})=>{const u=`password-${r.name}`;return n(o,{gap:"tight",children:[i(ue,{...r,id:u,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),autoComplete:w?"new-password":"current-password",disabled:c||k,"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&&i(b,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:s.password.message})]})}}),w&&i(W,{name:"confirmPassword",control:R,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:r=>{const u=Re("password");return r!==u?e("confirmPasswordMismatch","Passwords do not match"):!0}},render:({field:r})=>n(o,{gap:"tight",children:[i(ue,{...r,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:c,"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&&i(b,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:s.confirmPassword.message})]})}),w&&re&&i(je,{password:re,minLength:8,showRequirements:!0}),ie&&n(ne,{children:[n(o,{direction:"row",gap:"tight",align:"start",children:[i(le,{id:"tos-accept",checked:K,onCheckedChange:r=>G(r===!0),disabled:c}),i(ce,{htmlFor:"tos-accept",children:n(b,{as:"span",level:"caption",children:[e("terms.accept_prefix","I accept the")," ",C&&i(g,{type:"button",variant:f.LINK,onClick:()=>{Z?B(!0):Y&&window.open(Y,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.tos","Terms of Service")}),C&&S&&n(ne,{children:[" ",e("terms.and","and")," "]}),S&&i(g,{type:"button",variant:f.LINK,onClick:()=>{X?z(!0):J&&window.open(J,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.privacy","Privacy Policy")})]})})]}),Z&&i(de,{open:Pe,onOpenChange:B,title:e("terms.tos","Terms of Service"),showClose:!0,children:P}),X&&i(de,{open:_e,onOpenChange:z,title:e("terms.privacy","Privacy Policy"),showClose:!0,children:_})]}),!w&&n(o,{direction:"row",gap:"tight",align:"center",children:[i(le,{id:"remember-me",checked:q,onCheckedChange:r=>ke(r===!0),disabled:c||k}),i(ce,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),i(g,{type:"submit",variant:f.PRIMARY,disabled:Te,fullWidth:!0,children:c?e("loading","Loading..."):w?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!w&&n(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[i(g,{type:"button",variant:f.LINK,disabled:c||k,onClick:Ne,children:k?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),i(b,{as:"span",variant:"muted",children:"|"}),i(g,{type:"button",variant:f.LINK,disabled:c,onClick:()=>O("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),w&&i(o,{align:"center",children:i(g,{type:"button",variant:f.LINK,disabled:c,onClick:()=>O("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})]})})}var Ye=Xe;export{Ye as default};
|
|
1
|
+
"use client";import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useState as A}from"react";import{Button as x,BUTTON_VARIANT as B,Stack as m,Text as w}from"@donotdev/components";import{useTranslation as L}from"@donotdev/core";import{AuthConfirmPasswordField as R,AuthConsentField as U,AuthEmailField as d,AuthForm as h,AuthFormAlerts as p,AuthPasswordField as v,AuthRememberMeField as V,AuthSubmitButton as g}from"../emailAuth/fields";import{AUTH_FIELD as _,useEmailSignIn as j,useEmailSignUp as C,usePasswordResetRequest as H}from"../emailAuth/flows";const M=r=>{const s=r.currentTarget.form?.elements.namedItem(_.EMAIL);return s instanceof HTMLInputElement?s.value:""};function q({mode:r="signin",onSuccess:s,onError:F,className:o,tos:T,privacy:E,captchaToken:I}){const{t:a}=L("auth"),[f,S]=A(r),[i,k]=A(""),l={onSuccess:()=>s?.(void 0),onError:F,captchaToken:I},y=j(l),N=C(l),b=H(l),P=u=>c=>{k(M(c)),S(u)},t=(u,c)=>e(x,{type:"button",variant:B.LINK,onClick:P(c),children:u});return f==="reset"?n(h,{flow:b,className:o,children:[e(w,{variant:"muted",children:a("forgotPassword.intro","Enter your email and we will send you a reset link.")}),e(d,{defaultValue:i}),e(p,{}),e(g,{}),e(m,{align:"center",children:t(a("back","Back"),"signin")})]},"reset"):f==="signup"?n(h,{flow:N,className:o,children:[e(d,{defaultValue:i}),e(v,{}),e(R,{}),e(U,{tos:T,privacy:E}),e(p,{}),e(g,{}),e(m,{align:"center",children:t(a("alreadyHaveAccount","Already have an account? Sign In"),"signin")})]},"signup"):n(h,{flow:y,className:o,children:[e(d,{defaultValue:i}),e(v,{}),e(V,{}),e(p,{}),e(g,{}),n(m,{direction:"row",gap:"tight",justify:"center",align:"center",children:[t(a("forgotPassword","Forgot password?"),"reset"),e(w,{as:"span",variant:"muted",children:"|"}),t(a("actions.sign_up_submit","Sign Up"),"signup")]})]},"signin")}var D=q;export{D 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:u}){const{t:e}=x("auth"),t=n("user"),i=n("emailVerification"),l=n("sendEmailVerification"),s=t?.id,c=h(),a=u||`email-verification-${c}`,f=`${a}-heading`,m=`${a}-button`,g=async()=>{if(!(!t||!s))try{await l()}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 s}from"react/jsx-runtime";import{useImperativeHandle as o,forwardRef as i}from"react";import{hasTierAccess as f}from"@donotdev/core";import{useAuth as c}from"../useAuth";const p=i(({featureId:e,fallback:r=null,children:n},l)=>{const a=c("userSubscription")?.features?.includes(e)||!1;return o(l,()=>({enabled:a}),[a]),a?s(t,{children:n}):r?s(t,{children:r}):null}),m=i(({tier:e,fallback:r=null,children:n},l)=>{const a=c("userSubscription"),d=e||"pro",u=f(a?.tier,d);return o(l,()=>({enabled:u}),[u]),u?s(t,{children:n}):r?s(t,{children:r}):null}),h=i((e,r)=>s(m,{ref:r,tier:"pro",...e})),b=i((e,r)=>s(m,{ref:r,tier:"premium",...e}));export{p as Feature,b as PremiumFeature,h as ProFeature};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as r,jsxs as a,Fragment as w}from"react/jsx-runtime";import{Stack as f}from"@donotdev/components";import{hasRoleAccess as h,hasTierAccess as m}from"@donotdev/core";import{useAuth as t}from"../useAuth";import{AuthFallback as F}from"./AuthFallback";function g({requiredTier:e,userTier:i}){return r("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:a(f,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),a("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:e==="pro"?"Pro Feature":"Premium Feature"}),a("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",e," to access this feature",i&&` (current: ${i})`]})]})]})})}function p({requiredRole:e,userRole:i}){const o=Array.isArray(e)?e.join(" or "):e;return r("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:a(f,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),a("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive-foreground)"},children:"Access Denied"}),a("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",o," role",i&&` (current: ${i})`]})]})]})})}function b(){return r("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:a(f,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u23F0"}),a("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:"Subscription Required"}),r("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:"This feature requires an active subscription"})]})]})})}function y({children:e,role:i,tier:o,subscription:u,validate:n,fallback:s,message:l,showUpgradePrompt:A=!0,showLoginPrompt:S=!0}){const z=t("user"),R=t("loading"),q=t("userProfile"),v=t("userSubscription"),d=q?.role,c=v?.tier;return R?r("div",{style:{height:"2rem",borderRadius:"var(--radius)",backgroundColor:"var(--muted)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}):!z&&(i||o||u)?S?r(F,{message:l||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(T=>h(d,T))?s?r(s,{requiredRole:i,userRole:d||void 0}):r(p,{requiredRole:i,userRole:d||void 0}):o&&!m(c,o)?s?r(s,{requiredTier:o,userTier:c||"free"}):A?r(g,{requiredTier:o,userTier:c||"free"}):null:u&&!v?.isActive?s?r(s,{requiresSubscription:!0,hasSubscription:v?.isActive||!1}):r(b,{}):n&&!n(d,c)?s?r(s,{userRole:d,userTier:c}):r(p,{userRole:d}):r(w,{children:e})}function P(e){const i=t("user"),o=t("userProfile"),u=t("userSubscription"),n=o?.role,s=u?.tier;return!(!i&&(e.role||e.tier||e.subscription)||e.role&&!(Array.isArray(e.role)?e.role:[e.role]).some(l=>h(n,l))||e.tier&&!m(s,e.tier)||e.subscription&&!u?.isActive||e.validate&&n&&s&&!e.validate(n,s))}function k(e,i){return o=>r(y,{...i,children:r(e,{...o})})}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{jsx as t}from"react/jsx-runtime";import{Dialog as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Dialog as a}from"@donotdev/components";import{useTranslation as e}from"@donotdev/core";import{withAuthFallback as s}from"./AuthFallback";import r from"./MultipleAuthProviders";function p({open:n,onOpenChange:i}){const{t:o}=e("auth");return t(a,{open:n,onOpenChange:i,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 m=s(p,{message:"Authentication is not configured",showLoginButton:!0});var l=m;export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as
|
|
1
|
+
"use client";import{jsx as a,jsxs as S}from"react/jsx-runtime";import{Suspense as $,lazy as k,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 C}from"@donotdev/core";import{useAuth as m}from"../useAuth";import{withAuthFallback as G}from"./AuthFallback";import M from"./AuthPartnerButton";import{getAuthMethod as O}from"../constants";import{useAccountLinking as q}from"../hooks/useAccountLinking";const B=k(()=>import("./AccountLinking")),F=({providers:h,containerClassName:e="",providerClassName:p="",method:g,size:_="md",layout:r="vertical",showLabels:f=!0,spacing:o="medium",ariaLabel:v,id:A,fullWidth:b=!0,onSuccess:N})=>{const{t:s}=j("auth"),w=y(),n=A||w,{isRequired:R}=q(),l=m("error"),x=m("isAvailable"),z=O(g),i=h||C();if(!i||i.length===0)return a("div",{className:e,children:a("p",{children:"No authentication providers are configured"})});const I=()=>{const d=i.map((t,L)=>a(M,{partnerId:t,method:z,className:`${p} ${b?"dndev-w-full":""}`,tabIndex:L===0?0:void 0,id:`${n}-${t}-button`,onSuccess:N,children:f?void 0:null},t));return r==="grid"?a(T,{cols:2,gap:o,className:e,children:d}):a(c,{direction:r==="horizontal"?"row":"column",wrap:r==="horizontal"?"wrap":void 0,gap:o,align:r==="horizontal"?"center":"stretch",className:e,children:d})};return S(c,{className:"dndev-mx-auto",id:n,role:"region","aria-label":v||s("aria.signInOptions","Sign in options"),children:[I(),l&&x&&a(E,{variant:P.ERROR,description:l.message||s("errorGeneric","Authentication failed. Please try again.")}),R&&a($,{fallback:null,children:a(B,{})})]})},u=G(F,{message:"Authentication providers are not configured",showLoginButton:!0});var V=u;export{u as MultipleAuthProviders,V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordResetCallback.d.ts","sourceRoot":"","sources":["../../src/components/PasswordResetCallback.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PasswordResetCallback.d.ts","sourceRoot":"","sources":["../../src/components/PasswordResetCallback.tsx"],"names":[],"mappings":"AAsHA;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,uCAgXpC"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";import{jsx as s,jsxs as
|
|
2
|
-
`).some(o=>{const[c]=o.split(":");return c?.trim()===p}):!1}catch{return!1}}function J(){const{t:r}=$("auth"),n=f("passwordResetPending"),d=f("verifyPasswordResetCode"),i=f("confirmPasswordReset"),l=f("updatePassword"),p=f("signInWithEmail"),[a,o]=h("idle"),[c,A]=h(null),[v,_]=h(null),[k,W]=h(!1),[U,q]=h(null),{control:y,handleSubmit:M,getValues:Y,formState:{errors:t,isSubmitting:P},setError:E}=B({mode:"onChange",defaultValues:{password:"",confirmPassword:""}}),I=z({control:y,name:"password"});D(()=>{if(a!=="idle")return;const e=H();if(e.type==="supabase_error"){e.errorCode==="otp_expired"?o("expired"):(q(e.errorDescription||null),o("invalid"));return}if(e.type==="firebase"&&e.oobCode){W(!0),_(e.oobCode),o("loading"),d(e.oobCode).then(u=>{u?(A(u),o("ready")):o("expired")});return}n&&o("ready")},[n,a,d]);const j=L(async e=>{try{if(k&&v){if(await i(v,e.password),c)try{await p(c,e.password)}catch{}}else await l(e.password),V.getState().setPasswordResetPending(!1);o("idle")}catch(u){const T=u instanceof Error?u.message:String(u);T.includes("expired")||T.includes("EXPIRED")?o("expired"):E("root",{message:r("resetPassword.error","Failed to reset password. Please try again.")})}},[k,v,c,i,l,p,E,r]),b=L(()=>{o("idle"),A(null),_(null),q(null),V.getState().setPasswordResetPending(!1),typeof window<"u"&&window.history.replaceState(null,"",window.location.pathname)},[]);return a==="idle"?null:w(F,{open:!0,onOpenChange:e=>{e||b()},style:{maxWidth:"min(28rem, 90vw)"},title:a==="success"?r("resetPassword.success_title","Password updated"):a==="expired"||a==="invalid"?r("resetPassword.expired_title","Link expired"):a==="loading"?r("resetPassword.verifying","Verifying..."):r("resetPassword.title","Set new password"),showClose:!0,children:[a==="loading"&&w(m,{align:"center",justify:"center",children:[s(Z,{}),s(g,{level:"body",variant:"muted",children:r("resetPassword.verifying","Verifying reset link...")})]}),(a==="expired"||a==="invalid")&&w(m,{children:[s(R,{variant:S.WARNING,description:a==="expired"?r("resetPassword.expired_description","This password reset link has expired. Please request a new one."):U||r("resetPassword.invalid_description","This password reset link is invalid. Please request a new one.")}),s(C,{variant:x.PRIMARY,onClick:b,fullWidth:!0,children:r("resetPassword.back_to_signin","Back to Sign In")})]}),a==="success"&&w(m,{children:[s(R,{variant:S.SUCCESS,description:r("resetPassword.success_description","Your password has been reset successfully. You are now signed in.")}),s(C,{variant:x.PRIMARY,onClick:b,fullWidth:!0,children:r("resetPassword.continue","Continue")})]}),a==="ready"&&s("form",{onSubmit:M(j),noValidate:!0,children:w(m,{children:[c&&s(g,{level:"small",variant:"muted",children:r("resetPassword.for_email",`Enter a new password for ${c}`)}),t.root&&s(R,{variant:S.ERROR,description:t.root.message}),s(N,{name:"password",control:y,rules:{required:r("passwordRequired","Password is required"),minLength:{value:8,message:r("passwordMinLength","Password must be at least 8 characters")},validate:{uppercase:e=>!e||/[A-Z]/.test(e)||r("passwordRequirement.uppercase","One uppercase letter"),lowercase:e=>!e||/[a-z]/.test(e)||r("passwordRequirement.lowercase","One lowercase letter"),number:e=>!e||/[0-9]/.test(e)||r("passwordRequirement.number","One number"),special:e=>!e||/[^a-zA-Z0-9]/.test(e)||r("passwordRequirement.special","One special character"),breached:async e=>!e||e.length<8?!0:!await X(e)||r("errors.breached_password","This password has appeared in a data breach.")}},render:({field:e})=>w(m,{gap:"tight",children:[s(O,{...e,label:r("resetPassword.new_password","New password"),placeholder:r("passwordPlaceholder","Enter your password"),autoComplete:"new-password",disabled:P,"aria-invalid":!!t.password,"aria-describedby":t.password?"reset-password-error":void 0,className:"dndev-w-full","data-variant":t.password?"destructive":void 0}),t.password&&s(g,{as:"span",level:"caption",variant:"destructive",id:"reset-password-error",role:"alert",children:t.password.message})]})}),s(N,{name:"confirmPassword",control:y,rules:{required:r("confirmPasswordRequired","Please confirm your password"),validate:e=>e===Y("password")||r("confirmPasswordMismatch","Passwords do not match")},render:({field:e})=>w(m,{gap:"tight",children:[s(O,{...e,label:r("confirmPassword","Confirm password"),placeholder:r("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:P,"aria-invalid":!!t.confirmPassword,"aria-describedby":t.confirmPassword?"reset-confirm-error":void 0,className:"dndev-w-full","data-variant":t.confirmPassword?"destructive":void 0}),t.confirmPassword&&s(g,{as:"span",level:"caption",variant:"destructive",id:"reset-confirm-error",role:"alert",children:t.confirmPassword.message})]})}),I&&s(G,{password:I,minLength:8,showRequirements:!0}),s(C,{type:"submit",variant:x.PRIMARY,disabled:P,fullWidth:!0,children:P?r("loading","Loading..."):r("resetPassword.submit","Reset Password")})]})})]})}export{J as PasswordResetCallback};
|
|
1
|
+
"use client";import{jsx as s,jsxs as i}from"react/jsx-runtime";import{useCallback as L,useEffect as U,useState as m}from"react";import{useForm as j,Controller as N,useWatch as z}from"react-hook-form";import{Alert as R,ALERT_VARIANT as C,Button as S,BUTTON_VARIANT as _,Dialog as F,PasswordInput as V,Spinner as Z,Stack as l,Text as g}from"@donotdev/components";import{useTranslation as G}from"@donotdev/core";import{useAuthStore as O}from"../AuthStore";import{isBreachedPassword as X}from"../emailAuth/rules";import{useAuth as h}from"../useAuth";import{PasswordStrengthIndicator as $}from"./PasswordStrengthIndicator";function H(){if(typeof window>"u")return{type:null};const r=window.location.hash.slice(1);if(r){const n=new URLSearchParams(r),p=n.get("error_code");if(p){const f={type:"supabase_error",errorCode:p,errorDescription:n.get("error_description")?.replace(/\+/g," ")||void 0};return window.history.replaceState(null,"",window.location.pathname+window.location.search),f}if(n.get("type")==="recovery")return window.history.replaceState(null,"",window.location.pathname+window.location.search),{type:"supabase_recovery"}}const c=new URLSearchParams(window.location.search),w=c.get("oobCode");return w&&c.get("mode")==="resetPassword"?{type:"firebase",oobCode:w}:{type:null}}function J(){const{t:r}=G("auth"),c=h("passwordResetPending"),w=h("verifyPasswordResetCode"),n=h("confirmPasswordReset"),p=h("updatePassword"),f=h("signInWithEmail"),[a,t]=m("idle"),[u,x]=m(null),[v,A]=m(null),[q,W]=m(!1),[M,k]=m(null),{control:y,handleSubmit:Y,getValues:B,formState:{errors:o,isSubmitting:P},setError:E}=j({mode:"onChange",defaultValues:{password:"",confirmPassword:""}}),I=z({control:y,name:"password"});U(()=>{if(a!=="idle")return;const e=H();if(e.type==="supabase_error"){e.errorCode==="otp_expired"?t("expired"):(k(e.errorDescription||null),t("invalid"));return}if(e.type==="firebase"&&e.oobCode){W(!0),A(e.oobCode),t("loading"),w(e.oobCode).then(d=>{d?(x(d),t("ready")):t("expired")});return}c&&t("ready")},[c,a,w]);const D=L(async e=>{try{if(q&&v){if(await n(v,e.password),u)try{await f(u,e.password)}catch{}}else await p(e.password),O.getState().setPasswordResetPending(!1);t("idle")}catch(d){const T=d instanceof Error?d.message:String(d);T.includes("expired")||T.includes("EXPIRED")?t("expired"):E("root",{message:r("resetPassword.error","Failed to reset password. Please try again.")})}},[q,v,u,n,p,f,E,r]),b=L(()=>{t("idle"),x(null),A(null),k(null),O.getState().setPasswordResetPending(!1),typeof window<"u"&&window.history.replaceState(null,"",window.location.pathname)},[]);return a==="idle"?null:i(F,{open:!0,onOpenChange:e=>{e||b()},style:{maxWidth:"min(28rem, 90vw)"},title:a==="success"?r("resetPassword.success_title","Password updated"):a==="expired"||a==="invalid"?r("resetPassword.expired_title","Link expired"):a==="loading"?r("resetPassword.verifying","Verifying..."):r("resetPassword.title","Set new password"),showClose:!0,children:[a==="loading"&&i(l,{align:"center",justify:"center",children:[s(Z,{}),s(g,{level:"body",variant:"muted",children:r("resetPassword.verifying","Verifying reset link...")})]}),(a==="expired"||a==="invalid")&&i(l,{children:[s(R,{variant:C.WARNING,description:a==="expired"?r("resetPassword.expired_description","This password reset link has expired. Please request a new one."):M||r("resetPassword.invalid_description","This password reset link is invalid. Please request a new one.")}),s(S,{variant:_.PRIMARY,onClick:b,fullWidth:!0,children:r("resetPassword.back_to_signin","Back to Sign In")})]}),a==="success"&&i(l,{children:[s(R,{variant:C.SUCCESS,description:r("resetPassword.success_description","Your password has been reset successfully. You are now signed in.")}),s(S,{variant:_.PRIMARY,onClick:b,fullWidth:!0,children:r("resetPassword.continue","Continue")})]}),a==="ready"&&s("form",{onSubmit:Y(D),noValidate:!0,children:i(l,{children:[u&&s(g,{level:"small",variant:"muted",children:r("resetPassword.for_email",`Enter a new password for ${u}`)}),o.root&&s(R,{variant:C.ERROR,description:o.root.message}),s(N,{name:"password",control:y,rules:{required:r("passwordRequired","Password is required"),minLength:{value:8,message:r("passwordMinLength",{defaultValue:"Password must be at least 8 characters",count:8})},validate:{uppercase:e=>!e||/[A-Z]/.test(e)||r("passwordRequirement.uppercase","One uppercase letter"),lowercase:e=>!e||/[a-z]/.test(e)||r("passwordRequirement.lowercase","One lowercase letter"),number:e=>!e||/[0-9]/.test(e)||r("passwordRequirement.number","One number"),special:e=>!e||/[^a-zA-Z0-9]/.test(e)||r("passwordRequirement.special","One special character"),breached:async e=>!e||e.length<8?!0:!await X(e)||r("errors.breached_password","This password has appeared in a data breach.")}},render:({field:e})=>i(l,{gap:"tight",children:[s(V,{...e,label:r("resetPassword.new_password","New password"),placeholder:r("passwordPlaceholder","Enter your password"),autoComplete:"new-password",disabled:P,"aria-invalid":!!o.password,"aria-describedby":o.password?"reset-password-error":void 0,className:"dndev-w-full","data-variant":o.password?"destructive":void 0}),o.password&&s(g,{as:"span",level:"caption",variant:"destructive",id:"reset-password-error",role:"alert",children:o.password.message})]})}),s(N,{name:"confirmPassword",control:y,rules:{required:r("confirmPasswordRequired","Please confirm your password"),validate:e=>e===B("password")||r("confirmPasswordMismatch","Passwords do not match")},render:({field:e})=>i(l,{gap:"tight",children:[s(V,{...e,label:r("confirmPassword","Confirm password"),placeholder:r("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:P,"aria-invalid":!!o.confirmPassword,"aria-describedby":o.confirmPassword?"reset-confirm-error":void 0,className:"dndev-w-full","data-variant":o.confirmPassword?"destructive":void 0}),o.confirmPassword&&s(g,{as:"span",level:"caption",variant:"destructive",id:"reset-confirm-error",role:"alert",children:o.confirmPassword.message})]})}),I&&s($,{password:I,minLength:8,showRequirements:!0}),s(S,{type:"submit",variant:_.PRIMARY,disabled:P,fullWidth:!0,children:P?r("loading","Loading..."):r("resetPassword.submit","Reset Password")})]})})]})}export{J as PasswordResetCallback};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordStrengthIndicator.d.ts","sourceRoot":"","sources":["../../src/components/PasswordStrengthIndicator.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,8BAA8B;IAC7C,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"PasswordStrengthIndicator.d.ts","sourceRoot":"","sources":["../../src/components/PasswordStrengthIndicator.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,8BAA8B;IAC7C,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AA6FnE;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,QAAQ,EACR,SAAa,EACb,gBAAuB,EACvB,SAAS,GACV,EAAE,8BAA8B,+BAkFhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Check as
|
|
1
|
+
"use client";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{Check as v,Circle as f}from"lucide-react";import{useMemo as m}from"react";import{Progress as b,Stack as o,Text as l,cn as q}from"@donotdev/components";import{useTranslation as k}from"@donotdev/core";function S(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 N(e,t,s){return[{label:s("passwordRequirement.length",`At least ${t} characters`,{count:t}),met:e.length>=t},{label:s("passwordRequirement.uppercase","One uppercase letter"),met:/[A-Z]/.test(e)},{label:s("passwordRequirement.lowercase","One lowercase letter"),met:/[a-z]/.test(e)},{label:s("passwordRequirement.number","One number"),met:/[0-9]/.test(e)},{label:s("passwordRequirement.special","One special character (!@#$%^&*)"),met:/[^a-zA-Z0-9]/.test(e)}]}const R={weak:25,fair:50,good:75,strong:100},g={weak:"destructive",fair:"warning",good:"accent",strong:"success"};function x({password:e,minLength:t=8,showRequirements:s=!0,className:p}){const{t:a}=k("auth"),d=m(()=>S(e),[e]),u=m(()=>N(e,t,(n,c,w)=>a(n,{defaultValue:c||"",...w})),[e,t,a]),h={weak:a("passwordStrength.weak","Weak"),fair:a("passwordStrength.fair","Fair"),good:a("passwordStrength.good","Good"),strong:a("passwordStrength.strong","Strong")};return r(o,{gap:"tight",className:q("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:[a("passwordStrength.label","Password strength"),":"]}),i(l,{as:"strong",level:"caption",variant:g[d],children:h[d]})]}),i(b,{value:R[d],variant:g[d],className:"dndev-password-strength-bar"})]}),s&&r(o,{gap:"tight",className:"dndev-password-requirements",children:[r(l,{as:"strong",level:"caption",variant:"muted",children:[a("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(v,{className:"dndev-size-xs","data-variant":"success"}):i(f,{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{x as PasswordStrengthIndicator};
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EACL,kBAAkB,IAAI,aAAa,EACnC,KAAK,gBAAgB,IAAI,YAAY,GACtC,MAAM,gBAAgB,CAAC;AAMxB;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EACL,kBAAkB,IAAI,aAAa,EACnC,KAAK,gBAAgB,IAAI,YAAY,GACtC,MAAM,gBAAgB,CAAC;AAMxB;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAE5C,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAMD;;;;;;GAMG;AACH,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACrE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,iCAAiC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kDAAkD;IAClD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBACf,SAAQ,kBAAkB,EAAE,iBAAiB;IAC7C,uCAAuC;IACvC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;IACvC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3C;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;CAAG;AAElE;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,sBACf,SAAQ,iBAAiB,EAAE,kBAAkB;IAC7C,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;CAClD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,iEAAiE;IACjE,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;IAC5B,yCAAyC;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { EmailAuthFlow } from './flows';
|
|
3
|
+
/** Props of {@link AuthForm}. */
|
|
4
|
+
export interface AuthFormProps {
|
|
5
|
+
/** The flow this form runs (`useEmailSignIn()`, `useEmailSignUp()`, ...) */
|
|
6
|
+
flow: EmailAuthFlow;
|
|
7
|
+
/** Fields, app content, alerts, submit button */
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The `<form>` of an email auth flow. A real form, so password managers pair the
|
|
13
|
+
* fields and Enter submits. Shows an "unavailable" notice instead when the auth
|
|
14
|
+
* provider failed to start.
|
|
15
|
+
*
|
|
16
|
+
* @param props - AuthFormProps
|
|
17
|
+
* @returns The form
|
|
18
|
+
*/
|
|
19
|
+
export declare function AuthForm({ flow, children, className }: AuthFormProps): import("react").JSX.Element;
|
|
20
|
+
/** Props shared by the text fields. */
|
|
21
|
+
export interface AuthTextFieldProps {
|
|
22
|
+
/** Label (default: translated "Email" / "Password") */
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Placeholder (default: translated) */
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
/** Initial value */
|
|
27
|
+
defaultValue?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Email field (`name="email"`, `autocomplete="username"`: the identifier password
|
|
31
|
+
* managers pair with the password).
|
|
32
|
+
*
|
|
33
|
+
* @param props - AuthTextFieldProps
|
|
34
|
+
* @returns The field
|
|
35
|
+
*/
|
|
36
|
+
export declare function AuthEmailField({ label, placeholder, defaultValue, }: AuthTextFieldProps): import("react").JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* Password field. Sign-in: `current-password`. Sign-up: `new-password` and a strength
|
|
39
|
+
* meter with the policy requirements.
|
|
40
|
+
*
|
|
41
|
+
* @param props - AuthTextFieldProps
|
|
42
|
+
* @returns The field
|
|
43
|
+
*/
|
|
44
|
+
export declare function AuthPasswordField({ label, placeholder }: AuthTextFieldProps): import("react").JSX.Element;
|
|
45
|
+
/**
|
|
46
|
+
* Second password entry (sign-up, `name="confirmPassword"`). Rendering it makes the
|
|
47
|
+
* flow require a match.
|
|
48
|
+
*
|
|
49
|
+
* @param props - AuthTextFieldProps
|
|
50
|
+
* @returns The field
|
|
51
|
+
*/
|
|
52
|
+
export declare function AuthConfirmPasswordField({ label, placeholder, }: AuthTextFieldProps): import("react").JSX.Element;
|
|
53
|
+
/** Props of {@link AuthRememberMeField}. */
|
|
54
|
+
export interface AuthRememberMeFieldProps {
|
|
55
|
+
/** Label (default: translated "Remember me") */
|
|
56
|
+
label?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Initial state.
|
|
59
|
+
* @default true (sessions persist unless the user opts out)
|
|
60
|
+
*/
|
|
61
|
+
defaultChecked?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* "Remember me" (sign-in, `name="rememberMe"`). Rendered only when the auth provider
|
|
65
|
+
* can honour it; unticked = the session ends with the browser session.
|
|
66
|
+
*
|
|
67
|
+
* @param props - AuthRememberMeFieldProps
|
|
68
|
+
* @returns The checkbox, or nothing when the provider cannot do it
|
|
69
|
+
*/
|
|
70
|
+
export declare function AuthRememberMeField({ label, defaultChecked, }: AuthRememberMeFieldProps): import("react").JSX.Element | null;
|
|
71
|
+
/** Legal document: a path (opened in a new tab) or content (shown in a dialog). */
|
|
72
|
+
export type AuthLegalDocument = string | ReactNode;
|
|
73
|
+
/** Props of {@link AuthConsentField}. */
|
|
74
|
+
export interface AuthConsentFieldProps {
|
|
75
|
+
/** Terms of Service. Omit: from app config legal links, else `/legal/terms`. `false`: none */
|
|
76
|
+
tos?: AuthLegalDocument | false;
|
|
77
|
+
/** Privacy policy. Omit: from app config legal links, else `/legal/privacy`. `false`: none */
|
|
78
|
+
privacy?: AuthLegalDocument | false;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Terms / privacy consent (sign-up, `name="consent"`, GDPR). Rendering it makes the
|
|
82
|
+
* flow require it and record `gdpr_consent_at`.
|
|
83
|
+
*
|
|
84
|
+
* @param props - AuthConsentFieldProps
|
|
85
|
+
* @returns The checkbox and links, or nothing when both documents are `false`
|
|
86
|
+
*/
|
|
87
|
+
export declare function AuthConsentField({ tos, privacy }: AuthConsentFieldProps): import("react").JSX.Element | null;
|
|
88
|
+
/**
|
|
89
|
+
* Form-level messages: provider error / throttle, and a resend action when sign-in
|
|
90
|
+
* failed on an unconfirmed address.
|
|
91
|
+
*
|
|
92
|
+
* @returns The alerts, or nothing
|
|
93
|
+
*/
|
|
94
|
+
export declare function AuthFormAlerts(): import("react").JSX.Element | null;
|
|
95
|
+
/** Props of {@link AuthSubmitButton}. */
|
|
96
|
+
export interface AuthSubmitButtonProps {
|
|
97
|
+
/** Label (default: translated per flow) */
|
|
98
|
+
children?: ReactNode;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Submit button: full width, loading while the flow runs, disabled until the provider
|
|
102
|
+
* is ready and while CAPTCHA / throttle block.
|
|
103
|
+
*
|
|
104
|
+
* @param props - AuthSubmitButtonProps
|
|
105
|
+
* @returns The button
|
|
106
|
+
*/
|
|
107
|
+
export declare function AuthSubmitButton({ children }: AuthSubmitButtonProps): import("react").JSX.Element;
|
|
108
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/emailAuth/fields.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAqBvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAW7C,iCAAiC;AACjC,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,IAAI,EAAE,aAAa,CAAC;IACpB,iDAAiD;IACjD,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,aAAa,+BAyBpE;AAYD,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,WAAW,EACX,YAAY,GACb,EAAE,kBAAkB,+BAyBpB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,kBAAkB,+BAuC3E;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,KAAK,EACL,WAAW,GACZ,EAAE,kBAAkB,+BA0BpB;AAED,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;IACvC,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,cAAqB,GACtB,EAAE,wBAAwB,sCAa1B;AASD,mFAAmF;AACnF,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnD,yCAAyC;AACzC,MAAM,WAAW,qBAAqB;IACpC,8FAA8F;IAC9F,GAAG,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAAC;IAChC,8FAA8F;IAC9F,OAAO,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAAC;CACrC;AAmCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,qBAAqB,sCA6CvE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,uCAmB7B;AAED,yCAAyC;AACzC,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE,qBAAqB,+BAoBnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as n,jsxs as u,Fragment as A}from"react/jsx-runtime";import{createContext as L,use as M,useId as m,useState as R}from"react";import{Alert as E,ALERT_VARIANT as P,Button as w,BUTTON_VARIANT as y,Checkbox as C,Dialog as x,Input as O,Label as V,PasswordInput as I,Stack as h,Text as N,cn as B}from"@donotdev/components";import{useAppConfig as D,useTranslation as p}from"@donotdev/core";import{useAuth as U}from"../useAuth";import{PasswordStrengthIndicator as W}from"../components/PasswordStrengthIndicator";import{AUTH_FIELD as v}from"./flows";const S=L(null);function b(){const t=M(S);if(!t)throw new Error("Auth fields must be rendered inside <AuthForm>");return t}function j({flow:t,children:e,className:a}){const{t:i}=p("auth");return t.unavailable?n(E,{variant:P.WARNING,title:i("unavailable.title","Authentication Unavailable"),description:i("unavailable.description","Sign-in is temporarily unavailable. Please try again later.")}):n(S,{value:t,children:n("form",{noValidate:!0,onSubmit:t.onSubmit,className:B("dndev-auth-form",a),children:n(h,{children:e})})})}function g({id:t,message:e}){return e?n(N,{as:"span",level:"caption",variant:"destructive",id:t,role:"alert",children:e}):null}function H({label:t,placeholder:e,defaultValue:a}){const{t:i}=p("auth"),r=b(),l=m(),s=m(),o=r.fieldErrors.email;return u(h,{gap:"tight",children:[n(O,{id:l,name:v.EMAIL,type:"email",autoComplete:"username",label:t??i("email","Email"),placeholder:e??i("emailPlaceholder","Enter your email"),defaultValue:a,disabled:r.busy,"aria-invalid":!!o,"aria-describedby":o?s:void 0,"data-variant":o?"destructive":void 0,className:"dndev-w-full"}),n(g,{id:s,message:o})]})}function K({label:t,placeholder:e}){const{t:a}=p("auth"),i=b(),r=m(),l=m(),[s,o]=R(""),c=i.mode==="signup",d=i.fieldErrors.password;return u(h,{gap:"tight",children:[n(I,{id:r,name:v.PASSWORD,autoComplete:c?"new-password":"current-password",label:t??a("password","Password"),placeholder:e??a("passwordPlaceholder","Enter your password"),onInput:c?f=>o(f.target.value):void 0,disabled:i.busy,"aria-invalid":!!d,"aria-describedby":d?l:void 0,"data-variant":d?"destructive":void 0,className:"dndev-w-full"}),n(g,{id:l,message:d}),c&&s!==""&&n(W,{password:s,minLength:i.passwordMinLength,showRequirements:!0})]})}function q({label:t,placeholder:e}){const{t:a}=p("auth"),i=b(),r=m(),l=m(),s=i.fieldErrors.confirmPassword;return u(h,{gap:"tight",children:[n(I,{id:r,name:v.CONFIRM_PASSWORD,autoComplete:"new-password",label:t??a("confirmPassword","Confirm Password"),placeholder:e??a("confirmPasswordPlaceholder","Re-enter your password"),disabled:i.busy,"aria-invalid":!!s,"aria-describedby":s?l:void 0,"data-variant":s?"destructive":void 0,className:"dndev-w-full"}),n(g,{id:l,message:s})]})}function G({label:t,defaultChecked:e=!0}){const{t:a}=p("auth"),i=b(),r=U("canRememberMe");return!i.ready||!r()?null:n(C,{name:v.REMEMBER_ME,defaultChecked:e,disabled:i.busy,label:t??a("rememberMe","Remember me")})}const Y={minHeight:"auto",padding:0,display:"inline"};function F({label:t,document:e}){const[a,i]=R(!1),r=typeof e=="string";return u(A,{children:[n(w,{type:"button",variant:y.LINK,onClick:()=>r?window.open(e,"_blank","noopener,noreferrer"):i(!0),className:"dndev-p-0 dndev-h-auto",style:Y,children:t}),!r&&n(x,{open:a,onOpenChange:i,title:t,showClose:!0,children:e})]})}function Q({tos:t,privacy:e}){const{t:a}=p("auth"),i=b(),r=D("app"),l=m(),s=m(),o=(_,T)=>r?.footer?.legalLinks?.find(k=>k.path.includes(_))?.path??T,c=t===void 0?o("terms","/legal/terms"):t,d=e===void 0?o("privacy","/legal/privacy"):e;if(c===!1&&d===!1)return null;const f=i.fieldErrors.consent;return u(h,{gap:"tight",children:[u(h,{direction:"row",gap:"tight",align:"start",children:[n(C,{id:l,name:v.CONSENT,disabled:i.busy,"aria-invalid":!!f,"aria-describedby":f?s:void 0}),n(V,{htmlFor:l,children:u(N,{as:"span",level:"caption",children:[a("terms.accept_prefix","I accept the")," ",c!==!1&&n(F,{label:a("terms.tos","Terms of Service"),document:c}),c!==!1&&d!==!1&&u(A,{children:[" ",a("terms.and","and")," "]}),d!==!1&&n(F,{label:a("terms.privacy","Privacy Policy"),document:d})]})})]}),n(g,{id:s,message:f})]})}function X(){const{t}=p("auth"),e=b();if(!e.error)return null;const a=e.unconfirmedEmail;return u(h,{gap:"tight",children:[n(E,{variant:P.ERROR,description:e.error}),a&&n(w,{type:"button",variant:y.LINK,onClick:()=>{e.resendVerification(a)},children:t("signup.resend_verification","Resend verification email")})]})}function Z({children:t}){const{t:e}=p("auth"),a=b(),i=a.mode==="signup"?e("actions.sign_up_submit","Sign Up"):a.mode==="reset"?e("forgotPassword.submit","Send reset link"):e("actions.sign_in_submit","Sign In");return n(w,{type:"submit",variant:y.PRIMARY,fullWidth:!0,loading:a.busy,disabled:!a.ready||a.blocked,children:t??i})}export{q as AuthConfirmPasswordField,Q as AuthConsentField,H as AuthEmailField,j as AuthForm,X as AuthFormAlerts,K as AuthPasswordField,G as AuthRememberMeField,Z as AuthSubmitButton};
|