Installation
Requirements
- Node.js >= 20
Quick Start
1. Initialize Identity
Create a local agent identity once:2. Certify Your Agent
Attach identity and signed request helpers to any object:.sigilum property with identity metadata and request helpers.
3. Send Signed Requests
API Reference
certify(agent, options?)
Attaches Sigilum identity bindings to an agent object.
Parameters:
agent: object- Any object to certify (required)options?: CertifyOptionsnamespace?: string- Namespace to load (defaults to first found)homeDir?: string- Custom identity directory (defaults to~/.sigilum)apiBaseUrl?: string- API base URL (defaults tohttps://api.sigilum.idorSIGILUM_API_URL)fetchImpl?: typeof fetch- Custom fetch implementation
CertifiedAgent<T> - The agent with .sigilum bindings attached
Example:
agent.sigilum
Bindings attached to certified agents:
Properties
namespace: string- Agent’s namespacedid: string- Agent’s DID (for example:did:sigilum:alice:default#agent-abc123#alice)keyId: string- Agent’s key IDpublicKey: string- Agent’s Ed25519 public key (ed25519:...)certificate: SigilumCertificate- Agent’s certificate with proofapiBaseUrl: string- Resolved API base URL
Methods
sign(request)
Signs a request without sending it.
Parameters:
request: SignRequestInputurl: string | URL- Request URL (absolute or relative)method?: string- HTTP method (defaults toGET)headers?: HeaderInput- Request headersbody?: string | Uint8Array | ArrayBuffer | null- Request bodysubject?: string- Override subject for this requestcreated?: number- Unix timestamp for signature (defaults to now)nonce?: string- Custom nonce (defaults to random UUID)
SignedRequest
Example:
fetch(input, init?)
Signs and sends a request using the Fetch API.
Parameters:
input: string | URL | Request- Request URL or Request objectinit?: SigilumRequestOptions- Request options (extendsRequestInit)subject?: string- Override subject for this request- …all standard
RequestInitoptions
Promise<Response>
Example:
request(path, init?)
Convenience method that resolves paths relative to the namespace API base.
Parameters:
path: string- Path relative to/v1/namespaces/{namespace}/init?: SigilumRequestOptions- Request options
Promise<Response>
Example:
initIdentity(options)
Programmatically initialize a new agent identity.
Parameters:
options: InitIdentityOptionsnamespace: string- Namespace for this identity (required)homeDir?: string- Custom identity directoryforce?: boolean- Overwrite existing identity
InitIdentityResult
Example:
loadIdentity(options?)
Load an existing agent identity.
Parameters:
options?: LoadIdentityOptionsnamespace?: string- Namespace to load (defaults to first found)homeDir?: string- Custom identity directory
SigilumIdentity
Example:
verifyHttpSignature(input)
Verify an incoming signed request (server-side).
Parameters:
input: VerifySignatureInputurl: string | URL- Request URLmethod: string- HTTP methodheaders: HeaderInput- Request headersbody?: string | Uint8Array | ArrayBuffer | null- Request bodyexpectedNamespace?: string- Require specific namespaceexpectedSubject?: string- Require specific subjectstrict?: object- Replay/timestamp strictnessmaxAgeSeconds?: number- Maximum signature agenow?: number- Current Unix timestamp (defaults to now)nonceStore?: Set<string>- Nonce set for replay detection
VerifySignatureResult
Example:
retryWithBackoff(operation, options)
Retry helper with exponential backoff for idempotent operations.
Parameters:
operation: () => Promise<T>- Async operation to retryoptions: RetryWithBackoffOptions<T>idempotent: boolean- Required. Must betruewhenattempts > 1attempts?: number- Max attempts (defaults to 3)baseDelayMs?: number- Initial delay (defaults to 100ms)maxDelayMs?: number- Maximum delay (defaults to 2000ms)jitterRatio?: number- Jitter ratio (defaults to 0.2)shouldRetryResult?: (result: T) => boolean- Retry predicate for resultsshouldRetryError?: (error: unknown) => boolean- Retry predicate for errorssleep?: (delayMs: number) => Promise<void>- Custom sleep implementation
Promise<T>
Example:
shouldRetryHttpStatus(status)
Helper that returns true for retryable HTTP status codes.
Retryable statuses: 429, 502, 503, 504
Example:
Subject Override
Override thesigilum-subject header for a specific request:
subject is omitted, the SDK defaults to the signer’s namespace.
Identity Model
Hierarchy:namespace -> service -> agent -> subject
DID Format: did:sigilum:{namespace}:{service}#{agent}#{subject}
Example: did:sigilum:mfs:narmi#davis-agent#customer-12345
Error Codes
Signature verification failures return deterministic codes:| Code | Meaning |
|---|---|
SIG_CONTENT_DIGEST_MISMATCH | Request body tampered |
SIG_VERIFICATION_FAILED | Signature cryptographically invalid |
SIG_CERT_INVALID | Agent certificate proof failed |
SIG_TIMESTAMP_OUT_OF_RANGE | Signature expired or not yet valid |
SIG_REPLAY_DETECTED | Nonce already seen (replay attack) |
SIG_NAMESPACE_MISMATCH | Namespace header doesn’t match cert |
SIG_SUBJECT_MISSING | Required subject header missing |
SIG_MISSING_SIGNATURE_HEADERS | Missing Signature-Input or Signature |
SIG_ALGORITHM_UNSUPPORTED | Unsupported signature algorithm |
Authentication Note
Signed headers prove agent identity. Some endpoints also require additional auth: Example:POST /v1/claims requires Authorization: Bearer <service_api_key>
Advanced Usage
Custom Fetch Implementation
Manual Signing
Certificate Encoding/Decoding
Next Steps
SDK Overview
Learn about the common SDK contract
Python SDK
View the Python SDK documentation