MCPcopy Create free account
hub / github.com/vercel/examples / make_stream_token

Function make_stream_token

python/vibe-coding-ide/backend/src/auth.py:15–26  ·  view source on GitHub ↗

Create a signed JWT used by the SSE stream for resuming agent runs. The token embeds the provided payload and standard claims (iat/exp).

(payload: dict[str, Any])

Source from the content-addressed store, hash-verified

13
14
15def make_stream_token(payload: dict[str, Any]) -> str:
16 """Create a signed JWT used by the SSE stream for resuming agent runs.
17
18 The token embeds the provided payload and standard claims (iat/exp).
19 """
20 now = datetime.now(timezone.utc)
21 to_encode = {
22 **payload,
23 "iat": int(now.timestamp()),
24 "exp": int((now + timedelta(seconds=JWT_TTL_SECONDS)).timestamp()),
25 }
26 return jwt.encode(to_encode, JWT_SECRET, algorithm=JWT_ALG)
27
28
29def read_stream_token(token: str) -> dict[str, Any]:

Callers 2

tool_completed_sseFunction · 0.90
create_runFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected