MCPcopy
hub / github.com/simstudioai/sim / generateInternalToken

Function generateInternalToken

apps/sim/lib/auth/internal.ts:25–42  ·  view source on GitHub ↗
(userId?: string)

Source from the content-addressed store, hash-verified

23 * @param userId Optional user ID to embed in token payload
24 */
25export async function generateInternalToken(userId?: string): Promise<string> {
26 const secret = getJwtSecret()
27
28 const payload: { type: string; userId?: string } = { type: 'internal' }
29 if (userId) {
30 payload.userId = userId
31 }
32
33 const token = await new SignJWT(payload)
34 .setProtectedHeader({ alg: 'HS256' })
35 .setIssuedAt()
36 .setExpirationTime('5m')
37 .setIssuer('sim-internal')
38 .setAudience('sim-api')
39 .sign(secret)
40
41 return token
42}
43
44/**
45 * Verify an internal JWT token

Callers 9

executeToolFunction · 0.90
addInternalAuthIfNeededFunction · 0.90
executeMcpToolFunction · 0.90
connectorApiCallFunction · 0.90
postChunkFunction · 0.90
handleToolsCallFunction · 0.90
buildAuthHeadersFunction · 0.90
image.tsFile · 0.85
executeMistralOCRRequestFunction · 0.85

Calls 1

getJwtSecretFunction · 0.85

Tested by

no test coverage detected