@donotdev/auth 0.1.44 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AuthStore.js +1 -1
- package/dist/authHelpers.js +1 -1
- package/dist/components/AccountLinking.d.ts +1 -1
- package/dist/components/AccountLinking.d.ts.map +1 -1
- package/dist/components/AccountLinking.js +1 -1
- package/dist/components/AuthFallback.d.ts +11 -3
- package/dist/components/AuthFallback.d.ts.map +1 -1
- package/dist/components/AuthFallback.js +1 -1
- package/dist/components/AuthPartnerButton.d.ts +2 -2
- package/dist/components/AuthPartnerButton.d.ts.map +1 -1
- package/dist/components/AuthPartnerButton.js +1 -1
- package/dist/components/DeleteAccountDialogs.d.ts +2 -2
- package/dist/components/DeleteAccountDialogs.d.ts.map +1 -1
- package/dist/components/DeleteAccountDialogs.js +1 -1
- package/dist/components/EmailLinkForm.d.ts +1 -1
- package/dist/components/EmailLinkForm.d.ts.map +1 -1
- package/dist/components/EmailLinkForm.js +1 -1
- package/dist/components/EmailPasswordForm.d.ts +1 -1
- package/dist/components/EmailPasswordForm.d.ts.map +1 -1
- package/dist/components/EmailPasswordForm.js +2 -2
- package/dist/components/EmailVerification.d.ts +1 -1
- package/dist/components/EmailVerification.d.ts.map +1 -1
- package/dist/components/EmailVerification.js +1 -1
- package/dist/components/Feature.d.ts.map +1 -1
- package/dist/components/Feature.js +1 -1
- package/dist/components/FeatureGuard.d.ts +67 -6
- package/dist/components/FeatureGuard.d.ts.map +1 -1
- package/dist/components/FeatureGuard.js +1 -1
- package/dist/components/FeaturePlaceholder.d.ts +11 -3
- package/dist/components/FeaturePlaceholder.d.ts.map +1 -1
- package/dist/components/GoogleOneTap.d.ts +33 -1
- package/dist/components/GoogleOneTap.d.ts.map +1 -1
- package/dist/components/LoginModal.d.ts +1 -1
- package/dist/components/LoginModal.d.ts.map +1 -1
- package/dist/components/LoginModal.js +1 -1
- package/dist/components/MultipleAuthProviders.d.ts +1 -1
- package/dist/components/MultipleAuthProviders.d.ts.map +1 -1
- package/dist/components/MultipleAuthProviders.js +1 -1
- package/dist/components/NetworkStatusIndicator.d.ts +1 -1
- package/dist/components/NetworkStatusIndicator.d.ts.map +1 -1
- package/dist/components/PasswordResetCallback.d.ts +1 -1
- package/dist/components/PasswordResetCallback.d.ts.map +1 -1
- package/dist/components/PasswordResetCallback.js +1 -1
- package/dist/components/PasswordStrengthIndicator.d.ts +1 -1
- package/dist/components/PasswordStrengthIndicator.d.ts.map +1 -1
- package/dist/components/PasswordUpdateDialog.d.ts +1 -1
- package/dist/components/PasswordUpdateDialog.d.ts.map +1 -1
- package/dist/components/RateLimitAlert.d.ts +8 -0
- package/dist/components/RateLimitAlert.d.ts.map +1 -1
- package/dist/hooks/useAuthMethodToggle.js +1 -1
- package/dist/hooks/useAuthPartner.d.ts +1 -1
- package/dist/hooks/useAuthPartner.d.ts.map +1 -1
- package/dist/hooks/useAuthPartner.js +1 -1
- package/dist/hooks/useEmailLinkForm.js +1 -1
- package/dist/hooks/useGoogleOneTap.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 +281 -0
- package/package.json +9 -8
package/dist/AuthStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDoNotDevStore as i,FEATURE_STATUS as l}from"@donotdev/core";import{PARTNER_STATE as n}from"./constants";const
|
|
1
|
+
import{createDoNotDevStore as i,FEATURE_STATUS as l}from"@donotdev/core";import{PARTNER_STATE as n}from"./constants";const u={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},c=i({name:"auth-store",createStore:(t,a)=>({...u,setStatus:e=>{t({status:e})},setPartnerState:(e,r,s)=>{t(o=>({partnerStates:{...o.partnerStates,[e]:r},partnerError:r==="error"&&s?{partnerId:e,error:s}:o.partnerError?.partnerId===e?null:o.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)=>{t({user:e,authenticated:!0,userId:e.id,loading:!1,error:null,status:l.READY,userSubscription:r,userProfile:s})},setUnauthenticated:()=>{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(u)})});export{c as useAuthStore};
|
package/dist/authHelpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isClient as
|
|
1
|
+
import{isClient as r}from"@donotdev/core";import{useAuthStore as t}from"./AuthStore";function s(){return t.getState()}function u(e){return r()?t.subscribe(e):()=>{}}export{s as getAuthState,u as subscribeToAuth};
|
|
@@ -2,6 +2,6 @@ export interface AccountLinkingProps {
|
|
|
2
2
|
className?: string;
|
|
3
3
|
id?: string;
|
|
4
4
|
}
|
|
5
|
-
declare function AccountLinking(props: AccountLinkingProps): import("react
|
|
5
|
+
declare function AccountLinking(props: AccountLinkingProps): import("react").JSX.Element;
|
|
6
6
|
export default AccountLinking;
|
|
7
7
|
//# sourceMappingURL=AccountLinking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountLinking.d.ts","sourceRoot":"","sources":["../../src/components/AccountLinking.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AccountLinking.d.ts","sourceRoot":"","sources":["../../src/components/AccountLinking.tsx"],"names":[],"mappings":"AAiCA,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AA8JD,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,+BASjD;AAKD,eAAe,cAAc,CAAC"}
|
|
@@ -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,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Auth Fallback Component
|
|
3
|
+
* @description Graceful fallback when auth is not available or fails to load
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
1
9
|
import type { ComponentType } from 'react';
|
|
2
10
|
interface AuthFallbackProps {
|
|
3
11
|
/** Custom message to display */
|
|
@@ -15,7 +23,7 @@ interface AuthFallbackProps {
|
|
|
15
23
|
* @since 0.0.1
|
|
16
24
|
* @author AMBROISE PARK Consulting
|
|
17
25
|
*/
|
|
18
|
-
export declare function AuthFallback({ message, showLoginButton, className, }: AuthFallbackProps): import("react
|
|
26
|
+
export declare function AuthFallback({ message, showLoginButton, className, }: AuthFallbackProps): import("react").JSX.Element;
|
|
19
27
|
/**
|
|
20
28
|
* Higher-order component that wraps auth components
|
|
21
29
|
* Automatically shows AuthFallback when auth is not available
|
|
@@ -27,7 +35,7 @@ export declare function AuthFallback({ message, showLoginButton, className, }: A
|
|
|
27
35
|
* @param fallbackProps Props to pass to AuthFallback
|
|
28
36
|
* @returns Wrapped component that handles auth availability
|
|
29
37
|
*/
|
|
30
|
-
export declare function withAuthFallback<P extends object>(Component: ComponentType<P>, fallbackProps?: Omit<AuthFallbackProps, 'className'>): (props: P) => import("react
|
|
38
|
+
export declare function withAuthFallback<P extends object>(Component: ComponentType<P>, fallbackProps?: Omit<AuthFallbackProps, 'className'>): (props: P) => import("react").JSX.Element;
|
|
31
39
|
/**
|
|
32
40
|
* Hook that returns either the component or AuthFallback
|
|
33
41
|
*
|
|
@@ -40,7 +48,7 @@ export declare function withAuthFallback<P extends object>(Component: ComponentT
|
|
|
40
48
|
*/
|
|
41
49
|
export declare function useAuthComponent(fallbackProps?: Omit<AuthFallbackProps, 'className'>): {
|
|
42
50
|
isAuthAvailable: boolean;
|
|
43
|
-
AuthFallbackComponent: () => import("react
|
|
51
|
+
AuthFallbackComponent: () => import("react").JSX.Element;
|
|
44
52
|
};
|
|
45
53
|
export {};
|
|
46
54
|
//# sourceMappingURL=AuthFallback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthFallback.d.ts","sourceRoot":"","sources":["../../src/components/AuthFallback.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthFallback.d.ts","sourceRoot":"","sources":["../../src/components/AuthFallback.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAK3C,UAAU,iBAAiB;IACzB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAA2C,EAC3C,eAAuB,EACvB,SAAc,GACf,EAAE,iBAAiB,+BAYnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,aAAa,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,6CAcrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC;;;EAQrD"}
|
|
@@ -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};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type AuthPartnerButtonProps } from '../constants';
|
|
2
1
|
import type { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { type AuthPartnerButtonProps } from '../constants';
|
|
3
3
|
interface AuthPartnerButtonComponentProps extends AuthPartnerButtonProps {
|
|
4
4
|
onSuccess?: (result: any) => void;
|
|
5
5
|
onError?: (error: Error) => void;
|
|
@@ -14,6 +14,6 @@ interface AuthPartnerButtonComponentProps extends AuthPartnerButtonProps {
|
|
|
14
14
|
* @since 0.0.1
|
|
15
15
|
* @author AMBROISE PARK Consulting
|
|
16
16
|
*/
|
|
17
|
-
declare function AuthPartnerButton({ partnerId, method, onSuccess, onError, className, children, disabled, display, style, ...props }: AuthPartnerButtonComponentProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onError' | 'onSuccess'>): import("react
|
|
17
|
+
declare function AuthPartnerButton({ partnerId, method, onSuccess, onError, className, children, disabled, display, style, ...props }: AuthPartnerButtonComponentProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onError' | 'onSuccess'>): import("react").JSX.Element;
|
|
18
18
|
export default AuthPartnerButton;
|
|
19
19
|
//# sourceMappingURL=AuthPartnerButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthPartnerButton.d.ts","sourceRoot":"","sources":["../../src/components/AuthPartnerButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthPartnerButton.d.ts","sourceRoot":"","sources":["../../src/components/AuthPartnerButton.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,MAAM,OAAO,CAAC;AAejE,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,cAAc,CAAC;AAGtB,UAAU,+BAAgC,SAAQ,sBAAsB;IACtE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,MAAM,EACN,SAAS,EACT,OAAO,EACP,SAAc,EACd,QAAQ,EACR,QAAgB,EAChB,OAAsB,EACtB,KAAK,EACL,GAAG,KAAK,EACT,EAAE,+BAA+B,GAChC,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC,+BAyIvE;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
.dndev-interactive.auth-partner-button-custom[data-variant='outline']:hover {
|
|
3
3
|
background-color: var(--partner-hover-bg);
|
|
4
4
|
}
|
|
5
|
-
`,document.head.appendChild(r)}import{cn as D,DISPLAY as S,PROVIDER_ICONS as U,DefaultProviderIcon as M,Button as _,BUTTON_VARIANT as $,Spinner as V}from"@donotdev/components";import{AUTH_PARTNERS as W,useTranslation as j}from"@donotdev/core";import{EmailLinkForm as F}from"./EmailLinkForm";import H from"./EmailPasswordForm";import{getAuthMethod as k}from"../constants";import{useAuth as s}from"../useAuth";function K({partnerId:r,method:p,onSuccess:u,onError:l,className:
|
|
5
|
+
`,document.head.appendChild(r)}import{cn as D,DISPLAY as S,PROVIDER_ICONS as U,DefaultProviderIcon as M,Button as _,BUTTON_VARIANT as $,Spinner as V}from"@donotdev/components";import{AUTH_PARTNERS as W,useTranslation as j}from"@donotdev/core";import{EmailLinkForm as F}from"./EmailLinkForm";import H from"./EmailPasswordForm";import{getAuthMethod as k}from"../constants";import{useAuth as s}from"../useAuth";function K({partnerId:r,method:p,onSuccess:u,onError:l,className: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};
|
|
@@ -37,7 +37,7 @@ export interface ReauthDialogProps {
|
|
|
37
37
|
* @since 0.0.1
|
|
38
38
|
* @author AMBROISE PARK Consulting
|
|
39
39
|
*/
|
|
40
|
-
export declare function ReauthDialog({ open, isLoading, error, onReauth, onCancel, }: ReauthDialogProps): import("react
|
|
40
|
+
export declare function ReauthDialog({ open, isLoading, error, onReauth, onCancel, }: ReauthDialogProps): import("react").JSX.Element;
|
|
41
41
|
/**
|
|
42
42
|
* Confirmation dialog props
|
|
43
43
|
*
|
|
@@ -77,5 +77,5 @@ export interface ConfirmDeleteDialogProps {
|
|
|
77
77
|
* @since 0.0.1
|
|
78
78
|
* @author AMBROISE PARK Consulting
|
|
79
79
|
*/
|
|
80
|
-
export declare function ConfirmDeleteDialog({ open, isLoading, error, onConfirm, onCancel, }: ConfirmDeleteDialogProps): import("react
|
|
80
|
+
export declare function ConfirmDeleteDialog({ open, isLoading, error, onConfirm, onCancel, }: ConfirmDeleteDialogProps): import("react").JSX.Element;
|
|
81
81
|
//# sourceMappingURL=DeleteAccountDialogs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteAccountDialogs.d.ts","sourceRoot":"","sources":["../../src/components/DeleteAccountDialogs.tsx"],"names":[],"mappings":"AA+BA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,IAAI,EAAE,OAAO,CAAC;IAEd,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IAEnB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,gCAAgC;IAChC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C,qBAAqB;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,iBAAiB
|
|
1
|
+
{"version":3,"file":"DeleteAccountDialogs.d.ts","sourceRoot":"","sources":["../../src/components/DeleteAccountDialogs.tsx"],"names":[],"mappings":"AA+BA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,IAAI,EAAE,OAAO,CAAC;IAEd,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAC;IAEnB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,gCAAgC;IAChC,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C,qBAAqB;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,iBAAiB,+BA8DnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,6BAA6B;IAC7B,IAAI,EAAE,OAAO,CAAC;IAEd,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAC;IAEnB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/B,qBAAqB;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,GACT,EAAE,wBAAwB,+BAqG1B"}
|
|
@@ -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};
|
|
@@ -21,6 +21,6 @@ export interface EmailLinkFormProps {
|
|
|
21
21
|
* @since 0.0.1
|
|
22
22
|
* @author AMBROISE PARK Consulting
|
|
23
23
|
*/
|
|
24
|
-
export declare function EmailLinkForm({ className, onSuccess, onError, actionCodeSettings, }: EmailLinkFormProps): import("react
|
|
24
|
+
export declare function EmailLinkForm({ className, onSuccess, onError, actionCodeSettings, }: EmailLinkFormProps): import("react").JSX.Element;
|
|
25
25
|
export default EmailLinkForm;
|
|
26
26
|
//# sourceMappingURL=EmailLinkForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailLinkForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailLinkForm.tsx"],"names":[],"mappings":"AA4BA,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAc,EACd,SAAS,EACT,OAAO,EACP,kBAAkB,GACnB,EAAE,kBAAkB
|
|
1
|
+
{"version":3,"file":"EmailLinkForm.d.ts","sourceRoot":"","sources":["../../src/components/EmailLinkForm.tsx"],"names":[],"mappings":"AA4BA,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,kBAAkB,CAAC,EAAE;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,eAAe,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAC5B,SAAc,EACd,SAAS,EACT,OAAO,EACP,kBAAkB,GACnB,EAAE,kBAAkB,+BA0FpB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -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};
|
|
@@ -21,6 +21,6 @@ import type { EmailPasswordFormProps } from '../constants';
|
|
|
21
21
|
* @component
|
|
22
22
|
* @version 0.2.0
|
|
23
23
|
*/
|
|
24
|
-
declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, }: EmailPasswordFormProps): import("react
|
|
24
|
+
declare function EmailPasswordForm({ mode, onSuccess, onError, className, tos, privacy, captchaToken, }: EmailPasswordFormProps): import("react").JSX.Element;
|
|
25
25
|
export default EmailPasswordForm;
|
|
26
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":"AAqCA,OAAO,KAAK,EAAE,sBAAsB,EAAY,MAAM,cAAc,CAAC;AA8KrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,iBAAiB,CAAC,EACzB,IAAe,EACf,SAAS,EACT,OAAO,EACP,SAAc,EACd,GAAG,EACH,OAAO,EACP,YAAY,GACb,EAAE,sBAAsB,+BA2qBxB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as i,jsxs as n,Fragment as
|
|
2
|
-
`).some(e=>{const[N]=e.split(":");return N?.trim()===d}):!1}catch{return!1}}const Ge=[{test:a=>a.includes("429")||a.includes("rate")||a.includes("too_many_requests"),key:"errors.rate_limit",fallback:"Too many attempts. Please wait a moment and try again."},{test:a=>a.includes("email_not_confirmed")||a.includes("email not confirmed")||a.includes("auth/unverified-email"),key:"errors.email_not_confirmed",fallback:"Please verify your email before signing in."},{test:a=>a.includes("invalid_credentials")||a.includes("invalid login credentials")||a.includes("invalid-credential")||a.includes("auth/wrong-password")||a.includes("auth/user-not-found")||a.includes("invalid")&&a.includes("credential"),key:"errors.invalid_credentials",fallback:"Invalid email or password."},{test:a=>a.includes("already")||a.includes("exists")||a.includes("user_already_exists")||a.includes("user already registered")||a.includes("auth/email-already-in-use"),key:"signup.check_email",fallback:"Check your email to confirm your account."},{test:a=>a.includes("weak_password")||a.includes("weak password")||a.includes("auth/weak-password"),key:"errors.weak_password",fallback:"Password is too weak. Please choose a stronger password."},{test:a=>a.includes("network")||a.includes("fetch"),key:"networkError",fallback:"Network error. Please check your connection and try again."}];function Be(a,t){const m=(a instanceof Error?a.message:String(a)).toLowerCase();for(const l of Ge)if(l.test(m))return t(l.key,l.fallback);return t("errorGeneric","Authentication failed. Please try again.")}function ze({mode:a="signin",onSuccess:t,onError:m,className:l="",tos:y,privacy:d,captchaToken:p}){const{t:e}=De("auth"),N=Oe("app"),ue=v("signInWithEmail"),me=v("createUserWithEmail"),pe=v("sendPasswordResetEmail"),we=v("sendEmailVerification"),he=v("setRememberMe"),ge=v("isAvailable"),fe=v("loading"),[T,ve]=h(a),w=T==="signup",[q,ye]=h(!1),[j,x]=h(!1),[k,F]=h(!1),[H,U]=h(!1),[K,$]=h(!1),[be,G]=h(!1),[ke,B]=h(!1),P=y!==void 0?y:N?.footer?.legalLinks?.find(r=>r.path.includes("terms"))?.path??"/legal/terms",_=d!==void 0?d:N?.footer?.legalLinks?.find(r=>r.path.includes("privacy"))?.path??"/legal/privacy",C=P!==!1,S=_!==!1,z=C&&typeof P!="string",Z=S&&typeof _!="string",Y=C&&typeof P=="string"?P:null,J=S&&typeof _=="string"?_:null,{isRateLimited:M,recordAttempt:Pe,cooldownUntil:Q}=He(),{control:R,handleSubmit:_e,getValues:Ce,reset:X,formState:{errors:s,isSubmitting:Se},setError:D,clearErrors:ee}=Ue({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),ae=ne({control:R,name:"password"}),I=ne({control:R,name:"email"}),O=V(r=>{X({email:I||"",password:"",confirmPassword:""}),ee(),U(!1),x(!1),$(!1),ve(r)},[X,ee,I]),Re=async r=>{if(M()){D("root",{message:e("errors.rate_limit","Too many attempts. Please wait a moment and try again.")});return}Pe();try{T==="signin"?(q!==void 0&&await he(q),await ue(r.email,r.password),t?.(void 0)):(await me(r.email,r.password,K?{gdpr_consent_at:new Date().toISOString()}:void 0),U(!0),t?.(void 0))}catch(u){const Le=T==="signup",se=u instanceof Error?u.message:String(u),L=se.toLowerCase();if(Le&&(L.includes("already")||L.includes("exists")||L.includes("user_already_exists")||L.includes("auth/email-already-in-use"))){U(!0);return}const Te=Be(u,e);D("root",{message:Te}),m?.(u instanceof Error?u:new Error(se))}},Ie=async()=>{if(!I||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I)){D("email",{message:e("emailRequired","Email is required")});return}F(!0);try{await pe(I)}catch{}finally{x(!0),F(!1)}},Ae=async()=>{try{await we()}catch{}};if(!ge)return i(o,{className:l,children:i(A,{variant:E.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Please accept cookies to enable authentication.")})});const c=fe||Se,re=w&&(C||S),Ee=p!==void 0&&!p,Ne=c||M()||Ee||re&&!K,ie=Q?Math.max(0,Math.ceil((Q-Date.now())/1e3)):0;return i("form",{onSubmit:_e(Re),className:Me("dndev-auth-form",l),noValidate:!0,children:n(o,{children:[s.root&&i(A,{variant:E.ERROR,description:s.root.message}),M()&&ie>0&&i(A,{variant:E.WARNING,description:e("errors.rate_limit_cooldown",`Too many attempts. Please wait ${ie} seconds.`)}),H&&n(o,{children:[i(A,{variant:E.SUCCESS,title:e("signup.success_title","Check your email"),description:e("signup.check_email","If an account was created, you will receive a confirmation email. Check your inbox and spam folder.")}),n(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[i(g,{type:"button",variant:f.GHOST,onClick:Ae,children:e("signup.resend_verification","Resend verification email")}),i(b,{as:"span",variant:"muted",children:"|"}),i(g,{type:"button",variant:f.LINK,onClick:()=>O("signin"),children:e("actions.sign_in_submit","Sign In")})]})]}),j&&n(o,{children:[i(A,{variant:E.SUCCESS,title:e("forgotPassword.sent","Password reset email sent"),description:e("forgotPassword.check_email_safe","If an account exists with this email, you will receive password reset instructions.")}),i(o,{align:"center",children:i(g,{type:"button",variant:f.LINK,onClick:()=>{x(!1)},children:e("back","Back")})})]}),!H&&!j&&n(o,{children:[i(W,{name:"email",control:R,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:r})=>n(o,{gap:"tight",children:[i(Ke,{...r,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),autoComplete:"email webauthn",disabled:c||k,"aria-invalid":!!s.email,"aria-describedby":s.email?"email-error":void 0,className:"dndev-w-full","data-variant":s.email?"destructive":void 0}),s.email&&i(b,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:s.email.message})]})}),i(W,{name:"password",control:R,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:w?{uppercase:r=>r?/[A-Z]/.test(r)?!0:e("passwordRequirement.uppercase","Password must contain at least one uppercase letter"):!0,lowercase:r=>r?/[a-z]/.test(r)?!0:e("passwordRequirement.lowercase","Password must contain at least one lowercase letter"):!0,number:r=>r?/[0-9]/.test(r)?!0:e("passwordRequirement.number","Password must contain at least one number"):!0,special:r=>r?/[^a-zA-Z0-9]/.test(r)?!0:e("passwordRequirement.special","Password must contain at least one special character"):!0,breached:async r=>!r||r.length<8?!0:await $e(r)?e("errors.breached_password","This password has appeared in a data breach. Please choose a different password."):!0}:void 0},render:({field:r})=>{const u=`password-${r.name}`;return n(o,{gap:"tight",children:[i(ce,{...r,id:u,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),autoComplete:w?"new-password":"current-password",disabled:c||k,"aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,className:"dndev-w-full","data-variant":s.password?"destructive":void 0}),s.password&&i(b,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:s.password.message})]})}}),w&&i(W,{name:"confirmPassword",control:R,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:r=>{const u=Ce("password");return r!==u?e("confirmPasswordMismatch","Passwords do not match"):!0}},render:({field:r})=>n(o,{gap:"tight",children:[i(ce,{...r,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:c,"aria-invalid":!!s.confirmPassword,"aria-describedby":s.confirmPassword?"confirm-password-error":void 0,className:"dndev-w-full","data-variant":s.confirmPassword?"destructive":void 0}),s.confirmPassword&&i(b,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:s.confirmPassword.message})]})}),w&&ae&&i(Ve,{password:ae,minLength:8,showRequirements:!0}),re&&n(te,{children:[n(o,{direction:"row",gap:"tight",align:"start",children:[i(oe,{id:"tos-accept",checked:K,onCheckedChange:r=>$(r===!0),disabled:c}),i(de,{htmlFor:"tos-accept",children:n(b,{as:"span",level:"caption",children:[e("terms.accept_prefix","I accept the")," ",C&&i(g,{type:"button",variant:f.LINK,onClick:()=>{z?G(!0):Y&&window.open(Y,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.tos","Terms of Service")}),C&&S&&n(te,{children:[" ",e("terms.and","and")," "]}),S&&i(g,{type:"button",variant:f.LINK,onClick:()=>{Z?B(!0):J&&window.open(J,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.privacy","Privacy Policy")})]})})]}),z&&i(le,{open:be,onOpenChange:G,title:e("terms.tos","Terms of Service"),showClose:!0,children:P}),Z&&i(le,{open:ke,onOpenChange:B,title:e("terms.privacy","Privacy Policy"),showClose:!0,children:_})]}),!w&&n(o,{direction:"row",gap:"tight",align:"center",children:[i(oe,{id:"remember-me",checked:q,onCheckedChange:r=>ye(r===!0),disabled:c||k}),i(de,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),i(g,{type:"submit",variant:f.PRIMARY,disabled:Ne,fullWidth:!0,children:c?e("loading","Loading..."):w?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!w&&n(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[i(g,{type:"button",variant:f.LINK,disabled:c||k,onClick:Ie,children:k?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),i(b,{as:"span",variant:"muted",children:"|"}),i(g,{type:"button",variant:f.LINK,disabled:c,onClick:()=>O("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),w&&i(o,{align:"center",children:i(g,{type:"button",variant:f.LINK,disabled:c,onClick:()=>O("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})]})})}var Ze=ze;export{Ze as default};
|
|
1
|
+
"use client";import{jsx as i,jsxs as n,Fragment as ne}from"react/jsx-runtime";import{useCallback as V,useEffect as Ue,useRef as Ke,useState as h}from"react";import{useForm as Me,Controller as W,useWatch as oe}from"react-hook-form";import{Alert as A,ALERT_VARIANT as N,Button as g,BUTTON_VARIANT as f,Checkbox as le,Dialog as de,Input as De,Label as ce,PasswordInput as ue,Stack as o,Text as b,cn as Oe}from"@donotdev/components";import{useTranslation as Ve,useAppConfig as We}from"@donotdev/core";import{useAuth as v}from"../useAuth";import{PasswordStrengthIndicator as je}from"./PasswordStrengthIndicator";const Fe=6e4,He=5,$e=3e4;function Ge(){const a=Ke([]),[t,m]=h(null),l=V(()=>!!(t&&Date.now()<t),[t]),y=V(()=>{const d=Date.now();a.current=a.current.filter(p=>d-p<Fe),a.current.push(d),a.current.length>=He&&(m(d+$e),a.current=[])},[]);return Ue(()=>{if(!t)return;const d=t-Date.now();if(d<=0){m(null);return}const p=setTimeout(()=>m(null),d);return()=>clearTimeout(p)},[t]),{isRateLimited:l,recordAttempt:y,cooldownUntil:t}}async function Be(a){try{const t=new TextEncoder().encode(a),m=await crypto.subtle.digest("SHA-1",t),l=Array.from(new Uint8Array(m)).map(e=>e.toString(16).padStart(2,"0")).join("").toUpperCase(),y=l.slice(0,5),d=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(e=>{const[E]=e.split(":");return E?.trim()===d}):!1}catch{return!1}}const ze=[{test:a=>a.includes("429")||a.includes("rate")||a.includes("too_many_requests"),key:"errors.rate_limit",fallback:"Too many attempts. Please wait a moment and try again."},{test:a=>a.includes("email_not_confirmed")||a.includes("email not confirmed")||a.includes("auth/unverified-email"),key:"errors.email_not_confirmed",fallback:"Please verify your email before signing in."},{test:a=>a.includes("invalid_credentials")||a.includes("invalid login credentials")||a.includes("invalid-credential")||a.includes("auth/wrong-password")||a.includes("auth/user-not-found")||a.includes("invalid")&&a.includes("credential"),key:"errors.invalid_credentials",fallback:"Invalid email or password."},{test:a=>a.includes("already")||a.includes("exists")||a.includes("user_already_exists")||a.includes("user already registered")||a.includes("auth/email-already-in-use"),key:"signup.check_email",fallback:"Check your email to confirm your account."},{test:a=>a.includes("weak_password")||a.includes("weak password")||a.includes("auth/weak-password"),key:"errors.weak_password",fallback:"Password is too weak. Please choose a stronger password."},{test:a=>a.includes("network")||a.includes("fetch"),key:"networkError",fallback:"Network error. Please check your connection and try again."}];function Ze(a,t){const m=(a instanceof Error?a.message:String(a)).toLowerCase();for(const l of ze)if(l.test(m))return t(l.key,l.fallback);return t("errorGeneric","Authentication failed. Please try again.")}function Ye({mode:a="signin",onSuccess:t,onError:m,className:l="",tos:y,privacy:d,captchaToken:p}){const{t:e}=Ve("auth"),E=We("app"),me=v("signInWithEmail"),pe=v("createUserWithEmail"),we=v("sendPasswordResetEmail"),he=v("sendEmailVerification"),ge=v("setRememberMe"),fe=v("isAvailable"),j=v("status"),ve=v("loading"),ye=j==="degraded"||j==="error",[T,be]=h(a),w=T==="signup",[q,ke]=h(!1),[F,x]=h(!1),[k,H]=h(!1),[$,U]=h(!1),[K,G]=h(!1),[Pe,B]=h(!1),[_e,z]=h(!1),P=y!==void 0?y:E?.footer?.legalLinks?.find(r=>r.path.includes("terms"))?.path??"/legal/terms",_=d!==void 0?d:E?.footer?.legalLinks?.find(r=>r.path.includes("privacy"))?.path??"/legal/privacy",C=P!==!1,S=_!==!1,Z=C&&typeof P!="string",Y=S&&typeof _!="string",X=C&&typeof P=="string"?P:null,J=S&&typeof _=="string"?_:null,{isRateLimited:M,recordAttempt:Ce,cooldownUntil:Q}=Ge(),{control:R,handleSubmit:Se,getValues:Re,reset:ee,formState:{errors:s,isSubmitting:Ie},setError:D,clearErrors:ae}=Me({mode:"onChange",defaultValues:{email:"",password:"",confirmPassword:""}}),re=oe({control:R,name:"password"}),I=oe({control:R,name:"email"}),O=V(r=>{ee({email:I||"",password:"",confirmPassword:""}),ae(),U(!1),x(!1),G(!1),be(r)},[ee,ae,I]),Ae=async r=>{if(M()){D("root",{message:e("errors.rate_limit","Too many attempts. Please wait a moment and try again.")});return}Ce();try{T==="signin"?(q!==void 0&&await ge(q),await me(r.email,r.password),t?.(void 0)):(await pe(r.email,r.password,K?{gdpr_consent_at:new Date().toISOString()}:void 0),U(!0),t?.(void 0))}catch(u){const qe=T==="signup",te=u instanceof Error?u.message:String(u),L=te.toLowerCase();if(qe&&(L.includes("already")||L.includes("exists")||L.includes("user_already_exists")||L.includes("auth/email-already-in-use"))){U(!0);return}const xe=Ze(u,e);D("root",{message:xe}),m?.(u instanceof Error?u:new Error(te))}},Ne=async()=>{if(!I||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I)){D("email",{message:e("emailRequired","Email is required")});return}H(!0);try{await we(I)}catch{}finally{x(!0),H(!1)}},Ee=async()=>{try{await he()}catch{}};if(ye)return i(o,{className:l,children:i(A,{variant:N.WARNING,title:e("unavailable.title","Authentication Unavailable"),description:e("unavailable.description","Sign-in is temporarily unavailable. Please try again later.")})});const c=ve||Ie||!fe,ie=w&&(C||S),Le=p!==void 0&&!p,Te=c||M()||Le||ie&&!K,se=Q?Math.max(0,Math.ceil((Q-Date.now())/1e3)):0;return i("form",{onSubmit:Se(Ae),className:Oe("dndev-auth-form",l),noValidate:!0,children:n(o,{children:[s.root&&i(A,{variant:N.ERROR,description:s.root.message}),M()&&se>0&&i(A,{variant:N.WARNING,description:e("errors.rate_limit_cooldown",`Too many attempts. Please wait ${se} seconds.`)}),$&&n(o,{children:[i(A,{variant:N.SUCCESS,title:e("signup.success_title","Check your email"),description:e("signup.check_email","If an account was created, you will receive a confirmation email. Check your inbox and spam folder.")}),n(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[i(g,{type:"button",variant:f.GHOST,onClick:Ee,children:e("signup.resend_verification","Resend verification email")}),i(b,{as:"span",variant:"muted",children:"|"}),i(g,{type:"button",variant:f.LINK,onClick:()=>O("signin"),children:e("actions.sign_in_submit","Sign In")})]})]}),F&&n(o,{children:[i(A,{variant:N.SUCCESS,title:e("forgotPassword.sent","Password reset email sent"),description:e("forgotPassword.check_email_safe","If an account exists with this email, you will receive password reset instructions.")}),i(o,{align:"center",children:i(g,{type:"button",variant:f.LINK,onClick:()=>{x(!1)},children:e("back","Back")})})]}),!$&&!F&&n(o,{children:[i(W,{name:"email",control:R,rules:{required:e("emailRequired","Email is required"),pattern:{value:/^[^\s@]+@[^\s@]+\.[^\s@]+$/,message:e("emailInvalid","Invalid email address")}},render:({field:r})=>n(o,{gap:"tight",children:[i(De,{...r,type:"email",label:e("email","Email"),placeholder:e("emailPlaceholder","Enter your email"),autoComplete:"email webauthn",disabled:c||k,"aria-invalid":!!s.email,"aria-describedby":s.email?"email-error":void 0,className:"dndev-w-full","data-variant":s.email?"destructive":void 0}),s.email&&i(b,{as:"span",level:"caption",variant:"destructive",id:"email-error",role:"alert",children:s.email.message})]})}),i(W,{name:"password",control:R,rules:{required:e("passwordRequired","Password is required"),minLength:{value:8,message:e("passwordMinLength","Password must be at least 8 characters")},validate:w?{uppercase:r=>r?/[A-Z]/.test(r)?!0:e("passwordRequirement.uppercase","Password must contain at least one uppercase letter"):!0,lowercase:r=>r?/[a-z]/.test(r)?!0:e("passwordRequirement.lowercase","Password must contain at least one lowercase letter"):!0,number:r=>r?/[0-9]/.test(r)?!0:e("passwordRequirement.number","Password must contain at least one number"):!0,special:r=>r?/[^a-zA-Z0-9]/.test(r)?!0:e("passwordRequirement.special","Password must contain at least one special character"):!0,breached:async r=>!r||r.length<8?!0:await Be(r)?e("errors.breached_password","This password has appeared in a data breach. Please choose a different password."):!0}:void 0},render:({field:r})=>{const u=`password-${r.name}`;return n(o,{gap:"tight",children:[i(ue,{...r,id:u,label:e("password","Password"),placeholder:e("passwordPlaceholder","Enter your password"),autoComplete:w?"new-password":"current-password",disabled:c||k,"aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,className:"dndev-w-full","data-variant":s.password?"destructive":void 0}),s.password&&i(b,{as:"span",level:"caption",variant:"destructive",id:"password-error",role:"alert",children:s.password.message})]})}}),w&&i(W,{name:"confirmPassword",control:R,rules:{required:e("confirmPasswordRequired","Please confirm your password"),validate:r=>{const u=Re("password");return r!==u?e("confirmPasswordMismatch","Passwords do not match"):!0}},render:({field:r})=>n(o,{gap:"tight",children:[i(ue,{...r,label:e("confirmPassword","Confirm Password"),placeholder:e("confirmPasswordPlaceholder","Re-enter your password"),autoComplete:"new-password",disabled:c,"aria-invalid":!!s.confirmPassword,"aria-describedby":s.confirmPassword?"confirm-password-error":void 0,className:"dndev-w-full","data-variant":s.confirmPassword?"destructive":void 0}),s.confirmPassword&&i(b,{as:"span",level:"caption",variant:"destructive",id:"confirm-password-error",role:"alert",children:s.confirmPassword.message})]})}),w&&re&&i(je,{password:re,minLength:8,showRequirements:!0}),ie&&n(ne,{children:[n(o,{direction:"row",gap:"tight",align:"start",children:[i(le,{id:"tos-accept",checked:K,onCheckedChange:r=>G(r===!0),disabled:c}),i(ce,{htmlFor:"tos-accept",children:n(b,{as:"span",level:"caption",children:[e("terms.accept_prefix","I accept the")," ",C&&i(g,{type:"button",variant:f.LINK,onClick:()=>{Z?B(!0):X&&window.open(X,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.tos","Terms of Service")}),C&&S&&n(ne,{children:[" ",e("terms.and","and")," "]}),S&&i(g,{type:"button",variant:f.LINK,onClick:()=>{Y?z(!0):J&&window.open(J,"_blank","noopener,noreferrer")},className:"dndev-p-0 dndev-h-auto",style:{minHeight:"auto",padding:0,display:"inline"},children:e("terms.privacy","Privacy Policy")})]})})]}),Z&&i(de,{open:Pe,onOpenChange:B,title:e("terms.tos","Terms of Service"),showClose:!0,children:P}),Y&&i(de,{open:_e,onOpenChange:z,title:e("terms.privacy","Privacy Policy"),showClose:!0,children:_})]}),!w&&n(o,{direction:"row",gap:"tight",align:"center",children:[i(le,{id:"remember-me",checked:q,onCheckedChange:r=>ke(r===!0),disabled:c||k}),i(ce,{htmlFor:"remember-me",children:e("rememberMe","Remember me")})]}),i(g,{type:"submit",variant:f.PRIMARY,disabled:Te,fullWidth:!0,children:c?e("loading","Loading..."):w?e("actions.sign_up_submit","Sign Up"):e("actions.sign_in_submit","Sign In")}),!w&&n(o,{direction:"row",gap:"tight",justify:"center",align:"center",children:[i(g,{type:"button",variant:f.LINK,disabled:c||k,onClick:Ne,children:k?e("loading","Loading..."):e("forgotPassword","Forgot password?")}),i(b,{as:"span",variant:"muted",children:"|"}),i(g,{type:"button",variant:f.LINK,disabled:c,onClick:()=>O("signup"),children:e("actions.sign_up_submit","Sign Up")})]}),w&&i(o,{align:"center",children:i(g,{type:"button",variant:f.LINK,disabled:c,onClick:()=>O("signin"),children:e("alreadyHaveAccount","Already have an account? Sign In")})})]})]})})}var Xe=Ye;export{Xe as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EmailVerificationProps } from '../constants';
|
|
2
1
|
import type { JSX } from 'react';
|
|
2
|
+
import type { EmailVerificationProps } from '../constants';
|
|
3
3
|
/**
|
|
4
4
|
* Component for handling email verification
|
|
5
5
|
* Shows different states depending on verification status and provides verification button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailVerification.d.ts","sourceRoot":"","sources":["../../src/components/EmailVerification.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EmailVerification.d.ts","sourceRoot":"","sources":["../../src/components/EmailVerification.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAajC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAG3D;;;;;;;;;;GAUG;AACH,iBAAS,iBAAiB,CAAC,EACzB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,YAAY,EACZ,EAAE,GACH,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CA8F7C;AAKD,eAAe,iBAAiB,CAAC"}
|
|
@@ -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
|
-
{"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["../../src/components/Feature.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Feature.d.ts","sourceRoot":"","sources":["../../src/components/Feature.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,UAAU,gBAAgB;IACxB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,sDAAsD;IACtD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,qGAuBnB,CAAC;AAgCF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,uHAKrB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,uHAKzB,CAAC"}
|
|
@@ -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,5 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview FeatureGuard - Component-level feature access control
|
|
3
|
+
* @description Protects individual components based on user permissions, roles, and subscription tiers
|
|
4
|
+
* @version 0.1.0
|
|
5
|
+
* @since 0.0.1
|
|
6
|
+
* @author AMBROISE PARK Consulting
|
|
7
|
+
*
|
|
8
|
+
* This component provides granular feature access control within pages, allowing developers
|
|
9
|
+
* to show/hide features based on user permissions without manual hook management.
|
|
10
|
+
*
|
|
11
|
+
* **Use Cases:**
|
|
12
|
+
* - Show premium features only to pro users
|
|
13
|
+
* - Hide admin features from regular users
|
|
14
|
+
* - Display upgrade prompts for locked features
|
|
15
|
+
* - Conditional rendering based on subscription status
|
|
16
|
+
* - Protect individual UI components within pages
|
|
17
|
+
*
|
|
18
|
+
* **Architecture:**
|
|
19
|
+
* - Uses useAuth() for permission checking
|
|
20
|
+
* - Provides automatic fallback components
|
|
21
|
+
* - Supports role, tier, and custom validation
|
|
22
|
+
* - Graceful degradation when auth unavailable
|
|
23
|
+
* - Integrates with existing AuthGuard for route-level protection
|
|
24
|
+
*
|
|
25
|
+
* **Usage Patterns:**
|
|
26
|
+
*
|
|
27
|
+
* Role-based access:
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <FeatureGuard role="admin">
|
|
30
|
+
* <AdminPanel />
|
|
31
|
+
* </FeatureGuard>
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Subscription tier access:
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <FeatureGuard tier="pro" fallback={<UpgradePrompt />}>
|
|
37
|
+
* <PremiumFeature />
|
|
38
|
+
* </FeatureGuard>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Active subscription required:
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <FeatureGuard subscription>
|
|
44
|
+
* <SubscriberFeature />
|
|
45
|
+
* </FeatureGuard>
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* Custom validation:
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <FeatureGuard validate={(role, tier) => role === 'admin' && tier !== 'free'}>
|
|
51
|
+
* <CustomFeature />
|
|
52
|
+
* </FeatureGuard>
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* Multiple conditions:
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <FeatureGuard role="admin" tier="pro" subscription>
|
|
58
|
+
* <AdminPremiumFeature />
|
|
59
|
+
* </FeatureGuard>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
2
62
|
import type { ReactNode, ComponentType } from 'react';
|
|
63
|
+
import type { UserRole, SubscriptionTier } from '@donotdev/core';
|
|
3
64
|
/**
|
|
4
65
|
* Props for FeatureGuard component
|
|
5
66
|
*/
|
|
@@ -36,18 +97,18 @@ export interface FeatureGuardProps {
|
|
|
36
97
|
declare function UpgradePrompt({ requiredTier, userTier, }: {
|
|
37
98
|
requiredTier?: string;
|
|
38
99
|
userTier?: string;
|
|
39
|
-
}): import("react
|
|
100
|
+
}): import("react").JSX.Element;
|
|
40
101
|
/**
|
|
41
102
|
* Default access denied component
|
|
42
103
|
*/
|
|
43
104
|
declare function AccessDenied({ requiredRole, userRole, }: {
|
|
44
105
|
requiredRole?: string | string[];
|
|
45
106
|
userRole?: string;
|
|
46
|
-
}): import("react
|
|
107
|
+
}): import("react").JSX.Element;
|
|
47
108
|
/**
|
|
48
109
|
* Default subscription expired component
|
|
49
110
|
*/
|
|
50
|
-
declare function SubscriptionExpired(): import("react
|
|
111
|
+
declare function SubscriptionExpired(): import("react").JSX.Element;
|
|
51
112
|
/**
|
|
52
113
|
* FeatureGuard component that protects individual components based on user permissions
|
|
53
114
|
*
|
|
@@ -86,7 +147,7 @@ declare function SubscriptionExpired(): import("react/jsx-runtime").JSX.Element;
|
|
|
86
147
|
* @since 0.0.1
|
|
87
148
|
* @author AMBROISE PARK Consulting
|
|
88
149
|
*/
|
|
89
|
-
export declare function FeatureGuard({ children, role, tier, subscription, validate, fallback: CustomFallback, message, showUpgradePrompt, showLoginPrompt, }: FeatureGuardProps): import("react
|
|
150
|
+
export declare function FeatureGuard({ children, role, tier, subscription, validate, fallback: CustomFallback, message, showUpgradePrompt, showLoginPrompt, }: FeatureGuardProps): import("react").JSX.Element | null;
|
|
90
151
|
/**
|
|
91
152
|
* Hook to check if current user can access a feature
|
|
92
153
|
*
|
|
@@ -147,6 +208,6 @@ export declare function useCanAccessFeature(config: {
|
|
|
147
208
|
* @since 0.0.1
|
|
148
209
|
* @author AMBROISE PARK Consulting
|
|
149
210
|
*/
|
|
150
|
-
export declare function withFeatureGuard<P extends object>(Component: ComponentType<P>, config: Omit<FeatureGuardProps, 'children'>): (props: P) => import("react
|
|
211
|
+
export declare function withFeatureGuard<P extends object>(Component: ComponentType<P>, config: Omit<FeatureGuardProps, 'children'>): (props: P) => import("react").JSX.Element;
|
|
151
212
|
export { UpgradePrompt, AccessDenied, SubscriptionExpired };
|
|
152
213
|
//# sourceMappingURL=FeatureGuard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureGuard.d.ts","sourceRoot":"","sources":["../../src/components/FeatureGuard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeatureGuard.d.ts","sourceRoot":"","sources":["../../src/components/FeatureGuard.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMjE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,CAAC;IAEpB,qDAAqD;IACrD,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAE7B,iCAAiC;IACjC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IAExB,8CAA8C;IAC9C,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,CACT,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,IAAI,EAAE,gBAAgB,GAAG,SAAS,KAC/B,OAAO,CAAC;IAEb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,aAAa,CAAC;QACvB,YAAY,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;QACrC,YAAY,CAAC,EAAE,gBAAgB,CAAC;QAChC,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;QACpB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;QAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC,CAAC;IAEH,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,yDAAyD;IACzD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,iBAAS,aAAa,CAAC,EACrB,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,+BAsCA;AAED;;GAEG;AACH,iBAAS,YAAY,CAAC,EACpB,YAAY,EACZ,QAAQ,GACT,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,+BA0CA;AAED;;GAEG;AACH,iBAAS,mBAAmB,gCAqC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,QAAQ,EAAE,cAAc,EACxB,OAAO,EACP,iBAAwB,EACxB,eAAsB,GACvB,EAAE,iBAAiB,sCAwGnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,CACT,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,IAAI,EAAE,gBAAgB,GAAG,SAAS,KAC/B,OAAO,CAAC;CACd,GAAG,OAAO,CA6CV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,WAEV,CAAC,iCAOnC;AAGD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as e,jsxs as o,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:o(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u{1F512}"}),o("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:r==="pro"?"Pro Feature":"Premium Feature"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["Upgrade to ",r," to access this feature",i&&` (current: ${i})`]})]})]})})}function p({requiredRole:r,userRole:i}){const s=Array.isArray(r)?r.join(" or "):r;return e("div",{className:"dndev-surface","data-variant":"destructive","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--destructive)",backgroundColor:"var(--muted)"},children:o(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--destructive)"},children:"\u{1F6AB}"}),o("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--destructive-foreground)"},children:"Access Denied"}),o("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:["This feature requires ",s," role",i&&` (current: ${i})`]})]})]})})}function b(){return e("div",{className:"dndev-surface","data-variant":"default","data-shadow":"sm","data-radius":"lg",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",backgroundColor:"var(--muted)"},children:o(f,{direction:"row",align:"center",children:[e("span",{style:{color:"var(--accent)"},children:"\u23F0"}),o("div",{children:[e("p",{style:{fontWeight:500,fontSize:"var(--font-size-base)",color:"var(--foreground)"},children:"Subscription Required"}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:"This feature requires an active subscription"})]})]})})}function y({children:r,role:i,tier:s,subscription: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||s||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}):s&&!m(c,s)?a?e(a,{requiredTier:s,userTier:c||"free"}):A?e(g,{requiredTier:s,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"),s=t("userProfile"),u=t("userSubscription"),n=s?.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 s=>e(y,{...i,children:e(r,{...s})})}export{p as AccessDenied,y as FeatureGuard,b as SubscriptionExpired,g as UpgradePrompt,P as useCanAccessFeature,k as withFeatureGuard};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Feature placeholder components for DoNotDev framework
|
|
3
|
+
* @description Components for showing placeholders when features are not available
|
|
4
|
+
*
|
|
5
|
+
* @version 0.1.0
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @author AMBROISE PARK Consulting
|
|
8
|
+
*/
|
|
1
9
|
import type { ReactNode } from 'react';
|
|
2
10
|
/**
|
|
3
11
|
* Props for the FeaturePlaceholder component
|
|
@@ -39,7 +47,7 @@ interface TierPlaceholderProps {
|
|
|
39
47
|
* @since 0.0.1
|
|
40
48
|
* @author AMBROISE PARK Consulting
|
|
41
49
|
*/
|
|
42
|
-
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> | import("react
|
|
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> | import("react").JSX.Element | null;
|
|
43
51
|
/**
|
|
44
52
|
* Placeholder for Pro tier features
|
|
45
53
|
*
|
|
@@ -47,7 +55,7 @@ export declare function FeaturePlaceholder({ featureId, featureName, className,
|
|
|
47
55
|
* @since 0.0.1
|
|
48
56
|
* @author AMBROISE PARK Consulting
|
|
49
57
|
*/
|
|
50
|
-
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> | import("react
|
|
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> | import("react").JSX.Element | null;
|
|
51
59
|
/**
|
|
52
60
|
* Placeholder for Premium tier features
|
|
53
61
|
*
|
|
@@ -55,6 +63,6 @@ export declare const ProFeaturePlaceholder: ({ featureName, className, children,
|
|
|
55
63
|
* @since 0.0.1
|
|
56
64
|
* @author AMBROISE PARK Consulting
|
|
57
65
|
*/
|
|
58
|
-
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> | import("react
|
|
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> | import("react").JSX.Element | null;
|
|
59
67
|
export {};
|
|
60
68
|
//# sourceMappingURL=FeaturePlaceholder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeaturePlaceholder.d.ts","sourceRoot":"","sources":["../../src/components/FeaturePlaceholder.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeaturePlaceholder.d.ts","sourceRoot":"","sources":["../../src/components/FeaturePlaceholder.tsx"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC;;GAEG;AACH,UAAU,uBAAuB;IAC/B,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,UAAU,oBAAoB;IAC5B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,EACT,WAAW,EACX,SAAc,EACd,QAAQ,GACT,EAAE,uBAAuB,gTAqCzB;AAsDD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,0CA/C7B,oBAAoB,iTA+C+C,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,0CAxDjC,oBAAoB,iTA2DxB,CAAC"}
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview GoogleOneTap Component - October 2025 FedCM Mandatory
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* Modern Google One Tap component with mandatory FedCM compliance.
|
|
6
|
+
* Shows browser compatibility message if FedCM not supported.
|
|
7
|
+
*
|
|
8
|
+
* **Key Features:**
|
|
9
|
+
* - FedCM mandatory (no fallback)
|
|
10
|
+
* - Clear browser compatibility messaging
|
|
11
|
+
* - CSR/SSR safe with proper hydration
|
|
12
|
+
* - Framework-native UI components
|
|
13
|
+
* - Clean error states
|
|
14
|
+
*
|
|
15
|
+
* **Browser Support:**
|
|
16
|
+
* - ✅ Chrome 116+
|
|
17
|
+
* - ✅ Edge 116+
|
|
18
|
+
* - ❌ Safari (not yet supported)
|
|
19
|
+
* - ❌ Firefox (not yet supported)
|
|
20
|
+
*
|
|
21
|
+
* **Usage:**
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <GoogleOneTap
|
|
24
|
+
* onSuccess={(credential) => console.log('Signed in')}
|
|
25
|
+
* onError={(error) => console.error(error)}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @version 0.1.0
|
|
30
|
+
* @since 0.0.1
|
|
31
|
+
* @author AMBROISE PARK Consulting
|
|
32
|
+
*/
|
|
1
33
|
import type { ComponentType } from 'react';
|
|
2
34
|
/**
|
|
3
35
|
* Component props
|
|
@@ -65,6 +97,6 @@ interface GoogleOneTapProps {
|
|
|
65
97
|
* @since 0.0.1
|
|
66
98
|
* @author AMBROISE PARK Consulting
|
|
67
99
|
*/
|
|
68
|
-
declare function GoogleOneTap({ clientId, onSuccess, onError, autoSelect, cancelOnTapOutside, className, disabled, promptParentId, allowedParentOrigins, cspNonce, clientOnly, showErrorDetails, loadingComponent: LoadingComponent, errorComponent: ErrorComponent, browserNotSupportedComponent: BrowserNotSupportedComponent, }: GoogleOneTapProps): import("react
|
|
100
|
+
declare function GoogleOneTap({ clientId, onSuccess, onError, autoSelect, cancelOnTapOutside, className, disabled, promptParentId, allowedParentOrigins, cspNonce, clientOnly, showErrorDetails, loadingComponent: LoadingComponent, errorComponent: ErrorComponent, browserNotSupportedComponent: BrowserNotSupportedComponent, }: GoogleOneTapProps): import("react").JSX.Element | null;
|
|
69
101
|
export default GoogleOneTap;
|
|
70
102
|
//# sourceMappingURL=GoogleOneTap.d.ts.map
|