File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ import {
5555 recordPasswordResetAudit ,
5656} from '@/lib/auth/lifecycle-audit'
5757import { hashOAuthToken } from '@/lib/auth/oauth-access-token'
58+ import { revokeUserOAuthGrants } from '@/lib/auth/oauth-grants'
5859import {
5960 consentRequestNamesClient ,
6061 OAUTH_ACCESS_TOKEN_PREFIX ,
@@ -67,7 +68,6 @@ import {
6768 SIM_CLI_CLIENT_ID ,
6869} from '@/lib/auth/oauth-provider'
6970import { bindOAuthIssuedResource , oauthResourcePlugin } from '@/lib/auth/oauth-resource'
70- import { revokeUserOAuthGrants } from '@/lib/auth/oauth-token-family'
7171import { getSessionCookieCacheVersion } from '@/lib/auth/security-policy'
7272import { prepareSessionForCreation } from '@/lib/auth/session-hooks'
7373import { clampExpiryForSession } from '@/lib/auth/session-policy'
Original file line number Diff line number Diff line change 1+ import { db } from '@sim/db'
2+ import { oauthAccessToken , oauthTokenFamily } from '@sim/db/schema'
3+ import { eq } from 'drizzle-orm'
4+ import type { DbOrTx } from '@/lib/db/types'
5+
6+ /**
7+ * Revokes every refresh family and access token a user holds. Families outlive the session that
8+ * minted them (`session_id` is set null on delete), so deleting sessions alone leaves them
9+ * rotatable. Consents are kept, so a legitimate client re-authorizes without a new consent prompt.
10+ */
11+ export async function revokeUserOAuthGrants ( userId : string , database : DbOrTx = db ) : Promise < void > {
12+ await database . delete ( oauthTokenFamily ) . where ( eq ( oauthTokenFamily . userId , userId ) )
13+ await database . delete ( oauthAccessToken ) . where ( eq ( oauthAccessToken . userId , userId ) )
14+ }
Original file line number Diff line number Diff line change @@ -493,19 +493,6 @@ export async function rotateOAuthRefreshToken(
493493 } )
494494}
495495
496- /**
497- * Revokes every refresh family and access token a user holds. Families outlive the session that
498- * minted them (`session_id` is set null on delete), so deleting sessions alone leaves them
499- * rotatable. Consents are kept, so a legitimate client re-authorizes without a new consent prompt.
500- */
501- export async function revokeUserOAuthGrants (
502- userId : string ,
503- database : OAuthDatabase = db
504- ) : Promise < void > {
505- await database . delete ( oauthTokenFamily ) . where ( eq ( oauthTokenFamily . userId , userId ) )
506- await database . delete ( oauthAccessToken ) . where ( eq ( oauthAccessToken . userId , userId ) )
507- }
508-
509496/** Revokes one refresh family or one opaque access token. Unknown tokens are a successful no-op. */
510497export async function revokeOAuthToken (
511498 input : { credentials : OAuthClientCredentials ; token : string } ,
You can’t perform that action at this time.
0 commit comments