fix(js-sdk): add metadata parameter to request body type of reset-password route (#14458)
* fix(js-sdk): add metadata parameter to request body type * update changeset
This commit is contained in:
1 parent
0ffd790109
commit
ab7b04dbc9
2 files changed
+37
-26
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/js-sdk": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(js-sdk): add metadata parameter to request body type of reset-password route
|
||||||
@@ -14,11 +14,11 @@ export class Auth {
|
|||||||
/**
|
/**
|
||||||
* This method is used to retrieve a registration JWT token for a user, customer, or custom actor type. It sends a request to the
|
* This method is used to retrieve a registration JWT token for a user, customer, or custom actor type. It sends a request to the
|
||||||
* [Retrieve Registration Token API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_provider_register).
|
* [Retrieve Registration Token API route](https://docs.medusajs.com/api/store#auth_postactor_typeauth_provider_register).
|
||||||
*
|
*
|
||||||
* Then, it stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
* Then, it stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
||||||
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) method,
|
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) method,
|
||||||
* for example, after calling this method.
|
* for example, after calling this method.
|
||||||
*
|
*
|
||||||
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
||||||
*
|
*
|
||||||
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
||||||
@@ -38,7 +38,7 @@ export class Auth {
|
|||||||
* password: "supersecret"
|
* password: "supersecret"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* // all subsequent requests will use the token in the header
|
* // all subsequent requests will use the token in the header
|
||||||
* const { customer } = await sdk.store.customer.create({
|
* const { customer } = await sdk.store.customer.create({
|
||||||
* email: "customer@gmail.com",
|
* email: "customer@gmail.com",
|
||||||
@@ -66,32 +66,32 @@ export class Auth {
|
|||||||
/**
|
/**
|
||||||
* This method retrieves the JWT authenticated token for an admin user, customer, or custom
|
* This method retrieves the JWT authenticated token for an admin user, customer, or custom
|
||||||
* actor type. It sends a request to the [Authenticate API Route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_provider).
|
* actor type. It sends a request to the [Authenticate API Route](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_provider).
|
||||||
*
|
*
|
||||||
* ### Third-Party Authentication
|
* ### Third-Party Authentication
|
||||||
*
|
*
|
||||||
* If the API route returns a `location` property, it means that the authentication requires additional steps,
|
* If the API route returns a `location` property, it means that the authentication requires additional steps,
|
||||||
* typically in a third-party service. The `location` property is returned so that you
|
* typically in a third-party service. The `location` property is returned so that you
|
||||||
* can redirect the user to the appropriate page.
|
* can redirect the user to the appropriate page.
|
||||||
*
|
*
|
||||||
* :::note
|
* :::note
|
||||||
*
|
*
|
||||||
* For an example of implementing third-party authentication, refer to the
|
* For an example of implementing third-party authentication, refer to the
|
||||||
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
||||||
*
|
*
|
||||||
* :::
|
* :::
|
||||||
*
|
*
|
||||||
* ### Session Authentication
|
* ### Session Authentication
|
||||||
*
|
*
|
||||||
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
||||||
* [Set Authentication Session API route](https://docs.medusajs.com/api/admin#auth_postsession).
|
* [Set Authentication Session API route](https://docs.medusajs.com/api/admin#auth_postsession).
|
||||||
*
|
*
|
||||||
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
||||||
*
|
*
|
||||||
* ### Automatic Authentication
|
* ### Automatic Authentication
|
||||||
*
|
*
|
||||||
* If the authentication was successful, subsequent requests using the SDK will automatically have the necessary authentication headers / session
|
* If the authentication was successful, subsequent requests using the SDK will automatically have the necessary authentication headers / session
|
||||||
* set, based on your JS SDK authentication configurations.
|
* set, based on your JS SDK authentication configurations.
|
||||||
*
|
*
|
||||||
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
||||||
*
|
*
|
||||||
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
||||||
@@ -111,14 +111,14 @@ export class Auth {
|
|||||||
* password: "supersecret"
|
* password: "supersecret"
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* if (typeof result !== "string") {
|
* if (typeof result !== "string") {
|
||||||
* alert("Authentication requires additional steps")
|
* alert("Authentication requires additional steps")
|
||||||
* // replace with the redirect logic of your application
|
* // replace with the redirect logic of your application
|
||||||
* window.location.href = result.location
|
* window.location.href = result.location
|
||||||
* return
|
* return
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* // customer is now authenticated
|
* // customer is now authenticated
|
||||||
* // all subsequent requests will use the token in the header
|
* // all subsequent requests will use the token in the header
|
||||||
* const { customer } = await sdk.store.customer.retrieve()
|
* const { customer } = await sdk.store.customer.retrieve()
|
||||||
@@ -150,11 +150,11 @@ export class Auth {
|
|||||||
/**
|
/**
|
||||||
* This method is used to validate an Oauth callback from a third-party service, such as Google, for an admin user, customer, or custom actor types.
|
* This method is used to validate an Oauth callback from a third-party service, such as Google, for an admin user, customer, or custom actor types.
|
||||||
* It sends a request to the [Validate Authentication Callback](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_providercallback).
|
* It sends a request to the [Validate Authentication Callback](https://docs.medusajs.com/api/admin#auth_postactor_typeauth_providercallback).
|
||||||
*
|
*
|
||||||
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call the
|
||||||
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) or {@link refresh} methods,
|
* [store.customer.create](https://docs.medusajs.com/resources/references/js-sdk/store/customer#create) or {@link refresh} methods,
|
||||||
* for example, after calling this method.
|
* for example, after calling this method.
|
||||||
*
|
*
|
||||||
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
||||||
*
|
*
|
||||||
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
* @param actor - The actor type. For example, `user` for admin user, or `customer` for customer.
|
||||||
@@ -205,15 +205,15 @@ export class Auth {
|
|||||||
/**
|
/**
|
||||||
* This method refreshes a JWT authentication token, which is useful after validating the Oauth callback
|
* This method refreshes a JWT authentication token, which is useful after validating the Oauth callback
|
||||||
* with {@link callback}. It sends a request to the [Refresh Authentication Token API route](https://docs.medusajs.com/api/admin#auth_postadminauthtokenrefresh).
|
* with {@link callback}. It sends a request to the [Refresh Authentication Token API route](https://docs.medusajs.com/api/admin#auth_postadminauthtokenrefresh).
|
||||||
*
|
*
|
||||||
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call other
|
* The method stores the returned token and passes it in the header of subsequent requests. So, you can call other
|
||||||
* methods that require authentication after calling this method.
|
* methods that require authentication after calling this method.
|
||||||
*
|
*
|
||||||
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
||||||
*
|
*
|
||||||
* For an example of implementing third-party authentication, refer to the
|
* For an example of implementing third-party authentication, refer to the
|
||||||
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
* [Third-Party Login in Storefront](https://docs.medusajs.com/resources/storefront-development/customers/third-party-login) guide.
|
||||||
*
|
*
|
||||||
* @param headers - Headers to pass in the request
|
* @param headers - Headers to pass in the request
|
||||||
*
|
*
|
||||||
* @returns The refreshed JWT authentication token.
|
* @returns The refreshed JWT authentication token.
|
||||||
@@ -222,7 +222,7 @@ export class Auth {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const token = await sdk.auth.refresh()
|
* const token = await sdk.auth.refresh()
|
||||||
*
|
*
|
||||||
* // all subsequent requests will use the token in the header
|
* // all subsequent requests will use the token in the header
|
||||||
* const { customer } = await sdk.store.customer.retrieve()
|
* const { customer } = await sdk.store.customer.retrieve()
|
||||||
*/
|
*/
|
||||||
@@ -243,19 +243,19 @@ export class Auth {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method logs out the currently authenticated user based on your JS SDK authentication configurations.
|
* This method logs out the currently authenticated user based on your JS SDK authentication configurations.
|
||||||
*
|
*
|
||||||
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
* If the `auth.type` of the SDK is set to `session`, this method will also send a request to the
|
||||||
* [Delete Authentication Session API route](https://docs.medusajs.com/api/admin#auth_deletesession).
|
* [Delete Authentication Session API route](https://docs.medusajs.com/api/admin#auth_deletesession).
|
||||||
*
|
*
|
||||||
* The method also clears any stored tokens or sessions, based on your JS SDK authentication configurations.
|
* The method also clears any stored tokens or sessions, based on your JS SDK authentication configurations.
|
||||||
*
|
*
|
||||||
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
* Learn more in the [JS SDK Authentication](https://docs.medusajs.com/resources/js-sdk/auth/overview) guide.
|
||||||
*
|
*
|
||||||
* @tags auth
|
* @tags auth
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* await sdk.auth.logout()
|
* await sdk.auth.logout()
|
||||||
*
|
*
|
||||||
* // user is now logged out
|
* // user is now logged out
|
||||||
* // you can't send any requests that require authentication
|
* // you can't send any requests that require authentication
|
||||||
*/
|
*/
|
||||||
@@ -304,6 +304,12 @@ export class Auth {
|
|||||||
* this would be the user's email.
|
* this would be the user's email.
|
||||||
*/
|
*/
|
||||||
identifier: string
|
identifier: string
|
||||||
|
/**
|
||||||
|
* Optional metadata to include in the reset password request.
|
||||||
|
*
|
||||||
|
* @since 2.12.4
|
||||||
|
*/
|
||||||
|
metadata?: Record<string, unknown>
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
await this.client.fetch(`/auth/${actor}/${provider}/reset-password`, {
|
await this.client.fetch(`/auth/${actor}/${provider}/reset-password`, {
|
||||||
|
|||||||
Reference in new issue
Block a user