@spacelr/sdk 0.15.0 → 0.16.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.mjs CHANGED
@@ -85,7 +85,11 @@ var SpacelrEmailVerificationRequiredError = class extends SpacelrError {
85
85
 
86
86
  // libs/sdk/src/core/http-client.ts
87
87
  function isStaleSessionBody(body) {
88
- return typeof body === "object" && body !== null && body["message"] === "stale_session";
88
+ if (typeof body !== "object" || body === null) {
89
+ return false;
90
+ }
91
+ const flat = body;
92
+ return flat["code"] === "STALE_SESSION" || flat["message"] === "stale_session";
89
93
  }
90
94
  var HttpClient = class {
91
95
  constructor(config, tokenManager) {
@@ -2361,6 +2365,42 @@ var AuthModule = class _AuthModule {
2361
2365
  authenticated: true
2362
2366
  });
2363
2367
  }
2368
+ // ─── Session management (#805 SP1) ───
2369
+ /**
2370
+ * List the active sessions for the signed-in user. Each entry is flagged
2371
+ * `current` when it corresponds to the caller's own access token.
2372
+ */
2373
+ async listSessions() {
2374
+ const { sessions } = await this.http.request({
2375
+ method: "GET",
2376
+ path: "/auth/sessions",
2377
+ authenticated: true
2378
+ });
2379
+ return sessions;
2380
+ }
2381
+ /**
2382
+ * Revoke a single session by id, signing it out. The server refuses to
2383
+ * revoke the caller's own current session through this endpoint.
2384
+ */
2385
+ async revokeSession(sessionId) {
2386
+ return this.http.request({
2387
+ method: "DELETE",
2388
+ path: `/auth/sessions/${encodeURIComponent(sessionId)}`,
2389
+ authenticated: true
2390
+ });
2391
+ }
2392
+ /**
2393
+ * Sign out every other active session for the current user, keeping the
2394
+ * caller's own session intact.
2395
+ */
2396
+ async signOutOtherSessions() {
2397
+ return this.http.request({
2398
+ method: "POST",
2399
+ path: "/auth/sessions/revoke-others",
2400
+ authenticated: true,
2401
+ body: {}
2402
+ });
2403
+ }
2364
2404
  async storeTokensFromRegister(response) {
2365
2405
  if (!response.access_token) return;
2366
2406
  const expiresAt = response.expires_in ? Math.floor(Date.now() / 1e3) + response.expires_in : void 0;