UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

42 lines (41 loc) 1.51 kB
/** * SessionIdentity — generates unique user_id / session_id values per account * so that Anthropic sees consistent "user" fingerprints even when requests are * spread across multiple accounts. * * The generated metadata matches Claude Code's shape: * {"device_id":"<64 hex>","account_uuid":"<uuid>","session_id":"<uuid>"} */ import { getOrCreateClaudeCodeIdentity, purgeExpiredClaudeCodeIdentities, } from "../../../auth/anthropicOAuth.js"; export function purgeExpiredSessions() { purgeExpiredClaudeCodeIdentities(); } export function createSessionIdentity() { return { name: "session-identity", order: 20, enabled: true, async transformRequest(ctx) { const accountId = ctx.account.id; const identity = getOrCreateClaudeCodeIdentity(accountId, { existingUserId: ctx.request.body.metadata?.user_id, }); const body = { ...ctx.request.body }; // Only set user_id if not already present — in passthrough mode, // oauthFetch.ts owns this field and sets it from the shared helper. if (!body.metadata?.user_id) { body.metadata = { ...body.metadata, user_id: identity.metadataUserId, }; } return { ...ctx, request: { ...ctx.request, body, }, }; }, }; }