@donotdev/auth 0.0.22 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +3 -3
- package/dist/AuthStore.d.ts +1 -1
- package/dist/AuthStore.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.d.ts +3 -3
- package/dist/components/AuthFallback.js +1 -1
- package/dist/components/AuthPartnerButton.d.ts +1 -1
- package/dist/components/AuthPartnerButton.js +2 -2
- package/dist/components/DeleteAccountDialogs.d.ts +4 -4
- package/dist/components/DeleteAccountDialogs.js +1 -1
- package/dist/components/EmailLinkForm.d.ts +1 -1
- package/dist/components/EmailLinkForm.js +1 -1
- package/dist/components/EmailPasswordForm.d.ts +11 -4
- package/dist/components/EmailPasswordForm.d.ts.map +1 -1
- package/dist/components/EmailPasswordForm.js +2 -1
- package/dist/components/EmailVerification.d.ts +1 -1
- package/dist/components/EmailVerification.js +1 -1
- package/dist/components/Feature.d.ts +6 -6
- package/dist/components/Feature.js +1 -1
- package/dist/components/FeatureGuard.d.ts +3 -3
- package/dist/components/FeatureGuard.js +1 -1
- package/dist/components/FeaturePlaceholder.d.ts +3 -3
- package/dist/components/FeaturePlaceholder.js +1 -1
- package/dist/components/GoogleOneTap.d.ts +1 -1
- package/dist/components/GoogleOneTap.js +1 -1
- package/dist/components/LoginModal.js +1 -1
- package/dist/components/MultipleAuthProviders.d.ts +1 -1
- package/dist/components/MultipleAuthProviders.js +1 -1
- package/dist/components/NetworkStatusIndicator.d.ts +1 -1
- package/dist/components/NetworkStatusIndicator.js +1 -1
- package/dist/components/PasswordResetCallback.d.ts +12 -0
- package/dist/components/PasswordResetCallback.d.ts.map +1 -0
- package/dist/components/PasswordResetCallback.js +2 -0
- package/dist/components/PasswordStrengthIndicator.d.ts +1 -1
- package/dist/components/PasswordStrengthIndicator.js +1 -1
- package/dist/components/PasswordUpdateDialog.d.ts +1 -1
- package/dist/components/PasswordUpdateDialog.js +1 -1
- package/dist/components/RateLimitAlert.d.ts +1 -1
- package/dist/components/RateLimitAlert.js +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/constants.d.ts +42 -20
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/hooks/useAccountLinking.d.ts +1 -1
- package/dist/hooks/useAccountLinking.js +1 -1
- package/dist/hooks/useAuthMethodToggle.d.ts +1 -1
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.d.ts +1 -1
- package/dist/hooks/useAuthPartner.js +1 -1
- package/dist/hooks/useDeleteAccount.d.ts +2 -2
- package/dist/hooks/useDeleteAccount.js +1 -1
- package/dist/hooks/useEmailLinkAuth.d.ts +1 -1
- package/dist/hooks/useEmailLinkAuth.js +1 -1
- package/dist/hooks/useEmailLinkForm.d.ts +3 -3
- package/dist/hooks/useEmailLinkForm.js +1 -1
- package/dist/hooks/useFedCM.js +1 -1
- package/dist/hooks/useGoogleOneTap.js +1 -1
- package/dist/hooks/useNetworkStatus.d.ts +1 -1
- package/dist/hooks/useNetworkStatus.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/symbol-index.json +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useAuth.d.ts +1 -1
- package/dist/useAuth.d.ts.map +1 -1
- package/dist/useAuth.js +1 -1
- package/package.json +5 -5
package/LICENSE.md
CHANGED
|
@@ -8,7 +8,7 @@ Copyright © 2025 Ambroise Park Consulting. All rights reserved.
|
|
|
8
8
|
|
|
9
9
|
## 1. DEFINITIONS
|
|
10
10
|
|
|
11
|
-
**1.1 "Framework"** means the DoNotDev commercial software packages (excluding @donotdev/cli and @donotdev/
|
|
11
|
+
**1.1 "Framework"** means the DoNotDev commercial software packages (excluding @donotdev/cli, @donotdev/components, @donotdev/expo, and @donotdev/templates, which are licensed under MIT), including all compiled JavaScript files, TypeScript definition files, and associated documentation.
|
|
12
12
|
|
|
13
13
|
**1.2 "License Key"** means the unique alphanumeric key provided to you upon purchase, required to suppress watermarks and unlock full Framework functionality.
|
|
14
14
|
|
|
@@ -231,12 +231,12 @@ Ambroise Park Consulting has no obligation to provide support, updates, or maint
|
|
|
231
231
|
|
|
232
232
|
Questions about licensing or compliance:
|
|
233
233
|
|
|
234
|
-
**Email:**
|
|
234
|
+
**Email:** contact@donotdev.com
|
|
235
235
|
**Website:** donotdev.com
|
|
236
236
|
|
|
237
237
|
---
|
|
238
238
|
|
|
239
239
|
**END OF LICENSE AGREEMENT**
|
|
240
240
|
|
|
241
|
-
**DoNotDev Framework License
|
|
241
|
+
**DoNotDev Framework License v1.0**
|
|
242
242
|
Ambroise Park Consulting – 2025
|
package/dist/AuthStore.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @description Zustand store for auth state. Single source of truth with unified FeatureStatus.
|
|
4
4
|
* Uses status enum ('initializing' | 'ready' | 'degraded' | 'error') for lifecycle management.
|
|
5
5
|
*
|
|
6
|
-
* @version 0.0
|
|
6
|
+
* @version 0.1.0
|
|
7
7
|
* @since 0.0.1
|
|
8
8
|
* @author AMBROISE PARK Consulting
|
|
9
9
|
*/
|
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;
|
|
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,iIAgMvB,CAAC"}
|
package/dist/AuthStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as i,FEATURE_STATUS as
|
|
1
|
+
import{createDoNotDevStore as i,FEATURE_STATUS as u}from"@donotdev/core";import{PARTNER_STATE as l}from"./constants";const o={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:u.INITIALIZING},S=i({name:"auth-store",createStore:(t,a)=>({...o,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]||l.IDLE,clearAllPartnerStates:()=>t(r=>({partnerStates:Object.keys(r.partnerStates).reduce((e,s)=>(e[s]=l.IDLE,e),{}),partnerError:null})),setAuthenticated:(r,e,s)=>{t({user:r,authenticated:!0,userId:r.id,loading:!1,error:null,status:u.READY,userSubscription:e,userProfile:s})},setUnauthenticated:()=>{t({user:null,authenticated:!1,userId:null,loading:!1,error:null,status:u.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(o)})});export{S as useAuthStore};
|
package/dist/authHelpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isClient as e}from"@donotdev/core";import{useAuthStore as t}from"./AuthStore";function
|
|
1
|
+
import{isClient as e}from"@donotdev/core";import{useAuthStore as t}from"./AuthStore";function i(){return t.getState()}function n(r){return e()?t.subscribe(r):()=>{}}export{i as getAuthState,n as subscribeToAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as
|
|
1
|
+
"use client";import{jsx as i,jsxs as s}from"react/jsx-runtime";import{Suspense as w,lazy as I}from"react";import{Alert as k,ALERT_VARIANT as p,Button as c,BUTTON_VARIANT as a,Stack as r}from"@donotdev/components";import{useTranslation as T,safeSessionStorage as f,handleError as x,isDev as l}from"@donotdev/core";import{EmailLinkForm as y}from"./EmailLinkForm";import E from"./EmailPasswordForm";import{useAccountLinking as S}from"../hooks/useAccountLinking";const $=({className:o="",id:d})=>{const{t:e}=T("auth"),{isRequired:v,email:u,existingProvider:n,newProvider:m,handleSignInWithExistingProvider:L}=S();if(!v)return null;if(n==="password"||n==="emailLink"){l();const t=()=>{f.removeItem("accountLinkingInfo")},g=()=>{l()},h=A=>{x(A)};return i("div",{className:o,id:d,children:i(k,{variant:p.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:s(r,{children:[i("p",{children:e("accountLinking.message",`An account with email ${u} already exists with ${n==="password"?"email/password":"email link"}. To link your ${m} 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(E,{mode:"signin",onSuccess:g,onError:h})}):i("div",{style:{marginTop:"var(--gap-md)"},children:i(y,{onSuccess:g,onError:h})}),i(r,{direction:"row",justify:"end",children:i(c,{onClick:t,variant:a.GHOST,children:e("accountLinking.dismiss","Dismiss")})})]})})})}else{l();const t=()=>{f.removeItem("accountLinkingInfo")};return i("div",{className:o,id:d,children:i(k,{variant:p.WARNING,role:"alert","aria-live":"polite",title:e("accountLinking.title","Account Linking Required"),description:s(r,{children:[i("p",{children:e("accountLinking.message",`An account with email ${u} already exists with ${n}. To link your ${m} account, please sign in with ${n} first.`)}),s(r,{direction:"row",children:[i(c,{onClick:L,variant:a.PRIMARY,children:e("accountLinking.signInWith",`Sign in with ${n}`)}),i(c,{onClick:t,variant:a.GHOST,children:e("accountLinking.dismiss","Dismiss")})]})]})})})}},R=I(()=>Promise.resolve({default:$}));function N(o){return i(w,{fallback:null,children:i(R,{...o})})}var _=N;export{_ as default};
|
|
@@ -11,7 +11,7 @@ interface AuthFallbackProps {
|
|
|
11
11
|
* Graceful fallback component when auth is not available
|
|
12
12
|
* Prevents app crashes and provides clear feedback to users
|
|
13
13
|
*
|
|
14
|
-
* @version 0.0
|
|
14
|
+
* @version 0.1.0
|
|
15
15
|
* @since 0.0.1
|
|
16
16
|
* @author AMBROISE PARK Consulting
|
|
17
17
|
*/
|
|
@@ -20,7 +20,7 @@ export declare function AuthFallback({ message, showLoginButton, className, }: A
|
|
|
20
20
|
* Higher-order component that wraps auth components
|
|
21
21
|
* Automatically shows AuthFallback when auth is not available
|
|
22
22
|
*
|
|
23
|
-
* @version 0.0
|
|
23
|
+
* @version 0.1.0
|
|
24
24
|
* @since 0.0.1
|
|
25
25
|
* @author AMBROISE PARK Consulting
|
|
26
26
|
* @param Component The auth component to wrap
|
|
@@ -34,7 +34,7 @@ export declare function withAuthFallback<P extends object>(Component: ComponentT
|
|
|
34
34
|
* @param fallbackProps Props to pass to AuthFallback
|
|
35
35
|
* @returns Object with component and fallback for conditional rendering
|
|
36
36
|
*
|
|
37
|
-
* @version 0.0
|
|
37
|
+
* @version 0.1.0
|
|
38
38
|
* @since 0.0.1
|
|
39
39
|
* @author AMBROISE PARK Consulting
|
|
40
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as a}from"react/jsx-runtime";import{FeatureFallback as
|
|
1
|
+
import{jsx as a}from"react/jsx-runtime";import{FeatureFallback as u,withFeatureFallback as r}from"@donotdev/components";import{isFeatureAvailable as n,FRAMEWORK_FEATURES as i}from"@donotdev/core";function l({message:t="Authentication is not available",showLoginButton:e=!1,className:o=""}){return a(u,{featureName:"Authentication",message:t,icon:"\u{1F512}",showActionButton:e,actionButtonText:"Sign In (Unavailable)",className:o,helpText:"This feature requires authentication to be configured."})}function A(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 m(t){return{isAuthAvailable:n(i.AUTH),AuthFallbackComponent:()=>a(l,{...t})}}export{l as AuthFallback,m as useAuthComponent,A as withAuthFallback};
|
|
@@ -10,7 +10,7 @@ interface AuthPartnerButtonComponentProps extends AuthPartnerButtonProps {
|
|
|
10
10
|
* Provides a unified button interface for authentication with various partners
|
|
11
11
|
* (Google, Facebook, etc.) and methods (OAuth, email/password, email link).
|
|
12
12
|
*
|
|
13
|
-
* @version 0.0
|
|
13
|
+
* @version 0.1.0
|
|
14
14
|
* @since 0.0.1
|
|
15
15
|
* @author AMBROISE PARK Consulting
|
|
16
16
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as i}from"react/jsx-runtime";import{useMemo as C,useState as D}from"react";if(typeof document<"u"&&!document.getElementById("auth-partner-button-styles")){const n=document.createElement("style");n.id="auth-partner-button-styles",n.textContent=`
|
|
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(
|
|
5
|
+
`,document.head.appendChild(n)}import{cn as R,DISPLAY as P,PROVIDER_ICONS as M,DefaultProviderIcon as U,Button as W,BUTTON_VARIANT as _,Spinner as $}from"@donotdev/components";import{AUTH_PARTNERS as j,useTranslation as F}from"@donotdev/core";import{EmailLinkForm as K}from"./EmailLinkForm";import V from"./EmailPasswordForm";import{getAuthMethod as A}from"../constants";import{useAuth as s}from"../useAuth";function H({partnerId:n,method:f,onSuccess:u,onError:l,className:c="",children:b,disabled:h=!1,display:g=P.AUTO,style:p,...Y}){const{t:a}=F("auth"),v=s("user"),S=s("signInWithPartner"),T=s("linkWithPartner"),E=s("isAvailable"),[r,k]=D(!1),o=C(()=>j[n],[n]);if(n==="password")return i("div",{className:c,children:i(V,{mode:"signin",onSuccess:()=>u?.(null),onError:l,compact:!0})});if(n==="emailLink")return i("div",{className:c,children:i(K,{onSuccess:()=>u?.(null),onError:l})});const L=C(()=>M[n]||U,[n]),w=o?.firebaseProviderId,d=!!v?.providerData?.some(t=>t.providerId===w),m=v&&!d,x=async()=>{if(!(r||h)){k(!0);try{let t;if(m)t=await T(n,A(f));else{const O=A(f);t=await S(n,O)}t&&u?.(t)}catch(t){l?.(t instanceof Error?t:new Error(String(t)))}finally{k(!1)}}},e=o?.name,I=()=>{if(b)return b;if(m)return r?a("buttons.linking",{partner:e}):d?a("buttons.linked",{partner:e}):a("buttons.link",{partner:e});if(r)return a("buttons.signingIn",{partner:e});const t=o?.button?.textKey;return t?a(t):`Sign in with ${e}`},B=h||r||!E||m&&d||!1,y=o?.button?{backgroundColor:o.button.backgroundColor,color:o.button.textColor,borderColor:o.button.borderColor,"--partner-hover-bg":o.button.hoverBackgroundColor}:void 0,N=p?{...y,...p}:y;return i(W,{variant:_.OUTLINE,onClick:x,disabled:B,"aria-busy":r,display:g,"aria-label":r?`Signing in with ${e}...`:`Sign in with ${e}`,tooltip:void 0,style:N,className:R(o?.button&&"auth-partner-button-custom",c),icon:r?i($,{"aria-label":"Loading"}):L,children:g!==P.COMPACT&&I()})}var nt=H;export{nt as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Re-authentication dialog props
|
|
3
3
|
*
|
|
4
|
-
* @version 0.0
|
|
4
|
+
* @version 0.1.0
|
|
5
5
|
* @since 0.0.1
|
|
6
6
|
* @author AMBROISE PARK Consulting
|
|
7
7
|
*/
|
|
@@ -33,7 +33,7 @@ export interface ReauthDialogProps {
|
|
|
33
33
|
* />
|
|
34
34
|
* ```
|
|
35
35
|
*
|
|
36
|
-
* @version 0.0
|
|
36
|
+
* @version 0.1.0
|
|
37
37
|
* @since 0.0.1
|
|
38
38
|
* @author AMBROISE PARK Consulting
|
|
39
39
|
*/
|
|
@@ -41,7 +41,7 @@ export declare function ReauthDialog({ open, isLoading, error, onReauth, onCance
|
|
|
41
41
|
/**
|
|
42
42
|
* Confirmation dialog props
|
|
43
43
|
*
|
|
44
|
-
* @version 0.0
|
|
44
|
+
* @version 0.1.0
|
|
45
45
|
* @since 0.0.1
|
|
46
46
|
* @author AMBROISE PARK Consulting
|
|
47
47
|
*/
|
|
@@ -73,7 +73,7 @@ export interface ConfirmDeleteDialogProps {
|
|
|
73
73
|
* />
|
|
74
74
|
* ```
|
|
75
75
|
*
|
|
76
|
-
* @version 0.0
|
|
76
|
+
* @version 0.1.0
|
|
77
77
|
* @since 0.0.1
|
|
78
78
|
* @author AMBROISE PARK Consulting
|
|
79
79
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as t,jsxs as i,Fragment as p}from"react/jsx-runtime";import{Trash2 as y}from"lucide-react";import{useState as A}from"react";import{Dialog as b,Button as s,BUTTON_VARIANT as u,PasswordInput as x,Label as D,Checkbox as R,Alert as w,ALERT_VARIANT as v,Stack as a,Text as C,List as g}from"@donotdev/components";import{useTranslation as T}from"@donotdev/core";function F({open:h,isLoading:c,error:r,onReauth:m,onCancel:l}){const{t:e}=T("auth"),[o,f]=A(""),d=async()=>{await m(o)};return t(b,{open:h,onOpenChange:n=>!n&&l(),title:e("deleteAccount.reauth.title","Confirm Your Identity"),description:e("deleteAccount.reauth.description","For security, please re-enter your password to continue."),footer:i(p,{children:[t(s,{variant:u.OUTLINE,onClick:l,disabled:c,children:e("deleteAccount.reauth.cancel","Cancel")}),t(s,{variant:u.DEFAULT,onClick:d,disabled:c||!o,children:c?e("deleteAccount.reauth.verifying","Verifying..."):e("deleteAccount.reauth.continue","Continue")})]}),children:t("form",{onSubmit:n=>{n.preventDefault(),d()},children:i(a,{children:[t(x,{value:o,onChange:n=>f(n.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&&t(w,{variant:v.ERROR,description:r})]})})})}function P({open:h,isLoading:c,error:r,onConfirm:m,onCancel:l}){const{t:e}=T("auth"),[o,f]=A(!1),d=async()=>{o&&await m()};return t(b,{open:h,onOpenChange:n=>!n&&l(),"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:i(p,{children:[t(s,{variant:u.OUTLINE,onClick:l,disabled:c,children:e("deleteAccount.confirm.cancel","Cancel")}),t(s,{variant:u.DESTRUCTIVE,icon:y,onClick:d,disabled:c||!o,children:c?e("deleteAccount.confirm.deleting","Deleting..."):e("deleteAccount.confirm.delete","Delete My Account")})]}),children:i(a,{gap:"large",children:[i(a,{children:[t(C,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatDeleted","What will be deleted:")}),t(g,{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)")]})]}),i(a,{children:[t(C,{as:"h4",level:"h4",children:e("deleteAccount.confirm.whatKept","What will be kept (anonymized):")}),t(g,{items:[e("deleteAccount.confirm.billing","Billing history for tax/accounting purposes"),e("deleteAccount.confirm.invoices","Past invoices and transaction records")]})]}),i(a,{direction:"row",align:"start",children:[t(R,{id:"confirm-delete",checked:o,onCheckedChange:n=>f(n===!0)}),t(D,{htmlFor:"confirm-delete",children:e("deleteAccount.confirm.checkbox","I understand this action cannot be undone")})]}),r&&t(w,{variant:v.ERROR,description:r})]})})}export{P as ConfirmDeleteDialog,F as ReauthDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Mail as m,CheckCircle as E}from"lucide-react";import{Button as o,BUTTON_VARIANT as x,Input as N,Alert as S,ALERT_VARIANT as T,Spinner as b,Stack as n,Text as r}from"@donotdev/components";import{useTranslation as R}from"@donotdev/core";import{useEmailLinkForm as A}from"../hooks/useEmailLinkForm";function y({className:t="",onSuccess:c,onError:u,actionCodeSettings:h}){const{t:i}=R("auth"),{email:s,setEmail:k,isLoading:l,isSent:L,error:d,handleSendLink:p,handleResend:v,canSubmit:f}=A({onSuccess:c,onError:u,actionCodeSettings:h});return L?a(n,{className:t,children:[a(n,{align:"center",children:[e(E,{className:"dndev-size-touch"}),e(r,{as:"h3",level:"h3",children:i("emailLink.checkEmail","Check Your Email")}),e(r,{level:"small",variant:"muted",className:"dndev-text-center",children:i("emailLink.sentMessage",`We've sent a sign-in link to ${s}. Click the link in your email to complete sign-in.`)})]}),e(n,{direction:"row",justify:"center",children:e(o,{variant:x.OUTLINE,onClick:v,icon:m,iconEnd:!1,children:i("emailLink.resend","Resend Link")})})]}):e("form",{onSubmit:p,className:t,children:a(n,{children:[e(N,{type:"email",label:i("emailLink.emailLabel","Email Address"),value:s,onChange:g=>k(g.target.value),placeholder:i("emailLink.emailPlaceholder","Enter your email address"),required:!0,disabled:l,className:"dndev-w-full"}),d&&e(S,{variant:T.ERROR,description:d}),e(o,{type:"submit",disabled:!f,icon:l?e(b,{"aria-label":"Loading"}):m,iconEnd:!1,className:"dndev-w-full",children:l?i("emailLink.sending","Sending Link..."):i("emailLink.sendLink","Send Sign-In Link")}),e(r,{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 O=y;export{y as EmailLinkForm,O as default};
|
|
@@ -4,16 +4,23 @@ import type { EmailPasswordFormProps } from '../constants';
|
|
|
4
4
|
*
|
|
5
5
|
* Best-in-class email/password authentication form with:
|
|
6
6
|
* - Real-time validation with react-hook-form
|
|
7
|
-
* - Password strength indicator
|
|
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
|
|
8
13
|
* - Remember me persistence
|
|
9
14
|
* - Forgot password flow
|
|
10
|
-
* -
|
|
15
|
+
* - Resend verification email
|
|
16
|
+
* - Terms of Service / Privacy Policy consent (GDPR)
|
|
17
|
+
* - Sign in / Sign up mode switching with form reset
|
|
11
18
|
* - Full i18n support
|
|
12
19
|
* - Accessible with proper ARIA
|
|
13
20
|
*
|
|
14
21
|
* @component
|
|
15
|
-
* @version 0.0
|
|
22
|
+
* @version 0.2.0
|
|
16
23
|
*/
|
|
17
|
-
declare function EmailPasswordForm({ mode, onSuccess, onError, className, }: EmailPasswordFormProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, }: EmailPasswordFormProps): import("react/jsx-runtime").JSX.Element;
|
|
18
25
|
export default EmailPasswordForm;
|
|
19
26
|
//# 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,EAAY,MAAM,cAAc,CAAC;AAiKrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAc,EACd,GAAG,EACH,OAAO,EACP,YAAY,GACb,EAAE,sBAAsB,2CAqoBxB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as a,jsxs as
|
|
1
|
+
"use client";import{jsx as a,jsxs as i,Fragment as le}from"react/jsx-runtime";import{useCallback as V,useEffect as Ne,useRef as xe,useState as p}from"react";import{useForm as qe,Controller as B,useWatch as ce}from"react-hook-form";import{Alert as L,ALERT_VARIANT as T,Button as f,BUTTON_VARIANT as h,Checkbox as de,Dialog as ue,Input as Oe,Label as me,PasswordInput as pe,Stack as o,Text as v,cn as Ue}from"@donotdev/components";import{useTranslation as De,useAppConfig as We}from"@donotdev/core";import{useAuth as b}from"../useAuth";import{PasswordStrengthIndicator as Fe}from"./PasswordStrengthIndicator";const Ve=6e4,Be=5,je=3e4;function Ke(){const r=xe([]),[n,w]=p(null),g=V(()=>!!(n&&Date.now()<n),[n]),u=V(()=>{const l=Date.now();r.current=r.current.filter(y=>l-y<Ve),r.current.push(l),r.current.length>=Be&&(w(l+je),r.current=[])},[]);return Ne(()=>{if(!n)return;const l=n-Date.now();if(l<=0){w(null);return}const y=setTimeout(()=>w(null),l);return()=>clearTimeout(y)},[n]),{isRateLimited:g,recordAttempt:u,cooldownUntil:n}}async function He(r){try{const w=new TextEncoder().encode(r),g=await crypto.subtle.digest("SHA-1",w),l=Array.from(new Uint8Array(g)).map(k=>k.toString(16).padStart(2,"0")).join("").toUpperCase(),y=l.slice(0,5),e=l.slice(5),P=await fetch(`https://api.pwnedpasswords.com/range/${y}`,{headers:{"Add-Padding":"true"},credentials:"omit"});return P.ok?(await P.text()).split(`
|
|
2
|
+
`).some(k=>{const[N]=k.split(":");return N?.trim()===e}):!1}catch{return!1}}const $e=[{test:r=>r.includes("429")||r.includes("rate")||r.includes("too_many_requests"),key:"errors.rate_limit",fallback:"Too many attempts. Please wait a moment and try again."},{test:r=>r.includes("email_not_confirmed")||r.includes("email not confirmed")||r.includes("auth/unverified-email"),key:"errors.email_not_confirmed",fallback:"Please verify your email before signing in."},{test:r=>r.includes("invalid_credentials")||r.includes("invalid login credentials")||r.includes("invalid-credential")||r.includes("auth/wrong-password")||r.includes("auth/user-not-found")||r.includes("invalid")&&r.includes("credential"),key:"errors.invalid_credentials",fallback:"Invalid email or password."},{test:r=>r.includes("already")||r.includes("exists")||r.includes("user_already_exists")||r.includes("user already registered")||r.includes("auth/email-already-in-use"),key:"signup.check_email",fallback:"Check your email to confirm your account."},{test:r=>r.includes("weak_password")||r.includes("weak password")||r.includes("auth/weak-password"),key:"errors.weak_password",fallback:"Password is too weak. Please choose a stronger password."},{test:r=>r.includes("network")||r.includes("fetch"),key:"networkError",fallback:"Network error. Please check your connection and try again."}];function Ge(r,n){const g=(r instanceof Error?r.message:String(r)).toLowerCase();for(const u of $e)if(u.test(g))return n(u.key,u.fallback);return n("errorGeneric","Authentication failed. Please try again.")}function ze({mode:r="signin",onSuccess:n,onError:w,className:g="",tos:u,privacy:l,captchaToken:y}){const{t:e}=De("auth"),P=We("app"),j=b("signInWithEmail"),k=b("createUserWithEmail"),N=b("sendPasswordResetEmail"),fe=b("sendEmailVerification"),he=b("setRememberMe"),we=b("isAvailable"),ge=b("loading"),[x,ye]=p(r),m=x==="signup",[q,be]=p(!1),[K,O]=p(!1),[_,H]=p(!1),[$,U]=p(!1),[G,z]=p(!1),[ve,Z]=p(!1),[Pe,X]=p(!1),C=u!==void 0?u:P?.footer?.legalLinks?.find(t=>t.path.includes("terms"))?.path??"/legal/terms",S=l!==void 0?l:P?.footer?.legalLinks?.find(t=>t.path.includes("privacy"))?.path??"/legal/privacy",R=C!==!1,E=S!==!1,Y=R&&typeof C!="string",J=E&&typeof S!="string",Q=R&&typeof C=="string"?C:null,ee=E&&typeof S=="string"?S:null,{isRateLimited:D,recordAttempt:ke,cooldownUntil:re}=Ke(),{control:A,handleSubmit:_e,getValues:Ce,reset:te,formState:{errors:s,isSubmitting:Se},setError:W,clearErrors:ae}=qe({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),se=ce({control:A,name:"password"}),I=ce({control:A,name:"email"}),F=V(t=>{te({email:I||"",password:"",confirmPassword:""}),ae(),U(!1),O(!1),z(!1),ye(t)},[te,ae,I]),Re=async t=>{if(D()){W("root",{message:e("errors.rate_limit","Too many attempts. Please wait a moment and try again.")});return}ke();try{x==="signin"?(q!==void 0&&await he(q),await j(t.email,t.password),n?.(void 0)):(await k(t.email,t.password),U(!0),n?.(void 0))}catch(c){const Te=x==="signup",oe=c instanceof Error?c.message:String(c),M=oe.toLowerCase();if(Te&&(M.includes("already")||M.includes("exists")||M.includes("user_already_exists")||M.includes("auth/email-already-in-use"))){U(!0);return}const Me=Ge(c,e);W("root",{message:Me}),w?.(c instanceof Error?c:new Error(oe))}},Ee=async()=>{if(!I||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I)){W("email",{message:e("emailRequired","Email is required")});return}H(!0);try{await N(I)}catch{}finally{O(!0),H(!1)}},Ae=async()=>{try{await fe()}catch{}};if(!we)return a(o,{className:g,children:a(L,{variant:T.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Please accept cookies to enable authentication.")})});const d=ge||Se,ne=m&&(R||E),Ie=y!==void 0&&!y,Le=d||D()||Ie||ne&&!G,ie=re?Math.max(0,Math.ceil((re-Date.now())/1e3)):0;return a("form",{onSubmit:_e(Re),className:Ue("dndev-auth-form",g),noValidate:!0,children:i(o,{children:[s.root&&a(L,{variant:T.ERROR,description:s.root.message}),D()&&ie>0&&a(L,{variant:T.WARNING,description:e("errors.rate_limit_cooldown",`Too many attempts. Please wait ${ie} seconds.`)}),$&&i(o,{children:[a(L,{variant:T.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.")}),i(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[a(f,{type:"button",variant:h.GHOST,onClick:Ae,children:e("signup.resend_verification","Resend verification email")}),a(v,{as:"span",variant:"muted",children:"|"}),a(f,{type:"button",variant:h.LINK,onClick:()=>F("signin"),children:e("actions.sign_in_submit","Sign In")})]})]}),K&&i(o,{children:[a(L,{variant:T.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.")}),a(o,{align:"center",children:a(f,{type:"button",variant:h.LINK,onClick:()=>{O(!1)},children:e("back","Back")})})]}),!$&&!K&&i(o,{children:[a(B,{name:"email",control:A,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:t})=>i(o,{gap:"tight",children:[a(Oe,{...t,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),autoComplete:"email webauthn",disabled:d||_,"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&&a(v,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:s.email.message})]})}),a(B,{name:"password",control:A,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:m?{uppercase:t=>t?/[A-Z]/.test(t)?!0:e("passwordRequirement.uppercase","Password must contain at least one uppercase letter"):!0,lowercase:t=>t?/[a-z]/.test(t)?!0:e("passwordRequirement.lowercase","Password must contain at least one lowercase letter"):!0,number:t=>t?/[0-9]/.test(t)?!0:e("passwordRequirement.number","Password must contain at least one number"):!0,special:t=>t?/[^a-zA-Z0-9]/.test(t)?!0:e("passwordRequirement.special","Password must contain at least one special character"):!0,breached:async t=>!t||t.length<8?!0:await He(t)?e("errors.breached_password","This password has appeared in a data breach. Please choose a different password."):!0}:void 0},render:({field:t})=>{const c=`password-${t.name}`;return i(o,{gap:"tight",children:[a(pe,{...t,id:c,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),autoComplete:m?"new-password":"current-password",disabled:d||_,"aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,className:"dndev-w-full","data-variant":s.password?"destructive":void 0}),s.password&&a(v,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:s.password.message})]})}}),m&&a(B,{name:"confirmPassword",control:A,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:t=>{const c=Ce("password");return t!==c?e("confirmPasswordMismatch","Passwords do not match"):!0}},render:({field:t})=>i(o,{gap:"tight",children:[a(pe,{...t,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:d,"aria-invalid":!!s.confirmPassword,"aria-describedby":s.confirmPassword?"confirm-password-error":void 0,className:"dndev-w-full","data-variant":s.confirmPassword?"destructive":void 0}),s.confirmPassword&&a(v,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:s.confirmPassword.message})]})}),m&&se&&a(Fe,{password:se,minLength:8,showRequirements:!0}),ne&&i(le,{children:[i(o,{direction:"row",gap:"tight",align:"start",children:[a(de,{id:"tos-accept",checked:G,onCheckedChange:t=>z(t===!0),disabled:d}),a(me,{htmlFor:"tos-accept",children:i(v,{as:"span",level:"caption",children:[e("terms.accept_prefix","I accept the")," ",R&&a(f,{type:"button",variant:h.LINK,onClick:()=>{Y?Z(!0):Q&&window.open(Q,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.tos","Terms of Service")}),R&&E&&i(le,{children:[" ",e("terms.and","and")," "]}),E&&a(f,{type:"button",variant:h.LINK,onClick:()=>{J?X(!0):ee&&window.open(ee,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.privacy","Privacy Policy")})]})})]}),Y&&a(ue,{open:ve,onOpenChange:Z,title:e("terms.tos","Terms of Service"),showClose:!0,children:C}),J&&a(ue,{open:Pe,onOpenChange:X,title:e("terms.privacy","Privacy Policy"),showClose:!0,children:S})]}),!m&&i(o,{direction:"row",gap:"tight",align:"center",children:[a(de,{id:"remember-me",checked:q,onCheckedChange:t=>be(t===!0),disabled:d||_}),a(me,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),a(f,{type:"submit",variant:h.PRIMARY,disabled:Le,fullWidth:!0,children:d?e("loading","Loading..."):m?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!m&&i(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[a(f,{type:"button",variant:h.LINK,disabled:d||_,onClick:Ee,children:_?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),a(v,{as:"span",variant:"muted",children:"|"}),a(f,{type:"button",variant:h.LINK,disabled:d,onClick:()=>F("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),m&&a(o,{align:"center",children:a(f,{type:"button",variant:h.LINK,disabled:d,onClick:()=>F("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})]})})}var tr=ze;export{tr as default};
|
|
@@ -5,7 +5,7 @@ import type { JSX } from 'react';
|
|
|
5
5
|
* Shows different states depending on verification status and provides verification button
|
|
6
6
|
* Uses @donotdev/ui components for styling.
|
|
7
7
|
*
|
|
8
|
-
* @version 0.0
|
|
8
|
+
* @version 0.1.0
|
|
9
9
|
* @since 0.0.1
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
* @example
|
|
@@ -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
|
|
1
|
+
"use client";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useId as h}from"react";import{Card as v,Button as y,BUTTON_VARIANT as I,Alert as A,Spinner as b,Stack as d,Text as x}from"@donotdev/components";import{useTranslation as M,handleError as T}from"@donotdev/core";import{useAuth as a}from"../useAuth";function j({verifyButtonText:E,successMessage:S,sendingMessage:w,alreadyVerifiedMessage:k,notSignedInMessage:B,errorMessage:R,id:c}){const{t:i}=M("auth"),n=a("user"),e=a("emailVerification"),u=a("sendEmailVerification"),s=n?.id,l=h(),t=c||`email-verification-${l}`,f=`${t}-heading`,m=`${t}-button`,g=async()=>{if(!(!n||!s))try{await u()}catch(V){T(V)}};if(!n||!s)return null;const p=()=>{if(e.status!=="pending"&&e.status==="error")return"error"};return r(v,{id:t,title:r("span",{id:f,children:i("emailVerification.title")}),children:o(d,{children:[o(d,{direction:"row",justify:"between",align:"center",children:[r(x,{level:"small",variant:"muted",children:i("emailVerification.status.unknown")}),r(y,{id:m,onClick:g,disabled:e.status==="pending","aria-busy":e.status==="pending",variant:I.PRIMARY,icon:e.status==="pending"?r(b,{"aria-label":"Loading"}):void 0,iconEnd:!1,children:e.status==="pending"?i("status.verifying"):i("buttons.verify","Verify")})]}),e.status!=="verified"&&r(A,{variant:p(),title:e.status==="error"?i("aria.errorAlert"):i("status.verifying"),description:e.status==="error"?("error"in e?e.error:void 0)||i("emailVerification.error","An error occurred"):i("emailVerification.sending","Sending verification email...")})]})})}var O=j;export{O as default};
|
|
@@ -8,7 +8,7 @@ interface BaseFeatureProps {
|
|
|
8
8
|
/**
|
|
9
9
|
* Feature ref interface
|
|
10
10
|
*
|
|
11
|
-
* @version 0.0
|
|
11
|
+
* @version 0.1.0
|
|
12
12
|
* @since 0.0.1
|
|
13
13
|
* @author AMBROISE PARK Consulting
|
|
14
14
|
*/
|
|
@@ -19,7 +19,7 @@ export interface FeatureRef {
|
|
|
19
19
|
/**
|
|
20
20
|
* Feature props interface
|
|
21
21
|
*
|
|
22
|
-
* @version 0.0
|
|
22
|
+
* @version 0.1.0
|
|
23
23
|
* @since 0.0.1
|
|
24
24
|
* @author AMBROISE PARK Consulting
|
|
25
25
|
*/
|
|
@@ -30,7 +30,7 @@ export interface FeatureProps extends BaseFeatureProps {
|
|
|
30
30
|
/**
|
|
31
31
|
* Tier feature props interface
|
|
32
32
|
*
|
|
33
|
-
* @version 0.0
|
|
33
|
+
* @version 0.1.0
|
|
34
34
|
* @since 0.0.1
|
|
35
35
|
* @author AMBROISE PARK Consulting
|
|
36
36
|
*/
|
|
@@ -41,7 +41,7 @@ export interface TierFeatureProps extends BaseFeatureProps {
|
|
|
41
41
|
/**
|
|
42
42
|
* Component that conditionally renders content based on subscription features
|
|
43
43
|
*
|
|
44
|
-
* @version 0.0
|
|
44
|
+
* @version 0.1.0
|
|
45
45
|
* @since 0.0.1
|
|
46
46
|
* @author AMBROISE PARK Consulting
|
|
47
47
|
*/
|
|
@@ -49,7 +49,7 @@ export declare const Feature: import("react").ForwardRefExoticComponent<FeatureP
|
|
|
49
49
|
/**
|
|
50
50
|
* Component that renders content only for users with Pro tier or higher
|
|
51
51
|
*
|
|
52
|
-
* @version 0.0
|
|
52
|
+
* @version 0.1.0
|
|
53
53
|
* @since 0.0.1
|
|
54
54
|
* @author AMBROISE PARK Consulting
|
|
55
55
|
*/
|
|
@@ -57,7 +57,7 @@ export declare const ProFeature: import("react").ForwardRefExoticComponent<Omit<
|
|
|
57
57
|
/**
|
|
58
58
|
* Component that renders content only for users with Premium tier
|
|
59
59
|
*
|
|
60
|
-
* @version 0.0
|
|
60
|
+
* @version 0.1.0
|
|
61
61
|
* @since 0.0.1
|
|
62
62
|
* @author AMBROISE PARK Consulting
|
|
63
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{Fragment as
|
|
1
|
+
"use client";import{Fragment as s,jsx as t}from"react/jsx-runtime";import{useImperativeHandle as m,forwardRef as u}from"react";import{hasTierAccess as f}from"@donotdev/core";import{useAuth as l}from"../useAuth";const S=u(({featureId:e,fallback:r=null,children:i},o)=>{const n=l("userSubscription")?.features?.includes(e)||!1;return m(o,()=>({enabled:n}),[n]),n?t(s,{children:i}):r?t(s,{children:r}):null}),a=u(({tier:e,fallback:r=null,children:i},o)=>{const p=l("userSubscription"),n=e||"pro",c=f(p?.tier,n);return m(o,()=>({enabled:c}),[c]),c?t(s,{children:i}):r?t(s,{children:r}):null}),g=u((e,r)=>t(a,{ref:r,tier:"pro",...e})),T=u((e,r)=>t(a,{ref:r,tier:"premium",...e}));export{S as Feature,T as PremiumFeature,g as ProFeature};
|
|
@@ -82,7 +82,7 @@ declare function SubscriptionExpired(): import("react/jsx-runtime").JSX.Element;
|
|
|
82
82
|
* @param props - FeatureGuard configuration
|
|
83
83
|
* @returns Protected component or fallback component
|
|
84
84
|
*
|
|
85
|
-
* @version 0.0
|
|
85
|
+
* @version 0.1.0
|
|
86
86
|
* @since 0.0.1
|
|
87
87
|
* @author AMBROISE PARK Consulting
|
|
88
88
|
*/
|
|
@@ -110,7 +110,7 @@ export declare function FeatureGuard({ children, role, tier, subscription, valid
|
|
|
110
110
|
* @param config - Feature access configuration
|
|
111
111
|
* @returns True if user can access the feature, false otherwise
|
|
112
112
|
*
|
|
113
|
-
* @version 0.0
|
|
113
|
+
* @version 0.1.0
|
|
114
114
|
* @since 0.0.1
|
|
115
115
|
* @author AMBROISE PARK Consulting
|
|
116
116
|
*/
|
|
@@ -143,7 +143,7 @@ export declare function useCanAccessFeature(config: {
|
|
|
143
143
|
* @param config - Feature access configuration
|
|
144
144
|
* @returns Wrapped component with feature protection
|
|
145
145
|
*
|
|
146
|
-
* @version 0.0
|
|
146
|
+
* @version 0.1.0
|
|
147
147
|
* @since 0.0.1
|
|
148
148
|
* @author AMBROISE PARK Consulting
|
|
149
149
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as r,jsxs as
|
|
1
|
+
"use client";import{jsx as r,jsxs as n,Fragment as z}from"react/jsx-runtime";import{Stack as p}from"@donotdev/components";import{hasRoleAccess as g,hasTierAccess as b}from"@donotdev/core";import{useAuth as a}from"../useAuth";import{AuthFallback as D}from"./AuthFallback";function R({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:n(p,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),n("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:e==="pro"?"Pro Feature":"Premium Feature"}),n("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",e," to access this feature",i&&` (current: ${i})`]})]})]})})}function v({requiredRole:e,userRole:i}){const s=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:n(p,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),n("div",{children:[r("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive-foreground)"},children:"Access Denied"}),n("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",s," role",i&&` (current: ${i})`]})]})]})})}function y(){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:n(p,{direction:"row",align:"center",children:[r("span",{style:{color:"var(--accent)"},children:"\u23F0"}),n("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 T({children:e,role:i,tier:s,subscription:o,validate:u,fallback:t,message:h,showUpgradePrompt:m=!0,showLoginPrompt:l=!0}){const A=a("user"),S=a("loading"),q=a("userProfile"),f=a("userSubscription"),d=q?.role,c=f?.tier;return S?r("div",{style:{height:"2rem",borderRadius:"var(--radius)",backgroundColor:"var(--muted)",animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}):!A&&(i||s||o)?l?r(D,{message:h||"Please sign in to access this feature"}):null:i&&!(Array.isArray(i)?i:[i]).some(x=>g(d,x))?t?r(t,{requiredRole:i,userRole:d||void 0}):r(v,{requiredRole:i,userRole:d||void 0}):s&&!b(c,s)?t?r(t,{requiredTier:s,userTier:c||"free"}):m?r(R,{requiredTier:s,userTier:c||"free"}):null:o&&!f?.isActive?t?r(t,{requiresSubscription:!0,hasSubscription:f?.isActive||!1}):r(y,{}):u&&!u(d,c)?t?r(t,{userRole:d,userTier:c}):r(v,{userRole:d}):r(z,{children:e})}function F(e){const i=a("user"),s=a("userProfile"),o=a("userSubscription"),u=s?.role,t=o?.tier;return!(!i&&(e.role||e.tier||e.subscription)||e.role&&!(Array.isArray(e.role)?e.role:[e.role]).some(l=>g(u,l))||e.tier&&!b(t,e.tier)||e.subscription&&!o?.isActive||e.validate&&u&&t&&!e.validate(u,t))}function G(e,i){return o=>r(T,{...i,children:r(e,{...o})})}export{v as AccessDenied,T as FeatureGuard,y as SubscriptionExpired,R as UpgradePrompt,F as useCanAccessFeature,G as withFeatureGuard};
|
|
@@ -35,7 +35,7 @@ interface TierPlaceholderProps {
|
|
|
35
35
|
* />
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @version 0.0
|
|
38
|
+
* @version 0.1.0
|
|
39
39
|
* @since 0.0.1
|
|
40
40
|
* @author AMBROISE PARK Consulting
|
|
41
41
|
*/
|
|
@@ -43,7 +43,7 @@ export declare function FeaturePlaceholder({ featureId, featureName, className,
|
|
|
43
43
|
/**
|
|
44
44
|
* Placeholder for Pro tier features
|
|
45
45
|
*
|
|
46
|
-
* @version 0.0
|
|
46
|
+
* @version 0.1.0
|
|
47
47
|
* @since 0.0.1
|
|
48
48
|
* @author AMBROISE PARK Consulting
|
|
49
49
|
*/
|
|
@@ -51,7 +51,7 @@ export declare const ProFeaturePlaceholder: ({ featureName, className, children,
|
|
|
51
51
|
/**
|
|
52
52
|
* Placeholder for Premium tier features
|
|
53
53
|
*
|
|
54
|
-
* @version 0.0
|
|
54
|
+
* @version 0.1.0
|
|
55
55
|
* @since 0.0.1
|
|
56
56
|
* @author AMBROISE PARK Consulting
|
|
57
57
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsxs as
|
|
1
|
+
"use client";import{jsxs as d,jsx as c}from"react/jsx-runtime";import{cn as i}from"@donotdev/components";import{hasTierAccess as p}from"@donotdev/core";import{useAuth as u}from"../useAuth";function x({featureId:e,featureName:r,className:o="",children:a}){if(u("userSubscription")?.features?.includes(e)||!1)return null;const t=c("div",{className:i("dndev-surface",o),"data-variant":"muted","data-shadow":"none","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px dashed var(--border)",backgroundColor:"var(--muted)"},children:d("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",textAlign:"center"},children:[r," is not available on your current plan."]})});return a||t}function l(e,r){return function({featureName:a,className:s="",children:n}){const t=u("userSubscription");if(p(t?.tier,e))return null;const m=c("div",{className:i("dndev-surface",s),"data-variant":"muted","data-shadow":"none","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px dashed var(--border)",backgroundColor:"var(--muted)"},children:d("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)",textAlign:"center"},children:[a," is only available on ",r," tier."]})});return n||m}}const P=l("pro","Pro"),A=l("premium","Premium");export{x as FeaturePlaceholder,A as PremiumFeaturePlaceholder,P as ProFeaturePlaceholder};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as N}from"react/jsx-runtime";import{Card as i,Spinner as j,Stack as w}from"@donotdev/components";import{useTranslation as z}from"@donotdev/core";import{useGoogleOneTap as C}from"../hooks/useGoogleOneTap";function T({clientId:s,onSuccess:p,onError:l,autoSelect:m=!0,cancelOnTapOutside:c=!0,className:g="",disabled:o=!1,promptParentId:f,allowedParentOrigins:r,cspNonce:h,clientOnly:a=!1,showErrorDetails:I=!1,loadingComponent:t,errorComponent:G,browserNotSupportedComponent:L}){const{t:u}=z("auth"),{shouldShow:v,isLoaded:E,isLoading:x,error:y,containerRef:S,fedcmSupported:n,isHydrated:d,browserInfo:_}=C({clientId:s,autoSelect:m,cancelOnTapOutside:c,promptParentId:f,disabled:o,onSuccess:p,onError:l,allowedParentOrigins:r,cspNonce:h,clientOnly:a});return o||!v||a&&!d?null:x?t?e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:e(t,{})})}):e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e(i,{style:{padding:"var(--gap-md)"},children:N(w,{direction:"row",align:"center",children:[e(j,{}),e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:u("googleOneTapLoading","Loading Google One Tap...")})]})})}):!n||y?null:e("div",{className:"dndev-fixed",style:{right:"var(--gap-md)",zIndex:50,top:"calc(1rem + var(--header-height, 0px))"},children:e("div",{ref:S,className:`google-one-tap-container ${g}`.trim(),"data-testid":"google-one-tap","data-fedcm-supported":n,"data-hydrated":d,...r&&{"data-allowed-parent-origins":r.join(",")}})})}var H=T;export{H as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t}from"react/jsx-runtime";import{Dialog as
|
|
1
|
+
"use client";import{jsx as t}from"react/jsx-runtime";import{Dialog as e}from"@donotdev/components";import{useTranslation as r}from"@donotdev/core";import{withAuthFallback as s}from"./AuthFallback";import a from"./MultipleAuthProviders";function l({open:n,onOpenChange:i}){const{t:o}=r("auth");return t(e,{open:n,onOpenChange:i,title:o("signIn","Sign In"),description:o("choosePlatform","Choose a platform to sign in with"),children:t(a,{layout:"vertical",showLabels:!0,method:"popup"})})}const u=s(l,{message:"Authentication is not configured",showLoginButton:!0});var g=u;export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as e,jsxs as I}from"react/jsx-runtime";import{Suspense as N,lazy as j,useId as E}from"react";import{Alert as M,ALERT_VARIANT as S,Stack as l,Grid as $}from"@donotdev/components";import{useTranslation as T,getEnabledAuthPartners as _}from"@donotdev/core";import{useAuth as u}from"../useAuth";import{withAuthFallback as q}from"./AuthFallback";import B from"./AuthPartnerButton";import{getAuthMethod as G}from"../constants";import{useAccountLinking as O}from"../hooks/useAccountLinking";const F=j(()=>import("./AccountLinking")),V=({providers:h,containerClassName:t="",providerClassName:p="",method:f,size:y="md",layout:r="vertical",showLabels:g=!0,spacing:o="medium",ariaLabel:A,id:v,fullWidth:b=!0,onSuccess:x})=>{const{t:s}=T("auth"),P=E(),a=v||P,{isRequired:R}=O(),c=u("error"),k=u("isAvailable"),w=G(f),n=h||_();if(!n||n.length===0)return e("div",{className:t,children:e("p",{children:"No authentication providers are configured"})});const z=()=>{const d=n.map((i,L)=>e(B,{partnerId:i,method:w,className:`${p} ${b?"dndev-w-full":""}`,tabIndex:L===0?0:void 0,id:`${a}-${i}-button`,onSuccess:x,children:g?void 0:null},i));return r==="grid"?e($,{cols:2,gap:o,className:t,children:d}):e(l,{direction:r==="horizontal"?"row":"column",wrap:r==="horizontal"?"wrap":void 0,gap:o,align:r==="horizontal"?"center":"stretch",className:t,children:d})};return I(l,{className:"dndev-mx-auto",id:a,role:"region","aria-label":A||s("aria.signInOptions","Sign in options"),children:[z(),c&&k&&e(M,{variant:S.ERROR,description:c.message||s("errorGeneric","Authentication failed. Please try again.")}),R&&e(N,{fallback:null,children:e(F,{})})]})},m=q(V,{message:"Authentication providers are not configured",showLoginButton:!0});var Z=m;export{m as MultipleAuthProviders,Z as default};
|
|
@@ -3,7 +3,7 @@ import type { NetworkStatusIndicatorProps } from '../constants';
|
|
|
3
3
|
* Component to show network status with reconnection guidance
|
|
4
4
|
* Displays an alert when the user is offline or optionally when online
|
|
5
5
|
*
|
|
6
|
-
* @version 0.0
|
|
6
|
+
* @version 0.1.0
|
|
7
7
|
* @since 0.0.1
|
|
8
8
|
* @author AMBROISE PARK Consulting
|
|
9
9
|
* @param {NetworkStatusIndicatorProps} props - Component props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as t,jsxs as r}from"react/jsx-runtime";import{Alert as s,Button as l,BUTTON_VARIANT as u,Stack as c}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";import{useNetworkStatus as d}from"../hooks/useNetworkStatus";function
|
|
1
|
+
"use client";import{jsx as t,jsxs as r}from"react/jsx-runtime";import{Alert as s,Button as l,BUTTON_VARIANT as u,Stack as c}from"@donotdev/components";import{useTranslation as f}from"@donotdev/core";import{useNetworkStatus as d}from"../hooks/useNetworkStatus";function k({showWhenOnline:i=!1,className:a=""}){const{t:e}=f("auth"),{online:n,connectionType:o,isSlowConnection:w}=d();return n&&!i?null:t(s,{variant:n?void 0:"error",className:a,role:"status","aria-live":n?"polite":"assertive",title:n?e("networkStatus.online",{defaultValue:"You are online"}):e("networkStatus.offline",{defaultValue:"You are offline"}),description:n?t("span",{children:e("networkStatus.connectedVia",{connectionType:o||"unknown",defaultValue:`Connected via ${o||"unknown"}`})}):r(c,{children:[t("p",{children:e("networkStatus.offlineMessage",{defaultValue:"Authentication requires an internet connection. Please check your network settings."})}),t(l,{variant:u.GHOST,onClick:()=>{typeof window<"u"&&window.location.reload()},style:{fontSize:"var(--font-size-sm)",textDecoration:"underline",fontWeight:500},children:e("networkStatus.checkAgain",{defaultValue:"Check again"})})]})})}var T=k;export{T as default};
|