Skip to content

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.

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' } });
}

new ForgeRemoteTokenManager(opts): ForgeRemoteTokenManager

Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:72

Create a new ForgeRemoteTokenManager.

ForgeRemoteTokenManagerOptions

Configuration including the proxy URL, installation ID, and app system token

ForgeRemoteTokenManager

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.

ForgeAdapter

string

Promise<BoundClient>

const tokenManager = new ForgeRemoteTokenManager({ ... });
const client = await tokenManager.boundClient(adapter, payload.context.accountId);
const issue = await getIssue(client, { issueIdOrKey: 'PROJ-1' });

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.

string

Promise<ForgeRemoteUserToken>


invalidate(accountId): void

Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:94

Remove a cached token, forcing a fresh fetch on next getToken() call

string

void


invalidateAll(): void

Defined in: packages/core/src/auth/ForgeRemoteTokenManager.ts:99

Remove all cached tokens

void