From 9f376ff1f122c0f70559cf4f57813b9f2b608f3e Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 20 May 2025 19:27:13 +0300 Subject: [PATCH] fix(js-sdk): allow passing custom request body parameters in auth.register method (#12545) The `auth.login` method of the JS SDK allows passing custom, which is useful for custom authentication providers. For example: ```ts const response = await sdk.auth.login("customer", "phone-auth", { phone }) ``` However, the `auth.register` method doesn't allow that, so we can't do the following: ```ts const response = await sdk.auth.register("customer", "phone-auth", { phone }) ``` Instead, we'd have to use the `client.fetch` method. This PR fixes the input type of the payload passed to the `register` method to be similar to that of `login`, which would allow using it with custom authentication providers --- .changeset/beige-carrots-care.md | 5 +++++ packages/core/js-sdk/src/auth/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/beige-carrots-care.md diff --git a/.changeset/beige-carrots-care.md b/.changeset/beige-carrots-care.md new file mode 100644 index 0000000000..fbb2d6a1f1 --- /dev/null +++ b/.changeset/beige-carrots-care.md @@ -0,0 +1,5 @@ +--- +"@medusajs/js-sdk": patch +--- + +fix(js-sdk): allow passing custom request body parameters in auth.register method diff --git a/packages/core/js-sdk/src/auth/index.ts b/packages/core/js-sdk/src/auth/index.ts index a6c6378876..70a7a179ad 100644 --- a/packages/core/js-sdk/src/auth/index.ts +++ b/packages/core/js-sdk/src/auth/index.ts @@ -48,7 +48,7 @@ export class Auth { register = async ( actor: string, method: string, - payload: HttpTypes.AdminSignUpWithEmailPassword + payload: HttpTypes.AdminSignUpWithEmailPassword | Record ) => { const { token } = await this.client.fetch<{ token: string }>( `/auth/${actor}/${method}/register`,