dauth-context-react 6.0.0 → 6.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/index.d.mts +27 -2
- package/dist/index.d.ts +27 -2
- package/dist/index.js +1086 -158
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1086 -158
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/DauthProfileModal.tsx +1102 -238
- package/src/api/dauth.api.ts +73 -0
- package/src/api/interfaces/dauth.api.responses.ts +36 -0
- package/src/index.tsx +33 -1
- package/src/initialDauthState.ts +3 -0
- package/src/interfaces.ts +31 -0
- package/src/reducer/dauth.actions.ts +91 -0
- package/src/webauthn.ts +111 -0
package/dist/index.d.mts
CHANGED
|
@@ -34,6 +34,15 @@ interface IFormField {
|
|
|
34
34
|
field: string;
|
|
35
35
|
required: boolean;
|
|
36
36
|
}
|
|
37
|
+
interface IModalTheme {
|
|
38
|
+
accent?: string;
|
|
39
|
+
accentHover?: string;
|
|
40
|
+
surface?: string;
|
|
41
|
+
surfaceHover?: string;
|
|
42
|
+
textPrimary?: string;
|
|
43
|
+
textSecondary?: string;
|
|
44
|
+
border?: string;
|
|
45
|
+
}
|
|
37
46
|
interface IDauthDomainState {
|
|
38
47
|
name: string;
|
|
39
48
|
environments?: IDauthDomainEnvironment[];
|
|
@@ -41,6 +50,15 @@ interface IDauthDomainState {
|
|
|
41
50
|
allowedOrigins: string[];
|
|
42
51
|
authMethods?: IDauthAuthMethods;
|
|
43
52
|
formFields?: IFormField[];
|
|
53
|
+
modalTheme?: IModalTheme;
|
|
54
|
+
}
|
|
55
|
+
interface IPasskeyCredential {
|
|
56
|
+
_id: string;
|
|
57
|
+
name?: string;
|
|
58
|
+
deviceType: 'singleDevice' | 'multiDevice';
|
|
59
|
+
backedUp: boolean;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
lastUsedAt?: string;
|
|
44
62
|
}
|
|
45
63
|
interface IDauthState {
|
|
46
64
|
user: IDauthUser;
|
|
@@ -51,10 +69,17 @@ interface IDauthState {
|
|
|
51
69
|
logout: () => void;
|
|
52
70
|
updateUser: (fields: Partial<IDauthUser>) => Promise<boolean>;
|
|
53
71
|
deleteAccount: () => Promise<boolean>;
|
|
72
|
+
getPasskeyCredentials: () => Promise<IPasskeyCredential[]>;
|
|
73
|
+
registerPasskey: (name?: string) => Promise<IPasskeyCredential | null>;
|
|
74
|
+
deletePasskeyCredential: (credentialId: string) => Promise<boolean>;
|
|
54
75
|
}
|
|
55
76
|
interface DauthProfileModalProps {
|
|
56
77
|
open: boolean;
|
|
57
78
|
onClose: () => void;
|
|
79
|
+
/** Optional: provide a function to handle avatar upload.
|
|
80
|
+
* Receives a File, should return the URL string.
|
|
81
|
+
* If not provided, the avatar edit button is hidden. */
|
|
82
|
+
onAvatarUpload?: (file: File) => Promise<string>;
|
|
58
83
|
}
|
|
59
84
|
interface IDauthProviderProps {
|
|
60
85
|
domainName: string;
|
|
@@ -67,9 +92,9 @@ interface IDauthProviderProps {
|
|
|
67
92
|
dauthUrl?: string;
|
|
68
93
|
}
|
|
69
94
|
|
|
70
|
-
declare function DauthProfileModal({ open, onClose }: DauthProfileModalProps): React$1.ReactPortal | null;
|
|
95
|
+
declare function DauthProfileModal({ open, onClose, onAvatarUpload, }: DauthProfileModalProps): React$1.ReactPortal | null;
|
|
71
96
|
|
|
72
97
|
declare const DauthProvider: React$1.FC<IDauthProviderProps>;
|
|
73
98
|
declare const useDauth: () => IDauthState;
|
|
74
99
|
|
|
75
|
-
export { DauthProfileModal, type DauthProfileModalProps, DauthProvider, type IDauthAuthMethods, type IDauthProviderProps, type IFormField, useDauth };
|
|
100
|
+
export { DauthProfileModal, type DauthProfileModalProps, DauthProvider, type IDauthAuthMethods, type IDauthProviderProps, type IFormField, type IModalTheme, type IPasskeyCredential, useDauth };
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,15 @@ interface IFormField {
|
|
|
34
34
|
field: string;
|
|
35
35
|
required: boolean;
|
|
36
36
|
}
|
|
37
|
+
interface IModalTheme {
|
|
38
|
+
accent?: string;
|
|
39
|
+
accentHover?: string;
|
|
40
|
+
surface?: string;
|
|
41
|
+
surfaceHover?: string;
|
|
42
|
+
textPrimary?: string;
|
|
43
|
+
textSecondary?: string;
|
|
44
|
+
border?: string;
|
|
45
|
+
}
|
|
37
46
|
interface IDauthDomainState {
|
|
38
47
|
name: string;
|
|
39
48
|
environments?: IDauthDomainEnvironment[];
|
|
@@ -41,6 +50,15 @@ interface IDauthDomainState {
|
|
|
41
50
|
allowedOrigins: string[];
|
|
42
51
|
authMethods?: IDauthAuthMethods;
|
|
43
52
|
formFields?: IFormField[];
|
|
53
|
+
modalTheme?: IModalTheme;
|
|
54
|
+
}
|
|
55
|
+
interface IPasskeyCredential {
|
|
56
|
+
_id: string;
|
|
57
|
+
name?: string;
|
|
58
|
+
deviceType: 'singleDevice' | 'multiDevice';
|
|
59
|
+
backedUp: boolean;
|
|
60
|
+
createdAt: string;
|
|
61
|
+
lastUsedAt?: string;
|
|
44
62
|
}
|
|
45
63
|
interface IDauthState {
|
|
46
64
|
user: IDauthUser;
|
|
@@ -51,10 +69,17 @@ interface IDauthState {
|
|
|
51
69
|
logout: () => void;
|
|
52
70
|
updateUser: (fields: Partial<IDauthUser>) => Promise<boolean>;
|
|
53
71
|
deleteAccount: () => Promise<boolean>;
|
|
72
|
+
getPasskeyCredentials: () => Promise<IPasskeyCredential[]>;
|
|
73
|
+
registerPasskey: (name?: string) => Promise<IPasskeyCredential | null>;
|
|
74
|
+
deletePasskeyCredential: (credentialId: string) => Promise<boolean>;
|
|
54
75
|
}
|
|
55
76
|
interface DauthProfileModalProps {
|
|
56
77
|
open: boolean;
|
|
57
78
|
onClose: () => void;
|
|
79
|
+
/** Optional: provide a function to handle avatar upload.
|
|
80
|
+
* Receives a File, should return the URL string.
|
|
81
|
+
* If not provided, the avatar edit button is hidden. */
|
|
82
|
+
onAvatarUpload?: (file: File) => Promise<string>;
|
|
58
83
|
}
|
|
59
84
|
interface IDauthProviderProps {
|
|
60
85
|
domainName: string;
|
|
@@ -67,9 +92,9 @@ interface IDauthProviderProps {
|
|
|
67
92
|
dauthUrl?: string;
|
|
68
93
|
}
|
|
69
94
|
|
|
70
|
-
declare function DauthProfileModal({ open, onClose }: DauthProfileModalProps): React$1.ReactPortal | null;
|
|
95
|
+
declare function DauthProfileModal({ open, onClose, onAvatarUpload, }: DauthProfileModalProps): React$1.ReactPortal | null;
|
|
71
96
|
|
|
72
97
|
declare const DauthProvider: React$1.FC<IDauthProviderProps>;
|
|
73
98
|
declare const useDauth: () => IDauthState;
|
|
74
99
|
|
|
75
|
-
export { DauthProfileModal, type DauthProfileModalProps, DauthProvider, type IDauthAuthMethods, type IDauthProviderProps, type IFormField, useDauth };
|
|
100
|
+
export { DauthProfileModal, type DauthProfileModalProps, DauthProvider, type IDauthAuthMethods, type IDauthProviderProps, type IFormField, type IModalTheme, type IPasskeyCredential, useDauth };
|