Select the runtime and credential path
For server-side use, run Node.js 22 or newer and keep NEURALDEFEND_API_KEY in a secret manager or process environment. You can also pass apiKey explicitly. The staging factory selects the documented staging origin.
The browser build never reads environment variables. Do not ship an onboarding key in JavaScript, HTML, source maps, a mobile bundle, or static configuration. The published guide recommends an application-owned backend upload unless the tenant has an explicitly approved browser credential flow.
Use runtime-specific inputs
Node.js accepts a filesystem path, Uint8Array, Buffer, Blob, File, or readable stream under documented filename rules. Browsers accept File or Blob. A plain Blob, bytes, or unnamed stream needs an explicit filename.
Always branch on result.status. JSON.stringify emits stable normalized properties, while result.raw is a deeply frozen, redacted diagnostic payload and is not the stable application contract. Future unrecognized status or risk values resolve to an unknown result rather than silently becoming approval.
Cancellation, errors, and retries
Pass an AbortSignal to cancel preparation, retry waits, upload, or response processing. Caller cancellation is distinct from a timeout. The error hierarchy also distinguishes validation, authentication, scope, rate limit, server, network, protocol, and other HTTP failures.
The SDK applies bounded retries to selected rate-limit and server responses. Timeouts, network failures, protocol errors, cancellation, and most other HTTP failures are not retried automatically. Avoid wrapping the SDK in an uncoordinated retry loop.
Evidence boundary
Limitations
- No public documentation provides a universal browser credential-issuance implementation; keep uploads server-side unless Neural Defend approves a tenant-specific browser design.
Source record
