@frontegg/react-hooks 6.178.0-alpha.2 → 6.178.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/FronteggProvider/index.d.ts +12 -1
- package/FronteggProvider/index.js +133 -1
- package/FronteggStoreContext/index.d.ts +13 -1
- package/FronteggStoreContext/index.js +14 -1
- package/audits/auditLogs.d.ts +4 -2
- package/audits/auditLogs.js +6 -8
- package/audits/auditsMetadata.d.ts +4 -2
- package/audits/auditsMetadata.js +6 -8
- package/audits/hooks.d.ts +8 -0
- package/audits/hooks.js +30 -6
- package/auth/{allAccounts.d.ts → MSP/allAccounts.d.ts} +4 -2
- package/auth/MSP/allAccounts.js +15 -0
- package/auth/acceptInvitation.js +5 -10
- package/auth/activateAccount.js +4 -10
- package/auth/apiTokens.d.ts +2 -0
- package/auth/apiTokens.js +6 -8
- package/auth/customLogin.d.ts +5 -2
- package/auth/customLogin.js +11 -10
- package/auth/entitlements.d.ts +14 -14
- package/auth/entitlements.js +21 -25
- package/auth/forgotPassword.d.ts +2 -0
- package/auth/forgotPassword.js +6 -8
- package/auth/groups.d.ts +4 -0
- package/auth/groups.js +13 -12
- package/auth/hooks.d.ts +11 -10
- package/auth/hooks.js +58 -30
- package/auth/impersonate.d.ts +2 -0
- package/auth/impersonate.js +6 -7
- package/auth/index.d.ts +18 -15
- package/auth/index.js +19 -16
- package/auth/login.d.ts +1 -1
- package/auth/login.js +4 -13
- package/auth/mfa.d.ts +1 -1
- package/auth/mfa.js +4 -13
- package/auth/passkeys.d.ts +4 -1
- package/auth/passkeys.js +6 -7
- package/auth/profile.d.ts +4 -2
- package/auth/profile.js +8 -9
- package/auth/provisioning.d.ts +3 -1
- package/auth/provisioning.js +6 -7
- package/auth/resetPhoneNumber.d.ts +3 -1
- package/auth/resetPhoneNumber.js +6 -7
- package/auth/roles.d.ts +3 -1
- package/auth/roles.js +6 -7
- package/auth/security/restrictions.d.ts +2 -0
- package/auth/security/restrictions.js +10 -10
- package/auth/security/securityCenter.d.ts +4 -1
- package/auth/security/securityCenter.js +6 -8
- package/auth/security/securityPolicy.d.ts +11 -5
- package/auth/security/securityPolicy.js +30 -19
- package/auth/security/sessionsPolicy.d.ts +3 -1
- package/auth/security/sessionsPolicy.js +6 -8
- package/auth/sessions.d.ts +3 -1
- package/auth/sessions.js +6 -7
- package/auth/signup.d.ts +1 -1
- package/auth/signup.js +4 -13
- package/auth/sms.d.ts +4 -1
- package/auth/sms.js +6 -7
- package/auth/socialLogin.d.ts +1 -1
- package/auth/socialLogin.js +4 -10
- package/auth/sso.d.ts +1 -1
- package/auth/sso.js +4 -10
- package/auth/stepUp/index.d.ts +2 -0
- package/auth/stepUp/index.js +2 -0
- package/auth/stepUp/interfaces.d.ts +2 -0
- package/auth/stepUp/interfaces.js +1 -0
- package/auth/{stepUp.d.ts → stepUp/stepUp.d.ts} +2 -0
- package/auth/{stepUp.js → stepUp/stepUp.js} +6 -9
- package/auth/team.d.ts +1 -9
- package/auth/team.js +4 -22
- package/auth/tenants.d.ts +3 -1
- package/auth/tenants.js +6 -8
- package/common/CustomComponentHolder.js +1 -3
- package/common/index.js +3 -3
- package/connectivity/hooks.d.ts +5 -2
- package/connectivity/hooks.js +9 -6
- package/index.d.ts +2 -2
- package/index.js +3 -3
- package/node/FronteggProvider/index.js +134 -9
- package/node/FronteggStoreContext/index.js +35 -11
- package/node/audits/auditLogs.js +6 -8
- package/node/audits/auditsMetadata.js +6 -8
- package/node/audits/hooks.js +34 -7
- package/node/auth/MSP/allAccounts.js +24 -0
- package/node/auth/acceptInvitation.js +5 -7
- package/node/auth/activateAccount.js +4 -7
- package/node/auth/apiTokens.js +6 -8
- package/node/auth/customLogin.js +12 -11
- package/node/auth/entitlements.js +20 -24
- package/node/auth/forgotPassword.js +6 -8
- package/node/auth/groups.js +12 -12
- package/node/auth/hooks.js +62 -33
- package/node/auth/impersonate.js +6 -7
- package/node/auth/index.js +120 -91
- package/node/auth/login.js +4 -10
- package/node/auth/mfa.js +4 -10
- package/node/auth/passkeys.js +6 -7
- package/node/auth/profile.js +9 -10
- package/node/auth/provisioning.js +6 -7
- package/node/auth/resetPhoneNumber.js +6 -7
- package/node/auth/roles.js +6 -7
- package/node/auth/security/restrictions.js +10 -10
- package/node/auth/security/securityCenter.js +6 -8
- package/node/auth/security/securityPolicy.js +30 -16
- package/node/auth/security/sessionsPolicy.js +6 -8
- package/node/auth/sessions.js +6 -7
- package/node/auth/signup.js +4 -10
- package/node/auth/sms.js +6 -7
- package/node/auth/socialLogin.js +4 -7
- package/node/auth/sso.js +4 -7
- package/node/auth/stepUp/index.js +27 -0
- package/node/auth/stepUp/interfaces.js +5 -0
- package/node/auth/{stepUp.js → stepUp/stepUp.js} +7 -10
- package/node/auth/team.js +4 -25
- package/node/auth/tenants.js +6 -8
- package/node/common/CustomComponentHolder.js +1 -3
- package/node/common/index.js +2 -2
- package/node/connectivity/hooks.js +8 -5
- package/node/index.js +16 -16
- package/node/subscriptions/hooks.js +51 -84
- package/node/tests/hooks.tsc-test.js +318 -0
- package/node/vendor/hooks.js +6 -5
- package/package.json +3 -3
- package/subscriptions/hooks.d.ts +10 -32
- package/subscriptions/hooks.js +49 -81
- package/tests/hooks.tsc-test.js +317 -0
- package/vendor/hooks.d.ts +1 -0
- package/vendor/hooks.js +7 -9
- package/FronteggProvider/FronteggProvider.d.ts +0 -12
- package/FronteggProvider/FronteggProvider.js +0 -134
- package/FronteggStoreContext/FronteggStoreContext.d.ts +0 -9
- package/FronteggStoreContext/FronteggStoreContext.js +0 -16
- package/auth/allAccounts.js +0 -20
- package/auth/security/index.d.ts +0 -4
- package/auth/security/index.js +0 -4
- package/node/FronteggProvider/FronteggProvider.js +0 -140
- package/node/FronteggStoreContext/FronteggStoreContext.js +0 -26
- package/node/auth/allAccounts.js +0 -27
- package/node/auth/security/index.js +0 -49
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// noinspection JSUnusedLocalSymbols
|
|
2
|
+
|
|
3
|
+
import { useAcceptInvitationActions, useAcceptInvitationState, useActivateAccountActions, useActivateAccountState, useApiTokensActions, useApiTokensState, useAuditsActions, useAuditsState, useAuth, useAuthActions, useConnectivityActions, useConnectivityState, useForgotPasswordActions, useForgotPasswordState, useLoginActions, useLoginState, useMfaActions, useMfaState, useProfileActions, useProfileState, useResetPhoneNumberActions, useResetPhoneNumberState, useRolesActions, useRolesState, useSecurityPolicyActions, useSecurityPolicyState, useSessionsActions, useSessionsPolicyActions, useSessionsPolicyState, useSessionsState, useSignUpActions, useSignUpState, useSocialLoginActions, useSocialLoginState, useSSOActions, useSSOState, useTenantsActions, useTenantsState, useVendorActions, useVendorState } from '../index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* useAuth hook typescript tests
|
|
7
|
+
*/
|
|
8
|
+
{
|
|
9
|
+
const {
|
|
10
|
+
isAuthenticated,
|
|
11
|
+
isLoading
|
|
12
|
+
} = useAuth();
|
|
13
|
+
const isLoadingDirect = useAuth(state => state.isLoading);
|
|
14
|
+
isLoadingDirect.valueOf();
|
|
15
|
+
const {
|
|
16
|
+
user
|
|
17
|
+
} = useAuth(state => ({
|
|
18
|
+
user: state.user
|
|
19
|
+
}));
|
|
20
|
+
const {
|
|
21
|
+
loginUrl
|
|
22
|
+
} = useAuth(state => state.routes);
|
|
23
|
+
const {
|
|
24
|
+
loadProfile,
|
|
25
|
+
setLoginState
|
|
26
|
+
} = useAuthActions();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* useAcceptInvitationState hook typescript tests
|
|
31
|
+
*/
|
|
32
|
+
{
|
|
33
|
+
const {
|
|
34
|
+
step
|
|
35
|
+
} = useAcceptInvitationState();
|
|
36
|
+
const errorDirect = useAcceptInvitationState(state => state.error);
|
|
37
|
+
errorDirect == null ? void 0 : errorDirect.substring(0);
|
|
38
|
+
const {
|
|
39
|
+
acceptInvitation
|
|
40
|
+
} = useAcceptInvitationActions();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* useActivateAccountState hook typescript tests
|
|
45
|
+
*/
|
|
46
|
+
{
|
|
47
|
+
const {
|
|
48
|
+
step
|
|
49
|
+
} = useActivateAccountState();
|
|
50
|
+
const loadingDirect = useActivateAccountState(state => state.loading);
|
|
51
|
+
loadingDirect.valueOf();
|
|
52
|
+
const {
|
|
53
|
+
activateAccount
|
|
54
|
+
} = useActivateAccountActions();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* useApiTokensState hook typescript tests
|
|
59
|
+
*/
|
|
60
|
+
{
|
|
61
|
+
const {
|
|
62
|
+
roles
|
|
63
|
+
} = useApiTokensState();
|
|
64
|
+
const loadingDirect = useApiTokensState(state => state.loaders);
|
|
65
|
+
let m = loadingDirect.LOAD_API_TOKENS;
|
|
66
|
+
const {
|
|
67
|
+
loadUserApiTokens
|
|
68
|
+
} = useApiTokensActions();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* useForgotPasswordState hook typescript tests
|
|
73
|
+
*/
|
|
74
|
+
{
|
|
75
|
+
const {
|
|
76
|
+
step
|
|
77
|
+
} = useForgotPasswordState();
|
|
78
|
+
const emailDirect = useForgotPasswordState(state => state.email);
|
|
79
|
+
emailDirect.substring(0);
|
|
80
|
+
const {
|
|
81
|
+
forgotPassword
|
|
82
|
+
} = useForgotPasswordActions();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* useMfaState hook typescript tests
|
|
87
|
+
*/
|
|
88
|
+
{
|
|
89
|
+
const {
|
|
90
|
+
step
|
|
91
|
+
} = useMfaState();
|
|
92
|
+
const loadingDirect = useMfaState(state => state.loading);
|
|
93
|
+
loadingDirect.valueOf();
|
|
94
|
+
const {
|
|
95
|
+
enrollMfa
|
|
96
|
+
} = useMfaActions();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* useLoginState hook typescript tests
|
|
101
|
+
*/
|
|
102
|
+
{
|
|
103
|
+
const {
|
|
104
|
+
step
|
|
105
|
+
} = useLoginState();
|
|
106
|
+
const loadingDirect = useLoginState(state => state.loading);
|
|
107
|
+
loadingDirect.valueOf();
|
|
108
|
+
const {
|
|
109
|
+
logout
|
|
110
|
+
} = useLoginActions();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* useLoginState hook typescript tests
|
|
115
|
+
*/
|
|
116
|
+
{
|
|
117
|
+
const {
|
|
118
|
+
profile
|
|
119
|
+
} = useProfileState();
|
|
120
|
+
const loadingDirect = useProfileState(state => state.loading);
|
|
121
|
+
loadingDirect.valueOf();
|
|
122
|
+
const {
|
|
123
|
+
loadProfile
|
|
124
|
+
} = useProfileActions();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* useResetPhoneNumberState hook typescript tests
|
|
129
|
+
*/
|
|
130
|
+
{
|
|
131
|
+
const {
|
|
132
|
+
step
|
|
133
|
+
} = useResetPhoneNumberState();
|
|
134
|
+
const loadingDirect = useResetPhoneNumberState(state => state.loading);
|
|
135
|
+
loadingDirect.valueOf();
|
|
136
|
+
const {
|
|
137
|
+
resetPhoneNumber
|
|
138
|
+
} = useResetPhoneNumberActions();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* useRolesState hook typescript tests
|
|
143
|
+
*/
|
|
144
|
+
{
|
|
145
|
+
const {
|
|
146
|
+
saving
|
|
147
|
+
} = useRolesState();
|
|
148
|
+
const loadingDirect = useRolesState(state => state.loading);
|
|
149
|
+
loadingDirect.valueOf();
|
|
150
|
+
const {
|
|
151
|
+
loadRolesAndPermissions
|
|
152
|
+
} = useRolesActions();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* useSecurityPolicyState hook typescript tests
|
|
157
|
+
*/
|
|
158
|
+
{
|
|
159
|
+
const {
|
|
160
|
+
lockoutPolicy
|
|
161
|
+
} = useSecurityPolicyState();
|
|
162
|
+
const captchaPolicy = useSecurityPolicyState(state => state.captchaPolicy);
|
|
163
|
+
captchaPolicy.loading.valueOf();
|
|
164
|
+
const {
|
|
165
|
+
loadPublicSecurityPolicy
|
|
166
|
+
} = useSecurityPolicyActions();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* useSessionsState hook typescript tests
|
|
171
|
+
*/
|
|
172
|
+
{
|
|
173
|
+
const {
|
|
174
|
+
sessions
|
|
175
|
+
} = useSessionsState();
|
|
176
|
+
const loadingDirect = useSessionsState(state => state.loading);
|
|
177
|
+
loadingDirect.valueOf();
|
|
178
|
+
const {
|
|
179
|
+
deleteUserSession
|
|
180
|
+
} = useSessionsActions();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* useSessionsPolicyState hook typescript tests
|
|
185
|
+
*/
|
|
186
|
+
{
|
|
187
|
+
const {
|
|
188
|
+
configurations
|
|
189
|
+
} = useSessionsPolicyState();
|
|
190
|
+
const loadingDirect = useSessionsPolicyState(state => state.loading);
|
|
191
|
+
loadingDirect.valueOf();
|
|
192
|
+
const {
|
|
193
|
+
resetSessionsPolicyState
|
|
194
|
+
} = useSessionsPolicyActions();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* useSSOState hook typescript tests
|
|
199
|
+
*/
|
|
200
|
+
{
|
|
201
|
+
const {
|
|
202
|
+
authorizationRoles
|
|
203
|
+
} = useSSOState();
|
|
204
|
+
const loadingDirect = useSSOState(state => state.loading);
|
|
205
|
+
loadingDirect.valueOf();
|
|
206
|
+
const {
|
|
207
|
+
loadSSOConfigurationsV2
|
|
208
|
+
} = useSSOActions();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* useSignUpState hook typescript tests
|
|
213
|
+
*/
|
|
214
|
+
{
|
|
215
|
+
const {
|
|
216
|
+
stage
|
|
217
|
+
} = useSignUpState();
|
|
218
|
+
const loadingDirect = useSignUpState(state => state.loading);
|
|
219
|
+
loadingDirect.valueOf();
|
|
220
|
+
const {
|
|
221
|
+
setSignUpState
|
|
222
|
+
} = useSignUpActions();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* useSocialLoginState hook typescript tests
|
|
227
|
+
*/
|
|
228
|
+
{
|
|
229
|
+
const {
|
|
230
|
+
socialLoginsConfig
|
|
231
|
+
} = useSocialLoginState();
|
|
232
|
+
const loadingDirect = useSocialLoginState(state => state.loading);
|
|
233
|
+
loadingDirect.valueOf();
|
|
234
|
+
const {
|
|
235
|
+
loadSocialLoginsConfiguration
|
|
236
|
+
} = useSocialLoginActions();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* useSocialLoginState hook typescript tests
|
|
241
|
+
*/
|
|
242
|
+
{
|
|
243
|
+
const {
|
|
244
|
+
tenants
|
|
245
|
+
} = useTenantsState();
|
|
246
|
+
const loadingDirect = useTenantsState(state => state.loading);
|
|
247
|
+
loadingDirect.valueOf();
|
|
248
|
+
const {
|
|
249
|
+
loadTenants
|
|
250
|
+
} = useTenantsActions();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* useVendorState hook typescript tests
|
|
255
|
+
*/
|
|
256
|
+
{
|
|
257
|
+
const {
|
|
258
|
+
loading
|
|
259
|
+
} = useVendorState();
|
|
260
|
+
const isLoadingDirect = useVendorState(state => state.loading);
|
|
261
|
+
isLoadingDirect.valueOf();
|
|
262
|
+
const {
|
|
263
|
+
whiteLabelMode
|
|
264
|
+
} = useVendorState(state => ({
|
|
265
|
+
whiteLabelMode: state.whiteLabelMode
|
|
266
|
+
}));
|
|
267
|
+
const {
|
|
268
|
+
loadVendorPublicInfo
|
|
269
|
+
} = useVendorActions();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* useConnectivityState hook typescript tests
|
|
274
|
+
*/
|
|
275
|
+
{
|
|
276
|
+
const {
|
|
277
|
+
isLoading,
|
|
278
|
+
error
|
|
279
|
+
} = useConnectivityState();
|
|
280
|
+
const processIds = useConnectivityState(state => state.processIds);
|
|
281
|
+
processIds.map(id => id);
|
|
282
|
+
const {
|
|
283
|
+
email
|
|
284
|
+
} = useConnectivityState(state => {
|
|
285
|
+
var _state$email;
|
|
286
|
+
return {
|
|
287
|
+
email: (_state$email = state.email) != null ? _state$email : []
|
|
288
|
+
};
|
|
289
|
+
});
|
|
290
|
+
email.length;
|
|
291
|
+
const {
|
|
292
|
+
loadScope,
|
|
293
|
+
loadDataAction
|
|
294
|
+
} = useConnectivityActions();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* useAuditsState hook typescript tests
|
|
299
|
+
*/
|
|
300
|
+
{
|
|
301
|
+
const {
|
|
302
|
+
auditLogsState
|
|
303
|
+
} = useAuditsState();
|
|
304
|
+
const {
|
|
305
|
+
columns
|
|
306
|
+
} = useAuditsState(state => state.auditsMetadataState);
|
|
307
|
+
const {
|
|
308
|
+
loading
|
|
309
|
+
} = useAuditsState(state => ({
|
|
310
|
+
loading: state.auditLogsState.loading
|
|
311
|
+
}));
|
|
312
|
+
loading.valueOf();
|
|
313
|
+
let x = columns == null ? void 0 : columns.length;
|
|
314
|
+
const {
|
|
315
|
+
loadAuditLogs
|
|
316
|
+
} = useAuditsActions();
|
|
317
|
+
}
|
package/vendor/hooks.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VendorActions, VendorState } from '@frontegg/redux-store';
|
|
2
2
|
export declare type VendorStateMapper<S> = (state: VendorState) => S;
|
|
3
|
+
export declare type StateHookFunction<T> = (() => T) & (<S extends object>(mapper: (state: T) => S) => S);
|
|
3
4
|
export declare function useVendorState(): VendorState;
|
|
4
5
|
export declare function useVendorState<S>(stateMapper: VendorStateMapper<S>): S;
|
|
5
6
|
export declare const useVendorActions: () => VendorActions;
|
package/vendor/hooks.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { bindActionCreators, vendorActions, vendorStoreName } from '@frontegg/redux-store';
|
|
3
|
+
import { shallowEqual } from 'react-redux';
|
|
4
|
+
import { useSelector, useDispatch } from '../FronteggStoreContext';
|
|
6
5
|
const defaultMapper = state => state;
|
|
7
|
-
// @deprecated use useVendorState() instead
|
|
8
6
|
export function useVendorState(stateMapper = defaultMapper) {
|
|
9
|
-
|
|
10
|
-
return stateMapper(useSnapshot(state));
|
|
7
|
+
return useSelector(state => stateMapper(state[vendorStoreName]), shallowEqual);
|
|
11
8
|
}
|
|
12
9
|
export const useVendorActions = () => {
|
|
13
|
-
|
|
10
|
+
const dispatch = useDispatch();
|
|
11
|
+
return useMemo(() => bindActionCreators(vendorActions, dispatch), [vendorActions]);
|
|
14
12
|
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
import { ContextOptions } from '@frontegg/rest-api';
|
|
3
|
-
declare type FronteggAppInstance = any;
|
|
4
|
-
declare type FronteggProviderProps = {
|
|
5
|
-
app?: FronteggAppInstance;
|
|
6
|
-
contextOptions?: ContextOptions;
|
|
7
|
-
setLoading?: (loading: boolean) => void;
|
|
8
|
-
children?: ReactNode | undefined;
|
|
9
|
-
alwaysVisibleChildren?: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
export declare const FronteggStoreProvider: FC<FronteggProviderProps>;
|
|
12
|
-
export {};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["authenticatedUrl", "signUpSuccessUrl"];
|
|
4
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import { createStore } from '@frontegg/redux-store';
|
|
6
|
-
import { ContextHolder } from '@frontegg/rest-api';
|
|
7
|
-
import { Provider } from '../FronteggStoreContext';
|
|
8
|
-
import { useAuth, useAuthRoutes } from '../auth';
|
|
9
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
const defaultSetLoading = loading => {
|
|
13
|
-
if (loading) {
|
|
14
|
-
document.body.classList.add('frontegg-loading');
|
|
15
|
-
} else {
|
|
16
|
-
document.body.classList.remove('frontegg-loading');
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const HideChildrenIfFronteggRoutes = ({
|
|
20
|
-
children,
|
|
21
|
-
basename
|
|
22
|
-
}) => {
|
|
23
|
-
const routes = useAuthRoutes();
|
|
24
|
-
const uriRef = useRef(window.location.pathname);
|
|
25
|
-
const animationFrameRef = useRef(0);
|
|
26
|
-
const [uri, setUri] = useState(window.location.pathname);
|
|
27
|
-
const checker = useCallback(() => {
|
|
28
|
-
if (uriRef.current !== window.location.pathname) {
|
|
29
|
-
uriRef.current = window.location.pathname;
|
|
30
|
-
setUri(document.location.pathname);
|
|
31
|
-
}
|
|
32
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
33
|
-
}, []);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
document.addEventListener('frontegg_onRedirectTo_fired', () => {
|
|
36
|
-
if (uriRef.current !== window.location.pathname) {
|
|
37
|
-
uriRef.current = window.location.pathname;
|
|
38
|
-
setUri(document.location.pathname);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
window.addEventListener('popstate', () => {
|
|
42
|
-
if (uriRef.current !== window.location.pathname) {
|
|
43
|
-
uriRef.current = window.location.pathname;
|
|
44
|
-
setUri(document.location.pathname);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
48
|
-
return () => {
|
|
49
|
-
window.cancelAnimationFrame(animationFrameRef.current);
|
|
50
|
-
};
|
|
51
|
-
}, [checker, setUri]);
|
|
52
|
-
const calculatedBasename = basename ? basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '' : '';
|
|
53
|
-
const checkRoutes = _objectWithoutPropertiesLoose(routes, _excluded);
|
|
54
|
-
if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
58
|
-
children: children
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const FronteggContent = ({
|
|
62
|
-
children,
|
|
63
|
-
app,
|
|
64
|
-
setLoading
|
|
65
|
-
}) => {
|
|
66
|
-
var _app$options, _app$options2;
|
|
67
|
-
const {
|
|
68
|
-
isLoading
|
|
69
|
-
} = useAuth();
|
|
70
|
-
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
71
|
-
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
72
|
-
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
73
|
-
const loadingRef = useRef(undefined);
|
|
74
|
-
if (isLoading !== loadingRef.current && !isNextJS) {
|
|
75
|
-
loadingRef.current = isLoading;
|
|
76
|
-
setLoading(isLoading);
|
|
77
|
-
}
|
|
78
|
-
if (alwaysShowChildren) {
|
|
79
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
80
|
-
children: children
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (isLoading && !isNextJS) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
return /*#__PURE__*/_jsx(HideChildrenIfFronteggRoutes, {
|
|
87
|
-
basename: app == null ? void 0 : app.options.basename,
|
|
88
|
-
children: children
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
export const FronteggStoreProvider = props => {
|
|
92
|
-
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options5, _app$options6;
|
|
93
|
-
const {
|
|
94
|
-
children,
|
|
95
|
-
app,
|
|
96
|
-
contextOptions,
|
|
97
|
-
setLoading = defaultSetLoading,
|
|
98
|
-
alwaysVisibleChildren
|
|
99
|
-
} = props;
|
|
100
|
-
|
|
101
|
-
// TODO: make this optionals more readable
|
|
102
|
-
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
103
|
-
if (!context) {
|
|
104
|
-
throw Error('contextOptions must not be null or undefined');
|
|
105
|
-
}
|
|
106
|
-
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
107
|
-
const authOptions = app != null && (_app$options5 = app.options) != null && _app$options5.authOptions ? _extends({}, app.options.authOptions, {
|
|
108
|
-
hostedLoginBox: app.options.hostedLoginBox
|
|
109
|
-
}) : {
|
|
110
|
-
hostedLoginBox: app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.hostedLoginBox
|
|
111
|
-
};
|
|
112
|
-
ContextHolder.setContext(context);
|
|
113
|
-
const store = useMemo(() => {
|
|
114
|
-
var _app$name, _app$options7;
|
|
115
|
-
return createStore({
|
|
116
|
-
name: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default',
|
|
117
|
-
context,
|
|
118
|
-
previewMode,
|
|
119
|
-
initialState: {
|
|
120
|
-
auth: authOptions
|
|
121
|
-
},
|
|
122
|
-
urlStrategy: app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy,
|
|
123
|
-
storeHolder: app
|
|
124
|
-
});
|
|
125
|
-
}, [app, previewMode]);
|
|
126
|
-
return /*#__PURE__*/_jsxs(Provider, {
|
|
127
|
-
store: store,
|
|
128
|
-
children: [alwaysVisibleChildren, /*#__PURE__*/_jsx(FronteggContent, {
|
|
129
|
-
setLoading: setLoading,
|
|
130
|
-
app: app,
|
|
131
|
-
children: children
|
|
132
|
-
})]
|
|
133
|
-
});
|
|
134
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
import type { FronteggStore } from '@frontegg/redux-store';
|
|
3
|
-
export declare const FronteggStoreContext: import("react").Context<FronteggStore>;
|
|
4
|
-
export declare const useStore: () => FronteggStore;
|
|
5
|
-
export declare const Provider: FC<{
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
store: FronteggStore;
|
|
8
|
-
}>;
|
|
9
|
-
export default FronteggStoreContext;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createContext, memo, useContext } from 'react';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
export const FronteggStoreContext = /*#__PURE__*/createContext(null);
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7
|
-
FronteggStoreContext.displayName = 'FronteggStoreContext';
|
|
8
|
-
}
|
|
9
|
-
export const useStore = () => useContext(FronteggStoreContext);
|
|
10
|
-
export const Provider = /*#__PURE__*/memo(props => {
|
|
11
|
-
return /*#__PURE__*/_jsx(FronteggStoreContext.Provider, {
|
|
12
|
-
value: props.store,
|
|
13
|
-
children: props.children
|
|
14
|
-
});
|
|
15
|
-
}, () => true);
|
|
16
|
-
export default FronteggStoreContext;
|
package/auth/allAccounts.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useStore } from '../FronteggStoreContext';
|
|
2
|
-
import { useSnapshot } from 'valtio/react';
|
|
3
|
-
|
|
4
|
-
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
-
|
|
6
|
-
const defaultMapper = state => state;
|
|
7
|
-
export function useAllAccountsState(stateMapper = defaultMapper) {
|
|
8
|
-
const state = useStore().store.auth.allAccountsState;
|
|
9
|
-
return stateMapper(useSnapshot(state));
|
|
10
|
-
}
|
|
11
|
-
export const useAllAccountsActions = () => {
|
|
12
|
-
return useStore().stateActions.auth.allAccountsActions;
|
|
13
|
-
};
|
|
14
|
-
export function useAllAccountsDialogsState() {
|
|
15
|
-
const state = useStore().store.auth.allAccountsDialogsState;
|
|
16
|
-
return useSnapshot(state);
|
|
17
|
-
}
|
|
18
|
-
export const useAllAccountsDialogsActions = () => {
|
|
19
|
-
return useStore().stateActions.auth.allAccountsDialogActions;
|
|
20
|
-
};
|
package/auth/security/index.d.ts
DELETED
package/auth/security/index.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.FronteggStoreProvider = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
var _reduxStore = require("@frontegg/redux-store");
|
|
12
|
-
var _restApi = require("@frontegg/rest-api");
|
|
13
|
-
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
14
|
-
var _auth = require("../auth");
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
const _excluded = ["authenticatedUrl", "signUpSuccessUrl"];
|
|
17
|
-
const defaultSetLoading = loading => {
|
|
18
|
-
if (loading) {
|
|
19
|
-
document.body.classList.add('frontegg-loading');
|
|
20
|
-
} else {
|
|
21
|
-
document.body.classList.remove('frontegg-loading');
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const HideChildrenIfFronteggRoutes = ({
|
|
25
|
-
children,
|
|
26
|
-
basename
|
|
27
|
-
}) => {
|
|
28
|
-
const routes = (0, _auth.useAuthRoutes)();
|
|
29
|
-
const uriRef = (0, _react.useRef)(window.location.pathname);
|
|
30
|
-
const animationFrameRef = (0, _react.useRef)(0);
|
|
31
|
-
const [uri, setUri] = (0, _react.useState)(window.location.pathname);
|
|
32
|
-
const checker = (0, _react.useCallback)(() => {
|
|
33
|
-
if (uriRef.current !== window.location.pathname) {
|
|
34
|
-
uriRef.current = window.location.pathname;
|
|
35
|
-
setUri(document.location.pathname);
|
|
36
|
-
}
|
|
37
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
38
|
-
}, []);
|
|
39
|
-
(0, _react.useEffect)(() => {
|
|
40
|
-
document.addEventListener('frontegg_onRedirectTo_fired', () => {
|
|
41
|
-
if (uriRef.current !== window.location.pathname) {
|
|
42
|
-
uriRef.current = window.location.pathname;
|
|
43
|
-
setUri(document.location.pathname);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
window.addEventListener('popstate', () => {
|
|
47
|
-
if (uriRef.current !== window.location.pathname) {
|
|
48
|
-
uriRef.current = window.location.pathname;
|
|
49
|
-
setUri(document.location.pathname);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
53
|
-
return () => {
|
|
54
|
-
window.cancelAnimationFrame(animationFrameRef.current);
|
|
55
|
-
};
|
|
56
|
-
}, [checker, setUri]);
|
|
57
|
-
const calculatedBasename = basename ? basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '' : '';
|
|
58
|
-
const checkRoutes = (0, _objectWithoutPropertiesLoose2.default)(routes, _excluded);
|
|
59
|
-
if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
63
|
-
children: children
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
const FronteggContent = ({
|
|
67
|
-
children,
|
|
68
|
-
app,
|
|
69
|
-
setLoading
|
|
70
|
-
}) => {
|
|
71
|
-
var _app$options, _app$options2;
|
|
72
|
-
const {
|
|
73
|
-
isLoading
|
|
74
|
-
} = (0, _auth.useAuth)();
|
|
75
|
-
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
76
|
-
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
77
|
-
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
78
|
-
const loadingRef = (0, _react.useRef)(undefined);
|
|
79
|
-
if (isLoading !== loadingRef.current && !isNextJS) {
|
|
80
|
-
loadingRef.current = isLoading;
|
|
81
|
-
setLoading(isLoading);
|
|
82
|
-
}
|
|
83
|
-
if (alwaysShowChildren) {
|
|
84
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
85
|
-
children: children
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (isLoading && !isNextJS) {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HideChildrenIfFronteggRoutes, {
|
|
92
|
-
basename: app == null ? void 0 : app.options.basename,
|
|
93
|
-
children: children
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
const FronteggStoreProvider = props => {
|
|
97
|
-
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options5, _app$options6;
|
|
98
|
-
const {
|
|
99
|
-
children,
|
|
100
|
-
app,
|
|
101
|
-
contextOptions,
|
|
102
|
-
setLoading = defaultSetLoading,
|
|
103
|
-
alwaysVisibleChildren
|
|
104
|
-
} = props;
|
|
105
|
-
|
|
106
|
-
// TODO: make this optionals more readable
|
|
107
|
-
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
108
|
-
if (!context) {
|
|
109
|
-
throw Error('contextOptions must not be null or undefined');
|
|
110
|
-
}
|
|
111
|
-
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
112
|
-
const authOptions = app != null && (_app$options5 = app.options) != null && _app$options5.authOptions ? (0, _extends2.default)({}, app.options.authOptions, {
|
|
113
|
-
hostedLoginBox: app.options.hostedLoginBox
|
|
114
|
-
}) : {
|
|
115
|
-
hostedLoginBox: app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.hostedLoginBox
|
|
116
|
-
};
|
|
117
|
-
_restApi.ContextHolder.setContext(context);
|
|
118
|
-
const store = (0, _react.useMemo)(() => {
|
|
119
|
-
var _app$name, _app$options7;
|
|
120
|
-
return (0, _reduxStore.createStore)({
|
|
121
|
-
name: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default',
|
|
122
|
-
context,
|
|
123
|
-
previewMode,
|
|
124
|
-
initialState: {
|
|
125
|
-
auth: authOptions
|
|
126
|
-
},
|
|
127
|
-
urlStrategy: app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy,
|
|
128
|
-
storeHolder: app
|
|
129
|
-
});
|
|
130
|
-
}, [app, previewMode]);
|
|
131
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_FronteggStoreContext.Provider, {
|
|
132
|
-
store: store,
|
|
133
|
-
children: [alwaysVisibleChildren, /*#__PURE__*/(0, _jsxRuntime.jsx)(FronteggContent, {
|
|
134
|
-
setLoading: setLoading,
|
|
135
|
-
app: app,
|
|
136
|
-
children: children
|
|
137
|
-
})]
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
exports.FronteggStoreProvider = FronteggStoreProvider;
|