MCPcopy Index your code
hub / github.com/massCodeIO/massCode / isIntegrationTokenAuthorized

Function isIntegrationTokenAuthorized

src/main/api/integrations/auth.ts:50–73  ·  view source on GitHub ↗
(
  authorizationHeader?: string,
)

Source from the content-addressed store, hash-verified

48}
49
50export function isIntegrationTokenAuthorized(
51 authorizationHeader?: string,
52): boolean {
53 const enabled = store.preferences.get('api.integrations.enabled') as boolean
54 const tokenHash = store.preferences.get('api.integrations.tokenHash') as
55 | string
56 | null
57
58 if (!enabled || !tokenHash || !authorizationHeader) {
59 return false
60 }
61
62 const bearerPrefix = 'bearer '
63 if (!authorizationHeader.toLowerCase().startsWith(bearerPrefix)) {
64 return false
65 }
66
67 const token = authorizationHeader.slice(bearerPrefix.length).trim()
68 if (!token) {
69 return false
70 }
71
72 return isSameHash(hashIntegrationToken(token), tokenHash)
73}

Callers 1

captures.tsFile · 0.90

Calls 3

isSameHashFunction · 0.85
hashIntegrationTokenFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected