Skip to main content

AppChainConfig

The configuration object passed to AppChain.create().

type AppChainConfig = {
providerName: string;
issuer: string;
capabilities: Capability[];

// Identity persistence
host?: {
name?: string;
issuerUrl?: string;
privateKeyJwk?: JsonWebKey;
publicKeyJwk?: JsonWebKey;
};
agent?: {
agentId?: string;
privateKeyJwk?: JsonWebKey;
publicKeyJwk?: JsonWebKey;
};

// Store & adapters
encryptionKey?: string;
jtiAdapter?: JtiPersistenceAdapter;
storeAdapter?: StorePersistenceAdapter;
grantResolver?: (agentId: string, capability: string) => Promise<ResolvedGrant | undefined>;
auditExporter?: AuditExporter;
traceExporter?: TraceExporter;

// Access request system
accessRequests?: {
approvalSecret: string;
requestTTLMs?: number;
notifier: AccessRequestNotifier;
};
};

Required Fields

FieldTypeDescription
providerNamestringHuman-readable name for this service
issuerstringCanonical URL (e.g. https://myservice.com)
capabilitiesCapability[]Array of capability definitions

Identity Fields

FieldDescription
host.privateKeyJwkIf provided, restores the host identity instead of generating a new one
host.publicKeyJwkMust be provided together with privateKeyJwk
host.issuerUrlOverrides top-level issuer if set (must not conflict)
agent.agentIdRequired when restoring from JWKs
agent.privateKeyJwkRestore agent identity
agent.publicKeyJwkMust be provided together with privateKeyJwk

Adapter Fields

FieldDescription
encryptionKeyAES-256-GCM key for EncryptedStore (hex or base64). Auto-generated if omitted.
jtiAdapterRedis/database adapter for cross-process JTI replay protection
storeAdapterRedis/database adapter for persistent EncryptedStore
grantResolverDynamic grant lookup from your database
auditExporterWhere to drain audit entries (ConsoleAuditExporter, HttpAuditExporter, or custom)
traceExporterDefault exporter for closeTrace() — ships completed TraceRun objects (ConsoleTraceExporter, HttpTraceExporter, or custom)

Access Request Fields

FieldDescription
accessRequests.approvalSecretHMAC secret for verification codes. Keep outside agent reach.
accessRequests.requestTTLMsHow long a pending request stays open (default: 5 min)
accessRequests.notifierPluggable delivery channel for access request notifications

AppChain Methods

MethodReturnsDescription
wrap(target, grants, traceId?)Proxy<T>Wraps a service object with the auth gate; pass traceId to group spans
openTrace()stringOpen a new trace run; returns traceId
closeTrace(traceId, status, exporter?)Promise<TraceRun | undefined>Close trace and export the completed run
getAuditLog()AuditEntry[]All audit entries
getStats()ChainStatsSummary statistics
drain(exporter?)Promise<void>Export and clear audit buffer
destroy()voidClean up timers (JTI GC, access request expiry)
getWellKnownConfig()AgentConfigurationDiscovery endpoint payload
approve(decision)AccessRequestApprove a pending access request
deny(decision)AccessRequestDeny a pending access request
getPendingRequests()AccessRequest[]List pending requests
getApprovalRules()ApprovalRule[]List active approval rules
revokeApproval(ruleId)booleanRevoke a specific rule
revokeApprovalsForCapability(cap)numberRevoke all rules for a capability
revokeAllApprovals()numberRevoke all rules
accessRequestsEnabledbooleanWhether access requests are configured

AppChain Properties

PropertyTypeDescription
hostHostIdentityThe host identity
agentIdstringThe agent's stable ID (JWK thumbprint)