@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.d.mts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -307,6 +307,21 @@ interface PasskeyCredential {
|
|
|
307
307
|
createdAt: string;
|
|
308
308
|
lastUsedAt?: string;
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* A single active session, as returned by the session-list endpoint (#805).
|
|
312
|
+
* `current` marks the session tied to the caller's own access token.
|
|
313
|
+
*/
|
|
314
|
+
interface SessionSummary {
|
|
315
|
+
sessionId: string;
|
|
316
|
+
current: boolean;
|
|
317
|
+
clientId: string;
|
|
318
|
+
credentialId?: string;
|
|
319
|
+
userAgent?: string;
|
|
320
|
+
ip?: string;
|
|
321
|
+
country?: string;
|
|
322
|
+
createdAt: string;
|
|
323
|
+
lastSeenAt: string;
|
|
324
|
+
}
|
|
310
325
|
|
|
311
326
|
interface TokenStorage {
|
|
312
327
|
getTokens(): Promise<StoredTokens | null>;
|
|
@@ -1222,6 +1237,25 @@ declare class AuthModule {
|
|
|
1222
1237
|
* their recovery phrase. Authenticated.
|
|
1223
1238
|
*/
|
|
1224
1239
|
getRecoveryStatus(): Promise<RecoveryStatusResponse>;
|
|
1240
|
+
/**
|
|
1241
|
+
* List the active sessions for the signed-in user. Each entry is flagged
|
|
1242
|
+
* `current` when it corresponds to the caller's own access token.
|
|
1243
|
+
*/
|
|
1244
|
+
listSessions(): Promise<SessionSummary[]>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Revoke a single session by id, signing it out. The server refuses to
|
|
1247
|
+
* revoke the caller's own current session through this endpoint.
|
|
1248
|
+
*/
|
|
1249
|
+
revokeSession(sessionId: string): Promise<{
|
|
1250
|
+
revoked: true;
|
|
1251
|
+
}>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Sign out every other active session for the current user, keeping the
|
|
1254
|
+
* caller's own session intact.
|
|
1255
|
+
*/
|
|
1256
|
+
signOutOtherSessions(): Promise<{
|
|
1257
|
+
revokedCount: number;
|
|
1258
|
+
}>;
|
|
1225
1259
|
private storeTokensFromRegister;
|
|
1226
1260
|
}
|
|
1227
1261
|
|
package/dist/index.d.ts
CHANGED
|
@@ -307,6 +307,21 @@ interface PasskeyCredential {
|
|
|
307
307
|
createdAt: string;
|
|
308
308
|
lastUsedAt?: string;
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* A single active session, as returned by the session-list endpoint (#805).
|
|
312
|
+
* `current` marks the session tied to the caller's own access token.
|
|
313
|
+
*/
|
|
314
|
+
interface SessionSummary {
|
|
315
|
+
sessionId: string;
|
|
316
|
+
current: boolean;
|
|
317
|
+
clientId: string;
|
|
318
|
+
credentialId?: string;
|
|
319
|
+
userAgent?: string;
|
|
320
|
+
ip?: string;
|
|
321
|
+
country?: string;
|
|
322
|
+
createdAt: string;
|
|
323
|
+
lastSeenAt: string;
|
|
324
|
+
}
|
|
310
325
|
|
|
311
326
|
interface TokenStorage {
|
|
312
327
|
getTokens(): Promise<StoredTokens | null>;
|
|
@@ -1222,6 +1237,25 @@ declare class AuthModule {
|
|
|
1222
1237
|
* their recovery phrase. Authenticated.
|
|
1223
1238
|
*/
|
|
1224
1239
|
getRecoveryStatus(): Promise<RecoveryStatusResponse>;
|
|
1240
|
+
/**
|
|
1241
|
+
* List the active sessions for the signed-in user. Each entry is flagged
|
|
1242
|
+
* `current` when it corresponds to the caller's own access token.
|
|
1243
|
+
*/
|
|
1244
|
+
listSessions(): Promise<SessionSummary[]>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Revoke a single session by id, signing it out. The server refuses to
|
|
1247
|
+
* revoke the caller's own current session through this endpoint.
|
|
1248
|
+
*/
|
|
1249
|
+
revokeSession(sessionId: string): Promise<{
|
|
1250
|
+
revoked: true;
|
|
1251
|
+
}>;
|
|
1252
|
+
/**
|
|
1253
|
+
* Sign out every other active session for the current user, keeping the
|
|
1254
|
+
* caller's own session intact.
|
|
1255
|
+
*/
|
|
1256
|
+
signOutOtherSessions(): Promise<{
|
|
1257
|
+
revokedCount: number;
|
|
1258
|
+
}>;
|
|
1225
1259
|
private storeTokensFromRegister;
|
|
1226
1260
|
}
|
|
1227
1261
|
|
package/dist/index.js
CHANGED
|
@@ -132,7 +132,11 @@ var SpacelrEmailVerificationRequiredError = class extends SpacelrError {
|
|
|
132
132
|
|
|
133
133
|
// libs/sdk/src/core/http-client.ts
|
|
134
134
|
function isStaleSessionBody(body) {
|
|
135
|
-
|
|
135
|
+
if (typeof body !== "object" || body === null) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
const flat = body;
|
|
139
|
+
return flat["code"] === "STALE_SESSION" || flat["message"] === "stale_session";
|
|
136
140
|
}
|
|
137
141
|
var HttpClient = class {
|
|
138
142
|
constructor(config, tokenManager) {
|
|
@@ -2408,6 +2412,42 @@ var AuthModule = class _AuthModule {
|
|
|
2408
2412
|
authenticated: true
|
|
2409
2413
|
});
|
|
2410
2414
|
}
|
|
2415
|
+
// ─── Session management (#805 SP1) ───
|
|
2416
|
+
/**
|
|
2417
|
+
* List the active sessions for the signed-in user. Each entry is flagged
|
|
2418
|
+
* `current` when it corresponds to the caller's own access token.
|
|
2419
|
+
*/
|
|
2420
|
+
async listSessions() {
|
|
2421
|
+
const { sessions } = await this.http.request({
|
|
2422
|
+
method: "GET",
|
|
2423
|
+
path: "/auth/sessions",
|
|
2424
|
+
authenticated: true
|
|
2425
|
+
});
|
|
2426
|
+
return sessions;
|
|
2427
|
+
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Revoke a single session by id, signing it out. The server refuses to
|
|
2430
|
+
* revoke the caller's own current session through this endpoint.
|
|
2431
|
+
*/
|
|
2432
|
+
async revokeSession(sessionId) {
|
|
2433
|
+
return this.http.request({
|
|
2434
|
+
method: "DELETE",
|
|
2435
|
+
path: `/auth/sessions/${encodeURIComponent(sessionId)}`,
|
|
2436
|
+
authenticated: true
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* Sign out every other active session for the current user, keeping the
|
|
2441
|
+
* caller's own session intact.
|
|
2442
|
+
*/
|
|
2443
|
+
async signOutOtherSessions() {
|
|
2444
|
+
return this.http.request({
|
|
2445
|
+
method: "POST",
|
|
2446
|
+
path: "/auth/sessions/revoke-others",
|
|
2447
|
+
authenticated: true,
|
|
2448
|
+
body: {}
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2411
2451
|
async storeTokensFromRegister(response) {
|
|
2412
2452
|
if (!response.access_token) return;
|
|
2413
2453
|
const expiresAt = response.expires_in ? Math.floor(Date.now() / 1e3) + response.expires_in : void 0;
|