@frontegg/js 6.0.1-alpha.6 → 6.0.3-alpha.2
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/AdminPortalRenderer/index.d.ts +17 -0
- package/AdminPortalRenderer/index.js +88 -0
- package/AdminPortalRenderer/package.json +6 -0
- package/FronteggApp/FronteggApp.d.ts +4 -1
- package/FronteggApp/FronteggApp.js +42 -8
- package/LoginBoxRenderer/index.d.ts +20 -0
- package/LoginBoxRenderer/index.js +100 -0
- package/LoginBoxRenderer/package.json +6 -0
- package/index.d.ts +2 -0
- package/index.js +3 -1
- package/node/AdminPortalRenderer/index.js +105 -0
- package/node/FronteggApp/FronteggApp.js +42 -8
- package/node/LoginBoxRenderer/index.js +118 -0
- package/node/index.js +27 -1
- package/node/version.js +1 -1
- package/package.json +2 -2
- package/version.js +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EnhancedStore } from '@frontegg/redux-store';
|
|
2
|
+
import { FronteggAppOptions, FronteggThemeOptions } from '@frontegg/types';
|
|
3
|
+
import { FronteggApp } from '../FronteggApp';
|
|
4
|
+
export declare class AdminPortalRenderer {
|
|
5
|
+
app: FronteggApp;
|
|
6
|
+
options: FronteggAppOptions;
|
|
7
|
+
store: EnhancedStore;
|
|
8
|
+
setRoute: (route: string) => void;
|
|
9
|
+
themeSetter: ((themeOptions: FronteggThemeOptions) => {}) | undefined;
|
|
10
|
+
themeOptions: FronteggThemeOptions;
|
|
11
|
+
constructor(name: string, themeOptions: FronteggThemeOptions, store?: EnhancedStore, appOptions?: Partial<FronteggAppOptions>);
|
|
12
|
+
render(adminPortalContainer: HTMLElement): Promise<void>;
|
|
13
|
+
setStaticRoute(staticRoute: string): void;
|
|
14
|
+
unmount(): void;
|
|
15
|
+
setTheme(themeOptions: FronteggThemeOptions): void;
|
|
16
|
+
}
|
|
17
|
+
export default AdminPortalRenderer;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createFronteggStore } from '@frontegg/redux-store';
|
|
3
|
+
import { Metadata } from '@frontegg/types';
|
|
4
|
+
import { FronteggApp } from '../FronteggApp';
|
|
5
|
+
export class AdminPortalRenderer {
|
|
6
|
+
constructor(name, themeOptions, store, appOptions) {
|
|
7
|
+
this.app = void 0;
|
|
8
|
+
this.options = void 0;
|
|
9
|
+
this.store = void 0;
|
|
10
|
+
|
|
11
|
+
this.setRoute = () => {};
|
|
12
|
+
|
|
13
|
+
this.themeSetter = void 0;
|
|
14
|
+
this.themeOptions = {};
|
|
15
|
+
const contextOptions = {
|
|
16
|
+
baseUrl: 'preview'
|
|
17
|
+
};
|
|
18
|
+
this.store = store != null ? store : createFronteggStore({
|
|
19
|
+
context: contextOptions
|
|
20
|
+
}, this, true, undefined, undefined, true);
|
|
21
|
+
this.options = _extends({
|
|
22
|
+
themeOptions,
|
|
23
|
+
iframeRendering: true,
|
|
24
|
+
metadata: {},
|
|
25
|
+
previewMode: true,
|
|
26
|
+
builderMode: true,
|
|
27
|
+
store: this.store,
|
|
28
|
+
contextOptions
|
|
29
|
+
}, appOptions);
|
|
30
|
+
this.app = new FronteggApp(this.options, name, true);
|
|
31
|
+
Metadata.set({}, name);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async render(adminPortalContainer) {
|
|
35
|
+
let adminPortalEl = adminPortalContainer.querySelector('#root');
|
|
36
|
+
|
|
37
|
+
if (!adminPortalEl) {
|
|
38
|
+
adminPortalEl = adminPortalContainer.ownerDocument.createElement('div');
|
|
39
|
+
adminPortalEl.setAttribute('id', 'root');
|
|
40
|
+
adminPortalContainer.appendChild(adminPortalEl);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.app.adminPortalContainer = adminPortalContainer;
|
|
44
|
+
this.app.adminPortalEl = adminPortalEl;
|
|
45
|
+
|
|
46
|
+
const setThemeSetter = themeSetter => {
|
|
47
|
+
this.themeSetter = themeSetter;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const setStaticRouteSetter = setStaticRoute => {
|
|
51
|
+
this.setRoute = setStaticRoute;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const FronteggAdminPortal = await this.app.loadScript('FronteggAdminPortal');
|
|
55
|
+
this.app.adminPortalRenderer = FronteggAdminPortal.renderPage(adminPortalEl, {
|
|
56
|
+
options: this.options,
|
|
57
|
+
injector: this.app,
|
|
58
|
+
setThemeSetter,
|
|
59
|
+
setStaticRouteSetter
|
|
60
|
+
});
|
|
61
|
+
this.app.loading = false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setStaticRoute(staticRoute) {
|
|
65
|
+
var _this$setRoute;
|
|
66
|
+
|
|
67
|
+
(_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
unmount() {
|
|
71
|
+
try {
|
|
72
|
+
var _this$app$adminPortal;
|
|
73
|
+
|
|
74
|
+
(_this$app$adminPortal = this.app.adminPortalRenderer) == null ? void 0 : _this$app$adminPortal.unmount();
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.error('Failed to unmount admin Portal renderer', e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setTheme(themeOptions) {
|
|
81
|
+
var _this$themeSetter;
|
|
82
|
+
|
|
83
|
+
this.themeOptions = themeOptions;
|
|
84
|
+
(_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
export default AdminPortalRenderer;
|
|
@@ -17,11 +17,14 @@ export declare class FronteggApp {
|
|
|
17
17
|
cdnUrl: string;
|
|
18
18
|
customElementName: string;
|
|
19
19
|
adminPortalEl?: HTMLElement;
|
|
20
|
+
adminPortalRenderer?: any;
|
|
20
21
|
loginBoxEl?: HTMLElement;
|
|
21
22
|
checkoutDialogEl?: HTMLElement;
|
|
23
|
+
checkoutDialogRenderer?: any;
|
|
22
24
|
adminPortalContainer?: HTMLElement;
|
|
23
25
|
loginBoxContainer?: HTMLElement;
|
|
24
26
|
checkoutDialogContainer?: HTMLElement;
|
|
27
|
+
loginBoxRenderer?: any;
|
|
25
28
|
store: Omit<EnhancedStore<RootState>, 'dispatch'> & {
|
|
26
29
|
dispatch: Dispatch;
|
|
27
30
|
};
|
|
@@ -38,7 +41,7 @@ export declare class FronteggApp {
|
|
|
38
41
|
loadLoginBox(): Promise<void>;
|
|
39
42
|
showAdminPortal(): Promise<void>;
|
|
40
43
|
hideAdminPortal(): void;
|
|
41
|
-
showCheckoutDialog(opts: FronteggCheckoutDialogOptions): void
|
|
44
|
+
showCheckoutDialog(opts: FronteggCheckoutDialogOptions): Promise<void>;
|
|
42
45
|
hideCheckoutDialog(): void;
|
|
43
46
|
close(): void;
|
|
44
47
|
}
|
|
@@ -7,7 +7,7 @@ import { fetch as FronteggFetch } from '@frontegg/rest-api';
|
|
|
7
7
|
import versions from '../version';
|
|
8
8
|
export class FronteggApp {
|
|
9
9
|
constructor(_options, name, iframeRendering = false) {
|
|
10
|
-
var _this$options$store, _this$options$authOpt, _this$options$
|
|
10
|
+
var _this$options$store, _this$options$authOpt, _this$options$auditsO;
|
|
11
11
|
|
|
12
12
|
this.name = void 0;
|
|
13
13
|
this.iframeRendering = void 0;
|
|
@@ -16,11 +16,14 @@ export class FronteggApp {
|
|
|
16
16
|
this.cdnUrl = `https://assets.frontegg.com/admin-box/${versions.cdnVersion}`;
|
|
17
17
|
this.customElementName = '';
|
|
18
18
|
this.adminPortalEl = void 0;
|
|
19
|
+
this.adminPortalRenderer = void 0;
|
|
19
20
|
this.loginBoxEl = void 0;
|
|
20
21
|
this.checkoutDialogEl = void 0;
|
|
22
|
+
this.checkoutDialogRenderer = void 0;
|
|
21
23
|
this.adminPortalContainer = void 0;
|
|
22
24
|
this.loginBoxContainer = void 0;
|
|
23
25
|
this.checkoutDialogContainer = void 0;
|
|
26
|
+
this.loginBoxRenderer = void 0;
|
|
24
27
|
this.store = void 0;
|
|
25
28
|
this.loadingListeners = [];
|
|
26
29
|
this.updateLocalizations = void 0;
|
|
@@ -74,10 +77,15 @@ export class FronteggApp {
|
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
this.customElementName = customElementName;
|
|
80
|
+
const authOptions = this.options.authOptions ? _extends({}, this.options.authOptions, {
|
|
81
|
+
hostedLoginBox: this.options.hostedLoginBox
|
|
82
|
+
}) : {
|
|
83
|
+
hostedLoginBox: this.options.hostedLoginBox
|
|
84
|
+
};
|
|
77
85
|
this.store = (_this$options$store = this.options.store) != null ? _this$options$store : createFronteggStore({
|
|
78
86
|
context: this.options.contextOptions
|
|
79
|
-
}, this, this.options.previewMode,
|
|
80
|
-
auth: (_this$options$
|
|
87
|
+
}, this, this.options.previewMode, authOptions, {
|
|
88
|
+
auth: (_this$options$authOpt = this.options.authOptions) != null ? _this$options$authOpt : {},
|
|
81
89
|
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
82
90
|
});
|
|
83
91
|
AppHolder.setInstance(appName, this);
|
|
@@ -169,18 +177,44 @@ export class FronteggApp {
|
|
|
169
177
|
|
|
170
178
|
async showAdminPortal() {
|
|
171
179
|
const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
|
|
172
|
-
FronteggAdminPortal.render(this.adminPortalEl, {
|
|
180
|
+
this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
|
|
173
181
|
injector: this,
|
|
174
182
|
options: this.options
|
|
175
183
|
});
|
|
176
184
|
}
|
|
177
185
|
|
|
178
|
-
hideAdminPortal() {
|
|
186
|
+
hideAdminPortal() {
|
|
187
|
+
try {
|
|
188
|
+
var _this$adminPortalRend;
|
|
179
189
|
|
|
180
|
-
|
|
190
|
+
(_this$adminPortalRend = this.adminPortalRenderer) == null ? void 0 : _this$adminPortalRend.unmount();
|
|
191
|
+
} catch (e) {
|
|
192
|
+
console.error('Failed to unmount admin portal', e);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
181
195
|
|
|
182
|
-
|
|
196
|
+
async showCheckoutDialog(opts) {
|
|
197
|
+
const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
|
|
198
|
+
this.checkoutDialogRenderer = FronteggAdminPortal.renderCheckoutDialog(this.checkoutDialogEl, _extends({
|
|
199
|
+
injector: this
|
|
200
|
+
}, opts, {
|
|
201
|
+
options: this.options
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
183
204
|
|
|
184
|
-
|
|
205
|
+
hideCheckoutDialog() {
|
|
206
|
+
try {
|
|
207
|
+
var _this$checkoutDialogR;
|
|
208
|
+
|
|
209
|
+
(_this$checkoutDialogR = this.checkoutDialogRenderer) == null ? void 0 : _this$checkoutDialogR.unmount();
|
|
210
|
+
} catch (e) {
|
|
211
|
+
console.error('Failed to unmount checkout dialog', e);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
close() {
|
|
216
|
+
this.hideAdminPortal();
|
|
217
|
+
this.hideCheckoutDialog();
|
|
218
|
+
}
|
|
185
219
|
|
|
186
220
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EnhancedStore, FronteggState } from '@frontegg/redux-store';
|
|
2
|
+
import { FronteggAppOptions, FronteggThemeOptions } from '@frontegg/types';
|
|
3
|
+
import { FronteggApp } from '../FronteggApp';
|
|
4
|
+
declare const defaultTheme = "modern";
|
|
5
|
+
export { defaultTheme };
|
|
6
|
+
export declare class LoginBoxRenderer {
|
|
7
|
+
app: FronteggApp;
|
|
8
|
+
options: FronteggAppOptions;
|
|
9
|
+
store: EnhancedStore;
|
|
10
|
+
themeSetter: ((themeOptions: FronteggThemeOptions) => {}) | undefined;
|
|
11
|
+
setRoute: (route: string) => void;
|
|
12
|
+
themeOptions: FronteggThemeOptions;
|
|
13
|
+
constructor(name: string, themeOptions: FronteggThemeOptions, store?: EnhancedStore, appOptions?: Partial<FronteggAppOptions>);
|
|
14
|
+
render(loginBoxContainer: HTMLElement): Promise<void>;
|
|
15
|
+
unmount(): void;
|
|
16
|
+
setTheme(themeOptions: FronteggThemeOptions): void;
|
|
17
|
+
setStaticRoute(staticRoute: string): void;
|
|
18
|
+
setStore(state: Partial<FronteggState['auth']>): void;
|
|
19
|
+
}
|
|
20
|
+
export default LoginBoxRenderer;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createFronteggStore } from '@frontegg/redux-store';
|
|
3
|
+
import { Metadata } from '@frontegg/types';
|
|
4
|
+
import { FronteggApp } from '../FronteggApp';
|
|
5
|
+
const defaultTheme = 'modern';
|
|
6
|
+
export { defaultTheme };
|
|
7
|
+
export class LoginBoxRenderer {
|
|
8
|
+
constructor(name, themeOptions, store, appOptions) {
|
|
9
|
+
this.app = void 0;
|
|
10
|
+
this.options = void 0;
|
|
11
|
+
this.store = void 0;
|
|
12
|
+
this.themeSetter = void 0;
|
|
13
|
+
|
|
14
|
+
this.setRoute = () => {};
|
|
15
|
+
|
|
16
|
+
this.themeOptions = {};
|
|
17
|
+
const contextOptions = {
|
|
18
|
+
baseUrl: 'preview'
|
|
19
|
+
};
|
|
20
|
+
this.store = store != null ? store : createFronteggStore({
|
|
21
|
+
context: contextOptions
|
|
22
|
+
}, this, true, undefined, undefined, true);
|
|
23
|
+
this.options = _extends({
|
|
24
|
+
themeOptions,
|
|
25
|
+
iframeRendering: true,
|
|
26
|
+
metadata: {},
|
|
27
|
+
previewMode: true,
|
|
28
|
+
builderMode: true,
|
|
29
|
+
store: this.store,
|
|
30
|
+
contextOptions,
|
|
31
|
+
onRedirectTo: () => {
|
|
32
|
+
console.debug('path');
|
|
33
|
+
}
|
|
34
|
+
}, appOptions);
|
|
35
|
+
this.app = new FronteggApp(this.options, name, true);
|
|
36
|
+
Metadata.set({}, name);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async render(loginBoxContainer) {
|
|
40
|
+
let loginBoxEl = loginBoxContainer.querySelector('#root');
|
|
41
|
+
|
|
42
|
+
if (!loginBoxEl) {
|
|
43
|
+
loginBoxEl = loginBoxContainer.ownerDocument.createElement('div');
|
|
44
|
+
loginBoxEl.setAttribute('id', 'root');
|
|
45
|
+
loginBoxContainer.appendChild(loginBoxEl);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.app.loginBoxContainer = loginBoxContainer;
|
|
49
|
+
this.app.loginBoxEl = loginBoxEl;
|
|
50
|
+
|
|
51
|
+
const setThemeSetter = themeSetter => {
|
|
52
|
+
this.themeSetter = themeSetter;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const setStaticRouteSetter = setStaticRoute => {
|
|
56
|
+
this.setRoute = setStaticRoute;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const FronteggAdminPortal = await this.app.loadScript('FronteggLoginBox');
|
|
60
|
+
this.app.loginBoxRenderer = FronteggAdminPortal.renderPage(loginBoxEl, {
|
|
61
|
+
options: this.options,
|
|
62
|
+
injector: this.app,
|
|
63
|
+
setThemeSetter,
|
|
64
|
+
setStaticRouteSetter,
|
|
65
|
+
staticRoute: '/account/login'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
unmount() {
|
|
70
|
+
try {
|
|
71
|
+
var _this$app$loginBoxRen;
|
|
72
|
+
|
|
73
|
+
(_this$app$loginBoxRen = this.app.loginBoxRenderer) == null ? void 0 : _this$app$loginBoxRen.unmount();
|
|
74
|
+
} catch (e) {
|
|
75
|
+
console.error('Failed to unmount login box renderer', e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setTheme(themeOptions) {
|
|
80
|
+
var _this$themeSetter;
|
|
81
|
+
|
|
82
|
+
this.themeOptions = themeOptions;
|
|
83
|
+
(_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setStaticRoute(staticRoute) {
|
|
87
|
+
var _this$setRoute;
|
|
88
|
+
|
|
89
|
+
(_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setStore(state) {
|
|
93
|
+
this.store.dispatch({
|
|
94
|
+
type: 'auth/setState',
|
|
95
|
+
payload: state
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
export default LoginBoxRenderer;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license Frontegg v6.0.
|
|
1
|
+
/** @license Frontegg v6.0.3-alpha.2
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -8,4 +8,6 @@ export * from './FronteggApp';
|
|
|
8
8
|
export * from './HostedLogin';
|
|
9
9
|
export * from './AdminPortal';
|
|
10
10
|
export * from './CheckoutDialog';
|
|
11
|
+
export * from './AdminPortalRenderer';
|
|
12
|
+
export * from './LoginBoxRenderer';
|
|
11
13
|
export * from './initialize';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.AdminPortalRenderer = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _reduxStore = require("@frontegg/redux-store");
|
|
13
|
+
|
|
14
|
+
var _types = require("@frontegg/types");
|
|
15
|
+
|
|
16
|
+
var _FronteggApp = require("../FronteggApp");
|
|
17
|
+
|
|
18
|
+
class AdminPortalRenderer {
|
|
19
|
+
constructor(name, themeOptions, store, appOptions) {
|
|
20
|
+
this.app = void 0;
|
|
21
|
+
this.options = void 0;
|
|
22
|
+
this.store = void 0;
|
|
23
|
+
|
|
24
|
+
this.setRoute = () => {};
|
|
25
|
+
|
|
26
|
+
this.themeSetter = void 0;
|
|
27
|
+
this.themeOptions = {};
|
|
28
|
+
const contextOptions = {
|
|
29
|
+
baseUrl: 'preview'
|
|
30
|
+
};
|
|
31
|
+
this.store = store != null ? store : (0, _reduxStore.createFronteggStore)({
|
|
32
|
+
context: contextOptions
|
|
33
|
+
}, this, true, undefined, undefined, true);
|
|
34
|
+
this.options = (0, _extends2.default)({
|
|
35
|
+
themeOptions,
|
|
36
|
+
iframeRendering: true,
|
|
37
|
+
metadata: {},
|
|
38
|
+
previewMode: true,
|
|
39
|
+
builderMode: true,
|
|
40
|
+
store: this.store,
|
|
41
|
+
contextOptions
|
|
42
|
+
}, appOptions);
|
|
43
|
+
this.app = new _FronteggApp.FronteggApp(this.options, name, true);
|
|
44
|
+
|
|
45
|
+
_types.Metadata.set({}, name);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async render(adminPortalContainer) {
|
|
49
|
+
let adminPortalEl = adminPortalContainer.querySelector('#root');
|
|
50
|
+
|
|
51
|
+
if (!adminPortalEl) {
|
|
52
|
+
adminPortalEl = adminPortalContainer.ownerDocument.createElement('div');
|
|
53
|
+
adminPortalEl.setAttribute('id', 'root');
|
|
54
|
+
adminPortalContainer.appendChild(adminPortalEl);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.app.adminPortalContainer = adminPortalContainer;
|
|
58
|
+
this.app.adminPortalEl = adminPortalEl;
|
|
59
|
+
|
|
60
|
+
const setThemeSetter = themeSetter => {
|
|
61
|
+
this.themeSetter = themeSetter;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const setStaticRouteSetter = setStaticRoute => {
|
|
65
|
+
this.setRoute = setStaticRoute;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const FronteggAdminPortal = await this.app.loadScript('FronteggAdminPortal');
|
|
69
|
+
this.app.adminPortalRenderer = FronteggAdminPortal.renderPage(adminPortalEl, {
|
|
70
|
+
options: this.options,
|
|
71
|
+
injector: this.app,
|
|
72
|
+
setThemeSetter,
|
|
73
|
+
setStaticRouteSetter
|
|
74
|
+
});
|
|
75
|
+
this.app.loading = false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setStaticRoute(staticRoute) {
|
|
79
|
+
var _this$setRoute;
|
|
80
|
+
|
|
81
|
+
(_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
unmount() {
|
|
85
|
+
try {
|
|
86
|
+
var _this$app$adminPortal;
|
|
87
|
+
|
|
88
|
+
(_this$app$adminPortal = this.app.adminPortalRenderer) == null ? void 0 : _this$app$adminPortal.unmount();
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.error('Failed to unmount admin Portal renderer', e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
setTheme(themeOptions) {
|
|
95
|
+
var _this$themeSetter;
|
|
96
|
+
|
|
97
|
+
this.themeOptions = themeOptions;
|
|
98
|
+
(_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.AdminPortalRenderer = AdminPortalRenderer;
|
|
104
|
+
var _default = AdminPortalRenderer;
|
|
105
|
+
exports.default = _default;
|
|
@@ -23,7 +23,7 @@ var _version = _interopRequireDefault(require("../version"));
|
|
|
23
23
|
|
|
24
24
|
class FronteggApp {
|
|
25
25
|
constructor(_options, name, iframeRendering = false) {
|
|
26
|
-
var _this$options$store, _this$options$authOpt, _this$options$
|
|
26
|
+
var _this$options$store, _this$options$authOpt, _this$options$auditsO;
|
|
27
27
|
|
|
28
28
|
this.name = void 0;
|
|
29
29
|
this.iframeRendering = void 0;
|
|
@@ -32,11 +32,14 @@ class FronteggApp {
|
|
|
32
32
|
this.cdnUrl = `https://assets.frontegg.com/admin-box/${_version.default.cdnVersion}`;
|
|
33
33
|
this.customElementName = '';
|
|
34
34
|
this.adminPortalEl = void 0;
|
|
35
|
+
this.adminPortalRenderer = void 0;
|
|
35
36
|
this.loginBoxEl = void 0;
|
|
36
37
|
this.checkoutDialogEl = void 0;
|
|
38
|
+
this.checkoutDialogRenderer = void 0;
|
|
37
39
|
this.adminPortalContainer = void 0;
|
|
38
40
|
this.loginBoxContainer = void 0;
|
|
39
41
|
this.checkoutDialogContainer = void 0;
|
|
42
|
+
this.loginBoxRenderer = void 0;
|
|
40
43
|
this.store = void 0;
|
|
41
44
|
this.loadingListeners = [];
|
|
42
45
|
this.updateLocalizations = void 0;
|
|
@@ -90,10 +93,15 @@ class FronteggApp {
|
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
this.customElementName = customElementName;
|
|
96
|
+
const authOptions = this.options.authOptions ? (0, _extends2.default)({}, this.options.authOptions, {
|
|
97
|
+
hostedLoginBox: this.options.hostedLoginBox
|
|
98
|
+
}) : {
|
|
99
|
+
hostedLoginBox: this.options.hostedLoginBox
|
|
100
|
+
};
|
|
93
101
|
this.store = (_this$options$store = this.options.store) != null ? _this$options$store : (0, _reduxStore.createFronteggStore)({
|
|
94
102
|
context: this.options.contextOptions
|
|
95
|
-
}, this, this.options.previewMode,
|
|
96
|
-
auth: (_this$options$
|
|
103
|
+
}, this, this.options.previewMode, authOptions, {
|
|
104
|
+
auth: (_this$options$authOpt = this.options.authOptions) != null ? _this$options$authOpt : {},
|
|
97
105
|
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
98
106
|
});
|
|
99
107
|
|
|
@@ -186,19 +194,45 @@ class FronteggApp {
|
|
|
186
194
|
|
|
187
195
|
async showAdminPortal() {
|
|
188
196
|
const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
|
|
189
|
-
FronteggAdminPortal.render(this.adminPortalEl, {
|
|
197
|
+
this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
|
|
190
198
|
injector: this,
|
|
191
199
|
options: this.options
|
|
192
200
|
});
|
|
193
201
|
}
|
|
194
202
|
|
|
195
|
-
hideAdminPortal() {
|
|
203
|
+
hideAdminPortal() {
|
|
204
|
+
try {
|
|
205
|
+
var _this$adminPortalRend;
|
|
196
206
|
|
|
197
|
-
|
|
207
|
+
(_this$adminPortalRend = this.adminPortalRenderer) == null ? void 0 : _this$adminPortalRend.unmount();
|
|
208
|
+
} catch (e) {
|
|
209
|
+
console.error('Failed to unmount admin portal', e);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
198
212
|
|
|
199
|
-
|
|
213
|
+
async showCheckoutDialog(opts) {
|
|
214
|
+
const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
|
|
215
|
+
this.checkoutDialogRenderer = FronteggAdminPortal.renderCheckoutDialog(this.checkoutDialogEl, (0, _extends2.default)({
|
|
216
|
+
injector: this
|
|
217
|
+
}, opts, {
|
|
218
|
+
options: this.options
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
200
221
|
|
|
201
|
-
|
|
222
|
+
hideCheckoutDialog() {
|
|
223
|
+
try {
|
|
224
|
+
var _this$checkoutDialogR;
|
|
225
|
+
|
|
226
|
+
(_this$checkoutDialogR = this.checkoutDialogRenderer) == null ? void 0 : _this$checkoutDialogR.unmount();
|
|
227
|
+
} catch (e) {
|
|
228
|
+
console.error('Failed to unmount checkout dialog', e);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
close() {
|
|
233
|
+
this.hideAdminPortal();
|
|
234
|
+
this.hideCheckoutDialog();
|
|
235
|
+
}
|
|
202
236
|
|
|
203
237
|
}
|
|
204
238
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.defaultTheme = exports.default = exports.LoginBoxRenderer = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _reduxStore = require("@frontegg/redux-store");
|
|
13
|
+
|
|
14
|
+
var _types = require("@frontegg/types");
|
|
15
|
+
|
|
16
|
+
var _FronteggApp = require("../FronteggApp");
|
|
17
|
+
|
|
18
|
+
const defaultTheme = 'modern';
|
|
19
|
+
exports.defaultTheme = defaultTheme;
|
|
20
|
+
|
|
21
|
+
class LoginBoxRenderer {
|
|
22
|
+
constructor(name, themeOptions, store, appOptions) {
|
|
23
|
+
this.app = void 0;
|
|
24
|
+
this.options = void 0;
|
|
25
|
+
this.store = void 0;
|
|
26
|
+
this.themeSetter = void 0;
|
|
27
|
+
|
|
28
|
+
this.setRoute = () => {};
|
|
29
|
+
|
|
30
|
+
this.themeOptions = {};
|
|
31
|
+
const contextOptions = {
|
|
32
|
+
baseUrl: 'preview'
|
|
33
|
+
};
|
|
34
|
+
this.store = store != null ? store : (0, _reduxStore.createFronteggStore)({
|
|
35
|
+
context: contextOptions
|
|
36
|
+
}, this, true, undefined, undefined, true);
|
|
37
|
+
this.options = (0, _extends2.default)({
|
|
38
|
+
themeOptions,
|
|
39
|
+
iframeRendering: true,
|
|
40
|
+
metadata: {},
|
|
41
|
+
previewMode: true,
|
|
42
|
+
builderMode: true,
|
|
43
|
+
store: this.store,
|
|
44
|
+
contextOptions,
|
|
45
|
+
onRedirectTo: () => {
|
|
46
|
+
console.debug('path');
|
|
47
|
+
}
|
|
48
|
+
}, appOptions);
|
|
49
|
+
this.app = new _FronteggApp.FronteggApp(this.options, name, true);
|
|
50
|
+
|
|
51
|
+
_types.Metadata.set({}, name);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async render(loginBoxContainer) {
|
|
55
|
+
let loginBoxEl = loginBoxContainer.querySelector('#root');
|
|
56
|
+
|
|
57
|
+
if (!loginBoxEl) {
|
|
58
|
+
loginBoxEl = loginBoxContainer.ownerDocument.createElement('div');
|
|
59
|
+
loginBoxEl.setAttribute('id', 'root');
|
|
60
|
+
loginBoxContainer.appendChild(loginBoxEl);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.app.loginBoxContainer = loginBoxContainer;
|
|
64
|
+
this.app.loginBoxEl = loginBoxEl;
|
|
65
|
+
|
|
66
|
+
const setThemeSetter = themeSetter => {
|
|
67
|
+
this.themeSetter = themeSetter;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const setStaticRouteSetter = setStaticRoute => {
|
|
71
|
+
this.setRoute = setStaticRoute;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const FronteggAdminPortal = await this.app.loadScript('FronteggLoginBox');
|
|
75
|
+
this.app.loginBoxRenderer = FronteggAdminPortal.renderPage(loginBoxEl, {
|
|
76
|
+
options: this.options,
|
|
77
|
+
injector: this.app,
|
|
78
|
+
setThemeSetter,
|
|
79
|
+
setStaticRouteSetter,
|
|
80
|
+
staticRoute: '/account/login'
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
unmount() {
|
|
85
|
+
try {
|
|
86
|
+
var _this$app$loginBoxRen;
|
|
87
|
+
|
|
88
|
+
(_this$app$loginBoxRen = this.app.loginBoxRenderer) == null ? void 0 : _this$app$loginBoxRen.unmount();
|
|
89
|
+
} catch (e) {
|
|
90
|
+
console.error('Failed to unmount login box renderer', e);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
setTheme(themeOptions) {
|
|
95
|
+
var _this$themeSetter;
|
|
96
|
+
|
|
97
|
+
this.themeOptions = themeOptions;
|
|
98
|
+
(_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setStaticRoute(staticRoute) {
|
|
102
|
+
var _this$setRoute;
|
|
103
|
+
|
|
104
|
+
(_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setStore(state) {
|
|
108
|
+
this.store.dispatch({
|
|
109
|
+
type: 'auth/setState',
|
|
110
|
+
payload: state
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
exports.LoginBoxRenderer = LoginBoxRenderer;
|
|
117
|
+
var _default = LoginBoxRenderer;
|
|
118
|
+
exports.default = _default;
|
package/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license Frontegg v6.0.
|
|
1
|
+
/** @license Frontegg v6.0.3-alpha.2
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -74,6 +74,32 @@ Object.keys(_CheckoutDialog).forEach(function (key) {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
var _AdminPortalRenderer = require("./AdminPortalRenderer");
|
|
78
|
+
|
|
79
|
+
Object.keys(_AdminPortalRenderer).forEach(function (key) {
|
|
80
|
+
if (key === "default" || key === "__esModule") return;
|
|
81
|
+
if (key in exports && exports[key] === _AdminPortalRenderer[key]) return;
|
|
82
|
+
Object.defineProperty(exports, key, {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return _AdminPortalRenderer[key];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
var _LoginBoxRenderer = require("./LoginBoxRenderer");
|
|
91
|
+
|
|
92
|
+
Object.keys(_LoginBoxRenderer).forEach(function (key) {
|
|
93
|
+
if (key === "default" || key === "__esModule") return;
|
|
94
|
+
if (key in exports && exports[key] === _LoginBoxRenderer[key]) return;
|
|
95
|
+
Object.defineProperty(exports, key, {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return _LoginBoxRenderer[key];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
77
103
|
var _initialize = require("./initialize");
|
|
78
104
|
|
|
79
105
|
Object.keys(_initialize).forEach(function (key) {
|
package/node/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/js",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.3-alpha.2",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@babel/runtime": "^7.17.2",
|
|
8
|
-
"@frontegg/types": "6.0.
|
|
8
|
+
"@frontegg/types": "6.0.3-alpha.2"
|
|
9
9
|
},
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"private": false,
|
package/version.js
CHANGED