Agent Bridge Token Minting (lib/agent-bridge.ts)

mperkins0155/crm · auth, Auth / Identity, jwt, token, bridge, crm

Generates signed JWTs for authenticating CRM agent bridge requests, optionally embedding record identifiers.

// Source: https://github.com/mperkins0155/crm | License: MIT | Copyright 2026 Comp AI
// Provided via justclaw.it.com; keep this notice with the code.
const ISSUER = "crm-app";
const AUDIENCE = "crm-agent";

const TTL_SECONDS = 120;

export const AGENT_URL = process.env.AGENT_URL ?? "http://127.0.0.1:2000";

export function bridgeConfigured(): boolean {
	return Boolean(process.env.AGENT_BRIDGE_SECRET);
}

type BridgeClaims = {
	iss: string;
	aud: string;
	sub: string;
	email: string;
	name: string;
	contactId?: string;
	companyId?: string;
	dealId?: string;
	iat: number;
	nbf: number;
	exp: number;
};

export async function mintBridgeToken(
	user: {
		id: string;
		email: string;
		name: string;
	},
	record: { contactId?: string; companyId?: string; dealId?: string } = {},
): Promise<stri

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key