/** * ArkType schemas for the auth-broker wire protocol. * * Shared between the server (validates inbound request bodies) and the client * (validates responses from the broker). Schemas mirror the TypeScript types * in `./types.ts` 1:1; the types remain the source of truth for static typing, * and `Type` is asserted-compatible with them where possible. * * Response schemas accept keys they do not declare, and usage enums read a * value they do not know as `"unknown"`, so a client keeps working against a * newer broker. Request bodies the broker acts on use `"+": "reject"`: a broker * must not apply a write whose fields it cannot read. The observed-usage report * is the exception, since its unknown fields cannot change what gets recorded. * The OAuth credential schema keeps extra keys on writes too: it preserves * provider-specific extension fields so they round-trip through the broker * instead of being dropped (see below). */ import { type FluentType, type Type } from "@oh-my-pi/omptype"; import { type ApiKeyCredential, type AuthCredential, type AuthCredentialSnapshotEntry, type DisabledCredentialSummary, type OAuthCredential, type RemoteOAuthCredential, type SnapshotCredential } from "../auth-storage.js"; import type { ClientUsageReportRequest, ClientUsageReportResponse, ClientUsageSummaryResponse, CredentialBlockDeleteRequest, CredentialBlockRequest, CredentialBlockResponse, CredentialBlockSnapshot, CredentialBlocksDeleteResponse, CredentialDisableResponse, CredentialRefreshResponse, CredentialUploadRequest, CredentialUploadResponse, DisabledCredentialsResponse, HealthzResponse, RefresherSchedule, SnapshotEntry, SnapshotResponse, SnapshotStreamEntryEvent, SnapshotStreamEvent, SnapshotStreamRemovedEvent, SnapshotStreamSnapshotEvent, UsageHistoryResponse, UsageResponse, UsageStaleResponse } from "./types.js"; /** Real OAuth credential (broker-side) — refresh token is the actual upstream value. */ export declare const oauthCredentialSchema: FluentType; /** OAuth credential as it appears in broker snapshots — refresh replaced with sentinel. */ export declare const remoteOauthCredentialSchema: FluentType; export declare const apiKeyCredentialSchema: FluentType; /** Discriminated union accepted on POST /v1/credential (writes). */ export declare const writableAuthCredentialSchema: FluentType; /** Discriminated union returned in snapshots (refresh is sentinel for OAuth). */ export declare const snapshotCredentialSchema: FluentType; export declare const credentialSnapshotEntrySchema: FluentType; export declare const credentialBlockSnapshotSchema: FluentType; export declare const snapshotEntrySchema: FluentType; export declare const refresherScheduleSchema: FluentType; export declare const snapshotResponseSchema: FluentType; /** First frame on connect — full snapshot embedded inline with a `kind` tag. */ export declare const snapshotStreamSnapshotEventSchema: FluentType; /** Per-credential upsert/refresh delta. */ export declare const snapshotStreamEntryEventSchema: FluentType; /** Per-credential delete delta. */ export declare const snapshotStreamRemovedEventSchema: FluentType; /** Discriminated union over every event frame the snapshot stream emits. */ export declare const snapshotStreamEventSchema: FluentType; export declare const healthzResponseSchema: FluentType; /** * Broker `/v1/usage` response. Reports are full {@link UsageReport}s minus the * heavy provider-specific `raw` field (the server strips it before send) — we * keep `raw` optional in the underlying schema so a misconfigured broker that * forgot to strip still validates. */ export declare const usageResponseSchema: Type; /** Broker `/v1/usage/history` response — recorded usage-limit snapshots, oldest first. */ export declare const usageHistoryResponseSchema: Type; /** Broker `POST /v1/usage/observed` request — one client's batched observed usage. */ export declare const clientUsageReportRequestSchema: FluentType; export declare const clientUsageReportResponseSchema: FluentType; /** Broker `GET /v1/usage/clients` response — per-client token burn aggregates. */ export declare const clientUsageSummaryResponseSchema: FluentType; export declare const credentialRefreshResponseSchema: FluentType; export declare const credentialDisableRequestSchema: FluentType<{ cause?: string; }>; export declare const credentialDisableResponseSchema: FluentType; /** One disabled-credential tombstone — identity + cause, never token material. */ export declare const disabledCredentialSummarySchema: FluentType; /** Broker `GET /v1/credentials/disabled` response. */ export declare const disabledCredentialsResponseSchema: FluentType; export declare const credentialBlockRequestSchema: FluentType; export declare const credentialBlockDeleteRequestSchema: FluentType; export declare const credentialBlockResponseSchema: FluentType; export declare const credentialBlocksDeleteResponseSchema: FluentType; export declare const usageStaleResponseSchema: FluentType; export declare const credentialUploadRequestSchema: FluentType; export declare const credentialUploadResponseSchema: FluentType;