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

Function resolveAuthHint

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

Source from the content-addressed store, hash-verified

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

Callers 1

doc-gate.tsFile · 0.85

Calls 3

decodeAuthHintFunction · 0.90
parseCookieFunction · 0.90
organizationDisplayFunction · 0.85

Tested by

no test coverage detected