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

Function resolveAuthHint

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

Source from the content-addressed store, hash-verified

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