Skip to content

Commit c571d11

Browse files
authored
fix(clerk-js,types): Update signUp.password to allow for emailAddress and phoneNumber params (#6698)
1 parent e586dff commit c571d11

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

.changeset/tiny-spoons-unite.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,6 @@ class SignUpFuture implements SignUpFutureResource {
595595
}
596596

597597
async password(params: SignUpFuturePasswordParams): Promise<{ error: unknown }> {
598-
if ([params.emailAddress, params.phoneNumber].filter(Boolean).length > 1) {
599-
throw new Error('Only one of emailAddress or phoneNumber can be provided');
600-
}
601-
602598
return runAsyncResourceTask(this.resource, async () => {
603599
const { captchaToken, captchaWidgetType, captchaError } = await this.getCaptchaToken();
604600

@@ -618,6 +614,10 @@ class SignUpFuture implements SignUpFutureResource {
618614
body.emailAddress = params.emailAddress;
619615
}
620616

617+
if (params.username) {
618+
body.username = params.username;
619+
}
620+
621621
await this.resource.__internal_basePost({ path: this.resource.pathRoot, body });
622622
});
623623
}

packages/types/src/signUpFuture.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ export interface SignUpFutureEmailCodeVerifyParams {
1010
code: string;
1111
}
1212

13-
export type SignUpFuturePasswordParams =
14-
| {
15-
emailAddress: string;
16-
password: string;
17-
phoneNumber?: never;
18-
}
19-
| {
20-
phoneNumber: string;
21-
password: string;
22-
emailAddress?: never;
23-
};
13+
export type SignUpFuturePasswordParams = {
14+
password: string;
15+
} & (
16+
| { emailAddress: string; phoneNumber?: string; username?: string }
17+
| { emailAddress?: string; phoneNumber: string; username?: string }
18+
| { emailAddress?: string; phoneNumber?: string; username: string }
19+
);
2420

2521
export interface SignUpFuturePhoneCodeSendParams {
2622
phoneNumber?: string;

0 commit comments

Comments
 (0)