Skip to content

Commit 77b3b96

Browse files
committed
Merge pull-request #485
2 parents 511dab7 + 1ebd4e2 commit 77b3b96

File tree

18 files changed

+470
-348
lines changed

18 files changed

+470
-348
lines changed

.changeset/loud-bulldogs-hide.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@turnkey/sdk-react": major
3+
---
4+
5+
Remove references to server actions and import from sdk-server

.changeset/orange-carrots-sparkle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@turnkey/sdk-server": major
3+
---
4+
5+
Add server actions

examples/react-components/src/app/dashboard/page.tsx

+18-20
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import {
44
Export,
55
Import,
66
useTurnkey,
7-
getSuborgs,
8-
getVerifiedSuborgs,
97
OtpVerification,
108
OtpType,
11-
initOtpAuth,
129
} from "@turnkey/sdk-react";
10+
import { server } from "@turnkey/sdk-server";
1311
import { useEffect, useState } from "react";
1412
import "./dashboard.css";
1513
import {
@@ -84,31 +82,31 @@ export default function Dashboard() {
8482
toast.success("Wallet successfully imported");
8583
};
8684
const handleResendEmail = async () => {
87-
const initAuthResponse = await initOtpAuth({
85+
const sendOtpResponse = await server.sendOtp({
8886
suborgID: suborgId,
8987
otpType: OtpType.Email,
9088
contact: emailInput,
9189
userIdentifier: authIframeClient?.iframePublicKey!,
9290
});
93-
if (!initAuthResponse || !initAuthResponse.otpId!) {
91+
if (!sendOtpResponse || !sendOtpResponse.otpId!) {
9492
toast.error("Failed to send OTP");
9593
return;
9694
}
97-
setOtpId(initAuthResponse?.otpId!);
95+
setOtpId(sendOtpResponse?.otpId!);
9896
};
9997
const handleResendSms = async () => {
100-
const initAuthResponse = await initOtpAuth({
98+
const sendOtpResponse = await server.sendOtp({
10199
suborgID: suborgId,
102100
otpType: OtpType.Sms,
103101
contact: phoneInput,
104102
customSmsMessage: "Your Turnkey Demo OTP is {{.OtpCode}}",
105103
userIdentifier: authIframeClient?.iframePublicKey!,
106104
});
107-
if (!initAuthResponse || !initAuthResponse.otpId!) {
105+
if (!sendOtpResponse || !sendOtpResponse.otpId!) {
108106
toast.error("Failed to send OTP");
109107
return;
110108
}
111-
setOtpId(initAuthResponse?.otpId!);
109+
setOtpId(sendOtpResponse?.otpId!);
112110
};
113111

114112
const handleOtpSuccess = async (credentialBundle: any) => {
@@ -125,7 +123,7 @@ export default function Dashboard() {
125123
toast.error("Please enter a valid email address");
126124
return;
127125
}
128-
const suborgs = await getVerifiedSuborgs({
126+
const suborgs = await server.getVerifiedSuborgs({
129127
filterType: "EMAIL",
130128
filterValue: emailInput,
131129
});
@@ -139,17 +137,17 @@ export default function Dashboard() {
139137
userEmail: emailInput,
140138
userTagIds: [],
141139
});
142-
const initAuthResponse = await initOtpAuth({
140+
const sendOtpResponse = await server.sendOtp({
143141
suborgID: suborgId,
144142
otpType: OtpType.Email,
145143
contact: emailInput,
146144
userIdentifier: authIframeClient?.iframePublicKey!,
147145
});
148-
if (!initAuthResponse || !initAuthResponse.otpId!) {
146+
if (!sendOtpResponse || !sendOtpResponse.otpId!) {
149147
toast.error("Failed to send OTP");
150148
return;
151149
}
152-
setOtpId(initAuthResponse?.otpId!);
150+
setOtpId(sendOtpResponse?.otpId!);
153151
setIsEmailModalOpen(false);
154152
setIsOtpModalOpen(true);
155153
};
@@ -159,7 +157,7 @@ export default function Dashboard() {
159157
toast.error("Please enter a valid phone number.");
160158
return;
161159
}
162-
const suborgs = await getVerifiedSuborgs({
160+
const suborgs = await server.getVerifiedSuborgs({
163161
filterType: "PHONE_NUMBER",
164162
filterValue: phoneInput,
165163
});
@@ -173,18 +171,18 @@ export default function Dashboard() {
173171
userPhoneNumber: phoneInput,
174172
userTagIds: [],
175173
});
176-
const initAuthResponse = await initOtpAuth({
174+
const sendOtpResponse = await server.sendOtp({
177175
suborgID: suborgId,
178176
otpType: OtpType.Sms,
179177
contact: phoneInput,
180178
customSmsMessage: "Your Turnkey Demo OTP is {{.OtpCode}}",
181179
userIdentifier: authIframeClient?.iframePublicKey!,
182180
});
183-
if (!initAuthResponse || !initAuthResponse.otpId!) {
181+
if (!sendOtpResponse || !sendOtpResponse.otpId!) {
184182
toast.error("Failed to send OTP");
185183
return;
186184
}
187-
setOtpId(initAuthResponse?.otpId!);
185+
setOtpId(sendOtpResponse?.otpId!);
188186
setIsEmailModalOpen(false);
189187
setIsOtpModalOpen(true);
190188
};
@@ -223,7 +221,7 @@ export default function Dashboard() {
223221
console.error(`Unknown OAuth type: ${oauthType}`);
224222
}
225223
if (oidcToken) {
226-
const suborgs = await getSuborgs({
224+
const suborgs = await server.getSuborgs({
227225
filterType: "OIDC_TOKEN",
228226
filterValue: oidcToken.idToken,
229227
});
@@ -323,7 +321,7 @@ export default function Dashboard() {
323321
});
324322
setWallets(walletsResponse.wallets);
325323
if (userResponse.user.userEmail) {
326-
const suborgs = await getVerifiedSuborgs({
324+
const suborgs = await server.getVerifiedSuborgs({
327325
filterType: "EMAIL",
328326
filterValue: userResponse.user.userEmail,
329327
});
@@ -337,7 +335,7 @@ export default function Dashboard() {
337335
}
338336
}
339337
if (userResponse.user.userPhoneNumber) {
340-
const suborgs = await getVerifiedSuborgs({
338+
const suborgs = await server.getVerifiedSuborgs({
341339
filterType: "PHONE_NUMBER",
342340
filterValue: userResponse.user.userPhoneNumber,
343341
});

packages/sdk-react/src/actions/createSuborg.ts

-79
This file was deleted.

packages/sdk-react/src/actions/getSuborgs.ts

-38
This file was deleted.

packages/sdk-react/src/actions/getVerifiedSuborgs.ts

-38
This file was deleted.

packages/sdk-react/src/actions/index.ts

-8
This file was deleted.

packages/sdk-react/src/actions/initOtpAuth.ts

-51
This file was deleted.

0 commit comments

Comments
 (0)