@frontegg/js 6.0.1-alpha.3 → 6.0.1-alpha.6

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.
@@ -14,6 +14,7 @@ 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;
19
20
  loginBoxEl?: HTMLElement;
@@ -33,7 +34,7 @@ export declare class FronteggApp {
33
34
  updateLocalizationsSetter: (localizationUpdateFn: (localizations: LocalizationsOverrides) => void) => void;
34
35
  updateMetadata(metadata: FronteggAppOptions['metadata']): void;
35
36
  addOnLoadedListener(listener: () => void): void;
36
- loadScript(url: string, component: string): Promise<unknown>;
37
+ loadScript(component: string): Promise<unknown>;
37
38
  loadLoginBox(): Promise<void>;
38
39
  showAdminPortal(): Promise<void>;
39
40
  hideAdminPortal(): void;
@@ -13,6 +13,7 @@ export class FronteggApp {
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;
18
19
  this.loginBoxEl = void 0;
@@ -67,6 +68,11 @@ export class FronteggApp {
67
68
  requestCredentials: 'include'
68
69
  }, _options.contextOptions)
69
70
  });
71
+
72
+ if (this.options.cdnUrl) {
73
+ this.cdnUrl = this.options.cdnUrl;
74
+ }
75
+
70
76
  this.customElementName = customElementName;
71
77
  this.store = (_this$options$store = this.options.store) != null ? _this$options$store : createFronteggStore({
72
78
  context: this.options.contextOptions
@@ -95,7 +101,7 @@ export class FronteggApp {
95
101
  this.loadLoginBox();
96
102
  }
97
103
 
98
- this.loadScript(`https://assets.frontegg.com/admin-box/admin-portal/${versions.cdnVersion}/index.js`, 'FronteggAdminPortal');
104
+ this.loadScript('FronteggAdminPortal');
99
105
  }
100
106
 
101
107
  updateMetadata(metadata) {
@@ -117,15 +123,21 @@ export class FronteggApp {
117
123
  this.loadingListeners.push(listener);
118
124
  }
119
125
 
120
- loadScript(url, component) {
126
+ loadScript(component) {
121
127
  return new Promise((resolve, reject) => {
122
128
  if (window[component]) {
123
129
  resolve(window[component]);
124
130
  return;
125
131
  }
126
132
 
133
+ const entries = {
134
+ FronteggLoginBox: 'login-box/index.js',
135
+ FronteggAdminPortal: 'admin-portal/index.js'
136
+ };
127
137
  const script = document.createElement('script');
128
- script.src = url;
138
+ script.src = `${this.cdnUrl}/${entries[component]}`;
139
+ script.setAttribute('id', `${component}Script`);
140
+ script.setAttribute('cdn-url', this.cdnUrl);
129
141
 
130
142
  script.onload = () => {
131
143
  resolve(window[component]);
@@ -141,7 +153,7 @@ export class FronteggApp {
141
153
  }
142
154
 
143
155
  async loadLoginBox() {
144
- const FronteggLoginBox = await this.loadScript(`https://assets.frontegg.com/admin-box/login-box/${versions.cdnVersion}/index.js`, 'FronteggLoginBox');
156
+ const FronteggLoginBox = await this.loadScript('FronteggLoginBox');
145
157
  FronteggLoginBox.render(this.loginBoxEl, {
146
158
  injector: this,
147
159
  options: this.options
@@ -156,7 +168,7 @@ export class FronteggApp {
156
168
  }
157
169
 
158
170
  async showAdminPortal() {
159
- const FronteggAdminPortal = await this.loadScript(`https://assets.frontegg.com/admin-box/admin-portal/${versions.cdnVersion}/index.js`, 'FronteggAdminPortal');
171
+ const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
160
172
  FronteggAdminPortal.render(this.adminPortalEl, {
161
173
  injector: this,
162
174
  options: this.options
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.0.1-alpha.3
1
+ /** @license Frontegg v6.0.1-alpha.6
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.
@@ -29,6 +29,7 @@ class FronteggApp {
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;
34
35
  this.loginBoxEl = void 0;
@@ -83,6 +84,11 @@ class FronteggApp {
83
84
  requestCredentials: 'include'
84
85
  }, _options.contextOptions)
85
86
  });
87
+
88
+ if (this.options.cdnUrl) {
89
+ this.cdnUrl = this.options.cdnUrl;
90
+ }
91
+
86
92
  this.customElementName = customElementName;
87
93
  this.store = (_this$options$store = this.options.store) != null ? _this$options$store : (0, _reduxStore.createFronteggStore)({
88
94
  context: this.options.contextOptions
@@ -112,7 +118,7 @@ class FronteggApp {
112
118
  this.loadLoginBox();
113
119
  }
114
120
 
115
- this.loadScript(`https://assets.frontegg.com/admin-box/admin-portal/${_version.default.cdnVersion}/index.js`, 'FronteggAdminPortal');
121
+ this.loadScript('FronteggAdminPortal');
116
122
  }
117
123
 
118
124
  updateMetadata(metadata) {
@@ -134,15 +140,21 @@ class FronteggApp {
134
140
  this.loadingListeners.push(listener);
135
141
  }
136
142
 
137
- loadScript(url, component) {
143
+ loadScript(component) {
138
144
  return new Promise((resolve, reject) => {
139
145
  if (window[component]) {
140
146
  resolve(window[component]);
141
147
  return;
142
148
  }
143
149
 
150
+ const entries = {
151
+ FronteggLoginBox: 'login-box/index.js',
152
+ FronteggAdminPortal: 'admin-portal/index.js'
153
+ };
144
154
  const script = document.createElement('script');
145
- script.src = url;
155
+ script.src = `${this.cdnUrl}/${entries[component]}`;
156
+ script.setAttribute('id', `${component}Script`);
157
+ script.setAttribute('cdn-url', this.cdnUrl);
146
158
 
147
159
  script.onload = () => {
148
160
  resolve(window[component]);
@@ -158,7 +170,7 @@ class FronteggApp {
158
170
  }
159
171
 
160
172
  async loadLoginBox() {
161
- const FronteggLoginBox = await this.loadScript(`https://assets.frontegg.com/admin-box/login-box/${_version.default.cdnVersion}/index.js`, 'FronteggLoginBox');
173
+ const FronteggLoginBox = await this.loadScript('FronteggLoginBox');
162
174
  FronteggLoginBox.render(this.loginBoxEl, {
163
175
  injector: this,
164
176
  options: this.options
@@ -173,7 +185,7 @@ class FronteggApp {
173
185
  }
174
186
 
175
187
  async showAdminPortal() {
176
- const FronteggAdminPortal = await this.loadScript(`https://assets.frontegg.com/admin-box/admin-portal/${_version.default.cdnVersion}/index.js`, 'FronteggAdminPortal');
188
+ const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
177
189
  FronteggAdminPortal.render(this.adminPortalEl, {
178
190
  injector: this,
179
191
  options: this.options
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.0.1-alpha.3
1
+ /** @license Frontegg v6.0.1-alpha.6
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.
package/node/version.js CHANGED
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _default = {
8
- "cdnVersion": "6.0.1-alpha.3"
8
+ "cdnVersion": "6.0.1-alpha.6"
9
9
  };
10
10
  exports.default = _default;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@frontegg/js",
3
- "version": "6.0.1-alpha.3",
3
+ "version": "6.0.1-alpha.6",
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.1-alpha.3"
8
+ "@frontegg/types": "6.0.1-alpha.6"
9
9
  },
10
10
  "sideEffects": false,
11
11
  "private": false,
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export default {
2
- "cdnVersion": "6.0.1-alpha.3"
2
+ "cdnVersion": "6.0.1-alpha.6"
3
3
  };