@digitaldefiance/express-suite-react-components 2.1.42 → 2.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +2 -2
- package/src/components/ApiAccess.js +1 -1
- package/src/components/BackupCodeLoginForm.js +1 -1
- package/src/components/DropdownMenu.d.ts +4 -10
- package/src/components/DropdownMenu.d.ts.map +1 -1
- package/src/components/DropdownMenu.js +19 -7
- package/src/components/Flag.d.ts +12 -2
- package/src/components/Flag.d.ts.map +1 -1
- package/src/components/Flag.js +17 -4
- package/src/components/ForgotPasswordForm.js +1 -1
- package/src/components/LoginForm.js +1 -1
- package/src/components/SideMenu.d.ts +2 -7
- package/src/components/SideMenu.d.ts.map +1 -1
- package/src/components/SideMenu.js +7 -2
- package/src/components/TopMenu.d.ts +3 -14
- package/src/components/TopMenu.d.ts.map +1 -1
- package/src/components/TopMenu.js +23 -2
- package/src/components/TranslatedTitle.d.ts +5 -5
- package/src/components/TranslatedTitle.d.ts.map +1 -1
- package/src/components/TranslatedTitle.js +7 -5
- package/src/components/UserLanguageSelector.d.ts +1 -12
- package/src/components/UserLanguageSelector.d.ts.map +1 -1
- package/src/components/UserLanguageSelector.js +7 -4
- package/src/components/UserMenu.d.ts +4 -0
- package/src/components/UserMenu.d.ts.map +1 -0
- package/src/components/UserMenu.js +12 -0
- package/src/components/index.d.ts +1 -0
- package/src/components/index.d.ts.map +1 -1
- package/src/components/index.js +1 -0
- package/src/contexts/AuthProvider.d.ts +146 -0
- package/src/contexts/AuthProvider.d.ts.map +1 -0
- package/src/contexts/AuthProvider.js +406 -0
- package/src/contexts/I18nProvider.d.ts +6 -6
- package/src/contexts/I18nProvider.d.ts.map +1 -1
- package/src/contexts/I18nProvider.js +4 -4
- package/src/contexts/MenuContext.d.ts +16 -0
- package/src/contexts/MenuContext.d.ts.map +1 -0
- package/src/contexts/MenuContext.js +215 -0
- package/src/contexts/index.d.ts +2 -0
- package/src/contexts/index.d.ts.map +1 -1
- package/src/contexts/index.js +2 -0
- package/src/interfaces/AppConfig.d.ts +0 -2
- package/src/interfaces/AppConfig.d.ts.map +1 -1
- package/src/services/__mocks__/authService.d.ts +21 -0
- package/src/services/__mocks__/authService.d.ts.map +1 -0
- package/src/services/__mocks__/authService.js +15 -0
- package/src/services/authService.d.ts +80 -0
- package/src/services/authService.d.ts.map +1 -0
- package/src/services/authService.js +339 -0
- package/src/services/index.d.ts +1 -0
- package/src/services/index.d.ts.map +1 -1
- package/src/services/index.js +1 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMenu = exports.MenuProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// src/app/menuContext.tsx
|
|
6
|
+
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
7
|
+
const suite_core_lib_2 = require("@digitaldefiance/suite-core-lib");
|
|
8
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const AuthProvider_1 = require("./AuthProvider");
|
|
11
|
+
const IncludeOnMenu_1 = require("../enumerations/IncludeOnMenu");
|
|
12
|
+
const I18nProvider_1 = require("./I18nProvider");
|
|
13
|
+
const ThemeProvider_1 = require("./ThemeProvider");
|
|
14
|
+
const MenuContext = (0, react_1.createContext)(undefined);
|
|
15
|
+
const MenuProvider = ({ children }) => {
|
|
16
|
+
const { userData: user, isAuthenticated, mnemonic, clearMnemonic, wallet, clearWallet } = (0, AuthProvider_1.useAuth)();
|
|
17
|
+
const registeredMenuOptions = (0, react_1.useRef)(new Set());
|
|
18
|
+
const [registeredOptions, setRegisteredOptions] = (0, react_1.useState)(new Map());
|
|
19
|
+
const { t, tComponent } = (0, I18nProvider_1.useI18n)();
|
|
20
|
+
const { mode, toggleColorMode } = (0, ThemeProvider_1.useTheme)();
|
|
21
|
+
const registerMenuOption = (0, react_1.useCallback)((option) => {
|
|
22
|
+
const unregister = () => {
|
|
23
|
+
setRegisteredOptions((prev) => {
|
|
24
|
+
const newMap = new Map(prev);
|
|
25
|
+
newMap.delete(option.id);
|
|
26
|
+
return newMap;
|
|
27
|
+
});
|
|
28
|
+
registeredMenuOptions.current.delete(unregister);
|
|
29
|
+
};
|
|
30
|
+
setRegisteredOptions((prev) => {
|
|
31
|
+
const newMap = new Map(prev);
|
|
32
|
+
newMap.set(option.id, option);
|
|
33
|
+
return newMap;
|
|
34
|
+
});
|
|
35
|
+
registeredMenuOptions.current.add(unregister);
|
|
36
|
+
return unregister;
|
|
37
|
+
}, []);
|
|
38
|
+
const registerMenuOptions = (0, react_1.useCallback)((options) => {
|
|
39
|
+
const unregisterFunctions = options.map(registerMenuOption);
|
|
40
|
+
return () => unregisterFunctions.forEach((f) => f());
|
|
41
|
+
}, [registerMenuOption]);
|
|
42
|
+
const menuOptions = (0, react_1.useMemo)(() => {
|
|
43
|
+
const isUserRestricted = () => {
|
|
44
|
+
return user?.roles.some((role) => role.child);
|
|
45
|
+
};
|
|
46
|
+
let index = 0;
|
|
47
|
+
const baseOptions = [
|
|
48
|
+
{
|
|
49
|
+
id: 'dashboard',
|
|
50
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_Dashboard)),
|
|
51
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Dashboard, {}),
|
|
52
|
+
link: '/dashboard',
|
|
53
|
+
requiresAuth: true,
|
|
54
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
55
|
+
index: index++,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'user-divider',
|
|
59
|
+
label: '',
|
|
60
|
+
divider: true,
|
|
61
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
62
|
+
index: index++,
|
|
63
|
+
requiresAuth: false,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'logout',
|
|
67
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.LogoutButton)),
|
|
68
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.ExitToApp, {}),
|
|
69
|
+
link: '/logout',
|
|
70
|
+
requiresAuth: true,
|
|
71
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
72
|
+
index: index++,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'login',
|
|
76
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Login_LoginButton)),
|
|
77
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Login, {}),
|
|
78
|
+
link: '/login',
|
|
79
|
+
requiresAuth: false,
|
|
80
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
81
|
+
index: index++,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: 'register',
|
|
85
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.RegisterButton)),
|
|
86
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.PersonAdd, {}),
|
|
87
|
+
link: '/register',
|
|
88
|
+
requiresAuth: false,
|
|
89
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
90
|
+
index: index++,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 'forgot-password',
|
|
94
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.ForgotPassword_Title)),
|
|
95
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.LockOpen, {}),
|
|
96
|
+
link: '/forgot-password',
|
|
97
|
+
requiresAuth: false,
|
|
98
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
99
|
+
index: index++,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'change-password',
|
|
103
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ChangePassword)),
|
|
104
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.LockReset, {}),
|
|
105
|
+
link: '/change-password',
|
|
106
|
+
requiresAuth: true,
|
|
107
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
108
|
+
index: index++,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: 'backup-code',
|
|
112
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.BackupCodeRecovery_Title)),
|
|
113
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Key, {}),
|
|
114
|
+
link: '/backup-code',
|
|
115
|
+
requiresAuth: false,
|
|
116
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
117
|
+
index: index++,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: 'backup-codes',
|
|
121
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.BackupCodeRecovery_GenerateNewCodes)),
|
|
122
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Autorenew, {}),
|
|
123
|
+
link: '/backup-codes',
|
|
124
|
+
requiresAuth: true,
|
|
125
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
126
|
+
index: index++,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'divider',
|
|
130
|
+
label: '',
|
|
131
|
+
divider: true,
|
|
132
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
133
|
+
index: index++,
|
|
134
|
+
requiresAuth: false,
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: 'clear-mnemonic',
|
|
138
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ClearMnemonic)),
|
|
139
|
+
action: clearMnemonic,
|
|
140
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Key, {}),
|
|
141
|
+
requiresAuth: true,
|
|
142
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
143
|
+
index: index++,
|
|
144
|
+
filter: () => !!mnemonic,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: 'clear-wallet',
|
|
148
|
+
label: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ClearWallet)),
|
|
149
|
+
action: clearWallet,
|
|
150
|
+
icon: (0, jsx_runtime_1.jsx)(icons_material_1.Key, {}),
|
|
151
|
+
requiresAuth: true,
|
|
152
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.UserMenu, IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
153
|
+
index: index++,
|
|
154
|
+
filter: () => !!wallet,
|
|
155
|
+
},
|
|
156
|
+
...(isUserRestricted() ? [] : []),
|
|
157
|
+
{
|
|
158
|
+
id: 'color-divider',
|
|
159
|
+
label: '',
|
|
160
|
+
divider: true,
|
|
161
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
162
|
+
index: index++,
|
|
163
|
+
requiresAuth: undefined,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: 'theme-toggle',
|
|
167
|
+
label: mode === 'dark'
|
|
168
|
+
? t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ThemeToggle_Light))
|
|
169
|
+
: t(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_2.SuiteCoreStringKey.Common_ThemeToggle_Dark)),
|
|
170
|
+
icon: mode === 'dark' ? (0, jsx_runtime_1.jsx)(icons_material_1.Brightness7, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.Brightness4, {}),
|
|
171
|
+
includeOnMenus: [IncludeOnMenu_1.IncludeOnMenu.SideMenu],
|
|
172
|
+
index: index++,
|
|
173
|
+
requiresAuth: undefined,
|
|
174
|
+
action: toggleColorMode,
|
|
175
|
+
},
|
|
176
|
+
];
|
|
177
|
+
const allOptions = [...baseOptions, ...registeredOptions.values()];
|
|
178
|
+
return allOptions.sort((a, b) => a.index - b.index);
|
|
179
|
+
}, [t, tComponent, registeredOptions, user?.roles, mode, toggleColorMode]);
|
|
180
|
+
const getMenuOptions = (0, react_1.useCallback)((menuType, includeDividers) => {
|
|
181
|
+
const MenuFilter = (o) => {
|
|
182
|
+
// Apply the custom filter first
|
|
183
|
+
let customFilterPasses = true;
|
|
184
|
+
if (o.filter !== undefined) {
|
|
185
|
+
customFilterPasses = o.filter(o);
|
|
186
|
+
}
|
|
187
|
+
if (!customFilterPasses)
|
|
188
|
+
return false;
|
|
189
|
+
if (o.divider === true && !includeDividers)
|
|
190
|
+
return false;
|
|
191
|
+
return (o.includeOnMenus.includes(menuType) &&
|
|
192
|
+
(o.requiresAuth === undefined || o.requiresAuth === isAuthenticated));
|
|
193
|
+
};
|
|
194
|
+
return menuOptions.filter(MenuFilter);
|
|
195
|
+
}, [isAuthenticated, menuOptions]);
|
|
196
|
+
const contextValue = (0, react_1.useMemo)(() => {
|
|
197
|
+
return {
|
|
198
|
+
menuOptions: menuOptions,
|
|
199
|
+
getMenuOptions: getMenuOptions,
|
|
200
|
+
registerMenuOption: registerMenuOption,
|
|
201
|
+
registerMenuOptions: registerMenuOptions,
|
|
202
|
+
};
|
|
203
|
+
}, [menuOptions, getMenuOptions, registerMenuOption, registerMenuOptions]);
|
|
204
|
+
const memoizedChildren = (0, react_1.useMemo)(() => children, [children]);
|
|
205
|
+
return ((0, jsx_runtime_1.jsx)(MenuContext.Provider, { value: contextValue, children: memoizedChildren }));
|
|
206
|
+
};
|
|
207
|
+
exports.MenuProvider = MenuProvider;
|
|
208
|
+
const useMenu = () => {
|
|
209
|
+
const context = (0, react_1.useContext)(MenuContext);
|
|
210
|
+
if (context === undefined) {
|
|
211
|
+
throw new Error('useMenu must be used within a MenuProvider');
|
|
212
|
+
}
|
|
213
|
+
return context;
|
|
214
|
+
};
|
|
215
|
+
exports.useMenu = useMenu;
|
package/src/contexts/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
package/src/contexts/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./AuthProvider"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./MenuContext"), exports);
|
|
4
6
|
tslib_1.__exportStar(require("./I18nProvider"), exports);
|
|
5
7
|
tslib_1.__exportStar(require("./ThemeProvider"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/AppConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"AppConfig.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/interfaces/AppConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const mockAuthService: {
|
|
2
|
+
verifyToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
3
|
+
directLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
4
|
+
emailChallengeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
5
|
+
refreshToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
6
|
+
register: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
7
|
+
requestEmailLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
8
|
+
backupCodeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
9
|
+
changePassword: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
10
|
+
};
|
|
11
|
+
export declare const createAuthService: import("jest-mock").Mock<() => {
|
|
12
|
+
verifyToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
13
|
+
directLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
14
|
+
emailChallengeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
15
|
+
refreshToken: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
16
|
+
register: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
17
|
+
requestEmailLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
18
|
+
backupCodeLogin: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
19
|
+
changePassword: import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=authService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-express-suite-react-components/src/services/__mocks__/authService.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;CAS3B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;EAAiC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthService = exports.mockAuthService = void 0;
|
|
4
|
+
const globals_1 = require("@jest/globals");
|
|
5
|
+
exports.mockAuthService = {
|
|
6
|
+
verifyToken: globals_1.jest.fn(),
|
|
7
|
+
directLogin: globals_1.jest.fn(),
|
|
8
|
+
emailChallengeLogin: globals_1.jest.fn(),
|
|
9
|
+
refreshToken: globals_1.jest.fn(),
|
|
10
|
+
register: globals_1.jest.fn(),
|
|
11
|
+
requestEmailLogin: globals_1.jest.fn(),
|
|
12
|
+
backupCodeLogin: globals_1.jest.fn(),
|
|
13
|
+
changePassword: globals_1.jest.fn(),
|
|
14
|
+
};
|
|
15
|
+
exports.createAuthService = globals_1.jest.fn(() => exports.mockAuthService);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { EmailString, IECIESConfig, SecureString } from '@digitaldefiance/ecies-lib';
|
|
2
|
+
import { IConstants, IRequestUserDTO } from '@digitaldefiance/suite-core-lib';
|
|
3
|
+
import { CoreLanguageCode } from '@digitaldefiance/i18n-lib';
|
|
4
|
+
import { Wallet } from '@ethereumjs/wallet';
|
|
5
|
+
interface AuthContextFunctions {
|
|
6
|
+
setUser: (user: IRequestUserDTO | null) => void;
|
|
7
|
+
setLanguage: (lang: CoreLanguageCode) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class AuthService {
|
|
10
|
+
private constants;
|
|
11
|
+
private baseUrl;
|
|
12
|
+
private authContextFunctions;
|
|
13
|
+
private eciesService;
|
|
14
|
+
private cryptoCore;
|
|
15
|
+
private apiClient;
|
|
16
|
+
private authenticatedApiClient;
|
|
17
|
+
constructor(constants: IConstants, baseUrl: string, eciesConfig: IECIESConfig);
|
|
18
|
+
setAuthContextFunctions(functions: AuthContextFunctions): void;
|
|
19
|
+
getSiteDomain(): string;
|
|
20
|
+
register(username: string, email: string, timezone: string, password?: string): Promise<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
message: string;
|
|
23
|
+
mnemonic: string;
|
|
24
|
+
} | {
|
|
25
|
+
error: string;
|
|
26
|
+
errorType?: string;
|
|
27
|
+
field?: string;
|
|
28
|
+
errors?: Array<Record<string, string>>;
|
|
29
|
+
}>;
|
|
30
|
+
directLogin(mnemonic: SecureString, username?: string, email?: EmailString): Promise<{
|
|
31
|
+
token: string;
|
|
32
|
+
user: IRequestUserDTO;
|
|
33
|
+
wallet: Wallet;
|
|
34
|
+
message: string;
|
|
35
|
+
} | {
|
|
36
|
+
error: string;
|
|
37
|
+
errorType?: string;
|
|
38
|
+
}>;
|
|
39
|
+
requestEmailLogin(username?: string, email?: EmailString): Promise<string | {
|
|
40
|
+
error: string;
|
|
41
|
+
errorType?: string;
|
|
42
|
+
}>;
|
|
43
|
+
emailChallengeLogin(mnemonic: SecureString, token: string, username?: string, email?: EmailString): Promise<{
|
|
44
|
+
token: string;
|
|
45
|
+
user: IRequestUserDTO;
|
|
46
|
+
wallet: Wallet;
|
|
47
|
+
message: string;
|
|
48
|
+
} | {
|
|
49
|
+
error: string;
|
|
50
|
+
errorType?: string;
|
|
51
|
+
}>;
|
|
52
|
+
verifyToken(token: string): Promise<IRequestUserDTO | {
|
|
53
|
+
error: string;
|
|
54
|
+
errorType?: string;
|
|
55
|
+
}>;
|
|
56
|
+
refreshToken(): Promise<{
|
|
57
|
+
token: string;
|
|
58
|
+
user: IRequestUserDTO;
|
|
59
|
+
}>;
|
|
60
|
+
changePassword(currentPassword: string, newPassword: string): Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
} | {
|
|
63
|
+
error: string;
|
|
64
|
+
errorType?: string;
|
|
65
|
+
}>;
|
|
66
|
+
backupCodeLogin(identifier: string, code: string, isEmail: boolean, recoverMnemonic: boolean, newPassword?: string): Promise<{
|
|
67
|
+
token: string;
|
|
68
|
+
codeCount: number;
|
|
69
|
+
user?: IRequestUserDTO;
|
|
70
|
+
mnemonic?: string;
|
|
71
|
+
message?: string;
|
|
72
|
+
} | {
|
|
73
|
+
error: string;
|
|
74
|
+
status?: number;
|
|
75
|
+
errorType?: string;
|
|
76
|
+
}>;
|
|
77
|
+
}
|
|
78
|
+
export declare const createAuthService: (constants: IConstants, baseUrl: string, eciesConfig: IECIESConfig) => AuthService;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=authService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/services/authService.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEX,YAAY,EAGZ,YAAY,EAGb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAA2B,UAAU,EAAE,eAAe,EAA8C,MAAM,iCAAiC,CAAC;AACnJ,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAK5C,UAAU,oBAAoB;I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