Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions js/net/src/connection/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -359,12 +359,12 @@ async function connectInner(
tokens: readonly string[],
props: Omit<ConnectProps, "url">,
abort: Promise<void>,
): 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,
Expand Down
20 changes: 10 additions & 10 deletions js/net/src/connection/tokens.ts
Original file line number Diff line number Diff line change
@@ -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. */
Expand All @@ -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];
Expand All @@ -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);
Expand All @@ -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;
}
Expand All @@ -73,17 +73,17 @@ interface Entry {
*/
export class Held {
#handle: Handle;
#credential: Credential;
#credential: Presentation;
#entries = new Map<string, Entry>();
#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);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ export class Held {
const held = new WeakMap<Handle, Held>();

/** 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);
Expand Down
1 change: 0 additions & 1 deletion quest/m1/api-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 0 additions & 17 deletions quest/m1/api-audit/dial-credential.md

This file was deleted.

Loading