@turnkey/sdk-react 5.4.0-beta.6 → 5.4.1
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 +22 -10
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs +95 -256
- package/dist/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -1
- package/dist/components/auth/Apple.js.map +1 -1
- package/dist/components/auth/Apple.mjs +27 -29
- package/dist/components/auth/Apple.mjs.map +1 -1
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +277 -272
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/Facebook.js.map +1 -1
- package/dist/components/auth/Facebook.mjs +55 -58
- package/dist/components/auth/Facebook.mjs.map +1 -1
- package/dist/components/auth/Google.js.map +1 -1
- package/dist/components/auth/Google.mjs +27 -29
- package/dist/components/auth/Google.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.js.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +61 -62
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/dist/components/auth/PhoneInput.js.map +1 -1
- package/dist/components/auth/PhoneInput.mjs.map +1 -1
- package/dist/components/auth/TurnkeyThemeProvider.js.map +1 -1
- package/dist/components/auth/TurnkeyThemeProvider.mjs.map +1 -1
- package/dist/components/auth/constants.js.map +1 -1
- package/dist/components/auth/constants.mjs.map +1 -1
- package/dist/components/auth/facebookUtils.js.map +1 -1
- package/dist/components/auth/facebookUtils.mjs +17 -23
- package/dist/components/auth/facebookUtils.mjs.map +1 -1
- package/dist/components/auth/otp.js.map +1 -1
- package/dist/components/auth/otp.mjs.map +1 -1
- package/dist/components/auth/utils.js.map +1 -1
- package/dist/components/export/Export.js.map +1 -1
- package/dist/components/export/Export.mjs +56 -60
- package/dist/components/export/Export.mjs.map +1 -1
- package/dist/components/import/Import.js.map +1 -1
- package/dist/components/import/Import.mjs +64 -67
- package/dist/components/import/Import.mjs.map +1 -1
- package/dist/contexts/TurnkeyContext.js.map +1 -1
- package/dist/contexts/TurnkeyContext.mjs +15 -16
- package/dist/contexts/TurnkeyContext.mjs.map +1 -1
- package/dist/hooks/use-session.js.map +1 -1
- package/dist/hooks/use-session.mjs.map +1 -1
- package/dist/hooks/use-turnkey.js.map +1 -1
- package/dist/hooks/use-turnkey.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, asyncToGenerator as _asyncToGenerator,
|
|
2
|
+
import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../../_virtual/_rollupPluginBabelHelpers.mjs';
|
|
3
3
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import styles from './Auth.module.css.mjs';
|
|
5
5
|
import React, { useState, useEffect } from 'react';
|
|
@@ -117,29 +117,28 @@ var Auth = function Auth(_ref) {
|
|
|
117
117
|
passkeyCreated = _useState20[0],
|
|
118
118
|
setPasskeyCreated = _useState20[1];
|
|
119
119
|
var handleResendCode = /*#__PURE__*/function () {
|
|
120
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
121
|
-
return
|
|
122
|
-
while (1) switch (_context.
|
|
120
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
121
|
+
return _regenerator().w(function (_context) {
|
|
122
|
+
while (1) switch (_context.n) {
|
|
123
123
|
case 0:
|
|
124
124
|
if (!(step === OtpType.Email)) {
|
|
125
|
-
_context.
|
|
125
|
+
_context.n = 2;
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
|
-
_context.
|
|
128
|
+
_context.n = 1;
|
|
129
129
|
return handleSendOtp(email, OtpType.Email);
|
|
130
|
-
case
|
|
131
|
-
_context.
|
|
130
|
+
case 1:
|
|
131
|
+
_context.n = 3;
|
|
132
132
|
break;
|
|
133
|
-
case
|
|
133
|
+
case 2:
|
|
134
134
|
if (!(step === OtpType.Sms)) {
|
|
135
|
-
_context.
|
|
135
|
+
_context.n = 3;
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
|
-
_context.
|
|
138
|
+
_context.n = 3;
|
|
139
139
|
return handleSendOtp(phone, OtpType.Sms);
|
|
140
|
-
case
|
|
141
|
-
|
|
142
|
-
return _context.stop();
|
|
140
|
+
case 3:
|
|
141
|
+
return _context.a(2);
|
|
143
142
|
}
|
|
144
143
|
}, _callee);
|
|
145
144
|
}));
|
|
@@ -149,27 +148,26 @@ var Auth = function Auth(_ref) {
|
|
|
149
148
|
}();
|
|
150
149
|
useEffect(function () {
|
|
151
150
|
var manageClient = /*#__PURE__*/function () {
|
|
152
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/
|
|
151
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
153
152
|
var retrievedPublicKey;
|
|
154
|
-
return
|
|
155
|
-
while (1) switch (_context2.
|
|
153
|
+
return _regenerator().w(function (_context2) {
|
|
154
|
+
while (1) switch (_context2.n) {
|
|
156
155
|
case 0:
|
|
157
156
|
if (!(indexedDbClient && turnkey)) {
|
|
158
|
-
_context2.
|
|
157
|
+
_context2.n = 2;
|
|
159
158
|
break;
|
|
160
159
|
}
|
|
161
|
-
_context2.
|
|
160
|
+
_context2.n = 1;
|
|
162
161
|
return indexedDbClient.getPublicKey();
|
|
163
|
-
case
|
|
164
|
-
retrievedPublicKey = _context2.
|
|
162
|
+
case 1:
|
|
163
|
+
retrievedPublicKey = _context2.v;
|
|
165
164
|
if (retrievedPublicKey) {
|
|
166
165
|
setComponentReady(true);
|
|
167
166
|
} else {
|
|
168
167
|
onError("Failed to retrieve public key.");
|
|
169
168
|
}
|
|
170
|
-
case
|
|
171
|
-
|
|
172
|
-
return _context2.stop();
|
|
169
|
+
case 2:
|
|
170
|
+
return _context2.a(2);
|
|
173
171
|
}
|
|
174
172
|
}, _callee2);
|
|
175
173
|
}));
|
|
@@ -198,10 +196,10 @@ var Auth = function Auth(_ref) {
|
|
|
198
196
|
return (_phoneNumber$isValid = phoneNumber === null || phoneNumber === void 0 ? void 0 : phoneNumber.isValid()) !== null && _phoneNumber$isValid !== void 0 ? _phoneNumber$isValid : false;
|
|
199
197
|
};
|
|
200
198
|
var handleSignupWithPasskey = /*#__PURE__*/function () {
|
|
201
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/
|
|
202
|
-
var siteInfo, _authConfig$sessionLe, _passkeyConfig$name, _passkeyConfig$displa, _ref5, encodedChallenge, attestation, response, pubKey;
|
|
203
|
-
return
|
|
204
|
-
while (1) switch (_context3.
|
|
199
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
200
|
+
var siteInfo, _authConfig$sessionLe, _passkeyConfig$name, _passkeyConfig$displa, _ref5, encodedChallenge, attestation, response, pubKey, _t, _t2;
|
|
201
|
+
return _regenerator().w(function (_context3) {
|
|
202
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
205
203
|
case 0:
|
|
206
204
|
setPasskeySignupError("");
|
|
207
205
|
siteInfo = "".concat(new URL(window.location.href).hostname, " - ").concat(new Date().toLocaleString(undefined, {
|
|
@@ -214,12 +212,12 @@ var Auth = function Auth(_ref) {
|
|
|
214
212
|
}));
|
|
215
213
|
setPasskeySignupScreen(false);
|
|
216
214
|
setPasskeyCreationScreen(true);
|
|
217
|
-
_context3.
|
|
215
|
+
_context3.p = 1;
|
|
218
216
|
if (passkeyCreated) {
|
|
219
|
-
_context3.
|
|
217
|
+
_context3.n = 6;
|
|
220
218
|
break;
|
|
221
219
|
}
|
|
222
|
-
_context3.
|
|
220
|
+
_context3.n = 2;
|
|
223
221
|
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createUserPasskey({
|
|
224
222
|
publicKey: {
|
|
225
223
|
user: {
|
|
@@ -228,22 +226,22 @@ var Auth = function Auth(_ref) {
|
|
|
228
226
|
}
|
|
229
227
|
}
|
|
230
228
|
});
|
|
231
|
-
case
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
_context3.
|
|
229
|
+
case 2:
|
|
230
|
+
_t = _context3.v;
|
|
231
|
+
if (_t) {
|
|
232
|
+
_context3.n = 3;
|
|
235
233
|
break;
|
|
236
234
|
}
|
|
237
|
-
|
|
238
|
-
case
|
|
239
|
-
_ref5 =
|
|
235
|
+
_t = {};
|
|
236
|
+
case 3:
|
|
237
|
+
_ref5 = _t;
|
|
240
238
|
encodedChallenge = _ref5.encodedChallenge;
|
|
241
239
|
attestation = _ref5.attestation;
|
|
242
240
|
if (!(encodedChallenge && attestation)) {
|
|
243
|
-
_context3.
|
|
241
|
+
_context3.n = 5;
|
|
244
242
|
break;
|
|
245
243
|
}
|
|
246
|
-
_context3.
|
|
244
|
+
_context3.n = 4;
|
|
247
245
|
return server.createSuborg(_objectSpread2({
|
|
248
246
|
email: email,
|
|
249
247
|
passkey: {
|
|
@@ -254,108 +252,106 @@ var Auth = function Auth(_ref) {
|
|
|
254
252
|
}, customAccounts && {
|
|
255
253
|
customAccounts: customAccounts
|
|
256
254
|
}));
|
|
257
|
-
case
|
|
258
|
-
response = _context3.
|
|
255
|
+
case 4:
|
|
256
|
+
response = _context3.v;
|
|
259
257
|
if (response !== null && response !== void 0 && response.subOrganizationId) {
|
|
260
258
|
setPasskeyCreated(true);
|
|
261
259
|
}
|
|
262
|
-
_context3.
|
|
260
|
+
_context3.n = 6;
|
|
263
261
|
break;
|
|
264
|
-
case
|
|
265
|
-
case
|
|
266
|
-
_context3.
|
|
262
|
+
case 5:
|
|
263
|
+
case 6:
|
|
264
|
+
_context3.n = 7;
|
|
267
265
|
return indexedDbClient.resetKeyPair();
|
|
268
|
-
case
|
|
269
|
-
_context3.
|
|
266
|
+
case 7:
|
|
267
|
+
_context3.n = 8;
|
|
270
268
|
return indexedDbClient.getPublicKey();
|
|
271
|
-
case
|
|
272
|
-
pubKey = _context3.
|
|
273
|
-
_context3.
|
|
269
|
+
case 8:
|
|
270
|
+
pubKey = _context3.v;
|
|
271
|
+
_context3.n = 9;
|
|
274
272
|
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.loginWithPasskey({
|
|
275
273
|
sessionType: SessionType.READ_WRITE,
|
|
276
274
|
publicKey: pubKey,
|
|
277
275
|
expirationSeconds: (_authConfig$sessionLe = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe === void 0 ? void 0 : _authConfig$sessionLe.toString()
|
|
278
276
|
});
|
|
279
|
-
case
|
|
280
|
-
_context3.
|
|
277
|
+
case 9:
|
|
278
|
+
_context3.n = 10;
|
|
281
279
|
return onAuthSuccess();
|
|
282
|
-
case
|
|
283
|
-
_context3.
|
|
280
|
+
case 10:
|
|
281
|
+
_context3.n = 12;
|
|
284
282
|
break;
|
|
285
|
-
case
|
|
286
|
-
_context3.
|
|
287
|
-
|
|
283
|
+
case 11:
|
|
284
|
+
_context3.p = 11;
|
|
285
|
+
_t2 = _context3.v;
|
|
288
286
|
setPasskeySignupError(authErrors.passkey.timeoutOrNotAllowed);
|
|
289
|
-
console.error("Error during passkey signup: ",
|
|
290
|
-
case
|
|
291
|
-
|
|
292
|
-
return _context3.stop();
|
|
287
|
+
console.error("Error during passkey signup: ", _t2);
|
|
288
|
+
case 12:
|
|
289
|
+
return _context3.a(2);
|
|
293
290
|
}
|
|
294
|
-
}, _callee3, null, [[
|
|
291
|
+
}, _callee3, null, [[1, 11]]);
|
|
295
292
|
}));
|
|
296
293
|
return function handleSignupWithPasskey() {
|
|
297
294
|
return _ref4.apply(this, arguments);
|
|
298
295
|
};
|
|
299
296
|
}();
|
|
300
297
|
var handleLoginWithPasskey = /*#__PURE__*/function () {
|
|
301
|
-
var _ref6 = _asyncToGenerator(/*#__PURE__*/
|
|
302
|
-
var _authConfig$sessionLe2, pubKey;
|
|
303
|
-
return
|
|
304
|
-
while (1) switch (_context4.
|
|
298
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
299
|
+
var _authConfig$sessionLe2, pubKey, _t3;
|
|
300
|
+
return _regenerator().w(function (_context4) {
|
|
301
|
+
while (1) switch (_context4.p = _context4.n) {
|
|
305
302
|
case 0:
|
|
306
|
-
_context4.
|
|
303
|
+
_context4.p = 0;
|
|
307
304
|
setLoading("passkey");
|
|
308
|
-
_context4.
|
|
305
|
+
_context4.n = 1;
|
|
309
306
|
return indexedDbClient === null || indexedDbClient === void 0 ? void 0 : indexedDbClient.resetKeyPair();
|
|
310
|
-
case
|
|
311
|
-
_context4.
|
|
307
|
+
case 1:
|
|
308
|
+
_context4.n = 2;
|
|
312
309
|
return indexedDbClient.getPublicKey();
|
|
313
|
-
case
|
|
314
|
-
pubKey = _context4.
|
|
315
|
-
_context4.
|
|
310
|
+
case 2:
|
|
311
|
+
pubKey = _context4.v;
|
|
312
|
+
_context4.n = 3;
|
|
316
313
|
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.loginWithPasskey({
|
|
317
314
|
sessionType: SessionType.READ_WRITE,
|
|
318
315
|
publicKey: pubKey,
|
|
319
316
|
expirationSeconds: (_authConfig$sessionLe2 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe2 === void 0 ? void 0 : _authConfig$sessionLe2.toString()
|
|
320
317
|
});
|
|
321
|
-
case
|
|
322
|
-
_context4.
|
|
318
|
+
case 3:
|
|
319
|
+
_context4.n = 4;
|
|
323
320
|
return onAuthSuccess();
|
|
324
|
-
case
|
|
325
|
-
_context4.
|
|
321
|
+
case 4:
|
|
322
|
+
_context4.n = 6;
|
|
326
323
|
break;
|
|
327
|
-
case
|
|
328
|
-
_context4.
|
|
329
|
-
|
|
324
|
+
case 5:
|
|
325
|
+
_context4.p = 5;
|
|
326
|
+
_t3 = _context4.v;
|
|
330
327
|
onError(authErrors.passkey.loginFailed);
|
|
331
|
-
console.error("Error during passkey login: ",
|
|
332
|
-
case
|
|
333
|
-
_context4.
|
|
328
|
+
console.error("Error during passkey login: ", _t3);
|
|
329
|
+
case 6:
|
|
330
|
+
_context4.p = 6;
|
|
334
331
|
setLoading(undefined);
|
|
335
|
-
return _context4.
|
|
336
|
-
case
|
|
337
|
-
|
|
338
|
-
return _context4.stop();
|
|
332
|
+
return _context4.f(6);
|
|
333
|
+
case 7:
|
|
334
|
+
return _context4.a(2);
|
|
339
335
|
}
|
|
340
|
-
}, _callee4, null, [[0,
|
|
336
|
+
}, _callee4, null, [[0, 5, 6, 7]]);
|
|
341
337
|
}));
|
|
342
338
|
return function handleLoginWithPasskey() {
|
|
343
339
|
return _ref6.apply(this, arguments);
|
|
344
340
|
};
|
|
345
341
|
}();
|
|
346
342
|
var handleSendOtp = /*#__PURE__*/function () {
|
|
347
|
-
var _ref7 = _asyncToGenerator(/*#__PURE__*/
|
|
343
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(value, otpType) {
|
|
348
344
|
var _otpConfig$otpLength, _otpConfig$alphanumer;
|
|
349
345
|
var publicKey, initAuthResponse;
|
|
350
|
-
return
|
|
351
|
-
while (1) switch (_context5.
|
|
346
|
+
return _regenerator().w(function (_context5) {
|
|
347
|
+
while (1) switch (_context5.n) {
|
|
352
348
|
case 0:
|
|
353
349
|
setLoading(otpType);
|
|
354
|
-
_context5.
|
|
350
|
+
_context5.n = 1;
|
|
355
351
|
return indexedDbClient.getPublicKey();
|
|
356
|
-
case
|
|
357
|
-
publicKey = _context5.
|
|
358
|
-
_context5.
|
|
352
|
+
case 1:
|
|
353
|
+
publicKey = _context5.v;
|
|
354
|
+
_context5.n = 2;
|
|
359
355
|
return server.sendOtp(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
360
356
|
otpType: otpType,
|
|
361
357
|
contact: value
|
|
@@ -370,8 +366,8 @@ var Auth = function Auth(_ref) {
|
|
|
370
366
|
alphanumeric: (_otpConfig$alphanumer = otpConfig === null || otpConfig === void 0 ? void 0 : otpConfig.alphanumeric) !== null && _otpConfig$alphanumer !== void 0 ? _otpConfig$alphanumer : false,
|
|
371
367
|
userIdentifier: publicKey
|
|
372
368
|
}));
|
|
373
|
-
case
|
|
374
|
-
initAuthResponse = _context5.
|
|
369
|
+
case 2:
|
|
370
|
+
initAuthResponse = _context5.v;
|
|
375
371
|
if (initAuthResponse && initAuthResponse.otpId) {
|
|
376
372
|
setOtpId(initAuthResponse === null || initAuthResponse === void 0 ? void 0 : initAuthResponse.otpId);
|
|
377
373
|
setStep(otpType);
|
|
@@ -379,9 +375,8 @@ var Auth = function Auth(_ref) {
|
|
|
379
375
|
onError(authErrors.otp.sendFailed);
|
|
380
376
|
}
|
|
381
377
|
setLoading(undefined);
|
|
382
|
-
case
|
|
383
|
-
|
|
384
|
-
return _context5.stop();
|
|
378
|
+
case 3:
|
|
379
|
+
return _context5.a(2);
|
|
385
380
|
}
|
|
386
381
|
}, _callee5);
|
|
387
382
|
}));
|
|
@@ -390,7 +385,7 @@ var Auth = function Auth(_ref) {
|
|
|
390
385
|
};
|
|
391
386
|
}();
|
|
392
387
|
var handleOAuthLogin = /*#__PURE__*/function () {
|
|
393
|
-
var _ref8 = _asyncToGenerator(/*#__PURE__*/
|
|
388
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(credential, providerName) {
|
|
394
389
|
var _yield$server$getSubo;
|
|
395
390
|
var socialLinking,
|
|
396
391
|
pubKey,
|
|
@@ -412,21 +407,36 @@ var Auth = function Auth(_ref) {
|
|
|
412
407
|
userId,
|
|
413
408
|
_yield$server$createS,
|
|
414
409
|
_yield$server$createS2,
|
|
415
|
-
_args7 = arguments
|
|
416
|
-
|
|
417
|
-
|
|
410
|
+
_args7 = arguments,
|
|
411
|
+
_t4,
|
|
412
|
+
_t5,
|
|
413
|
+
_t6,
|
|
414
|
+
_t7,
|
|
415
|
+
_t8,
|
|
416
|
+
_t9,
|
|
417
|
+
_t0,
|
|
418
|
+
_t1,
|
|
419
|
+
_t10,
|
|
420
|
+
_t11,
|
|
421
|
+
_t12,
|
|
422
|
+
_t13,
|
|
423
|
+
_t14,
|
|
424
|
+
_t15,
|
|
425
|
+
_t16;
|
|
426
|
+
return _regenerator().w(function (_context7) {
|
|
427
|
+
while (1) switch (_context7.n) {
|
|
418
428
|
case 0:
|
|
419
429
|
socialLinking = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : false;
|
|
420
|
-
_context7.
|
|
430
|
+
_context7.n = 1;
|
|
421
431
|
return indexedDbClient === null || indexedDbClient === void 0 ? void 0 : indexedDbClient.getPublicKey();
|
|
422
|
-
case
|
|
423
|
-
pubKey = _context7.
|
|
432
|
+
case 1:
|
|
433
|
+
pubKey = _context7.v;
|
|
424
434
|
if (pubKey) {
|
|
425
|
-
_context7.
|
|
435
|
+
_context7.n = 2;
|
|
426
436
|
break;
|
|
427
437
|
}
|
|
428
|
-
return _context7.
|
|
429
|
-
case
|
|
438
|
+
return _context7.a(2);
|
|
439
|
+
case 2:
|
|
430
440
|
setOauthLoading(providerName);
|
|
431
441
|
oauthProviders = [{
|
|
432
442
|
providerName: providerName,
|
|
@@ -438,33 +448,32 @@ var Auth = function Auth(_ref) {
|
|
|
438
448
|
customAccounts: customAccounts
|
|
439
449
|
});
|
|
440
450
|
completeLogin = /*#__PURE__*/function () {
|
|
441
|
-
var _ref9 = _asyncToGenerator(/*#__PURE__*/
|
|
451
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(suborgID) {
|
|
442
452
|
var sessionResponse;
|
|
443
|
-
return
|
|
444
|
-
while (1) switch (_context6.
|
|
453
|
+
return _regenerator().w(function (_context6) {
|
|
454
|
+
while (1) switch (_context6.n) {
|
|
445
455
|
case 0:
|
|
446
|
-
_context6.
|
|
456
|
+
_context6.n = 1;
|
|
447
457
|
return server.oauthLogin({
|
|
448
458
|
suborgID: suborgID,
|
|
449
459
|
oidcToken: credential,
|
|
450
460
|
publicKey: pubKey,
|
|
451
461
|
sessionLengthSeconds: authConfig.sessionLengthSeconds
|
|
452
462
|
});
|
|
453
|
-
case
|
|
454
|
-
sessionResponse = _context6.
|
|
463
|
+
case 1:
|
|
464
|
+
sessionResponse = _context6.v;
|
|
455
465
|
if (!(sessionResponse !== null && sessionResponse !== void 0 && sessionResponse.session)) {
|
|
456
|
-
_context6.
|
|
466
|
+
_context6.n = 3;
|
|
457
467
|
break;
|
|
458
468
|
}
|
|
459
|
-
_context6.
|
|
469
|
+
_context6.n = 2;
|
|
460
470
|
return indexedDbClient.loginWithSession(sessionResponse.session);
|
|
461
|
-
case
|
|
462
|
-
return _context6.
|
|
463
|
-
case
|
|
471
|
+
case 2:
|
|
472
|
+
return _context6.a(2, onAuthSuccess());
|
|
473
|
+
case 3:
|
|
464
474
|
onError(authErrors.oauth.loginFailed);
|
|
465
|
-
case
|
|
466
|
-
|
|
467
|
-
return _context6.stop();
|
|
475
|
+
case 4:
|
|
476
|
+
return _context6.a(2);
|
|
468
477
|
}
|
|
469
478
|
}, _callee6);
|
|
470
479
|
}));
|
|
@@ -473,54 +482,54 @@ var Auth = function Auth(_ref) {
|
|
|
473
482
|
};
|
|
474
483
|
}(); // Non-social-linking path: getOrCreateSuborg then login
|
|
475
484
|
if (socialLinking) {
|
|
476
|
-
_context7.
|
|
485
|
+
_context7.n = 5;
|
|
477
486
|
break;
|
|
478
487
|
}
|
|
479
|
-
_context7.
|
|
488
|
+
_context7.n = 3;
|
|
480
489
|
return server.getOrCreateSuborg({
|
|
481
490
|
filterType: FilterType.OidcToken,
|
|
482
491
|
filterValue: credential,
|
|
483
492
|
additionalData: createSuborgData
|
|
484
493
|
});
|
|
485
|
-
case
|
|
486
|
-
resp = _context7.
|
|
494
|
+
case 3:
|
|
495
|
+
resp = _context7.v;
|
|
487
496
|
suborgIds = resp === null || resp === void 0 ? void 0 : resp.subOrganizationIds;
|
|
488
497
|
if (suborgIds !== null && suborgIds !== void 0 && suborgIds.length) {
|
|
489
|
-
_context7.
|
|
498
|
+
_context7.n = 4;
|
|
490
499
|
break;
|
|
491
500
|
}
|
|
492
|
-
return _context7.
|
|
493
|
-
case
|
|
494
|
-
return _context7.
|
|
495
|
-
case
|
|
496
|
-
_context7.
|
|
501
|
+
return _context7.a(2, onError(authErrors.oauth.loginFailed));
|
|
502
|
+
case 4:
|
|
503
|
+
return _context7.a(2, completeLogin(suborgIds[0]));
|
|
504
|
+
case 5:
|
|
505
|
+
_context7.n = 6;
|
|
497
506
|
return server.getSuborgs({
|
|
498
507
|
filterType: FilterType.OidcToken,
|
|
499
508
|
filterValue: credential
|
|
500
509
|
});
|
|
501
|
-
case
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (
|
|
505
|
-
_context7.
|
|
510
|
+
case 6:
|
|
511
|
+
_t5 = _yield$server$getSubo = _context7.v;
|
|
512
|
+
_t4 = _t5 === null;
|
|
513
|
+
if (_t4) {
|
|
514
|
+
_context7.n = 7;
|
|
506
515
|
break;
|
|
507
516
|
}
|
|
508
|
-
|
|
509
|
-
case
|
|
510
|
-
if (!
|
|
511
|
-
_context7.
|
|
517
|
+
_t4 = _yield$server$getSubo === void 0;
|
|
518
|
+
case 7:
|
|
519
|
+
if (!_t4) {
|
|
520
|
+
_context7.n = 8;
|
|
512
521
|
break;
|
|
513
522
|
}
|
|
514
|
-
|
|
515
|
-
_context7.
|
|
523
|
+
_t6 = void 0;
|
|
524
|
+
_context7.n = 9;
|
|
516
525
|
break;
|
|
517
|
-
case
|
|
518
|
-
|
|
519
|
-
case
|
|
520
|
-
oidcOrgIds =
|
|
526
|
+
case 8:
|
|
527
|
+
_t6 = _yield$server$getSubo.organizationIds;
|
|
528
|
+
case 9:
|
|
529
|
+
oidcOrgIds = _t6;
|
|
521
530
|
orgId = oidcOrgIds === null || oidcOrgIds === void 0 ? void 0 : oidcOrgIds[0]; // If not, try to link by verified email (Google only)
|
|
522
531
|
if (orgId) {
|
|
523
|
-
_context7.
|
|
532
|
+
_context7.n = 31;
|
|
524
533
|
break;
|
|
525
534
|
}
|
|
526
535
|
_ref0 = jwtDecode(credential) || {}, oidcEmail = _ref0.email, iss = _ref0.iss;
|
|
@@ -531,133 +540,130 @@ var Auth = function Auth(_ref) {
|
|
|
531
540
|
customAccounts: customAccounts
|
|
532
541
|
});
|
|
533
542
|
if (!(oidcEmail && iss === "https://accounts.google.com")) {
|
|
534
|
-
_context7.
|
|
543
|
+
_context7.n = 26;
|
|
535
544
|
break;
|
|
536
545
|
}
|
|
537
|
-
_context7.
|
|
546
|
+
_context7.n = 10;
|
|
538
547
|
return server.getVerifiedSuborgs({
|
|
539
548
|
filterType: FilterType.Email,
|
|
540
549
|
filterValue: oidcEmail
|
|
541
550
|
});
|
|
542
|
-
case
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (
|
|
546
|
-
_context7.
|
|
551
|
+
case 10:
|
|
552
|
+
_t8 = _yield$server$getVeri = _context7.v;
|
|
553
|
+
_t7 = _t8 === null;
|
|
554
|
+
if (_t7) {
|
|
555
|
+
_context7.n = 11;
|
|
547
556
|
break;
|
|
548
557
|
}
|
|
549
|
-
|
|
550
|
-
case
|
|
551
|
-
if (!
|
|
552
|
-
_context7.
|
|
558
|
+
_t7 = _yield$server$getVeri === void 0;
|
|
559
|
+
case 11:
|
|
560
|
+
if (!_t7) {
|
|
561
|
+
_context7.n = 12;
|
|
553
562
|
break;
|
|
554
563
|
}
|
|
555
|
-
|
|
556
|
-
_context7.
|
|
564
|
+
_t9 = void 0;
|
|
565
|
+
_context7.n = 13;
|
|
557
566
|
break;
|
|
558
|
-
case
|
|
559
|
-
|
|
560
|
-
case
|
|
561
|
-
emailOrgIds =
|
|
567
|
+
case 12:
|
|
568
|
+
_t9 = _yield$server$getVeri.organizationIds;
|
|
569
|
+
case 13:
|
|
570
|
+
emailOrgIds = _t9;
|
|
562
571
|
if (!(emailOrgIds !== null && emailOrgIds !== void 0 && emailOrgIds[0])) {
|
|
563
|
-
_context7.
|
|
572
|
+
_context7.n = 20;
|
|
564
573
|
break;
|
|
565
574
|
}
|
|
566
575
|
orgId = emailOrgIds[0];
|
|
567
576
|
// attach this new OIDC provider to the existing user
|
|
568
|
-
_context7.
|
|
577
|
+
_context7.n = 14;
|
|
569
578
|
return server.getUsers({
|
|
570
579
|
organizationId: orgId
|
|
571
580
|
});
|
|
572
|
-
case
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if (
|
|
576
|
-
_context7.
|
|
581
|
+
case 14:
|
|
582
|
+
_t1 = _yield$server$getUser = _context7.v;
|
|
583
|
+
_t0 = _t1 === null;
|
|
584
|
+
if (_t0) {
|
|
585
|
+
_context7.n = 15;
|
|
577
586
|
break;
|
|
578
587
|
}
|
|
579
|
-
|
|
580
|
-
case
|
|
581
|
-
if (!
|
|
582
|
-
_context7.
|
|
588
|
+
_t0 = _yield$server$getUser === void 0;
|
|
589
|
+
case 15:
|
|
590
|
+
if (!_t0) {
|
|
591
|
+
_context7.n = 16;
|
|
583
592
|
break;
|
|
584
593
|
}
|
|
585
|
-
|
|
586
|
-
_context7.
|
|
594
|
+
_t10 = void 0;
|
|
595
|
+
_context7.n = 17;
|
|
587
596
|
break;
|
|
588
|
-
case
|
|
589
|
-
|
|
590
|
-
case
|
|
591
|
-
userId =
|
|
597
|
+
case 16:
|
|
598
|
+
_t10 = (_yield$server$getUser2 = _yield$server$getUser.users) === null || _yield$server$getUser2 === void 0 ? void 0 : (_yield$server$getUser3 = _yield$server$getUser2[0]) === null || _yield$server$getUser3 === void 0 ? void 0 : _yield$server$getUser3.userId;
|
|
599
|
+
case 17:
|
|
600
|
+
userId = _t10;
|
|
592
601
|
if (userId) {
|
|
593
|
-
_context7.
|
|
602
|
+
_context7.n = 18;
|
|
594
603
|
break;
|
|
595
604
|
}
|
|
596
|
-
return _context7.
|
|
597
|
-
case
|
|
598
|
-
_context7.
|
|
605
|
+
return _context7.a(2, onError(authErrors.oauth.loginFailed));
|
|
606
|
+
case 18:
|
|
607
|
+
_context7.n = 19;
|
|
599
608
|
return server.createOauthProviders({
|
|
600
609
|
organizationId: orgId,
|
|
601
610
|
userId: userId,
|
|
602
611
|
oauthProviders: oauthProviders
|
|
603
612
|
});
|
|
604
|
-
case
|
|
605
|
-
_context7.
|
|
613
|
+
case 19:
|
|
614
|
+
_context7.n = 25;
|
|
606
615
|
break;
|
|
607
|
-
case
|
|
608
|
-
_context7.
|
|
616
|
+
case 20:
|
|
617
|
+
_context7.n = 21;
|
|
609
618
|
return server.createSuborg(createSuborgData);
|
|
610
|
-
case
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
if (
|
|
614
|
-
_context7.
|
|
619
|
+
case 21:
|
|
620
|
+
_t12 = _yield$server$createS = _context7.v;
|
|
621
|
+
_t11 = _t12 === null;
|
|
622
|
+
if (_t11) {
|
|
623
|
+
_context7.n = 22;
|
|
615
624
|
break;
|
|
616
625
|
}
|
|
617
|
-
|
|
618
|
-
case
|
|
619
|
-
if (!
|
|
620
|
-
_context7.
|
|
626
|
+
_t11 = _yield$server$createS === void 0;
|
|
627
|
+
case 22:
|
|
628
|
+
if (!_t11) {
|
|
629
|
+
_context7.n = 23;
|
|
621
630
|
break;
|
|
622
631
|
}
|
|
623
|
-
|
|
624
|
-
_context7.
|
|
632
|
+
_t13 = void 0;
|
|
633
|
+
_context7.n = 24;
|
|
625
634
|
break;
|
|
626
|
-
case
|
|
627
|
-
|
|
628
|
-
case
|
|
629
|
-
orgId =
|
|
630
|
-
case
|
|
631
|
-
_context7.
|
|
635
|
+
case 23:
|
|
636
|
+
_t13 = _yield$server$createS.subOrganizationId;
|
|
637
|
+
case 24:
|
|
638
|
+
orgId = _t13;
|
|
639
|
+
case 25:
|
|
640
|
+
_context7.n = 31;
|
|
632
641
|
break;
|
|
633
|
-
case
|
|
634
|
-
_context7.
|
|
642
|
+
case 26:
|
|
643
|
+
_context7.n = 27;
|
|
635
644
|
return server.createSuborg(createSuborgData);
|
|
636
|
-
case
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
if (
|
|
640
|
-
_context7.
|
|
645
|
+
case 27:
|
|
646
|
+
_t15 = _yield$server$createS2 = _context7.v;
|
|
647
|
+
_t14 = _t15 === null;
|
|
648
|
+
if (_t14) {
|
|
649
|
+
_context7.n = 28;
|
|
641
650
|
break;
|
|
642
651
|
}
|
|
643
|
-
|
|
644
|
-
case
|
|
645
|
-
if (!
|
|
646
|
-
_context7.
|
|
652
|
+
_t14 = _yield$server$createS2 === void 0;
|
|
653
|
+
case 28:
|
|
654
|
+
if (!_t14) {
|
|
655
|
+
_context7.n = 29;
|
|
647
656
|
break;
|
|
648
657
|
}
|
|
649
|
-
|
|
650
|
-
_context7.
|
|
658
|
+
_t16 = void 0;
|
|
659
|
+
_context7.n = 30;
|
|
651
660
|
break;
|
|
652
|
-
case
|
|
653
|
-
|
|
654
|
-
case
|
|
655
|
-
orgId =
|
|
656
|
-
case
|
|
657
|
-
return _context7.
|
|
658
|
-
case 94:
|
|
659
|
-
case "end":
|
|
660
|
-
return _context7.stop();
|
|
661
|
+
case 29:
|
|
662
|
+
_t16 = _yield$server$createS2.subOrganizationId;
|
|
663
|
+
case 30:
|
|
664
|
+
orgId = _t16;
|
|
665
|
+
case 31:
|
|
666
|
+
return _context7.a(2, orgId ? completeLogin(orgId) : onError(authErrors.oauth.loginFailed));
|
|
661
667
|
}
|
|
662
668
|
}, _callee7);
|
|
663
669
|
}));
|
|
@@ -666,31 +672,31 @@ var Auth = function Auth(_ref) {
|
|
|
666
672
|
};
|
|
667
673
|
}();
|
|
668
674
|
var handleLoginWithWallet = /*#__PURE__*/function () {
|
|
669
|
-
var _ref1 = _asyncToGenerator(/*#__PURE__*/
|
|
670
|
-
var _authConfig$sessionLe3, publicKey, _walletClient$getWall, type, resp, suborgIds, pubKey;
|
|
671
|
-
return
|
|
672
|
-
while (1) switch (_context8.
|
|
675
|
+
var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
676
|
+
var _authConfig$sessionLe3, publicKey, _walletClient$getWall, type, resp, suborgIds, pubKey, _t17;
|
|
677
|
+
return _regenerator().w(function (_context8) {
|
|
678
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
673
679
|
case 0:
|
|
674
680
|
setLoading("wallet");
|
|
675
|
-
_context8.
|
|
681
|
+
_context8.p = 1;
|
|
676
682
|
if (walletClient) {
|
|
677
|
-
_context8.
|
|
683
|
+
_context8.n = 2;
|
|
678
684
|
break;
|
|
679
685
|
}
|
|
680
686
|
throw new Error("Wallet client not initialized");
|
|
681
|
-
case
|
|
682
|
-
_context8.
|
|
687
|
+
case 2:
|
|
688
|
+
_context8.n = 3;
|
|
683
689
|
return walletClient.getPublicKey();
|
|
684
|
-
case
|
|
685
|
-
publicKey = _context8.
|
|
690
|
+
case 3:
|
|
691
|
+
publicKey = _context8.v;
|
|
686
692
|
if (publicKey) {
|
|
687
|
-
_context8.
|
|
693
|
+
_context8.n = 4;
|
|
688
694
|
break;
|
|
689
695
|
}
|
|
690
696
|
throw new Error(authErrors.wallet.noPublicKey);
|
|
691
|
-
case
|
|
697
|
+
case 4:
|
|
692
698
|
_walletClient$getWall = walletClient.getWalletInterface(), type = _walletClient$getWall.type;
|
|
693
|
-
_context8.
|
|
699
|
+
_context8.n = 5;
|
|
694
700
|
return server.getOrCreateSuborg(_objectSpread2({
|
|
695
701
|
filterType: FilterType.PublicKey,
|
|
696
702
|
filterValue: publicKey,
|
|
@@ -703,49 +709,48 @@ var Auth = function Auth(_ref) {
|
|
|
703
709
|
}, customAccounts && {
|
|
704
710
|
customAccounts: customAccounts
|
|
705
711
|
}));
|
|
706
|
-
case
|
|
707
|
-
resp = _context8.
|
|
712
|
+
case 5:
|
|
713
|
+
resp = _context8.v;
|
|
708
714
|
suborgIds = resp === null || resp === void 0 ? void 0 : resp.subOrganizationIds;
|
|
709
715
|
if (!(!suborgIds || suborgIds.length === 0)) {
|
|
710
|
-
_context8.
|
|
716
|
+
_context8.n = 6;
|
|
711
717
|
break;
|
|
712
718
|
}
|
|
713
719
|
onError(authErrors.wallet.loginFailed);
|
|
714
|
-
return _context8.
|
|
715
|
-
case
|
|
716
|
-
_context8.
|
|
720
|
+
return _context8.a(2);
|
|
721
|
+
case 6:
|
|
722
|
+
_context8.n = 7;
|
|
717
723
|
return indexedDbClient.resetKeyPair();
|
|
718
|
-
case
|
|
719
|
-
_context8.
|
|
724
|
+
case 7:
|
|
725
|
+
_context8.n = 8;
|
|
720
726
|
return indexedDbClient.getPublicKey();
|
|
721
|
-
case
|
|
722
|
-
pubKey = _context8.
|
|
723
|
-
_context8.
|
|
727
|
+
case 8:
|
|
728
|
+
pubKey = _context8.v;
|
|
729
|
+
_context8.n = 9;
|
|
724
730
|
return walletClient.loginWithWallet({
|
|
725
731
|
sessionType: SessionType.READ_WRITE,
|
|
726
732
|
publicKey: pubKey,
|
|
727
733
|
expirationSeconds: (_authConfig$sessionLe3 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe3 === void 0 ? void 0 : _authConfig$sessionLe3.toString()
|
|
728
734
|
});
|
|
729
|
-
case
|
|
730
|
-
_context8.
|
|
735
|
+
case 9:
|
|
736
|
+
_context8.n = 10;
|
|
731
737
|
return onAuthSuccess();
|
|
732
|
-
case
|
|
733
|
-
_context8.
|
|
738
|
+
case 10:
|
|
739
|
+
_context8.n = 12;
|
|
734
740
|
break;
|
|
735
|
-
case
|
|
736
|
-
_context8.
|
|
737
|
-
|
|
738
|
-
onError(
|
|
739
|
-
console.error("Error during wallet login: ",
|
|
740
|
-
case
|
|
741
|
-
_context8.
|
|
741
|
+
case 11:
|
|
742
|
+
_context8.p = 11;
|
|
743
|
+
_t17 = _context8.v;
|
|
744
|
+
onError(_t17.message || authErrors.wallet.loginFailed);
|
|
745
|
+
console.error("Error during wallet login: ", _t17);
|
|
746
|
+
case 12:
|
|
747
|
+
_context8.p = 12;
|
|
742
748
|
setLoading(undefined);
|
|
743
|
-
return _context8.
|
|
744
|
-
case
|
|
745
|
-
|
|
746
|
-
return _context8.stop();
|
|
749
|
+
return _context8.f(12);
|
|
750
|
+
case 13:
|
|
751
|
+
return _context8.a(2);
|
|
747
752
|
}
|
|
748
|
-
}, _callee8, null, [[1,
|
|
753
|
+
}, _callee8, null, [[1, 11, 12, 13]]);
|
|
749
754
|
}));
|
|
750
755
|
return function handleLoginWithWallet() {
|
|
751
756
|
return _ref1.apply(this, arguments);
|