@turnkey/sdk-react 5.3.2-beta.2 → 5.3.3
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 +14 -25
- package/dist/components/auth/Auth.d.ts +1 -0
- package/dist/components/auth/Auth.d.ts.map +1 -1
- package/dist/components/auth/Auth.js +15 -9
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +28 -32
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.d.ts +3 -0
- package/dist/components/auth/OtpVerification.d.ts.map +1 -1
- package/dist/components/auth/OtpVerification.js +6 -0
- package/dist/components/auth/OtpVerification.js.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +7 -1
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/package.json +13 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { slicedToArray as _slicedToArray,
|
|
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,
|
|
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$
|
|
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
|
|
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
|
|
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
|
|
347
|
-
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(
|
|
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
|
|
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
|
-
|
|
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
|
|
356
|
+
case 3:
|
|
366
357
|
publicKey = _context5.sent;
|
|
367
|
-
_context5.next =
|
|
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
|
|
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
|
|
382
|
+
case 9:
|
|
392
383
|
case "end":
|
|
393
384
|
return _context5.stop();
|
|
394
385
|
}
|
|
395
386
|
}, _callee5);
|
|
396
387
|
}));
|
|
397
|
-
return function
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
}
|
|
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", {
|