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