@frontegg/redux-store 7.76.0-alpha.2 → 7.76.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/auth/ForgotPasswordState/actions.d.ts +4 -1
- package/auth/ForgotPasswordState/actions.js +101 -9
- package/auth/ForgotPasswordState/interfaces.d.ts +10 -2
- package/auth/ForgotPasswordState/state.js +5 -0
- package/index.js +1 -1
- package/mocks/auth-mocks/forgotPasswordActions.mocks.d.ts +3 -0
- package/node/auth/ForgotPasswordState/actions.js +101 -9
- package/node/auth/ForgotPasswordState/state.js +5 -0
- package/node/index.js +1 -1
- package/node/toolkit/FronteggNativeModule.js +20 -0
- package/package.json +2 -2
- package/toolkit/FronteggNativeModule.d.ts +9 -0
- package/toolkit/FronteggNativeModule.js +20 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IGetUserPasswordConfig } from '@frontegg/rest-api';
|
|
2
2
|
import type { FronteggState, RestApi, SharedActions } from '../../interfaces';
|
|
3
|
-
import type { ForgotPasswordState, IForgotPasswordPayload, IResetPasswordPayload, IDeterminePasswordRecoveryStrategyPayload } from './interfaces';
|
|
3
|
+
import type { ForgotPasswordState, IForgotPasswordPayload, IResetPasswordPayload, IDeterminePasswordRecoveryStrategyPayload, IVerifyPasswordViaSmsPayload } from './interfaces';
|
|
4
4
|
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
|
|
5
5
|
setForgotPasswordState: (payload: Partial<ForgotPasswordState>) => void;
|
|
6
6
|
resetForgotPasswordState: () => void;
|
|
@@ -8,5 +8,8 @@ declare const _default: (store: FronteggState, api: RestApi, sharedActions: Shar
|
|
|
8
8
|
resetPassword: (payload: IResetPasswordPayload) => Promise<void>;
|
|
9
9
|
loadPasswordConfig: (payload?: IGetUserPasswordConfig) => Promise<void>;
|
|
10
10
|
determinePasswordRecoveryStrategy: (payload: IDeterminePasswordRecoveryStrategyPayload) => Promise<void>;
|
|
11
|
+
sendPasswordRecoveryEmail: () => Promise<void>;
|
|
12
|
+
sendPasswordRecoverySms: () => Promise<void>;
|
|
13
|
+
verifyPasswordViaSms: (payload: IVerifyPasswordViaSmsPayload) => Promise<void>;
|
|
11
14
|
};
|
|
12
15
|
export default _default;
|
|
@@ -34,11 +34,100 @@ export default ((store, api, sharedActions) => {
|
|
|
34
34
|
(_payload$callback2 = payload.callback) == null ? void 0 : _payload$callback2.call(payload, false, e);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
+
const sendPasswordRecoveryEmail = async () => {
|
|
38
|
+
const {
|
|
39
|
+
identifier,
|
|
40
|
+
identifierType
|
|
41
|
+
} = store.auth.forgotPasswordState;
|
|
42
|
+
setForgotPasswordState({
|
|
43
|
+
loading: true
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
await api.auth.resetPasswordViaEmail({
|
|
47
|
+
identifier,
|
|
48
|
+
identifierType
|
|
49
|
+
});
|
|
50
|
+
setForgotPasswordState({
|
|
51
|
+
loading: false,
|
|
52
|
+
error: undefined,
|
|
53
|
+
step: ForgotPasswordStep.success
|
|
54
|
+
});
|
|
55
|
+
} catch (e) {
|
|
56
|
+
setForgotPasswordState({
|
|
57
|
+
loading: false,
|
|
58
|
+
error: errorHandler(e, 'An error occurred while sending recovery email')
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const sendPasswordRecoverySms = async () => {
|
|
63
|
+
const {
|
|
64
|
+
identifier,
|
|
65
|
+
identifierType
|
|
66
|
+
} = store.auth.forgotPasswordState;
|
|
67
|
+
setForgotPasswordState({
|
|
68
|
+
loading: true
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
const response = await api.auth.resetPasswordViaSms({
|
|
72
|
+
identifier,
|
|
73
|
+
identifierType
|
|
74
|
+
});
|
|
75
|
+
setForgotPasswordState({
|
|
76
|
+
loading: false,
|
|
77
|
+
error: undefined,
|
|
78
|
+
sessionId: response.sessionId
|
|
79
|
+
});
|
|
80
|
+
} catch (e) {
|
|
81
|
+
setForgotPasswordState({
|
|
82
|
+
loading: false,
|
|
83
|
+
error: errorHandler(e, 'An error occurred while sending recovery sms')
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const verifyPasswordViaSms = async payload => {
|
|
88
|
+
const {
|
|
89
|
+
sessionId
|
|
90
|
+
} = store.auth.forgotPasswordState;
|
|
91
|
+
if (!sessionId) {
|
|
92
|
+
const error = 'Session ID not found in state for verifying password via sms.';
|
|
93
|
+
setForgotPasswordState({
|
|
94
|
+
loading: false,
|
|
95
|
+
error
|
|
96
|
+
});
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
setForgotPasswordState({
|
|
100
|
+
loading: true
|
|
101
|
+
});
|
|
102
|
+
try {
|
|
103
|
+
const response = await api.auth.verifyPasswordViaSms({
|
|
104
|
+
otcToken: payload.otcToken,
|
|
105
|
+
sessionId
|
|
106
|
+
});
|
|
107
|
+
if (!response.userId || !response.token) {
|
|
108
|
+
const error = 'Invalid response from server: missing userId or token';
|
|
109
|
+
throw new Error(error);
|
|
110
|
+
}
|
|
111
|
+
setForgotPasswordState({
|
|
112
|
+
loading: false,
|
|
113
|
+
error: undefined,
|
|
114
|
+
userId: response.userId,
|
|
115
|
+
token: response.token,
|
|
116
|
+
step: ForgotPasswordStep.resetPasswordPage
|
|
117
|
+
});
|
|
118
|
+
} catch (e) {
|
|
119
|
+
setForgotPasswordState({
|
|
120
|
+
loading: false,
|
|
121
|
+
error: errorHandler(e, 'An error occurred while verifying password via sms')
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
37
125
|
const determinePasswordRecoveryStrategy = async payload => {
|
|
38
126
|
setForgotPasswordState({
|
|
39
127
|
loading: true,
|
|
40
128
|
error: undefined,
|
|
41
|
-
identifier: payload.identifier
|
|
129
|
+
identifier: payload.identifier,
|
|
130
|
+
identifierType: payload.identifierType
|
|
42
131
|
});
|
|
43
132
|
try {
|
|
44
133
|
const strategies = await api.auth.getPasswordRecoveryStrategies();
|
|
@@ -47,23 +136,23 @@ export default ((store, api, sharedActions) => {
|
|
|
47
136
|
if (isEmailActive && isSmsActive) {
|
|
48
137
|
setForgotPasswordState({
|
|
49
138
|
loading: false,
|
|
50
|
-
step: ForgotPasswordStep.passwordRecoverySelector
|
|
139
|
+
step: ForgotPasswordStep.passwordRecoverySelector,
|
|
140
|
+
activeStrategies: strategies
|
|
51
141
|
});
|
|
52
142
|
} else if (isEmailActive) {
|
|
53
|
-
await
|
|
54
|
-
email: payload.identifier,
|
|
55
|
-
recaptchaToken: payload.recaptchaToken
|
|
56
|
-
});
|
|
143
|
+
await sendPasswordRecoveryEmail();
|
|
57
144
|
} else if (isSmsActive) {
|
|
58
145
|
setForgotPasswordState({
|
|
59
146
|
loading: false,
|
|
60
|
-
step: ForgotPasswordStep.resetPasswordViaSms
|
|
147
|
+
step: ForgotPasswordStep.resetPasswordViaSms,
|
|
148
|
+
activeStrategies: strategies
|
|
61
149
|
});
|
|
62
150
|
} else {
|
|
63
151
|
const error = 'No active password recovery methods found.';
|
|
64
152
|
setForgotPasswordState({
|
|
65
153
|
loading: false,
|
|
66
|
-
error
|
|
154
|
+
error,
|
|
155
|
+
activeStrategies: strategies
|
|
67
156
|
});
|
|
68
157
|
}
|
|
69
158
|
} catch (e) {
|
|
@@ -120,6 +209,9 @@ export default ((store, api, sharedActions) => {
|
|
|
120
209
|
forgotPassword,
|
|
121
210
|
resetPassword,
|
|
122
211
|
loadPasswordConfig,
|
|
123
|
-
determinePasswordRecoveryStrategy
|
|
212
|
+
determinePasswordRecoveryStrategy,
|
|
213
|
+
sendPasswordRecoveryEmail,
|
|
214
|
+
sendPasswordRecoverySms,
|
|
215
|
+
verifyPasswordViaSms
|
|
124
216
|
};
|
|
125
217
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IForgotPassword, IResetPassword } from '@frontegg/rest-api';
|
|
1
|
+
import type { EIdentifierType, IForgotPassword, IResetPassword, IPasswordRecoveryStrategy } from '@frontegg/rest-api';
|
|
2
2
|
import type { WithCallback } from '../../interfaces';
|
|
3
3
|
export declare enum ForgotPasswordStep {
|
|
4
4
|
'forgotPassword' = "forgotPassword",
|
|
@@ -18,8 +18,13 @@ export interface ForgotPasswordState {
|
|
|
18
18
|
step: ForgotPasswordStep;
|
|
19
19
|
passwordConfig: Partial<TestConfig> | null;
|
|
20
20
|
identifier: string;
|
|
21
|
+
identifierType: EIdentifierType;
|
|
21
22
|
loading: boolean;
|
|
23
|
+
sessionId?: string;
|
|
24
|
+
userId?: string;
|
|
25
|
+
token?: string;
|
|
22
26
|
error?: any;
|
|
27
|
+
activeStrategies?: IPasswordRecoveryStrategy[];
|
|
23
28
|
}
|
|
24
29
|
export interface IForgotPasswordPayload extends WithCallback<IForgotPassword> {
|
|
25
30
|
recaptchaToken?: string;
|
|
@@ -29,5 +34,8 @@ export interface IResetPasswordPayload extends WithCallback<IResetPassword> {
|
|
|
29
34
|
}
|
|
30
35
|
export interface IDeterminePasswordRecoveryStrategyPayload {
|
|
31
36
|
identifier: string;
|
|
32
|
-
|
|
37
|
+
identifierType: EIdentifierType;
|
|
33
38
|
}
|
|
39
|
+
export type IVerifyPasswordViaSmsPayload = {
|
|
40
|
+
otcToken: string;
|
|
41
|
+
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { ForgotPasswordStep } from './interfaces';
|
|
2
2
|
import { createProxy } from '../../toolkit/proxy';
|
|
3
|
+
import { EIdentifierType } from '@frontegg/rest-api';
|
|
3
4
|
export const initialState = {
|
|
4
5
|
step: ForgotPasswordStep.forgotPassword,
|
|
5
6
|
loading: false,
|
|
6
7
|
identifier: '',
|
|
8
|
+
identifierType: EIdentifierType.email,
|
|
9
|
+
sessionId: '',
|
|
10
|
+
userId: '',
|
|
11
|
+
token: '',
|
|
7
12
|
passwordConfig: null
|
|
8
13
|
};
|
|
9
14
|
export default (overrideState => createProxy(initialState, overrideState));
|
package/index.js
CHANGED
|
@@ -7,5 +7,8 @@ declare const _default: (store: FronteggState, api: RestApi, actions: SharedActi
|
|
|
7
7
|
resetPassword: (payload: import("../..").IResetPasswordPayload) => Promise<void>;
|
|
8
8
|
loadPasswordConfig: (payload?: IGetUserPasswordConfig) => Promise<void>;
|
|
9
9
|
determinePasswordRecoveryStrategy: (payload: import("../..").IDeterminePasswordRecoveryStrategyPayload) => Promise<void>;
|
|
10
|
+
sendPasswordRecoveryEmail: () => Promise<void>;
|
|
11
|
+
sendPasswordRecoverySms: () => Promise<void>;
|
|
12
|
+
verifyPasswordViaSms: (payload: import("../..").IVerifyPasswordViaSmsPayload) => Promise<void>;
|
|
10
13
|
};
|
|
11
14
|
export default _default;
|
|
@@ -41,11 +41,100 @@ var _default = (store, api, sharedActions) => {
|
|
|
41
41
|
(_payload$callback2 = payload.callback) == null ? void 0 : _payload$callback2.call(payload, false, e);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
+
const sendPasswordRecoveryEmail = async () => {
|
|
45
|
+
const {
|
|
46
|
+
identifier,
|
|
47
|
+
identifierType
|
|
48
|
+
} = store.auth.forgotPasswordState;
|
|
49
|
+
setForgotPasswordState({
|
|
50
|
+
loading: true
|
|
51
|
+
});
|
|
52
|
+
try {
|
|
53
|
+
await api.auth.resetPasswordViaEmail({
|
|
54
|
+
identifier,
|
|
55
|
+
identifierType
|
|
56
|
+
});
|
|
57
|
+
setForgotPasswordState({
|
|
58
|
+
loading: false,
|
|
59
|
+
error: undefined,
|
|
60
|
+
step: _interfaces.ForgotPasswordStep.success
|
|
61
|
+
});
|
|
62
|
+
} catch (e) {
|
|
63
|
+
setForgotPasswordState({
|
|
64
|
+
loading: false,
|
|
65
|
+
error: (0, _helpers.errorHandler)(e, 'An error occurred while sending recovery email')
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const sendPasswordRecoverySms = async () => {
|
|
70
|
+
const {
|
|
71
|
+
identifier,
|
|
72
|
+
identifierType
|
|
73
|
+
} = store.auth.forgotPasswordState;
|
|
74
|
+
setForgotPasswordState({
|
|
75
|
+
loading: true
|
|
76
|
+
});
|
|
77
|
+
try {
|
|
78
|
+
const response = await api.auth.resetPasswordViaSms({
|
|
79
|
+
identifier,
|
|
80
|
+
identifierType
|
|
81
|
+
});
|
|
82
|
+
setForgotPasswordState({
|
|
83
|
+
loading: false,
|
|
84
|
+
error: undefined,
|
|
85
|
+
sessionId: response.sessionId
|
|
86
|
+
});
|
|
87
|
+
} catch (e) {
|
|
88
|
+
setForgotPasswordState({
|
|
89
|
+
loading: false,
|
|
90
|
+
error: (0, _helpers.errorHandler)(e, 'An error occurred while sending recovery sms')
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const verifyPasswordViaSms = async payload => {
|
|
95
|
+
const {
|
|
96
|
+
sessionId
|
|
97
|
+
} = store.auth.forgotPasswordState;
|
|
98
|
+
if (!sessionId) {
|
|
99
|
+
const error = 'Session ID not found in state for verifying password via sms.';
|
|
100
|
+
setForgotPasswordState({
|
|
101
|
+
loading: false,
|
|
102
|
+
error
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setForgotPasswordState({
|
|
107
|
+
loading: true
|
|
108
|
+
});
|
|
109
|
+
try {
|
|
110
|
+
const response = await api.auth.verifyPasswordViaSms({
|
|
111
|
+
otcToken: payload.otcToken,
|
|
112
|
+
sessionId
|
|
113
|
+
});
|
|
114
|
+
if (!response.userId || !response.token) {
|
|
115
|
+
const error = 'Invalid response from server: missing userId or token';
|
|
116
|
+
throw new Error(error);
|
|
117
|
+
}
|
|
118
|
+
setForgotPasswordState({
|
|
119
|
+
loading: false,
|
|
120
|
+
error: undefined,
|
|
121
|
+
userId: response.userId,
|
|
122
|
+
token: response.token,
|
|
123
|
+
step: _interfaces.ForgotPasswordStep.resetPasswordPage
|
|
124
|
+
});
|
|
125
|
+
} catch (e) {
|
|
126
|
+
setForgotPasswordState({
|
|
127
|
+
loading: false,
|
|
128
|
+
error: (0, _helpers.errorHandler)(e, 'An error occurred while verifying password via sms')
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
44
132
|
const determinePasswordRecoveryStrategy = async payload => {
|
|
45
133
|
setForgotPasswordState({
|
|
46
134
|
loading: true,
|
|
47
135
|
error: undefined,
|
|
48
|
-
identifier: payload.identifier
|
|
136
|
+
identifier: payload.identifier,
|
|
137
|
+
identifierType: payload.identifierType
|
|
49
138
|
});
|
|
50
139
|
try {
|
|
51
140
|
const strategies = await api.auth.getPasswordRecoveryStrategies();
|
|
@@ -54,23 +143,23 @@ var _default = (store, api, sharedActions) => {
|
|
|
54
143
|
if (isEmailActive && isSmsActive) {
|
|
55
144
|
setForgotPasswordState({
|
|
56
145
|
loading: false,
|
|
57
|
-
step: _interfaces.ForgotPasswordStep.passwordRecoverySelector
|
|
146
|
+
step: _interfaces.ForgotPasswordStep.passwordRecoverySelector,
|
|
147
|
+
activeStrategies: strategies
|
|
58
148
|
});
|
|
59
149
|
} else if (isEmailActive) {
|
|
60
|
-
await
|
|
61
|
-
email: payload.identifier,
|
|
62
|
-
recaptchaToken: payload.recaptchaToken
|
|
63
|
-
});
|
|
150
|
+
await sendPasswordRecoveryEmail();
|
|
64
151
|
} else if (isSmsActive) {
|
|
65
152
|
setForgotPasswordState({
|
|
66
153
|
loading: false,
|
|
67
|
-
step: _interfaces.ForgotPasswordStep.resetPasswordViaSms
|
|
154
|
+
step: _interfaces.ForgotPasswordStep.resetPasswordViaSms,
|
|
155
|
+
activeStrategies: strategies
|
|
68
156
|
});
|
|
69
157
|
} else {
|
|
70
158
|
const error = 'No active password recovery methods found.';
|
|
71
159
|
setForgotPasswordState({
|
|
72
160
|
loading: false,
|
|
73
|
-
error
|
|
161
|
+
error,
|
|
162
|
+
activeStrategies: strategies
|
|
74
163
|
});
|
|
75
164
|
}
|
|
76
165
|
} catch (e) {
|
|
@@ -127,7 +216,10 @@ var _default = (store, api, sharedActions) => {
|
|
|
127
216
|
forgotPassword,
|
|
128
217
|
resetPassword,
|
|
129
218
|
loadPasswordConfig,
|
|
130
|
-
determinePasswordRecoveryStrategy
|
|
219
|
+
determinePasswordRecoveryStrategy,
|
|
220
|
+
sendPasswordRecoveryEmail,
|
|
221
|
+
sendPasswordRecoverySms,
|
|
222
|
+
verifyPasswordViaSms
|
|
131
223
|
};
|
|
132
224
|
};
|
|
133
225
|
exports.default = _default;
|
|
@@ -6,10 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.initialState = exports.default = void 0;
|
|
7
7
|
var _interfaces = require("./interfaces");
|
|
8
8
|
var _proxy = require("../../toolkit/proxy");
|
|
9
|
+
var _restApi = require("@frontegg/rest-api");
|
|
9
10
|
const initialState = {
|
|
10
11
|
step: _interfaces.ForgotPasswordStep.forgotPassword,
|
|
11
12
|
loading: false,
|
|
12
13
|
identifier: '',
|
|
14
|
+
identifierType: _restApi.EIdentifierType.email,
|
|
15
|
+
sessionId: '',
|
|
16
|
+
userId: '',
|
|
17
|
+
token: '',
|
|
13
18
|
passwordConfig: null
|
|
14
19
|
};
|
|
15
20
|
exports.initialState = initialState;
|
package/node/index.js
CHANGED
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
const FRONTEGG_EXTERNAL_MOBILE_BROWSER_KEY = 'frontegg_external_mobile_browser';
|
|
7
8
|
class FronteggNativeModule {
|
|
8
9
|
constructor() {
|
|
10
|
+
this.backToLoginImpl = undefined;
|
|
9
11
|
this.loginWithSSO = identifier => {
|
|
10
12
|
if (this.isIOSNativeBridgeAvailable()) {
|
|
11
13
|
var _window$webkit, _window$webkit$messag, _window$webkit$messag2;
|
|
@@ -92,6 +94,24 @@ class FronteggNativeModule {
|
|
|
92
94
|
return window.FronteggNativeBridge != null;
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Check if the current browser is an external mobile browser
|
|
99
|
+
* That being used by the Frontegg Mobile SDK to authenticate with social providers
|
|
100
|
+
* Back to login button should close and navigate back to the app
|
|
101
|
+
*/
|
|
102
|
+
isExternalMobileBrowser() {
|
|
103
|
+
return sessionStorage.getItem(FRONTEGG_EXTERNAL_MOBILE_BROWSER_KEY) !== null && this.backToLoginImpl != undefined;
|
|
104
|
+
}
|
|
105
|
+
setBackToLogin(impl) {
|
|
106
|
+
this.backToLoginImpl = impl;
|
|
107
|
+
}
|
|
108
|
+
backToLogin() {
|
|
109
|
+
if (this.backToLoginImpl) {
|
|
110
|
+
this.backToLoginImpl();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
95
115
|
/**
|
|
96
116
|
* @deprecated use isSocialLoginProviderAvailable instead for pkce flow in mobile
|
|
97
117
|
*/
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "7.76.0
|
|
3
|
+
"version": "7.76.0",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontegg LTD",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/runtime": "^7.18.6",
|
|
9
9
|
"@frontegg/entitlements-javascript-commons": "1.1.2",
|
|
10
|
-
"@frontegg/rest-api": "7.76.0
|
|
10
|
+
"@frontegg/rest-api": "7.76.0",
|
|
11
11
|
"fast-deep-equal": "3.1.3",
|
|
12
12
|
"get-value": "^3.0.1",
|
|
13
13
|
"proxy-compare": "^3.0.0",
|
|
@@ -19,8 +19,17 @@ declare global {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
declare class FronteggNativeModule {
|
|
22
|
+
private backToLoginImpl?;
|
|
22
23
|
isIOSNativeBridgeAvailable(): boolean;
|
|
23
24
|
isAndroidNativeBridgeAvailable(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check if the current browser is an external mobile browser
|
|
27
|
+
* That being used by the Frontegg Mobile SDK to authenticate with social providers
|
|
28
|
+
* Back to login button should close and navigate back to the app
|
|
29
|
+
*/
|
|
30
|
+
isExternalMobileBrowser(): boolean;
|
|
31
|
+
setBackToLogin(impl: () => void): void;
|
|
32
|
+
backToLogin(): void;
|
|
24
33
|
/**
|
|
25
34
|
* @deprecated use isSocialLoginProviderAvailable instead for pkce flow in mobile
|
|
26
35
|
*/
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
const FRONTEGG_EXTERNAL_MOBILE_BROWSER_KEY = 'frontegg_external_mobile_browser';
|
|
1
2
|
class FronteggNativeModule {
|
|
2
3
|
constructor() {
|
|
4
|
+
this.backToLoginImpl = undefined;
|
|
3
5
|
this.loginWithSSO = identifier => {
|
|
4
6
|
if (this.isIOSNativeBridgeAvailable()) {
|
|
5
7
|
var _window$webkit, _window$webkit$messag, _window$webkit$messag2;
|
|
@@ -86,6 +88,24 @@ class FronteggNativeModule {
|
|
|
86
88
|
return window.FronteggNativeBridge != null;
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Check if the current browser is an external mobile browser
|
|
93
|
+
* That being used by the Frontegg Mobile SDK to authenticate with social providers
|
|
94
|
+
* Back to login button should close and navigate back to the app
|
|
95
|
+
*/
|
|
96
|
+
isExternalMobileBrowser() {
|
|
97
|
+
return sessionStorage.getItem(FRONTEGG_EXTERNAL_MOBILE_BROWSER_KEY) !== null && this.backToLoginImpl != undefined;
|
|
98
|
+
}
|
|
99
|
+
setBackToLogin(impl) {
|
|
100
|
+
this.backToLoginImpl = impl;
|
|
101
|
+
}
|
|
102
|
+
backToLogin() {
|
|
103
|
+
if (this.backToLoginImpl) {
|
|
104
|
+
this.backToLoginImpl();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
89
109
|
/**
|
|
90
110
|
* @deprecated use isSocialLoginProviderAvailable instead for pkce flow in mobile
|
|
91
111
|
*/
|