useMongocampSessions
The signed-in user's own sessions (server 3.0, AUTH_SESSIONS=true). Used by the Sessions card of MongocampAccount.
ts
const { list, revoke, revokeOthers } = useMongocampSessions()
const rows = await list() // SessionRow[] | null — null: the server has no sessions
await revoke(rows[1].id)
await revokeOthers(rows) // every session but the current onelist()—GET /auth/sessions(15 s timeout) as rows{ id, current, device, ip, createdAt, lastUsedAt, expiresAt }(times in ms,0= unknown): the current session first, then the most recently used.deviceis a short name from the user agent (Chrome · macOS,Safari · iOS; an unknown agent as it is, at most 60 characters;''without one —utils/sessions.tsdeviceLabel). A server without sessions answers the route with404, which resolvesnull.revoke(id)—DELETE /auth/sessions/{id}: the session's refresh token and its access tokens stop working at once (on other server instances within 5 minutes). A session that is already gone (404) counts as ended.revokeOthers(rows)—revokefor every row that is notcurrent, one request each, stops at the first refusal; answers how many it ended. The server's ownDELETE /auth/sessionsends the current session too — for "sign out everywhere" use the dependency'suseMongocampAuth().revokeAllSessions(), which also clears the local session.
The refresh itself is the dependency's: with sessions its useMongocampAuth() refreshes through the httpOnly cookie mongocamp_refresh (same origin: the embedded server or a proxy) when the mongocamp.refreshToken option is on. A refresh token used a second time after the grace period ends the whole session (401, code 4014) — the dependency logs out, and MongocampErrorAlert says the session was ended elsewhere.
Not available in server proxy mode (there is no login).