Skip to content

BeechCMS


BeechCMS / @beechcms/core / IOAuthTokenRepository

Interface: IOAuthTokenRepository ​

Methods ​

findActiveByHash() ​

findActiveByHash(tokenHash, tokenType, nowTimestamp): Promise<OAuthTokenRecord | null>

Finds an unexpired, unrevoked token by hash and type.

Parameters ​

tokenHash ​

string

tokenType ​

OAuthTokenType

nowTimestamp ​

number

Returns ​

Promise<OAuthTokenRecord | null>


findByHash() ​

findByHash(tokenHash, tokenType): Promise<OAuthTokenRecord | null>

Finds a token by hash and type in any state (expired or revoked included).

Parameters ​

tokenHash ​

string

tokenType ​

OAuthTokenType

Returns ​

Promise<OAuthTokenRecord | null>


listAuthorizedClientsForUser() ​

listAuthorizedClientsForUser(userId, nowTimestamp): Promise<AuthorizedClientSummary[]>

Lists the clients holding at least one live token for this user, newest first.

Parameters ​

userId ​

string

nowTimestamp ​

number

Returns ​

Promise<AuthorizedClientSummary[]>


revokeAllForClientAndUser() ​

revokeAllForClientAndUser(clientId, userId, nowTimestamp): Promise<number>

Revokes every live token for one (client, user) pair — access AND refresh, never one without the other. Backs "revoke this app" in the dashboard.

Parameters ​

clientId ​

string

userId ​

string

nowTimestamp ​

number

Returns ​

Promise<number>


revokeByAuthorizationCode() ​

revokeByAuthorizationCode(authorizationCodeHash, nowTimestamp): Promise<number>

Revokes EVERY token descending from one authorization code, both access and refresh. Called on authorization-code replay (OAuth 2.1 §4.1.3). Returns the number of tokens revoked.

Parameters ​

authorizationCodeHash ​

string

nowTimestamp ​

number

Returns ​

Promise<number>


revokeByHash() ​

revokeByHash(tokenHash, nowTimestamp): Promise<boolean>

Revokes a single token. False when already revoked or absent.

Parameters ​

tokenHash ​

string

nowTimestamp ​

number

Returns ​

Promise<boolean>


save() ​

save(record): Promise<void>

Parameters ​

record ​

NewOAuthToken

Returns ​

Promise<void>