@openagentid/http API
Exported TypeScript types, signatures and source documentation.
Package manifest, subpaths, and integration guide.
This reference resolves exported symbols from the package entry point with the TypeScript parser/type checker. It includes declarations and inferred types, not implementation bodies. External dependencies unavailable to the extraction environment can remain unresolved; this is source documentation, not proof that all packages typecheck or are published.
OPENAGENT_AUTH_SCHEME
The canonical authorization scheme for OpenAgent-authenticated requests.
export declare const OPENAGENT_AUTH_SCHEME: "OpenAgent";Source: openagent-sdk/adapters/http/typescript/src/headers.ts:6.
HEADER_OPENAGENT_DID
Header carrying the authenticated agent's DID.
export declare const HEADER_OPENAGENT_DID: "x-openagent-did";Source: openagent-sdk/adapters/http/typescript/src/headers.ts:9.
HEADER_OPENAGENT_SESSION
Header carrying the session token (alternative to Authorization).
export declare const HEADER_OPENAGENT_SESSION: "x-openagent-session";Source: openagent-sdk/adapters/http/typescript/src/headers.ts:12.
CONTENT_TYPE_JSON
Content-Type for all Core Protocol JSON payloads.
export declare const CONTENT_TYPE_JSON: "application/json";Source: openagent-sdk/adapters/http/typescript/src/headers.ts:15.
extractOpenAgentToken
Extract the session token from an Authorization: OpenAgent <token>
header. Returns undefined if the header is missing, malformed, or uses a
different scheme.
export declare const extractOpenAgentToken: (authorization: string) => string | undefined;Source: openagent-sdk/adapters/http/typescript/src/headers.ts:22.
buildOpenAgentHeader
Build an Authorization: OpenAgent <token> header value.
export declare const buildOpenAgentHeader: (token: string) => string;Source: openagent-sdk/adapters/http/typescript/src/headers.ts:31.
HttpTransport
HTTP transport carrying the identity flow over REST.
export declare class HttpTransport {
constructor(config?: HttpTransportConfig): HttpTransport;
fetchChallenge(endpoint: string): Promise<IdentityChallenge>;
prove(endpoint: string, proof: IdentityProof): Promise<IdentityVerified>;
}Source: openagent-sdk/adapters/http/typescript/src/transport.ts:129.
TransportError
Transport error with HTTP context.
export declare class TransportError {
statusCode: number | undefined;
responseBody: string | undefined;
constructor(message: string, statusCode?: number, responseBody?: string): TransportError;
}Source: openagent-sdk/adapters/http/typescript/src/transport.ts:107.
CHALLENGE_TYPE
The literal type value of an identity challenge (Section 15.2).
export declare const CHALLENGE_TYPE: "openagent-challenge-v1";Source: openagent-sdk/adapters/http/typescript/src/transport.ts:13.
canonicalChallengeBytes
The JCS-canonical (RFC 8785) UTF-8 bytes of a challenge object.
Scoped to the challenge shape: a flat object whose values are strings (or absent). JCS for that shape is lexicographic key order, no whitespace, and JSON string escaping — which is exactly what this produces. Do not reuse for nested or numeric payloads; pull in a full JCS implementation there.
export declare const canonicalChallengeBytes: (challenge: IdentityChallenge) => Uint8Array;Source: openagent-sdk/adapters/http/typescript/src/transport.ts:91.
identityChallengeSchema
Zod schema for challenge validation (agents MUST validate before signing).
export declare const identityChallengeSchema: z.ZodObject<{ type: z.ZodLiteral<"openagent-challenge-v1">; nonce: z.ZodString; timestamp: z.ZodString; origin: z.ZodString; realm: z.ZodOptional<z.ZodString>; }, z.core.$strict>;Source: openagent-sdk/adapters/http/typescript/src/transport.ts:56.
identityVerifiedSchema
Zod schema for the verified session message.
export declare const identityVerifiedSchema: z.ZodObject<{ did: z.ZodString; trust_tier: z.ZodEnum<{ anonymous: "anonymous"; identified: "identified"; sovereign: "sovereign"; }>; session_token: z.ZodString; session_expires: z.ZodString; capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strip>;Source: openagent-sdk/adapters/http/typescript/src/transport.ts:75.
IdentityChallenge
Server → Agent: a cryptographic challenge (Section 15.2).
/** Server → Agent: a cryptographic challenge (Section 15.2). */
export interface IdentityChallenge {
type: string;
/** 64-character lowercase hex string (32 CSPRNG bytes). */
nonce: string;
/** ISO 8601 UTC, Z suffix, seconds precision. */
timestamp: string;
/** `scheme://host[:port]`. */
origin: string;
/** Optional protection-space identifier. */
realm?: string;
}Source: openagent-sdk/adapters/http/typescript/src/transport.ts:16.
IdentityProof
Agent → Server: the cryptographic proof of identity (Section 15.3).
/** Agent → Server: the cryptographic proof of identity (Section 15.3). */
export interface IdentityProof {
/** Base64url (no padding) signature over the JCS-canonical challenge bytes. */
signature: string;
/** Base64url (no padding) raw public key. */
public_key: string;
key_type: KeyType;
/** The nonce from the challenge, echoed. */
nonce: string;
}Source: openagent-sdk/adapters/http/typescript/src/transport.ts:32.
IdentityVerified
Server → Agent: identity confirmed; session issued (Section 15.4).
/** Server → Agent: identity confirmed; session issued (Section 15.4). */
export interface IdentityVerified {
did: string;
trust_tier: TrustTier;
session_token: string;
/** ISO 8601 UTC timestamp of session expiry. */
session_expires: string;
capabilities?: string[];
}Source: openagent-sdk/adapters/http/typescript/src/transport.ts:46.
KeyType
Signature scheme for a proof (Section 15.3).
/** Signature scheme for a proof (Section 15.3). */
export type KeyType = 'ed25519' | 'secp256k1';Source: openagent-sdk/adapters/http/typescript/src/transport.ts:29.
TrustTier
The resolution tier the server assigns (Section 15.4).
/** The resolution tier the server assigns (Section 15.4). */
export type TrustTier = 'anonymous' | 'identified' | 'sovereign';Source: openagent-sdk/adapters/http/typescript/src/transport.ts:43.
HttpTransportConfig
Configuration for the HTTP transport.
/** Configuration for the HTTP transport. */
export interface HttpTransportConfig {
/** Request timeout in milliseconds. Default: 30000. */
timeoutMs?: number;
/** Custom headers to include in all requests. */
headers?: Record<string, string>;
}Source: openagent-sdk/adapters/http/typescript/src/transport.ts:121.
ConformanceLevel
Conformance level enum values.
/** Conformance level enum values. */
export type ConformanceLevel = 'L0' | 'L1' | 'L2';Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:13.
DiscoveryDocument
Discovery document returned by the server.
/** Discovery document returned by the server. */
export interface DiscoveryDocument {
auth_endpoint: string;
supported_versions: number[];
server_did: string;
required_conformance_level: ConformanceLevel;
}Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:16.
discoveryDocumentSchema
Zod schema for DiscoveryDocument.
export declare const discoveryDocumentSchema: z.ZodObject<{ auth_endpoint: z.ZodString; supported_versions: z.ZodArray<z.ZodNumber>; server_did: z.ZodString; required_conformance_level: z.ZodEnum<{ L0: "L0"; L1: "L1"; L2: "L2"; }>; }, z.core.$strip>;Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:24.
WELL_KNOWN_PATH
Default well-known path.
export declare const WELL_KNOWN_PATH: "/.well-known/openagent";Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:32.
AUTH_ENDPOINT_PATH
Default auth endpoint path.
export declare const AUTH_ENDPOINT_PATH: "/.well-known/openagent/auth";Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:35.
PROVE_ENDPOINT_PATH
Default prove endpoint path.
export declare const PROVE_ENDPOINT_PATH: "/.well-known/openagent/auth/prove";Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:38.
fetchDiscovery
Fetch the discovery document from a server.
export declare const fetchDiscovery: (baseUrl: string, timeoutMs?: number) => Promise<DiscoveryDocument>;Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:46.
resolveAuthEndpoint
Resolve the full auth endpoint URL from a base URL and discovery document.
export declare const resolveAuthEndpoint: (baseUrl: string, doc: DiscoveryDocument) => string;Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:78.
resolveProveEndpoint
Resolve the prove endpoint URL (auth endpoint + /prove).
export declare const resolveProveEndpoint: (baseUrl: string, doc: DiscoveryDocument) => string;Source: openagent-sdk/adapters/http/typescript/src/discovery.ts:85.
DEFAULT_SESSION_TTL_SECS
Default session TTL in seconds.
export declare const DEFAULT_SESSION_TTL_SECS: 300;Source: openagent-sdk/adapters/http/typescript/src/server.ts:29.
DEFAULT_CHALLENGE_TTL_SECS
Default challenge TTL in seconds (Section 7: default 30s, max 300s).
export declare const DEFAULT_CHALLENGE_TTL_SECS: 60;Source: openagent-sdk/adapters/http/typescript/src/server.ts:32.
ServerConfig
Server configuration for the HTTP endpoints.
/** Server configuration for the HTTP endpoints. */
export interface ServerConfig {
/** The server's origin per RFC 6454 (`scheme://host[:port]`). Bound into every challenge. */
origin: string;
/** Optional protection-space identifier. */
realm?: string;
/** The trust tier assigned to verified agents. Default: anonymous. */
trustTier?: TrustTier;
/** Session TTL in seconds. */
sessionTtlSecs?: number;
/** Challenge TTL in seconds. */
challengeTtlSecs?: number;
/** Conformance level advertised in discovery. */
requiredConformance?: ConformanceLevel;
}Source: openagent-sdk/adapters/http/typescript/src/server.ts:35.
SessionState
Session states.
/** Session states. */
export type SessionState = 'awaiting_proof' | 'established' | 'closed';Source: openagent-sdk/adapters/http/typescript/src/server.ts:63.
StoredSession
A stored session.
/** A stored session. */
export interface StoredSession {
id: string;
state: SessionState;
initiatorDid: string;
responderDid: string;
nonce: string;
/** The exact challenge timestamp (spec format); needed to reconstruct the signed payload. */
challengeTimestamp: string;
createdAt: number;
expiresAt: number;
capabilities: string[];
}Source: openagent-sdk/adapters/http/typescript/src/server.ts:66.
SessionStore
Session store interface.
/** Session store interface. */
export interface SessionStore {
put(session: StoredSession): Promise<void>;
get(sessionId: string): Promise<StoredSession | undefined>;
remove(sessionId: string): Promise<void>;
}Source: openagent-sdk/adapters/http/typescript/src/server.ts:80.
VerifySignatureFn
Signature verifier function. The caller provides this (crypto-wasm, libsodium, noble-ed25519, a KMS call) since Ed25519 verification is not in every runtime's Web Crypto.
/**
* Signature verifier function. The caller provides this (crypto-wasm,
* libsodium, noble-ed25519, a KMS call) since Ed25519 verification is not in
* every runtime's Web Crypto.
*/
export type VerifySignatureFn = (params: {
publicKeyBase64Url: string;
payload: Uint8Array;
signatureBase64Url: string;
}) => Promise<boolean>;Source: openagent-sdk/adapters/http/typescript/src/server.ts:187.
AuthResult
Result of authenticating an incoming request.
/** Result of authenticating an incoming request. */
export interface AuthResult {
authenticated: boolean;
peerDid?: string;
sessionToken?: string;
error?: string;
}Source: openagent-sdk/adapters/http/typescript/src/server.ts:276.
InMemorySessionStore
In-memory session store for development and testing.
export declare class InMemorySessionStore {
put(session: StoredSession): Promise<void>;
get(sessionId: string): Promise<StoredSession | undefined>;
remove(sessionId: string): Promise<void>;
}Source: openagent-sdk/adapters/http/typescript/src/server.ts:87.
CoreAuthError
Error returned by server handlers, carrying the HTTP status to render.
export declare class CoreAuthError {
statusCode: number;
constructor(message: string, statusCode: number): CoreAuthError;
}Source: openagent-sdk/adapters/http/typescript/src/server.ts:104.
createServerConfig
Create a server config with sensible defaults.
export declare const createServerConfig: (origin: string, overrides?: Partial<ServerConfig>) => Required<Pick<ServerConfig, "origin" | "trustTier" | "sessionTtlSecs" | "challengeTtlSecs" | "requiredConformance">> & ServerConfig;Source: openagent-sdk/adapters/http/typescript/src/server.ts:51.
handleDiscovery
Handle GET /.well-known/openagent - returns the discovery document.
export declare const handleDiscovery: (config: ServerConfig & { requiredConformance?: ConformanceLevel; }) => DiscoveryDocument;Source: openagent-sdk/adapters/http/typescript/src/server.ts:134.
handleChallenge
Handle the challenge step - issue an IdentityChallenge.
Records a pending session keyed by the nonce: the proof carries exactly that correlation, and single-use-ness is enforced by removal.
export declare const handleChallenge: (config: ServerConfig & { requiredConformance?: ConformanceLevel; }, store: SessionStore) => Promise<IdentityChallenge>;Source: openagent-sdk/adapters/http/typescript/src/server.ts:149.
handleProve
Handle the prove step - verify an IdentityProof and issue a session.
Verification is normative-ordered: pending challenge first (present, unexpired), then shape checks (nonce echo), then the signature over the JCS-canonical challenge bytes. The nonce is consumed on success and on failure - a failed answer must not be retryable, or a verifier becomes an oracle.
export declare const handleProve: (config: ServerConfig & { requiredConformance?: ConformanceLevel; }, store: SessionStore, body: unknown, verifySignature: VerifySignatureFn) => Promise<IdentityVerified>;Source: openagent-sdk/adapters/http/typescript/src/server.ts:202.
authenticateRequest
Authenticate an incoming request by checking the session token.
export declare const authenticateRequest: (request: Request, store: SessionStore) => Promise<AuthResult>;Source: openagent-sdk/adapters/http/typescript/src/server.ts:284.
MiddlewareOptions
Options for creating OAAP middleware.
/** Options for creating OAAP middleware. */
export interface MiddlewareOptions {
/** Server DID. */
serverDid: string;
/** Session store (default: in-memory). */
store?: SessionStore;
/** Required conformance level (default: L2). */
requiredConformance?: 'L0' | 'L1' | 'L2';
/** Session TTL in seconds (default: 300). */
sessionTtlSecs?: number;
/** Challenge TTL in seconds (default: 60). */
challengeTtlSecs?: number;
/** Signature verification function. */
verifySignature: VerifySignatureFn;
/** Paths to exclude from authentication (well-known paths are always excluded). */
excludePaths?: string[];
}Source: openagent-sdk/adapters/http/typescript/src/middleware.ts:21.
createOpenAgentHandler
Create a generic OAAP middleware using the standard fetch Request/Response API.
Returns a function that:
- Handles OAAP well-known endpoints
- Validates authenticated requests
- Returns
undefinedfor well-known routes (caller should send the JSON response)
Works with Hono, Cloudflare Workers, Deno, Bun, and any fetch-based framework.
export declare const createOpenAgentHandler: (options: MiddlewareOptions) => { config: ServerConfig; store: SessionStore; handle: (request: Request) => Promise<Response | AuthResult>; };Source: openagent-sdk/adapters/http/typescript/src/middleware.ts:55.
createOpenAgentMiddleware
Create Express-compatible middleware.
Usage:
app.use(createOpenAgentMiddleware({
serverDid: 'did:oas:l1fe:service:api',
verifySignature: async (did, payload, sig) => { ... },
}));export declare const createOpenAgentMiddleware: (options: MiddlewareOptions) => (req: { url?: string; method?: string; headers: Record<string, string | string[] | undefined>; path?: string; }, res: { status: (code: number) => { json: (body: unknown) => void; end: () => void; }; }, next: () => void) => Promise<void>;Source: openagent-sdk/adapters/http/typescript/src/middleware.ts:155.
ClientConfig
Client configuration.
/** Client configuration. */
export interface ClientConfig {
/**
* The agent's DID. Reported to the server for audit and, where the
* deployment resolves DIDs, for trust-tier assignment. The agent proves
* possession of the key - lineage evaluation is the server's job.
*/
did: string;
/** The signature scheme the `sign` function implements. */
keyType?: KeyType;
/** Request timeout in milliseconds. Default: 30000. */
timeoutMs?: number;
}Source: openagent-sdk/adapters/http/typescript/src/client.ts:18.
SignFn
Function that signs a payload and returns a base64url (no padding) encoded signature.
The caller provides this — it may use
/**
* Function that signs a payload and returns a base64url (no padding)
* encoded signature.
*
* The caller provides this — it may use @openagentid/crypto-wasm, Web Crypto,
* or any Ed25519 implementation.
*/
export type SignFn = (payload: Uint8Array) => Promise<string>;Source: openagent-sdk/adapters/http/typescript/src/client.ts:38.
HttpAuthClient
HTTP client that performs the Core Protocol identity flow.
Usage:
const client = new HttpAuthClient({
config: { did: 'did:oas:l1fe:agent:my-bot' },
sign: async (payload) => base64url(ed25519Sign(privateKey, payload)),
publicKey: async () => base64url(ed25519PublicKey(privateKey)),
});
const session = await client.authenticate('https://api.example.com');
const resp = await session.get('/api/tools');export declare class HttpAuthClient {
constructor(params: { config: ClientConfig; sign: SignFn; publicKey: () => Promise<string>; transport?: HttpTransport; }): HttpAuthClient;
authenticate(baseUrl: string): Promise<AuthenticatedSession>;
}Source: openagent-sdk/adapters/http/typescript/src/client.ts:54.
AuthenticatedSession
An authenticated HTTP session obtained after a successful Core Protocol identity flow.
export declare class AuthenticatedSession {
constructor(params: { baseUrl: string; sessionId: string; peerDid: string; sessionToken: string; expiresAt: number; }): AuthenticatedSession;
isExpired(): boolean;
getSessionId(): string;
getPeerDid(): string;
getBaseUrl(): string;
fetch(path: string, init?: RequestInit): Promise<Response>;
get(path: string): Promise<Response>;
post(path: string, body: unknown): Promise<Response>;
put(path: string, body: unknown): Promise<Response>;
delete(path: string): Promise<Response>;
}Source: openagent-sdk/adapters/http/typescript/src/session.ts:12.
VERSION
SDK version — kept in sync with package.json.
export declare const VERSION: "0.1.1";Source: openagent-sdk/adapters/http/typescript/src/index.ts:86.