MCPcopy Create free account
hub / github.com/effect-app/libs / getAuthorizationToken

Function getAuthorizationToken

packages/infra/src/internal/auth.ts:131–143  ·  view source on GitHub ↗
(headers: HttpHeaders.Headers, authRequired: boolean)

Source from the content-addressed store, hash-verified

129}
130
131const getAuthorizationToken = (headers: HttpHeaders.Headers, authRequired: boolean) => {
132 const authorization = HttpHeaders.get(headers, "authorization")
133 if (Option.isNone(authorization)) {
134 return authRequired ? Effect.fail(new UnauthorizedError()) : Effect.succeed(Option.none<string>())
135 }
136
137 const [scheme, token] = authorization.value.split(" ")
138 if (!scheme || !token || scheme.toLowerCase() !== "bearer") {
139 return Effect.fail(new InvalidRequestError("", false))
140 }
141
142 return Effect.succeed(Option.some(token))
143}
144
145const makeResolveConfig = (config: Config) => {
146 let cached: Promise<ResolvedConfig> | undefined

Callers 1

checkJWTIFunction · 0.85

Calls 5

someMethod · 0.80
getMethod · 0.65
splitMethod · 0.65
failMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…