From c7184f80e46ed1c6ba802801e3ecc5a644109a8d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 27 Oct 2026 17:10:42 -0700 Subject: [PATCH 1/2] chore(quest): claim quest/m1/api-audit/dial-credential.md Quest-Claim: 415e5418900f987b From 5cb156fbc425f40bf5e490aa1ef8da77327361e7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 27 Oct 2026 17:15:47 -0700 Subject: [PATCH 2/2] refactor(net): name the dial credential presentation Co-Authored-By: GPT-6 --- js/net/src/connection/connect.ts | 6 +++--- js/net/src/connection/tokens.ts | 20 ++++++++++---------- quest/m1/api-audit/README.md | 1 - quest/m1/api-audit/dial-credential.md | 17 ----------------- 4 files changed, 13 insertions(+), 31 deletions(-) delete mode 100644 quest/m1/api-audit/dial-credential.md diff --git a/js/net/src/connection/connect.ts b/js/net/src/connection/connect.ts index a050c82709c..77bb6a1ea4a 100644 --- a/js/net/src/connection/connect.ts +++ b/js/net/src/connection/connect.ts @@ -17,7 +17,7 @@ import type { Established } from "./established.ts"; import * as Extensions from "./extensions.ts"; import { DISCOVERY_REMOVED, forwardAnnounced } from "./forward.ts"; import { DEFAULT_TIMEOUT, exchangeSetup, handsOff } from "./handshake.ts"; -import { type Credential, credential, fallback, hold } from "./tokens.ts"; +import { credential, fallback, hold, type Presentation } from "./tokens.ts"; // Default head start for WebTransport before attempting the WebSocket fallback. const DEFAULT_WEBSOCKET_DELAY_MS = Milli(500); @@ -359,12 +359,12 @@ async function connectInner( tokens: readonly string[], props: Omit, abort: Promise, -): Promise<[Established, Credential]> { +): Promise<[Established, Presentation]> { const offered = offer(props.versions); const dial = credential(raw, tokens, offered.setupToken); const url = dialable(dial.url); const fallbackDial = props.websocket?.url && fallback(raw, props.websocket.url, tokens, offered.setupToken); - const wiring = (presented: Credential): SessionProps => ({ + const wiring = (presented: Presentation): SessionProps => ({ publish: props.publish, handle: props.auth, client: true, diff --git a/js/net/src/connection/tokens.ts b/js/net/src/connection/tokens.ts index 66106369e52..83f59bcd9aa 100644 --- a/js/net/src/connection/tokens.ts +++ b/js/net/src/connection/tokens.ts @@ -1,8 +1,8 @@ -import { type Handle, type Credential as Presented, Unsupported } from "../auth.ts"; +import { type Credential, type Handle, Unsupported } from "../auth.ts"; import type { Established } from "./established.ts"; /** What one dial presents, decided from its URL, the offered versions, and the tokens. @internal */ -export interface Credential { +export interface Presentation { /** The URL to dial, carrying the connection credential when an offered version has no SETUP token. */ url: URL; /** The token SETUP carries, unless the URL brought its own credential. */ @@ -20,7 +20,7 @@ export interface Credential { * * @internal */ -export function credential(url: URL, tokens: readonly string[], setupToken: boolean): Credential { +export function credential(url: URL, tokens: readonly string[], setupToken: boolean): Presentation { const jwt = url.searchParams.get("jwt"); if (jwt) return { url, connection: jwt }; const first = tokens[0]; @@ -37,7 +37,7 @@ export function credential(url: URL, tokens: readonly string[], setupToken: bool * * @internal */ -export function fallback(primary: URL, url: URL, tokens: readonly string[], setupToken: boolean): Credential { +export function fallback(primary: URL, url: URL, tokens: readonly string[], setupToken: boolean): Presentation { const inherited = primary.searchParams.get("jwt"); if (inherited && !url.searchParams.get("jwt")) return credential(withJwt(url, inherited), tokens, setupToken); return credential(url, tokens, setupToken); @@ -51,12 +51,12 @@ export function withJwt(url: URL, jwt: string): URL { } /** The tokens to hold on their own AUTH streams, each once. @internal */ -export function extra(credential: Credential, tokens: readonly string[]): string[] { +export function extra(credential: Presentation, tokens: readonly string[]): string[] { return [...new Set(tokens)].filter((token) => token !== credential.connection); } interface Entry { - auth?: Presented; + auth?: Credential; pending: boolean; retired: boolean; } @@ -73,17 +73,17 @@ interface Entry { */ export class Held { #handle: Handle; - #credential: Credential; + #credential: Presentation; #entries = new Map(); #retiring: Entry[] = []; - constructor(handle: Handle, credential: Credential) { + constructor(handle: Handle, credential: Presentation) { this.#handle = handle; this.#credential = credential; } /** A new dial on the handle, whose credential decides which tokens ride AUTH. */ - dialed(credential: Credential, tokens: readonly string[]) { + dialed(credential: Presentation, tokens: readonly string[]) { this.#credential = credential; this.update(tokens); } @@ -139,7 +139,7 @@ export class Held { const held = new WeakMap(); /** Present `tokens` on `connection`, beside the credential its dial carried. @internal */ -export function hold(connection: Established, credential: Credential, tokens: readonly string[]): Held { +export function hold(connection: Established, credential: Presentation, tokens: readonly string[]): Held { const existing = held.get(connection.auth); if (existing) { existing.dialed(credential, tokens); diff --git a/quest/m1/api-audit/README.md b/quest/m1/api-audit/README.md index 5d3565b75ce..b3ca9d54028 100644 --- a/quest/m1/api-audit/README.md +++ b/quest/m1/api-audit/README.md @@ -76,7 +76,6 @@ Rejected in planning: - [Two broadcast resolutions](/quest/m1/api-audit/resolve.md) - Rust, JS, and the bindings resolve a broadcast with `request(path, epoch)` or `follow(path, epoch)`, and every racy two-step caller is gone - [Binding publications](/quest/m1/api-audit/binding-publication.md) - moq-ffi, the C ABI, and every wrapper hand out a publication handle that announces, replacing the private adapters - [Demand is wanted, everywhere](/quest/m1/api-audit/wanted.md) - every `used`/`unused` pair becomes `wanted()` and `wanted_changed()`, and unused ones go -- [One meaning for Credential](/quest/m1/api-audit/dial-credential.md) - the internal dial type gets its own name in JS and moq-tokio, and the `Presented` alias goes - [One strict path rule](/quest/m1/api-audit/strict-paths.md) - `Relative` refuses empty segments, `Path` refuses non-canonical escapes, the error is `path::Error`, and auth mints only strict paths - [Unix sockets accept through the allowlist](/quest/m1/api-audit/unix-accept.md) - the public pre-allowlist `unix::Listener::accept` becomes crate-private diff --git a/quest/m1/api-audit/dial-credential.md b/quest/m1/api-audit/dial-credential.md deleted file mode 100644 index 13bb972b7fc..00000000000 --- a/quest/m1/api-audit/dial-credential.md +++ /dev/null @@ -1,17 +0,0 @@ -# [XS] One meaning for Credential - -## Goal - -`Credential` means only the public `auth::Credential`. The internal type -for what one dial presents, in `js/net/src/connection/tokens.ts` and moq-tokio's -`connect/token.rs`, gets its own name, and the `Presented` import alias in -`tokens.ts` goes away. - -## Plan - -[moq-dev/moq#6751](https://github.com/moq-dev/moq/pull/6751) renamed the -public `Auth` to `Credential`, which collides with these internal types. -Pick a name by role (such as `Presentation`) and use it in both languages. -Both types are internal, so nothing public changes. - -Public API: none. Wire: none.