Fix bug where streaming didnt work due to correct use of Bearer token (#84)

This commit is contained in:
Simon J
2021-12-03 13:51:51 +11:00
committed by GitHub
parent 075538f029
commit 7c0db619c9
4 changed files with 49 additions and 49 deletions

View File

@@ -36,7 +36,7 @@ import morgan from "morgan";
import { takeWithRepeats } from "./utils";
import { parse } from "./burn";
import { axiosImageFetcher, ImageFetcher } from "./subsonic";
import { JWTSmapiLoginTokens, SmapiAuthTokens, SmapiToken } from "./smapi_auth";
import { JWTSmapiLoginTokens, SmapiAuthTokens, smapiTokenFromString } from "./smapi_auth";
export const BONOB_ACCESS_TOKEN_HEADER = "bat";
@@ -371,7 +371,7 @@ function server(
logger.info(
`${trace} bnb<- ${req.method} ${req.path}?${JSON.stringify(
req.query
)}, headers=${JSON.stringify({ ...req.headers, "authorization": "***" })}`
)}, headers=${JSON.stringify({ ...req.headers, "authorization": "*****" })}`
);
const authHeader = E.fromNullable("Missing header");
@@ -384,7 +384,7 @@ function server(
E.map(match => match[1]!)
)),
E.chain(bearerToken => pipe(
smapiAuthTokens.verify(bearerToken as unknown as SmapiToken),
smapiAuthTokens.verify(smapiTokenFromString(bearerToken)),
E.mapLeft(_ => "Bearer token failed to verify")
)),
E.getOrElseW(() => undefined)