(request: HttpServerRequest.HttpServerRequest)
| 27 | } |
| 28 | |
| 29 | function credentialFromRequest(request: HttpServerRequest.HttpServerRequest) { |
| 30 | const url = new URL(request.url, "http://localhost") |
| 31 | const token = url.searchParams.get(AUTH_TOKEN_QUERY) |
| 32 | if (token) return decodeCredential(token) |
| 33 | const match = /^Basic\s+(.+)$/i.exec(request.headers.authorization ?? "") |
| 34 | if (match) return decodeCredential(match[1]) |
| 35 | return Effect.succeed(emptyCredential()) |
| 36 | } |
| 37 | |
| 38 | export const authorizationLayer = Layer.effect( |
| 39 | Authorization, |
no test coverage detected