MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / oauthApiHandler

Function oauthApiHandler

packages/web/src/ee/features/oauth/apiHandler.ts:18–32  ·  view source on GitHub ↗
(handler: H)

Source from the content-addressed store, hash-verified

16 * @see https://datatracker.ietf.org/doc/html/rfc9700#section-4.12
17 */
18export function oauthApiHandler<H extends AnyHandler>(handler: H): H {
19 const wrapped = apiHandler(async (...args: Parameters<H>) => {
20 const response = await handler(...args);
21 if (response.status === 307 || response.status === 308) {
22 throw new Error(
23 `OAuth authorization server emitted HTTP ${response.status} redirect; ` +
24 `per RFC 9700 §4.12 the authorization server MUST NOT use 307/308. ` +
25 `Use 303 (See Other) instead.`
26 );
27 }
28 return response;
29 });
30
31 return wrapped as H;
32}

Callers 4

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
apiHandler.test.tsFile · 0.90

Calls 2

apiHandlerFunction · 0.90
handlerFunction · 0.85

Tested by

no test coverage detected