@turnkey/react-wallet-kit 1.0.0-beta.6 → 1.0.0
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/README.MD +5 -2
- package/dist/components/auth/Email.d.ts.map +1 -1
- package/dist/components/auth/Email.js +3 -0
- package/dist/components/auth/Email.js.map +1 -1
- package/dist/components/auth/Email.mjs +3 -0
- package/dist/components/auth/Email.mjs.map +1 -1
- package/dist/components/auth/OAuth.d.ts.map +1 -1
- package/dist/components/auth/OAuth.js +1 -0
- package/dist/components/auth/OAuth.js.map +1 -1
- package/dist/components/auth/OAuth.mjs +1 -0
- package/dist/components/auth/OAuth.mjs.map +1 -1
- package/dist/components/auth/Passkey.d.ts.map +1 -1
- package/dist/components/auth/Passkey.js +2 -0
- package/dist/components/auth/Passkey.js.map +1 -1
- package/dist/components/auth/Passkey.mjs +2 -0
- package/dist/components/auth/Passkey.mjs.map +1 -1
- package/dist/components/auth/Wallet.d.ts.map +1 -1
- package/dist/components/auth/Wallet.js +3 -2
- package/dist/components/auth/Wallet.js.map +1 -1
- package/dist/components/auth/Wallet.mjs +3 -2
- package/dist/components/auth/Wallet.mjs.map +1 -1
- package/dist/components/auth/index.js +2 -2
- package/dist/components/auth/index.js.map +1 -1
- package/dist/components/auth/index.mjs +2 -2
- package/dist/components/auth/index.mjs.map +1 -1
- package/dist/components/design/Buttons.d.ts +2 -0
- package/dist/components/design/Buttons.d.ts.map +1 -1
- package/dist/components/design/Buttons.js +8 -2
- package/dist/components/design/Buttons.js.map +1 -1
- package/dist/components/design/Buttons.mjs +9 -3
- package/dist/components/design/Buttons.mjs.map +1 -1
- package/dist/components/export/Export.d.ts.map +1 -1
- package/dist/components/export/Export.js +1 -0
- package/dist/components/export/Export.js.map +1 -1
- package/dist/components/export/Export.mjs +1 -0
- package/dist/components/export/Export.mjs.map +1 -1
- package/dist/components/export/ExportWarning.d.ts.map +1 -1
- package/dist/components/export/ExportWarning.js +1 -0
- package/dist/components/export/ExportWarning.js.map +1 -1
- package/dist/components/export/ExportWarning.mjs +1 -0
- package/dist/components/export/ExportWarning.mjs.map +1 -1
- package/dist/components/import/Import.d.ts.map +1 -1
- package/dist/components/import/Import.js +4 -1
- package/dist/components/import/Import.js.map +1 -1
- package/dist/components/import/Import.mjs +5 -2
- package/dist/components/import/Import.mjs.map +1 -1
- package/dist/components/sign/Message.d.ts.map +1 -1
- package/dist/components/sign/Message.js +1 -0
- package/dist/components/sign/Message.js.map +1 -1
- package/dist/components/sign/Message.mjs +1 -0
- package/dist/components/sign/Message.mjs.map +1 -1
- package/dist/components/user/RemovePasskey.d.ts.map +1 -1
- package/dist/components/user/RemovePasskey.js +1 -0
- package/dist/components/user/RemovePasskey.js.map +1 -1
- package/dist/components/user/RemovePasskey.mjs +1 -0
- package/dist/components/user/RemovePasskey.mjs.map +1 -1
- package/dist/providers/client/Provider.d.ts.map +1 -1
- package/dist/providers/client/Provider.js +79 -47
- package/dist/providers/client/Provider.js.map +1 -1
- package/dist/providers/client/Provider.mjs +979 -900
- package/dist/providers/client/Provider.mjs.map +1 -1
- package/dist/tests/timers-test.d.ts +2 -0
- package/dist/tests/timers-test.d.ts.map +1 -0
- package/dist/tests/utils-test.d.ts +2 -0
- package/dist/tests/utils-test.d.ts.map +1 -0
- package/dist/types/base.d.ts +3 -1
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/base.js.map +1 -1
- package/dist/types/base.mjs.map +1 -1
- package/package.json +6 -5
|
@@ -75,6 +75,7 @@ const ClientProvider = ({
|
|
|
75
75
|
const proxyAuthConfigRef = react.useRef(null);
|
|
76
76
|
const [allSessions, setAllSessions] = react.useState(undefined);
|
|
77
77
|
const {
|
|
78
|
+
isMobile,
|
|
78
79
|
pushPage,
|
|
79
80
|
closeModal
|
|
80
81
|
} = Hook.useModal();
|
|
@@ -166,6 +167,7 @@ const ClientProvider = ({
|
|
|
166
167
|
authCode: code,
|
|
167
168
|
redirectUri: redirectURI,
|
|
168
169
|
codeVerifier: verifier,
|
|
170
|
+
clientId,
|
|
169
171
|
nonce: nonce
|
|
170
172
|
});
|
|
171
173
|
sessionStorage.removeItem("discord_verifier");
|
|
@@ -220,6 +222,7 @@ const ClientProvider = ({
|
|
|
220
222
|
authCode: code,
|
|
221
223
|
redirectUri: redirectURI,
|
|
222
224
|
codeVerifier: verifier,
|
|
225
|
+
clientId,
|
|
223
226
|
nonce: nonce
|
|
224
227
|
});
|
|
225
228
|
sessionStorage.removeItem("twitter_verifier");
|
|
@@ -347,6 +350,14 @@ const ClientProvider = ({
|
|
|
347
350
|
appleOauthEnabled: config.auth?.methods?.appleOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("apple"),
|
|
348
351
|
facebookOauthEnabled: config.auth?.methods?.facebookOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("facebook")
|
|
349
352
|
};
|
|
353
|
+
const resolvedClientIds = {
|
|
354
|
+
googleClientId: config.auth?.oauthConfig?.googleClientId ?? proxyAuthConfig?.oauthClientIds?.google,
|
|
355
|
+
appleClientId: config.auth?.oauthConfig?.appleClientId ?? proxyAuthConfig?.oauthClientIds?.apple,
|
|
356
|
+
facebookClientId: config.auth?.oauthConfig?.facebookClientId ?? proxyAuthConfig?.oauthClientIds?.facebook,
|
|
357
|
+
xClientId: config.auth?.oauthConfig?.xClientId ?? proxyAuthConfig?.oauthClientIds?.x,
|
|
358
|
+
discordClientId: config.auth?.oauthConfig?.discordClientId ?? proxyAuthConfig?.oauthClientIds?.discord
|
|
359
|
+
};
|
|
360
|
+
const redirectUrl = config.auth?.oauthConfig?.oauthRedirectUri ?? proxyAuthConfig?.oauthRedirectUrl;
|
|
350
361
|
// Set a default ordering for the oAuth methods
|
|
351
362
|
const oauthOrder = config.auth?.oauthOrder ?? ["google", "apple", "x", "discord", "facebook"].filter(provider => resolvedMethods[`${provider}OauthEnabled`]);
|
|
352
363
|
// Set a default ordering for the overall auth methods
|
|
@@ -359,13 +370,18 @@ const ClientProvider = ({
|
|
|
359
370
|
methods: resolvedMethods,
|
|
360
371
|
oauthConfig: {
|
|
361
372
|
...config.auth?.oauthConfig,
|
|
362
|
-
|
|
373
|
+
...resolvedClientIds,
|
|
374
|
+
oauthRedirectUri: redirectUrl,
|
|
375
|
+
// on mobile we default to true since many mobile browsers
|
|
376
|
+
// (e.g. Safari) block popups
|
|
377
|
+
openOauthInPage: isMobile ? true : config.auth?.oauthConfig?.openOauthInPage
|
|
363
378
|
},
|
|
364
379
|
sessionExpirationSeconds: proxyAuthConfig?.sessionExpirationSeconds,
|
|
365
380
|
methodOrder,
|
|
366
381
|
oauthOrder,
|
|
367
382
|
autoRefreshSession: config.auth?.autoRefreshSession ?? true
|
|
368
383
|
},
|
|
384
|
+
autoRefreshManagedState: config.autoRefreshManagedState ?? true,
|
|
369
385
|
walletConfig: {
|
|
370
386
|
...config.walletConfig,
|
|
371
387
|
features: {
|
|
@@ -839,11 +855,11 @@ const ClientProvider = ({
|
|
|
839
855
|
}
|
|
840
856
|
return res;
|
|
841
857
|
}, [client, callbacks]);
|
|
842
|
-
const
|
|
858
|
+
const fetchWalletProviders = react.useCallback(async chain => {
|
|
843
859
|
if (!client) {
|
|
844
860
|
throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
845
861
|
}
|
|
846
|
-
const newProviders = await client.
|
|
862
|
+
const newProviders = await client.fetchWalletProviders(chain);
|
|
847
863
|
// we update state with the latest providers
|
|
848
864
|
// we keep this state so that initializeWalletProviderListeners() re-runs
|
|
849
865
|
// whenever the list of connected providers changes
|
|
@@ -1182,6 +1198,14 @@ const ClientProvider = ({
|
|
|
1182
1198
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1183
1199
|
return utils.withTurnkeyErrorHandling(() => client.fetchUser(params), callbacks, "Failed to fetch user");
|
|
1184
1200
|
}, [client, callbacks]);
|
|
1201
|
+
const fetchOrCreateP256ApiKeyUser = react.useCallback(async params => {
|
|
1202
|
+
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1203
|
+
return utils.withTurnkeyErrorHandling(() => client.fetchOrCreateP256ApiKeyUser(params), callbacks, "Failed to fetch or create delegated access user");
|
|
1204
|
+
}, [client, callbacks]);
|
|
1205
|
+
const fetchOrCreatePolicies = react.useCallback(async params => {
|
|
1206
|
+
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1207
|
+
return utils.withTurnkeyErrorHandling(() => client.fetchOrCreatePolicies(params), callbacks, "Failed to fetch or create delegated access user");
|
|
1208
|
+
}, [client, callbacks]);
|
|
1185
1209
|
const updateUserEmail = react.useCallback(async params => {
|
|
1186
1210
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1187
1211
|
const res = await utils.withTurnkeyErrorHandling(() => client.updateUserEmail(params), callbacks, "Failed to update user email");
|
|
@@ -1290,7 +1314,7 @@ const ClientProvider = ({
|
|
|
1290
1314
|
stampWith: params?.stampWith
|
|
1291
1315
|
});
|
|
1292
1316
|
return res;
|
|
1293
|
-
}, [client, callbacks]);
|
|
1317
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1294
1318
|
const importWallet = react.useCallback(async params => {
|
|
1295
1319
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1296
1320
|
const res = await utils.withTurnkeyErrorHandling(() => client.importWallet(params), callbacks, "Failed to import wallet");
|
|
@@ -1298,16 +1322,16 @@ const ClientProvider = ({
|
|
|
1298
1322
|
stampWith: params?.stampWith
|
|
1299
1323
|
});
|
|
1300
1324
|
return res;
|
|
1301
|
-
}, [client, callbacks]);
|
|
1325
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1302
1326
|
const importPrivateKey = react.useCallback(async params => {
|
|
1303
1327
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1304
1328
|
const res = await utils.withTurnkeyErrorHandling(() => client.importPrivateKey(params), callbacks, "Failed to import private key");
|
|
1305
1329
|
return res;
|
|
1306
|
-
}, [client, callbacks]);
|
|
1330
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1307
1331
|
const deleteSubOrganization = react.useCallback(async params => {
|
|
1308
1332
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1309
1333
|
return utils.withTurnkeyErrorHandling(() => client.deleteSubOrganization(params), callbacks, "Failed to delete sub-organization");
|
|
1310
|
-
}, [client, callbacks]);
|
|
1334
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1311
1335
|
const storeSession = react.useCallback(async params => {
|
|
1312
1336
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1313
1337
|
await utils.withTurnkeyErrorHandling(() => client.storeSession(params), callbacks, "Failed to store session");
|
|
@@ -1325,7 +1349,7 @@ const ClientProvider = ({
|
|
|
1325
1349
|
setSession(session);
|
|
1326
1350
|
setAllSessions(allSessions);
|
|
1327
1351
|
return;
|
|
1328
|
-
}, [client, callbacks]);
|
|
1352
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1329
1353
|
const clearSession = react.useCallback(async params => {
|
|
1330
1354
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1331
1355
|
await utils.withTurnkeyErrorHandling(() => client.clearSession(params), callbacks, "Failed to clear session");
|
|
@@ -1334,13 +1358,13 @@ const ClientProvider = ({
|
|
|
1334
1358
|
setSession(session);
|
|
1335
1359
|
setAllSessions(allSessions);
|
|
1336
1360
|
return;
|
|
1337
|
-
}, [client, callbacks]);
|
|
1361
|
+
}, [client, callbacks, session, user, masterConfig]);
|
|
1338
1362
|
const clearAllSessions = react.useCallback(async () => {
|
|
1339
1363
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1340
1364
|
setSession(undefined);
|
|
1341
1365
|
setAllSessions(undefined);
|
|
1342
1366
|
return await utils.withTurnkeyErrorHandling(() => client.clearAllSessions(), callbacks, "Failed to clear all sessions");
|
|
1343
|
-
}, [client, callbacks]);
|
|
1367
|
+
}, [client, callbacks, session, user, masterConfig]);
|
|
1344
1368
|
const refreshSession = react.useCallback(async params => {
|
|
1345
1369
|
if (!client) {
|
|
1346
1370
|
throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
@@ -1369,15 +1393,15 @@ const ClientProvider = ({
|
|
|
1369
1393
|
setSession(session);
|
|
1370
1394
|
setAllSessions(allSessions);
|
|
1371
1395
|
return res;
|
|
1372
|
-
}, [client, callbacks]);
|
|
1396
|
+
}, [client, callbacks, scheduleSessionExpiration, session, user, masterConfig]);
|
|
1373
1397
|
const getSession = react.useCallback(async params => {
|
|
1374
1398
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1375
1399
|
return utils.withTurnkeyErrorHandling(() => client.getSession(params), callbacks, "Failed to get session");
|
|
1376
|
-
}, [client, callbacks]);
|
|
1400
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1377
1401
|
const getAllSessions = react.useCallback(async () => {
|
|
1378
1402
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1379
1403
|
return utils.withTurnkeyErrorHandling(() => client.getAllSessions(), callbacks, "Failed to get all sessions");
|
|
1380
|
-
}, [client, callbacks]);
|
|
1404
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1381
1405
|
const setActiveSession = react.useCallback(async params => {
|
|
1382
1406
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1383
1407
|
const session = await utils.withTurnkeyErrorHandling(() => client.getSession({
|
|
@@ -1393,24 +1417,25 @@ const ClientProvider = ({
|
|
|
1393
1417
|
await refreshUser();
|
|
1394
1418
|
}, callbacks, "Failed to refresh data after setting active session");
|
|
1395
1419
|
return;
|
|
1396
|
-
}, [client, callbacks]);
|
|
1420
|
+
}, [client, callbacks, session, user, masterConfig]);
|
|
1397
1421
|
const getActiveSessionKey = react.useCallback(async () => {
|
|
1398
1422
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1399
1423
|
return utils.withTurnkeyErrorHandling(() => client.getActiveSessionKey(), callbacks, "Failed to get active session key");
|
|
1400
|
-
}, [client, callbacks]);
|
|
1424
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1401
1425
|
const clearUnusedKeyPairs = react.useCallback(async () => {
|
|
1402
1426
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1403
1427
|
return utils.withTurnkeyErrorHandling(() => client.clearUnusedKeyPairs(), callbacks, "Failed to clear unused key pairs");
|
|
1404
|
-
}, [client, callbacks]);
|
|
1428
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1405
1429
|
const createApiKeyPair = react.useCallback(async params => {
|
|
1406
1430
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1407
1431
|
return utils.withTurnkeyErrorHandling(() => client.createApiKeyPair(params), callbacks, "Failed to create API key pair");
|
|
1408
|
-
}, [client, callbacks]);
|
|
1432
|
+
}, [client, callbacks, session, user, masterConfig]);
|
|
1409
1433
|
const getProxyAuthConfig = react.useCallback(async () => {
|
|
1410
1434
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1411
1435
|
return utils.withTurnkeyErrorHandling(() => client.getProxyAuthConfig(), callbacks, "Failed to get proxy auth config");
|
|
1412
|
-
}, [client, callbacks]);
|
|
1436
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1413
1437
|
const refreshUser = react.useCallback(async params => {
|
|
1438
|
+
if (!masterConfig?.autoRefreshManagedState) return;
|
|
1414
1439
|
const {
|
|
1415
1440
|
stampWith
|
|
1416
1441
|
} = params || {};
|
|
@@ -1421,13 +1446,14 @@ const ClientProvider = ({
|
|
|
1421
1446
|
if (user) {
|
|
1422
1447
|
setUser(user);
|
|
1423
1448
|
}
|
|
1424
|
-
}, [client, callbacks]);
|
|
1449
|
+
}, [client, callbacks, fetchUser, masterConfig, session, user]);
|
|
1425
1450
|
const refreshWallets = react.useCallback(async params => {
|
|
1451
|
+
if (!masterConfig?.autoRefreshManagedState) return;
|
|
1426
1452
|
const {
|
|
1427
1453
|
stampWith
|
|
1428
1454
|
} = params || {};
|
|
1429
1455
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
1430
|
-
const walletProviders = await utils.withTurnkeyErrorHandling(() =>
|
|
1456
|
+
const walletProviders = await utils.withTurnkeyErrorHandling(() => fetchWalletProviders(), callbacks, "Failed to refresh wallets");
|
|
1431
1457
|
const wallets = await utils.withTurnkeyErrorHandling(() => fetchWallets({
|
|
1432
1458
|
stampWith,
|
|
1433
1459
|
walletProviders
|
|
@@ -1435,7 +1461,7 @@ const ClientProvider = ({
|
|
|
1435
1461
|
if (wallets) {
|
|
1436
1462
|
setWallets(wallets);
|
|
1437
1463
|
}
|
|
1438
|
-
}, [client, callbacks,
|
|
1464
|
+
}, [client, callbacks, fetchWalletProviders, fetchWallets, masterConfig, session, user]);
|
|
1439
1465
|
const handleDiscordOauth = react.useCallback(async params => {
|
|
1440
1466
|
const {
|
|
1441
1467
|
clientId = masterConfig?.auth?.oauthConfig?.discordClientId,
|
|
@@ -1526,6 +1552,7 @@ const ClientProvider = ({
|
|
|
1526
1552
|
authCode,
|
|
1527
1553
|
redirectUri: redirectURI,
|
|
1528
1554
|
codeVerifier: verifier,
|
|
1555
|
+
clientId,
|
|
1529
1556
|
nonce: nonce
|
|
1530
1557
|
}).then(resp => {
|
|
1531
1558
|
sessionStorage.removeItem("discord_verifier");
|
|
@@ -1573,7 +1600,7 @@ const ClientProvider = ({
|
|
|
1573
1600
|
} catch (error) {
|
|
1574
1601
|
throw error;
|
|
1575
1602
|
}
|
|
1576
|
-
}, [client, callbacks]);
|
|
1603
|
+
}, [client, callbacks, completeOauth, createApiKeyPair, masterConfig, session, user]);
|
|
1577
1604
|
const handleXOauth = react.useCallback(async params => {
|
|
1578
1605
|
const {
|
|
1579
1606
|
clientId = masterConfig?.auth?.oauthConfig?.xClientId,
|
|
@@ -1664,6 +1691,7 @@ const ClientProvider = ({
|
|
|
1664
1691
|
authCode,
|
|
1665
1692
|
redirectUri: redirectURI,
|
|
1666
1693
|
codeVerifier: verifier,
|
|
1694
|
+
clientId,
|
|
1667
1695
|
nonce
|
|
1668
1696
|
}).then(resp => {
|
|
1669
1697
|
sessionStorage.removeItem("twitter_verifier");
|
|
@@ -1711,7 +1739,7 @@ const ClientProvider = ({
|
|
|
1711
1739
|
} catch (error) {
|
|
1712
1740
|
throw error;
|
|
1713
1741
|
}
|
|
1714
|
-
}, [client, callbacks]);
|
|
1742
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1715
1743
|
const handleGoogleOauth = react.useCallback(async params => {
|
|
1716
1744
|
const {
|
|
1717
1745
|
clientId = masterConfig?.auth?.oauthConfig?.googleClientId,
|
|
@@ -1839,7 +1867,7 @@ const ClientProvider = ({
|
|
|
1839
1867
|
} catch (error) {
|
|
1840
1868
|
throw error;
|
|
1841
1869
|
}
|
|
1842
|
-
}, [client, callbacks]);
|
|
1870
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1843
1871
|
const handleAppleOauth = react.useCallback(async params => {
|
|
1844
1872
|
const {
|
|
1845
1873
|
clientId = masterConfig?.auth?.oauthConfig?.appleClientId,
|
|
@@ -1963,7 +1991,7 @@ const ClientProvider = ({
|
|
|
1963
1991
|
} catch (error) {
|
|
1964
1992
|
throw error;
|
|
1965
1993
|
}
|
|
1966
|
-
}, [client, callbacks]);
|
|
1994
|
+
}, [client, callbacks, masterConfig, session, user]);
|
|
1967
1995
|
const handleFacebookOauth = react.useCallback(async params => {
|
|
1968
1996
|
const {
|
|
1969
1997
|
clientId = masterConfig?.auth?.oauthConfig?.facebookClientId,
|
|
@@ -2105,7 +2133,7 @@ const ClientProvider = ({
|
|
|
2105
2133
|
} catch (error) {
|
|
2106
2134
|
throw error;
|
|
2107
2135
|
}
|
|
2108
|
-
}, [client, callbacks]);
|
|
2136
|
+
}, [client, callbacks, masterConfig, client, session, user]);
|
|
2109
2137
|
const handleLogin = react.useCallback(async params => {
|
|
2110
2138
|
pushPage({
|
|
2111
2139
|
key: "Log in or sign up",
|
|
@@ -2113,7 +2141,7 @@ const ClientProvider = ({
|
|
|
2113
2141
|
sessionKey: params?.sessionKey
|
|
2114
2142
|
})
|
|
2115
2143
|
});
|
|
2116
|
-
}, [pushPage]);
|
|
2144
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2117
2145
|
const handleExportWallet = react.useCallback(async params => {
|
|
2118
2146
|
const {
|
|
2119
2147
|
walletId,
|
|
@@ -2133,7 +2161,7 @@ const ClientProvider = ({
|
|
|
2133
2161
|
} : {})
|
|
2134
2162
|
})
|
|
2135
2163
|
});
|
|
2136
|
-
}, [pushPage]);
|
|
2164
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2137
2165
|
const handleExportPrivateKey = react.useCallback(async params => {
|
|
2138
2166
|
const {
|
|
2139
2167
|
privateKeyId,
|
|
@@ -2157,7 +2185,7 @@ const ClientProvider = ({
|
|
|
2157
2185
|
} : {})
|
|
2158
2186
|
})
|
|
2159
2187
|
});
|
|
2160
|
-
}, [pushPage]);
|
|
2188
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2161
2189
|
const handleExportWalletAccount = react.useCallback(async params => {
|
|
2162
2190
|
const {
|
|
2163
2191
|
address,
|
|
@@ -2181,7 +2209,7 @@ const ClientProvider = ({
|
|
|
2181
2209
|
} : {})
|
|
2182
2210
|
})
|
|
2183
2211
|
});
|
|
2184
|
-
}, [pushPage]);
|
|
2212
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2185
2213
|
const handleImportWallet = react.useCallback(async params => {
|
|
2186
2214
|
const {
|
|
2187
2215
|
defaultWalletAccounts,
|
|
@@ -2214,7 +2242,7 @@ const ClientProvider = ({
|
|
|
2214
2242
|
}
|
|
2215
2243
|
throw new sdkTypes.TurnkeyError("Failed to import wallet.", sdkTypes.TurnkeyErrorCodes.IMPORT_WALLET_ERROR, error);
|
|
2216
2244
|
}
|
|
2217
|
-
}, [pushPage]);
|
|
2245
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2218
2246
|
const handleImportPrivateKey = react.useCallback(async params => {
|
|
2219
2247
|
const {
|
|
2220
2248
|
curve,
|
|
@@ -2247,7 +2275,7 @@ const ClientProvider = ({
|
|
|
2247
2275
|
}
|
|
2248
2276
|
throw new sdkTypes.TurnkeyError("Failed to import private key.", sdkTypes.TurnkeyErrorCodes.IMPORT_WALLET_ERROR, error);
|
|
2249
2277
|
}
|
|
2250
|
-
}, [pushPage]);
|
|
2278
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2251
2279
|
const handleUpdateUserName = react.useCallback(async params => {
|
|
2252
2280
|
const {
|
|
2253
2281
|
successPageDuration = 2000,
|
|
@@ -2313,7 +2341,7 @@ const ClientProvider = ({
|
|
|
2313
2341
|
}
|
|
2314
2342
|
throw new sdkTypes.TurnkeyError("Failed to update user name.", sdkTypes.TurnkeyErrorCodes.UPDATE_USER_NAME_ERROR, error);
|
|
2315
2343
|
}
|
|
2316
|
-
}, [pushPage]);
|
|
2344
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2317
2345
|
const handleUpdateUserPhoneNumber = react.useCallback(async params => {
|
|
2318
2346
|
const {
|
|
2319
2347
|
successPageDuration = 2000,
|
|
@@ -2417,7 +2445,7 @@ const ClientProvider = ({
|
|
|
2417
2445
|
}
|
|
2418
2446
|
throw new sdkTypes.TurnkeyError("Failed to initialize OTP for sms verification.", sdkTypes.TurnkeyErrorCodes.INIT_OTP_ERROR, error);
|
|
2419
2447
|
}
|
|
2420
|
-
}, [pushPage]);
|
|
2448
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2421
2449
|
const handleUpdateUserEmail = react.useCallback(async params => {
|
|
2422
2450
|
const {
|
|
2423
2451
|
successPageDuration = 2000,
|
|
@@ -2514,14 +2542,16 @@ const ClientProvider = ({
|
|
|
2514
2542
|
}
|
|
2515
2543
|
throw new sdkTypes.TurnkeyError("Failed to initialize OTP for email verification.", sdkTypes.TurnkeyErrorCodes.INIT_OTP_ERROR, error);
|
|
2516
2544
|
}
|
|
2517
|
-
}, [pushPage]);
|
|
2545
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2518
2546
|
const handleAddEmail = react.useCallback(async params => {
|
|
2519
2547
|
const {
|
|
2520
2548
|
successPageDuration = 2000,
|
|
2521
2549
|
subTitle,
|
|
2522
2550
|
title
|
|
2523
2551
|
} = params || {};
|
|
2524
|
-
if (!client)
|
|
2552
|
+
if (!client) {
|
|
2553
|
+
throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
2554
|
+
}
|
|
2525
2555
|
if (!session) {
|
|
2526
2556
|
throw new sdkTypes.TurnkeyError("No active session found.", sdkTypes.TurnkeyErrorCodes.NO_SESSION_FOUND);
|
|
2527
2557
|
}
|
|
@@ -2611,7 +2641,7 @@ const ClientProvider = ({
|
|
|
2611
2641
|
}
|
|
2612
2642
|
throw new sdkTypes.TurnkeyError("Failed to initialize OTP for email verification.", sdkTypes.TurnkeyErrorCodes.INIT_OTP_ERROR, error);
|
|
2613
2643
|
}
|
|
2614
|
-
}, [pushPage]);
|
|
2644
|
+
}, [pushPage, client, session, user]);
|
|
2615
2645
|
const handleAddPhoneNumber = react.useCallback(async params => {
|
|
2616
2646
|
const {
|
|
2617
2647
|
successPageDuration = 2000,
|
|
@@ -2719,7 +2749,7 @@ const ClientProvider = ({
|
|
|
2719
2749
|
}
|
|
2720
2750
|
throw new sdkTypes.TurnkeyError("Failed to initialize OTP for sms verification.", sdkTypes.TurnkeyErrorCodes.INIT_OTP_ERROR, error);
|
|
2721
2751
|
}
|
|
2722
|
-
}, [pushPage]);
|
|
2752
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2723
2753
|
const handleRemovePasskey = react.useCallback(async params => {
|
|
2724
2754
|
const {
|
|
2725
2755
|
authenticatorId,
|
|
@@ -2760,7 +2790,7 @@ const ClientProvider = ({
|
|
|
2760
2790
|
preventBack: true
|
|
2761
2791
|
});
|
|
2762
2792
|
}), callbacks, "Failed to remove passkey");
|
|
2763
|
-
}, [pushPage]);
|
|
2793
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2764
2794
|
const handleAddPasskey = react.useCallback(async params => {
|
|
2765
2795
|
const {
|
|
2766
2796
|
name,
|
|
@@ -2805,7 +2835,7 @@ const ClientProvider = ({
|
|
|
2805
2835
|
}
|
|
2806
2836
|
throw new sdkTypes.TurnkeyError("Failed to add passkey in handler.", sdkTypes.TurnkeyErrorCodes.ADD_PASSKEY_ERROR, error);
|
|
2807
2837
|
}
|
|
2808
|
-
}, [pushPage]);
|
|
2838
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2809
2839
|
const handleRemoveOauthProvider = react.useCallback(async params => {
|
|
2810
2840
|
const {
|
|
2811
2841
|
providerId,
|
|
@@ -2849,7 +2879,7 @@ const ClientProvider = ({
|
|
|
2849
2879
|
}
|
|
2850
2880
|
throw new sdkTypes.TurnkeyError("Failed to remove OAuth provider in handler.", sdkTypes.TurnkeyErrorCodes.REMOVE_OAUTH_PROVIDER_ERROR, error);
|
|
2851
2881
|
}
|
|
2852
|
-
}, [pushPage]);
|
|
2882
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2853
2883
|
const handleAddOauthProvider = react.useCallback(async params => {
|
|
2854
2884
|
if (!client) throw new sdkTypes.TurnkeyError("Client is not initialized.", sdkTypes.TurnkeyErrorCodes.CLIENT_NOT_INITIALIZED);
|
|
2855
2885
|
if (!session) {
|
|
@@ -2924,7 +2954,7 @@ const ClientProvider = ({
|
|
|
2924
2954
|
throw new sdkTypes.TurnkeyError(`Unsupported OAuth provider: ${providerName}`, sdkTypes.TurnkeyErrorCodes.NOT_FOUND);
|
|
2925
2955
|
}
|
|
2926
2956
|
}
|
|
2927
|
-
}, [pushPage]);
|
|
2957
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2928
2958
|
const handleConnectExternalWallet = react.useCallback(async params => {
|
|
2929
2959
|
const {
|
|
2930
2960
|
successPageDuration = 2000
|
|
@@ -2936,7 +2966,7 @@ const ClientProvider = ({
|
|
|
2936
2966
|
if (!masterConfig?.walletConfig?.features?.connecting) {
|
|
2937
2967
|
throw new sdkTypes.TurnkeyError("Wallet connecting is not enabled.", sdkTypes.TurnkeyErrorCodes.FEATURE_NOT_ENABLED);
|
|
2938
2968
|
}
|
|
2939
|
-
const providers = await
|
|
2969
|
+
const providers = await fetchWalletProviders();
|
|
2940
2970
|
pushPage({
|
|
2941
2971
|
key: "Connect wallet",
|
|
2942
2972
|
content: jsxRuntime.jsx(ConnectWallet.ConnectWalletModal, {
|
|
@@ -2944,7 +2974,7 @@ const ClientProvider = ({
|
|
|
2944
2974
|
successPageDuration: successPageDuration
|
|
2945
2975
|
})
|
|
2946
2976
|
});
|
|
2947
|
-
}, [pushPage]);
|
|
2977
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2948
2978
|
const handleRemoveUserEmail = react.useCallback(async params => {
|
|
2949
2979
|
const {
|
|
2950
2980
|
successPageDuration = 2000,
|
|
@@ -2983,7 +3013,7 @@ const ClientProvider = ({
|
|
|
2983
3013
|
}
|
|
2984
3014
|
throw new sdkTypes.TurnkeyError("Failed to remove user email.", sdkTypes.TurnkeyErrorCodes.UPDATE_USER_EMAIL_ERROR, error);
|
|
2985
3015
|
}
|
|
2986
|
-
}, [pushPage]);
|
|
3016
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
2987
3017
|
const handleRemoveUserPhoneNumber = react.useCallback(async params => {
|
|
2988
3018
|
const {
|
|
2989
3019
|
successPageDuration = 2000,
|
|
@@ -3022,7 +3052,7 @@ const ClientProvider = ({
|
|
|
3022
3052
|
}
|
|
3023
3053
|
throw new sdkTypes.TurnkeyError("Failed to remove user phone number.", sdkTypes.TurnkeyErrorCodes.UPDATE_USER_PHONE_NUMBER_ERROR, error);
|
|
3024
3054
|
}
|
|
3025
|
-
}, [pushPage]);
|
|
3055
|
+
}, [pushPage, masterConfig, client, session, user]);
|
|
3026
3056
|
react.useEffect(() => {
|
|
3027
3057
|
if (proxyAuthConfigRef.current) return;
|
|
3028
3058
|
// Only fetch the proxy auth config once. Use that to build the master config.
|
|
@@ -3121,7 +3151,7 @@ const ClientProvider = ({
|
|
|
3121
3151
|
logout,
|
|
3122
3152
|
loginWithPasskey,
|
|
3123
3153
|
signUpWithPasskey,
|
|
3124
|
-
|
|
3154
|
+
fetchWalletProviders,
|
|
3125
3155
|
connectWalletAccount,
|
|
3126
3156
|
disconnectWalletAccount,
|
|
3127
3157
|
switchWalletAccountChain,
|
|
@@ -3144,6 +3174,8 @@ const ClientProvider = ({
|
|
|
3144
3174
|
signTransaction,
|
|
3145
3175
|
signAndSendTransaction,
|
|
3146
3176
|
fetchUser,
|
|
3177
|
+
fetchOrCreateP256ApiKeyUser,
|
|
3178
|
+
fetchOrCreatePolicies,
|
|
3147
3179
|
refreshUser,
|
|
3148
3180
|
updateUserEmail,
|
|
3149
3181
|
removeUserEmail,
|