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

Function resolveAuthHint

apps/cloud/src/auth/ssr-gate.ts:109–139  ·  view source on GitHub ↗
(
  session: VerifiedSession,
  cookieHeader: string | null,
)

Source from the content-addressed store, hash-verified

107 * fields (which would ping-pong with the client's authoritative write).
108 */
109const resolveAuthHint = async (
110 session: VerifiedSession,
111 cookieHeader: string | null,
112): Promise<{ hint: AuthHint; mint: boolean }> => {
113 const existing = decodeAuthHint(parseCookie(cookieHeader, AUTH_HINT_COOKIE));
114 if (
115 existing &&
116 existing.user.id === session.userId &&
117 (existing.organization?.id ?? null) === session.organizationId
118 ) {
119 return { hint: existing, mint: false };
120 }
121 return {
122 hint: {
123 v: 1,
124 user: {
125 id: session.userId,
126 email: session.email,
127 name: session.name,
128 avatarUrl: session.avatarUrl,
129 },
130 organization: session.organizationId
131 ? {
132 id: session.organizationId,
133 ...(await organizationDisplay(session.organizationId)),
134 }
135 : null,
136 },
137 mint: true,
138 };
139};
140
141// The sealed session carries the org ID but not its name/slug; the local
142// mirror has both (every org row is born with a slug — see

Callers 1

ssr-gate.tsFile · 0.85

Calls 3

decodeAuthHintFunction · 0.90
parseCookieFunction · 0.90
organizationDisplayFunction · 0.85

Tested by

no test coverage detected