Skip to content

PrivacyBackendRegistry

SIP Protocol API Reference v0.7.4


SIP Protocol API Reference / PrivacyBackendRegistry

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20266

Registry for managing privacy backends

Provides a centralized way to register, discover, and manage different privacy backend implementations. Optionally integrates with BackendHealthTracker for circuit breaker support.

new PrivacyBackendRegistry(config?): PrivacyBackendRegistry

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20275

Create a new registry

PrivacyBackendRegistryConfig

Registry configuration

PrivacyBackendRegistry

getHealthTracker(): BackendHealthTracker | null

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20281

Get the health tracker instance

BackendHealthTracker | null

Health tracker or null if not enabled


setHealthTracker(tracker): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20290

Attach an external health tracker

Useful for sharing a health tracker between multiple registries or for testing.

Health tracker to attach

BackendHealthTracker | null

void


getRateLimiter(): RateLimiter | null

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20296

Get the rate limiter instance

RateLimiter | null

Rate limiter or null if not enabled


setRateLimiter(limiter): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20305

Attach an external rate limiter

Useful for sharing a rate limiter between multiple registries or for testing.

Rate limiter to attach

RateLimiter | null

void


register(backend, options?): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20319

Register a privacy backend

PrivacyBackend

Backend instance to register

BackendRegistrationOptions

Registration options

void

Error if backend with same name exists and override is false

registry.register(new SIPNativeBackend())
registry.register(new PrivacyCashBackend(), { priority: 100 })

unregister(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20326

Unregister a backend by name

string

Backend name to unregister

boolean

true if backend was removed, false if not found


get(name): PrivacyBackend | undefined

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20333

Get a backend by name

string

Backend name

PrivacyBackend | undefined

Backend instance or undefined if not found


has(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20340

Check if a backend is registered

string

Backend name

boolean

true if registered (regardless of enabled state)


getAll(): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20346

Get all enabled backends sorted by priority

PrivacyBackend[]

Array of backends (highest priority first)


getAllEntries(): RegisteredBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20352

Get all registered entries (including disabled)

RegisteredBackend[]

Array of registered backend entries


getByChain(chain): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20359

Get backends supporting a specific chain

string

Chain type to filter by

PrivacyBackend[]

Array of backends supporting the chain


getByType(type): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20366

Get backends of a specific type

PrivacyBackendType

Backend type to filter by

PrivacyBackend[]

Array of backends of the specified type


getCompliant(): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20372

Get backends that support compliance (viewing keys)

PrivacyBackend[]

Array of compliance-supporting backends


findAvailable(params): Promise<object[]>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20379

Find available backends for a transfer

PrivacyTransferParams

Transfer parameters

Promise<object[]>

Array of available backends with availability info


enable(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20389

Enable a backend

string

Backend name

boolean

true if backend was enabled, false if not found


disable(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20396

Disable a backend

string

Backend name

boolean

true if backend was disabled, false if not found


setPriority(name, priority): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20404

Set backend priority

string

Backend name

number

New priority value

boolean

true if priority was set, false if not found


count(enabledOnly?): number

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20411

Get count of registered backends

boolean

If true, only count enabled backends

number

Number of backends


clear(): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20415

Clear all registered backends

void


getNames(enabledOnly?): string[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20422

Get backend names

boolean

If true, only return enabled backend names

string[]

Array of backend names


getHealthy(): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20431

Get all healthy backends (circuit not open)

Filters out backends where the circuit breaker is open. Falls back to getAll() if health tracking is disabled.

PrivacyBackend[]

Array of healthy backends


getHealthyByChain(chain): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20438

Get healthy backends supporting a specific chain

string

Chain type to filter by

PrivacyBackend[]

Array of healthy backends supporting the chain


getHealthState(name): BackendHealthState | undefined

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20445

Get health state for a backend

string

Backend name

BackendHealthState | undefined

Health state or undefined if not tracked


getMetrics(name): BackendMetrics | undefined

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20452

Get metrics for a backend

string

Backend name

BackendMetrics | undefined

Metrics or undefined if not tracked


getHealthSummary(): Record<string, { healthy: boolean; state: string; failures: number; lastError?: string; }>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20458

Get summary of all backend health

Record<string, { healthy: boolean; state: string; failures: number; lastError?: string; }>

Object with backend names as keys and health info as values


isHealthy(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20470

Check if a backend is healthy

string

Backend name

boolean

true if healthy or health tracking is disabled


openCircuit(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20479

Manually open circuit for a backend

Useful for maintenance or known issues.

string

Backend name

boolean

true if circuit was opened, false if not found or tracking disabled


closeCircuit(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20488

Manually close circuit for a backend

Use with caution - may route requests to failing backend.

string

Backend name

boolean

true if circuit was closed, false if not found or tracking disabled


resetHealth(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20497

Reset health state for a backend

Clears failure count and closes circuit.

string

Backend name

boolean

true if reset, false if not found or tracking disabled


recordSuccess(name, latencyMs): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20504

Record a successful execution for a backend

string

Backend name

number

Request latency in milliseconds

void


recordFailure(name, reason): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20511

Record a failed execution for a backend

string

Backend name

string

Failure reason

void


tryAcquire(name, tokens?): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20519

Try to acquire rate limit tokens for a backend (non-blocking)

string

Backend name

number

Number of tokens to acquire (default: 1)

boolean

true if tokens were acquired, false if rate limited or limiter disabled


acquire(name, options?): Promise<void>

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20528

Acquire rate limit tokens for a backend (async with queueing)

string

Backend name

AcquireOptions

Acquire options (tokens, timeout)

Promise<void>

Promise resolving when tokens are acquired

RateLimitExceededError, QueueFullError, or AcquireTimeoutError


canAcquire(name, tokens?): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20536

Check if tokens can be acquired without consuming them

string

Backend name

number

Number of tokens to check (default: 1)

boolean

true if tokens are available


getRateLimitStats(name): RateLimitStats | undefined

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20543

Get rate limit statistics for a backend

string

Backend name

RateLimitStats | undefined

Rate limit stats or undefined if limiter disabled


isRateLimited(name): boolean

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20550

Check if a backend is rate limited (no tokens available)

string

Backend name

boolean

true if rate limited, false if available or limiter disabled


getAvailable(): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20556

Get all backends that are NOT rate limited

PrivacyBackend[]

Array of backends with available rate limit tokens


getAvailableByChain(chain): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20565

Get available backends for a specific chain

Filters by both chain support and rate limit availability.

string

Chain type to filter by

PrivacyBackend[]

Array of available backends supporting the chain


getReady(): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20571

Get backends that are both healthy AND not rate limited

PrivacyBackend[]

Array of backends ready for use


getReadyByChain(chain): PrivacyBackend[]

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20578

Get ready backends for a specific chain

string

Chain type to filter by

PrivacyBackend[]

Array of ready backends supporting the chain


resetRateLimit(name): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20586

Reset rate limit state for a backend

Refills bucket to max tokens and clears stats.

string

Backend name

void


disposeRateLimiter(): void

Defined in: @sip-protocol/sdk/dist/index-DXh2IGkz.d.ts:20592

Dispose rate limiter resources

Call when shutting down to clean up queue processing intervals.

void