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

Function normalizedTokenScope

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

Source from the content-addressed store, hash-verified

942};
943
944const normalizedTokenScope = (
945 as: oauth.AuthorizationServer,
946 scope: string | undefined,
947): string | undefined => {
948 if (scope === undefined || scope.trim().length === 0) return undefined;
949 const tokenEndpoint = typeof as.token_endpoint === "string" ? URL.parse(as.token_endpoint) : null;
950 const isSlackTokenEndpoint =
951 tokenEndpoint?.hostname.toLowerCase() === "slack.com" &&
952 (tokenEndpoint.pathname === "/api/oauth.v2.access" ||
953 tokenEndpoint.pathname === "/api/oauth.v2.user.access");
954 if (!isSlackTokenEndpoint) return scope;
955
956 const normalized = scope
957 .split(/[\s,]+/)
958 .filter(Boolean)
959 .join(" ");
960 return normalized.length > 0 ? normalized : undefined;
961};
962
963const tokenResponseFrom = (
964 as: oauth.AuthorizationServer,

Callers 1

tokenResponseFromFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected