@turnkey/sdk-react 5.0.0 → 5.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 +12 -0
- package/dist/components/auth/Apple.d.ts +0 -1
- package/dist/components/auth/Apple.d.ts.map +1 -1
- package/dist/components/auth/Apple.js +62 -48
- package/dist/components/auth/Apple.js.map +1 -1
- package/dist/components/auth/Apple.mjs +104 -53
- package/dist/components/auth/Apple.mjs.map +1 -1
- package/dist/components/auth/Auth.d.ts.map +1 -1
- package/dist/components/auth/Auth.js +18 -19
- package/dist/components/auth/Auth.js.map +1 -1
- package/dist/components/auth/Auth.mjs +135 -137
- package/dist/components/auth/Auth.mjs.map +1 -1
- package/dist/components/auth/Facebook.d.ts +0 -1
- package/dist/components/auth/Facebook.d.ts.map +1 -1
- package/dist/components/auth/Facebook.js +80 -44
- package/dist/components/auth/Facebook.js.map +1 -1
- package/dist/components/auth/Facebook.mjs +155 -104
- package/dist/components/auth/Facebook.mjs.map +1 -1
- package/dist/components/auth/Google.d.ts +0 -1
- package/dist/components/auth/Google.d.ts.map +1 -1
- package/dist/components/auth/Google.js +70 -52
- package/dist/components/auth/Google.js.map +1 -1
- package/dist/components/auth/Google.mjs +116 -80
- package/dist/components/auth/Google.mjs.map +1 -1
- package/dist/components/auth/OtpVerification.d.ts.map +1 -1
- package/dist/components/auth/OtpVerification.js +1 -0
- package/dist/components/auth/OtpVerification.js.map +1 -1
- package/dist/components/auth/OtpVerification.mjs +30 -27
- package/dist/components/auth/OtpVerification.mjs.map +1 -1
- package/dist/components/auth/constants.js +1 -1
- package/dist/components/auth/constants.js.map +1 -1
- package/dist/components/auth/constants.mjs +1 -1
- package/dist/components/auth/constants.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -79,7 +79,6 @@ const Auth = ({
|
|
|
79
79
|
indexedDbClient,
|
|
80
80
|
turnkey: turnkey$1
|
|
81
81
|
} = useTurnkey.useTurnkey();
|
|
82
|
-
const [publicKey, setPublicKey] = React.useState("");
|
|
83
82
|
const [email, setEmail] = React.useState("");
|
|
84
83
|
const [phone, setPhone] = React.useState("");
|
|
85
84
|
const [otpId, setOtpId] = React.useState(null);
|
|
@@ -99,22 +98,18 @@ const Auth = ({
|
|
|
99
98
|
}
|
|
100
99
|
};
|
|
101
100
|
React.useEffect(() => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const publicKey = await indexedDbClient.getPublicKey();
|
|
108
|
-
setPublicKey(publicKey);
|
|
101
|
+
const manageClient = async () => {
|
|
102
|
+
if (indexedDbClient && turnkey$1) {
|
|
103
|
+
const retrievedPublicKey = await indexedDbClient.getPublicKey();
|
|
104
|
+
if (retrievedPublicKey) {
|
|
105
|
+
setComponentReady(true);
|
|
109
106
|
} else {
|
|
110
|
-
|
|
111
|
-
const publicKey = await indexedDbClient.getPublicKey();
|
|
112
|
-
setPublicKey(publicKey);
|
|
107
|
+
onError("Failed to retrieve public key.");
|
|
113
108
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, [indexedDbClient]);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
manageClient();
|
|
112
|
+
}, [indexedDbClient, turnkey$1]);
|
|
118
113
|
if (!componentReady) {
|
|
119
114
|
return jsxRuntime.jsx("div", {
|
|
120
115
|
className: Auth_module.default.defaultLoader,
|
|
@@ -176,6 +171,7 @@ const Auth = ({
|
|
|
176
171
|
constants.authErrors.passkey.createFailed;
|
|
177
172
|
}
|
|
178
173
|
}
|
|
174
|
+
await indexedDbClient.resetKeyPair();
|
|
179
175
|
const pubKey = await indexedDbClient.getPublicKey();
|
|
180
176
|
await passkeyClient?.loginWithPasskey({
|
|
181
177
|
sessionType: exports.SessionType.READ_WRITE,
|
|
@@ -191,6 +187,7 @@ const Auth = ({
|
|
|
191
187
|
const handleLoginWithPasskey = async () => {
|
|
192
188
|
try {
|
|
193
189
|
setLoading("passkey");
|
|
190
|
+
await indexedDbClient?.resetKeyPair();
|
|
194
191
|
const pubKey = await indexedDbClient.getPublicKey();
|
|
195
192
|
await passkeyClient?.loginWithPasskey({
|
|
196
193
|
sessionType: exports.SessionType.READ_WRITE,
|
|
@@ -234,6 +231,10 @@ const Auth = ({
|
|
|
234
231
|
setLoading(undefined);
|
|
235
232
|
};
|
|
236
233
|
const handleOAuthLogin = async (credential, providerName) => {
|
|
234
|
+
const pubKey = await indexedDbClient?.getPublicKey();
|
|
235
|
+
if (!pubKey) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
237
238
|
setOauthLoading(providerName);
|
|
238
239
|
const createSuborgData = {
|
|
239
240
|
oauthProviders: [{
|
|
@@ -258,7 +259,7 @@ const Auth = ({
|
|
|
258
259
|
const sessionResponse = await sdkServer.server.oauthLogin({
|
|
259
260
|
suborgID: suborgId,
|
|
260
261
|
oidcToken: credential,
|
|
261
|
-
publicKey:
|
|
262
|
+
publicKey: pubKey,
|
|
262
263
|
sessionLengthSeconds: authConfig.sessionLengthSeconds
|
|
263
264
|
});
|
|
264
265
|
if (sessionResponse && sessionResponse.session) {
|
|
@@ -296,6 +297,7 @@ const Auth = ({
|
|
|
296
297
|
onError(constants.authErrors.wallet.loginFailed);
|
|
297
298
|
return;
|
|
298
299
|
}
|
|
300
|
+
await indexedDbClient.resetKeyPair();
|
|
299
301
|
const pubKey = await indexedDbClient.getPublicKey();
|
|
300
302
|
await walletClient.loginWithWallet({
|
|
301
303
|
sessionType: exports.SessionType.READ_WRITE,
|
|
@@ -343,18 +345,15 @@ const Auth = ({
|
|
|
343
345
|
layout: layout,
|
|
344
346
|
clientId: authConfig.googleClientId ?? process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID,
|
|
345
347
|
openInPage: authConfig.openOAuthInPage,
|
|
346
|
-
publicKey: publicKey,
|
|
347
348
|
onSuccess: response => handleOAuthLogin(response.idToken, "Google")
|
|
348
349
|
}), appleEnabled && jsxRuntime.jsx(Apple.default, {
|
|
349
350
|
layout: layout,
|
|
350
351
|
clientId: authConfig.appleClientId ?? process.env.NEXT_PUBLIC_APPLE_CLIENT_ID,
|
|
351
|
-
publicKey: publicKey,
|
|
352
352
|
openInPage: authConfig.openOAuthInPage,
|
|
353
353
|
onSuccess: response => handleOAuthLogin(response.idToken, "Apple")
|
|
354
354
|
}), facebookEnabled && jsxRuntime.jsx(Facebook.default, {
|
|
355
355
|
layout: layout,
|
|
356
356
|
clientId: authConfig.facebookClientId ?? process.env.NEXT_PUBLIC_FACEBOOK_CLIENT_ID,
|
|
357
|
-
publicKey: publicKey,
|
|
358
357
|
openInPage: authConfig.openOAuthInPage,
|
|
359
358
|
onSuccess: response => handleOAuthLogin(response.id_token, "Facebook")
|
|
360
359
|
})]
|