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

Function normalizedTokenScope

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

Source from the content-addressed store, hash-verified

749};
750
751const normalizedTokenScope = (
752 as: oauth.AuthorizationServer,
753 scope: string | undefined,
754): string | undefined => {
755 if (scope === undefined || scope.trim().length === 0) return undefined;
756 const tokenEndpoint = typeof as.token_endpoint === "string" ? URL.parse(as.token_endpoint) : null;
757 const isSlackTokenEndpoint =
758 tokenEndpoint?.hostname.toLowerCase() === "slack.com" &&
759 (tokenEndpoint.pathname === "/api/oauth.v2.access" ||
760 tokenEndpoint.pathname === "/api/oauth.v2.user.access");
761 if (!isSlackTokenEndpoint) return scope;
762
763 const normalized = scope
764 .split(/[\s,]+/)
765 .filter(Boolean)
766 .join(" ");
767 return normalized.length > 0 ? normalized : undefined;
768};
769
770const tokenResponseFrom = (
771 as: oauth.AuthorizationServer,

Callers 1

tokenResponseFromFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected