@turnkey/sdk-react 3.0.6 → 3.1.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/CHANGELOG.md +14 -0
- 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 +66 -0
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +109 -0
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/constants.d.ts +6 -1
- package/dist/components/auth/constants.d.ts.map +1 -1
- package/dist/components/auth/constants.js +6 -0
- package/dist/components/auth/constants.js.map +1 -1
- package/dist/components/auth/constants.mjs +6 -0
- package/dist/components/auth/constants.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @turnkey/sdk-react
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9317588: Adds wallet as an authentication option in the Embedded Wallet Kit components for sdk-react
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [233ae71]
|
|
12
|
+
- Updated dependencies [9317588]
|
|
13
|
+
- @turnkey/sdk-browser@1.16.0
|
|
14
|
+
- @turnkey/sdk-server@2.4.0
|
|
15
|
+
- @turnkey/crypto@2.3.1
|
|
16
|
+
|
|
3
17
|
## 3.0.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../../src/components/auth/Auth.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../../src/components/auth/Auth.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAcnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAsC1D,UAAU,SAAS;IACjB,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,UAAU,EAAE;QACV,YAAY,EAAE,OAAO,CAAC;QACtB,cAAc,EAAE,OAAO,CAAC;QACxB,YAAY,EAAE,OAAO,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;QACtB,eAAe,EAAE,OAAO,CAAC;QACzB,aAAa,EAAE,OAAO,CAAC;QACvB,aAAa,EAAE,OAAO,CAAC;QACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,QAAA,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAwpB7B,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -65,6 +65,7 @@ const Auth = ({
|
|
|
65
65
|
const {
|
|
66
66
|
passkeyClient,
|
|
67
67
|
authIframeClient,
|
|
68
|
+
walletClient,
|
|
68
69
|
turnkey: turnkey$1
|
|
69
70
|
} = useTurnkey.useTurnkey();
|
|
70
71
|
const [email, setEmail] = React.useState("");
|
|
@@ -78,6 +79,7 @@ const Auth = ({
|
|
|
78
79
|
const [passkeySignupError, setPasskeySignupError] = React.useState("");
|
|
79
80
|
const [loading, setLoading] = React.useState(true);
|
|
80
81
|
const [passkeyCreated, setPasskeyCreated] = React.useState(false);
|
|
82
|
+
const [walletLoading, setWalletLoading] = React.useState(false);
|
|
81
83
|
const handleResendCode = async () => {
|
|
82
84
|
if (step === constants.OtpType.Email) {
|
|
83
85
|
await handleOtpLogin(constants.FilterType.Email, email, constants.OtpType.Email);
|
|
@@ -260,6 +262,55 @@ const Auth = ({
|
|
|
260
262
|
onError(constants.authErrors.oauth.loginFailed);
|
|
261
263
|
}
|
|
262
264
|
};
|
|
265
|
+
const handleLoginWithWallet = async () => {
|
|
266
|
+
setWalletLoading(true);
|
|
267
|
+
try {
|
|
268
|
+
if (!walletClient) {
|
|
269
|
+
throw new Error("Wallet client not initialized");
|
|
270
|
+
}
|
|
271
|
+
const publicKey = await walletClient.getPublicKey();
|
|
272
|
+
if (!publicKey) {
|
|
273
|
+
throw new Error(constants.authErrors.wallet.noPublicKey);
|
|
274
|
+
}
|
|
275
|
+
const {
|
|
276
|
+
type
|
|
277
|
+
} = walletClient.getWalletInterface();
|
|
278
|
+
const resp = await sdkServer.server.getOrCreateSuborg({
|
|
279
|
+
filterType: constants.FilterType.PublicKey,
|
|
280
|
+
filterValue: publicKey,
|
|
281
|
+
additionalData: {
|
|
282
|
+
wallet: {
|
|
283
|
+
publicKey,
|
|
284
|
+
type
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
const suborgIds = resp?.subOrganizationIds;
|
|
289
|
+
if (!suborgIds || suborgIds.length === 0) {
|
|
290
|
+
onError(constants.authErrors.wallet.loginFailed);
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const suborgId = suborgIds[0];
|
|
294
|
+
const sessionResponse = await walletClient.createReadWriteSession({
|
|
295
|
+
targetPublicKey: authIframeClient?.iframePublicKey,
|
|
296
|
+
...(suborgId && {
|
|
297
|
+
organizationId: suborgId
|
|
298
|
+
}),
|
|
299
|
+
...(authConfig.sessionLengthSeconds !== undefined && {
|
|
300
|
+
expirationSeconds: authConfig.sessionLengthSeconds.toString()
|
|
301
|
+
})
|
|
302
|
+
});
|
|
303
|
+
if (sessionResponse?.credentialBundle) {
|
|
304
|
+
await handleAuthSuccess(sessionResponse.credentialBundle, authConfig.sessionLengthSeconds?.toString());
|
|
305
|
+
} else {
|
|
306
|
+
throw new Error(constants.authErrors.wallet.loginFailed);
|
|
307
|
+
}
|
|
308
|
+
} catch (error) {
|
|
309
|
+
onError(error.message || constants.authErrors.wallet.loginFailed);
|
|
310
|
+
} finally {
|
|
311
|
+
setWalletLoading(false);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
263
314
|
const renderBackButton = () => jsxRuntime.jsx(ChevronLeftIcon, {
|
|
264
315
|
onClick: () => {
|
|
265
316
|
setPasskeyCreationScreen(false);
|
|
@@ -385,6 +436,21 @@ const Auth = ({
|
|
|
385
436
|
children: "Sign up with passkey"
|
|
386
437
|
})]
|
|
387
438
|
}) : null;
|
|
439
|
+
case "wallet":
|
|
440
|
+
return authConfig.walletEnabled && !otpId ? jsxRuntime.jsx("div", {
|
|
441
|
+
className: Auth_module.passkeyContainer,
|
|
442
|
+
children: jsxRuntime.jsx("button", {
|
|
443
|
+
className: Auth_module.authButton,
|
|
444
|
+
type: "button",
|
|
445
|
+
onClick: handleLoginWithWallet,
|
|
446
|
+
disabled: walletLoading,
|
|
447
|
+
children: walletLoading ? jsxRuntime.jsx(material.CircularProgress, {
|
|
448
|
+
size: 24,
|
|
449
|
+
thickness: 4,
|
|
450
|
+
className: Auth_module.buttonProgress || ""
|
|
451
|
+
}) : "Continue with Wallet"
|
|
452
|
+
})
|
|
453
|
+
}) : null;
|
|
388
454
|
case "socials":
|
|
389
455
|
return authConfig.googleEnabled || authConfig.appleEnabled || authConfig.facebookEnabled ? renderSocialButtons() : null;
|
|
390
456
|
default:
|