@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.d.cts CHANGED
@@ -2985,13 +2985,20 @@ declare class Users {
2985
2985
  rotatePassword(params: ResetPasswordRequest): Promise<UserResponse>;
2986
2986
  forgotPassword(params: ForgotPasswordRequest): Promise<Record<string, unknown>>;
2987
2987
  /**
2988
- * Reset a user's password using the single-purpose JWT delivered by the
2989
- * forgot-password email.
2988
+ * Reset a user's password using the email link token.
2990
2989
  *
2991
- * The backend's `SinglePurposeJWTAuth` reads the token from the
2992
- * `Authorization: Bearer …` header, not from the request body, so the
2993
- * SDK lifts the `token` field out of `params` and sends it as the header.
2994
- * Callers still pass `{ password, token }` — the shape is unchanged.
2990
+ * The email link delivers an `EmailToken`, but `/user/reset_password` is
2991
+ * gated by `SinglePurposeJWTAuth` which expects a different JWT type
2992
+ * (`SinglePurposeToken`). The SDK hides this two-step dance:
2993
+ *
2994
+ * 1. Exchange the EmailToken for a SinglePurposeToken at `/user/from_email`
2995
+ * (`crates/router/src/core/user.rs:2773`, no auth required).
2996
+ * 2. Call `/user/reset_password` with the SinglePurposeToken as
2997
+ * `Authorization: Bearer` and the original EmailToken in the body —
2998
+ * the handler decodes body.token as an EmailToken to look up the user
2999
+ * (`crates/router/src/core/user.rs:687`).
3000
+ *
3001
+ * Callers just pass `{ password, token }` (the token from the URL).
2995
3002
  */
2996
3003
  resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>>;
2997
3004
  verifyEmail(params: Record<string, unknown>): Promise<AuthResponse>;
package/dist/index.d.ts CHANGED
@@ -2985,13 +2985,20 @@ declare class Users {
2985
2985
  rotatePassword(params: ResetPasswordRequest): Promise<UserResponse>;
2986
2986
  forgotPassword(params: ForgotPasswordRequest): Promise<Record<string, unknown>>;
2987
2987
  /**
2988
- * Reset a user's password using the single-purpose JWT delivered by the
2989
- * forgot-password email.
2988
+ * Reset a user's password using the email link token.
2990
2989
  *
2991
- * The backend's `SinglePurposeJWTAuth` reads the token from the
2992
- * `Authorization: Bearer …` header, not from the request body, so the
2993
- * SDK lifts the `token` field out of `params` and sends it as the header.
2994
- * Callers still pass `{ password, token }` — the shape is unchanged.
2990
+ * The email link delivers an `EmailToken`, but `/user/reset_password` is
2991
+ * gated by `SinglePurposeJWTAuth` which expects a different JWT type
2992
+ * (`SinglePurposeToken`). The SDK hides this two-step dance:
2993
+ *
2994
+ * 1. Exchange the EmailToken for a SinglePurposeToken at `/user/from_email`
2995
+ * (`crates/router/src/core/user.rs:2773`, no auth required).
2996
+ * 2. Call `/user/reset_password` with the SinglePurposeToken as
2997
+ * `Authorization: Bearer` and the original EmailToken in the body —
2998
+ * the handler decodes body.token as an EmailToken to look up the user
2999
+ * (`crates/router/src/core/user.rs:687`).
3000
+ *
3001
+ * Callers just pass `{ password, token }` (the token from the URL).
2995
3002
  */
2996
3003
  resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>>;
2997
3004
  verifyEmail(params: Record<string, unknown>): Promise<AuthResponse>;
package/dist/index.js CHANGED
@@ -2030,19 +2030,30 @@ var Users = class {
2030
2030
  return this.request("POST", "/user/forgot_password", { body: params });
2031
2031
  }
2032
2032
  /**
2033
- * Reset a user's password using the single-purpose JWT delivered by the
2034
- * forgot-password email.
2033
+ * Reset a user's password using the email link token.
2035
2034
  *
2036
- * The backend's `SinglePurposeJWTAuth` reads the token from the
2037
- * `Authorization: Bearer …` header, not from the request body, so the
2038
- * SDK lifts the `token` field out of `params` and sends it as the header.
2039
- * Callers still pass `{ password, token }` — the shape is unchanged.
2035
+ * The email link delivers an `EmailToken`, but `/user/reset_password` is
2036
+ * gated by `SinglePurposeJWTAuth` which expects a different JWT type
2037
+ * (`SinglePurposeToken`). The SDK hides this two-step dance:
2038
+ *
2039
+ * 1. Exchange the EmailToken for a SinglePurposeToken at `/user/from_email`
2040
+ * (`crates/router/src/core/user.rs:2773`, no auth required).
2041
+ * 2. Call `/user/reset_password` with the SinglePurposeToken as
2042
+ * `Authorization: Bearer` and the original EmailToken in the body —
2043
+ * the handler decodes body.token as an EmailToken to look up the user
2044
+ * (`crates/router/src/core/user.rs:687`).
2045
+ *
2046
+ * Callers just pass `{ password, token }` (the token from the URL).
2040
2047
  */
2041
2048
  async resetPassword(params) {
2042
- const { token, password } = params;
2049
+ const exchange = await this.request(
2050
+ "POST",
2051
+ "/user/from_email",
2052
+ { body: { token: params.token } }
2053
+ );
2043
2054
  return this.request("POST", "/user/reset_password", {
2044
- body: { password },
2045
- headers: { Authorization: `Bearer ${token}` }
2055
+ body: { token: params.token, password: params.password },
2056
+ headers: { Authorization: `Bearer ${exchange.token}` }
2046
2057
  });
2047
2058
  }
2048
2059
  async verifyEmail(params) {