MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / signAccessToken

Function signAccessToken

apps/cloud/src/auth/workos.node.test.ts:54–76  ·  view source on GitHub ↗
(
  keypair: Keypair,
  claims: {
    readonly subject?: string;
    readonly organizationId?: string;
    readonly sessionId?: string;
    readonly expiresIn?: string | number;
  } = {},
)

Source from the content-addressed store, hash-verified

52};
53
54const signAccessToken = (
55 keypair: Keypair,
56 claims: {
57 readonly subject?: string;
58 readonly organizationId?: string;
59 readonly sessionId?: string;
60 readonly expiresIn?: string | number;
61 } = {},
62) => {
63 const jwt = new SignJWT({
64 org_id: claims.organizationId ?? "org_test",
65 sid: claims.sessionId ?? "session_test",
66 })
67 .setProtectedHeader({ alg: "RS256", kid: keypair.kid })
68 .setSubject(claims.subject ?? USER.id)
69 .setIssuedAt();
70
71 return (
72 typeof claims.expiresIn === "number"
73 ? jwt.setExpirationTime(claims.expiresIn)
74 : jwt.setExpirationTime(claims.expiresIn ?? "5m")
75 ).sign(keypair.privateKey);
76};
77
78const sealSession = async (accessToken: string, refreshToken = "refresh_test"): Promise<string> =>
79 `${await sealIron(

Callers 2

withWorkOSStubFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected