@turnkey/sdk-react 3.0.3 → 3.0.5
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/CHANGELOG.md +19 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs +84 -102
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -1
- package/dist/components/auth/Apple.d.ts +4 -2
- package/dist/components/auth/Apple.d.ts.map +1 -1
- package/dist/components/auth/Apple.js +66 -41
- package/dist/components/auth/Apple.js.map +1 -1
- package/dist/components/auth/Apple.mjs +66 -41
- package/dist/components/auth/Apple.mjs.map +1 -1
- package/dist/components/auth/Auth.d.ts.map +1 -1
- package/dist/components/auth/Auth.js +31 -41
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +127 -172
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/Facebook.js.map +1 -1
- package/dist/components/auth/Facebook.mjs +3 -3
- package/dist/components/auth/Facebook.mjs.map +1 -1
- package/dist/components/auth/Google.js.map +1 -1
- package/dist/components/auth/Google.mjs +1 -1
- package/dist/components/auth/Google.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +2 -2
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/dist/components/auth/PhoneInput.js.map +1 -1
- package/dist/components/auth/facebookUtils.mjs +2 -2
- package/dist/components/auth/facebookUtils.mjs.map +1 -1
- package/dist/components/auth/otp.js.map +1 -1
- package/dist/components/export/Export.mjs +4 -4
- package/dist/components/export/Export.mjs.map +1 -1
- package/dist/components/import/Import.mjs +3 -3
- package/dist/components/import/Import.mjs.map +1 -1
- package/dist/contexts/TurnkeyContext.mjs +3 -3
- package/dist/contexts/TurnkeyContext.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -109,7 +109,7 @@ var Auth = function Auth(_ref) {
|
|
|
109
109
|
passkeyCreated = _useState22[0],
|
|
110
110
|
setPasskeyCreated = _useState22[1];
|
|
111
111
|
var handleResendCode = /*#__PURE__*/function () {
|
|
112
|
-
var _ref2 = _asyncToGenerator(
|
|
112
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
113
113
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
114
114
|
while (1) switch (_context.prev = _context.next) {
|
|
115
115
|
case 0:
|
|
@@ -162,118 +162,38 @@ var Auth = function Auth(_ref) {
|
|
|
162
162
|
var phoneNumber = parsePhoneNumberFromString(phone);
|
|
163
163
|
return (_phoneNumber$isValid = phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.isValid()) !== null && _phoneNumber$isValid !== void 0 ? _phoneNumber$isValid : false;
|
|
164
164
|
};
|
|
165
|
-
var
|
|
166
|
-
var _ref3 = _asyncToGenerator(
|
|
167
|
-
var additionalData,
|
|
168
|
-
suborgId,
|
|
169
|
-
getVerifiedSuborgsResponse,
|
|
170
|
-
getSuborgsResponse,
|
|
171
|
-
createSuborgData,
|
|
172
|
-
createSuborgResponse,
|
|
173
|
-
_args2 = arguments;
|
|
165
|
+
var handleAuthSuccess = /*#__PURE__*/function () {
|
|
166
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(credentialBundle, expirationSeconds) {
|
|
174
167
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
175
168
|
while (1) switch (_context2.prev = _context2.next) {
|
|
176
|
-
case 0:
|
|
177
|
-
additionalData = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
178
|
-
if (!(filterType == FilterType.Email || filterType == FilterType.PhoneNumber)) {
|
|
179
|
-
_context2.next = 11;
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
_context2.next = 4;
|
|
183
|
-
return server.getVerifiedSuborgs({
|
|
184
|
-
filterType: filterType,
|
|
185
|
-
filterValue: filterValue
|
|
186
|
-
});
|
|
187
|
-
case 4:
|
|
188
|
-
getVerifiedSuborgsResponse = _context2.sent;
|
|
189
|
-
if (!(!getVerifiedSuborgsResponse || !getVerifiedSuborgsResponse.organizationIds)) {
|
|
190
|
-
_context2.next = 8;
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
onError(authErrors.suborg.fetchFailed);
|
|
194
|
-
return _context2.abrupt("return", null);
|
|
195
|
-
case 8:
|
|
196
|
-
suborgId = getVerifiedSuborgsResponse === null || getVerifiedSuborgsResponse === void 0 ? void 0 : getVerifiedSuborgsResponse.organizationIds[0];
|
|
197
|
-
_context2.next = 18;
|
|
198
|
-
break;
|
|
199
|
-
case 11:
|
|
200
|
-
_context2.next = 13;
|
|
201
|
-
return server.getSuborgs({
|
|
202
|
-
filterType: filterType,
|
|
203
|
-
filterValue: filterValue
|
|
204
|
-
});
|
|
205
|
-
case 13:
|
|
206
|
-
getSuborgsResponse = _context2.sent;
|
|
207
|
-
if (!(!getSuborgsResponse || !getSuborgsResponse.organizationIds)) {
|
|
208
|
-
_context2.next = 17;
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
onError(authErrors.suborg.fetchFailed);
|
|
212
|
-
return _context2.abrupt("return", null);
|
|
213
|
-
case 17:
|
|
214
|
-
suborgId = getSuborgsResponse === null || getSuborgsResponse === void 0 ? void 0 : getSuborgsResponse.organizationIds[0];
|
|
215
|
-
case 18:
|
|
216
|
-
if (suborgId) {
|
|
217
|
-
_context2.next = 27;
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
createSuborgData = _objectSpread2({}, additionalData);
|
|
221
|
-
if (filterType === FilterType.Email) createSuborgData.email = filterValue;else if (filterType === FilterType.PhoneNumber) createSuborgData.phoneNumber = filterValue;
|
|
222
|
-
if (customAccounts) {
|
|
223
|
-
createSuborgData.customAccounts = customAccounts;
|
|
224
|
-
}
|
|
225
|
-
_context2.next = 24;
|
|
226
|
-
return server.createSuborg(createSuborgData);
|
|
227
|
-
case 24:
|
|
228
|
-
createSuborgResponse = _context2.sent;
|
|
229
|
-
if (!createSuborgResponse || !createSuborgResponse.subOrganizationId) {
|
|
230
|
-
onError(authErrors.suborg.createFailed);
|
|
231
|
-
}
|
|
232
|
-
suborgId = createSuborgResponse === null || createSuborgResponse === void 0 ? void 0 : createSuborgResponse.subOrganizationId;
|
|
233
|
-
case 27:
|
|
234
|
-
return _context2.abrupt("return", suborgId);
|
|
235
|
-
case 28:
|
|
236
|
-
case "end":
|
|
237
|
-
return _context2.stop();
|
|
238
|
-
}
|
|
239
|
-
}, _callee2);
|
|
240
|
-
}));
|
|
241
|
-
return function handleGetOrCreateSuborg(_x, _x2) {
|
|
242
|
-
return _ref3.apply(this, arguments);
|
|
243
|
-
};
|
|
244
|
-
}();
|
|
245
|
-
var handleAuthSuccess = /*#__PURE__*/function () {
|
|
246
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(credentialBundle, expirationSeconds) {
|
|
247
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
248
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
249
169
|
case 0:
|
|
250
170
|
if (!credentialBundle) {
|
|
251
|
-
|
|
171
|
+
_context2.next = 7;
|
|
252
172
|
break;
|
|
253
173
|
}
|
|
254
|
-
|
|
174
|
+
_context2.next = 3;
|
|
255
175
|
return authIframeClient.injectCredentialBundle(credentialBundle);
|
|
256
176
|
case 3:
|
|
257
|
-
|
|
177
|
+
_context2.next = 5;
|
|
258
178
|
return authIframeClient.loginWithAuthBundle(credentialBundle, expirationSeconds);
|
|
259
179
|
case 5:
|
|
260
|
-
|
|
180
|
+
_context2.next = 7;
|
|
261
181
|
return onAuthSuccess();
|
|
262
182
|
case 7:
|
|
263
183
|
case "end":
|
|
264
|
-
return
|
|
184
|
+
return _context2.stop();
|
|
265
185
|
}
|
|
266
|
-
},
|
|
186
|
+
}, _callee2);
|
|
267
187
|
}));
|
|
268
|
-
return function handleAuthSuccess(
|
|
269
|
-
return
|
|
188
|
+
return function handleAuthSuccess(_x, _x2) {
|
|
189
|
+
return _ref3.apply(this, arguments);
|
|
270
190
|
};
|
|
271
191
|
}();
|
|
272
192
|
var handleSignupWithPasskey = /*#__PURE__*/function () {
|
|
273
|
-
var
|
|
274
|
-
var siteInfo, _turnkey$config$defau,
|
|
275
|
-
return _regeneratorRuntime().wrap(function
|
|
276
|
-
while (1) switch (
|
|
193
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
194
|
+
var siteInfo, _turnkey$config$defau, _ref5, encodedChallenge, attestation, response, sessionResponse, _authConfig$sessionLe;
|
|
195
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
196
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
277
197
|
case 0:
|
|
278
198
|
setPasskeySignupError("");
|
|
279
199
|
siteInfo = "".concat(new URL(window.location.href).hostname, " - ").concat(new Date().toLocaleString(undefined, {
|
|
@@ -286,12 +206,12 @@ var Auth = function Auth(_ref) {
|
|
|
286
206
|
}));
|
|
287
207
|
setPasskeySignupScreen(false);
|
|
288
208
|
setPasskeyCreationScreen(true);
|
|
289
|
-
|
|
209
|
+
_context3.prev = 4;
|
|
290
210
|
if (passkeyCreated) {
|
|
291
|
-
|
|
211
|
+
_context3.next = 22;
|
|
292
212
|
break;
|
|
293
213
|
}
|
|
294
|
-
|
|
214
|
+
_context3.next = 8;
|
|
295
215
|
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createUserPasskey({
|
|
296
216
|
publicKey: {
|
|
297
217
|
user: {
|
|
@@ -301,21 +221,21 @@ var Auth = function Auth(_ref) {
|
|
|
301
221
|
}
|
|
302
222
|
});
|
|
303
223
|
case 8:
|
|
304
|
-
|
|
305
|
-
if (
|
|
306
|
-
|
|
224
|
+
_context3.t0 = _context3.sent;
|
|
225
|
+
if (_context3.t0) {
|
|
226
|
+
_context3.next = 11;
|
|
307
227
|
break;
|
|
308
228
|
}
|
|
309
|
-
|
|
229
|
+
_context3.t0 = {};
|
|
310
230
|
case 11:
|
|
311
|
-
|
|
312
|
-
encodedChallenge =
|
|
313
|
-
attestation =
|
|
231
|
+
_ref5 = _context3.t0;
|
|
232
|
+
encodedChallenge = _ref5.encodedChallenge;
|
|
233
|
+
attestation = _ref5.attestation;
|
|
314
234
|
if (!(encodedChallenge && attestation)) {
|
|
315
|
-
|
|
235
|
+
_context3.next = 21;
|
|
316
236
|
break;
|
|
317
237
|
}
|
|
318
|
-
|
|
238
|
+
_context3.next = 17;
|
|
319
239
|
return server.createSuborg(_objectSpread2({
|
|
320
240
|
email: email,
|
|
321
241
|
passkey: {
|
|
@@ -327,15 +247,15 @@ var Auth = function Auth(_ref) {
|
|
|
327
247
|
customAccounts: customAccounts
|
|
328
248
|
}));
|
|
329
249
|
case 17:
|
|
330
|
-
response =
|
|
250
|
+
response = _context3.sent;
|
|
331
251
|
if (response !== null && response !== void 0 && response.subOrganizationId) {
|
|
332
252
|
setPasskeyCreated(true);
|
|
333
253
|
}
|
|
334
|
-
|
|
254
|
+
_context3.next = 22;
|
|
335
255
|
break;
|
|
336
256
|
case 21:
|
|
337
257
|
case 22:
|
|
338
|
-
|
|
258
|
+
_context3.next = 24;
|
|
339
259
|
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createReadWriteSession(_objectSpread2(_objectSpread2({
|
|
340
260
|
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
341
261
|
}, authConfig.sessionLengthSeconds !== undefined && {
|
|
@@ -344,43 +264,43 @@ var Auth = function Auth(_ref) {
|
|
|
344
264
|
organizationId: (_turnkey$config$defau = turnkey === null || turnkey === void 0 ? void 0 : turnkey.config.defaultOrganizationId) !== null && _turnkey$config$defau !== void 0 ? _turnkey$config$defau : process.env.NEXT_PUBLIC_ORGANIZATION_ID
|
|
345
265
|
}));
|
|
346
266
|
case 24:
|
|
347
|
-
sessionResponse =
|
|
267
|
+
sessionResponse = _context3.sent;
|
|
348
268
|
if (!(sessionResponse !== null && sessionResponse !== void 0 && sessionResponse.credentialBundle)) {
|
|
349
|
-
|
|
269
|
+
_context3.next = 30;
|
|
350
270
|
break;
|
|
351
271
|
}
|
|
352
|
-
|
|
272
|
+
_context3.next = 28;
|
|
353
273
|
return handleAuthSuccess(sessionResponse.credentialBundle, (_authConfig$sessionLe = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe === void 0 ? void 0 : _authConfig$sessionLe.toString());
|
|
354
274
|
case 28:
|
|
355
|
-
|
|
275
|
+
_context3.next = 31;
|
|
356
276
|
break;
|
|
357
277
|
case 30:
|
|
358
278
|
setPasskeySignupError(authErrors.passkey.loginFailed);
|
|
359
279
|
case 31:
|
|
360
|
-
|
|
280
|
+
_context3.next = 36;
|
|
361
281
|
break;
|
|
362
282
|
case 33:
|
|
363
|
-
|
|
364
|
-
|
|
283
|
+
_context3.prev = 33;
|
|
284
|
+
_context3.t1 = _context3["catch"](4);
|
|
365
285
|
setPasskeySignupError(authErrors.passkey.timeoutOrNotAllowed);
|
|
366
286
|
case 36:
|
|
367
287
|
case "end":
|
|
368
|
-
return
|
|
288
|
+
return _context3.stop();
|
|
369
289
|
}
|
|
370
|
-
},
|
|
290
|
+
}, _callee3, null, [[4, 33]]);
|
|
371
291
|
}));
|
|
372
292
|
return function handleSignupWithPasskey() {
|
|
373
|
-
return
|
|
293
|
+
return _ref4.apply(this, arguments);
|
|
374
294
|
};
|
|
375
295
|
}();
|
|
376
296
|
var handleLoginWithPasskey = /*#__PURE__*/function () {
|
|
377
|
-
var
|
|
297
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
378
298
|
var _turnkey$config$defau2, sessionResponse, _authConfig$sessionLe2;
|
|
379
|
-
return _regeneratorRuntime().wrap(function
|
|
380
|
-
while (1) switch (
|
|
299
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
300
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
381
301
|
case 0:
|
|
382
|
-
|
|
383
|
-
|
|
302
|
+
_context4.prev = 0;
|
|
303
|
+
_context4.next = 3;
|
|
384
304
|
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createReadWriteSession(_objectSpread2(_objectSpread2({
|
|
385
305
|
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
386
306
|
}, authConfig.sessionLengthSeconds !== undefined && {
|
|
@@ -389,45 +309,63 @@ var Auth = function Auth(_ref) {
|
|
|
389
309
|
organizationId: (_turnkey$config$defau2 = turnkey === null || turnkey === void 0 ? void 0 : turnkey.config.defaultOrganizationId) !== null && _turnkey$config$defau2 !== void 0 ? _turnkey$config$defau2 : process.env.NEXT_PUBLIC_ORGANIZATION_ID
|
|
390
310
|
}));
|
|
391
311
|
case 3:
|
|
392
|
-
sessionResponse =
|
|
312
|
+
sessionResponse = _context4.sent;
|
|
393
313
|
if (!(sessionResponse !== null && sessionResponse !== void 0 && sessionResponse.credentialBundle)) {
|
|
394
|
-
|
|
314
|
+
_context4.next = 9;
|
|
395
315
|
break;
|
|
396
316
|
}
|
|
397
|
-
|
|
317
|
+
_context4.next = 7;
|
|
398
318
|
return handleAuthSuccess(sessionResponse.credentialBundle, (_authConfig$sessionLe2 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe2 === void 0 ? void 0 : _authConfig$sessionLe2.toString());
|
|
399
319
|
case 7:
|
|
400
|
-
|
|
320
|
+
_context4.next = 10;
|
|
401
321
|
break;
|
|
402
322
|
case 9:
|
|
403
323
|
case 10:
|
|
404
|
-
|
|
324
|
+
_context4.next = 15;
|
|
405
325
|
break;
|
|
406
326
|
case 12:
|
|
407
|
-
|
|
408
|
-
|
|
327
|
+
_context4.prev = 12;
|
|
328
|
+
_context4.t0 = _context4["catch"](0);
|
|
409
329
|
onError(authErrors.passkey.loginFailed);
|
|
410
330
|
case 15:
|
|
411
331
|
case "end":
|
|
412
|
-
return
|
|
332
|
+
return _context4.stop();
|
|
413
333
|
}
|
|
414
|
-
},
|
|
334
|
+
}, _callee4, null, [[0, 12]]);
|
|
415
335
|
}));
|
|
416
336
|
return function handleLoginWithPasskey() {
|
|
417
|
-
return
|
|
337
|
+
return _ref6.apply(this, arguments);
|
|
418
338
|
};
|
|
419
339
|
}();
|
|
420
340
|
var handleOtpLogin = /*#__PURE__*/function () {
|
|
421
|
-
var
|
|
422
|
-
var suborgId, initAuthResponse;
|
|
423
|
-
return _regeneratorRuntime().wrap(function
|
|
424
|
-
while (1) switch (
|
|
341
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(type, value, otpType) {
|
|
342
|
+
var createSuborgData, resp, suborgIds, suborgId, initAuthResponse;
|
|
343
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
344
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
425
345
|
case 0:
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
346
|
+
createSuborgData = {};
|
|
347
|
+
if (type === FilterType.Email) createSuborgData.email = value;else if (type === FilterType.PhoneNumber) createSuborgData.phoneNumber = value;
|
|
348
|
+
if (customAccounts) {
|
|
349
|
+
createSuborgData.customAccounts = customAccounts;
|
|
350
|
+
}
|
|
351
|
+
_context5.next = 5;
|
|
352
|
+
return server.getOrCreateSuborg({
|
|
353
|
+
filterType: type,
|
|
354
|
+
filterValue: value,
|
|
355
|
+
additionalData: createSuborgData
|
|
356
|
+
});
|
|
357
|
+
case 5:
|
|
358
|
+
resp = _context5.sent;
|
|
359
|
+
suborgIds = resp === null || resp === void 0 ? void 0 : resp.subOrganizationIds;
|
|
360
|
+
if (!(!suborgIds || suborgIds.length === 0)) {
|
|
361
|
+
_context5.next = 10;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
onError(authErrors.otp.sendFailed);
|
|
365
|
+
return _context5.abrupt("return");
|
|
366
|
+
case 10:
|
|
367
|
+
suborgId = suborgIds[0];
|
|
368
|
+
_context5.next = 13;
|
|
431
369
|
return server.sendOtp(_objectSpread2(_objectSpread2({
|
|
432
370
|
suborgID: suborgId,
|
|
433
371
|
otpType: otpType,
|
|
@@ -437,8 +375,8 @@ var Auth = function Auth(_ref) {
|
|
|
437
375
|
}), {}, {
|
|
438
376
|
userIdentifier: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
439
377
|
}));
|
|
440
|
-
case
|
|
441
|
-
initAuthResponse =
|
|
378
|
+
case 13:
|
|
379
|
+
initAuthResponse = _context5.sent;
|
|
442
380
|
if (initAuthResponse && initAuthResponse.otpId) {
|
|
443
381
|
setSuborgId(suborgId);
|
|
444
382
|
setOtpId(initAuthResponse === null || initAuthResponse === void 0 ? void 0 : initAuthResponse.otpId);
|
|
@@ -446,60 +384,77 @@ var Auth = function Auth(_ref) {
|
|
|
446
384
|
} else {
|
|
447
385
|
onError(authErrors.otp.sendFailed);
|
|
448
386
|
}
|
|
449
|
-
case
|
|
387
|
+
case 15:
|
|
450
388
|
case "end":
|
|
451
|
-
return
|
|
389
|
+
return _context5.stop();
|
|
452
390
|
}
|
|
453
|
-
},
|
|
391
|
+
}, _callee5);
|
|
454
392
|
}));
|
|
455
|
-
return function handleOtpLogin(
|
|
456
|
-
return
|
|
393
|
+
return function handleOtpLogin(_x3, _x4, _x5) {
|
|
394
|
+
return _ref7.apply(this, arguments);
|
|
457
395
|
};
|
|
458
396
|
}();
|
|
459
397
|
var handleOAuthLogin = /*#__PURE__*/function () {
|
|
460
|
-
var
|
|
461
|
-
var suborgId, oauthResponse, _authConfig$sessionLe3;
|
|
462
|
-
return _regeneratorRuntime().wrap(function
|
|
463
|
-
while (1) switch (
|
|
398
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(credential, providerName) {
|
|
399
|
+
var createSuborgData, resp, suborgIds, suborgId, oauthResponse, _authConfig$sessionLe3;
|
|
400
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
401
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
464
402
|
case 0:
|
|
465
403
|
setOauthLoading(providerName);
|
|
466
|
-
|
|
467
|
-
return handleGetOrCreateSuborg(FilterType.OidcToken, credential, {
|
|
404
|
+
createSuborgData = {
|
|
468
405
|
oauthProviders: [{
|
|
469
406
|
providerName: providerName,
|
|
470
407
|
oidcToken: credential
|
|
471
408
|
}]
|
|
409
|
+
};
|
|
410
|
+
if (customAccounts) {
|
|
411
|
+
createSuborgData.customAccounts = customAccounts;
|
|
412
|
+
}
|
|
413
|
+
_context6.next = 5;
|
|
414
|
+
return server.getOrCreateSuborg({
|
|
415
|
+
filterType: FilterType.OidcToken,
|
|
416
|
+
filterValue: credential,
|
|
417
|
+
additionalData: createSuborgData
|
|
472
418
|
});
|
|
473
|
-
case
|
|
474
|
-
|
|
475
|
-
|
|
419
|
+
case 5:
|
|
420
|
+
resp = _context6.sent;
|
|
421
|
+
suborgIds = resp === null || resp === void 0 ? void 0 : resp.subOrganizationIds;
|
|
422
|
+
if (!(!suborgIds || suborgIds.length === 0)) {
|
|
423
|
+
_context6.next = 10;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
onError(authErrors.oauth.loginFailed);
|
|
427
|
+
return _context6.abrupt("return");
|
|
428
|
+
case 10:
|
|
429
|
+
suborgId = suborgIds[0];
|
|
430
|
+
_context6.next = 13;
|
|
476
431
|
return server.oauth({
|
|
477
432
|
suborgID: suborgId,
|
|
478
433
|
oidcToken: credential,
|
|
479
434
|
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey,
|
|
480
435
|
sessionLengthSeconds: authConfig.sessionLengthSeconds
|
|
481
436
|
});
|
|
482
|
-
case
|
|
483
|
-
oauthResponse =
|
|
437
|
+
case 13:
|
|
438
|
+
oauthResponse = _context6.sent;
|
|
484
439
|
if (!(oauthResponse && oauthResponse.token)) {
|
|
485
|
-
|
|
440
|
+
_context6.next = 19;
|
|
486
441
|
break;
|
|
487
442
|
}
|
|
488
|
-
|
|
443
|
+
_context6.next = 17;
|
|
489
444
|
return handleAuthSuccess(oauthResponse.token, (_authConfig$sessionLe3 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe3 === void 0 ? void 0 : _authConfig$sessionLe3.toString());
|
|
490
|
-
case
|
|
491
|
-
|
|
445
|
+
case 17:
|
|
446
|
+
_context6.next = 20;
|
|
492
447
|
break;
|
|
493
|
-
case
|
|
448
|
+
case 19:
|
|
494
449
|
onError(authErrors.oauth.loginFailed);
|
|
495
|
-
case
|
|
450
|
+
case 20:
|
|
496
451
|
case "end":
|
|
497
|
-
return
|
|
452
|
+
return _context6.stop();
|
|
498
453
|
}
|
|
499
|
-
},
|
|
454
|
+
}, _callee6);
|
|
500
455
|
}));
|
|
501
|
-
return function handleOAuthLogin(
|
|
502
|
-
return
|
|
456
|
+
return function handleOAuthLogin(_x6, _x7) {
|
|
457
|
+
return _ref8.apply(this, arguments);
|
|
503
458
|
};
|
|
504
459
|
}();
|
|
505
460
|
var renderBackButton = function renderBackButton() {
|