@delopay/sdk 0.3.1 → 0.3.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.cjs +20 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2070,19 +2070,30 @@ var Users = class {
|
|
|
2070
2070
|
return this.request("POST", "/user/forgot_password", { body: params });
|
|
2071
2071
|
}
|
|
2072
2072
|
/**
|
|
2073
|
-
* Reset a user's password using the
|
|
2074
|
-
* forgot-password email.
|
|
2073
|
+
* Reset a user's password using the email link token.
|
|
2075
2074
|
*
|
|
2076
|
-
* The
|
|
2077
|
-
*
|
|
2078
|
-
*
|
|
2079
|
-
*
|
|
2075
|
+
* The email link delivers an `EmailToken`, but `/user/reset_password` is
|
|
2076
|
+
* gated by `SinglePurposeJWTAuth` which expects a different JWT type
|
|
2077
|
+
* (`SinglePurposeToken`). The SDK hides this two-step dance:
|
|
2078
|
+
*
|
|
2079
|
+
* 1. Exchange the EmailToken for a SinglePurposeToken at `/user/from_email`
|
|
2080
|
+
* (`crates/router/src/core/user.rs:2773`, no auth required).
|
|
2081
|
+
* 2. Call `/user/reset_password` with the SinglePurposeToken as
|
|
2082
|
+
* `Authorization: Bearer` and the original EmailToken in the body —
|
|
2083
|
+
* the handler decodes body.token as an EmailToken to look up the user
|
|
2084
|
+
* (`crates/router/src/core/user.rs:687`).
|
|
2085
|
+
*
|
|
2086
|
+
* Callers just pass `{ password, token }` (the token from the URL).
|
|
2080
2087
|
*/
|
|
2081
2088
|
async resetPassword(params) {
|
|
2082
|
-
const
|
|
2089
|
+
const exchange = await this.request(
|
|
2090
|
+
"POST",
|
|
2091
|
+
"/user/from_email",
|
|
2092
|
+
{ body: { token: params.token } }
|
|
2093
|
+
);
|
|
2083
2094
|
return this.request("POST", "/user/reset_password", {
|
|
2084
|
-
body: { password },
|
|
2085
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
2095
|
+
body: { token: params.token, password: params.password },
|
|
2096
|
+
headers: { Authorization: `Bearer ${exchange.token}` }
|
|
2086
2097
|
});
|
|
2087
2098
|
}
|
|
2088
2099
|
async verifyEmail(params) {
|