proto: land F2 — download.provideAuth (1.2.0)

The last contract gap blocking an M1 definition-of-done item: CORE's "401
handled" has no return path without it, and B2a's sibling F2 was accepted in
proto-answers-m1.md but never actually landed.

download.provideAuth {taskId, username, password, save?} -> {ok}, exactly as
proposed there. Privileged and Unix-socket-only: a credential-bearing method
must never be reachable from the browser, which is the other half of the
promise event.auth.required's own description already makes ("never back
through this event, never into a log"). It answers the challenge; it does not
itself resume the task -- the daemon retries with the credential attached and
the ordinary event.task.state reports the task leaving retry_wait, the same
as any other state change.

save only tells the daemon whether to persist the credential in the Secret
Service for next time, or use it for this attempt alone -- it never touches
SQLite or a log either way, in keeping with CLAUDE.md's secrets rule.

Three fixtures: the success path, -32010 for a task that no longer exists
(credentials submitted for it are simply discarded), and -32003 confirming
the extension has no path to this method under any transport.

mockd gets a real handler rather than falling through to the generic fixture
responder: it validates the taskId exists (so the -32010 fixture is
replayable) and actually transitions the task out of retry_wait.

Minor bump, 1.1.0 -> 1.2.0: additive method, no existing type touched.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012fgjnqFCS5h5L7gZTZo3rV
This commit is contained in:
2026-09-10 00:01:58 +04:00
co-authored by Claude Sonnet 5
parent f60070c420
commit 2d36e9fef0
17 changed files with 409 additions and 24 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
//
// Source: contracts/schema/**
// Generator: contracts/codegen/gen_ts.py
// Contract: v1.1.0
// Contract: v1.2.0
//
// Hand-editing this file is a merge blocker. Fix the schema and regenerate:
// python3 contracts/codegen/gen_ts.py
+1 -1
View File
@@ -3,7 +3,7 @@
//
// Source: contracts/schema/**
// Generator: contracts/codegen/gen_ts.py
// Contract: v1.1.0
// Contract: v1.2.0
//
// Hand-editing this file is a merge blocker. Fix the schema and regenerate:
// python3 contracts/codegen/gen_ts.py
+15 -1
View File
@@ -3,7 +3,7 @@
//
// Source: contracts/schema/**
// Generator: contracts/codegen/gen_ts.py
// Contract: v1.1.0
// Contract: v1.2.0
//
// Hand-editing this file is a merge blocker. Fix the schema and regenerate:
// python3 contracts/codegen/gen_ts.py
@@ -33,6 +33,8 @@ import type {
DownloadPauseParams,
DownloadProbeParams,
DownloadProbeResult,
DownloadProvideAuthParams,
DownloadProvideAuthResult,
DownloadRefreshUrlParams,
DownloadRefreshUrlResult,
DownloadRemoveParams,
@@ -159,6 +161,17 @@ export interface MethodMap {
* when this lands.
*/
"download.probe": { params: DownloadProbeParams; result: DownloadProbeResult };
/**
* Answer an event.auth.required challenge. The task sits in retry_wait until this arrives;
* on success the daemon retries with the credentials attached and the task resumes on its
* own — this method does not itself start the transfer. Privileged and Unix-socket-only: a
* credential-bearing method must never be reachable from the browser, which is exactly the
* boundary event.auth.required's own description draws ('never back through this event,
* never into a log') — this is the other half of that promise. Credentials are handed to
* the Secret Service, never to SQLite and never logged; save only tells the daemon whether
* to persist them there for next time, or use them for this attempt alone.
*/
"download.provideAuth": { params: DownloadProvideAuthParams; result: DownloadProvideAuthResult };
/**
* IDM's 'Refresh Download Address'. Point an existing task at a freshly-issued URL when a
* signed link has expired, keeping every byte already on disk. The daemon re-probes and
@@ -346,6 +359,7 @@ export const METHODS: { readonly [M in MethodName]: MethodMeta } = {
"download.list": { privileged: false, transports: ['uds', 'ws'], deadlineMs: 5000, errors: [] },
"download.pause": { privileged: false, transports: ['uds', 'ws'], deadlineMs: 5000, errors: [-32010] },
"download.probe": { privileged: false, transports: ['uds', 'ws'], deadlineMs: 30000, errors: [-32013] },
"download.provideAuth": { privileged: true, transports: ['uds'], deadlineMs: 5000, errors: [-32003, -32010] },
"download.refreshUrl": { privileged: false, transports: ['uds', 'ws'], deadlineMs: 30000, errors: [-32010, -32013] },
"download.remove": { privileged: true, transports: ['uds'], deadlineMs: 10000, errors: [-32003, -32010] },
"download.resume": { privileged: false, transports: ['uds', 'ws'], deadlineMs: 5000, errors: [-32010] },
+18 -2
View File
@@ -3,7 +3,7 @@
//
// Source: contracts/schema/**
// Generator: contracts/codegen/gen_ts.py
// Contract: v1.1.0
// Contract: v1.2.0
//
// Hand-editing this file is a merge blocker. Fix the schema and regenerate:
// python3 contracts/codegen/gen_ts.py
@@ -11,7 +11,7 @@
// ---------------------------------------------------------------------------
export const PROTOCOL_VERSION = "1.1.0";
export const PROTOCOL_VERSION = "1.2.0";
/**
* Every error code the daemon may return. Adding one is a minor bump; changing the meaning
@@ -978,6 +978,22 @@ export interface DownloadProbeResult {
requiresAuth?: boolean;
}
export interface DownloadProvideAuthParams {
taskId: string;
username: string;
password: string;
/**
* true persists the credential in the Secret Service, keyed by host and realm, for future
* downloads from the same site. false or null uses it for this task's retry only. Never
* affects SQLite or the daemon's logs either way.
*/
save?: boolean | null;
}
export interface DownloadProvideAuthResult {
ok: boolean;
}
export interface DownloadRefreshUrlParams {
taskId: string;
url: string;
+31 -1
View File
@@ -3,7 +3,7 @@
//
// Source: contracts/schema/**
// Generator: contracts/codegen/gen_ts.py
// Contract: v1.1.0
// Contract: v1.2.0
//
// Hand-editing this file is a merge blocker. Fix the schema and regenerate:
// python3 contracts/codegen/gen_ts.py
@@ -46,6 +46,8 @@ import type {
DownloadPauseParams,
DownloadProbeParams,
DownloadProbeResult,
DownloadProvideAuthParams,
DownloadProvideAuthResult,
DownloadRefreshUrlParams,
DownloadRefreshUrlResult,
DownloadRemoveParams,
@@ -1233,6 +1235,32 @@ export function validateDownloadProbeResult(v: unknown, path = ''): Validated<Do
return { ok: true, value: out as unknown as DownloadProbeResult };
}
/** Validate an untrusted value as DownloadProvideAuthParams. */
export function validateDownloadProvideAuthParams(v: unknown, path = ''): Validated<DownloadProvideAuthParams> {
if (!isPlainObject(v)) return fail(path, 'expected an object');
const out: Record<string, unknown> = {};
let r: Validated<null>;
r = req(v, "taskId", path, vString, out);
if (!r.ok) return r;
r = req(v, "username", path, vLimited(vString, { maxLength: 256 }), out);
if (!r.ok) return r;
r = req(v, "password", path, vLimited(vString, { maxLength: 1024 }), out);
if (!r.ok) return r;
r = opt(v, "save", path, vBoolean, out);
if (!r.ok) return r;
return { ok: true, value: out as unknown as DownloadProvideAuthParams };
}
/** Validate an untrusted value as DownloadProvideAuthResult. */
export function validateDownloadProvideAuthResult(v: unknown, path = ''): Validated<DownloadProvideAuthResult> {
if (!isPlainObject(v)) return fail(path, 'expected an object');
const out: Record<string, unknown> = {};
let r: Validated<null>;
r = req(v, "ok", path, vBoolean, out);
if (!r.ok) return r;
return { ok: true, value: out as unknown as DownloadProvideAuthResult };
}
/** Validate an untrusted value as DownloadRefreshUrlParams. */
export function validateDownloadRefreshUrlParams(v: unknown, path = ''): Validated<DownloadRefreshUrlParams> {
if (!isPlainObject(v)) return fail(path, 'expected an object');
@@ -2058,6 +2086,7 @@ const PARAMS_VALIDATORS: { [M in MethodName]: Validator<MethodMap[M]['params']>
"download.list": validateDownloadListParams,
"download.pause": validateDownloadPauseParams,
"download.probe": validateDownloadProbeParams,
"download.provideAuth": validateDownloadProvideAuthParams,
"download.refreshUrl": validateDownloadRefreshUrlParams,
"download.remove": validateDownloadRemoveParams,
"download.resume": validateDownloadResumeParams,
@@ -2099,6 +2128,7 @@ const RESULT_VALIDATORS: { [M in MethodName]: Validator<MethodMap[M]['result']>
"download.list": validateDownloadListResult,
"download.pause": validateBulkTaskResult,
"download.probe": validateDownloadProbeResult,
"download.provideAuth": validateDownloadProvideAuthResult,
"download.refreshUrl": validateDownloadRefreshUrlResult,
"download.remove": validateDownloadRemoveResult,
"download.resume": validateBulkTaskResult,