@mitumba/sdk 4.0.0 → 5.0.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 +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1518,6 +1518,12 @@ interface Order {
|
|
|
1518
1518
|
listing_condition: string | null;
|
|
1519
1519
|
listing_size: string | null;
|
|
1520
1520
|
buyer_name: string | null;
|
|
1521
|
+
/**
|
|
1522
|
+
* The buyer's county. Not sensitive — always returned to both parties, including to the seller
|
|
1523
|
+
* before payment (with `buyer_name`) while `buyer_phone`/`delivery_address` are withheld.
|
|
1524
|
+
* (Mitumba-Ltd/mitumba#321)
|
|
1525
|
+
*/
|
|
1526
|
+
buyer_county: string | null;
|
|
1521
1527
|
/**
|
|
1522
1528
|
* The buyer's phone. Visible to the buyer at any status. Visible to the seller **only** while
|
|
1523
1529
|
* they are handing the parcel over — statuses `paid`, `seller_confirmed`, `shipped`,
|
|
@@ -2403,6 +2409,11 @@ declare class APIClient {
|
|
|
2403
2409
|
/** Create an isomorphic WebSocket using the configured or global transport. */
|
|
2404
2410
|
createWebSocket(url: string, protocols: string | string[]): WebSocketLike;
|
|
2405
2411
|
clearToken(): Promise<void>;
|
|
2412
|
+
/**
|
|
2413
|
+
* The current stored refresh token, or null if none. Exposed so logout can revoke the exact
|
|
2414
|
+
* token the SDK holds rather than relying on the caller to supply (or guess) it.
|
|
2415
|
+
*/
|
|
2416
|
+
getStoredRefreshToken(): Promise<string | null>;
|
|
2406
2417
|
/**
|
|
2407
2418
|
* Check if user has a stored session (access or refresh token available).
|
|
2408
2419
|
*/
|
|
@@ -2451,12 +2462,19 @@ declare class AuthModule {
|
|
|
2451
2462
|
refresh_token: string;
|
|
2452
2463
|
}, options?: RequestOptions): Promise<AuthTokens>;
|
|
2453
2464
|
/**
|
|
2454
|
-
*
|
|
2465
|
+
* Log out: revoke the current server session and clear the stored tokens.
|
|
2466
|
+
*
|
|
2467
|
+
* Reads the refresh token the SDK holds and revokes exactly that session server-side, then
|
|
2468
|
+
* always clears local tokens — even if the network call fails or there was no token — so the
|
|
2469
|
+
* device is signed out regardless. Idempotent: a second call is a no-op that still resolves.
|
|
2470
|
+
*
|
|
2471
|
+
* @returns `{ ok, revoked }` where `revoked` is true only when the server confirmed revocation.
|
|
2472
|
+
* `revoked: false` means local credentials were cleared but the server session may persist
|
|
2473
|
+
* until expiry (offline, or already revoked) — callers should not claim remote sign-out then.
|
|
2455
2474
|
*/
|
|
2456
|
-
logout(
|
|
2457
|
-
refresh_token: string;
|
|
2458
|
-
}, options?: RequestOptions): Promise<{
|
|
2475
|
+
logout(options?: RequestOptions): Promise<{
|
|
2459
2476
|
ok: boolean;
|
|
2477
|
+
revoked: boolean;
|
|
2460
2478
|
}>;
|
|
2461
2479
|
/**
|
|
2462
2480
|
* Request a password reset email.
|
package/dist/index.d.ts
CHANGED
|
@@ -1518,6 +1518,12 @@ interface Order {
|
|
|
1518
1518
|
listing_condition: string | null;
|
|
1519
1519
|
listing_size: string | null;
|
|
1520
1520
|
buyer_name: string | null;
|
|
1521
|
+
/**
|
|
1522
|
+
* The buyer's county. Not sensitive — always returned to both parties, including to the seller
|
|
1523
|
+
* before payment (with `buyer_name`) while `buyer_phone`/`delivery_address` are withheld.
|
|
1524
|
+
* (Mitumba-Ltd/mitumba#321)
|
|
1525
|
+
*/
|
|
1526
|
+
buyer_county: string | null;
|
|
1521
1527
|
/**
|
|
1522
1528
|
* The buyer's phone. Visible to the buyer at any status. Visible to the seller **only** while
|
|
1523
1529
|
* they are handing the parcel over — statuses `paid`, `seller_confirmed`, `shipped`,
|
|
@@ -2403,6 +2409,11 @@ declare class APIClient {
|
|
|
2403
2409
|
/** Create an isomorphic WebSocket using the configured or global transport. */
|
|
2404
2410
|
createWebSocket(url: string, protocols: string | string[]): WebSocketLike;
|
|
2405
2411
|
clearToken(): Promise<void>;
|
|
2412
|
+
/**
|
|
2413
|
+
* The current stored refresh token, or null if none. Exposed so logout can revoke the exact
|
|
2414
|
+
* token the SDK holds rather than relying on the caller to supply (or guess) it.
|
|
2415
|
+
*/
|
|
2416
|
+
getStoredRefreshToken(): Promise<string | null>;
|
|
2406
2417
|
/**
|
|
2407
2418
|
* Check if user has a stored session (access or refresh token available).
|
|
2408
2419
|
*/
|
|
@@ -2451,12 +2462,19 @@ declare class AuthModule {
|
|
|
2451
2462
|
refresh_token: string;
|
|
2452
2463
|
}, options?: RequestOptions): Promise<AuthTokens>;
|
|
2453
2464
|
/**
|
|
2454
|
-
*
|
|
2465
|
+
* Log out: revoke the current server session and clear the stored tokens.
|
|
2466
|
+
*
|
|
2467
|
+
* Reads the refresh token the SDK holds and revokes exactly that session server-side, then
|
|
2468
|
+
* always clears local tokens — even if the network call fails or there was no token — so the
|
|
2469
|
+
* device is signed out regardless. Idempotent: a second call is a no-op that still resolves.
|
|
2470
|
+
*
|
|
2471
|
+
* @returns `{ ok, revoked }` where `revoked` is true only when the server confirmed revocation.
|
|
2472
|
+
* `revoked: false` means local credentials were cleared but the server session may persist
|
|
2473
|
+
* until expiry (offline, or already revoked) — callers should not claim remote sign-out then.
|
|
2455
2474
|
*/
|
|
2456
|
-
logout(
|
|
2457
|
-
refresh_token: string;
|
|
2458
|
-
}, options?: RequestOptions): Promise<{
|
|
2475
|
+
logout(options?: RequestOptions): Promise<{
|
|
2459
2476
|
ok: boolean;
|
|
2477
|
+
revoked: boolean;
|
|
2460
2478
|
}>;
|
|
2461
2479
|
/**
|
|
2462
2480
|
* Request a password reset email.
|
package/dist/index.js
CHANGED
|
@@ -229,6 +229,13 @@ var APIClient = class {
|
|
|
229
229
|
this.config.refreshToken = void 0;
|
|
230
230
|
await this.tokenStore.clear();
|
|
231
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* The current stored refresh token, or null if none. Exposed so logout can revoke the exact
|
|
234
|
+
* token the SDK holds rather than relying on the caller to supply (or guess) it.
|
|
235
|
+
*/
|
|
236
|
+
async getStoredRefreshToken() {
|
|
237
|
+
return this.config.refreshToken ?? await this.tokenStore.getRefreshToken();
|
|
238
|
+
}
|
|
232
239
|
/**
|
|
233
240
|
* Check if user has a stored session (access or refresh token available).
|
|
234
241
|
*/
|
|
@@ -473,12 +480,28 @@ var AuthModule = class {
|
|
|
473
480
|
return result;
|
|
474
481
|
}
|
|
475
482
|
/**
|
|
476
|
-
*
|
|
483
|
+
* Log out: revoke the current server session and clear the stored tokens.
|
|
484
|
+
*
|
|
485
|
+
* Reads the refresh token the SDK holds and revokes exactly that session server-side, then
|
|
486
|
+
* always clears local tokens — even if the network call fails or there was no token — so the
|
|
487
|
+
* device is signed out regardless. Idempotent: a second call is a no-op that still resolves.
|
|
488
|
+
*
|
|
489
|
+
* @returns `{ ok, revoked }` where `revoked` is true only when the server confirmed revocation.
|
|
490
|
+
* `revoked: false` means local credentials were cleared but the server session may persist
|
|
491
|
+
* until expiry (offline, or already revoked) — callers should not claim remote sign-out then.
|
|
477
492
|
*/
|
|
478
|
-
async logout(
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
493
|
+
async logout(options) {
|
|
494
|
+
const refreshToken = await this.client.getStoredRefreshToken();
|
|
495
|
+
let revoked = false;
|
|
496
|
+
try {
|
|
497
|
+
if (refreshToken) {
|
|
498
|
+
await this.client.post("/auth/logout", { refresh_token: refreshToken }, options);
|
|
499
|
+
revoked = true;
|
|
500
|
+
}
|
|
501
|
+
} finally {
|
|
502
|
+
await this.client.clearToken();
|
|
503
|
+
}
|
|
504
|
+
return { ok: true, revoked };
|
|
482
505
|
}
|
|
483
506
|
/**
|
|
484
507
|
* Request a password reset email.
|