@turnkey/sdk-react 3.0.1 → 3.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.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -0
- package/dist/components/auth/Auth.d.ts.map +1 -1
- package/dist/components/auth/Auth.js +13 -5
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +46 -32
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.d.ts +1 -1
- package/dist/components/auth/OtpVerification.d.ts.map +1 -1
- package/dist/components/auth/OtpVerification.js +1 -1
- package/dist/components/auth/OtpVerification.js.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +1 -1
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/dist/hooks/use-session.d.ts.map +1 -1
- package/dist/hooks/use-session.js +3 -2
- package/dist/hooks/use-session.js.map +1 -1
- package/dist/hooks/use-session.mjs +2 -1
- package/dist/hooks/use-session.mjs.map +1 -1
- package/dist/hooks/use-turnkey.d.ts.map +1 -1
- package/dist/hooks/use-turnkey.js +1 -0
- package/dist/hooks/use-turnkey.js.map +1 -1
- package/dist/hooks/use-turnkey.mjs +1 -0
- package/dist/hooks/use-turnkey.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -173,7 +173,7 @@ var Auth = function Auth(_ref) {
|
|
|
173
173
|
case 0:
|
|
174
174
|
additionalData = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : {};
|
|
175
175
|
if (!(filterType == FilterType.Email || filterType == FilterType.PhoneNumber)) {
|
|
176
|
-
_context2.next =
|
|
176
|
+
_context2.next = 11;
|
|
177
177
|
break;
|
|
178
178
|
}
|
|
179
179
|
_context2.next = 4;
|
|
@@ -183,27 +183,35 @@ var Auth = function Auth(_ref) {
|
|
|
183
183
|
});
|
|
184
184
|
case 4:
|
|
185
185
|
getVerifiedSuborgsResponse = _context2.sent;
|
|
186
|
-
if (!getVerifiedSuborgsResponse || !getVerifiedSuborgsResponse.organizationIds) {
|
|
187
|
-
|
|
186
|
+
if (!(!getVerifiedSuborgsResponse || !getVerifiedSuborgsResponse.organizationIds)) {
|
|
187
|
+
_context2.next = 8;
|
|
188
|
+
break;
|
|
188
189
|
}
|
|
190
|
+
onError(authErrors.suborg.fetchFailed);
|
|
191
|
+
return _context2.abrupt("return", null);
|
|
192
|
+
case 8:
|
|
189
193
|
suborgId = getVerifiedSuborgsResponse === null || getVerifiedSuborgsResponse === void 0 ? void 0 : getVerifiedSuborgsResponse.organizationIds[0];
|
|
190
|
-
_context2.next =
|
|
194
|
+
_context2.next = 18;
|
|
191
195
|
break;
|
|
192
|
-
case
|
|
193
|
-
_context2.next =
|
|
196
|
+
case 11:
|
|
197
|
+
_context2.next = 13;
|
|
194
198
|
return server.getSuborgs({
|
|
195
199
|
filterType: filterType,
|
|
196
200
|
filterValue: filterValue
|
|
197
201
|
});
|
|
198
|
-
case
|
|
202
|
+
case 13:
|
|
199
203
|
getSuborgsResponse = _context2.sent;
|
|
200
|
-
if (!getSuborgsResponse || !getSuborgsResponse.organizationIds) {
|
|
201
|
-
|
|
204
|
+
if (!(!getSuborgsResponse || !getSuborgsResponse.organizationIds)) {
|
|
205
|
+
_context2.next = 17;
|
|
206
|
+
break;
|
|
202
207
|
}
|
|
208
|
+
onError(authErrors.suborg.fetchFailed);
|
|
209
|
+
return _context2.abrupt("return", null);
|
|
210
|
+
case 17:
|
|
203
211
|
suborgId = getSuborgsResponse === null || getSuborgsResponse === void 0 ? void 0 : getSuborgsResponse.organizationIds[0];
|
|
204
|
-
case
|
|
212
|
+
case 18:
|
|
205
213
|
if (suborgId) {
|
|
206
|
-
_context2.next =
|
|
214
|
+
_context2.next = 27;
|
|
207
215
|
break;
|
|
208
216
|
}
|
|
209
217
|
createSuborgData = _objectSpread2({}, additionalData);
|
|
@@ -211,17 +219,17 @@ var Auth = function Auth(_ref) {
|
|
|
211
219
|
if (customAccounts) {
|
|
212
220
|
createSuborgData.customAccounts = customAccounts;
|
|
213
221
|
}
|
|
214
|
-
_context2.next =
|
|
222
|
+
_context2.next = 24;
|
|
215
223
|
return server.createSuborg(createSuborgData);
|
|
216
|
-
case
|
|
224
|
+
case 24:
|
|
217
225
|
createSuborgResponse = _context2.sent;
|
|
218
226
|
if (!createSuborgResponse || !createSuborgResponse.subOrganizationId) {
|
|
219
227
|
onError(authErrors.suborg.createFailed);
|
|
220
228
|
}
|
|
221
229
|
suborgId = createSuborgResponse === null || createSuborgResponse === void 0 ? void 0 : createSuborgResponse.subOrganizationId;
|
|
222
|
-
case
|
|
230
|
+
case 27:
|
|
223
231
|
return _context2.abrupt("return", suborgId);
|
|
224
|
-
case
|
|
232
|
+
case 28:
|
|
225
233
|
case "end":
|
|
226
234
|
return _context2.stop();
|
|
227
235
|
}
|
|
@@ -232,7 +240,7 @@ var Auth = function Auth(_ref) {
|
|
|
232
240
|
};
|
|
233
241
|
}();
|
|
234
242
|
var handleAuthSuccess = /*#__PURE__*/function () {
|
|
235
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(credentialBundle) {
|
|
243
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(credentialBundle, expirationSeconds) {
|
|
236
244
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
237
245
|
while (1) switch (_context3.prev = _context3.next) {
|
|
238
246
|
case 0:
|
|
@@ -244,7 +252,7 @@ var Auth = function Auth(_ref) {
|
|
|
244
252
|
return authIframeClient.injectCredentialBundle(credentialBundle);
|
|
245
253
|
case 3:
|
|
246
254
|
_context3.next = 5;
|
|
247
|
-
return authIframeClient.loginWithAuthBundle(credentialBundle);
|
|
255
|
+
return authIframeClient.loginWithAuthBundle(credentialBundle, expirationSeconds);
|
|
248
256
|
case 5:
|
|
249
257
|
_context3.next = 7;
|
|
250
258
|
return onAuthSuccess();
|
|
@@ -254,13 +262,13 @@ var Auth = function Auth(_ref) {
|
|
|
254
262
|
}
|
|
255
263
|
}, _callee3);
|
|
256
264
|
}));
|
|
257
|
-
return function handleAuthSuccess(_x3) {
|
|
265
|
+
return function handleAuthSuccess(_x3, _x4) {
|
|
258
266
|
return _ref4.apply(this, arguments);
|
|
259
267
|
};
|
|
260
268
|
}();
|
|
261
269
|
var handleSignupWithPasskey = /*#__PURE__*/function () {
|
|
262
270
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
263
|
-
var siteInfo, _turnkey$config$defau, _ref6, encodedChallenge, attestation, response, sessionResponse;
|
|
271
|
+
var siteInfo, _turnkey$config$defau, _ref6, encodedChallenge, attestation, response, sessionResponse, _authConfig$sessionLe;
|
|
264
272
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
265
273
|
while (1) switch (_context4.prev = _context4.next) {
|
|
266
274
|
case 0:
|
|
@@ -325,10 +333,13 @@ var Auth = function Auth(_ref) {
|
|
|
325
333
|
case 21:
|
|
326
334
|
case 22:
|
|
327
335
|
_context4.next = 24;
|
|
328
|
-
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createReadWriteSession({
|
|
329
|
-
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
336
|
+
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createReadWriteSession(_objectSpread2(_objectSpread2({
|
|
337
|
+
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
338
|
+
}, authConfig.sessionLengthSeconds !== undefined && {
|
|
339
|
+
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
340
|
+
}), {}, {
|
|
330
341
|
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
|
|
331
|
-
});
|
|
342
|
+
}));
|
|
332
343
|
case 24:
|
|
333
344
|
sessionResponse = _context4.sent;
|
|
334
345
|
if (!(sessionResponse !== null && sessionResponse !== void 0 && sessionResponse.credentialBundle)) {
|
|
@@ -336,7 +347,7 @@ var Auth = function Auth(_ref) {
|
|
|
336
347
|
break;
|
|
337
348
|
}
|
|
338
349
|
_context4.next = 28;
|
|
339
|
-
return handleAuthSuccess(sessionResponse.credentialBundle);
|
|
350
|
+
return handleAuthSuccess(sessionResponse.credentialBundle, (_authConfig$sessionLe = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe === void 0 ? void 0 : _authConfig$sessionLe.toString());
|
|
340
351
|
case 28:
|
|
341
352
|
_context4.next = 31;
|
|
342
353
|
break;
|
|
@@ -361,16 +372,19 @@ var Auth = function Auth(_ref) {
|
|
|
361
372
|
}();
|
|
362
373
|
var handleLoginWithPasskey = /*#__PURE__*/function () {
|
|
363
374
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
364
|
-
var _turnkey$config$defau2, sessionResponse;
|
|
375
|
+
var _turnkey$config$defau2, sessionResponse, _authConfig$sessionLe2;
|
|
365
376
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
366
377
|
while (1) switch (_context5.prev = _context5.next) {
|
|
367
378
|
case 0:
|
|
368
379
|
_context5.prev = 0;
|
|
369
380
|
_context5.next = 3;
|
|
370
|
-
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createReadWriteSession({
|
|
371
|
-
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
381
|
+
return passkeyClient === null || passkeyClient === void 0 ? void 0 : passkeyClient.createReadWriteSession(_objectSpread2(_objectSpread2({
|
|
382
|
+
targetPublicKey: authIframeClient === null || authIframeClient === void 0 ? void 0 : authIframeClient.iframePublicKey
|
|
383
|
+
}, authConfig.sessionLengthSeconds !== undefined && {
|
|
384
|
+
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
385
|
+
}), {}, {
|
|
372
386
|
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
|
|
373
|
-
});
|
|
387
|
+
}));
|
|
374
388
|
case 3:
|
|
375
389
|
sessionResponse = _context5.sent;
|
|
376
390
|
if (!(sessionResponse !== null && sessionResponse !== void 0 && sessionResponse.credentialBundle)) {
|
|
@@ -378,7 +392,7 @@ var Auth = function Auth(_ref) {
|
|
|
378
392
|
break;
|
|
379
393
|
}
|
|
380
394
|
_context5.next = 7;
|
|
381
|
-
return handleAuthSuccess(sessionResponse.credentialBundle);
|
|
395
|
+
return handleAuthSuccess(sessionResponse.credentialBundle, (_authConfig$sessionLe2 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe2 === void 0 ? void 0 : _authConfig$sessionLe2.toString());
|
|
382
396
|
case 7:
|
|
383
397
|
_context5.next = 10;
|
|
384
398
|
break;
|
|
@@ -435,13 +449,13 @@ var Auth = function Auth(_ref) {
|
|
|
435
449
|
}
|
|
436
450
|
}, _callee6);
|
|
437
451
|
}));
|
|
438
|
-
return function handleOtpLogin(
|
|
452
|
+
return function handleOtpLogin(_x5, _x6, _x7) {
|
|
439
453
|
return _ref8.apply(this, arguments);
|
|
440
454
|
};
|
|
441
455
|
}();
|
|
442
456
|
var handleOAuthLogin = /*#__PURE__*/function () {
|
|
443
457
|
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(credential, providerName) {
|
|
444
|
-
var suborgId, oauthResponse;
|
|
458
|
+
var suborgId, oauthResponse, _authConfig$sessionLe3;
|
|
445
459
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
446
460
|
while (1) switch (_context7.prev = _context7.next) {
|
|
447
461
|
case 0:
|
|
@@ -469,7 +483,7 @@ var Auth = function Auth(_ref) {
|
|
|
469
483
|
break;
|
|
470
484
|
}
|
|
471
485
|
_context7.next = 10;
|
|
472
|
-
return handleAuthSuccess(oauthResponse.token);
|
|
486
|
+
return handleAuthSuccess(oauthResponse.token, (_authConfig$sessionLe3 = authConfig.sessionLengthSeconds) === null || _authConfig$sessionLe3 === void 0 ? void 0 : _authConfig$sessionLe3.toString());
|
|
473
487
|
case 10:
|
|
474
488
|
_context7.next = 13;
|
|
475
489
|
break;
|
|
@@ -481,7 +495,7 @@ var Auth = function Auth(_ref) {
|
|
|
481
495
|
}
|
|
482
496
|
}, _callee7);
|
|
483
497
|
}));
|
|
484
|
-
return function handleOAuthLogin(
|
|
498
|
+
return function handleOAuthLogin(_x8, _x9) {
|
|
485
499
|
return _ref9.apply(this, arguments);
|
|
486
500
|
};
|
|
487
501
|
}();
|