MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / refreshTokenAction

Function refreshTokenAction

packages/auth-server/src/server/tokens.ts:70–94  ·  view source on GitHub ↗
(req: any, res: any)

Source from the content-addressed store, hash-verified

68// let usedTokens: Record<string, boolean> = {};
69
70export async function refreshTokenAction(req: any, res: any) {
71 const token = getToken(req);
72 if (!token) {
73 throw new Error('Token not found');
74 }
75
76 // if (usedTokens[token]) {
77 // throw new Error('Token already used');
78 // }
79
80 const isValid = (await verifyToken(token)) as JwtPayload;
81 const newToken = await signToken(isValid.data);
82
83 // TODO: add refreshToken used on some external black-list
84 // usedTokens[token] = true;
85
86 // persist cookies for SSR
87 setSessionCookies({
88 token: newToken,
89 req,
90 res,
91 });
92
93 return { newToken };
94}

Callers 1

CreateRouterFunction · 0.90

Calls 4

setSessionCookiesFunction · 0.90
verifyTokenFunction · 0.85
signTokenFunction · 0.85
getTokenFunction · 0.70

Tested by

no test coverage detected