Client is the entry point of the CyborgDB JS/TS SDK. It connects to a running CyborgDB service and creates, loads, and lists encrypted indexes. Operations on an index, such as upsert and query, are methods of the EncryptedIndex it returns.
Constructor
Parameters
apiKey is the service authentication credential: the root key or a per-user cdbk_ token. It is required only when the service runs with CYBORGDB_SERVICE_ROOT_KEY set; against an unauthenticated service (the default), omit it. This is distinct from the service’s CYBORGDB_API_KEY license key. See Managing Keys.CyborgDBValidationError if baseUrl can’t be parsed or doesn’t use http:// or https://.
Example Usage
TLS verification
verifySsl decides whether the SDK checks the service’s TLS certificate:
Turning verification off works on Node.js, where requests then go through the
node:https module instead of fetch. It follows redirects and honors AbortSignal, and it times out a connection after 300 seconds of inactivity. Browsers and Edge runtimes can’t turn verification off; verifySsl: false has no effect there.
When verification is off, the SDK logs console.warn messages: on Node, one saying verification is disabled and a second saying the insecure transport is in use. The loopback auto-detect case logs its first message with console.info. A plain http:// URL also logs “SSL verification is disabled”, although there is no TLS to disable.
Errors
Failed requests throw a subclass ofCyborgDBError chosen by HTTP status, such as CyborgDBNotFoundError for 404 or CyborgDBAuthenticationError for 401. Arguments rejected inside the SDK, before a request is sent, throw CyborgDBValidationError. See Errors for the full list.
Supported runtimes
The package has no runtime dependencies and needs onlyfetch and Web Crypto, so it runs on: