MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / buildJWTPayload

Function buildJWTPayload

apps/api/src/lib/jwt/jwt-utils.ts:31–48  ·  view source on GitHub ↗
(
  id: string,
  email: string,
  accountId: string
)

Source from the content-addressed store, hash-verified

29 * inside the JWT clock-skew tolerance every verifier accepts.
30 */
31export const buildJWTPayload = async (
32 id: string,
33 email: string,
34 accountId: string
35): Promise<Record<string, string | number>> => {
36 const nowSeconds = Math.floor(nowMs() / 1000);
37 const cutoffSeconds = await jwtRevocationService.getUserRevokeCutoff(id);
38 const iat = Math.max(nowSeconds, cutoffSeconds);
39
40 return {
41 id,
42 email,
43 aid: accountId,
44 jti: crypto.randomUUID(),
45 iat,
46 exp: iat + JWT_TTL_SECONDS,
47 };
48};

Callers 5

mfa.routes.tsFile · 0.90
auth.routes.tsFile · 0.90
accounts.routes.tsFile · 0.90
signCookieFunction · 0.90
jwt-utils.test.tsFile · 0.90

Calls 1

nowMsFunction · 0.90

Tested by 1

signCookieFunction · 0.72