@delopay/sdk 0.20.0 → 0.21.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
@@ -1358,6 +1358,102 @@ interface Terminate2faQueryParams {
1358
1358
  */
1359
1359
  skip_two_factor_auth?: boolean;
1360
1360
  }
1361
+ /**
1362
+ * Optional query for `GET /user/me/login-activity`. Backend clamps `limit`
1363
+ * to `1..=200` (default 25) and floors `offset` at 0 (default 0).
1364
+ */
1365
+ interface LoginHistoryParams {
1366
+ limit?: number;
1367
+ offset?: number;
1368
+ }
1369
+ /**
1370
+ * One row from the authenticated user's login history.
1371
+ *
1372
+ * `event_type` enumerates the signin attempt outcome — current values:
1373
+ * `signin_success`, `signin_failure`, `signup_success`, `sso_success`,
1374
+ * `sso_failure`, `totp_success`, `totp_failure`, `recovery_code_success`,
1375
+ * `recovery_code_failure`, `magic_link_success`. Stored as a string so
1376
+ * older rows stay readable when the enum grows.
1377
+ *
1378
+ * `failure_reason` is set on failure rows. Current values:
1379
+ * `user_not_found`, `invalid_credentials`, `totp_invalid`,
1380
+ * `totp_max_attempts`, `recovery_code_invalid`, `not_in_admin_org`,
1381
+ * `rate_limited`, `other`.
1382
+ *
1383
+ * `auth_method` tells the dashboard how the attempt authenticated:
1384
+ * `password`, `magic_link`, `sso_oidc`, `totp`, `recovery_code`.
1385
+ *
1386
+ * Geo fields (`country_code`, `city`, `latitude`, `longitude`) are populated
1387
+ * by an offline MaxMind GeoLite2-City lookup at signin time. They stay
1388
+ * `null` for private/loopback IPs, when the lookup misses, or when the
1389
+ * GeoIP service is disabled in backend config.
1390
+ */
1391
+ interface LoginHistoryEntry {
1392
+ id: string;
1393
+ event_type: string;
1394
+ failure_reason: string | null;
1395
+ auth_method: string;
1396
+ ip_address: string | null;
1397
+ user_agent: string | null;
1398
+ country_code: string | null;
1399
+ city: string | null;
1400
+ latitude: number | null;
1401
+ longitude: number | null;
1402
+ /** ISO-8601 timestamp the row was inserted (signin attempt time). */
1403
+ created_at: string;
1404
+ }
1405
+ /**
1406
+ * Response shape for `GET /user/me/login-activity`. `total_count` is the
1407
+ * unpaginated row count for client-side page-count calculation.
1408
+ *
1409
+ * When the authenticated user is a Delopay admin currently impersonating
1410
+ * a non-admin merchant via `switch_merchant_for_user_in_org`, the backend
1411
+ * returns `entries: []` and `total_count: 0` so the admin's IP / geo
1412
+ * doesn't render inside the merchant dashboard. The admin can still see
1413
+ * their real activity by switching back to the admin organization.
1414
+ */
1415
+ interface LoginHistoryResponse {
1416
+ entries: LoginHistoryEntry[];
1417
+ total_count: number;
1418
+ offset: number;
1419
+ limit: number;
1420
+ }
1421
+ /**
1422
+ * One row from `GET /user/me/sessions` (issue #118).
1423
+ *
1424
+ * A session is one minted login JWT. `id` is also the JWT's `jti`. The
1425
+ * row is mutable: `last_seen_at` is updated as the session makes API
1426
+ * calls (debounced to one DB write per 5 min), and `revoked_at` is set
1427
+ * when the user disconnects this session from the dashboard.
1428
+ *
1429
+ * `auth_method` enumerates the signin method that produced the session.
1430
+ * Today only `password` issues sessions; SSO / TOTP / recovery will follow.
1431
+ *
1432
+ * `is_current` is `true` for the row corresponding to the JWT used to
1433
+ * make the listing request — the dashboard renders a "This device" tag
1434
+ * and asks for confirmation before letting the user disconnect it.
1435
+ */
1436
+ interface UserSessionEntry {
1437
+ id: string;
1438
+ auth_method: string;
1439
+ ip_address: string | null;
1440
+ user_agent: string | null;
1441
+ country_code: string | null;
1442
+ city: string | null;
1443
+ /** ISO-8601 timestamp the session was created (signin time). */
1444
+ created_at: string;
1445
+ /** ISO-8601 timestamp of the most recent observed API call on this session. */
1446
+ last_seen_at: string;
1447
+ /** ISO-8601 timestamp at which the session JWT exp lapses. */
1448
+ expires_at: string;
1449
+ is_current: boolean;
1450
+ }
1451
+ interface UserSessionListResponse {
1452
+ sessions: UserSessionEntry[];
1453
+ }
1454
+ interface UserSessionRevokeResponse {
1455
+ revoked: boolean;
1456
+ }
1361
1457
  /** Optional query params for `GET /user/role/list/invite`. */
1362
1458
  interface ListInvitableRolesParams {
1363
1459
  /**
@@ -2950,6 +3046,44 @@ declare class Users {
2950
3046
  signUp(params: SignUpRequest | SignUpWithMerchantRequest): Promise<AuthResponse>;
2951
3047
  signIn(params: SignInRequest): Promise<AuthResponse>;
2952
3048
  signOut(): Promise<Record<string, unknown>>;
3049
+ /**
3050
+ * Paginated login history for the authenticated user — IP, User-Agent,
3051
+ * country / city / lat-lon (when GeoIP is enabled in backend), success
3052
+ * and failure events with their reasons. Strictly scoped to the JWT
3053
+ * subject; a user can only see their own activity.
3054
+ *
3055
+ * `GET /user/me/login-activity`. Requires a logged-in JWT.
3056
+ *
3057
+ * The backend returns an empty page when a Delopay admin is impersonating
3058
+ * a non-admin merchant, so the admin's metadata never renders inside the
3059
+ * merchant dashboard.
3060
+ */
3061
+ listLoginActivity(params?: LoginHistoryParams): Promise<LoginHistoryResponse>;
3062
+ /**
3063
+ * List the authenticated user's currently-active dashboard sessions
3064
+ * (one row per minted login JWT that hasn't been revoked or expired).
3065
+ *
3066
+ * The row matching the JWT making this call has `is_current: true`,
3067
+ * which is what lets the dashboard render a "This device" tag.
3068
+ *
3069
+ * `GET /user/me/sessions`. Requires a logged-in JWT. Returns an empty
3070
+ * list when a Delopay admin is impersonating a non-admin merchant
3071
+ * (same guard as `listLoginActivity`).
3072
+ */
3073
+ listActiveSessions(): Promise<UserSessionListResponse>;
3074
+ /**
3075
+ * Disconnect one of the authenticated user's sessions. The matching
3076
+ * JWT is rejected on its next request — fast-path via Redis, fall back
3077
+ * to the persistent `revoked_at` column.
3078
+ *
3079
+ * Idempotent: revoking an already-revoked or unknown id returns 404,
3080
+ * which the caller can treat as success for retry purposes. Revoking
3081
+ * a session id that belongs to a different user also returns 404 —
3082
+ * the response intentionally doesn't leak whether the id exists.
3083
+ *
3084
+ * `POST /user/me/sessions/{sessionId}/revoke`.
3085
+ */
3086
+ revokeSession(sessionId: string): Promise<UserSessionRevokeResponse>;
2953
3087
  getDetails(): Promise<UserResponse>;
2954
3088
  update(params: UpdateUserDetailsRequest): Promise<UserResponse>;
2955
3089
  changePassword(params: ChangePasswordRequest): Promise<UserResponse>;
@@ -3675,4 +3809,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
3675
3809
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
3676
3810
  declare function shadowFor(style: SurfaceStyle): string;
3677
3811
 
3678
- export { type Address, type AddressDetails, 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 AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, 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, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type GatewayConnectRequest, type GatewayResponse, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type NonPillRadius, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, 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 PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileLogoUploadResponse, 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 RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SummaryPosition, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateUserDetailsRequest, type UserResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
3812
+ export { type Address, type AddressDetails, 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 AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, 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, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type GatewayConnectRequest, type GatewayResponse, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type NonPillRadius, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, 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 PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileLogoUploadResponse, 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 RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SummaryPosition, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
package/dist/index.d.ts CHANGED
@@ -1358,6 +1358,102 @@ interface Terminate2faQueryParams {
1358
1358
  */
1359
1359
  skip_two_factor_auth?: boolean;
1360
1360
  }
1361
+ /**
1362
+ * Optional query for `GET /user/me/login-activity`. Backend clamps `limit`
1363
+ * to `1..=200` (default 25) and floors `offset` at 0 (default 0).
1364
+ */
1365
+ interface LoginHistoryParams {
1366
+ limit?: number;
1367
+ offset?: number;
1368
+ }
1369
+ /**
1370
+ * One row from the authenticated user's login history.
1371
+ *
1372
+ * `event_type` enumerates the signin attempt outcome — current values:
1373
+ * `signin_success`, `signin_failure`, `signup_success`, `sso_success`,
1374
+ * `sso_failure`, `totp_success`, `totp_failure`, `recovery_code_success`,
1375
+ * `recovery_code_failure`, `magic_link_success`. Stored as a string so
1376
+ * older rows stay readable when the enum grows.
1377
+ *
1378
+ * `failure_reason` is set on failure rows. Current values:
1379
+ * `user_not_found`, `invalid_credentials`, `totp_invalid`,
1380
+ * `totp_max_attempts`, `recovery_code_invalid`, `not_in_admin_org`,
1381
+ * `rate_limited`, `other`.
1382
+ *
1383
+ * `auth_method` tells the dashboard how the attempt authenticated:
1384
+ * `password`, `magic_link`, `sso_oidc`, `totp`, `recovery_code`.
1385
+ *
1386
+ * Geo fields (`country_code`, `city`, `latitude`, `longitude`) are populated
1387
+ * by an offline MaxMind GeoLite2-City lookup at signin time. They stay
1388
+ * `null` for private/loopback IPs, when the lookup misses, or when the
1389
+ * GeoIP service is disabled in backend config.
1390
+ */
1391
+ interface LoginHistoryEntry {
1392
+ id: string;
1393
+ event_type: string;
1394
+ failure_reason: string | null;
1395
+ auth_method: string;
1396
+ ip_address: string | null;
1397
+ user_agent: string | null;
1398
+ country_code: string | null;
1399
+ city: string | null;
1400
+ latitude: number | null;
1401
+ longitude: number | null;
1402
+ /** ISO-8601 timestamp the row was inserted (signin attempt time). */
1403
+ created_at: string;
1404
+ }
1405
+ /**
1406
+ * Response shape for `GET /user/me/login-activity`. `total_count` is the
1407
+ * unpaginated row count for client-side page-count calculation.
1408
+ *
1409
+ * When the authenticated user is a Delopay admin currently impersonating
1410
+ * a non-admin merchant via `switch_merchant_for_user_in_org`, the backend
1411
+ * returns `entries: []` and `total_count: 0` so the admin's IP / geo
1412
+ * doesn't render inside the merchant dashboard. The admin can still see
1413
+ * their real activity by switching back to the admin organization.
1414
+ */
1415
+ interface LoginHistoryResponse {
1416
+ entries: LoginHistoryEntry[];
1417
+ total_count: number;
1418
+ offset: number;
1419
+ limit: number;
1420
+ }
1421
+ /**
1422
+ * One row from `GET /user/me/sessions` (issue #118).
1423
+ *
1424
+ * A session is one minted login JWT. `id` is also the JWT's `jti`. The
1425
+ * row is mutable: `last_seen_at` is updated as the session makes API
1426
+ * calls (debounced to one DB write per 5 min), and `revoked_at` is set
1427
+ * when the user disconnects this session from the dashboard.
1428
+ *
1429
+ * `auth_method` enumerates the signin method that produced the session.
1430
+ * Today only `password` issues sessions; SSO / TOTP / recovery will follow.
1431
+ *
1432
+ * `is_current` is `true` for the row corresponding to the JWT used to
1433
+ * make the listing request — the dashboard renders a "This device" tag
1434
+ * and asks for confirmation before letting the user disconnect it.
1435
+ */
1436
+ interface UserSessionEntry {
1437
+ id: string;
1438
+ auth_method: string;
1439
+ ip_address: string | null;
1440
+ user_agent: string | null;
1441
+ country_code: string | null;
1442
+ city: string | null;
1443
+ /** ISO-8601 timestamp the session was created (signin time). */
1444
+ created_at: string;
1445
+ /** ISO-8601 timestamp of the most recent observed API call on this session. */
1446
+ last_seen_at: string;
1447
+ /** ISO-8601 timestamp at which the session JWT exp lapses. */
1448
+ expires_at: string;
1449
+ is_current: boolean;
1450
+ }
1451
+ interface UserSessionListResponse {
1452
+ sessions: UserSessionEntry[];
1453
+ }
1454
+ interface UserSessionRevokeResponse {
1455
+ revoked: boolean;
1456
+ }
1361
1457
  /** Optional query params for `GET /user/role/list/invite`. */
1362
1458
  interface ListInvitableRolesParams {
1363
1459
  /**
@@ -2950,6 +3046,44 @@ declare class Users {
2950
3046
  signUp(params: SignUpRequest | SignUpWithMerchantRequest): Promise<AuthResponse>;
2951
3047
  signIn(params: SignInRequest): Promise<AuthResponse>;
2952
3048
  signOut(): Promise<Record<string, unknown>>;
3049
+ /**
3050
+ * Paginated login history for the authenticated user — IP, User-Agent,
3051
+ * country / city / lat-lon (when GeoIP is enabled in backend), success
3052
+ * and failure events with their reasons. Strictly scoped to the JWT
3053
+ * subject; a user can only see their own activity.
3054
+ *
3055
+ * `GET /user/me/login-activity`. Requires a logged-in JWT.
3056
+ *
3057
+ * The backend returns an empty page when a Delopay admin is impersonating
3058
+ * a non-admin merchant, so the admin's metadata never renders inside the
3059
+ * merchant dashboard.
3060
+ */
3061
+ listLoginActivity(params?: LoginHistoryParams): Promise<LoginHistoryResponse>;
3062
+ /**
3063
+ * List the authenticated user's currently-active dashboard sessions
3064
+ * (one row per minted login JWT that hasn't been revoked or expired).
3065
+ *
3066
+ * The row matching the JWT making this call has `is_current: true`,
3067
+ * which is what lets the dashboard render a "This device" tag.
3068
+ *
3069
+ * `GET /user/me/sessions`. Requires a logged-in JWT. Returns an empty
3070
+ * list when a Delopay admin is impersonating a non-admin merchant
3071
+ * (same guard as `listLoginActivity`).
3072
+ */
3073
+ listActiveSessions(): Promise<UserSessionListResponse>;
3074
+ /**
3075
+ * Disconnect one of the authenticated user's sessions. The matching
3076
+ * JWT is rejected on its next request — fast-path via Redis, fall back
3077
+ * to the persistent `revoked_at` column.
3078
+ *
3079
+ * Idempotent: revoking an already-revoked or unknown id returns 404,
3080
+ * which the caller can treat as success for retry purposes. Revoking
3081
+ * a session id that belongs to a different user also returns 404 —
3082
+ * the response intentionally doesn't leak whether the id exists.
3083
+ *
3084
+ * `POST /user/me/sessions/{sessionId}/revoke`.
3085
+ */
3086
+ revokeSession(sessionId: string): Promise<UserSessionRevokeResponse>;
2953
3087
  getDetails(): Promise<UserResponse>;
2954
3088
  update(params: UpdateUserDetailsRequest): Promise<UserResponse>;
2955
3089
  changePassword(params: ChangePasswordRequest): Promise<UserResponse>;
@@ -3675,4 +3809,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
3675
3809
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
3676
3810
  declare function shadowFor(style: SurfaceStyle): string;
3677
3811
 
3678
- export { type Address, type AddressDetails, 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 AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, 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, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type GatewayConnectRequest, type GatewayResponse, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type NonPillRadius, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, 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 PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileLogoUploadResponse, 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 RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SummaryPosition, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateUserDetailsRequest, type UserResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
3812
+ export { type Address, type AddressDetails, 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 AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, 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, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type GatewayConnectRequest, type GatewayResponse, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type NonPillRadius, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, 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 PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileLogoUploadResponse, 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 RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionCreateRequest, type SubscriptionListParams, type SubscriptionListResponse, type SubscriptionResponse, type SubscriptionUpdateRequest, Subscriptions, type SummaryPosition, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
package/dist/index.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  shadowFor,
41
41
  surfacePadValue,
42
42
  verticalGapValue
43
- } from "./chunk-QGQR2OBR.js";
43
+ } from "./chunk-EPZVT7EJ.js";
44
44
  export {
45
45
  Analytics,
46
46
  AnalyticsDashboard,
package/dist/internal.cjs CHANGED
@@ -1958,6 +1958,55 @@ var Users = class {
1958
1958
  async signOut() {
1959
1959
  return this.request("POST", "/user/signout");
1960
1960
  }
1961
+ /**
1962
+ * Paginated login history for the authenticated user — IP, User-Agent,
1963
+ * country / city / lat-lon (when GeoIP is enabled in backend), success
1964
+ * and failure events with their reasons. Strictly scoped to the JWT
1965
+ * subject; a user can only see their own activity.
1966
+ *
1967
+ * `GET /user/me/login-activity`. Requires a logged-in JWT.
1968
+ *
1969
+ * The backend returns an empty page when a Delopay admin is impersonating
1970
+ * a non-admin merchant, so the admin's metadata never renders inside the
1971
+ * merchant dashboard.
1972
+ */
1973
+ async listLoginActivity(params) {
1974
+ if (params === void 0) {
1975
+ return this.request("GET", "/user/me/login-activity");
1976
+ }
1977
+ return this.request("GET", "/user/me/login-activity", {
1978
+ query: params
1979
+ });
1980
+ }
1981
+ /**
1982
+ * List the authenticated user's currently-active dashboard sessions
1983
+ * (one row per minted login JWT that hasn't been revoked or expired).
1984
+ *
1985
+ * The row matching the JWT making this call has `is_current: true`,
1986
+ * which is what lets the dashboard render a "This device" tag.
1987
+ *
1988
+ * `GET /user/me/sessions`. Requires a logged-in JWT. Returns an empty
1989
+ * list when a Delopay admin is impersonating a non-admin merchant
1990
+ * (same guard as `listLoginActivity`).
1991
+ */
1992
+ async listActiveSessions() {
1993
+ return this.request("GET", "/user/me/sessions");
1994
+ }
1995
+ /**
1996
+ * Disconnect one of the authenticated user's sessions. The matching
1997
+ * JWT is rejected on its next request — fast-path via Redis, fall back
1998
+ * to the persistent `revoked_at` column.
1999
+ *
2000
+ * Idempotent: revoking an already-revoked or unknown id returns 404,
2001
+ * which the caller can treat as success for retry purposes. Revoking
2002
+ * a session id that belongs to a different user also returns 404 —
2003
+ * the response intentionally doesn't leak whether the id exists.
2004
+ *
2005
+ * `POST /user/me/sessions/{sessionId}/revoke`.
2006
+ */
2007
+ async revokeSession(sessionId) {
2008
+ return this.request("POST", `/user/me/sessions/${encodeURIComponent(sessionId)}/revoke`);
2009
+ }
1961
2010
  async getDetails() {
1962
2011
  return this.request("GET", "/user");
1963
2012
  }