@turnkey/sdk-react 5.0.1 → 5.0.2

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.
@@ -153,35 +153,24 @@ var Auth = function Auth(_ref) {
153
153
  useEffect(function () {
154
154
  var manageClient = /*#__PURE__*/function () {
155
155
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
156
- var session, retrievedPublicKey;
156
+ var retrievedPublicKey;
157
157
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
158
158
  while (1) switch (_context2.prev = _context2.next) {
159
159
  case 0:
160
160
  if (!(indexedDbClient && turnkey)) {
161
- _context2.next = 11;
161
+ _context2.next = 5;
162
162
  break;
163
163
  }
164
164
  _context2.next = 3;
165
- return turnkey.getSession();
166
- case 3:
167
- session = _context2.sent;
168
- if (session) {
169
- _context2.next = 7;
170
- break;
171
- }
172
- _context2.next = 7;
173
- return indexedDbClient.resetKeyPair();
174
- case 7:
175
- _context2.next = 9;
176
165
  return indexedDbClient.getPublicKey();
177
- case 9:
166
+ case 3:
178
167
  retrievedPublicKey = _context2.sent;
179
168
  if (retrievedPublicKey) {
180
169
  setComponentReady(true);
181
170
  } else {
182
171
  onError("Failed to retrieve public key.");
183
172
  }
184
- case 11:
173
+ case 5:
185
174
  case "end":
186
175
  return _context2.stop();
187
176
  }
@@ -278,31 +267,34 @@ var Auth = function Auth(_ref) {
278
267
  case 21:
279
268
  case 22:
280
269
  _context3.next = 24;
281
- return indexedDbClient.getPublicKey();
270
+ return indexedDbClient.resetKeyPair();
282
271
  case 24:
272
+ _context3.next = 26;
273
+ return indexedDbClient.getPublicKey();
274
+ case 26:
283
275
  pubKey = _context3.sent;
284
- _context3.next = 27;
276
+ _context3.next = 29;
285
277
  return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.loginWithPasskey({
286
278
  sessionType: SessionType.READ_WRITE,
287
279
  publicKey: pubKey,
288
280
  expirationSeconds: (_authConfig$sessionLe = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe === void 0 ? void 0 : _authConfig$sessionLe.toString()
289
281
  });
290
- case 27:
291
- _context3.next = 29;
292
- return onAuthSuccess();
293
282
  case 29:
294
- _context3.next = 35;
295
- break;
283
+ _context3.next = 31;
284
+ return onAuthSuccess();
296
285
  case 31:
297
- _context3.prev = 31;
286
+ _context3.next = 37;
287
+ break;
288
+ case 33:
289
+ _context3.prev = 33;
298
290
  _context3.t1 = _context3["catch"](4);
299
291
  setPasskeySignupError(authErrors.passkey.timeoutOrNotAllowed);
300
292
  console.error("Error during passkey signup: ", _context3.t1);
301
- case 35:
293
+ case 37:
302
294
  case "end":
303
295
  return _context3.stop();
304
296
  }
305
- }, _callee3, null, [[4, 31]]);
297
+ }, _callee3, null, [[4, 33]]);
306
298
  }));
307
299
  return function handleSignupWithPasskey() {
308
300
  return _ref4.apply(this, arguments);
@@ -317,35 +309,38 @@ var Auth = function Auth(_ref) {
317
309
  _context4.prev = 0;
318
310
  setLoading("passkey");
319
311
  _context4.next = 4;
320
- return indexedDbClient.getPublicKey();
312
+ return indexedDbClient === null || indexedDbClient === void 0 ? void 0 : indexedDbClient.resetKeyPair();
321
313
  case 4:
314
+ _context4.next = 6;
315
+ return indexedDbClient.getPublicKey();
316
+ case 6:
322
317
  pubKey = _context4.sent;
323
- _context4.next = 7;
318
+ _context4.next = 9;
324
319
  return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.loginWithPasskey({
325
320
  sessionType: SessionType.READ_WRITE,
326
321
  publicKey: pubKey,
327
322
  expirationSeconds: (_authConfig$sessionLe2 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe2 === void 0 ? void 0 : _authConfig$sessionLe2.toString()
328
323
  });
329
- case 7:
330
- _context4.next = 9;
331
- return onAuthSuccess();
332
324
  case 9:
333
- _context4.next = 15;
334
- break;
325
+ _context4.next = 11;
326
+ return onAuthSuccess();
335
327
  case 11:
336
- _context4.prev = 11;
328
+ _context4.next = 17;
329
+ break;
330
+ case 13:
331
+ _context4.prev = 13;
337
332
  _context4.t0 = _context4["catch"](0);
338
333
  onError(authErrors.passkey.loginFailed);
339
334
  console.error("Error during passkey login: ", _context4.t0);
340
- case 15:
341
- _context4.prev = 15;
335
+ case 17:
336
+ _context4.prev = 17;
342
337
  setLoading(undefined);
343
- return _context4.finish(15);
344
- case 18:
338
+ return _context4.finish(17);
339
+ case 20:
345
340
  case "end":
346
341
  return _context4.stop();
347
342
  }
348
- }, _callee4, null, [[0, 11, 15, 18]]);
343
+ }, _callee4, null, [[0, 13, 17, 20]]);
349
344
  }));
350
345
  return function handleLoginWithPasskey() {
351
346
  return _ref6.apply(this, arguments);
@@ -529,35 +524,38 @@ var Auth = function Auth(_ref) {
529
524
  return _context7.abrupt("return");
530
525
  case 17:
531
526
  _context7.next = 19;
532
- return indexedDbClient.getPublicKey();
527
+ return indexedDbClient.resetKeyPair();
533
528
  case 19:
529
+ _context7.next = 21;
530
+ return indexedDbClient.getPublicKey();
531
+ case 21:
534
532
  pubKey = _context7.sent;
535
- _context7.next = 22;
533
+ _context7.next = 24;
536
534
  return walletClient.loginWithWallet({
537
535
  sessionType: SessionType.READ_WRITE,
538
536
  publicKey: pubKey,
539
537
  expirationSeconds: (_authConfig$sessionLe3 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe3 === void 0 ? void 0 : _authConfig$sessionLe3.toString()
540
538
  });
541
- case 22:
542
- _context7.next = 24;
543
- return onAuthSuccess();
544
539
  case 24:
545
- _context7.next = 30;
546
- break;
540
+ _context7.next = 26;
541
+ return onAuthSuccess();
547
542
  case 26:
548
- _context7.prev = 26;
543
+ _context7.next = 32;
544
+ break;
545
+ case 28:
546
+ _context7.prev = 28;
549
547
  _context7.t0 = _context7["catch"](1);
550
548
  onError(_context7.t0.message || authErrors.wallet.loginFailed);
551
549
  console.error("Error during wallet login: ", _context7.t0);
552
- case 30:
553
- _context7.prev = 30;
550
+ case 32:
551
+ _context7.prev = 32;
554
552
  setLoading(undefined);
555
- return _context7.finish(30);
556
- case 33:
553
+ return _context7.finish(32);
554
+ case 35:
557
555
  case "end":
558
556
  return _context7.stop();
559
557
  }
560
- }, _callee7, null, [[1, 26, 30, 33]]);
558
+ }, _callee7, null, [[1, 28, 32, 35]]);
561
559
  }));
562
560
  return function handleLoginWithWallet() {
563
561
  return _ref9.apply(this, arguments);