@turnkey/sdk-react 3.0.4 → 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.
|
@@ -339,27 +339,33 @@ var Auth = function Auth(_ref) {
|
|
|
339
339
|
}();
|
|
340
340
|
var handleOtpLogin = /*#__PURE__*/function () {
|
|
341
341
|
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(type, value, otpType) {
|
|
342
|
-
var resp, suborgIds, suborgId, initAuthResponse;
|
|
342
|
+
var createSuborgData, resp, suborgIds, suborgId, initAuthResponse;
|
|
343
343
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
344
344
|
while (1) switch (_context5.prev = _context5.next) {
|
|
345
345
|
case 0:
|
|
346
|
-
|
|
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;
|
|
347
352
|
return server.getOrCreateSuborg({
|
|
348
353
|
filterType: type,
|
|
349
|
-
filterValue: value
|
|
354
|
+
filterValue: value,
|
|
355
|
+
additionalData: createSuborgData
|
|
350
356
|
});
|
|
351
|
-
case
|
|
357
|
+
case 5:
|
|
352
358
|
resp = _context5.sent;
|
|
353
359
|
suborgIds = resp === null || resp === void 0 ? void 0 : resp.subOrganizationIds;
|
|
354
360
|
if (!(!suborgIds || suborgIds.length === 0)) {
|
|
355
|
-
_context5.next =
|
|
361
|
+
_context5.next = 10;
|
|
356
362
|
break;
|
|
357
363
|
}
|
|
358
|
-
onError(authErrors.
|
|
364
|
+
onError(authErrors.otp.sendFailed);
|
|
359
365
|
return _context5.abrupt("return");
|
|
360
|
-
case
|
|
366
|
+
case 10:
|
|
361
367
|
suborgId = suborgIds[0];
|
|
362
|
-
_context5.next =
|
|
368
|
+
_context5.next = 13;
|
|
363
369
|
return server.sendOtp(_objectSpread2(_objectSpread2({
|
|
364
370
|
suborgID: suborgId,
|
|
365
371
|
otpType: otpType,
|
|
@@ -369,7 +375,7 @@ var Auth = function Auth(_ref) {
|
|
|
369
375
|
}), {}, {
|
|
370
376
|
userIdentifier: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
371
377
|
}));
|
|
372
|
-
case
|
|
378
|
+
case 13:
|
|
373
379
|
initAuthResponse = _context5.sent;
|
|
374
380
|
if (initAuthResponse && initAuthResponse.otpId) {
|
|
375
381
|
setSuborgId(suborgId);
|
|
@@ -378,7 +384,7 @@ var Auth = function Auth(_ref) {
|
|
|
378
384
|
} else {
|
|
379
385
|
onError(authErrors.otp.sendFailed);
|
|
380
386
|
}
|
|
381
|
-
case
|
|
387
|
+
case 15:
|
|
382
388
|
case "end":
|
|
383
389
|
return _context5.stop();
|
|
384
390
|
}
|
|
@@ -390,54 +396,58 @@ var Auth = function Auth(_ref) {
|
|
|
390
396
|
}();
|
|
391
397
|
var handleOAuthLogin = /*#__PURE__*/function () {
|
|
392
398
|
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(credential, providerName) {
|
|
393
|
-
var resp, suborgIds, suborgId, oauthResponse, _authConfig$sessionLe3;
|
|
399
|
+
var createSuborgData, resp, suborgIds, suborgId, oauthResponse, _authConfig$sessionLe3;
|
|
394
400
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
395
401
|
while (1) switch (_context6.prev = _context6.next) {
|
|
396
402
|
case 0:
|
|
397
403
|
setOauthLoading(providerName);
|
|
398
|
-
|
|
404
|
+
createSuborgData = {
|
|
405
|
+
oauthProviders: [{
|
|
406
|
+
providerName: providerName,
|
|
407
|
+
oidcToken: credential
|
|
408
|
+
}]
|
|
409
|
+
};
|
|
410
|
+
if (customAccounts) {
|
|
411
|
+
createSuborgData.customAccounts = customAccounts;
|
|
412
|
+
}
|
|
413
|
+
_context6.next = 5;
|
|
399
414
|
return server.getOrCreateSuborg({
|
|
400
415
|
filterType: FilterType.OidcToken,
|
|
401
416
|
filterValue: credential,
|
|
402
|
-
additionalData:
|
|
403
|
-
oauthProviders: [{
|
|
404
|
-
providerName: providerName,
|
|
405
|
-
oidcToken: credential
|
|
406
|
-
}]
|
|
407
|
-
}
|
|
417
|
+
additionalData: createSuborgData
|
|
408
418
|
});
|
|
409
|
-
case
|
|
419
|
+
case 5:
|
|
410
420
|
resp = _context6.sent;
|
|
411
421
|
suborgIds = resp === null || resp === void 0 ? void 0 : resp.subOrganizationIds;
|
|
412
422
|
if (!(!suborgIds || suborgIds.length === 0)) {
|
|
413
|
-
_context6.next =
|
|
423
|
+
_context6.next = 10;
|
|
414
424
|
break;
|
|
415
425
|
}
|
|
416
426
|
onError(authErrors.oauth.loginFailed);
|
|
417
427
|
return _context6.abrupt("return");
|
|
418
|
-
case
|
|
428
|
+
case 10:
|
|
419
429
|
suborgId = suborgIds[0];
|
|
420
|
-
_context6.next =
|
|
430
|
+
_context6.next = 13;
|
|
421
431
|
return server.oauth({
|
|
422
432
|
suborgID: suborgId,
|
|
423
433
|
oidcToken: credential,
|
|
424
434
|
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey,
|
|
425
435
|
sessionLengthSeconds: authConfig.sessionLengthSeconds
|
|
426
436
|
});
|
|
427
|
-
case
|
|
437
|
+
case 13:
|
|
428
438
|
oauthResponse = _context6.sent;
|
|
429
439
|
if (!(oauthResponse && oauthResponse.token)) {
|
|
430
|
-
_context6.next =
|
|
440
|
+
_context6.next = 19;
|
|
431
441
|
break;
|
|
432
442
|
}
|
|
433
|
-
_context6.next =
|
|
443
|
+
_context6.next = 17;
|
|
434
444
|
return handleAuthSuccess(oauthResponse.token, (_authConfig$sessionLe3 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe3 === void 0 ? void 0 : _authConfig$sessionLe3.toString());
|
|
435
|
-
case 15:
|
|
436
|
-
_context6.next = 18;
|
|
437
|
-
break;
|
|
438
445
|
case 17:
|
|
446
|
+
_context6.next = 20;
|
|
447
|
+
break;
|
|
448
|
+
case 19:
|
|
439
449
|
onError(authErrors.oauth.loginFailed);
|
|
440
|
-
case
|
|
450
|
+
case 20:
|
|
441
451
|
case "end":
|
|
442
452
|
return _context6.stop();
|
|
443
453
|
}
|