@frontegg/js 6.0.1-alpha.4 → 6.0.3-alpha.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/AdminPortalRenderer/index.d.ts +17 -0
- package/AdminPortalRenderer/index.js +88 -0
- package/AdminPortalRenderer/package.json +6 -0
- package/FronteggApp/FronteggApp.d.ts +6 -2
- package/FronteggApp/FronteggApp.js +59 -13
- 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 +59 -13
- 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;
|
|
@@ -14,13 +14,17 @@ export declare class FronteggApp {
|
|
|
14
14
|
readonly iframeRendering: boolean;
|
|
15
15
|
options: FronteggAppOptions;
|
|
16
16
|
loading: boolean;
|
|
17
|
+
cdnUrl: string;
|
|
17
18
|
customElementName: string;
|
|
18
19
|
adminPortalEl?: HTMLElement;
|
|
20
|
+
adminPortalRenderer?: any;
|
|
19
21
|
loginBoxEl?: HTMLElement;
|
|
20
22
|
checkoutDialogEl?: HTMLElement;
|
|
23
|
+
checkoutDialogRenderer?: any;
|
|
21
24
|
adminPortalContainer?: HTMLElement;
|
|
22
25
|
loginBoxContainer?: HTMLElement;
|
|
23
26
|
checkoutDialogContainer?: HTMLElement;
|
|
27
|
+
loginBoxRenderer?: any;
|
|
24
28
|
store: Omit<EnhancedStore<RootState>, 'dispatch'> & {
|
|
25
29
|
dispatch: Dispatch;
|
|
26
30
|
};
|
|
@@ -33,11 +37,11 @@ export declare class FronteggApp {
|
|
|
33
37
|
updateLocalizationsSetter: (localizationUpdateFn: (localizations: LocalizationsOverrides) => void) => void;
|
|
34
38
|
updateMetadata(metadata: FronteggAppOptions['metadata']): void;
|
|
35
39
|
addOnLoadedListener(listener: () => void): void;
|
|
36
|
-
loadScript(
|
|
40
|
+
loadScript(component: string): Promise<unknown>;
|
|
37
41
|
loadLoginBox(): Promise<void>;
|
|
38
42
|
showAdminPortal(): Promise<void>;
|
|
39
43
|
hideAdminPortal(): void;
|
|
40
|
-
showCheckoutDialog(opts: FronteggCheckoutDialogOptions): void
|
|
44
|
+
showCheckoutDialog(opts: FronteggCheckoutDialogOptions): Promise<void>;
|
|
41
45
|
hideCheckoutDialog(): void;
|
|
42
46
|
close(): void;
|
|
43
47
|
}
|
|
@@ -7,19 +7,23 @@ 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;
|
|
14
14
|
this.options = void 0;
|
|
15
15
|
this.loading = true;
|
|
16
|
+
this.cdnUrl = `https://assets.frontegg.com/admin-box/${versions.cdnVersion}`;
|
|
16
17
|
this.customElementName = '';
|
|
17
18
|
this.adminPortalEl = void 0;
|
|
19
|
+
this.adminPortalRenderer = void 0;
|
|
18
20
|
this.loginBoxEl = void 0;
|
|
19
21
|
this.checkoutDialogEl = void 0;
|
|
22
|
+
this.checkoutDialogRenderer = void 0;
|
|
20
23
|
this.adminPortalContainer = void 0;
|
|
21
24
|
this.loginBoxContainer = void 0;
|
|
22
25
|
this.checkoutDialogContainer = void 0;
|
|
26
|
+
this.loginBoxRenderer = void 0;
|
|
23
27
|
this.store = void 0;
|
|
24
28
|
this.loadingListeners = [];
|
|
25
29
|
this.updateLocalizations = void 0;
|
|
@@ -67,11 +71,21 @@ export class FronteggApp {
|
|
|
67
71
|
requestCredentials: 'include'
|
|
68
72
|
}, _options.contextOptions)
|
|
69
73
|
});
|
|
74
|
+
|
|
75
|
+
if (this.options.cdnUrl) {
|
|
76
|
+
this.cdnUrl = this.options.cdnUrl;
|
|
77
|
+
}
|
|
78
|
+
|
|
70
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
|
+
};
|
|
71
85
|
this.store = (_this$options$store = this.options.store) != null ? _this$options$store : createFronteggStore({
|
|
72
86
|
context: this.options.contextOptions
|
|
73
|
-
}, this, this.options.previewMode,
|
|
74
|
-
auth: (_this$options$
|
|
87
|
+
}, this, this.options.previewMode, authOptions, {
|
|
88
|
+
auth: (_this$options$authOpt = this.options.authOptions) != null ? _this$options$authOpt : {},
|
|
75
89
|
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
76
90
|
});
|
|
77
91
|
AppHolder.setInstance(appName, this);
|
|
@@ -95,7 +109,7 @@ export class FronteggApp {
|
|
|
95
109
|
this.loadLoginBox();
|
|
96
110
|
}
|
|
97
111
|
|
|
98
|
-
this.loadScript(
|
|
112
|
+
this.loadScript('FronteggAdminPortal');
|
|
99
113
|
}
|
|
100
114
|
|
|
101
115
|
updateMetadata(metadata) {
|
|
@@ -117,15 +131,21 @@ export class FronteggApp {
|
|
|
117
131
|
this.loadingListeners.push(listener);
|
|
118
132
|
}
|
|
119
133
|
|
|
120
|
-
loadScript(
|
|
134
|
+
loadScript(component) {
|
|
121
135
|
return new Promise((resolve, reject) => {
|
|
122
136
|
if (window[component]) {
|
|
123
137
|
resolve(window[component]);
|
|
124
138
|
return;
|
|
125
139
|
}
|
|
126
140
|
|
|
141
|
+
const entries = {
|
|
142
|
+
FronteggLoginBox: 'login-box/index.js',
|
|
143
|
+
FronteggAdminPortal: 'admin-portal/index.js'
|
|
144
|
+
};
|
|
127
145
|
const script = document.createElement('script');
|
|
128
|
-
script.src =
|
|
146
|
+
script.src = `${this.cdnUrl}/${entries[component]}`;
|
|
147
|
+
script.setAttribute('id', `${component}Script`);
|
|
148
|
+
script.setAttribute('cdn-url', this.cdnUrl);
|
|
129
149
|
|
|
130
150
|
script.onload = () => {
|
|
131
151
|
resolve(window[component]);
|
|
@@ -141,7 +161,7 @@ export class FronteggApp {
|
|
|
141
161
|
}
|
|
142
162
|
|
|
143
163
|
async loadLoginBox() {
|
|
144
|
-
const FronteggLoginBox = await this.loadScript(
|
|
164
|
+
const FronteggLoginBox = await this.loadScript('FronteggLoginBox');
|
|
145
165
|
FronteggLoginBox.render(this.loginBoxEl, {
|
|
146
166
|
injector: this,
|
|
147
167
|
options: this.options
|
|
@@ -156,19 +176,45 @@ export class FronteggApp {
|
|
|
156
176
|
}
|
|
157
177
|
|
|
158
178
|
async showAdminPortal() {
|
|
159
|
-
const FronteggAdminPortal = await this.loadScript(
|
|
160
|
-
FronteggAdminPortal.render(this.adminPortalEl, {
|
|
179
|
+
const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
|
|
180
|
+
this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
|
|
161
181
|
injector: this,
|
|
162
182
|
options: this.options
|
|
163
183
|
});
|
|
164
184
|
}
|
|
165
185
|
|
|
166
|
-
hideAdminPortal() {
|
|
186
|
+
hideAdminPortal() {
|
|
187
|
+
try {
|
|
188
|
+
var _this$adminPortalRend;
|
|
189
|
+
|
|
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
|
+
}
|
|
195
|
+
|
|
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
|
+
}
|
|
167
204
|
|
|
168
|
-
|
|
205
|
+
hideCheckoutDialog() {
|
|
206
|
+
try {
|
|
207
|
+
var _this$checkoutDialogR;
|
|
169
208
|
|
|
170
|
-
|
|
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
|
+
}
|
|
171
214
|
|
|
172
|
-
close() {
|
|
215
|
+
close() {
|
|
216
|
+
this.hideAdminPortal();
|
|
217
|
+
this.hideCheckoutDialog();
|
|
218
|
+
}
|
|
173
219
|
|
|
174
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.0
|
|
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,19 +23,23 @@ 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;
|
|
30
30
|
this.options = void 0;
|
|
31
31
|
this.loading = true;
|
|
32
|
+
this.cdnUrl = `https://assets.frontegg.com/admin-box/${_version.default.cdnVersion}`;
|
|
32
33
|
this.customElementName = '';
|
|
33
34
|
this.adminPortalEl = void 0;
|
|
35
|
+
this.adminPortalRenderer = void 0;
|
|
34
36
|
this.loginBoxEl = void 0;
|
|
35
37
|
this.checkoutDialogEl = void 0;
|
|
38
|
+
this.checkoutDialogRenderer = void 0;
|
|
36
39
|
this.adminPortalContainer = void 0;
|
|
37
40
|
this.loginBoxContainer = void 0;
|
|
38
41
|
this.checkoutDialogContainer = void 0;
|
|
42
|
+
this.loginBoxRenderer = void 0;
|
|
39
43
|
this.store = void 0;
|
|
40
44
|
this.loadingListeners = [];
|
|
41
45
|
this.updateLocalizations = void 0;
|
|
@@ -83,11 +87,21 @@ class FronteggApp {
|
|
|
83
87
|
requestCredentials: 'include'
|
|
84
88
|
}, _options.contextOptions)
|
|
85
89
|
});
|
|
90
|
+
|
|
91
|
+
if (this.options.cdnUrl) {
|
|
92
|
+
this.cdnUrl = this.options.cdnUrl;
|
|
93
|
+
}
|
|
94
|
+
|
|
86
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
|
+
};
|
|
87
101
|
this.store = (_this$options$store = this.options.store) != null ? _this$options$store : (0, _reduxStore.createFronteggStore)({
|
|
88
102
|
context: this.options.contextOptions
|
|
89
|
-
}, this, this.options.previewMode,
|
|
90
|
-
auth: (_this$options$
|
|
103
|
+
}, this, this.options.previewMode, authOptions, {
|
|
104
|
+
auth: (_this$options$authOpt = this.options.authOptions) != null ? _this$options$authOpt : {},
|
|
91
105
|
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
92
106
|
});
|
|
93
107
|
|
|
@@ -112,7 +126,7 @@ class FronteggApp {
|
|
|
112
126
|
this.loadLoginBox();
|
|
113
127
|
}
|
|
114
128
|
|
|
115
|
-
this.loadScript(
|
|
129
|
+
this.loadScript('FronteggAdminPortal');
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
updateMetadata(metadata) {
|
|
@@ -134,15 +148,21 @@ class FronteggApp {
|
|
|
134
148
|
this.loadingListeners.push(listener);
|
|
135
149
|
}
|
|
136
150
|
|
|
137
|
-
loadScript(
|
|
151
|
+
loadScript(component) {
|
|
138
152
|
return new Promise((resolve, reject) => {
|
|
139
153
|
if (window[component]) {
|
|
140
154
|
resolve(window[component]);
|
|
141
155
|
return;
|
|
142
156
|
}
|
|
143
157
|
|
|
158
|
+
const entries = {
|
|
159
|
+
FronteggLoginBox: 'login-box/index.js',
|
|
160
|
+
FronteggAdminPortal: 'admin-portal/index.js'
|
|
161
|
+
};
|
|
144
162
|
const script = document.createElement('script');
|
|
145
|
-
script.src =
|
|
163
|
+
script.src = `${this.cdnUrl}/${entries[component]}`;
|
|
164
|
+
script.setAttribute('id', `${component}Script`);
|
|
165
|
+
script.setAttribute('cdn-url', this.cdnUrl);
|
|
146
166
|
|
|
147
167
|
script.onload = () => {
|
|
148
168
|
resolve(window[component]);
|
|
@@ -158,7 +178,7 @@ class FronteggApp {
|
|
|
158
178
|
}
|
|
159
179
|
|
|
160
180
|
async loadLoginBox() {
|
|
161
|
-
const FronteggLoginBox = await this.loadScript(
|
|
181
|
+
const FronteggLoginBox = await this.loadScript('FronteggLoginBox');
|
|
162
182
|
FronteggLoginBox.render(this.loginBoxEl, {
|
|
163
183
|
injector: this,
|
|
164
184
|
options: this.options
|
|
@@ -173,20 +193,46 @@ class FronteggApp {
|
|
|
173
193
|
}
|
|
174
194
|
|
|
175
195
|
async showAdminPortal() {
|
|
176
|
-
const FronteggAdminPortal = await this.loadScript(
|
|
177
|
-
FronteggAdminPortal.render(this.adminPortalEl, {
|
|
196
|
+
const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
|
|
197
|
+
this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
|
|
178
198
|
injector: this,
|
|
179
199
|
options: this.options
|
|
180
200
|
});
|
|
181
201
|
}
|
|
182
202
|
|
|
183
|
-
hideAdminPortal() {
|
|
203
|
+
hideAdminPortal() {
|
|
204
|
+
try {
|
|
205
|
+
var _this$adminPortalRend;
|
|
206
|
+
|
|
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
|
+
}
|
|
212
|
+
|
|
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
|
+
}
|
|
184
221
|
|
|
185
|
-
|
|
222
|
+
hideCheckoutDialog() {
|
|
223
|
+
try {
|
|
224
|
+
var _this$checkoutDialogR;
|
|
186
225
|
|
|
187
|
-
|
|
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
|
+
}
|
|
188
231
|
|
|
189
|
-
close() {
|
|
232
|
+
close() {
|
|
233
|
+
this.hideAdminPortal();
|
|
234
|
+
this.hideCheckoutDialog();
|
|
235
|
+
}
|
|
190
236
|
|
|
191
237
|
}
|
|
192
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.0
|
|
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.0",
|
|
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.0"
|
|
9
9
|
},
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"private": false,
|
package/version.js
CHANGED