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

Function normalizedTokenScope

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

Source from the content-addressed store, hash-verified

975};
976
977const normalizedTokenScope = (
978 as: oauth.AuthorizationServer,
979 scope: string | undefined,
980): string | undefined => {
981 if (scope === undefined || scope.trim().length === 0) return undefined;
982 const tokenEndpoint = typeof as.token_endpoint === "string" ? URL.parse(as.token_endpoint) : null;
983 const isSlackTokenEndpoint =
984 tokenEndpoint?.hostname.toLowerCase() === "slack.com" &&
985 (tokenEndpoint.pathname === "/api/oauth.v2.access" ||
986 tokenEndpoint.pathname === "/api/oauth.v2.user.access");
987 if (!isSlackTokenEndpoint) return scope;
988
989 const normalized = scope
990 .split(/[\s,]+/)
991 .filter(Boolean)
992 .join(" ");
993 return normalized.length > 0 ? normalized : undefined;
994};
995
996const tokenResponseFrom = (
997 as: oauth.AuthorizationServer,

Callers 1

tokenResponseFromFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected