@frontegg/js 6.10.1 → 6.12.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.js +20 -7
- package/AdminPortalRenderer/index.js +99 -59
- package/AppHolder/index.js +22 -11
- package/CheckoutDialog/index.js +20 -7
- package/FronteggApp/FronteggApp.d.ts +2 -0
- package/FronteggApp/FronteggApp.js +355 -165
- package/HostedLogin/index.js +35 -24
- package/LoginBoxRenderer/index.js +111 -70
- package/index.js +1 -1
- package/initialize.js +113 -81
- package/node/AdminPortal/index.js +25 -7
- package/node/AdminPortalRenderer/index.js +105 -63
- package/node/AppHolder/index.js +25 -11
- package/node/CheckoutDialog/index.js +25 -7
- package/node/FronteggApp/FronteggApp.js +363 -170
- package/node/FronteggApp/index.js +1 -1
- package/node/HostedLogin/index.js +42 -29
- package/node/LoginBoxRenderer/index.js +117 -74
- package/node/index.js +9 -9
- package/node/initialize.js +120 -82
- package/node/utils/index.js +31 -22
- package/node/version.js +3 -3
- package/package.json +14 -2
- package/umd/frontegg.development.js +26540 -0
- package/umd/frontegg.production.min.js +2 -0
- package/umd/frontegg.production.min.js.LICENSE.txt +1 -0
- package/utils/index.js +29 -20
- package/version.js +1 -1
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
6
|
import { createFronteggStore } from '@frontegg/redux-store';
|
|
3
7
|
import { Metadata } from '@frontegg/types';
|
|
4
8
|
import { formatName } from '../utils';
|
|
@@ -7,15 +11,23 @@ import { fetch as FronteggFetch } from '@frontegg/rest-api';
|
|
|
7
11
|
import * as FronteggRestApi from '@frontegg/rest-api';
|
|
8
12
|
import * as FronteggTypes from '@frontegg/types';
|
|
9
13
|
import versions from '../version';
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
var _this
|
|
14
|
+
export var FronteggApp = /*#__PURE__*/function () {
|
|
15
|
+
function FronteggApp(_options, name) {
|
|
16
|
+
var _this = this,
|
|
17
|
+
_this$options$authOpt,
|
|
18
|
+
_this$options$store,
|
|
19
|
+
_this$options$authOpt2,
|
|
20
|
+
_this$options$auditsO;
|
|
21
|
+
|
|
22
|
+
var iframeRendering = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
23
|
+
|
|
24
|
+
_classCallCheck(this, FronteggApp);
|
|
13
25
|
|
|
14
26
|
this.name = void 0;
|
|
15
27
|
this.iframeRendering = void 0;
|
|
16
28
|
this.options = void 0;
|
|
17
29
|
this.loading = true;
|
|
18
|
-
this.cdnUrl =
|
|
30
|
+
this.cdnUrl = "https://assets.frontegg.com/admin-box/".concat(versions.cdnVersion);
|
|
19
31
|
this.customElementName = '';
|
|
20
32
|
this.adminPortalEl = void 0;
|
|
21
33
|
this.adminPortalRenderer = void 0;
|
|
@@ -30,51 +42,99 @@ export class FronteggApp {
|
|
|
30
42
|
this.flags = {};
|
|
31
43
|
this.loadingListeners = [];
|
|
32
44
|
this.updateLocalizations = void 0;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
this.loadAdminBoxMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
46
|
+
var Get, _data$rows$0$configur, _data$rows, _data$rows$, data;
|
|
47
|
+
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
Get = FronteggFetch.Get;
|
|
53
|
+
|
|
54
|
+
if (_this.options.metadata) {
|
|
55
|
+
_context.next = 12;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_context.prev = 2;
|
|
60
|
+
_context.next = 5;
|
|
61
|
+
return Get("/metadata", {
|
|
62
|
+
entityName: 'adminBox'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
case 5:
|
|
66
|
+
data = _context.sent;
|
|
67
|
+
_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 : {};
|
|
68
|
+
_context.next = 12;
|
|
69
|
+
break;
|
|
70
|
+
|
|
71
|
+
case 9:
|
|
72
|
+
_context.prev = 9;
|
|
73
|
+
_context.t0 = _context["catch"](2);
|
|
74
|
+
console.error('failed to get admin portal metadata', _context.t0);
|
|
75
|
+
|
|
76
|
+
case 12:
|
|
77
|
+
Metadata.set(_this.options.metadata, _this.name);
|
|
78
|
+
|
|
79
|
+
case 13:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context.stop();
|
|
82
|
+
}
|
|
49
83
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
};
|
|
84
|
+
}, _callee, null, [[2, 9]]);
|
|
85
|
+
}));
|
|
86
|
+
this.requestAuthorize = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
87
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
88
|
+
while (1) {
|
|
89
|
+
switch (_context2.prev = _context2.next) {
|
|
90
|
+
case 0:
|
|
91
|
+
if (!_this.options.hostedLoginBox && !_this.options.builderMode && _this.options.framework !== 'nextjs') {
|
|
92
|
+
_this.store.dispatch({
|
|
93
|
+
type: 'auth/requestAuthorize',
|
|
94
|
+
payload: true
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case 1:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context2.stop();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}, _callee2);
|
|
104
|
+
}));
|
|
105
|
+
this.loadFeatureFlags = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
106
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
107
|
+
while (1) {
|
|
108
|
+
switch (_context3.prev = _context3.next) {
|
|
109
|
+
case 0:
|
|
110
|
+
_context3.prev = 0;
|
|
111
|
+
_context3.next = 3;
|
|
112
|
+
return FronteggRestApi.loadFeatureFlags();
|
|
113
|
+
|
|
114
|
+
case 3:
|
|
115
|
+
_this.flags = _context3.sent;
|
|
116
|
+
_context3.next = 9;
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case 6:
|
|
120
|
+
_context3.prev = 6;
|
|
121
|
+
_context3.t0 = _context3["catch"](0);
|
|
122
|
+
console.error('failed to get admin portal feature flags', _context3.t0);
|
|
123
|
+
|
|
124
|
+
case 9:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context3.stop();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, _callee3, null, [[0, 6]]);
|
|
130
|
+
}));
|
|
71
131
|
|
|
72
|
-
this.updateLocalizationsSetter = localizationUpdateFn
|
|
73
|
-
|
|
132
|
+
this.updateLocalizationsSetter = function (localizationUpdateFn) {
|
|
133
|
+
_this.updateLocalizations = localizationUpdateFn;
|
|
74
134
|
};
|
|
75
135
|
|
|
76
|
-
|
|
77
|
-
|
|
136
|
+
var appName = formatName(name);
|
|
137
|
+
var customElementName = "frontegg-app-".concat(appName);
|
|
78
138
|
this.iframeRendering = iframeRendering;
|
|
79
139
|
this.name = appName;
|
|
80
140
|
this.options = _extends({}, _options, {
|
|
@@ -88,7 +148,7 @@ export class FronteggApp {
|
|
|
88
148
|
}
|
|
89
149
|
|
|
90
150
|
this.customElementName = customElementName;
|
|
91
|
-
|
|
151
|
+
var authOptions = this.options.authOptions ? _extends({}, this.options.authOptions, {
|
|
92
152
|
hostedLoginBox: this.options.hostedLoginBox
|
|
93
153
|
}) : {
|
|
94
154
|
hostedLoginBox: this.options.hostedLoginBox
|
|
@@ -103,140 +163,270 @@ export class FronteggApp {
|
|
|
103
163
|
AppHolder.setInstance(appName, this);
|
|
104
164
|
}
|
|
105
165
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
166
|
+
_createClass(FronteggApp, [{
|
|
167
|
+
key: "initContainers",
|
|
168
|
+
value: function () {
|
|
169
|
+
var _initContainers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(elements) {
|
|
170
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
171
|
+
while (1) {
|
|
172
|
+
switch (_context4.prev = _context4.next) {
|
|
173
|
+
case 0:
|
|
174
|
+
this.adminPortalEl = elements.adminPortalEl;
|
|
175
|
+
this.loginBoxEl = elements.loginBoxEl;
|
|
176
|
+
this.checkoutDialogEl = elements.checkoutDialogEl;
|
|
177
|
+
this.adminPortalContainer = elements.adminPortalContainer;
|
|
178
|
+
this.loginBoxContainer = elements.loginBoxContainer;
|
|
179
|
+
this.checkoutDialogContainer = elements.checkoutDialogContainer;
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
document.body.classList.add('frontegg-loading');
|
|
183
|
+
} catch (e) {}
|
|
184
|
+
|
|
185
|
+
_context4.next = 9;
|
|
186
|
+
return Promise.all([this.loadAdminBoxMetadata(), this.requestAuthorize(), this.loadFeatureFlags()]);
|
|
187
|
+
|
|
188
|
+
case 9:
|
|
189
|
+
if (!this.options.previewMode && !this.options.customLoginBox) {
|
|
190
|
+
this.loadLoginBox();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
this.loadScript('FronteggAdminPortal');
|
|
194
|
+
|
|
195
|
+
case 11:
|
|
196
|
+
case "end":
|
|
197
|
+
return _context4.stop();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, _callee4, this);
|
|
201
|
+
}));
|
|
202
|
+
|
|
203
|
+
function initContainers(_x) {
|
|
204
|
+
return _initContainers.apply(this, arguments);
|
|
205
|
+
}
|
|
126
206
|
|
|
127
|
-
|
|
128
|
-
|
|
207
|
+
return initContainers;
|
|
208
|
+
}()
|
|
209
|
+
}, {
|
|
210
|
+
key: "updateMetadata",
|
|
211
|
+
value: function updateMetadata(metadata) {
|
|
212
|
+
Metadata.set(metadata, this.name);
|
|
129
213
|
|
|
130
|
-
|
|
131
|
-
|
|
214
|
+
if (metadata != null && metadata.localizations) {
|
|
215
|
+
var _this$updateLocalizat;
|
|
132
216
|
|
|
133
|
-
|
|
217
|
+
(_this$updateLocalizat = this.updateLocalizations) == null ? void 0 : _this$updateLocalizat.call(this, metadata.localizations);
|
|
218
|
+
}
|
|
134
219
|
}
|
|
135
|
-
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "addOnLoadedListener",
|
|
222
|
+
value: function addOnLoadedListener(listener) {
|
|
223
|
+
if (!this.loading) {
|
|
224
|
+
listener();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
136
227
|
|
|
137
|
-
|
|
138
|
-
if (!this.loading) {
|
|
139
|
-
listener();
|
|
140
|
-
return;
|
|
228
|
+
this.loadingListeners.push(listener);
|
|
141
229
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (window[component]) {
|
|
150
|
-
resolve(window[component]);
|
|
151
|
-
return;
|
|
230
|
+
}, {
|
|
231
|
+
key: "ready",
|
|
232
|
+
value: function ready(listener) {
|
|
233
|
+
if (this.loading) {
|
|
234
|
+
listener();
|
|
235
|
+
} else {
|
|
236
|
+
this.addOnLoadedListener(listener);
|
|
152
237
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "loginWithRedirect",
|
|
241
|
+
value: function loginWithRedirect() {
|
|
242
|
+
this.store.dispatch({
|
|
243
|
+
type: 'auth/setState',
|
|
244
|
+
payload: {
|
|
245
|
+
isLoading: true
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
this.store.dispatch({
|
|
249
|
+
type: 'auth/requestHostedLoginAuthorize'
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}, {
|
|
253
|
+
key: "loadScript",
|
|
254
|
+
value: function loadScript(component) {
|
|
255
|
+
var _this2 = this;
|
|
256
|
+
|
|
257
|
+
return new Promise(function (resolve, reject) {
|
|
258
|
+
// TODO: prevent this behavior if development
|
|
259
|
+
if (window[component]) {
|
|
172
260
|
resolve(window[component]);
|
|
261
|
+
return;
|
|
173
262
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
var entries = {
|
|
267
|
+
FronteggLoginBox: 'login-box/index.js',
|
|
268
|
+
FronteggAdminPortal: 'admin-portal/index.js'
|
|
269
|
+
};
|
|
270
|
+
var script = document.createElement('script');
|
|
271
|
+
script.src = "".concat(_this2.cdnUrl, "/").concat(entries[component]);
|
|
272
|
+
script.setAttribute('id', "".concat(component, "Script"));
|
|
273
|
+
script.setAttribute('cdn-url', _this2.cdnUrl);
|
|
274
|
+
|
|
275
|
+
script.onload = function () {
|
|
276
|
+
if (window["".concat(component, "Init")]) {
|
|
277
|
+
resolve(window["".concat(component, "Init")]({
|
|
278
|
+
FronteggRestApi: FronteggRestApi,
|
|
279
|
+
FronteggTypes: FronteggTypes
|
|
280
|
+
}));
|
|
281
|
+
} else {
|
|
282
|
+
resolve(window[component]);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
script.onerror = function (e) {
|
|
287
|
+
console.log('Profile page error', e);
|
|
288
|
+
reject(e);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
document.body.append(script);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
key: "loadLoginBox",
|
|
296
|
+
value: function () {
|
|
297
|
+
var _loadLoginBox = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
298
|
+
var FronteggLoginBox;
|
|
299
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
300
|
+
while (1) {
|
|
301
|
+
switch (_context5.prev = _context5.next) {
|
|
302
|
+
case 0:
|
|
303
|
+
_context5.next = 2;
|
|
304
|
+
return this.loadScript('FronteggLoginBox');
|
|
305
|
+
|
|
306
|
+
case 2:
|
|
307
|
+
FronteggLoginBox = _context5.sent;
|
|
308
|
+
FronteggLoginBox.render(this.loginBoxEl, {
|
|
309
|
+
injector: this,
|
|
310
|
+
options: this.options
|
|
311
|
+
});
|
|
312
|
+
this.loading = false;
|
|
313
|
+
this.loadingListeners.forEach(function (listener) {
|
|
314
|
+
try {
|
|
315
|
+
listener();
|
|
316
|
+
} catch (e) {}
|
|
317
|
+
});
|
|
318
|
+
this.loadingListeners = [];
|
|
319
|
+
|
|
320
|
+
case 7:
|
|
321
|
+
case "end":
|
|
322
|
+
return _context5.stop();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}, _callee5, this);
|
|
326
|
+
}));
|
|
327
|
+
|
|
328
|
+
function loadLoginBox() {
|
|
329
|
+
return _loadLoginBox.apply(this, arguments);
|
|
330
|
+
}
|
|
180
331
|
|
|
181
|
-
|
|
182
|
-
})
|
|
183
|
-
}
|
|
332
|
+
return loadLoginBox;
|
|
333
|
+
}()
|
|
334
|
+
}, {
|
|
335
|
+
key: "showAdminPortal",
|
|
336
|
+
value: function () {
|
|
337
|
+
var _showAdminPortal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
338
|
+
var FronteggAdminPortal;
|
|
339
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
340
|
+
while (1) {
|
|
341
|
+
switch (_context6.prev = _context6.next) {
|
|
342
|
+
case 0:
|
|
343
|
+
_context6.next = 2;
|
|
344
|
+
return this.loadScript('FronteggAdminPortal');
|
|
345
|
+
|
|
346
|
+
case 2:
|
|
347
|
+
FronteggAdminPortal = _context6.sent;
|
|
348
|
+
this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
|
|
349
|
+
injector: this,
|
|
350
|
+
options: this.options
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
case 4:
|
|
354
|
+
case "end":
|
|
355
|
+
return _context6.stop();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}, _callee6, this);
|
|
359
|
+
}));
|
|
360
|
+
|
|
361
|
+
function showAdminPortal() {
|
|
362
|
+
return _showAdminPortal.apply(this, arguments);
|
|
363
|
+
}
|
|
184
364
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
this.loading = false;
|
|
192
|
-
this.loadingListeners.forEach(listener => {
|
|
365
|
+
return showAdminPortal;
|
|
366
|
+
}()
|
|
367
|
+
}, {
|
|
368
|
+
key: "hideAdminPortal",
|
|
369
|
+
value: function hideAdminPortal() {
|
|
193
370
|
try {
|
|
194
|
-
|
|
195
|
-
} catch (e) {}
|
|
196
|
-
});
|
|
197
|
-
this.loadingListeners = [];
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
async showAdminPortal() {
|
|
201
|
-
const FronteggAdminPortal = await this.loadScript('FronteggAdminPortal');
|
|
202
|
-
this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
|
|
203
|
-
injector: this,
|
|
204
|
-
options: this.options
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
hideAdminPortal() {
|
|
209
|
-
try {
|
|
210
|
-
var _this$adminPortalRend;
|
|
371
|
+
var _this$adminPortalRend;
|
|
211
372
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
373
|
+
(_this$adminPortalRend = this.adminPortalRenderer) == null ? void 0 : _this$adminPortalRend.unmount();
|
|
374
|
+
} catch (e) {
|
|
375
|
+
console.error('Failed to unmount admin portal', e);
|
|
376
|
+
}
|
|
215
377
|
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
378
|
+
}, {
|
|
379
|
+
key: "showCheckoutDialog",
|
|
380
|
+
value: function () {
|
|
381
|
+
var _showCheckoutDialog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(opts) {
|
|
382
|
+
var FronteggAdminPortal;
|
|
383
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
384
|
+
while (1) {
|
|
385
|
+
switch (_context7.prev = _context7.next) {
|
|
386
|
+
case 0:
|
|
387
|
+
_context7.next = 2;
|
|
388
|
+
return this.loadScript('FronteggAdminPortal');
|
|
389
|
+
|
|
390
|
+
case 2:
|
|
391
|
+
FronteggAdminPortal = _context7.sent;
|
|
392
|
+
this.checkoutDialogRenderer = FronteggAdminPortal.renderCheckoutDialog(this.checkoutDialogEl, _extends({
|
|
393
|
+
injector: this
|
|
394
|
+
}, opts, {
|
|
395
|
+
options: this.options
|
|
396
|
+
}));
|
|
397
|
+
|
|
398
|
+
case 4:
|
|
399
|
+
case "end":
|
|
400
|
+
return _context7.stop();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}, _callee7, this);
|
|
404
|
+
}));
|
|
405
|
+
|
|
406
|
+
function showCheckoutDialog(_x2) {
|
|
407
|
+
return _showCheckoutDialog.apply(this, arguments);
|
|
408
|
+
}
|
|
226
409
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
410
|
+
return showCheckoutDialog;
|
|
411
|
+
}()
|
|
412
|
+
}, {
|
|
413
|
+
key: "hideCheckoutDialog",
|
|
414
|
+
value: function hideCheckoutDialog() {
|
|
415
|
+
try {
|
|
416
|
+
var _this$checkoutDialogR;
|
|
230
417
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
418
|
+
(_this$checkoutDialogR = this.checkoutDialogRenderer) == null ? void 0 : _this$checkoutDialogR.unmount();
|
|
419
|
+
} catch (e) {
|
|
420
|
+
console.error('Failed to unmount checkout dialog', e);
|
|
421
|
+
}
|
|
234
422
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
423
|
+
}, {
|
|
424
|
+
key: "close",
|
|
425
|
+
value: function close() {
|
|
426
|
+
this.hideAdminPortal();
|
|
427
|
+
this.hideCheckoutDialog();
|
|
428
|
+
}
|
|
429
|
+
}]);
|
|
241
430
|
|
|
242
|
-
|
|
431
|
+
return FronteggApp;
|
|
432
|
+
}();
|
package/HostedLogin/index.js
CHANGED
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
4
|
import { authActions } from '@frontegg/redux-store';
|
|
3
5
|
import { AppHolder } from '../AppHolder';
|
|
4
6
|
import { ContextHolder } from '@frontegg/rest-api';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
export var HostedLogin = /*#__PURE__*/function () {
|
|
8
|
+
function HostedLogin() {
|
|
9
|
+
_classCallCheck(this, HostedLogin);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_createClass(HostedLogin, null, [{
|
|
13
|
+
key: "setAuthentication",
|
|
14
|
+
value: function setAuthentication(isAuthenticated, accessToken, user) {
|
|
15
|
+
var appName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'default';
|
|
16
|
+
var app = AppHolder.getInstance(appName);
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
if (isAuthenticated && accessToken) {
|
|
19
|
+
ContextHolder.setAccessToken(accessToken);
|
|
20
|
+
ContextHolder.setUser(_extends({}, user, {
|
|
21
|
+
accessToken: accessToken
|
|
22
|
+
}));
|
|
23
|
+
app.store.dispatch(authActions.setState({
|
|
24
|
+
isLoading: false,
|
|
25
|
+
isAuthenticated: isAuthenticated,
|
|
26
|
+
user: user
|
|
27
|
+
}));
|
|
28
|
+
app.store.dispatch(authActions.loadTenants());
|
|
29
|
+
} else {
|
|
30
|
+
ContextHolder.setAccessToken(null);
|
|
31
|
+
ContextHolder.setUser(null);
|
|
32
|
+
app.store.dispatch(authActions.setState({
|
|
33
|
+
isLoading: false,
|
|
34
|
+
isAuthenticated: false,
|
|
35
|
+
user: null
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
28
38
|
}
|
|
29
|
-
}
|
|
39
|
+
}]);
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
return HostedLogin;
|
|
42
|
+
}();
|