Skip to content

Commit 28bf6fa

Browse files
committed
refactor(sdk): say what the bearer header checks refuse, and keep TIMED_OUT internal
1 parent a42b363 commit 28bf6fa

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎packages/auth/src/http.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { AuthError } from './error.ts';
77
import { DecodeError, parse } from './json.ts';
88
import { MAX_RESPONSE_BYTES, REQUEST_DEADLINE } from './protocol.ts';
99

10-
/** What {@link Http.within} resolves to when its deadline passes first. */
10+
/**
11+
* What {@link Http.within} resolves to when its deadline passes first.
12+
* @internal
13+
*/
1114
export const TIMED_OUT: unique symbol = Symbol('timed out');
1215

1316
/** The `fetch` the SDK sends requests with; inject one to proxy or mock them. */

‎packages/auth/src/resource.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ export class Resource<S extends string = never, X = undefined> {
9191
const joined = values.length > 1 && values.some((value) => /^bearer(?: |$)/i.test(value));
9292
const space = header.indexOf(' ');
9393
const scheme = space === -1 ? header : header.slice(0, space);
94+
// Any other scheme is no token; a joined Bearer header, or Bearer without a
95+
// token, is malformed.
9496
if (!joined && asciiLowercase(scheme) !== 'bearer') {
9597
const scope = scopes.length === 0 ? undefined : Scopes.checked(scopes).toString();
9698
throw new AuthError(

0 commit comments

Comments
 (0)