@donotdev/auth 0.3.2 → 0.3.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/README.md +6 -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.js +1 -1
- package/dist/components/DeleteAccountDialogs.js +1 -1
- package/dist/components/EmailLinkForm.js +1 -1
- package/dist/components/EmailPasswordForm.d.ts +4 -2
- package/dist/components/EmailPasswordForm.d.ts.map +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.d.ts +3 -3
- package/dist/components/LoginModal.js +1 -1
- package/dist/components/MultipleAuthProviders.js +1 -1
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/emailAuth/fields.d.ts +65 -2
- package/dist/emailAuth/fields.d.ts.map +1 -1
- package/dist/emailAuth/fields.js +1 -1
- package/dist/emailAuth/flows.d.ts +182 -15
- package/dist/emailAuth/flows.d.ts.map +1 -1
- package/dist/emailAuth/flows.js +1 -1
- package/dist/emailAuth/rules.d.ts +33 -4
- package/dist/emailAuth/rules.d.ts.map +1 -1
- package/dist/emailAuth/rules.js +2 -2
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.js +1 -1
- package/dist/hooks/useAuthUsers.d.ts +34 -0
- package/dist/hooks/useAuthUsers.d.ts.map +1 -0
- package/dist/hooks/useAuthUsers.js +1 -0
- package/dist/hooks/useDeleteAccount.js +1 -1
- package/dist/hooks/useEmailLinkForm.js +1 -1
- package/dist/hooks/useGoogleOneTap.js +1 -1
- package/dist/index.d.ts +9 -5
- 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 +66 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -63,7 +63,12 @@ TypeScript autocomplete shows you everything available.
|
|
|
63
63
|
- **`signInWithPartner(partnerId, method?)`** - OAuth sign in
|
|
64
64
|
- **`signOut()`** - Sign out
|
|
65
65
|
- **`sendPasswordResetEmail(email)`** - Reset password
|
|
66
|
-
- **`sendEmailVerification()`** -
|
|
66
|
+
- **`sendEmailVerification(email?)`** - Send (again) the confirmation email or code
|
|
67
|
+
- **`verifyEmailCode(email, code)`** - Confirm a sign-up address with the emailed code; signs the user in (providers implementing it: Supabase)
|
|
68
|
+
|
|
69
|
+
**Admin:**
|
|
70
|
+
|
|
71
|
+
- **`listUsers()`** - Every auth account (`AuthUserSummary[]`); needs the admin-only `listAuthUsers` server function deployed (Supabase, Firebase). `useAuthUsers()` wraps it: `{ users, loading, error, reload }`
|
|
67
72
|
|
|
68
73
|
**Security (Firebase-verified):**
|
|
69
74
|
|
package/dist/AuthStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as c,FEATURE_STATUS as l,syncQueryCacheIdentity as o}from"@donotdev/core";import{PARTNER_STATE as
|
|
1
|
+
import{createDoNotDevStore as c,FEATURE_STATUS as l,syncQueryCacheIdentity as o}from"@donotdev/core";import{PARTNER_STATE as n}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:e=>{t({status:e})},setPartnerState:(e,r,s)=>{t(u=>({partnerStates:{...u.partnerStates,[e]:r},partnerError:r==="error"&&s?{partnerId:e,error:s}:u.partnerError?.partnerId===e?null:u.partnerError}))},getPartnerState:e=>a().partnerStates[e]||n.IDLE,clearAllPartnerStates:()=>t(e=>({partnerStates:Object.keys(e.partnerStates).reduce((r,s)=>(r[s]=n.IDLE,r),{}),partnerError:null})),setAuthenticated:(e,r,s)=>{o(e.id),t({user:e,authenticated:!0,userId:e.id,loading:!1,error:null,status:l.READY,userSubscription:r,userProfile:s})},setUnauthenticated:()=>{o(null),t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:l.READY,userSubscription:null,userProfile:null})},setAuthLoading:e=>{t({loading:e})},setAuthError:e=>{t({error:e,loading:!1})},clearAuthError:()=>{t({error:null})},getCustomClaim:e=>a().getCustomClaimLocal(e),getCustomClaims:()=>a().getCustomClaimsLocal(),setAuthService:e=>t({authService:e}),getCustomClaimLocal:e=>{const r=a(),s=r.userProfile;return s?.claims&&typeof s.claims=="object"&&e in s.claims?s.claims[e]:s&&typeof s=="object"&&e in s?s[e]:r.user&&typeof r.user=="object"&&e in r.user?r.user[e]:null},getCustomClaimsLocal:()=>{const e=a(),r={};return e.userProfile?.claims&&Object.assign(r,e.userProfile.claims),Object.freeze({...r})},setPasswordResetPending:e=>t({passwordResetPending:e}),setEmailVerificationStatus:(e,r)=>t({emailVerification:{status:e,error:r}}),setUserProfile:e=>t({userProfile:e}),setUserSubscription:e=>t({userSubscription:e}),setLoading:e=>t({loading:e}),setError:e=>t({error:e}),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 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"),[o,y]=B(!1),n=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=n?.firebaseProviderId,c=!!g?.providerData?.some(t=>t.providerId===P),m=g&&!c,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}):c?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&&c||!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=v?{...C,...v}: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",d),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 c,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:o,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:c(f,{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=>p(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 x({open:h,isLoading:o,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:c(f,{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=>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 f}from"lucide-react";import{Button as c,BUTTON_VARIANT as N,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(f,{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:N.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: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: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};
|
|
@@ -3,7 +3,9 @@ import type { EmailPasswordFormProps } from '../constants';
|
|
|
3
3
|
* Email/password form with three views: sign in (remember me, forgot password),
|
|
4
4
|
* sign up (password policy + strength, breached-password check, confirmation,
|
|
5
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.
|
|
6
|
+
* still do arrives as a toast that stays until dismissed. With `confirmation="code"`,
|
|
7
|
+
* a sign-up (or a sign-in of an unconfirmed address) shows the code step instead, and
|
|
8
|
+
* `onSuccess` runs once the code signed the user in.
|
|
7
9
|
*
|
|
8
10
|
* @component
|
|
9
11
|
* @example
|
|
@@ -11,6 +13,6 @@ import type { EmailPasswordFormProps } from '../constants';
|
|
|
11
13
|
* <EmailPasswordForm onSuccess={() => setOpen(false)} />
|
|
12
14
|
* ```
|
|
13
15
|
*/
|
|
14
|
-
declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, }: EmailPasswordFormProps): import("react").JSX.Element;
|
|
16
|
+
declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, confirmation, }: EmailPasswordFormProps): import("react").JSX.Element;
|
|
15
17
|
export default EmailPasswordForm;
|
|
16
18
|
//# sourceMappingURL=EmailPasswordForm.d.ts.map
|
|
@@ -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":"AAsCA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAQ3D;;;;;;;;;;;;;GAaG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAS,EACT,GAAG,EACH,OAAO,EACP,YAAY,EACZ,YAAsB,GACvB,EAAE,sBAAsB,+BA0GxB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as i}from"react/jsx-runtime";import{useState as g}from"react";import{Button as L,BUTTON_VARIANT as R,Stack as r,Text as T}from"@donotdev/components";import{useTranslation as V}from"@donotdev/core";import{AuthCodeStep as _,AuthConfirmPasswordField as j,AuthConsentField as H,AuthEmailField as p,AuthForm as A,AuthFormAlerts as w,AuthPasswordField as F,AuthRememberMeField as M,AuthSubmitButton as v}from"../emailAuth/fields";import{AUTH_FIELD as U,useEmailSignIn as q,useEmailSignUp as D,usePasswordResetRequest as K}from"../emailAuth/flows";const O=c=>{const a=c.currentTarget.form?.elements.namedItem(U.EMAIL);return a instanceof HTMLInputElement?a.value:""};function z({mode:c="signin",onSuccess:a,onError:k,className:s,tos:y,privacy:C,captchaToken:I,confirmation:l="toast"}){const{t}=V("auth"),[S,N]=g(c),[u,E]=g(""),[m,d]=g(null),f={onSuccess:()=>a?.(void 0),onError:k,captchaToken:I},b=q({...f,confirmation:l,onCodeSent:d}),P=D({...f,confirmation:l,onSuccess:n=>{l==="code"&&n.awaitingConfirmation?d(n.email):a?.(void 0)}}),x=K(f);if(m!==null)return e(r,{className:s,children:e(_,{email:m,onSuccess:()=>a?.(void 0),onChangeEmail:()=>{E(m),d(null)}})});const B=n=>h=>{E(O(h)),N(n)},o=(n,h)=>e(L,{type:"button",variant:R.LINK,onClick:B(h),children:n});return S==="reset"?i(A,{flow:x,className:s,children:[e(T,{variant:"muted",children:t("forgotPassword.intro","Enter your email and we will send you a reset link.")}),e(p,{defaultValue:u}),e(w,{}),e(v,{}),e(r,{align:"center",children:o(t("back","Back"),"signin")})]},"reset"):S==="signup"?i(A,{flow:P,className:s,children:[e(p,{defaultValue:u}),e(F,{}),e(j,{}),e(H,{tos:y,privacy:C}),e(w,{}),e(v,{}),e(r,{align:"center",children:o(t("alreadyHaveAccount","Already have an account? Sign In"),"signin")})]},"signup"):i(A,{flow:b,className:s,children:[e(p,{defaultValue:u}),e(F,{}),e(M,{}),e(w,{}),e(v,{}),i(r,{direction:"row",gap:"tight",justify:"center",align:"center",children:[o(t("forgotPassword","Forgot password?"),"reset"),e(T,{as:"span",variant:"muted",children:"|"}),o(t("actions.sign_up_submit","Create account"),"signup")]})]},"signin")}var Z=z;export{Z 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 o,forwardRef as i}from"react";import{hasTierAccess as f}from"@donotdev/core";import{useAuth as c}from"../useAuth";const p=i(({featureId:r,fallback:e=null,children:l},n)=>{const s=c("userSubscription")?.features?.includes(r)||!1;return o(n,()=>({enabled:s}),[s]),s?a(t,{children:l}):e?a(t,{children:e}):null}),m=i(({tier:r,fallback:e=null,children:l},n)=>{const s=c("userSubscription"),d=r||"pro",u=f(s?.tier,d);return o(n,()=>({enabled:u}),[u]),u?a(t,{children:l}):e?a(t,{children:e}):null}),h=i((r,e)=>a(m,{ref:e,tier:"pro",...r})),b=i((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 s,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 T}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:s(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),s("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:r==="pro"?"Pro Feature":"Premium Feature"}),s("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 o=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:s(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),s("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive)"},children:"Access Denied"}),s("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",o," 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:s(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u23F0"}),s("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:o,subscription:u,validate:n,fallback:a,message:l,showUpgradePrompt:A=!0,showLoginPrompt:z=!0}){const S=t("user"),R=t("loading"),q=t("userProfile"),v=t("userSubscription"),d=q?.role,c=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||o||u)?z?e(T,{message:l||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(F=>h(d,F))?a?e(a,{requiredRole:i,userRole:d||void 0}):e(p,{requiredRole:i,userRole:d||void 0}):o&&!m(c,o)?a?e(a,{requiredTier:o,userTier:c||"free"}):A?e(g,{requiredTier:o,userTier:c||"free"}):null:u&&!v?.isActive?a?e(a,{requiresSubscription:!0,hasSubscription:v?.isActive||!1}):e(b,{}):n&&!n(d,c)?a?e(a,{userRole:d,userTier:c}):e(p,{userRole:d}):e(w,{children:r})}function P(r){const i=t("user"),o=t("userProfile"),u=t("userSubscription"),n=o?.role,a=u?.tier;return!(!i&&(r.role||r.tier||r.subscription)||r.role&&!(Array.isArray(r.role)?r.role:[r.role]).some(l=>h(n,l))||r.tier&&!m(a,r.tier)||r.subscription&&!u?.isActive||r.validate&&n&&a&&!r.validate(n,a))}function k(r,i){return o=>e(y,{...i,children:e(r,{...o})})}export{p as AccessDenied,y as FeatureGuard,b as SubscriptionExpired,g as UpgradePrompt,P as useCanAccessFeature,k as withFeatureGuard};
|
|
@@ -47,7 +47,7 @@ interface TierPlaceholderProps {
|
|
|
47
47
|
* @since 0.0.1
|
|
48
48
|
* @author AMBROISE PARK Consulting
|
|
49
49
|
*/
|
|
50
|
-
export declare function FeaturePlaceholder({ featureId, featureName, className, children, }: FeaturePlaceholderProps): string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
50
|
+
export declare function FeaturePlaceholder({ featureId, featureName, className, children, }: FeaturePlaceholderProps): string | number | bigint | true | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
|
|
51
51
|
/**
|
|
52
52
|
* Placeholder for Pro tier features
|
|
53
53
|
*
|
|
@@ -55,7 +55,7 @@ export declare function FeaturePlaceholder({ featureId, featureName, className,
|
|
|
55
55
|
* @since 0.0.1
|
|
56
56
|
* @author AMBROISE PARK Consulting
|
|
57
57
|
*/
|
|
58
|
-
export declare const ProFeaturePlaceholder: ({ featureName, className, children, }: TierPlaceholderProps) => string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
58
|
+
export declare const ProFeaturePlaceholder: ({ featureName, className, children, }: TierPlaceholderProps) => string | number | bigint | true | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
|
|
59
59
|
/**
|
|
60
60
|
* Placeholder for Premium tier features
|
|
61
61
|
*
|
|
@@ -63,6 +63,6 @@ export declare const ProFeaturePlaceholder: ({ featureName, className, children,
|
|
|
63
63
|
* @since 0.0.1
|
|
64
64
|
* @author AMBROISE PARK Consulting
|
|
65
65
|
*/
|
|
66
|
-
export declare const PremiumFeaturePlaceholder: ({ featureName, className, children, }: TierPlaceholderProps) => string | number | bigint | true | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> |
|
|
66
|
+
export declare const PremiumFeaturePlaceholder: ({ featureName, className, children, }: TierPlaceholderProps) => string | number | bigint | true | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null;
|
|
67
67
|
export {};
|
|
68
68
|
//# sourceMappingURL=FeaturePlaceholder.d.ts.map
|
|
@@ -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 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 k}from"react/jsx-runtime";import{Suspense as
|
|
1
|
+
"use client";import{jsx as a,jsxs as k}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 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=$(()=>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:b=!0,onSuccess:N})=>{const{t}=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:r,children:a("p",{children:"No authentication providers are configured"})});const I=()=>{const d=i.map((s,S)=>a(M,{partnerId:s,method:z,className:`${p} ${b?"dndev-w-full":""}`,tabIndex:S===0?0:void 0,id:`${n}-${s}-button`,onSuccess:N,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 k(c,{className:"dndev-mx-auto",id:n,role:"region","aria-label":v||t("aria.signInOptions","Sign in options"),children:[I(),l&&x&&a(E,{variant:P.ERROR,description:l.message||t("errorGeneric","Authentication failed. Please try again.")}),R&&a(L,{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};
|
package/dist/constants.d.ts
CHANGED
|
@@ -149,6 +149,15 @@ export interface EmailPasswordFormProps extends BaseComponentProps, AuthCallback
|
|
|
149
149
|
* and passing the token here. When provided, submit is blocked until token is truthy.
|
|
150
150
|
*/
|
|
151
151
|
captchaToken?: string;
|
|
152
|
+
/**
|
|
153
|
+
* How a sign-up (or a sign-in of an unconfirmed address) confirms the email
|
|
154
|
+
* (default `'toast'`: the "check your email" toast with Resend). `'code'`: the form
|
|
155
|
+
* shows `AuthCodeStep` (a 6-character emailed code), then calls `onSuccess` once
|
|
156
|
+
* signed in. Needs a provider with `verifyEmailCode` (Supabase) and a code email
|
|
157
|
+
* template.
|
|
158
|
+
* @default 'toast'
|
|
159
|
+
*/
|
|
160
|
+
confirmation?: 'toast' | 'code';
|
|
152
161
|
}
|
|
153
162
|
/**
|
|
154
163
|
* Props for account linking component
|
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,yBAA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,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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AuthUser } from '@donotdev/core';
|
|
3
|
+
import type { EmailAuthFlow, EmailCodeConfirmation } from './flows';
|
|
3
4
|
/** Props of {@link AuthForm}. */
|
|
4
5
|
export interface AuthFormProps {
|
|
5
6
|
/** The flow this form runs (`useEmailSignIn()`, `useEmailSignUp()`, ...) */
|
|
@@ -34,9 +35,24 @@ export interface AuthTextFieldProps {
|
|
|
34
35
|
* @returns The field
|
|
35
36
|
*/
|
|
36
37
|
export declare function AuthEmailField({ label, placeholder, defaultValue, }: AuthTextFieldProps): import("react").JSX.Element;
|
|
38
|
+
/** Props of {@link AuthNameField}. */
|
|
39
|
+
export interface AuthNameFieldProps extends AuthTextFieldProps {
|
|
40
|
+
/** Help text: an (i) after the label shows it on hover, focus or tap */
|
|
41
|
+
info?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Name field (`name="displayName"`, `autocomplete="name"`): the name the user wants in
|
|
45
|
+
* emails. Optional, never validated: sign-up stores it trimmed as the display name
|
|
46
|
+
* (metadata `full_name`) when filled, nothing when empty.
|
|
47
|
+
*
|
|
48
|
+
* @param props - AuthNameFieldProps
|
|
49
|
+
* @returns The field
|
|
50
|
+
*/
|
|
51
|
+
export declare function AuthNameField({ label, placeholder, defaultValue, info, }: AuthNameFieldProps): import("react").JSX.Element;
|
|
37
52
|
/**
|
|
38
53
|
* Password field. Sign-in: `current-password`. Sign-up: `new-password` and a strength
|
|
39
|
-
* meter with the policy requirements
|
|
54
|
+
* meter, with the policy requirements unless the flow's `passwordComposition` is
|
|
55
|
+
* `false`.
|
|
40
56
|
*
|
|
41
57
|
* @param props - AuthTextFieldProps
|
|
42
58
|
* @returns The field
|
|
@@ -105,4 +121,51 @@ export interface AuthSubmitButtonProps {
|
|
|
105
121
|
* @returns The button
|
|
106
122
|
*/
|
|
107
123
|
export declare function AuthSubmitButton({ children }: AuthSubmitButtonProps): import("react").JSX.Element;
|
|
124
|
+
/** Props of {@link AuthCodeField}. */
|
|
125
|
+
export interface AuthCodeFieldProps {
|
|
126
|
+
/** The code step (`useEmailCodeConfirmation(...)`) */
|
|
127
|
+
confirmation: EmailCodeConfirmation;
|
|
128
|
+
/** Label (default: translated "Confirmation code") */
|
|
129
|
+
label?: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The sign-up code step: one box per character (`autocomplete="one-time-code"`,
|
|
133
|
+
* paste of the whole code), submitted as soon as the last character is typed, the
|
|
134
|
+
* error under it, "A new code has been sent." under it after a resend (no toast), and
|
|
135
|
+
* a Resend button with its countdown; after a resend the code input has focus again.
|
|
136
|
+
* Render it outside the
|
|
137
|
+
* sign-up `AuthForm` (it is not a form field).
|
|
138
|
+
*
|
|
139
|
+
* @param props - AuthCodeFieldProps
|
|
140
|
+
* @returns The code field
|
|
141
|
+
*/
|
|
142
|
+
export declare function AuthCodeField({ confirmation, label }: AuthCodeFieldProps): import("react").JSX.Element;
|
|
143
|
+
/** Props of {@link AuthCodeStep}. */
|
|
144
|
+
export interface AuthCodeStepProps {
|
|
145
|
+
/** The address the code was sent to */
|
|
146
|
+
email: string;
|
|
147
|
+
/**
|
|
148
|
+
* Characters of the code: match the provider (Supabase: `mailer_otp_length`).
|
|
149
|
+
* @default 6
|
|
150
|
+
*/
|
|
151
|
+
length?: number;
|
|
152
|
+
/** Called with the signed-in user once the code is confirmed */
|
|
153
|
+
onSuccess?: (user: AuthUser) => void;
|
|
154
|
+
/** Shows a "Change address" link that calls this (back to the form) */
|
|
155
|
+
onChangeEmail?: () => void;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The whole code step of a `confirmation: 'code'` sign-up or sign-in: "Enter the code
|
|
159
|
+
* sent to {email}", the code field (auto-submit, error, inline "new code sent",
|
|
160
|
+
* Resend with countdown) and, with `onChangeEmail`, a "Change address" link. No toast.
|
|
161
|
+
*
|
|
162
|
+
* @param props - AuthCodeStepProps
|
|
163
|
+
* @returns The code step
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```tsx
|
|
167
|
+
* <AuthCodeStep email={email} onSuccess={next} onChangeEmail={() => setEmail(null)} />
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare function AuthCodeStep({ email, length, onSuccess, onChangeEmail, }: AuthCodeStepProps): import("react").JSX.Element;
|
|
108
171
|
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/emailAuth/fields.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file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AC;IAChB,gEAAgE;IAChE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrC,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,SAAS,EACT,aAAa,GACd,EAAE,iBAAiB,+BAmBnB"}
|
package/dist/emailAuth/fields.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as a,jsxs as f,Fragment as I}from"react/jsx-runtime";import{createContext as k,use as M,useId as p,useRef as D,useState as R}from"react";import{Alert as N,ALERT_VARIANT as E,Button as v,BUTTON_VARIANT as w,Checkbox as P,Dialog as O,Input as L,Label as K,PasswordInput as x,PinInput as j,Stack as m,Text as C,cn as B}from"@donotdev/components";import{useAppConfig as W,useTranslation as c}from"@donotdev/core";import{useAuth as $}from"../useAuth";import{PasswordStrengthIndicator as H}from"../components/PasswordStrengthIndicator";import{AUTH_FIELD as b,useEmailCodeConfirmation as U}from"./flows";const _=k(null);function h(){const e=M(_);if(!e)throw new Error("Auth fields must be rendered inside <AuthForm>");return e}function te({flow:e,children:n,className:t}){const{t:r}=c("auth");return e.unavailable?a(N,{variant:E.WARNING,title:r("unavailable.title","Authentication Unavailable"),description:r("unavailable.description","Sign-in is temporarily unavailable. Please try again later.")}):a(_,{value:e,children:a("form",{noValidate:!0,onSubmit:e.onSubmit,className:B("dndev-auth-form",t),children:a(m,{children:n})})})}function y({id:e,message:n}){return n?a(C,{as:"span",level:"caption",variant:"destructive",id:e,role:"alert",children:n}):null}function ne({label:e,placeholder:n,defaultValue:t}){const{t:r}=c("auth"),o=h(),i=p(),d=p(),s=o.fieldErrors.email;return f(m,{gap:"tight",children:[a(L,{id:i,name:b.EMAIL,type:"email",autoComplete:"username",label:e??r("email","Email"),placeholder:n??r("emailPlaceholder","Enter your email"),defaultValue:t,disabled:o.busy,"aria-invalid":!!s,"aria-describedby":s?d:void 0,"data-variant":s?"destructive":void 0,className:"dndev-w-full"}),a(y,{id:d,message:s})]})}function re({label:e,placeholder:n,defaultValue:t,info:r}){const{t:o}=c("auth"),i=h();return a(L,{name:b.DISPLAY_NAME,type:"text",autoComplete:"name",label:e??o("name","Name"),placeholder:n,defaultValue:t,info:r,disabled:i.busy,className:"dndev-w-full"})}function F(){const{t:e}=c("auth");return{show:e("passwordToggle.show",{defaultValue:"Show password"}),hide:e("passwordToggle.hide",{defaultValue:"Hide password"})}}function ae({label:e,placeholder:n}){const{t}=c("auth"),r=h(),o=p(),i=p(),[d,s]=R(""),l=r.mode==="signup",u=r.fieldErrors.password,g=F();return f(m,{gap:"tight",children:[a(x,{id:o,name:b.PASSWORD,autoComplete:l?"new-password":"current-password",revealAriaLabel:g,label:e??t("password","Password"),placeholder:n??t("passwordPlaceholder","Enter your password"),onInput:l?A=>s(A.target.value):void 0,disabled:r.busy,"aria-invalid":!!u,"aria-describedby":u?i:void 0,"data-variant":u?"destructive":void 0,className:"dndev-w-full"}),a(y,{id:i,message:u}),l&&d!==""&&a(H,{password:d,minLength:r.passwordMinLength,showRequirements:r.passwordComposition!==!1})]})}function oe({label:e,placeholder:n}){const{t}=c("auth"),r=h(),o=p(),i=p(),d=r.fieldErrors.confirmPassword,s=F();return f(m,{gap:"tight",children:[a(x,{id:o,name:b.CONFIRM_PASSWORD,autoComplete:"new-password",revealAriaLabel:s,label:e??t("confirmPassword","Confirm Password"),placeholder:n??t("confirmPasswordPlaceholder","Re-enter your password"),disabled:r.busy,"aria-invalid":!!d,"aria-describedby":d?i:void 0,"data-variant":d?"destructive":void 0,className:"dndev-w-full"}),a(y,{id:i,message:d})]})}function ie({label:e,defaultChecked:n=!0}){const{t}=c("auth"),r=h(),o=$("canRememberMe");return!r.ready||!o()?null:a(P,{name:b.REMEMBER_ME,defaultChecked:n,disabled:r.busy,label:e??t("rememberMe","Remember me")})}const Y={minHeight:"auto",padding:0,display:"inline"};function S({label:e,document:n}){const[t,r]=R(!1),o=typeof n=="string";return f(I,{children:[a(v,{type:"button",variant:w.LINK,onClick:()=>o?window.open(n,"_blank","noopener,noreferrer"):r(!0),className:"dndev-p-0 dndev-h-auto",style:Y,children:e}),!o&&a(O,{open:t,onOpenChange:r,title:e,showClose:!0,children:n})]})}function se({tos:e,privacy:n}){const{t}=c("auth"),r=h(),o=W("app"),i=p(),d=p(),s=(A,V)=>o?.footer?.legalLinks?.find(T=>T.path.includes(A))?.path??V,l=e===void 0?s("terms","/legal/terms"):e,u=n===void 0?s("privacy","/legal/privacy"):n;if(l===!1&&u===!1)return null;const g=r.fieldErrors.consent;return f(m,{gap:"tight",children:[f(m,{direction:"row",gap:"tight",align:"start",children:[a(P,{id:i,name:b.CONSENT,disabled:r.busy,"aria-invalid":!!g,"aria-describedby":g?d:void 0}),a(K,{htmlFor:i,children:f(C,{as:"span",level:"caption",children:[t("terms.accept_prefix","I accept the")," ",l!==!1&&a(S,{label:t("terms.tos","Terms of Service"),document:l}),l!==!1&&u!==!1&&f(I,{children:[" ",t("terms.and","and")," "]}),u!==!1&&a(S,{label:t("terms.privacy","Privacy Policy"),document:u})]})})]}),a(y,{id:d,message:g})]})}function de(){const{t:e}=c("auth"),n=h();if(!n.error)return null;const t=n.unconfirmedEmail;return f(m,{gap:"tight",children:[a(N,{variant:E.ERROR,description:n.error}),t&&a(v,{type:"button",variant:w.LINK,onClick:()=>{n.resendVerification(t)},children:e("signup.resend_verification","Resend verification email")})]})}function le({children:e}){const{t:n}=c("auth"),t=h(),r=t.mode==="signup"?n("actions.sign_up_submit","Create account"):t.mode==="reset"?n("forgotPassword.submit","Send reset link"):n("actions.sign_in_submit","Sign In");return a(v,{type:"submit",variant:w.PRIMARY,fullWidth:!0,loading:t.busy,disabled:!t.ready||t.blocked,children:e??r})}function q({confirmation:e,label:n}){const{t}=c("auth"),r=p(),o=D(null),{error:i,resent:d,resendIn:s}=e;return f(m,{gap:"tight",children:[a(j,{ref:o,value:e.code,onChange:e.setCode,onComplete:l=>{e.submit(l)},length:e.length,mask:!1,autoFocus:!0,label:n??t("codeConfirmation.label",{defaultValue:"Confirmation code"}),disabled:e.busy||!e.ready,digitAriaLabel:(l,u)=>t("codeConfirmation.digit",{defaultValue:`Digit ${l} of ${u}`,index:l,length:u}),"aria-invalid":!!i,"aria-describedby":i?r:void 0}),a(y,{id:r,message:i??void 0}),d&&a(C,{as:"span",level:"caption",variant:"success",role:"status",children:t("codeConfirmation.sent",{defaultValue:"A new code has been sent."})}),a(v,{type:"button",variant:w.LINK,loading:e.resending,disabled:s>0||!e.ready,onClick:()=>{e.resend().then(()=>o.current?.focus())},children:s>0?t("codeConfirmation.resend_in",{defaultValue:`Resend code in ${s} s`,seconds:s}):t("codeConfirmation.resend",{defaultValue:"Resend code"})})]})}function ue({email:e,length:n,onSuccess:t,onChangeEmail:r}){const{t:o}=c("auth"),i=U({email:e,length:n,onSuccess:t});return f(m,{children:[a(C,{variant:"muted",children:o("codeConfirmation.intro",{defaultValue:`Enter the code sent to ${e}`,email:e})}),a(q,{confirmation:i}),r&&a(v,{type:"button",variant:w.LINK,onClick:r,children:o("codeConfirmation.change_email",{defaultValue:"Change address"})})]})}export{q as AuthCodeField,ue as AuthCodeStep,oe as AuthConfirmPasswordField,se as AuthConsentField,ne as AuthEmailField,te as AuthForm,de as AuthFormAlerts,re as AuthNameField,ae as AuthPasswordField,ie as AuthRememberMeField,le as AuthSubmitButton};
|