feat(core): API support helpers: token list, suggestions, attachment links, connection runs, device auth, file-mode sync
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7f3d0d5c44
commit
7b0a6738dd
@@ -198,3 +198,31 @@ export async function revokeAppToken(db: Db, userId: string, id: string): Promis
|
||||
.where("revoked_at", "is", null)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export interface AppTokenInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
scopes: TokenScope[];
|
||||
lastUsedAt: string | null;
|
||||
revokedAt: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
/** The user's app tokens, newest first. Metadata only: the token and its hash are never returned. */
|
||||
export async function listAppTokens(db: Db, userId: string): Promise<AppTokenInfo[]> {
|
||||
const rows = await db.k
|
||||
.selectFrom("app_tokens")
|
||||
.select(["id", "name", "scopes", "last_used_at", "revoked_at", "created_at"])
|
||||
.where("user_id", "=", userId)
|
||||
.orderBy("created_at", "desc")
|
||||
.orderBy("id", "desc")
|
||||
.execute();
|
||||
return rows.map((r) => ({
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
scopes: fromJson<TokenScope[]>(r.scopes, []),
|
||||
lastUsedAt: r.last_used_at,
|
||||
revokedAt: r.revoked_at,
|
||||
createdAt: r.created_at,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user