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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ConnectionModel(
db,secret?,tables?):ConnectionModel
Defined in: packages/core/src/models/connections.ts:32
Parameters
Section titled “Parameters”secret?
Section titled “secret?”tables?
Section titled “tables?”Returns
Section titled “Returns”ConnectionModel
Methods
Section titled “Methods”accessToken()
Section titled “accessToken()”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.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
service
Section titled “service”string
oauth?
Section titled “oauth?”Pick<OAuthClient, "refresh">
Date = ...
Returns
Section titled “Returns”Promise<string | null>
connect()
Section titled “connect()”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.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
service
Section titled “service”string
tokens
Section titled “tokens”Returns
Section titled “Returns”Promise<void>
info()
Section titled “info()”info(
userId,service):Promise<UserConnection|null>
Defined in: packages/core/src/models/connections.ts:39
The connection row (never the plaintext), or null.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
service
Section titled “service”string
Returns
Section titled “Returns”Promise<UserConnection | null>
listForUser()
Section titled “listForUser()”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.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<UserConnection[]>
remove()
Section titled “remove()”remove(
userId,service):Promise<void>
Defined in: packages/core/src/models/connections.ts:82
Remove a connection.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
service
Section titled “service”string
Returns
Section titled “Returns”Promise<void>