@mitumba/sdk 5.11.0 → 5.13.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 +44 -14
- package/dist/index.d.ts +44 -14
- package/dist/index.js +30 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
package/dist/index.mjs
CHANGED
|
@@ -445,7 +445,6 @@ var AuthModule = class {
|
|
|
445
445
|
constructor(client) {
|
|
446
446
|
this.client = client;
|
|
447
447
|
}
|
|
448
|
-
client;
|
|
449
448
|
/**
|
|
450
449
|
* Register a new account.
|
|
451
450
|
* If using EmailRegisterInput, returns AuthTokens (auto-persisted).
|
|
@@ -477,11 +476,15 @@ var AuthModule = class {
|
|
|
477
476
|
return this.client.post("/auth/otp/send", input, options);
|
|
478
477
|
}
|
|
479
478
|
/**
|
|
480
|
-
* Verify
|
|
479
|
+
* Verify a phone OTP code.
|
|
480
|
+
*
|
|
481
|
+
* Returns the session tokens (auto-persisted) for an account without a second factor. An account
|
|
482
|
+
* with 2FA gets a `TwoFactorRequired` challenge instead, exactly like `login()`: complete it with
|
|
483
|
+
* `verify2FA()` or the passkey ceremony. Narrow with `'requires_2fa' in result`.
|
|
481
484
|
*/
|
|
482
485
|
async verifyOtp(input, options) {
|
|
483
486
|
const result = await this.client.post("/auth/otp/verify", input, options);
|
|
484
|
-
await this.client.setSession(result);
|
|
487
|
+
if (isAuthTokens(result)) await this.client.setSession(result);
|
|
485
488
|
return result;
|
|
486
489
|
}
|
|
487
490
|
/**
|
|
@@ -699,7 +702,6 @@ var OAuthModule = class {
|
|
|
699
702
|
constructor(client) {
|
|
700
703
|
this.client = client;
|
|
701
704
|
}
|
|
702
|
-
client;
|
|
703
705
|
/**
|
|
704
706
|
* Mint a one-time authorization code for the relying party.
|
|
705
707
|
*
|
|
@@ -733,18 +735,23 @@ var OAuthModule = class {
|
|
|
733
735
|
);
|
|
734
736
|
}
|
|
735
737
|
/**
|
|
736
|
-
* Exchange a one-time authorization code for
|
|
738
|
+
* Exchange a one-time authorization code for tokens.
|
|
737
739
|
*
|
|
738
740
|
* The relying party calls this server-to-server (or from its own origin) with the PKCE verifier
|
|
739
741
|
* that matches the earlier challenge. The authorization code is single-use — a reused, expired,
|
|
740
|
-
* or tampered code is rejected with `400 invalid_grant`.
|
|
741
|
-
*
|
|
742
|
-
*
|
|
742
|
+
* or tampered code is rejected with `400 invalid_grant`. `grant_type` is set to
|
|
743
|
+
* `'authorization_code'` by the SDK.
|
|
744
|
+
*
|
|
745
|
+
* When the result is a Mitumba session (it carries a `refresh_token`, as for the Mitumba
|
|
746
|
+
* marketplace), the tokens are persisted into the client session via `setSession`, so the caller
|
|
747
|
+
* is signed in immediately. Any other relying party receives an access token addressed only to
|
|
748
|
+
* itself and no refresh token; that result is returned untouched and the client session is left
|
|
749
|
+
* as it was, because such a token cannot call Mitumba's APIs or be refreshed.
|
|
743
750
|
*
|
|
744
751
|
* @param input - The token exchange request (code, redirect URI, client, PKCE verifier, optional secret)
|
|
745
752
|
* @param options - Optional per-request options (abort signal, extra headers)
|
|
746
|
-
* @returns The access
|
|
747
|
-
* @throws {APIError} On `400 invalid_grant` (bad/expired/replayed code
|
|
753
|
+
* @returns The access token, granted scope, and either a refresh token (Mitumba session) or an id_token (relying party)
|
|
754
|
+
* @throws {APIError} On `400 invalid_grant` (bad/expired/replayed code or withdrawn consent), `401 invalid_client` (wrong secret), or `503 temporarily_unavailable` (token signing unavailable)
|
|
748
755
|
*
|
|
749
756
|
* @example
|
|
750
757
|
* ```typescript
|
|
@@ -763,10 +770,12 @@ var OAuthModule = class {
|
|
|
763
770
|
{ ...input, grant_type: "authorization_code" },
|
|
764
771
|
options
|
|
765
772
|
);
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
773
|
+
if (result.refresh_token) {
|
|
774
|
+
await this.client.setSession({
|
|
775
|
+
access_token: result.access_token,
|
|
776
|
+
refresh_token: result.refresh_token
|
|
777
|
+
});
|
|
778
|
+
}
|
|
770
779
|
return result;
|
|
771
780
|
}
|
|
772
781
|
/**
|
|
@@ -795,13 +804,17 @@ var OAuthModule = class {
|
|
|
795
804
|
return this.client.get("/auth/oauth/jwks.json", void 0, options);
|
|
796
805
|
}
|
|
797
806
|
/**
|
|
798
|
-
* Fetch the userinfo claim set
|
|
807
|
+
* Fetch the userinfo claim set.
|
|
799
808
|
*
|
|
800
|
-
* Returns `sub` plus the identity claims the
|
|
801
|
-
*
|
|
809
|
+
* Returns `sub` plus the identity claims the token's granted scopes allow. With a Mitumba session
|
|
810
|
+
* the SDK attaches the session's bearer token automatically. A relying party, whose client holds no
|
|
811
|
+
* Mitumba session (`exchangeCode()` does not set one for it), passes its own access token explicitly:
|
|
812
|
+
* `sdk.oauth.userinfo({ headers: { Authorization: `Bearer ${tokens.access_token}` } })`. A custom
|
|
813
|
+
* `Authorization` header never replaces an active session's token.
|
|
802
814
|
*
|
|
803
815
|
* @param options - Optional per-request options (abort signal, extra headers)
|
|
804
816
|
* @returns The userinfo claims
|
|
817
|
+
* @throws {APIError} On `401` with no token, or `401 invalid_token` for a token that is expired, revoked, or no longer consented
|
|
805
818
|
*/
|
|
806
819
|
async userinfo(options) {
|
|
807
820
|
return this.client.get("/auth/oauth/userinfo", void 0, options);
|
|
@@ -897,7 +910,6 @@ var ListingsModule = class {
|
|
|
897
910
|
constructor(client) {
|
|
898
911
|
this.client = client;
|
|
899
912
|
}
|
|
900
|
-
client;
|
|
901
913
|
/**
|
|
902
914
|
* Browse the marketplace feed with optional filters.
|
|
903
915
|
*/
|
|
@@ -1042,7 +1054,6 @@ var SearchModule = class {
|
|
|
1042
1054
|
constructor(client) {
|
|
1043
1055
|
this.client = client;
|
|
1044
1056
|
}
|
|
1045
|
-
client;
|
|
1046
1057
|
/**
|
|
1047
1058
|
* Perform a full-text search with optional filters.
|
|
1048
1059
|
*/
|
|
@@ -1082,7 +1093,6 @@ var OrdersModule = class {
|
|
|
1082
1093
|
constructor(client) {
|
|
1083
1094
|
this.client = client;
|
|
1084
1095
|
}
|
|
1085
|
-
client;
|
|
1086
1096
|
/**
|
|
1087
1097
|
* Create a new order from a listing.
|
|
1088
1098
|
*/
|
|
@@ -1118,7 +1128,6 @@ var PayModule = class {
|
|
|
1118
1128
|
constructor(client) {
|
|
1119
1129
|
this.client = client;
|
|
1120
1130
|
}
|
|
1121
|
-
client;
|
|
1122
1131
|
/**
|
|
1123
1132
|
* Initiate an M-Pesa STK Push payment for an order.
|
|
1124
1133
|
*/
|
|
@@ -1174,7 +1183,6 @@ var VaziModule = class {
|
|
|
1174
1183
|
constructor(client) {
|
|
1175
1184
|
this.client = client;
|
|
1176
1185
|
}
|
|
1177
|
-
client;
|
|
1178
1186
|
/**
|
|
1179
1187
|
* Browse the AI-curated outfit feed.
|
|
1180
1188
|
*/
|
|
@@ -1303,8 +1311,6 @@ var ManagedMessagesRealtimeConnection = class {
|
|
|
1303
1311
|
this.options = options;
|
|
1304
1312
|
this.currentCursor = options.resumeCursor ?? null;
|
|
1305
1313
|
}
|
|
1306
|
-
client;
|
|
1307
|
-
options;
|
|
1308
1314
|
currentState = "closed";
|
|
1309
1315
|
currentCursor;
|
|
1310
1316
|
socket = null;
|
|
@@ -1638,7 +1644,6 @@ var MessagesModule = class {
|
|
|
1638
1644
|
constructor(client) {
|
|
1639
1645
|
this.client = client;
|
|
1640
1646
|
}
|
|
1641
|
-
client;
|
|
1642
1647
|
/**
|
|
1643
1648
|
* Create a bilateral block from a v2 inbox perspective. A buyer blocks a store (`{ store_id }`);
|
|
1644
1649
|
* a store blocks a buyer (`{ buyer_id }`). Idempotent.
|
|
@@ -1824,7 +1829,6 @@ var NotificationsModule = class {
|
|
|
1824
1829
|
constructor(client) {
|
|
1825
1830
|
this.client = client;
|
|
1826
1831
|
}
|
|
1827
|
-
client;
|
|
1828
1832
|
/**
|
|
1829
1833
|
* List paginated notifications with unread count.
|
|
1830
1834
|
*/
|
|
@@ -1848,7 +1852,6 @@ var StoresModule = class {
|
|
|
1848
1852
|
constructor(client) {
|
|
1849
1853
|
this.client = client;
|
|
1850
1854
|
}
|
|
1851
|
-
client;
|
|
1852
1855
|
/**
|
|
1853
1856
|
* Get a store by its URL slug.
|
|
1854
1857
|
*/
|
|
@@ -1962,7 +1965,6 @@ var ReviewsModule = class {
|
|
|
1962
1965
|
constructor(client) {
|
|
1963
1966
|
this.client = client;
|
|
1964
1967
|
}
|
|
1965
|
-
client;
|
|
1966
1968
|
/**
|
|
1967
1969
|
* List reviews for a store (public).
|
|
1968
1970
|
*/
|
|
@@ -1996,7 +1998,6 @@ var WishlistsModule = class {
|
|
|
1996
1998
|
constructor(client) {
|
|
1997
1999
|
this.client = client;
|
|
1998
2000
|
}
|
|
1999
|
-
client;
|
|
2000
2001
|
/**
|
|
2001
2002
|
* List saved listings.
|
|
2002
2003
|
*/
|
|
@@ -2022,7 +2023,6 @@ var CartModule = class {
|
|
|
2022
2023
|
constructor(client) {
|
|
2023
2024
|
this.client = client;
|
|
2024
2025
|
}
|
|
2025
|
-
client;
|
|
2026
2026
|
/**
|
|
2027
2027
|
* List items in the cart.
|
|
2028
2028
|
*/
|
|
@@ -2060,7 +2060,6 @@ var SettingsModule = class {
|
|
|
2060
2060
|
constructor(client) {
|
|
2061
2061
|
this.client = client;
|
|
2062
2062
|
}
|
|
2063
|
-
client;
|
|
2064
2063
|
// ── Profile ──
|
|
2065
2064
|
async getProfile(options) {
|
|
2066
2065
|
return this.client.get("/auth/me", void 0, options);
|
|
@@ -2193,7 +2192,6 @@ var MailerModule = class {
|
|
|
2193
2192
|
constructor(client) {
|
|
2194
2193
|
this.client = client;
|
|
2195
2194
|
}
|
|
2196
|
-
client;
|
|
2197
2195
|
/**
|
|
2198
2196
|
* Send a transactional email via the notifications worker.
|
|
2199
2197
|
*/
|
|
@@ -2207,7 +2205,6 @@ var BusinessesModule = class {
|
|
|
2207
2205
|
constructor(client) {
|
|
2208
2206
|
this.client = client;
|
|
2209
2207
|
}
|
|
2210
|
-
client;
|
|
2211
2208
|
/** Get all businesses owned by the current user. */
|
|
2212
2209
|
async getMine(options) {
|
|
2213
2210
|
return this.client.get("/listings/businesses/mine", void 0, options);
|
|
@@ -2227,7 +2224,6 @@ var AdminModule = class {
|
|
|
2227
2224
|
constructor(client) {
|
|
2228
2225
|
this.client = client;
|
|
2229
2226
|
}
|
|
2230
|
-
client;
|
|
2231
2227
|
async blockIp(ip, reasonOrDuration = 24, durationOrOptions, maybeOptions) {
|
|
2232
2228
|
const modern = typeof reasonOrDuration === "string";
|
|
2233
2229
|
const reason = modern ? reasonOrDuration : "No reason supplied by legacy SDK caller";
|
|
@@ -2431,7 +2427,6 @@ var DisputesModule = class {
|
|
|
2431
2427
|
constructor(client) {
|
|
2432
2428
|
this.client = client;
|
|
2433
2429
|
}
|
|
2434
|
-
client;
|
|
2435
2430
|
/** Raise a dispute on an order (buyer). */
|
|
2436
2431
|
async raise(orderId, input, options) {
|
|
2437
2432
|
return this.client.post(`/orders/${orderId}/dispute`, input, options);
|
|
@@ -2479,7 +2474,6 @@ var UploadsModule = class {
|
|
|
2479
2474
|
constructor(client) {
|
|
2480
2475
|
this.client = client;
|
|
2481
2476
|
}
|
|
2482
|
-
client;
|
|
2483
2477
|
/** Upload a file (avatar, evidence, etc). Returns the public CDN URL. */
|
|
2484
2478
|
async upload(file, options) {
|
|
2485
2479
|
const formData = new FormData();
|
|
@@ -2493,7 +2487,6 @@ var ReportsModule = class {
|
|
|
2493
2487
|
constructor(client) {
|
|
2494
2488
|
this.client = client;
|
|
2495
2489
|
}
|
|
2496
|
-
client;
|
|
2497
2490
|
/** Report a listing, review, store, or user for admin review. */
|
|
2498
2491
|
async create(input, options) {
|
|
2499
2492
|
return this.client.post("/listings/reports", input, options);
|
|
@@ -2505,7 +2498,6 @@ var WholesaleModule = class {
|
|
|
2505
2498
|
constructor(client) {
|
|
2506
2499
|
this.client = client;
|
|
2507
2500
|
}
|
|
2508
|
-
client;
|
|
2509
2501
|
// ── Wholesale Store ──
|
|
2510
2502
|
/** Get the current user's wholesale store and depots. */
|
|
2511
2503
|
async getWholesaleStore(options) {
|
|
@@ -2641,7 +2633,6 @@ var IamModule = class {
|
|
|
2641
2633
|
constructor(client) {
|
|
2642
2634
|
this.client = client;
|
|
2643
2635
|
}
|
|
2644
|
-
client;
|
|
2645
2636
|
/** Start IAM sign-in with an organization ID or alias, email and password. */
|
|
2646
2637
|
async login(input, options) {
|
|
2647
2638
|
const result = await this.client.post("/auth/iam/login", input, options);
|
|
@@ -2778,7 +2769,6 @@ var MarketsModule = class {
|
|
|
2778
2769
|
constructor(client) {
|
|
2779
2770
|
this.client = client;
|
|
2780
2771
|
}
|
|
2781
|
-
client;
|
|
2782
2772
|
/**
|
|
2783
2773
|
* List the platform's markets: the countries Mitumba operates in or plans to, with each
|
|
2784
2774
|
* market's currency, locale, phone rules, region naming and payment rails.
|