the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 1241cd4e999bb3f48dca4cab7bcff14fe6f5d6ad 41 lines 1.2 kB view raw
1import { describe, expect, it, vi } from "vitest"; 2 3vi.mock("../../lib/env", () => ({ 4 env: { 5 JWT_SECRET: "test-jwt-secret", 6 }, 7})); 8 9const { default: generateJwt } = await import("../../lib/generateJwt"); 10 11describe("generateJwt", () => { 12 it("returns a non-empty JWT string", async () => { 13 const token = await generateJwt("did:plc:testuser"); 14 expect(typeof token).toBe("string"); 15 expect(token.length).toBeGreaterThan(0); 16 }); 17 18 it("returns a well-formed JWT (three dot-separated parts)", async () => { 19 const token = await generateJwt("did:plc:testuser"); 20 const parts = token.split("."); 21 expect(parts).toHaveLength(3); 22 }); 23 24 it("encodes the provided DID as the sub claim", async () => { 25 const did = "did:plc:abc123"; 26 const token = await generateJwt(did); 27 28 // Decode the payload (second segment) without verification 29 const payload = JSON.parse( 30 Buffer.from(token.split(".")[1]!, "base64url").toString("utf-8"), 31 ); 32 33 expect(payload.sub).toBe(did); 34 }); 35 36 it("produces different tokens for different DIDs", async () => { 37 const token1 = await generateJwt("did:plc:user1"); 38 const token2 = await generateJwt("did:plc:user2"); 39 expect(token1).not.toBe(token2); 40 }); 41});