Sessions

Get and revoke auth sessions
View as Markdown

Get a session

Check the status of an auth session:

1import { Gwop } from "@gwop/sdk";
2
3const gwop = new Gwop({
4 merchantApiKey: process.env.GWOP_MERCHANT_API_KEY,
5});
6
7const { result: session } = await gwop.authSessions.get({
8 sessionId: "sess_abc123",
9});
10
11console.log(session.status); // "active", "revoked", or "expired"
12console.log(session.sub); // "base:0x742d..." — wallet identity
13console.log(session.chain); // "base" or "solana"
14console.log(session.walletAddress); // "0x742d35Cc..."
15console.log(session.createdAt); // Session creation timestamp
16console.log(session.expiresAt); // Session expiry
17console.log(session.revokedAt); // null if active, Date if revoked

Session fields

FieldTypeDescription
sessionIdstringSession identifier
statusstringactive, revoked, or expired
substringWallet identity ({chain}:{address})
chainstringbase or solana
walletAddressstringRaw wallet address
createdAtDateWhen the session was created
expiresAtDateWhen the session expires
revokedAtDate | nullWhen the session was revoked, or null

Revoke a session

Revoke an active session (logout):

1const { result } = await gwop.authSessions.revoke({
2 sessionId: "sess_abc123",
3});

Errors

1import * as errors from "@gwop/sdk/models/errors";
2
3try {
4 await gwop.authSessions.get({ sessionId: "sess_invalid" });
5} catch (err) {
6 if (err instanceof errors.ErrorResponse) {
7 err.data$.error.code; // "SESSION_NOT_FOUND"
8 err.data$.error.message; // "Session not found"
9 err.statusCode; // 404
10 }
11}

Next step