@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.d.mts +11 -18
- package/dist/index.d.ts +11 -18
- package/dist/index.js +18 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/recovery.ts +30 -45
package/dist/index.d.mts
CHANGED
|
@@ -867,12 +867,12 @@ declare class DropshipperClient {
|
|
|
867
867
|
* logged in. Backend URLs are owned here; the dashboard never builds them.
|
|
868
868
|
*
|
|
869
869
|
* Endpoints:
|
|
870
|
-
* - `POST /auth/
|
|
871
|
-
* - `GET /
|
|
872
|
-
* - `POST /auth/
|
|
873
|
-
* - `GET /store/dropshipper/applications/activate/verify`(verify activation token, no consume)
|
|
874
|
-
* - `POST /store/dropshipper/applications/activate`
|
|
875
|
-
* - `POST /public/dropshipper/applications`
|
|
870
|
+
* - `POST /dropshipper/auth/emailpass/reset-password` (request reset, dropshipper)
|
|
871
|
+
* - `GET /dropshipper/auth/emailpass/reset-password/verify` (verify reset token, no consume)
|
|
872
|
+
* - `POST /dropshipper/auth/emailpass/update` (confirm reset, consumes token)
|
|
873
|
+
* - `GET /store/dropshipper/applications/activate/verify` (verify activation token, no consume)
|
|
874
|
+
* - `POST /store/dropshipper/applications/activate` (confirm activation, consumes token)
|
|
875
|
+
* - `POST /public/dropshipper/applications` (submit application, no auth)
|
|
876
876
|
*
|
|
877
877
|
* Confirm methods follow the two-phase contract: verify (no consume) first,
|
|
878
878
|
* then confirm (atomic consume). A re-verify after a failed confirm maps the
|
|
@@ -915,33 +915,26 @@ declare class RecoveryClient {
|
|
|
915
915
|
private logger;
|
|
916
916
|
constructor(config: RecoveryClientConfig);
|
|
917
917
|
private request;
|
|
918
|
-
/**
|
|
919
|
-
* Decodes the `entity_id` (email) claim from a Medusa reset-password JWT.
|
|
920
|
-
*
|
|
921
|
-
* The JWT is unsigned-trust for this claim: the email is later sent to
|
|
922
|
-
* `POST /auth/user/emailpass/update`, where Medusa itself re-validates the
|
|
923
|
-
* token signature and payload before applying the change.
|
|
924
|
-
*/
|
|
925
|
-
private decodeResetTokenEmail;
|
|
926
918
|
/**
|
|
927
919
|
* Solicita un email de reset de contraseña para el actor `user`
|
|
928
920
|
* (dropshippers). El backend responde de forma uniforme exista o no la
|
|
929
921
|
* cuenta (anti enumeración).
|
|
930
922
|
*
|
|
931
|
-
* `POST /auth/
|
|
923
|
+
* `POST /dropshipper/auth/emailpass/reset-password`
|
|
932
924
|
*/
|
|
933
925
|
requestUserPasswordReset(email: string): Promise<void>;
|
|
934
926
|
/**
|
|
935
927
|
* Verifica un token de reset de contraseña sin consumirlo. Devuelve el
|
|
936
928
|
* email enmascarado (p. ej. `j***@ejemplo.com`) solo cuando `status === 'valid'`.
|
|
937
929
|
*
|
|
938
|
-
* `GET /
|
|
930
|
+
* `GET /dropshipper/auth/emailpass/reset-password/verify`
|
|
939
931
|
*/
|
|
940
932
|
verifyUserPasswordResetToken(token: string): Promise<TokenVerifyResult>;
|
|
941
933
|
/**
|
|
942
934
|
* Confirma el reset: re-verifica el token (sin consumir), luego consume el
|
|
943
|
-
* token vía `POST /auth/
|
|
944
|
-
* propio JWT
|
|
935
|
+
* token vía `POST /dropshipper/auth/emailpass/update`. El email se deriva del
|
|
936
|
+
* propio JWT en el backend; aquí solo se envía la nueva contraseña. Nunca
|
|
937
|
+
* devuelve auto-login: al éxito, la UI redirige a /login.
|
|
945
938
|
*/
|
|
946
939
|
confirmUserPasswordReset(token: string, password: string): Promise<RecoveryConfirmResult>;
|
|
947
940
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -867,12 +867,12 @@ declare class DropshipperClient {
|
|
|
867
867
|
* logged in. Backend URLs are owned here; the dashboard never builds them.
|
|
868
868
|
*
|
|
869
869
|
* Endpoints:
|
|
870
|
-
* - `POST /auth/
|
|
871
|
-
* - `GET /
|
|
872
|
-
* - `POST /auth/
|
|
873
|
-
* - `GET /store/dropshipper/applications/activate/verify`(verify activation token, no consume)
|
|
874
|
-
* - `POST /store/dropshipper/applications/activate`
|
|
875
|
-
* - `POST /public/dropshipper/applications`
|
|
870
|
+
* - `POST /dropshipper/auth/emailpass/reset-password` (request reset, dropshipper)
|
|
871
|
+
* - `GET /dropshipper/auth/emailpass/reset-password/verify` (verify reset token, no consume)
|
|
872
|
+
* - `POST /dropshipper/auth/emailpass/update` (confirm reset, consumes token)
|
|
873
|
+
* - `GET /store/dropshipper/applications/activate/verify` (verify activation token, no consume)
|
|
874
|
+
* - `POST /store/dropshipper/applications/activate` (confirm activation, consumes token)
|
|
875
|
+
* - `POST /public/dropshipper/applications` (submit application, no auth)
|
|
876
876
|
*
|
|
877
877
|
* Confirm methods follow the two-phase contract: verify (no consume) first,
|
|
878
878
|
* then confirm (atomic consume). A re-verify after a failed confirm maps the
|
|
@@ -915,33 +915,26 @@ declare class RecoveryClient {
|
|
|
915
915
|
private logger;
|
|
916
916
|
constructor(config: RecoveryClientConfig);
|
|
917
917
|
private request;
|
|
918
|
-
/**
|
|
919
|
-
* Decodes the `entity_id` (email) claim from a Medusa reset-password JWT.
|
|
920
|
-
*
|
|
921
|
-
* The JWT is unsigned-trust for this claim: the email is later sent to
|
|
922
|
-
* `POST /auth/user/emailpass/update`, where Medusa itself re-validates the
|
|
923
|
-
* token signature and payload before applying the change.
|
|
924
|
-
*/
|
|
925
|
-
private decodeResetTokenEmail;
|
|
926
918
|
/**
|
|
927
919
|
* Solicita un email de reset de contraseña para el actor `user`
|
|
928
920
|
* (dropshippers). El backend responde de forma uniforme exista o no la
|
|
929
921
|
* cuenta (anti enumeración).
|
|
930
922
|
*
|
|
931
|
-
* `POST /auth/
|
|
923
|
+
* `POST /dropshipper/auth/emailpass/reset-password`
|
|
932
924
|
*/
|
|
933
925
|
requestUserPasswordReset(email: string): Promise<void>;
|
|
934
926
|
/**
|
|
935
927
|
* Verifica un token de reset de contraseña sin consumirlo. Devuelve el
|
|
936
928
|
* email enmascarado (p. ej. `j***@ejemplo.com`) solo cuando `status === 'valid'`.
|
|
937
929
|
*
|
|
938
|
-
* `GET /
|
|
930
|
+
* `GET /dropshipper/auth/emailpass/reset-password/verify`
|
|
939
931
|
*/
|
|
940
932
|
verifyUserPasswordResetToken(token: string): Promise<TokenVerifyResult>;
|
|
941
933
|
/**
|
|
942
934
|
* Confirma el reset: re-verifica el token (sin consumir), luego consume el
|
|
943
|
-
* token vía `POST /auth/
|
|
944
|
-
* propio JWT
|
|
935
|
+
* token vía `POST /dropshipper/auth/emailpass/update`. El email se deriva del
|
|
936
|
+
* propio JWT en el backend; aquí solo se envía la nueva contraseña. Nunca
|
|
937
|
+
* devuelve auto-login: al éxito, la UI redirige a /login.
|
|
945
938
|
*/
|
|
946
939
|
confirmUserPasswordReset(token: string, password: string): Promise<RecoveryConfirmResult>;
|
|
947
940
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1997,27 +1997,14 @@ var RecoveryClient = class {
|
|
|
1997
1997
|
details
|
|
1998
1998
|
);
|
|
1999
1999
|
}
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
* Decodes the `entity_id` (email) claim from a Medusa reset-password JWT.
|
|
2007
|
-
*
|
|
2008
|
-
* The JWT is unsigned-trust for this claim: the email is later sent to
|
|
2009
|
-
* `POST /auth/user/emailpass/update`, where Medusa itself re-validates the
|
|
2010
|
-
* token signature and payload before applying the change.
|
|
2011
|
-
*/
|
|
2012
|
-
decodeResetTokenEmail(token) {
|
|
2013
|
-
const parts = token.split(".");
|
|
2014
|
-
if (parts.length !== 3) return null;
|
|
2015
|
-
try {
|
|
2016
|
-
const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
2017
|
-
return typeof payload.entity_id === "string" && payload.entity_id.length > 0 ? payload.entity_id : null;
|
|
2018
|
-
} catch {
|
|
2019
|
-
return null;
|
|
2000
|
+
if ((response.headers.get("content-type") ?? "").includes("application/json")) {
|
|
2001
|
+
try {
|
|
2002
|
+
return await response.json();
|
|
2003
|
+
} catch {
|
|
2004
|
+
return {};
|
|
2005
|
+
}
|
|
2020
2006
|
}
|
|
2007
|
+
return {};
|
|
2021
2008
|
}
|
|
2022
2009
|
// -------------------------------------------------------------------------
|
|
2023
2010
|
// Password reset
|
|
@@ -2027,49 +2014,46 @@ var RecoveryClient = class {
|
|
|
2027
2014
|
* (dropshippers). El backend responde de forma uniforme exista o no la
|
|
2028
2015
|
* cuenta (anti enumeración).
|
|
2029
2016
|
*
|
|
2030
|
-
* `POST /auth/
|
|
2017
|
+
* `POST /dropshipper/auth/emailpass/reset-password`
|
|
2031
2018
|
*/
|
|
2032
2019
|
async requestUserPasswordReset(email) {
|
|
2033
|
-
await this.request("POST", "/auth/
|
|
2034
|
-
|
|
2020
|
+
await this.request("POST", "/dropshipper/auth/emailpass/reset-password", {
|
|
2021
|
+
email
|
|
2035
2022
|
});
|
|
2036
2023
|
}
|
|
2037
2024
|
/**
|
|
2038
2025
|
* Verifica un token de reset de contraseña sin consumirlo. Devuelve el
|
|
2039
2026
|
* email enmascarado (p. ej. `j***@ejemplo.com`) solo cuando `status === 'valid'`.
|
|
2040
2027
|
*
|
|
2041
|
-
* `GET /
|
|
2028
|
+
* `GET /dropshipper/auth/emailpass/reset-password/verify`
|
|
2042
2029
|
*/
|
|
2043
2030
|
async verifyUserPasswordResetToken(token) {
|
|
2044
|
-
return this.request("GET", `/
|
|
2031
|
+
return this.request("GET", `/dropshipper/auth/emailpass/reset-password/verify?token=${encodeURIComponent(token)}`);
|
|
2045
2032
|
}
|
|
2046
2033
|
/**
|
|
2047
2034
|
* Confirma el reset: re-verifica el token (sin consumir), luego consume el
|
|
2048
|
-
* token vía `POST /auth/
|
|
2049
|
-
* propio JWT
|
|
2035
|
+
* token vía `POST /dropshipper/auth/emailpass/update`. El email se deriva del
|
|
2036
|
+
* propio JWT en el backend; aquí solo se envía la nueva contraseña. Nunca
|
|
2037
|
+
* devuelve auto-login: al éxito, la UI redirige a /login.
|
|
2050
2038
|
*/
|
|
2051
2039
|
async confirmUserPasswordReset(token, password) {
|
|
2052
2040
|
const verify = await this.verifyUserPasswordResetToken(token);
|
|
2053
2041
|
if (verify.status !== "valid") {
|
|
2054
2042
|
return { ok: false, status: verify.status };
|
|
2055
2043
|
}
|
|
2056
|
-
const email = this.decodeResetTokenEmail(token);
|
|
2057
|
-
if (!email) {
|
|
2058
|
-
return { ok: false, status: "invalid" };
|
|
2059
|
-
}
|
|
2060
2044
|
try {
|
|
2061
2045
|
const headers = {
|
|
2062
2046
|
Authorization: `Bearer ${token}`,
|
|
2063
2047
|
"Content-Type": "application/json"
|
|
2064
2048
|
};
|
|
2065
|
-
const response = await fetchBackendWithResilience(`${this.baseUrl}/auth/
|
|
2049
|
+
const response = await fetchBackendWithResilience(`${this.baseUrl}/dropshipper/auth/emailpass/update`, {
|
|
2066
2050
|
method: "POST",
|
|
2067
2051
|
headers,
|
|
2068
|
-
body: JSON.stringify({
|
|
2052
|
+
body: JSON.stringify({ password })
|
|
2069
2053
|
});
|
|
2070
2054
|
if (!response.ok) {
|
|
2071
2055
|
throw new import_adapters4.ProviderAPIError(
|
|
2072
|
-
`[recovery] POST /auth/
|
|
2056
|
+
`[recovery] POST /dropshipper/auth/emailpass/update failed: HTTP ${response.status}`,
|
|
2073
2057
|
"RECOVERY_API_" + response.status,
|
|
2074
2058
|
response.status
|
|
2075
2059
|
);
|