@cshield/client
@cshield/client
Client SDK for communicating with ContractShield sidecar or centralized service.
Installation
npm install @cshield/clientUsage
import { ContractShieldClient } from '@cshield/client';
const client = new ContractShieldClient({ url: 'http://localhost:3100', cacheEnabled: true, cacheTtlMs: 60000, failOpen: true, retries: 2, timeoutMs: 5000});
const decision = await client.evaluate(context);Options
| Option | Type | Default | Description |
|---|---|---|---|
url | string | required | Sidecar/service URL |
socketPath | string | - | Unix socket path (faster) |
cacheEnabled | boolean | false | Enable response caching |
cacheTtlMs | number | 60000 | Cache TTL in ms |
failOpen | boolean | false | Allow on error |
retries | number | 0 | Retry attempts |
timeoutMs | number | 5000 | Request timeout |
Unix Socket (Low Latency)
const client = new ContractShieldClient({ socketPath: '/var/run/contractshield/pdp.sock'});Latency: ~0.1ms vs ~1-5ms for HTTP.