import type { ReclaimClient } from '@reclaimprotocol/client/api'; import type { CreateProviderVersionRequest, ProviderVersionRef } from '@reclaimprotocol/client/openapi'; import type { DraftResponseMatch, HttpMethod, OldUrlType, ReclaimProvider, ResponseRedaction, WebCredentials } from './schema.ts'; /** One entry of the version's `requests[]` (a `RequestSelection`), derived * from the openapi type so it can't drift from what the server accepts. */ type RequestSelection = CreateProviderVersionRequest['requests'][number]; /** The subset of a draft a request selection is built from — the only fields * `providerToRequestSelection` reads. A full `ReclaimProvider` satisfies it, * as does a lighter injected-request draft (no `name`/`paramValues`). */ export interface DraftRequest { url: string; method: HttpMethod; body?: string; writeRedactionMode?: ReclaimProvider['writeRedactionMode']; additionalClientOptions?: ReclaimProvider['additionalClientOptions']; responseMatches?: DraftResponseMatch[]; responseRedactions?: ResponseRedaction[]; /** How the verification client supplies cookies/auth on replay. Default * `include` (both backends). */ credentials?: WebCredentials; /** Old-devtools `urlType` override. Ignored by THIS translator (the * builder backend has no urlType) — read only by the old-devtools * translator (`old/to-register.ts`). */ urlType?: OldUrlType; } /** A request the page's injection script is allowed to fire, plus the * pagination/optionality flags of `RequestSelectionTemplate`. Reuses the * shared `DraftRequest` shape — no provider `name`/`paramValues` required. */ export interface AllowedJsRequest extends DraftRequest { /** Allow the template to match many requests (for example, pagination). * Default true. */ multiple?: boolean; /** Fail validation if no request matches this template. Default true. */ required?: boolean; /** Names of `${var}` placeholders in this template's `responseMatches`/ * `responseRedactions` that get substituted at verify time from the * submitted proof's own witness params (for example, an index list a * `Reclaim.requestClaim` call attached alongside its `{{var}}` * extractions). Omit (or leave empty) when the template has no such * placeholders — verification then matches it literally as-is. */ templateParams?: string[]; /** How multiple values for `templateParams` expand into request specs. * `'separate'` (default): one independent spec per value, each expected * to match its own proof. `'merge'`: all values folded into ONE spec * with one `responseMatches`/`responseRedactions` entry per value, * matching a single proof that bundles them all into one claim. */ templateParamsMode?: 'separate' | 'merge'; } /** Optional extras for a create-version body beyond the request list. */ export interface CreateVersionOptions { notes?: string; version?: ProviderVersionRef; /** Complete context schema for this new immutable version. When omitted, * it is derived from `{{context.}}` placeholders. */ requiredContext?: CreateProviderVersionRequest['requiredContext']; /** JS injected before every page load (`webSettings.jsUserScripts`). */ jsUserScripts?: string; /** Requests the injection script may fire, as `RequestSelectionTemplate`s. */ allowedJsRequests?: AllowedJsRequest[]; /** In-app interception options, mapped to * `webSettings.clientOptions.inapp.interceptorOptions` — ONLY when this * is explicitly passed (builder's schema has no `NONE` interceptorType; * omitting `inapp` entirely IS the "no interception" signal, so omitting * this must omit `inapp`, not default it to HAWKEYE). When it IS passed, * `isDocumentRequestReplayEnabled` defaults to `false` (disabled) unless * explicitly overridden here — see `providerToCreateVersionRequest`. Only * meaningful for `HAWKEYE`/`MSWJS`; inert for `CDP`. */ interceptorOptions?: { interceptorType: 'HAWKEYE' | 'MSWJS' | 'CDP'; interceptorSettings?: string; isDocumentRequestReplayEnabled?: boolean; }; } /** * Derive the version's `requiredContext` JSON Schema from the * `{{context.}}` placeholders across EVERY request's url/body (plus any * injected requests and the injection script) — mechanical, so a published * recipe can never reference a context value the Builder doesn't require. * Returns undefined when nothing references context (the field is optional). * Authors can pass a complete schema when creating the new version to refine * types or descriptions. Never edit a version in place after creation. * * A SECRET-named context param (see `classifyParamName`) is NOT rejected here * even when it's templated into the URL/geoLocation — write-redaction can * still hide it there, up to `secretUrlCharBudget` characters (summed across * every such value in that URL). Whether it actually fits is only knowable * once a real value exists, so that check runs at verification time * (`verify/run.ts`), against the consumer's actual supplied value — not here. */ export declare function deriveRequiredContext(providers: ReclaimProvider[], injection?: { allowedJsRequests?: AllowedJsRequest[]; jsUserScripts?: string; }): CreateProviderVersionRequest['requiredContext']; /** * Translate one drafted request into a `RequestSelection`. Shared by the * top-level `requests` and by `allowedJsRequests`. * * `responseMatches`/`responseRedactions` are INDEPENDENT parallel arrays, * isomorphic to the attestor's `ProviderParams<'http'>` (no nested fold). * `responseRedactions` decide which portions of the response are revealed; * `responseMatches` then run against the union of the revealed content. Neither * depends on the other's length or order, so both pass through untouched. * (The old-devtools translator has its own opt-in index-pairing concern; the * builder deliberately does not.) */ export declare function providerToRequestSelection(provider: DraftRequest): RequestSelection; export declare function providerToCreateVersionRequest(providers: ReclaimProvider[], initialUrl: string, opts?: CreateVersionOptions): CreateProviderVersionRequest; /** * Fetch every current version and resolve a strictly newer immutable version. * The default bump is patch. Callers can request major/minor/patch or provide * an exact version; an exact version must be higher than every existing one. * A failed lookup propagates — silently resetting to 1.0.0 could collide with * an existing version. */ export declare function nextVersion(client: ReclaimClient, providerId: string, bump?: VersionBump): Promise; export type VersionBump = 'major' | 'minor' | 'patch'; /** Resolve either an explicit version or a requested semantic bump. */ export declare function resolveNewVersion(client: ReclaimClient, providerId: string, input?: { version?: ProviderVersionRef; bump?: VersionBump; }): Promise; export declare function bumpVersion(versions: ProviderVersionRef[], bump?: VersionBump): ProviderVersionRef; export {};