@turnkey/sdk-react 5.3.2-beta.0 → 5.3.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.
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.mjs';
2
+ import { slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } 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';
@@ -16,7 +16,7 @@ import appleIcon from '../../assets/apple.svg.mjs';
16
16
  import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
17
17
  import OtpVerification from './OtpVerification.mjs';
18
18
  import { useTurnkey } from '../../hooks/use-turnkey.mjs';
19
- import { OtpType, FilterType, authErrors } from './constants.mjs';
19
+ import { OtpType, authErrors, FilterType } from './constants.mjs';
20
20
  import { server } from '@turnkey/sdk-server';
21
21
  import parsePhoneNumberFromString from 'libphonenumber-js';
22
22
  import { SessionType } from '@turnkey/sdk-types';
@@ -56,7 +56,7 @@ var passkeyIconError = jsxs("svg", {
56
56
  })]
57
57
  });
58
58
  var Auth = function Auth(_ref) {
59
- var _otpConfig$alphanumer2, _otpConfig$otpLength2;
59
+ var _otpConfig$otpLength2;
60
60
  var onAuthSuccess = _ref.onAuthSuccess,
61
61
  onError = _ref.onError,
62
62
  authConfig = _ref.authConfig,
@@ -126,7 +126,7 @@ var Auth = function Auth(_ref) {
126
126
  break;
127
127
  }
128
128
  _context.next = 3;
129
- return handleOtpLogin(FilterType.Email, email, OtpType.Email);
129
+ return handleSendOtp(email, OtpType.Email);
130
130
  case 3:
131
131
  _context.next = 8;
132
132
  break;
@@ -136,7 +136,7 @@ var Auth = function Auth(_ref) {
136
136
  break;
137
137
  }
138
138
  _context.next = 8;
139
- return handleOtpLogin(FilterType.PhoneNumber, phone, OtpType.Sms);
139
+ return handleSendOtp(phone, OtpType.Sms);
140
140
  case 8:
141
141
  case "end":
142
142
  return _context.stop();
@@ -343,28 +343,19 @@ var Auth = function Auth(_ref) {
343
343
  return _ref6.apply(this, arguments);
344
344
  };
345
345
  }();
346
- var handleOtpLogin = /*#__PURE__*/function () {
347
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(type, value, otpType) {
346
+ var handleSendOtp = /*#__PURE__*/function () {
347
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(value, otpType) {
348
348
  var _otpConfig$otpLength, _otpConfig$alphanumer;
349
- var createSuborgData, publicKey, initAuthResponse;
349
+ var publicKey, initAuthResponse;
350
350
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
351
351
  while (1) switch (_context5.prev = _context5.next) {
352
352
  case 0:
353
353
  setLoading(otpType);
354
- createSuborgData = {};
355
- if (type === FilterType.Email) {
356
- createSuborgData.email = value;
357
- } else if (type === FilterType.PhoneNumber) {
358
- createSuborgData.phoneNumber = value;
359
- }
360
- if (customAccounts) {
361
- createSuborgData.customAccounts = customAccounts;
362
- }
363
- _context5.next = 6;
354
+ _context5.next = 3;
364
355
  return indexedDbClient.getPublicKey();
365
- case 6:
356
+ case 3:
366
357
  publicKey = _context5.sent;
367
- _context5.next = 9;
358
+ _context5.next = 6;
368
359
  return server.sendOtp(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
369
360
  otpType: otpType,
370
361
  contact: value
@@ -379,7 +370,7 @@ var Auth = function Auth(_ref) {
379
370
  alphanumeric: (_otpConfig$alphanumer = otpConfig === null || otpConfig === void 0 ? void 0 : otpConfig.alphanumeric) !== null && _otpConfig$alphanumer !== void 0 ? _otpConfig$alphanumer : false,
380
371
  userIdentifier: publicKey
381
372
  }));
382
- case 9:
373
+ case 6:
383
374
  initAuthResponse = _context5.sent;
384
375
  if (initAuthResponse && initAuthResponse.otpId) {
385
376
  setOtpId(initAuthResponse === null || initAuthResponse === void 0 ? void 0 : initAuthResponse.otpId);
@@ -388,13 +379,13 @@ var Auth = function Auth(_ref) {
388
379
  onError(authErrors.otp.sendFailed);
389
380
  }
390
381
  setLoading(undefined);
391
- case 12:
382
+ case 9:
392
383
  case "end":
393
384
  return _context5.stop();
394
385
  }
395
386
  }, _callee5);
396
387
  }));
397
- return function handleOtpLogin(_x, _x2, _x3) {
388
+ return function handleSendOtp(_x, _x2) {
398
389
  return _ref7.apply(this, arguments);
399
390
  };
400
391
  }();
@@ -477,7 +468,7 @@ var Auth = function Auth(_ref) {
477
468
  }
478
469
  }, _callee6);
479
470
  }));
480
- return function completeLogin(_x6) {
471
+ return function completeLogin(_x5) {
481
472
  return _ref9.apply(this, arguments);
482
473
  };
483
474
  }(); // Non-social-linking path: getOrCreateSuborg then login
@@ -670,7 +661,7 @@ var Auth = function Auth(_ref) {
670
661
  }
671
662
  }, _callee7);
672
663
  }));
673
- return function handleOAuthLogin(_x4, _x5) {
664
+ return function handleOAuthLogin(_x3, _x4) {
674
665
  return _ref8.apply(this, arguments);
675
666
  };
676
667
  }();
@@ -700,7 +691,7 @@ var Auth = function Auth(_ref) {
700
691
  case 9:
701
692
  _walletClient$getWall = walletClient.getWalletInterface(), type = _walletClient$getWall.type;
702
693
  _context8.next = 12;
703
- return server.getOrCreateSuborg({
694
+ return server.getOrCreateSuborg(_objectSpread2({
704
695
  filterType: FilterType.PublicKey,
705
696
  filterValue: publicKey,
706
697
  additionalData: {
@@ -709,7 +700,9 @@ var Auth = function Auth(_ref) {
709
700
  type: type
710
701
  }
711
702
  }
712
- });
703
+ }, customAccounts && {
704
+ customAccounts: customAccounts
705
+ }));
713
706
  case 12:
714
707
  resp = _context8.sent;
715
708
  suborgIds = resp === null || resp === void 0 ? void 0 : resp.subOrganizationIds;
@@ -818,7 +811,7 @@ var Auth = function Auth(_ref) {
818
811
  return authConfig.emailEnabled && !otpId ? jsxs("form", {
819
812
  onSubmit: function onSubmit(e) {
820
813
  e.preventDefault();
821
- handleOtpLogin(FilterType.Email, email, OtpType.Email);
814
+ handleSendOtp(email, OtpType.Email);
822
815
  },
823
816
  children: [jsx("div", {
824
817
  className: styles.inputGroup,
@@ -867,7 +860,7 @@ var Auth = function Auth(_ref) {
867
860
  return authConfig.phoneEnabled && !otpId ? jsxs("form", {
868
861
  onSubmit: function onSubmit(e) {
869
862
  e.preventDefault();
870
- handleOtpLogin(FilterType.PhoneNumber, phone, OtpType.Sms);
863
+ handleSendOtp(phone, OtpType.Sms);
871
864
  },
872
865
  children: [jsx("div", {
873
866
  className: styles.phoneInput,
@@ -1036,16 +1029,19 @@ var Auth = function Auth(_ref) {
1036
1029
  })
1037
1030
  })]
1038
1031
  }, section);
1039
- }), otpId && jsx(OtpVerification, {
1032
+ }), otpId && jsx(OtpVerification, _objectSpread2({
1040
1033
  type: step,
1041
1034
  contact: step === OtpType.Email ? email : phone,
1042
1035
  otpId: otpId,
1043
- alphanumeric: (_otpConfig$alphanumer2 = otpConfig === null || otpConfig === void 0 ? void 0 : otpConfig.alphanumeric) !== null && _otpConfig$alphanumer2 !== void 0 ? _otpConfig$alphanumer2 : false,
1036
+ alphanumeric: otpConfig === null || otpConfig === void 0 ? void 0 : otpConfig.alphanumeric,
1037
+ includeUnverifiedSubOrgs: otpConfig === null || otpConfig === void 0 ? void 0 : otpConfig.includeUnverifiedSubOrgs,
1044
1038
  sessionLengthSeconds: authConfig.sessionLengthSeconds,
1045
1039
  onValidateSuccess: onAuthSuccess,
1046
1040
  onResendCode: handleResendCode,
1047
1041
  numBoxes: (_otpConfig$otpLength2 = otpConfig === null || otpConfig === void 0 ? void 0 : otpConfig.otpLength) !== null && _otpConfig$otpLength2 !== void 0 ? _otpConfig$otpLength2 : 6
1048
- }), !otpId && jsx("div", {
1042
+ }, customAccounts && {
1043
+ customAccounts: customAccounts
1044
+ })), !otpId && jsx("div", {
1049
1045
  className: styles.tos,
1050
1046
  children: jsxs("span", {
1051
1047
  children: ["By continuing, you agree to our", " ", jsx("a", {