@mitumba/sdk 5.0.0 → 5.1.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.mts +126 -1
- package/dist/index.d.ts +126 -1
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1356,6 +1356,66 @@ interface RootSetupResult {
|
|
|
1356
1356
|
permissions: AdminPermission[];
|
|
1357
1357
|
next_step: string;
|
|
1358
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Request body for the authorize (mint) step. The accounts app calls this once the user is
|
|
1361
|
+
* authenticated to mint a one-time authorization code for the relying party.
|
|
1362
|
+
*
|
|
1363
|
+
* The SDK always sets `code_challenge_method: 'S256'` internally, so callers never supply it.
|
|
1364
|
+
*/
|
|
1365
|
+
interface OAuthAuthorizeInput {
|
|
1366
|
+
/** The relying party's registered client identifier. */
|
|
1367
|
+
client_id: string;
|
|
1368
|
+
/** The registered redirect URI the one-time code is returned to. */
|
|
1369
|
+
redirect_uri: string;
|
|
1370
|
+
/** Optional space-delimited list of requested scopes. */
|
|
1371
|
+
scope?: string;
|
|
1372
|
+
/** Opaque value echoed back unchanged, used by the relying party for CSRF protection. */
|
|
1373
|
+
state: string;
|
|
1374
|
+
/** The PKCE code challenge (base64url SHA-256 of the verifier). */
|
|
1375
|
+
code_challenge: string;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Result of the authorize (mint) step: a one-time authorization code plus the echoed state.
|
|
1379
|
+
*/
|
|
1380
|
+
interface OAuthAuthorizeResult {
|
|
1381
|
+
/** One-time authorization code to redirect back to the relying party. */
|
|
1382
|
+
code: string;
|
|
1383
|
+
/** The `state` value supplied in the request, echoed back unchanged. */
|
|
1384
|
+
state: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Request body for the token exchange step. The relying party exchanges the one-time code for a
|
|
1388
|
+
* token pair. `grant_type` is set to `'authorization_code'` by the SDK, so callers need not pass it.
|
|
1389
|
+
*/
|
|
1390
|
+
interface OAuthTokenExchangeInput {
|
|
1391
|
+
/** Always `'authorization_code'`. Defaulted by the SDK; callers may omit it. */
|
|
1392
|
+
grant_type?: 'authorization_code';
|
|
1393
|
+
/** The one-time authorization code returned by the authorize step. */
|
|
1394
|
+
code: string;
|
|
1395
|
+
/** The redirect URI used in the authorize step; must match exactly. */
|
|
1396
|
+
redirect_uri: string;
|
|
1397
|
+
/** The relying party's registered client identifier. */
|
|
1398
|
+
client_id: string;
|
|
1399
|
+
/** The PKCE code verifier that matches the earlier code challenge. */
|
|
1400
|
+
code_verifier: string;
|
|
1401
|
+
/** The client secret for confidential clients. Omit for public clients. */
|
|
1402
|
+
client_secret?: string;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Result of a successful token exchange: the access/refresh token pair and its metadata.
|
|
1406
|
+
*/
|
|
1407
|
+
interface OAuthTokenResult {
|
|
1408
|
+
/** The access token (JWT) for authenticated requests. */
|
|
1409
|
+
access_token: string;
|
|
1410
|
+
/** The refresh token used to rotate the access token. */
|
|
1411
|
+
refresh_token: string;
|
|
1412
|
+
/** Lifetime of the access token in seconds. */
|
|
1413
|
+
expires_in: number;
|
|
1414
|
+
/** Always `'Bearer'`. */
|
|
1415
|
+
token_type: 'Bearer';
|
|
1416
|
+
/** Space-delimited list of scopes actually granted. */
|
|
1417
|
+
scope: string;
|
|
1418
|
+
}
|
|
1359
1419
|
|
|
1360
1420
|
declare const CONDITIONS: readonly ["new", "like_new", "good", "fair"];
|
|
1361
1421
|
type Condition = typeof CONDITIONS[number];
|
|
@@ -2623,6 +2683,70 @@ declare class AuthModule {
|
|
|
2623
2683
|
}>;
|
|
2624
2684
|
}
|
|
2625
2685
|
|
|
2686
|
+
/**
|
|
2687
|
+
* Relying-party OAuth session hand-off.
|
|
2688
|
+
*
|
|
2689
|
+
* Wraps the authorization-code + PKCE flow: the accounts app mints a one-time code with
|
|
2690
|
+
* {@link OAuthModule.authorize}, redirects it back to the relying party, and the relying party
|
|
2691
|
+
* exchanges it for a token pair with {@link OAuthModule.exchangeCode}.
|
|
2692
|
+
*/
|
|
2693
|
+
declare class OAuthModule {
|
|
2694
|
+
private readonly client;
|
|
2695
|
+
constructor(client: APIClient);
|
|
2696
|
+
/**
|
|
2697
|
+
* Mint a one-time authorization code for the relying party.
|
|
2698
|
+
*
|
|
2699
|
+
* This is the authenticated mint step the accounts app calls after the user is signed in. It
|
|
2700
|
+
* returns a one-time code (plus the echoed `state`) that the app then redirects back to the
|
|
2701
|
+
* relying party's `redirect_uri`. The PKCE method is fixed to `'S256'` by the SDK, so callers
|
|
2702
|
+
* cannot supply a weaker value. The returned code is not a session — this method does not
|
|
2703
|
+
* persist anything.
|
|
2704
|
+
*
|
|
2705
|
+
* @param input - The authorize request (client, redirect URI, state, PKCE challenge, scope)
|
|
2706
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
2707
|
+
* @returns The one-time authorization code and the echoed `state`
|
|
2708
|
+
* @throws {APIError} On `400` (`invalid_redirect_uri`, `invalid_client`, `invalid_scope`) or other errors
|
|
2709
|
+
*
|
|
2710
|
+
* @example
|
|
2711
|
+
* ```typescript
|
|
2712
|
+
* const { code, state } = await sdk.oauth.authorize({
|
|
2713
|
+
* client_id: 'rp_abc',
|
|
2714
|
+
* redirect_uri: 'https://app.example.com/callback',
|
|
2715
|
+
* scope: 'profile email',
|
|
2716
|
+
* state: csrfState,
|
|
2717
|
+
* code_challenge: challenge,
|
|
2718
|
+
* })
|
|
2719
|
+
* ```
|
|
2720
|
+
*/
|
|
2721
|
+
authorize(input: OAuthAuthorizeInput, options?: RequestOptions): Promise<OAuthAuthorizeResult>;
|
|
2722
|
+
/**
|
|
2723
|
+
* Exchange a one-time authorization code for a token pair.
|
|
2724
|
+
*
|
|
2725
|
+
* The relying party calls this server-to-server (or from its own origin) with the PKCE verifier
|
|
2726
|
+
* that matches the earlier challenge. The authorization code is single-use — a reused, expired,
|
|
2727
|
+
* or tampered code is rejected with `400 invalid_grant`. On success the returned tokens are
|
|
2728
|
+
* persisted into the client session via `setSession`, so the relying party is logged in
|
|
2729
|
+
* immediately after the exchange. `grant_type` is set to `'authorization_code'` by the SDK.
|
|
2730
|
+
*
|
|
2731
|
+
* @param input - The token exchange request (code, redirect URI, client, PKCE verifier, optional secret)
|
|
2732
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
2733
|
+
* @returns The access/refresh token pair and granted scope
|
|
2734
|
+
* @throws {APIError} On `400 invalid_grant` (bad/expired/replayed code) or `401 invalid_client` (wrong secret)
|
|
2735
|
+
*
|
|
2736
|
+
* @example
|
|
2737
|
+
* ```typescript
|
|
2738
|
+
* const tokens = await sdk.oauth.exchangeCode({
|
|
2739
|
+
* code,
|
|
2740
|
+
* redirect_uri: 'https://app.example.com/callback',
|
|
2741
|
+
* client_id: 'rp_abc',
|
|
2742
|
+
* code_verifier: verifier,
|
|
2743
|
+
* })
|
|
2744
|
+
* // sdk is now authenticated as the exchanged session
|
|
2745
|
+
* ```
|
|
2746
|
+
*/
|
|
2747
|
+
exchangeCode(input: OAuthTokenExchangeInput, options?: RequestOptions): Promise<OAuthTokenResult>;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2626
2750
|
declare class ListingsModule {
|
|
2627
2751
|
private readonly client;
|
|
2628
2752
|
constructor(client: APIClient);
|
|
@@ -3750,6 +3874,7 @@ declare function baleShareUrl(baleId: string, options?: ShareUrlOptions): string
|
|
|
3750
3874
|
declare class MitumbaClient {
|
|
3751
3875
|
readonly api: APIClient;
|
|
3752
3876
|
readonly auth: AuthModule;
|
|
3877
|
+
readonly oauth: OAuthModule;
|
|
3753
3878
|
readonly listings: ListingsModule;
|
|
3754
3879
|
readonly search: SearchModule;
|
|
3755
3880
|
readonly orders: OrdersModule;
|
|
@@ -3800,4 +3925,4 @@ declare class MitumbaClient {
|
|
|
3800
3925
|
isAuthenticated(): Promise<boolean>;
|
|
3801
3926
|
}
|
|
3802
3927
|
|
|
3803
|
-
export { APIClient, APIError, type APIErrorResponse, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, ORDER_STATUSES, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, baleShareUrl, createTokenStore, isMessagingAPIError, listingShareUrl, storeShareUrl };
|
|
3928
|
+
export { APIClient, APIError, type APIErrorResponse, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, baleShareUrl, createTokenStore, isMessagingAPIError, listingShareUrl, storeShareUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -1356,6 +1356,66 @@ interface RootSetupResult {
|
|
|
1356
1356
|
permissions: AdminPermission[];
|
|
1357
1357
|
next_step: string;
|
|
1358
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Request body for the authorize (mint) step. The accounts app calls this once the user is
|
|
1361
|
+
* authenticated to mint a one-time authorization code for the relying party.
|
|
1362
|
+
*
|
|
1363
|
+
* The SDK always sets `code_challenge_method: 'S256'` internally, so callers never supply it.
|
|
1364
|
+
*/
|
|
1365
|
+
interface OAuthAuthorizeInput {
|
|
1366
|
+
/** The relying party's registered client identifier. */
|
|
1367
|
+
client_id: string;
|
|
1368
|
+
/** The registered redirect URI the one-time code is returned to. */
|
|
1369
|
+
redirect_uri: string;
|
|
1370
|
+
/** Optional space-delimited list of requested scopes. */
|
|
1371
|
+
scope?: string;
|
|
1372
|
+
/** Opaque value echoed back unchanged, used by the relying party for CSRF protection. */
|
|
1373
|
+
state: string;
|
|
1374
|
+
/** The PKCE code challenge (base64url SHA-256 of the verifier). */
|
|
1375
|
+
code_challenge: string;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Result of the authorize (mint) step: a one-time authorization code plus the echoed state.
|
|
1379
|
+
*/
|
|
1380
|
+
interface OAuthAuthorizeResult {
|
|
1381
|
+
/** One-time authorization code to redirect back to the relying party. */
|
|
1382
|
+
code: string;
|
|
1383
|
+
/** The `state` value supplied in the request, echoed back unchanged. */
|
|
1384
|
+
state: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Request body for the token exchange step. The relying party exchanges the one-time code for a
|
|
1388
|
+
* token pair. `grant_type` is set to `'authorization_code'` by the SDK, so callers need not pass it.
|
|
1389
|
+
*/
|
|
1390
|
+
interface OAuthTokenExchangeInput {
|
|
1391
|
+
/** Always `'authorization_code'`. Defaulted by the SDK; callers may omit it. */
|
|
1392
|
+
grant_type?: 'authorization_code';
|
|
1393
|
+
/** The one-time authorization code returned by the authorize step. */
|
|
1394
|
+
code: string;
|
|
1395
|
+
/** The redirect URI used in the authorize step; must match exactly. */
|
|
1396
|
+
redirect_uri: string;
|
|
1397
|
+
/** The relying party's registered client identifier. */
|
|
1398
|
+
client_id: string;
|
|
1399
|
+
/** The PKCE code verifier that matches the earlier code challenge. */
|
|
1400
|
+
code_verifier: string;
|
|
1401
|
+
/** The client secret for confidential clients. Omit for public clients. */
|
|
1402
|
+
client_secret?: string;
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Result of a successful token exchange: the access/refresh token pair and its metadata.
|
|
1406
|
+
*/
|
|
1407
|
+
interface OAuthTokenResult {
|
|
1408
|
+
/** The access token (JWT) for authenticated requests. */
|
|
1409
|
+
access_token: string;
|
|
1410
|
+
/** The refresh token used to rotate the access token. */
|
|
1411
|
+
refresh_token: string;
|
|
1412
|
+
/** Lifetime of the access token in seconds. */
|
|
1413
|
+
expires_in: number;
|
|
1414
|
+
/** Always `'Bearer'`. */
|
|
1415
|
+
token_type: 'Bearer';
|
|
1416
|
+
/** Space-delimited list of scopes actually granted. */
|
|
1417
|
+
scope: string;
|
|
1418
|
+
}
|
|
1359
1419
|
|
|
1360
1420
|
declare const CONDITIONS: readonly ["new", "like_new", "good", "fair"];
|
|
1361
1421
|
type Condition = typeof CONDITIONS[number];
|
|
@@ -2623,6 +2683,70 @@ declare class AuthModule {
|
|
|
2623
2683
|
}>;
|
|
2624
2684
|
}
|
|
2625
2685
|
|
|
2686
|
+
/**
|
|
2687
|
+
* Relying-party OAuth session hand-off.
|
|
2688
|
+
*
|
|
2689
|
+
* Wraps the authorization-code + PKCE flow: the accounts app mints a one-time code with
|
|
2690
|
+
* {@link OAuthModule.authorize}, redirects it back to the relying party, and the relying party
|
|
2691
|
+
* exchanges it for a token pair with {@link OAuthModule.exchangeCode}.
|
|
2692
|
+
*/
|
|
2693
|
+
declare class OAuthModule {
|
|
2694
|
+
private readonly client;
|
|
2695
|
+
constructor(client: APIClient);
|
|
2696
|
+
/**
|
|
2697
|
+
* Mint a one-time authorization code for the relying party.
|
|
2698
|
+
*
|
|
2699
|
+
* This is the authenticated mint step the accounts app calls after the user is signed in. It
|
|
2700
|
+
* returns a one-time code (plus the echoed `state`) that the app then redirects back to the
|
|
2701
|
+
* relying party's `redirect_uri`. The PKCE method is fixed to `'S256'` by the SDK, so callers
|
|
2702
|
+
* cannot supply a weaker value. The returned code is not a session — this method does not
|
|
2703
|
+
* persist anything.
|
|
2704
|
+
*
|
|
2705
|
+
* @param input - The authorize request (client, redirect URI, state, PKCE challenge, scope)
|
|
2706
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
2707
|
+
* @returns The one-time authorization code and the echoed `state`
|
|
2708
|
+
* @throws {APIError} On `400` (`invalid_redirect_uri`, `invalid_client`, `invalid_scope`) or other errors
|
|
2709
|
+
*
|
|
2710
|
+
* @example
|
|
2711
|
+
* ```typescript
|
|
2712
|
+
* const { code, state } = await sdk.oauth.authorize({
|
|
2713
|
+
* client_id: 'rp_abc',
|
|
2714
|
+
* redirect_uri: 'https://app.example.com/callback',
|
|
2715
|
+
* scope: 'profile email',
|
|
2716
|
+
* state: csrfState,
|
|
2717
|
+
* code_challenge: challenge,
|
|
2718
|
+
* })
|
|
2719
|
+
* ```
|
|
2720
|
+
*/
|
|
2721
|
+
authorize(input: OAuthAuthorizeInput, options?: RequestOptions): Promise<OAuthAuthorizeResult>;
|
|
2722
|
+
/**
|
|
2723
|
+
* Exchange a one-time authorization code for a token pair.
|
|
2724
|
+
*
|
|
2725
|
+
* The relying party calls this server-to-server (or from its own origin) with the PKCE verifier
|
|
2726
|
+
* that matches the earlier challenge. The authorization code is single-use — a reused, expired,
|
|
2727
|
+
* or tampered code is rejected with `400 invalid_grant`. On success the returned tokens are
|
|
2728
|
+
* persisted into the client session via `setSession`, so the relying party is logged in
|
|
2729
|
+
* immediately after the exchange. `grant_type` is set to `'authorization_code'` by the SDK.
|
|
2730
|
+
*
|
|
2731
|
+
* @param input - The token exchange request (code, redirect URI, client, PKCE verifier, optional secret)
|
|
2732
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
2733
|
+
* @returns The access/refresh token pair and granted scope
|
|
2734
|
+
* @throws {APIError} On `400 invalid_grant` (bad/expired/replayed code) or `401 invalid_client` (wrong secret)
|
|
2735
|
+
*
|
|
2736
|
+
* @example
|
|
2737
|
+
* ```typescript
|
|
2738
|
+
* const tokens = await sdk.oauth.exchangeCode({
|
|
2739
|
+
* code,
|
|
2740
|
+
* redirect_uri: 'https://app.example.com/callback',
|
|
2741
|
+
* client_id: 'rp_abc',
|
|
2742
|
+
* code_verifier: verifier,
|
|
2743
|
+
* })
|
|
2744
|
+
* // sdk is now authenticated as the exchanged session
|
|
2745
|
+
* ```
|
|
2746
|
+
*/
|
|
2747
|
+
exchangeCode(input: OAuthTokenExchangeInput, options?: RequestOptions): Promise<OAuthTokenResult>;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2626
2750
|
declare class ListingsModule {
|
|
2627
2751
|
private readonly client;
|
|
2628
2752
|
constructor(client: APIClient);
|
|
@@ -3750,6 +3874,7 @@ declare function baleShareUrl(baleId: string, options?: ShareUrlOptions): string
|
|
|
3750
3874
|
declare class MitumbaClient {
|
|
3751
3875
|
readonly api: APIClient;
|
|
3752
3876
|
readonly auth: AuthModule;
|
|
3877
|
+
readonly oauth: OAuthModule;
|
|
3753
3878
|
readonly listings: ListingsModule;
|
|
3754
3879
|
readonly search: SearchModule;
|
|
3755
3880
|
readonly orders: OrdersModule;
|
|
@@ -3800,4 +3925,4 @@ declare class MitumbaClient {
|
|
|
3800
3925
|
isAuthenticated(): Promise<boolean>;
|
|
3801
3926
|
}
|
|
3802
3927
|
|
|
3803
|
-
export { APIClient, APIError, type APIErrorResponse, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, ORDER_STATUSES, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, baleShareUrl, createTokenStore, isMessagingAPIError, listingShareUrl, storeShareUrl };
|
|
3928
|
+
export { APIClient, APIError, type APIErrorResponse, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddPaymentMethodInput, type Address, type AdminAuditEntry, type AdminAuthStrength, type AdminListingItem, AdminModule, type AdminOperator, type AdminOrderDetail, type AdminOrderListItem, type AdminPayoutItem, type AdminPermission, type AdminPermissionDescription, type AdminRecoveryEvent, type AdminRecoveryRequest, type AdminReport, type AdminRolePreset, type AdminStoreDetail, type AdminStoreListItem, type AdminUserDetail, type AdminUserListItem, type AdminVaziOutfit, type AdminVerificationItem, type AdminWholesalePendingStore, type ApiResponse, type AttachmentDownloadAuthorization, type AttachmentUploadAuthorization, type AttachmentUploadBody, type AttachmentUploadState, type AttachmentUploadStatus, type AuthCapabilities, AuthModule, type AuthTokens, type AuthenticationResponseJSON, BALE_ORDER_STATUSES, type Bale, type BaleDetail, type BaleFeedItem, type BaleFulfillment, type BaleGrade, type BaleImageUploadResult, type BaleOrder, type BaleOrderEvent, type BaleOrderStatus, type BaleType, type BecomeBaleSellerInput, type BecomeSellerInput, type BlockedIp, type Business, type BusinessType, BusinessesModule, type BuyerResolveThreadInput, type BuyerSummary, CONDITIONS, type CartItem, CartModule, type Category, type ChangePasswordInput, type CheckoutNextAction, type CheckoutOrder, type CheckoutPaymentMethod, type CheckoutStatus, type CheckoutStatusResponse, type City, type CompleteOnboardingInput, type CompleteRecoveryResult, type Condition, type Conversation, type ConversationId, type ConversationSummary, type CreateAttachmentUploadInput, type CreateBaleInput, type CreateBaleOrderInput, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateReportInput, type CreateReviewInput, type CreateStoreInput, type CursorPage, DEFAULT_SHARE_ORIGIN, DESIRED_RESOLUTIONS, DISPUTE_REASONS, DISPUTE_STATUSES, type DeliveryAddress, type DesiredResolution, type Dispute, type DisputeEvent, type DisputeEvidence, type DisputeListParams, type DisputeReason, type DisputeStatus, DisputesModule, type EmailLoginInput, type EmailRegisterInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListThreadMessagesParams, type ListThreadsParams, type Listing, type ListingImage, type ListingStatus, type ListingsFeedParams, ListingsModule, type LoginInput, MailerModule, type MailerTemplate, MemoryTokenStore, type Message, type MessageAttachment, type MessageAuthor, type MessageId, type MessagePage, type MessageReportReason, type MessageResponse, MessagesModule, type MessagesRealtimeConnection, type MessagesRealtimeEnvelope, type MessagesRealtimeEvent, type MessagesRealtimeOptions, type MessagesRealtimeState, type MessagesRealtimeTicket, type MessagingBlockInput, type MessagingBlockRemovedResult, type MessagingBlockResult, type MessagingCapabilities, type MessagingCursor, type MessagingErrorCode, type MessagingIdempotentRequestOptions, type MessagingInboxes, type MessagingPerspective, MitumbaClient, type MitumbaClientConfig, type MpesaInput, type Notification, type NotificationPref, type NotificationType, NotificationsModule, type OAuthAuthorizeInput, type OAuthAuthorizeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, PAYMENT_STATUSES, type PaginatedResponse, PayModule, type PaymentAttemptStatus, type PaymentMethod, type PaymentMethodType, type PaymentProvider, type PaymentStatus, type PaymentStatusResponse, type PaystackInitResponse, type PaystackInput, type PendingPayoutApproval, type PhoneLoginInput, type PhoneRegisterInput, type PresignImageResponse, type ProviderId, type PublicKeyCredentialCreationOptionsJSON, type PublicKeyCredentialRequestOptionsJSON, type RaiseDisputeInput, type ReadCursorResult, RealtimeProtocolError, RealtimeUnavailableError, type RecoveryStatus, type RecoveryStatusResult, type RegenerateBackupCodesResult, type RegisterInput, type RegistrationResponseJSON, ReportsModule, type RequestOptions, type RequestRecoveryInput, type RequestRecoveryResult, type ResetPasswordInput, type ResolveDisputeInput, type ResolveThreadResult, type RespondDisputeInput, type Review, type ReviewableOrder, ReviewsModule, type RootSetupInput, type RootSetupResult, type SaveSearchInput, type SaveWholesaleStoreInput, type SearchHistoryItem, SearchModule, type SearchParams, type SearchResult, type SellerProfile, type SellerStorefront, type SellerType, type SendEmailInput, type SendMessageInput, type SendOtpInput, type SendThreadMessageInput, type SendThreadMessageResult, type Session, SettingsModule, type ShareUrlOptions, type SimilarListing, type StiEvent, type StkPushInput, type StkPushResponse, type Store, type StoreAnalytics, type StoreResolveThreadInput, type StoreReviewsPage, type StoreSettings, type StoreStats, type StoreSummary, StoresModule, type SubscriptionTier, type SystemStats, TWO_FACTOR_METHOD_TYPES, type ThreadCard, type ThreadId, type ThreadMessage, type ThreadSubject, type ThreadSystemEvent, type ThreadTimelineItem, type ThreadTimelineItemId, type TokenStore, type TransitionOrderInput, type TrendingTerm, type TwoFactorMethod, type TwoFactorMethodType, type TwoFactorRequired, type UpdateBusinessInput, type UpdateConversationPreferencesInput, type UpdateListingInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, baleShareUrl, createTokenStore, isMessagingAPIError, listingShareUrl, storeShareUrl };
|
package/dist/index.js
CHANGED
|
@@ -678,6 +678,83 @@ var AuthModule = class {
|
|
|
678
678
|
}
|
|
679
679
|
};
|
|
680
680
|
|
|
681
|
+
// src/modules/oauth.ts
|
|
682
|
+
var OAuthModule = class {
|
|
683
|
+
constructor(client) {
|
|
684
|
+
this.client = client;
|
|
685
|
+
}
|
|
686
|
+
client;
|
|
687
|
+
/**
|
|
688
|
+
* Mint a one-time authorization code for the relying party.
|
|
689
|
+
*
|
|
690
|
+
* This is the authenticated mint step the accounts app calls after the user is signed in. It
|
|
691
|
+
* returns a one-time code (plus the echoed `state`) that the app then redirects back to the
|
|
692
|
+
* relying party's `redirect_uri`. The PKCE method is fixed to `'S256'` by the SDK, so callers
|
|
693
|
+
* cannot supply a weaker value. The returned code is not a session — this method does not
|
|
694
|
+
* persist anything.
|
|
695
|
+
*
|
|
696
|
+
* @param input - The authorize request (client, redirect URI, state, PKCE challenge, scope)
|
|
697
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
698
|
+
* @returns The one-time authorization code and the echoed `state`
|
|
699
|
+
* @throws {APIError} On `400` (`invalid_redirect_uri`, `invalid_client`, `invalid_scope`) or other errors
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```typescript
|
|
703
|
+
* const { code, state } = await sdk.oauth.authorize({
|
|
704
|
+
* client_id: 'rp_abc',
|
|
705
|
+
* redirect_uri: 'https://app.example.com/callback',
|
|
706
|
+
* scope: 'profile email',
|
|
707
|
+
* state: csrfState,
|
|
708
|
+
* code_challenge: challenge,
|
|
709
|
+
* })
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
712
|
+
async authorize(input, options) {
|
|
713
|
+
return this.client.post(
|
|
714
|
+
"/auth/oauth/authorize",
|
|
715
|
+
{ ...input, code_challenge_method: "S256" },
|
|
716
|
+
options
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* Exchange a one-time authorization code for a token pair.
|
|
721
|
+
*
|
|
722
|
+
* The relying party calls this server-to-server (or from its own origin) with the PKCE verifier
|
|
723
|
+
* that matches the earlier challenge. The authorization code is single-use — a reused, expired,
|
|
724
|
+
* or tampered code is rejected with `400 invalid_grant`. On success the returned tokens are
|
|
725
|
+
* persisted into the client session via `setSession`, so the relying party is logged in
|
|
726
|
+
* immediately after the exchange. `grant_type` is set to `'authorization_code'` by the SDK.
|
|
727
|
+
*
|
|
728
|
+
* @param input - The token exchange request (code, redirect URI, client, PKCE verifier, optional secret)
|
|
729
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
730
|
+
* @returns The access/refresh token pair and granted scope
|
|
731
|
+
* @throws {APIError} On `400 invalid_grant` (bad/expired/replayed code) or `401 invalid_client` (wrong secret)
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```typescript
|
|
735
|
+
* const tokens = await sdk.oauth.exchangeCode({
|
|
736
|
+
* code,
|
|
737
|
+
* redirect_uri: 'https://app.example.com/callback',
|
|
738
|
+
* client_id: 'rp_abc',
|
|
739
|
+
* code_verifier: verifier,
|
|
740
|
+
* })
|
|
741
|
+
* // sdk is now authenticated as the exchanged session
|
|
742
|
+
* ```
|
|
743
|
+
*/
|
|
744
|
+
async exchangeCode(input, options) {
|
|
745
|
+
const result = await this.client.post(
|
|
746
|
+
"/auth/oauth/token",
|
|
747
|
+
{ ...input, grant_type: "authorization_code" },
|
|
748
|
+
options
|
|
749
|
+
);
|
|
750
|
+
await this.client.setSession({
|
|
751
|
+
access_token: result.access_token,
|
|
752
|
+
refresh_token: result.refresh_token
|
|
753
|
+
});
|
|
754
|
+
return result;
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
|
|
681
758
|
// src/modules/listings.ts
|
|
682
759
|
var ListingsModule = class {
|
|
683
760
|
constructor(client) {
|
|
@@ -2473,6 +2550,7 @@ function baleShareUrl(baleId, options = {}) {
|
|
|
2473
2550
|
var MitumbaClient = class {
|
|
2474
2551
|
api;
|
|
2475
2552
|
auth;
|
|
2553
|
+
oauth;
|
|
2476
2554
|
listings;
|
|
2477
2555
|
search;
|
|
2478
2556
|
orders;
|
|
@@ -2495,6 +2573,7 @@ var MitumbaClient = class {
|
|
|
2495
2573
|
constructor(config) {
|
|
2496
2574
|
this.api = new APIClient(config);
|
|
2497
2575
|
this.auth = new AuthModule(this.api);
|
|
2576
|
+
this.oauth = new OAuthModule(this.api);
|
|
2498
2577
|
this.listings = new ListingsModule(this.api);
|
|
2499
2578
|
this.search = new SearchModule(this.api);
|
|
2500
2579
|
this.orders = new OrdersModule(this.api);
|
|
@@ -2575,6 +2654,7 @@ exports.MemoryTokenStore = MemoryTokenStore;
|
|
|
2575
2654
|
exports.MessagesModule = MessagesModule;
|
|
2576
2655
|
exports.MitumbaClient = MitumbaClient;
|
|
2577
2656
|
exports.NotificationsModule = NotificationsModule;
|
|
2657
|
+
exports.OAuthModule = OAuthModule;
|
|
2578
2658
|
exports.ORDER_STATUSES = ORDER_STATUSES;
|
|
2579
2659
|
exports.OrdersModule = OrdersModule;
|
|
2580
2660
|
exports.PAYMENT_STATUSES = PAYMENT_STATUSES;
|