?
EventGrantResult
TypeWhat events.grant returns: the subscribe token and when it expires.
The result of minting a grant. The token is what the client presents to subscribe; expiresAt and ttlSeconds describe its lifetime, which is also the revocation window. Return the whole object from your subscribe method, or at least the token; the Interface SDK's events client re-invokes that method to re-mint when the grant expires.
EventGrantResult.ts
interface EventGrantResult { token: string expiresAt: number ttlSeconds: number }
Fields
token
string
Bearer token the client passes to the events stream (the Interface SDK's getToken, or Authorization: Bearer on GET /_/events).
expiresAt
number
Milliseconds since epoch; the stream closes at this instant and the client re-mints.
ttlSeconds
number
The clamped lifetime actually applied, between 60 and 3600.
Hand the token to the client
const grant = await events.grant(`user:${auth.userId}`); return { token: grant.token }; // the frontend's getToken returns this