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

Function nestedAuthedUserGrant

packages/core/sdk/src/oauth-helpers.ts:1095–1116  ·  view source on GitHub ↗
(
  response: Response,
)

Source from the content-addressed store, hash-verified

1093 * absent or empty, and normalize Slack's comma separator back to RFC space-delimited
1094 * scope syntax at this boundary. */
1095const nestedAuthedUserGrant = async (
1096 response: Response,
1097): Promise<NestedAuthedUserGrant | undefined> => {
1098 const decoded = decodeNestedAuthedUserScope(await safeJsonFromResponse(response));
1099 if (Option.isNone(decoded)) return undefined;
1100 const normalized = decoded.value.authed_user.scope
1101 .split(/[\s,]+/)
1102 .filter(Boolean)
1103 .join(" ");
1104 if (normalized.length === 0) return undefined;
1105 const nestedAccessToken = decoded.value.authed_user.access_token;
1106 const nestedTokenType = decoded.value.authed_user.token_type;
1107 const nestedRefreshToken = decoded.value.authed_user.refresh_token;
1108 const nestedExpiresIn = decoded.value.authed_user.expires_in;
1109 return {
1110 scope: normalized,
1111 ...(nestedAccessToken === undefined ? {} : { accessToken: nestedAccessToken }),
1112 ...(nestedTokenType === undefined ? {} : { tokenType: nestedTokenType }),
1113 ...(nestedRefreshToken === undefined ? {} : { refreshToken: nestedRefreshToken }),
1114 ...(nestedExpiresIn === undefined ? {} : { expiresIn: nestedExpiresIn }),
1115 };
1116};
1117
1118// MCP source connections are pure OAuth 2.0. Some providers (PostHog, etc.)
1119// front an OIDC backend and emit an `id_token` anyway; oauth4webapi then

Callers 1

Calls 1

safeJsonFromResponseFunction · 0.85

Tested by

no test coverage detected