Skip to content

ConnectionModel

Defined in: packages/core/src/models/connections.ts:27

Data operations for user OAuth connections, addressed by (user, service). Plaintext only leaves through accessToken; a token is refreshed lazily, when its owner (or a request on their behalf) needs it — never in the background.

new ConnectionModel(db, secret?, tables?): ConnectionModel

Defined in: packages/core/src/models/connections.ts:32

DatabaseAdapter

SecretInput

ConnectionTables

ConnectionModel

accessToken(userId, service, oauth?, now?): Promise<string | null>

Defined in: packages/core/src/models/connections.ts:92

A usable access token, refreshing it (once, under concurrent calls) when it is about to expire. A failed refresh marks the connection expired and returns null until the user reconnects.

string

string

Pick<OAuthClient, "refresh">

Date = ...

Promise<string | null>


connect(userId, service, tokens): Promise<void>

Defined in: packages/core/src/models/connections.ts:58

Store (or replace) a connection from fresh tokens; resets it to healthy.

string

string

OAuthTokens

Promise<void>


info(userId, service): Promise<UserConnection | null>

Defined in: packages/core/src/models/connections.ts:39

The connection row (never the plaintext), or null.

string

string

Promise<UserConnection | null>


listForUser(userId): Promise<UserConnection[]>

Defined in: packages/core/src/models/connections.ts:51

Every connection of a user (no plaintext), for a “connected apps” list.

string

Promise<UserConnection[]>


remove(userId, service): Promise<void>

Defined in: packages/core/src/models/connections.ts:82

Remove a connection.

string

string

Promise<void>