@delopay/sdk 0.3.2 → 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,15 +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.
2990
- *
2991
- * The backend validates the token **twice**: first by the
2992
- * `SinglePurposeJWTAuth` middleware (reads `Authorization: Bearer …`),
2993
- * then by the handler itself (decodes `body.token` as an `EmailToken` and
2994
- * looks up the user by the embedded email — see
2995
- * `crates/router/src/core/user.rs:687`). The same JWT satisfies both, so
2996
- * the SDK sends it in both places. Callers still pass `{ password, token }`.
2988
+ * Reset a user's password using the email link token.
2989
+ *
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).
2997
3002
  */
2998
3003
  resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>>;
2999
3004
  verifyEmail(params: Record<string, unknown>): Promise<AuthResponse>;
package/dist/index.d.ts CHANGED
@@ -2985,15 +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.
2990
- *
2991
- * The backend validates the token **twice**: first by the
2992
- * `SinglePurposeJWTAuth` middleware (reads `Authorization: Bearer …`),
2993
- * then by the handler itself (decodes `body.token` as an `EmailToken` and
2994
- * looks up the user by the embedded email — see
2995
- * `crates/router/src/core/user.rs:687`). The same JWT satisfies both, so
2996
- * the SDK sends it in both places. Callers still pass `{ password, token }`.
2988
+ * Reset a user's password using the email link token.
2989
+ *
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).
2997
3002
  */
2998
3003
  resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>>;
2999
3004
  verifyEmail(params: Record<string, unknown>): Promise<AuthResponse>;
package/dist/index.js CHANGED
@@ -2030,20 +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 validates the token **twice**: first by the
2037
- * `SinglePurposeJWTAuth` middleware (reads `Authorization: Bearer …`),
2038
- * then by the handler itself (decodes `body.token` as an `EmailToken` and
2039
- * looks up the user by the embedded email — see
2040
- * `crates/router/src/core/user.rs:687`). The same JWT satisfies both, so
2041
- * the SDK sends it in both places. Callers still pass `{ password, token }`.
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).
2042
2047
  */
2043
2048
  async resetPassword(params) {
2049
+ const exchange = await this.request(
2050
+ "POST",
2051
+ "/user/from_email",
2052
+ { body: { token: params.token } }
2053
+ );
2044
2054
  return this.request("POST", "/user/reset_password", {
2045
- body: params,
2046
- headers: { Authorization: `Bearer ${params.token}` }
2055
+ body: { token: params.token, password: params.password },
2056
+ headers: { Authorization: `Bearer ${exchange.token}` }
2047
2057
  });
2048
2058
  }
2049
2059
  async verifyEmail(params) {