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

Function normalizedTokenScope

packages/core/sdk/src/oauth-helpers.ts:928–945  ·  view source on GitHub ↗
(
  as: oauth.AuthorizationServer,
  scope: string | undefined,
)

Source from the content-addressed store, hash-verified

926};
927
928const normalizedTokenScope = (
929 as: oauth.AuthorizationServer,
930 scope: string | undefined,
931): string | undefined => {
932 if (scope === undefined || scope.trim().length === 0) return undefined;
933 const tokenEndpoint = typeof as.token_endpoint === "string" ? URL.parse(as.token_endpoint) : null;
934 const isSlackTokenEndpoint =
935 tokenEndpoint?.hostname.toLowerCase() === "slack.com" &&
936 (tokenEndpoint.pathname === "/api/oauth.v2.access" ||
937 tokenEndpoint.pathname === "/api/oauth.v2.user.access");
938 if (!isSlackTokenEndpoint) return scope;
939
940 const normalized = scope
941 .split(/[\s,]+/)
942 .filter(Boolean)
943 .join(" ");
944 return normalized.length > 0 ? normalized : undefined;
945};
946
947const tokenResponseFrom = (
948 as: oauth.AuthorizationServer,

Callers 1

tokenResponseFromFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected