ForgeRemoteTokenManager
Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:64
Manages offline user impersonation tokens for Forge Remote backends.
Similar to OfflineTokenManager but authenticates using an appSystemToken
from the inbound invocation payload instead of relying on Container identity.
Because Forge Remotes are stateless per-invocation handlers, this manager is typically instantiated fresh per request. Token caching is still valuable within a single invocation that makes multiple API calls for the same user, and across warm Lambda / Cloud Run invocations where the handler module stays alive.
Example
Section titled “Example”import { ForgeRemoteAdapter, ForgeRemoteTokenManager, asOfflineUser } from '@forge-clients/core';import { getIssue } from '@forge-clients/jira/v3';
export async function handler(payload: ForgeInvocationPayload) { const adapter = new ForgeRemoteAdapter({ product: 'jira', proxyUrl, installationId: payload.installationId, appSystemToken: payload.appSystemToken }); const tokenManager = new ForgeRemoteTokenManager({ proxyUrl, installationId: payload.installationId, appSystemToken: payload.appSystemToken });
const token = await tokenManager.getToken(payload.context.accountId!); const client = asOfflineUser(adapter, token.accountId, token.accessToken); return getIssue(client, { path: { issueIdOrKey: 'PROJ-1' } });}Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ForgeRemoteTokenManager(
opts):ForgeRemoteTokenManager
Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:72
Create a new ForgeRemoteTokenManager.
Parameters
Section titled “Parameters”ForgeRemoteTokenManagerOptions
Configuration including the proxy URL, installation ID, and app system token
Returns
Section titled “Returns”ForgeRemoteTokenManager
Methods
Section titled “Methods”boundClient()
Section titled “boundClient()”boundClient(
adapter,accountId):Promise<BoundClient>
Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:112
Convenience method — fetch a valid token and return a BoundClient for offline user impersonation. Caches the token internally.
Parameters
Section titled “Parameters”adapter
Section titled “adapter”accountId
Section titled “accountId”string
Returns
Section titled “Returns”Promise<BoundClient>
Example
Section titled “Example”const tokenManager = new ForgeRemoteTokenManager({ ... });const client = await tokenManager.boundClient(adapter, payload.context.accountId);const issue = await getIssue(client, { issueIdOrKey: 'PROJ-1' });getToken()
Section titled “getToken()”getToken(
accountId):Promise<ForgeRemoteUserToken>
Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:80
Get a valid offline user token for the given accountId. Returns the cached token if it is still valid, otherwise fetches a new one.
Parameters
Section titled “Parameters”accountId
Section titled “accountId”string
Returns
Section titled “Returns”Promise<ForgeRemoteUserToken>
invalidate()
Section titled “invalidate()”invalidate(
accountId):void
Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:94
Remove a cached token, forcing a fresh fetch on next getToken() call
Parameters
Section titled “Parameters”accountId
Section titled “accountId”string
Returns
Section titled “Returns”void
invalidateAll()
Section titled “invalidateAll()”invalidateAll():
void
Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:99
Remove all cached tokens
Returns
Section titled “Returns”void