@frontegg/js 6.0.1-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/AdminPortal/index.d.ts +4 -0
- package/AdminPortal/index.js +11 -0
- package/AdminPortal/package.json +6 -0
- package/AppHolder/index.d.ts +6 -0
- package/AppHolder/index.js +17 -0
- package/AppHolder/package.json +6 -0
- package/CheckoutDialog/index.d.ts +5 -0
- package/CheckoutDialog/index.js +11 -0
- package/CheckoutDialog/package.json +6 -0
- package/FronteggApp/FronteggApp.d.ts +44 -0
- package/FronteggApp/FronteggApp.js +173 -0
- package/FronteggApp/index.d.ts +1 -0
- package/FronteggApp/index.js +1 -0
- package/FronteggApp/package.json +6 -0
- package/HostedLogin/index.d.ts +4 -0
- package/HostedLogin/index.js +31 -0
- package/HostedLogin/package.json +6 -0
- package/index.d.ts +6 -0
- package/index.js +11 -0
- package/initialize.d.ts +3 -0
- package/initialize.js +110 -0
- package/node/AdminPortal/index.js +21 -0
- package/node/AppHolder/index.js +26 -0
- package/node/CheckoutDialog/index.js +21 -0
- package/node/FronteggApp/FronteggApp.js +191 -0
- package/node/FronteggApp/index.js +18 -0
- package/node/HostedLogin/index.js +50 -0
- package/node/index.js +88 -0
- package/node/initialize.js +123 -0
- package/node/utils/index.js +19 -0
- package/package.json +14 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.js +7 -0
- package/utils/package.json +6 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class AppHolder {
|
|
2
|
+
static setInstance(name, app) {
|
|
3
|
+
AppHolder._apps[name] = app;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
static getInstance(name) {
|
|
7
|
+
const app = AppHolder._apps[name];
|
|
8
|
+
|
|
9
|
+
if (!app) {
|
|
10
|
+
throw Error(`[${name}] FronteggApp not found`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return app;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
AppHolder._apps = {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppHolder } from '../AppHolder';
|
|
2
|
+
export class CheckoutDialog {
|
|
3
|
+
static show(opts, name = 'default') {
|
|
4
|
+
AppHolder.getInstance(name).showCheckoutDialog(opts);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
static hide(name = 'default') {
|
|
8
|
+
AppHolder.getInstance(name).hideCheckoutDialog();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EnhancedStore } from '@reduxjs/toolkit';
|
|
2
|
+
import { Dispatch, RootState } from '@frontegg/redux-store';
|
|
3
|
+
import { FronteggAppOptions, FronteggCheckoutDialogOptions, LocalizationsOverrides } from '@frontegg/types';
|
|
4
|
+
declare type FronteggAppContainers = {
|
|
5
|
+
adminPortalEl: HTMLElement;
|
|
6
|
+
loginBoxEl: HTMLElement;
|
|
7
|
+
checkoutDialogEl: HTMLElement;
|
|
8
|
+
adminPortalContainer: HTMLElement;
|
|
9
|
+
loginBoxContainer: HTMLElement;
|
|
10
|
+
checkoutDialogContainer: HTMLElement;
|
|
11
|
+
};
|
|
12
|
+
export declare class FronteggApp {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly iframeRendering: boolean;
|
|
15
|
+
options: FronteggAppOptions;
|
|
16
|
+
loading: boolean;
|
|
17
|
+
customElementName: string;
|
|
18
|
+
adminPortalEl?: HTMLElement;
|
|
19
|
+
loginBoxEl?: HTMLElement;
|
|
20
|
+
checkoutDialogEl?: HTMLElement;
|
|
21
|
+
adminPortalContainer?: HTMLElement;
|
|
22
|
+
loginBoxContainer?: HTMLElement;
|
|
23
|
+
checkoutDialogContainer?: HTMLElement;
|
|
24
|
+
store: Omit<EnhancedStore<RootState>, 'dispatch'> & {
|
|
25
|
+
dispatch: Dispatch;
|
|
26
|
+
};
|
|
27
|
+
loadingListeners: (() => void)[];
|
|
28
|
+
updateLocalizations?: (localizations: LocalizationsOverrides) => void;
|
|
29
|
+
constructor(_options: FronteggAppOptions, name: string, iframeRendering?: boolean);
|
|
30
|
+
loadAdminBoxMetadata: () => Promise<void>;
|
|
31
|
+
requestAuthorize: () => Promise<void>;
|
|
32
|
+
initContainers(elements: FronteggAppContainers): Promise<void>;
|
|
33
|
+
updateLocalizationsSetter: (localizationUpdateFn: (localizations: LocalizationsOverrides) => void) => void;
|
|
34
|
+
updateMetadata(metadata: FronteggAppOptions['metadata']): void;
|
|
35
|
+
addOnLoadedListener(listener: () => void): void;
|
|
36
|
+
loadScript(url: string, component: string): Promise<unknown>;
|
|
37
|
+
loadLoginBox(): Promise<void>;
|
|
38
|
+
showAdminPortal(): Promise<void>;
|
|
39
|
+
hideAdminPortal(): void;
|
|
40
|
+
showCheckoutDialog(opts: FronteggCheckoutDialogOptions): void;
|
|
41
|
+
hideCheckoutDialog(): void;
|
|
42
|
+
close(): void;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createFronteggStore } from '@frontegg/redux-store';
|
|
3
|
+
import { Metadata } from '@frontegg/types';
|
|
4
|
+
import { formatName } from '../utils';
|
|
5
|
+
import { AppHolder } from '../AppHolder';
|
|
6
|
+
import { fetch as FronteggFetch } from '@frontegg/rest-api';
|
|
7
|
+
export class FronteggApp {
|
|
8
|
+
constructor(_options, name, iframeRendering = false) {
|
|
9
|
+
var _this$options$store, _this$options$authOpt, _this$options$authOpt2, _this$options$auditsO;
|
|
10
|
+
|
|
11
|
+
this.name = void 0;
|
|
12
|
+
this.iframeRendering = void 0;
|
|
13
|
+
this.options = void 0;
|
|
14
|
+
this.loading = true;
|
|
15
|
+
this.customElementName = '';
|
|
16
|
+
this.adminPortalEl = void 0;
|
|
17
|
+
this.loginBoxEl = void 0;
|
|
18
|
+
this.checkoutDialogEl = void 0;
|
|
19
|
+
this.adminPortalContainer = void 0;
|
|
20
|
+
this.loginBoxContainer = void 0;
|
|
21
|
+
this.checkoutDialogContainer = void 0;
|
|
22
|
+
this.store = void 0;
|
|
23
|
+
this.loadingListeners = [];
|
|
24
|
+
this.updateLocalizations = void 0;
|
|
25
|
+
|
|
26
|
+
this.loadAdminBoxMetadata = async () => {
|
|
27
|
+
const {
|
|
28
|
+
Get
|
|
29
|
+
} = FronteggFetch;
|
|
30
|
+
|
|
31
|
+
if (!this.options.metadata) {
|
|
32
|
+
try {
|
|
33
|
+
var _data$rows$0$configur, _data$rows, _data$rows$;
|
|
34
|
+
|
|
35
|
+
const data = await Get(`/metadata`, {
|
|
36
|
+
entityName: 'adminBox'
|
|
37
|
+
});
|
|
38
|
+
this.options.metadata = (_data$rows$0$configur = data == null ? void 0 : (_data$rows = data.rows) == null ? void 0 : (_data$rows$ = _data$rows[0]) == null ? void 0 : _data$rows$.configuration) != null ? _data$rows$0$configur : {};
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.error('failed to get admin portal metadata', e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Metadata.set(this.options.metadata, this.name);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
this.requestAuthorize = async () => {
|
|
48
|
+
if (!this.options.hostedLoginBox && !this.options.builderMode && this.options.framework !== 'nextjs') {
|
|
49
|
+
this.store.dispatch({
|
|
50
|
+
type: 'auth/requestAuthorize',
|
|
51
|
+
payload: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
this.updateLocalizationsSetter = localizationUpdateFn => {
|
|
57
|
+
this.updateLocalizations = localizationUpdateFn;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
let appName = formatName(name);
|
|
61
|
+
let customElementName = `frontegg-app-${appName}`;
|
|
62
|
+
this.iframeRendering = iframeRendering;
|
|
63
|
+
this.name = appName;
|
|
64
|
+
this.options = _extends({}, _options, {
|
|
65
|
+
contextOptions: _extends({
|
|
66
|
+
requestCredentials: 'include'
|
|
67
|
+
}, _options.contextOptions)
|
|
68
|
+
});
|
|
69
|
+
this.customElementName = customElementName;
|
|
70
|
+
this.store = (_this$options$store = this.options.store) != null ? _this$options$store : createFronteggStore({
|
|
71
|
+
context: this.options.contextOptions
|
|
72
|
+
}, this, this.options.previewMode, (_this$options$authOpt = this.options.authOptions) != null ? _this$options$authOpt : {}, {
|
|
73
|
+
auth: (_this$options$authOpt2 = this.options.authOptions) != null ? _this$options$authOpt2 : {},
|
|
74
|
+
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
75
|
+
});
|
|
76
|
+
AppHolder.setInstance(appName, this);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async initContainers(elements) {
|
|
80
|
+
this.adminPortalEl = elements.adminPortalEl;
|
|
81
|
+
this.loginBoxEl = elements.loginBoxEl;
|
|
82
|
+
this.checkoutDialogEl = elements.checkoutDialogEl;
|
|
83
|
+
this.adminPortalContainer = elements.adminPortalContainer;
|
|
84
|
+
this.loginBoxContainer = elements.loginBoxContainer;
|
|
85
|
+
this.checkoutDialogContainer = elements.checkoutDialogContainer;
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
document.body.classList.add('frontegg-loading');
|
|
89
|
+
} catch (e) {}
|
|
90
|
+
|
|
91
|
+
await Promise.all([this.loadAdminBoxMetadata(), this.requestAuthorize()]);
|
|
92
|
+
|
|
93
|
+
if (!this.options.previewMode && !this.options.customLoginBox) {
|
|
94
|
+
this.loadLoginBox();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.loadScript('http://localhost:3002/index.js', 'FronteggAdminPortal');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
updateMetadata(metadata) {
|
|
101
|
+
Metadata.set(metadata, this.name);
|
|
102
|
+
|
|
103
|
+
if (metadata != null && metadata.localizations) {
|
|
104
|
+
var _this$updateLocalizat;
|
|
105
|
+
|
|
106
|
+
(_this$updateLocalizat = this.updateLocalizations) == null ? void 0 : _this$updateLocalizat.call(this, metadata.localizations);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
addOnLoadedListener(listener) {
|
|
111
|
+
if (!this.loading) {
|
|
112
|
+
listener();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.loadingListeners.push(listener);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
loadScript(url, component) {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
if (window[component]) {
|
|
122
|
+
resolve(window[component]);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const script = document.createElement('script');
|
|
127
|
+
script.src = url;
|
|
128
|
+
|
|
129
|
+
script.onload = () => {
|
|
130
|
+
resolve(window[component]);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
script.onerror = e => {
|
|
134
|
+
console.log('Profile page error', e);
|
|
135
|
+
reject(e);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
document.body.append(script);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async loadLoginBox() {
|
|
143
|
+
const FronteggLoginBox = await this.loadScript('http://localhost:3001/index.js', 'FronteggLoginBox');
|
|
144
|
+
FronteggLoginBox.render(this.loginBoxEl, {
|
|
145
|
+
injector: this,
|
|
146
|
+
options: this.options
|
|
147
|
+
});
|
|
148
|
+
this.loading = false;
|
|
149
|
+
this.loadingListeners.forEach(listener => {
|
|
150
|
+
try {
|
|
151
|
+
listener();
|
|
152
|
+
} catch (e) {}
|
|
153
|
+
});
|
|
154
|
+
this.loadingListeners = [];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async showAdminPortal() {
|
|
158
|
+
const FronteggAdminPortal = await this.loadScript('http://localhost:3002/index.js', 'FronteggAdminPortal');
|
|
159
|
+
FronteggAdminPortal.render(this.adminPortalEl, {
|
|
160
|
+
injector: this,
|
|
161
|
+
options: this.options
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
hideAdminPortal() {}
|
|
166
|
+
|
|
167
|
+
showCheckoutDialog(opts) {}
|
|
168
|
+
|
|
169
|
+
hideCheckoutDialog() {}
|
|
170
|
+
|
|
171
|
+
close() {}
|
|
172
|
+
|
|
173
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FronteggApp';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './FronteggApp';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { authActions } from '@frontegg/redux-store';
|
|
3
|
+
import { AppHolder } from '../AppHolder';
|
|
4
|
+
import { ContextHolder } from '@frontegg/rest-api';
|
|
5
|
+
export class HostedLogin {
|
|
6
|
+
static setAuthentication(isAuthenticated, accessToken, user, appName = 'default') {
|
|
7
|
+
const app = AppHolder.getInstance(appName);
|
|
8
|
+
|
|
9
|
+
if (isAuthenticated && accessToken) {
|
|
10
|
+
ContextHolder.setAccessToken(accessToken);
|
|
11
|
+
ContextHolder.setUser(_extends({}, user, {
|
|
12
|
+
accessToken
|
|
13
|
+
}));
|
|
14
|
+
app.store.dispatch(authActions.setState({
|
|
15
|
+
isLoading: false,
|
|
16
|
+
isAuthenticated,
|
|
17
|
+
user
|
|
18
|
+
}));
|
|
19
|
+
app.store.dispatch(authActions.loadTenants());
|
|
20
|
+
} else {
|
|
21
|
+
ContextHolder.setAccessToken(null);
|
|
22
|
+
ContextHolder.setUser(null);
|
|
23
|
+
app.store.dispatch(authActions.setState({
|
|
24
|
+
isLoading: false,
|
|
25
|
+
isAuthenticated: false,
|
|
26
|
+
user: null
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @license Frontegg v6.0.1-alpha.0
|
|
2
|
+
*
|
|
3
|
+
* This source code is licensed under the MIT license found in the
|
|
4
|
+
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
export * from './AppHolder';
|
|
7
|
+
export * from './FronteggApp';
|
|
8
|
+
export * from './HostedLogin';
|
|
9
|
+
export * from './AdminPortal';
|
|
10
|
+
export * from './CheckoutDialog';
|
|
11
|
+
export * from './initialize';
|
package/initialize.d.ts
ADDED
package/initialize.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { FronteggApp } from './FronteggApp';
|
|
2
|
+
import { AppHolder } from './AppHolder';
|
|
3
|
+
import { createElement } from './utils';
|
|
4
|
+
export const initialize = (options, name = 'default') => {
|
|
5
|
+
const createdApp = new FronteggApp(options, name);
|
|
6
|
+
|
|
7
|
+
if (typeof document !== 'undefined') {
|
|
8
|
+
var _document$querySelect;
|
|
9
|
+
|
|
10
|
+
if (!customElements.get('frontegg-app')) {
|
|
11
|
+
class FronteggAppContainer extends HTMLElement {
|
|
12
|
+
constructor(...args) {
|
|
13
|
+
super(...args);
|
|
14
|
+
this.app = null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static get observedAttributes() {
|
|
18
|
+
return ['app-name'];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
this.updateContent();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
26
|
+
if (name === 'app-name') {
|
|
27
|
+
if (oldValue === null) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (oldValue === newValue) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.innerHTML = '';
|
|
36
|
+
|
|
37
|
+
if (newValue === null) {
|
|
38
|
+
this.remove();
|
|
39
|
+
} else {
|
|
40
|
+
this.updateContent();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.debug('attributeChangedCallback', name, oldValue, newValue);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
updateContent() {
|
|
48
|
+
var _this$getAttribute;
|
|
49
|
+
|
|
50
|
+
const appName = (_this$getAttribute = this.getAttribute('app-name')) != null ? _this$getAttribute : 'default';
|
|
51
|
+
const app = AppHolder.getInstance(appName);
|
|
52
|
+
|
|
53
|
+
if (app === null) {
|
|
54
|
+
throw Error(`FronteggApp not found for appName: '${appName}'`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.setAttribute('id', `frontegg-app-${app.name}`);
|
|
58
|
+
const adminPortalContainer = createElement(this, 'div', {
|
|
59
|
+
id: `frontegg-admin-portal-container-${app.name}`
|
|
60
|
+
});
|
|
61
|
+
const loginBoxContainer = createElement(this, 'div', {
|
|
62
|
+
id: `frontegg-login-box-container-${app.name}`
|
|
63
|
+
});
|
|
64
|
+
const checkoutDialogContainer = createElement(this, 'div', {
|
|
65
|
+
id: `frontegg-checkout-dialog-container-${app.name}`
|
|
66
|
+
});
|
|
67
|
+
const adminBoxShadowEl = adminPortalContainer.attachShadow({
|
|
68
|
+
mode: 'open'
|
|
69
|
+
});
|
|
70
|
+
const loginBoxShadowEl = loginBoxContainer.attachShadow({
|
|
71
|
+
mode: 'open'
|
|
72
|
+
});
|
|
73
|
+
const checkoutDialogShadowEl = checkoutDialogContainer.attachShadow({
|
|
74
|
+
mode: 'open'
|
|
75
|
+
});
|
|
76
|
+
const adminPortalEl = createElement(adminBoxShadowEl, 'div', {
|
|
77
|
+
id: `frontegg-admin-portal-${app.name}`,
|
|
78
|
+
class: 'frontegg-root-content'
|
|
79
|
+
});
|
|
80
|
+
const loginBoxEl = createElement(loginBoxShadowEl, 'div', {
|
|
81
|
+
id: `frontegg-login-box-${app.name}`,
|
|
82
|
+
class: 'frontegg-root-content'
|
|
83
|
+
});
|
|
84
|
+
const checkoutDialogEl = createElement(checkoutDialogShadowEl, 'div', {
|
|
85
|
+
id: `frontegg-checkout-dialog-${app.name}`,
|
|
86
|
+
class: 'frontegg-root-content'
|
|
87
|
+
});
|
|
88
|
+
app.initContainers({
|
|
89
|
+
adminPortalEl,
|
|
90
|
+
loginBoxEl,
|
|
91
|
+
adminPortalContainer,
|
|
92
|
+
loginBoxContainer,
|
|
93
|
+
checkoutDialogContainer,
|
|
94
|
+
checkoutDialogEl
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
customElements.define('frontegg-app', FronteggAppContainer);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
(_document$querySelect = document.querySelector(`frontegg-app[app-name="${createdApp.name}"]`)) == null ? void 0 : _document$querySelect.remove();
|
|
104
|
+
const element = document.createElement('frontegg-app');
|
|
105
|
+
element.setAttribute('app-name', createdApp.name);
|
|
106
|
+
document.body.appendChild(element);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return createdApp;
|
|
110
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AdminPortal = void 0;
|
|
7
|
+
|
|
8
|
+
var _AppHolder = require("../AppHolder");
|
|
9
|
+
|
|
10
|
+
class AdminPortal {
|
|
11
|
+
static show(name = 'default') {
|
|
12
|
+
_AppHolder.AppHolder.getInstance(name).showAdminPortal();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static hide(name = 'default') {
|
|
16
|
+
_AppHolder.AppHolder.getInstance(name).hideAdminPortal();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.AdminPortal = AdminPortal;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AppHolder = void 0;
|
|
7
|
+
|
|
8
|
+
class AppHolder {
|
|
9
|
+
static setInstance(name, app) {
|
|
10
|
+
AppHolder._apps[name] = app;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static getInstance(name) {
|
|
14
|
+
const app = AppHolder._apps[name];
|
|
15
|
+
|
|
16
|
+
if (!app) {
|
|
17
|
+
throw Error(`[${name}] FronteggApp not found`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return app;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.AppHolder = AppHolder;
|
|
26
|
+
AppHolder._apps = {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CheckoutDialog = void 0;
|
|
7
|
+
|
|
8
|
+
var _AppHolder = require("../AppHolder");
|
|
9
|
+
|
|
10
|
+
class CheckoutDialog {
|
|
11
|
+
static show(opts, name = 'default') {
|
|
12
|
+
_AppHolder.AppHolder.getInstance(name).showCheckoutDialog(opts);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static hide(name = 'default') {
|
|
16
|
+
_AppHolder.AppHolder.getInstance(name).hideCheckoutDialog();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.CheckoutDialog = CheckoutDialog;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.FronteggApp = 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 _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
var _AppHolder = require("../AppHolder");
|
|
19
|
+
|
|
20
|
+
var _restApi = require("@frontegg/rest-api");
|
|
21
|
+
|
|
22
|
+
class FronteggApp {
|
|
23
|
+
constructor(_options, name, iframeRendering = false) {
|
|
24
|
+
var _this$options$store, _this$options$authOpt, _this$options$authOpt2, _this$options$auditsO;
|
|
25
|
+
|
|
26
|
+
this.name = void 0;
|
|
27
|
+
this.iframeRendering = void 0;
|
|
28
|
+
this.options = void 0;
|
|
29
|
+
this.loading = true;
|
|
30
|
+
this.customElementName = '';
|
|
31
|
+
this.adminPortalEl = void 0;
|
|
32
|
+
this.loginBoxEl = void 0;
|
|
33
|
+
this.checkoutDialogEl = void 0;
|
|
34
|
+
this.adminPortalContainer = void 0;
|
|
35
|
+
this.loginBoxContainer = void 0;
|
|
36
|
+
this.checkoutDialogContainer = void 0;
|
|
37
|
+
this.store = void 0;
|
|
38
|
+
this.loadingListeners = [];
|
|
39
|
+
this.updateLocalizations = void 0;
|
|
40
|
+
|
|
41
|
+
this.loadAdminBoxMetadata = async () => {
|
|
42
|
+
const {
|
|
43
|
+
Get
|
|
44
|
+
} = _restApi.fetch;
|
|
45
|
+
|
|
46
|
+
if (!this.options.metadata) {
|
|
47
|
+
try {
|
|
48
|
+
var _data$rows$0$configur, _data$rows, _data$rows$;
|
|
49
|
+
|
|
50
|
+
const data = await Get(`/metadata`, {
|
|
51
|
+
entityName: 'adminBox'
|
|
52
|
+
});
|
|
53
|
+
this.options.metadata = (_data$rows$0$configur = data == null ? void 0 : (_data$rows = data.rows) == null ? void 0 : (_data$rows$ = _data$rows[0]) == null ? void 0 : _data$rows$.configuration) != null ? _data$rows$0$configur : {};
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error('failed to get admin portal metadata', e);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_types.Metadata.set(this.options.metadata, this.name);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
this.requestAuthorize = async () => {
|
|
63
|
+
if (!this.options.hostedLoginBox && !this.options.builderMode && this.options.framework !== 'nextjs') {
|
|
64
|
+
this.store.dispatch({
|
|
65
|
+
type: 'auth/requestAuthorize',
|
|
66
|
+
payload: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
this.updateLocalizationsSetter = localizationUpdateFn => {
|
|
72
|
+
this.updateLocalizations = localizationUpdateFn;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
let appName = (0, _utils.formatName)(name);
|
|
76
|
+
let customElementName = `frontegg-app-${appName}`;
|
|
77
|
+
this.iframeRendering = iframeRendering;
|
|
78
|
+
this.name = appName;
|
|
79
|
+
this.options = (0, _extends2.default)({}, _options, {
|
|
80
|
+
contextOptions: (0, _extends2.default)({
|
|
81
|
+
requestCredentials: 'include'
|
|
82
|
+
}, _options.contextOptions)
|
|
83
|
+
});
|
|
84
|
+
this.customElementName = customElementName;
|
|
85
|
+
this.store = (_this$options$store = this.options.store) != null ? _this$options$store : (0, _reduxStore.createFronteggStore)({
|
|
86
|
+
context: this.options.contextOptions
|
|
87
|
+
}, this, this.options.previewMode, (_this$options$authOpt = this.options.authOptions) != null ? _this$options$authOpt : {}, {
|
|
88
|
+
auth: (_this$options$authOpt2 = this.options.authOptions) != null ? _this$options$authOpt2 : {},
|
|
89
|
+
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
_AppHolder.AppHolder.setInstance(appName, this);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async initContainers(elements) {
|
|
96
|
+
this.adminPortalEl = elements.adminPortalEl;
|
|
97
|
+
this.loginBoxEl = elements.loginBoxEl;
|
|
98
|
+
this.checkoutDialogEl = elements.checkoutDialogEl;
|
|
99
|
+
this.adminPortalContainer = elements.adminPortalContainer;
|
|
100
|
+
this.loginBoxContainer = elements.loginBoxContainer;
|
|
101
|
+
this.checkoutDialogContainer = elements.checkoutDialogContainer;
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
document.body.classList.add('frontegg-loading');
|
|
105
|
+
} catch (e) {}
|
|
106
|
+
|
|
107
|
+
await Promise.all([this.loadAdminBoxMetadata(), this.requestAuthorize()]);
|
|
108
|
+
|
|
109
|
+
if (!this.options.previewMode && !this.options.customLoginBox) {
|
|
110
|
+
this.loadLoginBox();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.loadScript('http://localhost:3002/index.js', 'FronteggAdminPortal');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
updateMetadata(metadata) {
|
|
117
|
+
_types.Metadata.set(metadata, this.name);
|
|
118
|
+
|
|
119
|
+
if (metadata != null && metadata.localizations) {
|
|
120
|
+
var _this$updateLocalizat;
|
|
121
|
+
|
|
122
|
+
(_this$updateLocalizat = this.updateLocalizations) == null ? void 0 : _this$updateLocalizat.call(this, metadata.localizations);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
addOnLoadedListener(listener) {
|
|
127
|
+
if (!this.loading) {
|
|
128
|
+
listener();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.loadingListeners.push(listener);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
loadScript(url, component) {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
if (window[component]) {
|
|
138
|
+
resolve(window[component]);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const script = document.createElement('script');
|
|
143
|
+
script.src = url;
|
|
144
|
+
|
|
145
|
+
script.onload = () => {
|
|
146
|
+
resolve(window[component]);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
script.onerror = e => {
|
|
150
|
+
console.log('Profile page error', e);
|
|
151
|
+
reject(e);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
document.body.append(script);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async loadLoginBox() {
|
|
159
|
+
const FronteggLoginBox = await this.loadScript('http://localhost:3001/index.js', 'FronteggLoginBox');
|
|
160
|
+
FronteggLoginBox.render(this.loginBoxEl, {
|
|
161
|
+
injector: this,
|
|
162
|
+
options: this.options
|
|
163
|
+
});
|
|
164
|
+
this.loading = false;
|
|
165
|
+
this.loadingListeners.forEach(listener => {
|
|
166
|
+
try {
|
|
167
|
+
listener();
|
|
168
|
+
} catch (e) {}
|
|
169
|
+
});
|
|
170
|
+
this.loadingListeners = [];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async showAdminPortal() {
|
|
174
|
+
const FronteggAdminPortal = await this.loadScript('http://localhost:3002/index.js', 'FronteggAdminPortal');
|
|
175
|
+
FronteggAdminPortal.render(this.adminPortalEl, {
|
|
176
|
+
injector: this,
|
|
177
|
+
options: this.options
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
hideAdminPortal() {}
|
|
182
|
+
|
|
183
|
+
showCheckoutDialog(opts) {}
|
|
184
|
+
|
|
185
|
+
hideCheckoutDialog() {}
|
|
186
|
+
|
|
187
|
+
close() {}
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
exports.FronteggApp = FronteggApp;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _FronteggApp = require("./FronteggApp");
|
|
8
|
+
|
|
9
|
+
Object.keys(_FronteggApp).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _FronteggApp[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _FronteggApp[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.HostedLogin = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _reduxStore = require("@frontegg/redux-store");
|
|
13
|
+
|
|
14
|
+
var _AppHolder = require("../AppHolder");
|
|
15
|
+
|
|
16
|
+
var _restApi = require("@frontegg/rest-api");
|
|
17
|
+
|
|
18
|
+
class HostedLogin {
|
|
19
|
+
static setAuthentication(isAuthenticated, accessToken, user, appName = 'default') {
|
|
20
|
+
const app = _AppHolder.AppHolder.getInstance(appName);
|
|
21
|
+
|
|
22
|
+
if (isAuthenticated && accessToken) {
|
|
23
|
+
_restApi.ContextHolder.setAccessToken(accessToken);
|
|
24
|
+
|
|
25
|
+
_restApi.ContextHolder.setUser((0, _extends2.default)({}, user, {
|
|
26
|
+
accessToken
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
app.store.dispatch(_reduxStore.authActions.setState({
|
|
30
|
+
isLoading: false,
|
|
31
|
+
isAuthenticated,
|
|
32
|
+
user
|
|
33
|
+
}));
|
|
34
|
+
app.store.dispatch(_reduxStore.authActions.loadTenants());
|
|
35
|
+
} else {
|
|
36
|
+
_restApi.ContextHolder.setAccessToken(null);
|
|
37
|
+
|
|
38
|
+
_restApi.ContextHolder.setUser(null);
|
|
39
|
+
|
|
40
|
+
app.store.dispatch(_reduxStore.authActions.setState({
|
|
41
|
+
isLoading: false,
|
|
42
|
+
isAuthenticated: false,
|
|
43
|
+
user: null
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.HostedLogin = HostedLogin;
|
package/node/index.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** @license Frontegg v6.0.1-alpha.0
|
|
2
|
+
*
|
|
3
|
+
* This source code is licensed under the MIT license found in the
|
|
4
|
+
* LICENSE file in the root directory of this source tree.
|
|
5
|
+
*/
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
var _AppHolder = require("./AppHolder");
|
|
13
|
+
|
|
14
|
+
Object.keys(_AppHolder).forEach(function (key) {
|
|
15
|
+
if (key === "default" || key === "__esModule") return;
|
|
16
|
+
if (key in exports && exports[key] === _AppHolder[key]) return;
|
|
17
|
+
Object.defineProperty(exports, key, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _AppHolder[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
var _FronteggApp = require("./FronteggApp");
|
|
26
|
+
|
|
27
|
+
Object.keys(_FronteggApp).forEach(function (key) {
|
|
28
|
+
if (key === "default" || key === "__esModule") return;
|
|
29
|
+
if (key in exports && exports[key] === _FronteggApp[key]) return;
|
|
30
|
+
Object.defineProperty(exports, key, {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _FronteggApp[key];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
var _HostedLogin = require("./HostedLogin");
|
|
39
|
+
|
|
40
|
+
Object.keys(_HostedLogin).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _HostedLogin[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _HostedLogin[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var _AdminPortal = require("./AdminPortal");
|
|
52
|
+
|
|
53
|
+
Object.keys(_AdminPortal).forEach(function (key) {
|
|
54
|
+
if (key === "default" || key === "__esModule") return;
|
|
55
|
+
if (key in exports && exports[key] === _AdminPortal[key]) return;
|
|
56
|
+
Object.defineProperty(exports, key, {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () {
|
|
59
|
+
return _AdminPortal[key];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
var _CheckoutDialog = require("./CheckoutDialog");
|
|
65
|
+
|
|
66
|
+
Object.keys(_CheckoutDialog).forEach(function (key) {
|
|
67
|
+
if (key === "default" || key === "__esModule") return;
|
|
68
|
+
if (key in exports && exports[key] === _CheckoutDialog[key]) return;
|
|
69
|
+
Object.defineProperty(exports, key, {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () {
|
|
72
|
+
return _CheckoutDialog[key];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
var _initialize = require("./initialize");
|
|
78
|
+
|
|
79
|
+
Object.keys(_initialize).forEach(function (key) {
|
|
80
|
+
if (key === "default" || key === "__esModule") return;
|
|
81
|
+
if (key in exports && exports[key] === _initialize[key]) return;
|
|
82
|
+
Object.defineProperty(exports, key, {
|
|
83
|
+
enumerable: true,
|
|
84
|
+
get: function () {
|
|
85
|
+
return _initialize[key];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initialize = void 0;
|
|
7
|
+
|
|
8
|
+
var _FronteggApp = require("./FronteggApp");
|
|
9
|
+
|
|
10
|
+
var _AppHolder = require("./AppHolder");
|
|
11
|
+
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
|
|
14
|
+
const initialize = (options, name = 'default') => {
|
|
15
|
+
const createdApp = new _FronteggApp.FronteggApp(options, name);
|
|
16
|
+
|
|
17
|
+
if (typeof document !== 'undefined') {
|
|
18
|
+
var _document$querySelect;
|
|
19
|
+
|
|
20
|
+
if (!customElements.get('frontegg-app')) {
|
|
21
|
+
class FronteggAppContainer extends HTMLElement {
|
|
22
|
+
constructor(...args) {
|
|
23
|
+
super(...args);
|
|
24
|
+
this.app = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static get observedAttributes() {
|
|
28
|
+
return ['app-name'];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
this.updateContent();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
36
|
+
if (name === 'app-name') {
|
|
37
|
+
if (oldValue === null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (oldValue === newValue) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.innerHTML = '';
|
|
46
|
+
|
|
47
|
+
if (newValue === null) {
|
|
48
|
+
this.remove();
|
|
49
|
+
} else {
|
|
50
|
+
this.updateContent();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
console.debug('attributeChangedCallback', name, oldValue, newValue);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
updateContent() {
|
|
58
|
+
var _this$getAttribute;
|
|
59
|
+
|
|
60
|
+
const appName = (_this$getAttribute = this.getAttribute('app-name')) != null ? _this$getAttribute : 'default';
|
|
61
|
+
|
|
62
|
+
const app = _AppHolder.AppHolder.getInstance(appName);
|
|
63
|
+
|
|
64
|
+
if (app === null) {
|
|
65
|
+
throw Error(`FronteggApp not found for appName: '${appName}'`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.setAttribute('id', `frontegg-app-${app.name}`);
|
|
69
|
+
const adminPortalContainer = (0, _utils.createElement)(this, 'div', {
|
|
70
|
+
id: `frontegg-admin-portal-container-${app.name}`
|
|
71
|
+
});
|
|
72
|
+
const loginBoxContainer = (0, _utils.createElement)(this, 'div', {
|
|
73
|
+
id: `frontegg-login-box-container-${app.name}`
|
|
74
|
+
});
|
|
75
|
+
const checkoutDialogContainer = (0, _utils.createElement)(this, 'div', {
|
|
76
|
+
id: `frontegg-checkout-dialog-container-${app.name}`
|
|
77
|
+
});
|
|
78
|
+
const adminBoxShadowEl = adminPortalContainer.attachShadow({
|
|
79
|
+
mode: 'open'
|
|
80
|
+
});
|
|
81
|
+
const loginBoxShadowEl = loginBoxContainer.attachShadow({
|
|
82
|
+
mode: 'open'
|
|
83
|
+
});
|
|
84
|
+
const checkoutDialogShadowEl = checkoutDialogContainer.attachShadow({
|
|
85
|
+
mode: 'open'
|
|
86
|
+
});
|
|
87
|
+
const adminPortalEl = (0, _utils.createElement)(adminBoxShadowEl, 'div', {
|
|
88
|
+
id: `frontegg-admin-portal-${app.name}`,
|
|
89
|
+
class: 'frontegg-root-content'
|
|
90
|
+
});
|
|
91
|
+
const loginBoxEl = (0, _utils.createElement)(loginBoxShadowEl, 'div', {
|
|
92
|
+
id: `frontegg-login-box-${app.name}`,
|
|
93
|
+
class: 'frontegg-root-content'
|
|
94
|
+
});
|
|
95
|
+
const checkoutDialogEl = (0, _utils.createElement)(checkoutDialogShadowEl, 'div', {
|
|
96
|
+
id: `frontegg-checkout-dialog-${app.name}`,
|
|
97
|
+
class: 'frontegg-root-content'
|
|
98
|
+
});
|
|
99
|
+
app.initContainers({
|
|
100
|
+
adminPortalEl,
|
|
101
|
+
loginBoxEl,
|
|
102
|
+
adminPortalContainer,
|
|
103
|
+
loginBoxContainer,
|
|
104
|
+
checkoutDialogContainer,
|
|
105
|
+
checkoutDialogEl
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
customElements.define('frontegg-app', FronteggAppContainer);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
(_document$querySelect = document.querySelector(`frontegg-app[app-name="${createdApp.name}"]`)) == null ? void 0 : _document$querySelect.remove();
|
|
115
|
+
const element = document.createElement('frontegg-app');
|
|
116
|
+
element.setAttribute('app-name', createdApp.name);
|
|
117
|
+
document.body.appendChild(element);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return createdApp;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
exports.initialize = initialize;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatName = exports.createElement = void 0;
|
|
7
|
+
|
|
8
|
+
const formatName = name => name.replace(/\W+/g, ' ').split(/ |\B(?=[A-Z])/).map(word => word.toLowerCase()).join('');
|
|
9
|
+
|
|
10
|
+
exports.formatName = formatName;
|
|
11
|
+
|
|
12
|
+
const createElement = (container, type, attrs = {}) => {
|
|
13
|
+
const el = document.createElement(type);
|
|
14
|
+
Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));
|
|
15
|
+
container.appendChild(el);
|
|
16
|
+
return el;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.createElement = createElement;
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@frontegg/js",
|
|
3
|
+
"version": "6.0.1-alpha.0",
|
|
4
|
+
"main": "./node/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@babel/runtime": "^7.17.2",
|
|
8
|
+
"@frontegg/types": "6.0.1-alpha.0"
|
|
9
|
+
},
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"private": false,
|
|
12
|
+
"module": "./index.js",
|
|
13
|
+
"types": "./index.d.ts"
|
|
14
|
+
}
|
package/utils/index.d.ts
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const formatName = name => name.replace(/\W+/g, ' ').split(/ |\B(?=[A-Z])/).map(word => word.toLowerCase()).join('');
|
|
2
|
+
export const createElement = (container, type, attrs = {}) => {
|
|
3
|
+
const el = document.createElement(type);
|
|
4
|
+
Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));
|
|
5
|
+
container.appendChild(el);
|
|
6
|
+
return el;
|
|
7
|
+
};
|