Skip to content

Commit 7d82778

Browse files
committed
fix(clerk-js,shared): Do not expect phoneNumber for sendPhoneCode
1 parent 6fb0c85 commit 7d82778

3 files changed

Lines changed: 26 additions & 34 deletions

File tree

.changeset/every-terms-care.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/shared': patch
4+
---
5+
6+
Fix issue where `signUp.verifications.sendPhoneCode()` expected to be provided a `phoneNumber`.

packages/clerk-js/src/core/resources/SignUp.ts

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,26 @@ class SignUpFuture implements SignUpFutureResource {
905905
});
906906
}
907907

908+
async sendPhoneCode(params: SignUpFuturePhoneCodeSendParams): Promise<{ error: ClerkError | null }> {
909+
const { channel = 'sms' } = params;
910+
return runAsyncResourceTask(this.#resource, async () => {
911+
await this.#resource.__internal_basePost({
912+
body: { strategy: 'phone_code', channel },
913+
action: 'prepare_verification',
914+
});
915+
});
916+
}
917+
918+
async verifyPhoneCode(params: SignUpFuturePhoneCodeVerifyParams): Promise<{ error: ClerkError | null }> {
919+
const { code } = params;
920+
return runAsyncResourceTask(this.#resource, async () => {
921+
await this.#resource.__internal_basePost({
922+
body: { strategy: 'phone_code', code },
923+
action: 'attempt_verification',
924+
});
925+
});
926+
}
927+
908928
async sendEmailLink(params: SignUpFutureEmailLinkSendParams): Promise<{ error: ClerkError | null }> {
909929
const { verificationUrl } = params;
910930
return runAsyncResourceTask(this.#resource, async () => {
@@ -945,34 +965,6 @@ class SignUpFuture implements SignUpFutureResource {
945965
});
946966
}
947967

948-
async sendPhoneCode(params: SignUpFuturePhoneCodeSendParams): Promise<{ error: ClerkError | null }> {
949-
const { phoneNumber, channel = 'sms' } = params;
950-
return runAsyncResourceTask(this.#resource, async () => {
951-
if (!this.#resource.id) {
952-
const { captchaToken, captchaWidgetType, captchaError } = await this.getCaptchaToken();
953-
await this.#resource.__internal_basePost({
954-
path: this.#resource.pathRoot,
955-
body: { phoneNumber, captchaToken, captchaWidgetType, captchaError },
956-
});
957-
}
958-
959-
await this.#resource.__internal_basePost({
960-
body: { strategy: 'phone_code', channel },
961-
action: 'prepare_verification',
962-
});
963-
});
964-
}
965-
966-
async verifyPhoneCode(params: SignUpFuturePhoneCodeVerifyParams): Promise<{ error: ClerkError | null }> {
967-
const { code } = params;
968-
return runAsyncResourceTask(this.#resource, async () => {
969-
await this.#resource.__internal_basePost({
970-
body: { strategy: 'phone_code', code },
971-
action: 'attempt_verification',
972-
});
973-
});
974-
}
975-
976968
async sso(params: SignUpFutureSSOParams): Promise<{ error: ClerkError | null }> {
977969
const {
978970
strategy,

packages/shared/src/types/signUpFuture.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,6 @@ export type SignUpFuturePasswordParams = SignUpFutureAdditionalParams & {
178178
);
179179

180180
export interface SignUpFuturePhoneCodeSendParams {
181-
/**
182-
* The user's phone number in [E.164 format](https://en.wikipedia.org/wiki/E.164). Only supported if
183-
* [phone number](https://clerk.com/docs/guides/configure/auth-strategies/sign-up-sign-in-options#phone) is enabled.
184-
* Keep in mind that the phone number requires an extra verification process.
185-
*/
186-
phoneNumber?: string;
187181
/**
188182
* The mechanism to use to send the code to the provided phone number. Defaults to `'sms'`.
189183
*/

0 commit comments

Comments
 (0)