@mitumba/sdk 3.1.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 +55 -7
- package/dist/index.d.ts +55 -7
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -227,6 +227,13 @@ var APIClient = class {
|
|
|
227
227
|
this.config.refreshToken = void 0;
|
|
228
228
|
await this.tokenStore.clear();
|
|
229
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* The current stored refresh token, or null if none. Exposed so logout can revoke the exact
|
|
232
|
+
* token the SDK holds rather than relying on the caller to supply (or guess) it.
|
|
233
|
+
*/
|
|
234
|
+
async getStoredRefreshToken() {
|
|
235
|
+
return this.config.refreshToken ?? await this.tokenStore.getRefreshToken();
|
|
236
|
+
}
|
|
230
237
|
/**
|
|
231
238
|
* Check if user has a stored session (access or refresh token available).
|
|
232
239
|
*/
|
|
@@ -471,12 +478,28 @@ var AuthModule = class {
|
|
|
471
478
|
return result;
|
|
472
479
|
}
|
|
473
480
|
/**
|
|
474
|
-
*
|
|
481
|
+
* Log out: revoke the current server session and clear the stored tokens.
|
|
482
|
+
*
|
|
483
|
+
* Reads the refresh token the SDK holds and revokes exactly that session server-side, then
|
|
484
|
+
* always clears local tokens — even if the network call fails or there was no token — so the
|
|
485
|
+
* device is signed out regardless. Idempotent: a second call is a no-op that still resolves.
|
|
486
|
+
*
|
|
487
|
+
* @returns `{ ok, revoked }` where `revoked` is true only when the server confirmed revocation.
|
|
488
|
+
* `revoked: false` means local credentials were cleared but the server session may persist
|
|
489
|
+
* until expiry (offline, or already revoked) — callers should not claim remote sign-out then.
|
|
475
490
|
*/
|
|
476
|
-
async logout(
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
491
|
+
async logout(options) {
|
|
492
|
+
const refreshToken = await this.client.getStoredRefreshToken();
|
|
493
|
+
let revoked = false;
|
|
494
|
+
try {
|
|
495
|
+
if (refreshToken) {
|
|
496
|
+
await this.client.post("/auth/logout", { refresh_token: refreshToken }, options);
|
|
497
|
+
revoked = true;
|
|
498
|
+
}
|
|
499
|
+
} finally {
|
|
500
|
+
await this.client.clearToken();
|
|
501
|
+
}
|
|
502
|
+
return { ok: true, revoked };
|
|
480
503
|
}
|
|
481
504
|
/**
|
|
482
505
|
* Request a password reset email.
|
|
@@ -1826,6 +1849,13 @@ var SettingsModule = class {
|
|
|
1826
1849
|
async getProfile(options) {
|
|
1827
1850
|
return this.client.get("/auth/me", void 0, options);
|
|
1828
1851
|
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Update the current user's profile. Only the provided fields change. Returns the updated
|
|
1854
|
+
* {@link UserProfile}. See {@link UpdateProfileInput} for the server-enforced contract.
|
|
1855
|
+
*
|
|
1856
|
+
* @throws {APIError} `invalid_input` (400) when a field violates the contract, and
|
|
1857
|
+
* `phone_taken` (409) when the phone number already belongs to another account.
|
|
1858
|
+
*/
|
|
1829
1859
|
async updateProfile(input, options) {
|
|
1830
1860
|
return this.client.put("/auth/me", input, options);
|
|
1831
1861
|
}
|