@delopay/sdk 0.3.3 → 0.4.0

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
@@ -1100,6 +1100,36 @@ interface TotpResponse {
1100
1100
  interface RecoveryCodesResponse {
1101
1101
  recovery_codes: string[];
1102
1102
  }
1103
+ /** Request shape for exchanging an email-link token for a single-purpose token. */
1104
+ interface FromEmailRequest {
1105
+ /** The JWT delivered in the password-reset / verify-email / invite link. */
1106
+ token: string;
1107
+ }
1108
+ /**
1109
+ * Purpose of a single-purpose JWT. The backend decides which purpose to issue
1110
+ * next based on the user's current state (e.g. TOTP not set → `totp`, TOTP
1111
+ * verified → `reset_password`).
1112
+ */
1113
+ type TokenPurpose = 'totp' | 'reset_password' | 'sso' | 'auth_select' | 'merchant_select' | 'accept_invitation_from_email' | 'force_set_password' | 'verify_email' | string;
1114
+ /** Response shape from endpoints that issue a new single-purpose token. */
1115
+ interface TokenResponse {
1116
+ /** Signed JWT — pass as `Authorization: Bearer <token>` on the next call. */
1117
+ token: string;
1118
+ /** Kind of token — tells the client which step to perform next. */
1119
+ token_type: TokenPurpose;
1120
+ }
1121
+ /** Body for `POST|PUT /user/2fa/totp/verify` — 6-digit code from authenticator app. */
1122
+ interface VerifyTotpRequest {
1123
+ totp: string;
1124
+ }
1125
+ /** Optional query params for `GET /user/2fa/terminate`. */
1126
+ interface Terminate2faQueryParams {
1127
+ /**
1128
+ * Skip the TOTP requirement entirely. Only honored when the backend has
1129
+ * `force_two_factor_auth = false`. Use sparingly — it weakens security.
1130
+ */
1131
+ skip_two_factor_auth?: boolean;
1132
+ }
1103
1133
  interface PhoneOtpRequest {
1104
1134
  phone_number: string;
1105
1135
  }
@@ -2985,22 +3015,26 @@ declare class Users {
2985
3015
  rotatePassword(params: ResetPasswordRequest): Promise<UserResponse>;
2986
3016
  forgotPassword(params: ForgotPasswordRequest): Promise<Record<string, unknown>>;
2987
3017
  /**
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:
3018
+ * Commit a password reset.
2993
3019
  *
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).
3020
+ * The caller is responsible for obtaining a `SinglePurposeToken` with
3021
+ * `purpose: reset_password` via the email-token exchange + TOTP flow
3022
+ * (see `fromEmail`, `beginTotp`, `updateTotp`/`verifyTotp`,
3023
+ * `generateRecoveryCodes`, `terminate2fa`) and setting it on the client
3024
+ * via `setJwtToken` before calling this method. `body.token` must still
3025
+ * be the original `EmailToken` from the reset-link URL — the handler
3026
+ * decodes it a second time to find the user
3027
+ * (`delopay-backend/crates/router/src/core/user.rs:687`).
3002
3028
  */
3003
3029
  resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>>;
3030
+ /**
3031
+ * Exchange an email-link token (`EmailToken`) for a single-purpose JWT
3032
+ * that drives the next step of the flow (TOTP, verify email, accept
3033
+ * invitation, etc.). No authentication required.
3034
+ *
3035
+ * The `token_type` in the response tells you which step to run next.
3036
+ */
3037
+ fromEmail(params: FromEmailRequest): Promise<TokenResponse>;
3004
3038
  verifyEmail(params: Record<string, unknown>): Promise<AuthResponse>;
3005
3039
  sendVerificationEmail(params: ForgotPasswordRequest): Promise<Record<string, unknown>>;
3006
3040
  createMerchant(params: Record<string, unknown>): Promise<AuthResponse>;
@@ -3010,8 +3044,23 @@ declare class Users {
3010
3044
  listProfiles(): Promise<Record<string, unknown>[]>;
3011
3045
  inviteUsers(params: InviteUsersRequest[]): Promise<InviteUsersResponse[]>;
3012
3046
  acceptInvitation(params: Record<string, unknown>): Promise<AuthResponse>;
3047
+ /**
3048
+ * Start TOTP setup (or no-op if already set).
3049
+ *
3050
+ * Returns the QR-code payload when the user has no TOTP configured yet;
3051
+ * returns `{ secret: null }` when the user is already set up (caller
3052
+ * should then prompt for a 6-digit code and call `verifyTotp`).
3053
+ *
3054
+ * Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3055
+ */
3013
3056
  beginTotp(): Promise<TotpResponse>;
3014
- verifyTotp(params: Record<string, unknown>): Promise<AuthResponse>;
3057
+ /**
3058
+ * Verify a 6-digit TOTP code for a user whose TOTP is already set up.
3059
+ * Marks the code as used in Redis so subsequent flow steps can advance.
3060
+ *
3061
+ * Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3062
+ */
3063
+ verifyTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>>;
3015
3064
  resetTotp(): Promise<Record<string, unknown>>;
3016
3065
  generateRecoveryCodes(): Promise<RecoveryCodesResponse>;
3017
3066
  verifyRecoveryCode(params: Record<string, unknown>): Promise<AuthResponse>;
@@ -3036,10 +3085,21 @@ declare class Users {
3036
3085
  check2faStatus(): Promise<Record<string, unknown>>;
3037
3086
  /** Check 2FA status (v2). `GET /user/2fa/v2` */
3038
3087
  check2faStatusV2(): Promise<Record<string, unknown>>;
3039
- /** Update TOTP. `PUT /user/2fa/totp/verify` */
3040
- updateTotp(params: Record<string, unknown>): Promise<Record<string, unknown>>;
3041
- /** Terminate 2FA. `GET /user/2fa/terminate` */
3042
- terminate2fa(): Promise<Record<string, unknown>>;
3088
+ /**
3089
+ * Finish first-time TOTP setup: commit the secret generated by `beginTotp`
3090
+ * against a 6-digit code from the user's authenticator app.
3091
+ *
3092
+ * `PUT /user/2fa/totp/verify`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3093
+ */
3094
+ updateTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>>;
3095
+ /**
3096
+ * Complete the TOTP step and advance to the next flow stage (e.g.
3097
+ * `reset_password`). Returns a fresh single-purpose token with the
3098
+ * next `token_type`.
3099
+ *
3100
+ * `GET /user/2fa/terminate`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3101
+ */
3102
+ terminate2fa(query?: Terminate2faQueryParams): Promise<TokenResponse>;
3043
3103
  /** Create auth method. `POST /user/auth` */
3044
3104
  createAuthMethod(params: Record<string, unknown>): Promise<Record<string, unknown>>;
3045
3105
  /** Update auth method. `PUT /user/auth` */
@@ -3545,4 +3605,4 @@ declare const Webhooks: {
3545
3605
  verify(rawBody: string, signatureHeader: string, secret: string, options?: VerifyOptions): Promise<WebhookEvent>;
3546
3606
  };
3547
3607
 
3548
- export { type Address, type AddressDetails, type AdminAdjustmentRequest, type AdminAdjustmentResponse, type AdminAnalyticsRequest, type AdminCustomerDetail, type AdminCustomerListParams, type AdminCustomerListResponse, type AdminSignInRequest, type AdminTransactionListParams, type AdminTransactionListResponse, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, AnalyticsDashboard, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuditLogListParams, type AuditLogListResponse, type AuditLogResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AuthorizeResponse, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, Cache, type CaptureMethod, type CardDetail, type CardDetailFromLocker, type CardIssuerCreateRequest, type CardIssuerListResponse, type CardIssuerResponse, type CardIssuerUpdateRequest, Cards, type ChangePasswordRequest, Configs, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type CreateInternalUserRequest, type CreateTenantUserRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerSummary, type CustomerUpdateRequest, type CustomerUser, type DashboardMetadataResponse, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeType, Files, Forex, type ForgotPasswordRequest, type GatewayConnectRequest, type GatewayResponse, type GsmDecision, type GsmRuleCreateRequest, type GsmRuleResponse, type GsmRuleUpdateRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LedgerEntry, type LedgerListParams, type LedgerResponse, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type OnboardMerchantRequest, type OnboardMerchantResponse, type OverviewStat, type OverviewStatsResponse, type PaymentAnalyticsRequest, type PaymentAnalyticsResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentStat, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformAnalyticsResponse, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCreateRequest, type RegionResponse, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestFn, type RequestOptions, type ResetPasswordRequest, type RoutingConfigCreateRequest, type RoutingConfigResponse, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SignupToggleRequest, type SignupToggleResponse, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SwitchMerchantRequest, type SwitchProfileRequest, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type UpdateUserDetailsRequest, type UserResponse, type VerifyOptions, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks };
3608
+ export { type Address, type AddressDetails, type AdminAdjustmentRequest, type AdminAdjustmentResponse, type AdminAnalyticsRequest, type AdminCustomerDetail, type AdminCustomerListParams, type AdminCustomerListResponse, type AdminSignInRequest, type AdminTransactionListParams, type AdminTransactionListResponse, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, AnalyticsDashboard, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuditLogListParams, type AuditLogListResponse, type AuditLogResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AuthorizeResponse, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, Cache, type CaptureMethod, type CardDetail, type CardDetailFromLocker, type CardIssuerCreateRequest, type CardIssuerListResponse, type CardIssuerResponse, type CardIssuerUpdateRequest, Cards, type ChangePasswordRequest, Configs, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type CreateInternalUserRequest, type CreateTenantUserRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerSummary, type CustomerUpdateRequest, type CustomerUser, type DashboardMetadataResponse, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeType, Files, Forex, type ForgotPasswordRequest, type FromEmailRequest, type GatewayConnectRequest, type GatewayResponse, type GsmDecision, type GsmRuleCreateRequest, type GsmRuleResponse, type GsmRuleUpdateRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LedgerEntry, type LedgerListParams, type LedgerResponse, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type OnboardMerchantRequest, type OnboardMerchantResponse, type OverviewStat, type OverviewStatsResponse, type PaymentAnalyticsRequest, type PaymentAnalyticsResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentStat, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformAnalyticsResponse, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCreateRequest, type RegionResponse, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestFn, type RequestOptions, type ResetPasswordRequest, type RoutingConfigCreateRequest, type RoutingConfigResponse, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SignupToggleRequest, type SignupToggleResponse, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type UpdateUserDetailsRequest, type UserResponse, type VerifyOptions, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks };
package/dist/index.d.ts CHANGED
@@ -1100,6 +1100,36 @@ interface TotpResponse {
1100
1100
  interface RecoveryCodesResponse {
1101
1101
  recovery_codes: string[];
1102
1102
  }
1103
+ /** Request shape for exchanging an email-link token for a single-purpose token. */
1104
+ interface FromEmailRequest {
1105
+ /** The JWT delivered in the password-reset / verify-email / invite link. */
1106
+ token: string;
1107
+ }
1108
+ /**
1109
+ * Purpose of a single-purpose JWT. The backend decides which purpose to issue
1110
+ * next based on the user's current state (e.g. TOTP not set → `totp`, TOTP
1111
+ * verified → `reset_password`).
1112
+ */
1113
+ type TokenPurpose = 'totp' | 'reset_password' | 'sso' | 'auth_select' | 'merchant_select' | 'accept_invitation_from_email' | 'force_set_password' | 'verify_email' | string;
1114
+ /** Response shape from endpoints that issue a new single-purpose token. */
1115
+ interface TokenResponse {
1116
+ /** Signed JWT — pass as `Authorization: Bearer <token>` on the next call. */
1117
+ token: string;
1118
+ /** Kind of token — tells the client which step to perform next. */
1119
+ token_type: TokenPurpose;
1120
+ }
1121
+ /** Body for `POST|PUT /user/2fa/totp/verify` — 6-digit code from authenticator app. */
1122
+ interface VerifyTotpRequest {
1123
+ totp: string;
1124
+ }
1125
+ /** Optional query params for `GET /user/2fa/terminate`. */
1126
+ interface Terminate2faQueryParams {
1127
+ /**
1128
+ * Skip the TOTP requirement entirely. Only honored when the backend has
1129
+ * `force_two_factor_auth = false`. Use sparingly — it weakens security.
1130
+ */
1131
+ skip_two_factor_auth?: boolean;
1132
+ }
1103
1133
  interface PhoneOtpRequest {
1104
1134
  phone_number: string;
1105
1135
  }
@@ -2985,22 +3015,26 @@ declare class Users {
2985
3015
  rotatePassword(params: ResetPasswordRequest): Promise<UserResponse>;
2986
3016
  forgotPassword(params: ForgotPasswordRequest): Promise<Record<string, unknown>>;
2987
3017
  /**
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:
3018
+ * Commit a password reset.
2993
3019
  *
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).
3020
+ * The caller is responsible for obtaining a `SinglePurposeToken` with
3021
+ * `purpose: reset_password` via the email-token exchange + TOTP flow
3022
+ * (see `fromEmail`, `beginTotp`, `updateTotp`/`verifyTotp`,
3023
+ * `generateRecoveryCodes`, `terminate2fa`) and setting it on the client
3024
+ * via `setJwtToken` before calling this method. `body.token` must still
3025
+ * be the original `EmailToken` from the reset-link URL — the handler
3026
+ * decodes it a second time to find the user
3027
+ * (`delopay-backend/crates/router/src/core/user.rs:687`).
3002
3028
  */
3003
3029
  resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>>;
3030
+ /**
3031
+ * Exchange an email-link token (`EmailToken`) for a single-purpose JWT
3032
+ * that drives the next step of the flow (TOTP, verify email, accept
3033
+ * invitation, etc.). No authentication required.
3034
+ *
3035
+ * The `token_type` in the response tells you which step to run next.
3036
+ */
3037
+ fromEmail(params: FromEmailRequest): Promise<TokenResponse>;
3004
3038
  verifyEmail(params: Record<string, unknown>): Promise<AuthResponse>;
3005
3039
  sendVerificationEmail(params: ForgotPasswordRequest): Promise<Record<string, unknown>>;
3006
3040
  createMerchant(params: Record<string, unknown>): Promise<AuthResponse>;
@@ -3010,8 +3044,23 @@ declare class Users {
3010
3044
  listProfiles(): Promise<Record<string, unknown>[]>;
3011
3045
  inviteUsers(params: InviteUsersRequest[]): Promise<InviteUsersResponse[]>;
3012
3046
  acceptInvitation(params: Record<string, unknown>): Promise<AuthResponse>;
3047
+ /**
3048
+ * Start TOTP setup (or no-op if already set).
3049
+ *
3050
+ * Returns the QR-code payload when the user has no TOTP configured yet;
3051
+ * returns `{ secret: null }` when the user is already set up (caller
3052
+ * should then prompt for a 6-digit code and call `verifyTotp`).
3053
+ *
3054
+ * Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3055
+ */
3013
3056
  beginTotp(): Promise<TotpResponse>;
3014
- verifyTotp(params: Record<string, unknown>): Promise<AuthResponse>;
3057
+ /**
3058
+ * Verify a 6-digit TOTP code for a user whose TOTP is already set up.
3059
+ * Marks the code as used in Redis so subsequent flow steps can advance.
3060
+ *
3061
+ * Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3062
+ */
3063
+ verifyTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>>;
3015
3064
  resetTotp(): Promise<Record<string, unknown>>;
3016
3065
  generateRecoveryCodes(): Promise<RecoveryCodesResponse>;
3017
3066
  verifyRecoveryCode(params: Record<string, unknown>): Promise<AuthResponse>;
@@ -3036,10 +3085,21 @@ declare class Users {
3036
3085
  check2faStatus(): Promise<Record<string, unknown>>;
3037
3086
  /** Check 2FA status (v2). `GET /user/2fa/v2` */
3038
3087
  check2faStatusV2(): Promise<Record<string, unknown>>;
3039
- /** Update TOTP. `PUT /user/2fa/totp/verify` */
3040
- updateTotp(params: Record<string, unknown>): Promise<Record<string, unknown>>;
3041
- /** Terminate 2FA. `GET /user/2fa/terminate` */
3042
- terminate2fa(): Promise<Record<string, unknown>>;
3088
+ /**
3089
+ * Finish first-time TOTP setup: commit the secret generated by `beginTotp`
3090
+ * against a 6-digit code from the user's authenticator app.
3091
+ *
3092
+ * `PUT /user/2fa/totp/verify`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3093
+ */
3094
+ updateTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>>;
3095
+ /**
3096
+ * Complete the TOTP step and advance to the next flow stage (e.g.
3097
+ * `reset_password`). Returns a fresh single-purpose token with the
3098
+ * next `token_type`.
3099
+ *
3100
+ * `GET /user/2fa/terminate`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.
3101
+ */
3102
+ terminate2fa(query?: Terminate2faQueryParams): Promise<TokenResponse>;
3043
3103
  /** Create auth method. `POST /user/auth` */
3044
3104
  createAuthMethod(params: Record<string, unknown>): Promise<Record<string, unknown>>;
3045
3105
  /** Update auth method. `PUT /user/auth` */
@@ -3545,4 +3605,4 @@ declare const Webhooks: {
3545
3605
  verify(rawBody: string, signatureHeader: string, secret: string, options?: VerifyOptions): Promise<WebhookEvent>;
3546
3606
  };
3547
3607
 
3548
- export { type Address, type AddressDetails, type AdminAdjustmentRequest, type AdminAdjustmentResponse, type AdminAnalyticsRequest, type AdminCustomerDetail, type AdminCustomerListParams, type AdminCustomerListResponse, type AdminSignInRequest, type AdminTransactionListParams, type AdminTransactionListResponse, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, AnalyticsDashboard, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuditLogListParams, type AuditLogListResponse, type AuditLogResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AuthorizeResponse, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, Cache, type CaptureMethod, type CardDetail, type CardDetailFromLocker, type CardIssuerCreateRequest, type CardIssuerListResponse, type CardIssuerResponse, type CardIssuerUpdateRequest, Cards, type ChangePasswordRequest, Configs, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type CreateInternalUserRequest, type CreateTenantUserRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerSummary, type CustomerUpdateRequest, type CustomerUser, type DashboardMetadataResponse, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeType, Files, Forex, type ForgotPasswordRequest, type GatewayConnectRequest, type GatewayResponse, type GsmDecision, type GsmRuleCreateRequest, type GsmRuleResponse, type GsmRuleUpdateRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LedgerEntry, type LedgerListParams, type LedgerResponse, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type OnboardMerchantRequest, type OnboardMerchantResponse, type OverviewStat, type OverviewStatsResponse, type PaymentAnalyticsRequest, type PaymentAnalyticsResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentStat, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformAnalyticsResponse, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCreateRequest, type RegionResponse, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestFn, type RequestOptions, type ResetPasswordRequest, type RoutingConfigCreateRequest, type RoutingConfigResponse, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SignupToggleRequest, type SignupToggleResponse, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SwitchMerchantRequest, type SwitchProfileRequest, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type UpdateUserDetailsRequest, type UserResponse, type VerifyOptions, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks };
3608
+ export { type Address, type AddressDetails, type AdminAdjustmentRequest, type AdminAdjustmentResponse, type AdminAnalyticsRequest, type AdminCustomerDetail, type AdminCustomerListParams, type AdminCustomerListResponse, type AdminSignInRequest, type AdminTransactionListParams, type AdminTransactionListResponse, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, AnalyticsDashboard, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuditLogListParams, type AuditLogListResponse, type AuditLogResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AuthorizeResponse, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, Cache, type CaptureMethod, type CardDetail, type CardDetailFromLocker, type CardIssuerCreateRequest, type CardIssuerListResponse, type CardIssuerResponse, type CardIssuerUpdateRequest, Cards, type ChangePasswordRequest, Configs, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type CreateInternalUserRequest, type CreateTenantUserRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerSummary, type CustomerUpdateRequest, type CustomerUser, type DashboardMetadataResponse, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeType, Files, Forex, type ForgotPasswordRequest, type FromEmailRequest, type GatewayConnectRequest, type GatewayResponse, type GsmDecision, type GsmRuleCreateRequest, type GsmRuleResponse, type GsmRuleUpdateRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LedgerEntry, type LedgerListParams, type LedgerResponse, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type OnboardMerchantRequest, type OnboardMerchantResponse, type OverviewStat, type OverviewStatsResponse, type PaymentAnalyticsRequest, type PaymentAnalyticsResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentStat, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformAnalyticsResponse, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCreateRequest, type RegionResponse, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestFn, type RequestOptions, type ResetPasswordRequest, type RoutingConfigCreateRequest, type RoutingConfigResponse, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SignupToggleRequest, type SignupToggleResponse, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type UpdateUserDetailsRequest, type UserResponse, type VerifyOptions, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks };
package/dist/index.js CHANGED
@@ -2030,31 +2030,29 @@ 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 email link token.
2033
+ * Commit a password reset.
2034
2034
  *
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).
2035
+ * The caller is responsible for obtaining a `SinglePurposeToken` with
2036
+ * `purpose: reset_password` via the email-token exchange + TOTP flow
2037
+ * (see `fromEmail`, `beginTotp`, `updateTotp`/`verifyTotp`,
2038
+ * `generateRecoveryCodes`, `terminate2fa`) and setting it on the client
2039
+ * via `setJwtToken` before calling this method. `body.token` must still
2040
+ * be the original `EmailToken` from the reset-link URL — the handler
2041
+ * decodes it a second time to find the user
2042
+ * (`delopay-backend/crates/router/src/core/user.rs:687`).
2047
2043
  */
2048
2044
  async resetPassword(params) {
2049
- const exchange = await this.request(
2050
- "POST",
2051
- "/user/from_email",
2052
- { body: { token: params.token } }
2053
- );
2054
- return this.request("POST", "/user/reset_password", {
2055
- body: { token: params.token, password: params.password },
2056
- headers: { Authorization: `Bearer ${exchange.token}` }
2057
- });
2045
+ return this.request("POST", "/user/reset_password", { body: params });
2046
+ }
2047
+ /**
2048
+ * Exchange an email-link token (`EmailToken`) for a single-purpose JWT
2049
+ * that drives the next step of the flow (TOTP, verify email, accept
2050
+ * invitation, etc.). No authentication required.
2051
+ *
2052
+ * The `token_type` in the response tells you which step to run next.
2053
+ */
2054
+ async fromEmail(params) {
2055
+ return this.request("POST", "/user/from_email", { body: params });
2058
2056
  }
2059
2057
  async verifyEmail(params) {
2060
2058
  return this.request("POST", "/user/verify_email", { body: params });
@@ -2083,9 +2081,24 @@ var Users = class {
2083
2081
  async acceptInvitation(params) {
2084
2082
  return this.request("POST", "/user/user/invite/accept", { body: params });
2085
2083
  }
2084
+ /**
2085
+ * Start TOTP setup (or no-op if already set).
2086
+ *
2087
+ * Returns the QR-code payload when the user has no TOTP configured yet;
2088
+ * returns `{ secret: null }` when the user is already set up (caller
2089
+ * should then prompt for a 6-digit code and call `verifyTotp`).
2090
+ *
2091
+ * Requires `Authorization: Bearer <SPT{purpose:totp}>`.
2092
+ */
2086
2093
  async beginTotp() {
2087
2094
  return this.request("GET", "/user/2fa/totp/begin");
2088
2095
  }
2096
+ /**
2097
+ * Verify a 6-digit TOTP code for a user whose TOTP is already set up.
2098
+ * Marks the code as used in Redis so subsequent flow steps can advance.
2099
+ *
2100
+ * Requires `Authorization: Bearer <SPT{purpose:totp}>`.
2101
+ */
2089
2102
  async verifyTotp(params) {
2090
2103
  return this.request("POST", "/user/2fa/totp/verify", { body: params });
2091
2104
  }
@@ -2152,13 +2165,29 @@ var Users = class {
2152
2165
  async check2faStatusV2() {
2153
2166
  return this.request("GET", "/user/2fa/v2");
2154
2167
  }
2155
- /** Update TOTP. `PUT /user/2fa/totp/verify` */
2168
+ /**
2169
+ * Finish first-time TOTP setup: commit the secret generated by `beginTotp`
2170
+ * against a 6-digit code from the user's authenticator app.
2171
+ *
2172
+ * `PUT /user/2fa/totp/verify`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.
2173
+ */
2156
2174
  async updateTotp(params) {
2157
2175
  return this.request("PUT", "/user/2fa/totp/verify", { body: params });
2158
2176
  }
2159
- /** Terminate 2FA. `GET /user/2fa/terminate` */
2160
- async terminate2fa() {
2161
- return this.request("GET", "/user/2fa/terminate");
2177
+ /**
2178
+ * Complete the TOTP step and advance to the next flow stage (e.g.
2179
+ * `reset_password`). Returns a fresh single-purpose token with the
2180
+ * next `token_type`.
2181
+ *
2182
+ * `GET /user/2fa/terminate`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.
2183
+ */
2184
+ async terminate2fa(query) {
2185
+ if (query === void 0) {
2186
+ return this.request("GET", "/user/2fa/terminate");
2187
+ }
2188
+ return this.request("GET", "/user/2fa/terminate", {
2189
+ query
2190
+ });
2162
2191
  }
2163
2192
  /** Create auth method. `POST /user/auth` */
2164
2193
  async createAuthMethod(params) {