@mitumba/sdk 5.3.0 → 5.5.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 +292 -1
- package/dist/index.d.ts +292 -1
- package/dist/index.js +191 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +191 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1538,6 +1538,30 @@ interface OAuthConsentRequired {
|
|
|
1538
1538
|
/** The scopes the user is being asked to grant. */
|
|
1539
1539
|
scopes: string[];
|
|
1540
1540
|
}
|
|
1541
|
+
/**
|
|
1542
|
+
* The result of a silent (`prompt=none`) authorization attempt.
|
|
1543
|
+
*
|
|
1544
|
+
* Discriminated on `ok` so a client can branch without try/catch for the expected outcomes: a
|
|
1545
|
+
* success carries the one-time `code` (+ echoed `state`) to redirect back to the relying party; a
|
|
1546
|
+
* failure carries a `reason` the client uses to decide its fallback (typically: do nothing and stay
|
|
1547
|
+
* logged out, or start a visible interactive sign-in). Only genuinely unexpected errors (network,
|
|
1548
|
+
* 5xx) throw from {@link OAuthModule.silentAuthorize}; the reasons below are returned, not thrown.
|
|
1549
|
+
*
|
|
1550
|
+
* - `login_required` — no usable session for a silent mint, or this client is not authorized for
|
|
1551
|
+
* silent authentication. The client should fall back to a visible sign-in (or stay logged out).
|
|
1552
|
+
* - `interaction_required` — consent is needed and cannot be collected silently; fall back to a
|
|
1553
|
+
* visible flow where the user can consent.
|
|
1554
|
+
* - `unauthenticated` — the request reached the gateway with no session at all (HTTP 401). Treated
|
|
1555
|
+
* as a distinct, still-non-throwing reason so "not signed in yet" is a normal silent outcome.
|
|
1556
|
+
*/
|
|
1557
|
+
type SilentAuthorizeResult = {
|
|
1558
|
+
ok: true;
|
|
1559
|
+
code: string;
|
|
1560
|
+
state: string;
|
|
1561
|
+
} | {
|
|
1562
|
+
ok: false;
|
|
1563
|
+
reason: 'login_required' | 'interaction_required' | 'unauthenticated';
|
|
1564
|
+
};
|
|
1541
1565
|
|
|
1542
1566
|
declare const CONDITIONS: readonly ["new", "like_new", "good", "fair"];
|
|
1543
1567
|
type Condition = typeof CONDITIONS[number];
|
|
@@ -2505,6 +2529,172 @@ interface DisputeListParams {
|
|
|
2505
2529
|
page?: number;
|
|
2506
2530
|
}
|
|
2507
2531
|
|
|
2532
|
+
/** IAM principal lifecycle state. */
|
|
2533
|
+
type IamUserStatus = 'active' | 'disabled';
|
|
2534
|
+
/** Organization lifecycle state. */
|
|
2535
|
+
type OrganizationStatus = 'active' | 'suspended';
|
|
2536
|
+
/** Organization category. */
|
|
2537
|
+
type OrganizationKind = 'product' | 'department' | 'team';
|
|
2538
|
+
/** Organization returned by organization-management and IAM profile endpoints. */
|
|
2539
|
+
interface Organization {
|
|
2540
|
+
id: string;
|
|
2541
|
+
display_id: string;
|
|
2542
|
+
alias: string;
|
|
2543
|
+
name: string;
|
|
2544
|
+
kind: OrganizationKind;
|
|
2545
|
+
status: OrganizationStatus;
|
|
2546
|
+
parent_id: string | null;
|
|
2547
|
+
created_at: string;
|
|
2548
|
+
updated_at: string;
|
|
2549
|
+
}
|
|
2550
|
+
/** Organization list row, including its IAM-user count. */
|
|
2551
|
+
interface OrganizationSummary extends Organization {
|
|
2552
|
+
iam_user_count: number;
|
|
2553
|
+
}
|
|
2554
|
+
/** Tokens issued for an IAM principal. */
|
|
2555
|
+
interface IamTokens {
|
|
2556
|
+
access_token: string;
|
|
2557
|
+
refresh_token: string;
|
|
2558
|
+
expires_in: number;
|
|
2559
|
+
principal_type: 'iam';
|
|
2560
|
+
org_id: string;
|
|
2561
|
+
second_factor_enrolled: boolean;
|
|
2562
|
+
}
|
|
2563
|
+
/** Start IAM sign-in with an organization ID or alias. */
|
|
2564
|
+
interface IamLoginInput {
|
|
2565
|
+
org: string;
|
|
2566
|
+
email: string;
|
|
2567
|
+
password: string;
|
|
2568
|
+
}
|
|
2569
|
+
/** Second-factor method offered during IAM sign-in. */
|
|
2570
|
+
interface IamLoginMethod {
|
|
2571
|
+
id: string;
|
|
2572
|
+
type: 'totp' | 'passkey';
|
|
2573
|
+
label: string | null;
|
|
2574
|
+
}
|
|
2575
|
+
/** Password accepted; finish sign-in with one of the returned methods. */
|
|
2576
|
+
interface IamTwoFactorRequired {
|
|
2577
|
+
requires_2fa: true;
|
|
2578
|
+
temp_token: string;
|
|
2579
|
+
methods: IamLoginMethod[];
|
|
2580
|
+
}
|
|
2581
|
+
/** Finish IAM sign-in with an authenticator or backup code. */
|
|
2582
|
+
interface VerifyIamTwoFactorInput {
|
|
2583
|
+
temp_token: string;
|
|
2584
|
+
code: string;
|
|
2585
|
+
method_id?: string;
|
|
2586
|
+
}
|
|
2587
|
+
/** Activate an invited IAM principal and choose its password. */
|
|
2588
|
+
interface ActivateIamUserInput {
|
|
2589
|
+
org: string;
|
|
2590
|
+
email: string;
|
|
2591
|
+
code: string;
|
|
2592
|
+
password: string;
|
|
2593
|
+
}
|
|
2594
|
+
/** Result of activating an IAM principal. */
|
|
2595
|
+
interface ActivateIamUserResult {
|
|
2596
|
+
ok: true;
|
|
2597
|
+
next_step: string;
|
|
2598
|
+
}
|
|
2599
|
+
/** Current IAM principal and its organization-scoped access. */
|
|
2600
|
+
interface IamProfile {
|
|
2601
|
+
id: string;
|
|
2602
|
+
email: string;
|
|
2603
|
+
display_name: string | null;
|
|
2604
|
+
status: IamUserStatus;
|
|
2605
|
+
organization: Organization;
|
|
2606
|
+
permissions: AdminPermission[];
|
|
2607
|
+
two_factor_methods_count: number;
|
|
2608
|
+
backup_codes_remaining: number;
|
|
2609
|
+
admin_enrolment_required: boolean;
|
|
2610
|
+
}
|
|
2611
|
+
/** Add an IAM authenticator or passkey. */
|
|
2612
|
+
interface AddIamTwoFactorMethodInput {
|
|
2613
|
+
type: 'totp' | 'passkey';
|
|
2614
|
+
label?: string;
|
|
2615
|
+
}
|
|
2616
|
+
/** TOTP enrollment response. */
|
|
2617
|
+
interface AddIamTotpResult {
|
|
2618
|
+
id: string;
|
|
2619
|
+
otpauth_uri: string;
|
|
2620
|
+
secret: string;
|
|
2621
|
+
}
|
|
2622
|
+
/** Passkey enrollment response. */
|
|
2623
|
+
interface AddIamPasskeyResult {
|
|
2624
|
+
method_id: string;
|
|
2625
|
+
options: PublicKeyCredentialCreationOptionsJSON;
|
|
2626
|
+
}
|
|
2627
|
+
/** IAM factor verification response. Backup codes appear only for the first factor. */
|
|
2628
|
+
interface VerifyIamMethodResult {
|
|
2629
|
+
ok: true;
|
|
2630
|
+
backup_codes?: string[];
|
|
2631
|
+
}
|
|
2632
|
+
/** Create an organization. */
|
|
2633
|
+
interface CreateOrganizationInput {
|
|
2634
|
+
alias: string;
|
|
2635
|
+
name: string;
|
|
2636
|
+
kind: OrganizationKind;
|
|
2637
|
+
parent_id?: string;
|
|
2638
|
+
}
|
|
2639
|
+
/** Update mutable organization fields. */
|
|
2640
|
+
interface UpdateOrganizationInput {
|
|
2641
|
+
name?: string;
|
|
2642
|
+
status?: OrganizationStatus;
|
|
2643
|
+
}
|
|
2644
|
+
/** IAM user shown in an organization's operator list. */
|
|
2645
|
+
interface IamUser {
|
|
2646
|
+
id: string;
|
|
2647
|
+
org_id?: string;
|
|
2648
|
+
email: string;
|
|
2649
|
+
display_name: string | null;
|
|
2650
|
+
status: IamUserStatus;
|
|
2651
|
+
activated: boolean;
|
|
2652
|
+
second_factor_enrolled?: boolean;
|
|
2653
|
+
permissions: AdminPermission[];
|
|
2654
|
+
last_active_at?: string | null;
|
|
2655
|
+
created_at?: string;
|
|
2656
|
+
}
|
|
2657
|
+
/** Create an IAM principal in an organization. */
|
|
2658
|
+
interface CreateIamUserInput {
|
|
2659
|
+
email: string;
|
|
2660
|
+
display_name?: string;
|
|
2661
|
+
permissions?: AdminPermission[];
|
|
2662
|
+
}
|
|
2663
|
+
/** One-time IAM activation credential returned to the provisioning administrator. */
|
|
2664
|
+
interface IamActivation {
|
|
2665
|
+
code: string;
|
|
2666
|
+
expires_at: string;
|
|
2667
|
+
org_id: string;
|
|
2668
|
+
org_alias: string | null;
|
|
2669
|
+
org_display_id: string;
|
|
2670
|
+
}
|
|
2671
|
+
/** Result of provisioning an IAM principal. */
|
|
2672
|
+
interface CreateIamUserResult {
|
|
2673
|
+
iam_user: IamUser;
|
|
2674
|
+
activation: IamActivation;
|
|
2675
|
+
}
|
|
2676
|
+
/** Result of listing one organization's IAM principals. */
|
|
2677
|
+
interface ListIamUsersResult {
|
|
2678
|
+
organization: Organization;
|
|
2679
|
+
iam_users: IamUser[];
|
|
2680
|
+
grantable_permissions: AdminPermission[];
|
|
2681
|
+
}
|
|
2682
|
+
/** Input to finish IAM passkey sign-in. */
|
|
2683
|
+
interface FinishIamPasskeyLoginInput {
|
|
2684
|
+
temp_token: string;
|
|
2685
|
+
credential: AuthenticationResponseJSON;
|
|
2686
|
+
}
|
|
2687
|
+
/** Input to finish IAM passkey enrollment. */
|
|
2688
|
+
type FinishIamPasskeyEnrollmentInput = RegistrationResponseJSON;
|
|
2689
|
+
/** IAM passkey assertion options. */
|
|
2690
|
+
interface IamPasskeyLoginOptions {
|
|
2691
|
+
options: PublicKeyCredentialRequestOptionsJSON;
|
|
2692
|
+
}
|
|
2693
|
+
/** IAM second-factor methods response. */
|
|
2694
|
+
interface IamMethodsResult {
|
|
2695
|
+
methods: TwoFactorMethod[];
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2508
2698
|
interface MitumbaClientConfig {
|
|
2509
2699
|
baseUrl: string;
|
|
2510
2700
|
debug?: boolean;
|
|
@@ -2934,6 +3124,31 @@ declare class OAuthModule {
|
|
|
2934
3124
|
listConsents(options?: RequestOptions): Promise<{
|
|
2935
3125
|
consents: OAuthConsent[];
|
|
2936
3126
|
}>;
|
|
3127
|
+
/**
|
|
3128
|
+
* Attempt a silent (`prompt=none`) authorization — the "sign in once, every app knows you" path.
|
|
3129
|
+
*
|
|
3130
|
+
* Sends the authorize request with `prompt=none`, meaning: mint a code only if it can be done with
|
|
3131
|
+
* no interaction, otherwise tell me why so I can fall back. Unlike {@link OAuthModule.authorize},
|
|
3132
|
+
* the expected non-success outcomes are RETURNED (discriminated on `ok`), not thrown, so a caller
|
|
3133
|
+
* can branch cleanly without a try/catch:
|
|
3134
|
+
*
|
|
3135
|
+
* - `{ ok: true, code, state }` — redirect to `redirect_uri?code=..&state=..` as usual.
|
|
3136
|
+
* - `{ ok: false, reason: 'login_required' }` — no usable session, or this client is not
|
|
3137
|
+
* authorized for silent auth. Fall back to a visible sign-in (or stay logged out).
|
|
3138
|
+
* - `{ ok: false, reason: 'interaction_required' }` — consent needed; fall back to a visible flow.
|
|
3139
|
+
* - `{ ok: false, reason: 'unauthenticated' }` — no session reached the server (HTTP 401).
|
|
3140
|
+
*
|
|
3141
|
+
* Only genuinely unexpected errors (network failure, 5xx, an unrecognised error code) throw.
|
|
3142
|
+
* `code_challenge_method` is fixed to `'S256'` and `prompt` to `'none'` by the SDK. This is a
|
|
3143
|
+
* top-level/first-party call carrying the session the SDK holds; the server never mints for a
|
|
3144
|
+
* client that lacks the silent-auth privilege (it returns `login_required`).
|
|
3145
|
+
*
|
|
3146
|
+
* @param input - The authorize request (client, redirect URI, state, PKCE challenge, scope)
|
|
3147
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
3148
|
+
* @returns A discriminated success-or-fallback result
|
|
3149
|
+
* @throws {APIError} Only on unexpected failures (network, 5xx, unknown error code)
|
|
3150
|
+
*/
|
|
3151
|
+
silentAuthorize(input: OAuthAuthorizeInput, options?: RequestOptions): Promise<SilentAuthorizeResult>;
|
|
2937
3152
|
}
|
|
2938
3153
|
|
|
2939
3154
|
declare class ListingsModule {
|
|
@@ -4038,6 +4253,81 @@ declare class WholesaleModule {
|
|
|
4038
4253
|
getAnalytics(period?: 'daily' | 'weekly' | 'monthly', options?: RequestOptions): Promise<WholesaleAnalytics>;
|
|
4039
4254
|
}
|
|
4040
4255
|
|
|
4256
|
+
/**
|
|
4257
|
+
* Organization-scoped operator identity and access.
|
|
4258
|
+
*
|
|
4259
|
+
* Root continues to use {@link AuthModule}. IAM users use this module for organization-aware sign-in,
|
|
4260
|
+
* activation, second factors and session lifecycle. Organization administration methods require a
|
|
4261
|
+
* root/global-operator session with the corresponding server-side permission.
|
|
4262
|
+
*/
|
|
4263
|
+
declare class IamModule {
|
|
4264
|
+
private readonly client;
|
|
4265
|
+
constructor(client: APIClient);
|
|
4266
|
+
/** Start IAM sign-in with an organization ID or alias, email and password. */
|
|
4267
|
+
login(input: IamLoginInput, options?: RequestOptions): Promise<IamTokens | IamTwoFactorRequired>;
|
|
4268
|
+
/** Finish IAM sign-in with a TOTP or one-time backup code. */
|
|
4269
|
+
verifyTwoFactor(input: VerifyIamTwoFactorInput, options?: RequestOptions): Promise<IamTokens>;
|
|
4270
|
+
/** Get WebAuthn assertion options for a pending IAM sign-in. */
|
|
4271
|
+
startPasskeyLogin(tempToken: string, options?: RequestOptions): Promise<IamPasskeyLoginOptions>;
|
|
4272
|
+
/** Finish IAM passkey sign-in and persist the returned IAM session. */
|
|
4273
|
+
finishPasskeyLogin(input: FinishIamPasskeyLoginInput, options?: RequestOptions): Promise<IamTokens>;
|
|
4274
|
+
/** Activate an invited IAM user and choose its password. */
|
|
4275
|
+
activate(input: ActivateIamUserInput, options?: RequestOptions): Promise<ActivateIamUserResult>;
|
|
4276
|
+
/** Rotate an IAM refresh token and persist the returned session. */
|
|
4277
|
+
refresh(refreshToken: string, options?: RequestOptions): Promise<IamTokens>;
|
|
4278
|
+
/** End the current IAM session and clear locally stored credentials. */
|
|
4279
|
+
logout(options?: RequestOptions): Promise<{
|
|
4280
|
+
ok: true;
|
|
4281
|
+
}>;
|
|
4282
|
+
/** Get the current IAM principal, organization and effective access state. */
|
|
4283
|
+
me(options?: RequestOptions): Promise<IamProfile>;
|
|
4284
|
+
/** List this IAM principal's enrolled second-factor methods. */
|
|
4285
|
+
listMethods(options?: RequestOptions): Promise<IamMethodsResult>;
|
|
4286
|
+
/** Begin adding an authenticator app or passkey. */
|
|
4287
|
+
addMethod(input: AddIamTwoFactorMethodInput, options?: RequestOptions): Promise<AddIamTotpResult | AddIamPasskeyResult>;
|
|
4288
|
+
/** Verify and enable a pending IAM authenticator method. */
|
|
4289
|
+
verifyMethod(methodId: string, code: string, options?: RequestOptions): Promise<VerifyIamMethodResult>;
|
|
4290
|
+
/** Finish and enable a pending IAM passkey method. */
|
|
4291
|
+
finishPasskeyEnrollment(methodId: string, credential: FinishIamPasskeyEnrollmentInput, options?: RequestOptions): Promise<VerifyIamMethodResult>;
|
|
4292
|
+
/** List organizations the current root/global operator may administer. */
|
|
4293
|
+
listOrganizations(options?: RequestOptions): Promise<{
|
|
4294
|
+
organizations: OrganizationSummary[];
|
|
4295
|
+
kinds: OrganizationKind[];
|
|
4296
|
+
}>;
|
|
4297
|
+
/** Create an organization. */
|
|
4298
|
+
createOrganization(input: CreateOrganizationInput, options?: RequestOptions): Promise<{
|
|
4299
|
+
organization: Organization;
|
|
4300
|
+
}>;
|
|
4301
|
+
/** Update an organization's name or lifecycle state. */
|
|
4302
|
+
updateOrganization(orgId: string, input: UpdateOrganizationInput, options?: RequestOptions): Promise<{
|
|
4303
|
+
organization: Organization;
|
|
4304
|
+
}>;
|
|
4305
|
+
/** List IAM users and grantable permissions in one organization. */
|
|
4306
|
+
listUsers(orgId: string, options?: RequestOptions): Promise<ListIamUsersResult>;
|
|
4307
|
+
/** Provision an IAM user. The activation code is returned once. */
|
|
4308
|
+
createUser(orgId: string, input: CreateIamUserInput, options?: RequestOptions): Promise<CreateIamUserResult>;
|
|
4309
|
+
/** Grant one organization-scoped permission to an IAM user. */
|
|
4310
|
+
grantPermission(orgId: string, iamUserId: string, permission: AdminPermission, options?: RequestOptions): Promise<{
|
|
4311
|
+
ok: true;
|
|
4312
|
+
permissions: AdminPermission[];
|
|
4313
|
+
}>;
|
|
4314
|
+
/** Revoke one permission and immediately end the IAM user's sessions. */
|
|
4315
|
+
revokePermission(orgId: string, iamUserId: string, permission: AdminPermission, options?: RequestOptions): Promise<{
|
|
4316
|
+
ok: true;
|
|
4317
|
+
revoked: boolean;
|
|
4318
|
+
permissions: AdminPermission[];
|
|
4319
|
+
}>;
|
|
4320
|
+
/** Enable or disable an IAM user. Disabling immediately ends its sessions. */
|
|
4321
|
+
setUserStatus(orgId: string, iamUserId: string, status: IamUserStatus, options?: RequestOptions): Promise<{
|
|
4322
|
+
ok: true;
|
|
4323
|
+
status: IamUserStatus;
|
|
4324
|
+
}>;
|
|
4325
|
+
/** Reissue the one-time activation credential for an unactivated IAM user. */
|
|
4326
|
+
reissueActivation(orgId: string, iamUserId: string, options?: RequestOptions): Promise<{
|
|
4327
|
+
activation: IamActivation;
|
|
4328
|
+
}>;
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4041
4331
|
/**
|
|
4042
4332
|
* Canonical go.mitumba.africa share URLs — the one place clients build listing, store and bale share links.
|
|
4043
4333
|
*
|
|
@@ -4083,6 +4373,7 @@ declare class MitumbaClient {
|
|
|
4083
4373
|
readonly uploads: UploadsModule;
|
|
4084
4374
|
readonly reports: ReportsModule;
|
|
4085
4375
|
readonly wholesale: WholesaleModule;
|
|
4376
|
+
readonly iam: IamModule;
|
|
4086
4377
|
constructor(config: MitumbaClientConfig);
|
|
4087
4378
|
/**
|
|
4088
4379
|
* Set the access token for authenticated requests.
|
|
@@ -4114,4 +4405,4 @@ declare class MitumbaClient {
|
|
|
4114
4405
|
isAuthenticated(): Promise<boolean>;
|
|
4115
4406
|
}
|
|
4116
4407
|
|
|
4117
|
-
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 Jwk, type Jwks, 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, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OpenIdConfiguration, 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 UserInfo, 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, isConsentRequired, isMessagingAPIError, listingShareUrl, storeShareUrl };
|
|
4408
|
+
export { APIClient, APIError, type APIErrorResponse, type ActivateIamUserInput, type ActivateIamUserResult, type Add2FAMethodInput, type Add2FAMethodResult, type AddAddressInput, type AddDepotInput, type AddIamPasskeyResult, type AddIamTotpResult, type AddIamTwoFactorMethodInput, 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 CreateIamUserInput, type CreateIamUserResult, type CreateListingInput, type CreateMessageBlockInput, type CreateMessageBlockResult, type CreateMessageReportInput, type CreateMessageReportResult, type CreateOrderInput, type CreateOrganizationInput, 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 FinishIamPasskeyEnrollmentInput, type FinishIamPasskeyLoginInput, type FollowedStore, type ForgotPasswordInput, IDBTokenStore, type IamActivation, type IamLoginInput, type IamLoginMethod, type IamMethodsResult, IamModule, type IamPasskeyLoginOptions, type IamProfile, type IamTokens, type IamTwoFactorRequired, type IamUser, type IamUserStatus, type InboxRealtimeEvent, type InitiateCheckoutInput, type InitiateCheckoutResponse, type Jwk, type Jwks, type KnownPaymentProvider, LISTING_STATUSES, type LegacyLinkResolution, type LegacyMessageArchiveSummary, type LegacyMessagePage, type LegacyMessageRecord, type LinkedAccount, type LinkedAccountProvider, type ListConversationsParams, type ListIamUsersResult, 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, type OAuthConsent, type OAuthConsentInput, type OAuthConsentRequired, type OAuthConsentRevokeResult, OAuthModule, type OAuthTokenExchangeInput, type OAuthTokenResult, ORDER_STATUSES, type OpenIdConfiguration, type OperatorPermissionGrant, type Order, type OrderEvent, type OrderHistoryParams, type OrderStatus, OrdersModule, type Organization, type OrganizationKind, type OrganizationStatus, type OrganizationSummary, 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 SilentAuthorizeResult, 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 UpdateOrganizationInput, type UpdateProfileInput, type UpdateStoreInput, type UpdateThreadPreferencesInput, UploadsModule, type UserInfo, type UserProfile, type VAZIOutfit, type VAZIOutfitDetail, type VAZIOutfitDetailItem, type VAZIOutfitItem, type VaziFeedParams, type VaziFeedResponse, VaziModule, type Verify2FAInput, type VerifyIamMethodResult, type VerifyIamTwoFactorInput, type VerifyOtpInput, type WebSocketCloseEventLike, type WebSocketFactory, type WebSocketLike, type WebSocketMessageEventLike, type WholesaleAnalytics, type WholesaleDepot, type WholesaleFeedParams, WholesaleModule, type WholesaleStore, type WishlistListing, WishlistsModule, baleShareUrl, createTokenStore, isConsentRequired, isMessagingAPIError, listingShareUrl, storeShareUrl };
|
package/dist/index.js
CHANGED
|
@@ -151,6 +151,21 @@ function isExpiringSoon(token, thresholdSeconds) {
|
|
|
151
151
|
return false;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
+
function refreshPathForToken(token) {
|
|
155
|
+
if (!token) return "/auth/refresh";
|
|
156
|
+
try {
|
|
157
|
+
const encoded = token.split(".")[1];
|
|
158
|
+
if (!encoded) return "/auth/refresh";
|
|
159
|
+
const normalized = encoded.replace(/-/g, "+").replace(/_/g, "/");
|
|
160
|
+
const payload = JSON.parse(atob(normalized));
|
|
161
|
+
return payload.ptype === "iam" ? "/auth/iam/refresh" : "/auth/refresh";
|
|
162
|
+
} catch {
|
|
163
|
+
return "/auth/refresh";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function isSessionEndpoint(path) {
|
|
167
|
+
return path === "/auth/login" || path === "/auth/register" || path === "/auth/refresh" || path === "/auth/iam/login" || path === "/auth/iam/login/2fa" || path === "/auth/iam/login/passkey/start" || path === "/auth/iam/login/passkey/finish" || path === "/auth/iam/activate" || path === "/auth/iam/refresh" || path === "/auth/iam/logout";
|
|
168
|
+
}
|
|
154
169
|
function isErrorRecord(value) {
|
|
155
170
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
156
171
|
}
|
|
@@ -266,7 +281,7 @@ var APIClient = class {
|
|
|
266
281
|
}
|
|
267
282
|
}
|
|
268
283
|
async request(method, path, body, params, options) {
|
|
269
|
-
if (!
|
|
284
|
+
if (!isSessionEndpoint(path)) {
|
|
270
285
|
await this.ensureFreshToken(options);
|
|
271
286
|
}
|
|
272
287
|
const url = new URL(path, this.config.baseUrl);
|
|
@@ -327,7 +342,7 @@ var APIClient = class {
|
|
|
327
342
|
}
|
|
328
343
|
break;
|
|
329
344
|
}
|
|
330
|
-
if (response.status === 401 && !
|
|
345
|
+
if (response.status === 401 && !isSessionEndpoint(path)) {
|
|
331
346
|
const hasRefreshToken = this.config.refreshToken && this.config.refreshToken.length > 0;
|
|
332
347
|
if (hasRefreshToken) {
|
|
333
348
|
try {
|
|
@@ -367,7 +382,7 @@ var APIClient = class {
|
|
|
367
382
|
this.isRefreshing = true;
|
|
368
383
|
this.refreshPromise = (async () => {
|
|
369
384
|
try {
|
|
370
|
-
const url = new URL(
|
|
385
|
+
const url = new URL(refreshPathForToken(this.config.token), this.config.baseUrl);
|
|
371
386
|
const response = await fetch(url.toString(), {
|
|
372
387
|
method: "POST",
|
|
373
388
|
headers: { "Content-Type": "application/json" },
|
|
@@ -833,6 +848,50 @@ var OAuthModule = class {
|
|
|
833
848
|
async listConsents(options) {
|
|
834
849
|
return this.client.get("/auth/oauth/consents", void 0, options);
|
|
835
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* Attempt a silent (`prompt=none`) authorization — the "sign in once, every app knows you" path.
|
|
853
|
+
*
|
|
854
|
+
* Sends the authorize request with `prompt=none`, meaning: mint a code only if it can be done with
|
|
855
|
+
* no interaction, otherwise tell me why so I can fall back. Unlike {@link OAuthModule.authorize},
|
|
856
|
+
* the expected non-success outcomes are RETURNED (discriminated on `ok`), not thrown, so a caller
|
|
857
|
+
* can branch cleanly without a try/catch:
|
|
858
|
+
*
|
|
859
|
+
* - `{ ok: true, code, state }` — redirect to `redirect_uri?code=..&state=..` as usual.
|
|
860
|
+
* - `{ ok: false, reason: 'login_required' }` — no usable session, or this client is not
|
|
861
|
+
* authorized for silent auth. Fall back to a visible sign-in (or stay logged out).
|
|
862
|
+
* - `{ ok: false, reason: 'interaction_required' }` — consent needed; fall back to a visible flow.
|
|
863
|
+
* - `{ ok: false, reason: 'unauthenticated' }` — no session reached the server (HTTP 401).
|
|
864
|
+
*
|
|
865
|
+
* Only genuinely unexpected errors (network failure, 5xx, an unrecognised error code) throw.
|
|
866
|
+
* `code_challenge_method` is fixed to `'S256'` and `prompt` to `'none'` by the SDK. This is a
|
|
867
|
+
* top-level/first-party call carrying the session the SDK holds; the server never mints for a
|
|
868
|
+
* client that lacks the silent-auth privilege (it returns `login_required`).
|
|
869
|
+
*
|
|
870
|
+
* @param input - The authorize request (client, redirect URI, state, PKCE challenge, scope)
|
|
871
|
+
* @param options - Optional per-request options (abort signal, extra headers)
|
|
872
|
+
* @returns A discriminated success-or-fallback result
|
|
873
|
+
* @throws {APIError} Only on unexpected failures (network, 5xx, unknown error code)
|
|
874
|
+
*/
|
|
875
|
+
async silentAuthorize(input, options) {
|
|
876
|
+
try {
|
|
877
|
+
const result = await this.client.post(
|
|
878
|
+
"/auth/oauth/authorize",
|
|
879
|
+
{ ...input, code_challenge_method: "S256", prompt: "none" },
|
|
880
|
+
options
|
|
881
|
+
);
|
|
882
|
+
if (isConsentRequired(result)) return { ok: false, reason: "interaction_required" };
|
|
883
|
+
return { ok: true, code: result.code, state: result.state };
|
|
884
|
+
} catch (err) {
|
|
885
|
+
if (err instanceof APIError) {
|
|
886
|
+
if (err.status === 401) return { ok: false, reason: "unauthenticated" };
|
|
887
|
+
if (err.code === "login_required") return { ok: false, reason: "login_required" };
|
|
888
|
+
if (err.code === "interaction_required" || err.code === "consent_required") {
|
|
889
|
+
return { ok: false, reason: "interaction_required" };
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
throw err;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
836
895
|
};
|
|
837
896
|
|
|
838
897
|
// src/modules/listings.ts
|
|
@@ -2557,6 +2616,132 @@ var WholesaleModule = class {
|
|
|
2557
2616
|
}
|
|
2558
2617
|
};
|
|
2559
2618
|
|
|
2619
|
+
// src/modules/iam.ts
|
|
2620
|
+
function isIamTokens(result) {
|
|
2621
|
+
return "access_token" in result;
|
|
2622
|
+
}
|
|
2623
|
+
var IamModule = class {
|
|
2624
|
+
constructor(client) {
|
|
2625
|
+
this.client = client;
|
|
2626
|
+
}
|
|
2627
|
+
client;
|
|
2628
|
+
/** Start IAM sign-in with an organization ID or alias, email and password. */
|
|
2629
|
+
async login(input, options) {
|
|
2630
|
+
const result = await this.client.post("/auth/iam/login", input, options);
|
|
2631
|
+
if (isIamTokens(result)) await this.client.setSession(result);
|
|
2632
|
+
return result;
|
|
2633
|
+
}
|
|
2634
|
+
/** Finish IAM sign-in with a TOTP or one-time backup code. */
|
|
2635
|
+
async verifyTwoFactor(input, options) {
|
|
2636
|
+
const result = await this.client.post("/auth/iam/login/2fa", input, options);
|
|
2637
|
+
await this.client.setSession(result);
|
|
2638
|
+
return result;
|
|
2639
|
+
}
|
|
2640
|
+
/** Get WebAuthn assertion options for a pending IAM sign-in. */
|
|
2641
|
+
async startPasskeyLogin(tempToken, options) {
|
|
2642
|
+
return this.client.post("/auth/iam/login/passkey/start", { temp_token: tempToken }, options);
|
|
2643
|
+
}
|
|
2644
|
+
/** Finish IAM passkey sign-in and persist the returned IAM session. */
|
|
2645
|
+
async finishPasskeyLogin(input, options) {
|
|
2646
|
+
const result = await this.client.post("/auth/iam/login/passkey/finish", input, options);
|
|
2647
|
+
await this.client.setSession(result);
|
|
2648
|
+
return result;
|
|
2649
|
+
}
|
|
2650
|
+
/** Activate an invited IAM user and choose its password. */
|
|
2651
|
+
async activate(input, options) {
|
|
2652
|
+
return this.client.post("/auth/iam/activate", input, options);
|
|
2653
|
+
}
|
|
2654
|
+
/** Rotate an IAM refresh token and persist the returned session. */
|
|
2655
|
+
async refresh(refreshToken, options) {
|
|
2656
|
+
const result = await this.client.post("/auth/iam/refresh", { refresh_token: refreshToken }, options);
|
|
2657
|
+
await this.client.setSession(result);
|
|
2658
|
+
return result;
|
|
2659
|
+
}
|
|
2660
|
+
/** End the current IAM session and clear locally stored credentials. */
|
|
2661
|
+
async logout(options) {
|
|
2662
|
+
const refreshToken = await this.client.getStoredRefreshToken();
|
|
2663
|
+
if (!refreshToken) {
|
|
2664
|
+
await this.client.clearToken();
|
|
2665
|
+
return { ok: true };
|
|
2666
|
+
}
|
|
2667
|
+
const result = await this.client.post("/auth/iam/logout", { refresh_token: refreshToken }, options);
|
|
2668
|
+
await this.client.clearToken();
|
|
2669
|
+
return result;
|
|
2670
|
+
}
|
|
2671
|
+
/** Get the current IAM principal, organization and effective access state. */
|
|
2672
|
+
async me(options) {
|
|
2673
|
+
return this.client.get("/auth/iam/me", void 0, options);
|
|
2674
|
+
}
|
|
2675
|
+
/** List this IAM principal's enrolled second-factor methods. */
|
|
2676
|
+
async listMethods(options) {
|
|
2677
|
+
return this.client.get("/auth/iam/2fa/methods", void 0, options);
|
|
2678
|
+
}
|
|
2679
|
+
/** Begin adding an authenticator app or passkey. */
|
|
2680
|
+
async addMethod(input, options) {
|
|
2681
|
+
return this.client.post("/auth/iam/2fa/methods", input, options);
|
|
2682
|
+
}
|
|
2683
|
+
/** Verify and enable a pending IAM authenticator method. */
|
|
2684
|
+
async verifyMethod(methodId, code, options) {
|
|
2685
|
+
return this.client.post(`/auth/iam/2fa/methods/${encodeURIComponent(methodId)}/verify`, { code }, options);
|
|
2686
|
+
}
|
|
2687
|
+
/** Finish and enable a pending IAM passkey method. */
|
|
2688
|
+
async finishPasskeyEnrollment(methodId, credential, options) {
|
|
2689
|
+
return this.client.post(`/auth/iam/2fa/methods/${encodeURIComponent(methodId)}/passkey/finish`, credential, options);
|
|
2690
|
+
}
|
|
2691
|
+
/** List organizations the current root/global operator may administer. */
|
|
2692
|
+
async listOrganizations(options) {
|
|
2693
|
+
return this.client.get("/auth/orgs", void 0, options);
|
|
2694
|
+
}
|
|
2695
|
+
/** Create an organization. */
|
|
2696
|
+
async createOrganization(input, options) {
|
|
2697
|
+
return this.client.post("/auth/orgs", input, options);
|
|
2698
|
+
}
|
|
2699
|
+
/** Update an organization's name or lifecycle state. */
|
|
2700
|
+
async updateOrganization(orgId, input, options) {
|
|
2701
|
+
return this.client.patch(`/auth/orgs/${encodeURIComponent(orgId)}`, input, options);
|
|
2702
|
+
}
|
|
2703
|
+
/** List IAM users and grantable permissions in one organization. */
|
|
2704
|
+
async listUsers(orgId, options) {
|
|
2705
|
+
return this.client.get(`/auth/orgs/${encodeURIComponent(orgId)}/iam-users`, void 0, options);
|
|
2706
|
+
}
|
|
2707
|
+
/** Provision an IAM user. The activation code is returned once. */
|
|
2708
|
+
async createUser(orgId, input, options) {
|
|
2709
|
+
return this.client.post(`/auth/orgs/${encodeURIComponent(orgId)}/iam-users`, input, options);
|
|
2710
|
+
}
|
|
2711
|
+
/** Grant one organization-scoped permission to an IAM user. */
|
|
2712
|
+
async grantPermission(orgId, iamUserId, permission, options) {
|
|
2713
|
+
return this.client.post(
|
|
2714
|
+
`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/permissions`,
|
|
2715
|
+
{ permission },
|
|
2716
|
+
options
|
|
2717
|
+
);
|
|
2718
|
+
}
|
|
2719
|
+
/** Revoke one permission and immediately end the IAM user's sessions. */
|
|
2720
|
+
async revokePermission(orgId, iamUserId, permission, options) {
|
|
2721
|
+
return this.client.delete(
|
|
2722
|
+
`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/permissions/${encodeURIComponent(permission)}`,
|
|
2723
|
+
void 0,
|
|
2724
|
+
options
|
|
2725
|
+
);
|
|
2726
|
+
}
|
|
2727
|
+
/** Enable or disable an IAM user. Disabling immediately ends its sessions. */
|
|
2728
|
+
async setUserStatus(orgId, iamUserId, status, options) {
|
|
2729
|
+
return this.client.post(
|
|
2730
|
+
`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/status`,
|
|
2731
|
+
{ status },
|
|
2732
|
+
options
|
|
2733
|
+
);
|
|
2734
|
+
}
|
|
2735
|
+
/** Reissue the one-time activation credential for an unactivated IAM user. */
|
|
2736
|
+
async reissueActivation(orgId, iamUserId, options) {
|
|
2737
|
+
return this.client.post(
|
|
2738
|
+
`/auth/orgs/${encodeURIComponent(orgId)}/iam-users/${encodeURIComponent(iamUserId)}/activation`,
|
|
2739
|
+
void 0,
|
|
2740
|
+
options
|
|
2741
|
+
);
|
|
2742
|
+
}
|
|
2743
|
+
};
|
|
2744
|
+
|
|
2560
2745
|
// src/types/auth.ts
|
|
2561
2746
|
var TWO_FACTOR_METHOD_TYPES = ["totp", "sms", "email", "passkey"];
|
|
2562
2747
|
|
|
@@ -2650,6 +2835,7 @@ var MitumbaClient = class {
|
|
|
2650
2835
|
uploads;
|
|
2651
2836
|
reports;
|
|
2652
2837
|
wholesale;
|
|
2838
|
+
iam;
|
|
2653
2839
|
constructor(config) {
|
|
2654
2840
|
this.api = new APIClient(config);
|
|
2655
2841
|
this.auth = new AuthModule(this.api);
|
|
@@ -2673,6 +2859,7 @@ var MitumbaClient = class {
|
|
|
2673
2859
|
this.uploads = new UploadsModule(this.api);
|
|
2674
2860
|
this.reports = new ReportsModule(this.api);
|
|
2675
2861
|
this.wholesale = new WholesaleModule(this.api);
|
|
2862
|
+
this.iam = new IamModule(this.api);
|
|
2676
2863
|
}
|
|
2677
2864
|
/**
|
|
2678
2865
|
* Set the access token for authenticated requests.
|
|
@@ -2727,6 +2914,7 @@ exports.DISPUTE_REASONS = DISPUTE_REASONS;
|
|
|
2727
2914
|
exports.DISPUTE_STATUSES = DISPUTE_STATUSES;
|
|
2728
2915
|
exports.DisputesModule = DisputesModule;
|
|
2729
2916
|
exports.IDBTokenStore = IDBTokenStore;
|
|
2917
|
+
exports.IamModule = IamModule;
|
|
2730
2918
|
exports.LISTING_STATUSES = LISTING_STATUSES;
|
|
2731
2919
|
exports.ListingsModule = ListingsModule;
|
|
2732
2920
|
exports.MailerModule = MailerModule;
|