Configuration
TheBlursec (or BlursecClient) constructor accepts a single BlursecClientConfig object:
blursec.config for diagnostics.
apiKey — required
Non-empty string. Sent on every request as Authorization: Bearer <apiKey>.
Never embed the key in client-side bundles. API keys grant full access to your Blursec workspace.
environment — default: "production"
One of "production", "staging", "local". Selects the default baseUrl:
baseUrl — default: derived from environment
Explicit override for the API base URL. Useful for:
- Self-hosted Blursec deployments
- Pointing the SDK at a recording proxy (e.g. for VCR-style tests)
- Per-region traffic steering
https://api.example.com and https://api.example.com/ behave identically.
timeoutMs — default: 30_000
Default per-request timeout in milliseconds. Applied to every request the SDK makes via AbortController, unless overridden by a per-call options.timeoutMs.
Credential checks use their own default of 1500 ms (see credentials.md). This config option only affectsMust be a positive finite number —auth.*andsessions.*calls, plus arbitraryclient.request()calls.
0, -1, and Infinity throw BlursecValidationError.
defaultHeaders — default: {}
Extra headers attached to every outbound request. Useful for:
- Tenant routing (
X-Tenant,X-Workspace-Id) - Tracing (
traceparent,X-Request-Id) - Feature flags
options.headers always wins over defaults. The SDK manages Authorization, Accept, and Content-Type itself.
fetch — default: globalThis.fetch
Inject a custom fetch implementation. Required on:
- Runtimes without a global
fetch(older Node, some embedded environments) - Tests where you want to record/replay HTTP traffic
- Production setups with custom retry, telemetry, or DNS-pinning logic
Don’t add retries on credential checks. A failed checkCredential should fail open instantly — see examples/custom-fetch-retry.ts.
logger / logLevel — optional structured audit logging
Pass a BlursecLogger to receive PII-scrubbed, structured-log entries for every security-relevant event (client init, each check, fail-open, breaker transitions). Omitted → the SDK emits nothing.
audit-level entries are always emitted regardless of logLevel (SOC 2 audit trail). Use createNoopLogger() to explicitly silence everything.
circuitBreaker — optional
Guards the credential-check hot path: after repeated failures the breaker opens and rejects requests fast (folded into the existing fail-open path) so login latency doesn’t balloon during a Blursec incident.
/health endpoint via the exported CircuitBreaker.

