@thorprovider/medusa-extended 1.13.2 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1969,27 +1969,14 @@ var RecoveryClient = class {
1969
1969
  details
1970
1970
  );
1971
1971
  }
1972
- return response.json();
1973
- }
1974
- // -------------------------------------------------------------------------
1975
- // Private — reset token helpers
1976
- // -------------------------------------------------------------------------
1977
- /**
1978
- * Decodes the `entity_id` (email) claim from a Medusa reset-password JWT.
1979
- *
1980
- * The JWT is unsigned-trust for this claim: the email is later sent to
1981
- * `POST /auth/user/emailpass/update`, where Medusa itself re-validates the
1982
- * token signature and payload before applying the change.
1983
- */
1984
- decodeResetTokenEmail(token) {
1985
- const parts = token.split(".");
1986
- if (parts.length !== 3) return null;
1987
- try {
1988
- const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
1989
- return typeof payload.entity_id === "string" && payload.entity_id.length > 0 ? payload.entity_id : null;
1990
- } catch {
1991
- return null;
1972
+ if ((response.headers.get("content-type") ?? "").includes("application/json")) {
1973
+ try {
1974
+ return await response.json();
1975
+ } catch {
1976
+ return {};
1977
+ }
1992
1978
  }
1979
+ return {};
1993
1980
  }
1994
1981
  // -------------------------------------------------------------------------
1995
1982
  // Password reset
@@ -1999,49 +1986,46 @@ var RecoveryClient = class {
1999
1986
  * (dropshippers). El backend responde de forma uniforme exista o no la
2000
1987
  * cuenta (anti enumeración).
2001
1988
  *
2002
- * `POST /auth/user/emailpass/reset-password`
1989
+ * `POST /dropshipper/auth/emailpass/reset-password`
2003
1990
  */
2004
1991
  async requestUserPasswordReset(email) {
2005
- await this.request("POST", "/auth/user/emailpass/reset-password", {
2006
- identifier: email
1992
+ await this.request("POST", "/dropshipper/auth/emailpass/reset-password", {
1993
+ email
2007
1994
  });
2008
1995
  }
2009
1996
  /**
2010
1997
  * Verifica un token de reset de contraseña sin consumirlo. Devuelve el
2011
1998
  * email enmascarado (p. ej. `j***@ejemplo.com`) solo cuando `status === 'valid'`.
2012
1999
  *
2013
- * `GET /store/dropshipper/auth/reset-password/verify`
2000
+ * `GET /dropshipper/auth/emailpass/reset-password/verify`
2014
2001
  */
2015
2002
  async verifyUserPasswordResetToken(token) {
2016
- return this.request("GET", `/store/dropshipper/auth/reset-password/verify?token=${encodeURIComponent(token)}`);
2003
+ return this.request("GET", `/dropshipper/auth/emailpass/reset-password/verify?token=${encodeURIComponent(token)}`);
2017
2004
  }
2018
2005
  /**
2019
2006
  * Confirma el reset: re-verifica el token (sin consumir), luego consume el
2020
- * token vía `POST /auth/user/emailpass/update`. El email se deriva del
2021
- * propio JWT. Nunca devuelve auto-login: al éxito, la UI redirige a /login.
2007
+ * token vía `POST /dropshipper/auth/emailpass/update`. El email se deriva del
2008
+ * propio JWT en el backend; aquí solo se envía la nueva contraseña. Nunca
2009
+ * devuelve auto-login: al éxito, la UI redirige a /login.
2022
2010
  */
2023
2011
  async confirmUserPasswordReset(token, password) {
2024
2012
  const verify = await this.verifyUserPasswordResetToken(token);
2025
2013
  if (verify.status !== "valid") {
2026
2014
  return { ok: false, status: verify.status };
2027
2015
  }
2028
- const email = this.decodeResetTokenEmail(token);
2029
- if (!email) {
2030
- return { ok: false, status: "invalid" };
2031
- }
2032
2016
  try {
2033
2017
  const headers = {
2034
2018
  Authorization: `Bearer ${token}`,
2035
2019
  "Content-Type": "application/json"
2036
2020
  };
2037
- const response = await fetchBackendWithResilience(`${this.baseUrl}/auth/user/emailpass/update`, {
2021
+ const response = await fetchBackendWithResilience(`${this.baseUrl}/dropshipper/auth/emailpass/update`, {
2038
2022
  method: "POST",
2039
2023
  headers,
2040
- body: JSON.stringify({ email, password })
2024
+ body: JSON.stringify({ password })
2041
2025
  });
2042
2026
  if (!response.ok) {
2043
2027
  throw new ProviderAPIError4(
2044
- `[recovery] POST /auth/user/emailpass/update failed: HTTP ${response.status}`,
2028
+ `[recovery] POST /dropshipper/auth/emailpass/update failed: HTTP ${response.status}`,
2045
2029
  "RECOVERY_API_" + response.status,
2046
2030
  response.status
2047
2031
  );