Changeset 2d66d66 in Klonkt for src/services/OAuthService.js
- Timestamp:
- 07/19/2026 04:17:44 PM (7 weeks ago)
- Branches:
- main
- Children:
- 33e1dbd
- Parents:
- 4407c67
- git-author:
- Robin <roboburr@…> (07/19/2026 04:17:27 PM)
- git-committer:
- Robin <roboburr@…> (07/19/2026 04:17:44 PM)
- File:
-
- 1 edited
-
src/services/OAuthService.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/services/OAuthService.js
r4407c67 r2d66d66 109 109 } 110 110 111 export default { registerClient, getClient, createCode, exchangeCode, verifyBearer, revokeToken, validRedirectUri }; 111 // The active authorizations (bearer tokens) a user has granted, with the app 112 // name and the site each is scoped to. The bearer itself is never stored, so 113 // revocation is keyed on token_hash: safe to render, you cannot derive the 114 // token from its hash. 115 export function listAuthorizations(userId) { 116 return db.prepare(` 117 SELECT t.token_hash, t.site_slug, t.scope, t.created_at, t.last_used_at, c.client_name 118 FROM oauth_tokens t 119 LEFT JOIN oauth_clients c ON c.client_id = t.client_id 120 WHERE t.user_id = ? 121 ORDER BY t.created_at DESC 122 `).all(String(userId || '')); 123 } 124 125 // Revoke one authorization, scoped to the owner so a user can only revoke their 126 // own tokens. Returns true when a row was removed. 127 export function revokeAuthorization(userId, tokenHash) { 128 try { 129 const r = db.prepare('DELETE FROM oauth_tokens WHERE token_hash = ? AND user_id = ?') 130 .run(String(tokenHash || ''), String(userId || '')); 131 return r.changes > 0; 132 } catch { return false; } 133 } 134 135 export default { 136 registerClient, getClient, createCode, exchangeCode, verifyBearer, revokeToken, validRedirectUri, 137 listAuthorizations, revokeAuthorization, 138 };
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)