initialize(options)

Initializes the DropOnAir client. On first call it generates an X25519 keypair, stores it securely, publishes the public key to your key directory, exchanges a token, and opens the WebSocket connection.

Returns a Promise<DropOnAirClient>.

import { initialize } from '@droponair/sdk-js';

const client = await initialize({
  appId:                'your-app-id',
  publicApiKey:         'your-public-api-key',
  getUserJwt:           () => fetch('/api/auth/token').then(r => r.text()),
  tokenExchangeEndpoint: '/api/droponair/token',
  keyDirectoryEndpoint:  '/api/droponair/keys',
});

Options

OptionTypeRequiredDescription
appIdstringYesYour DropOnAir App ID from the dashboard
publicApiKeystringYesYour public API key, safe to expose client-side
getUserJwt() => Promise<string>YesCallback that returns a fresh JWT from your backend. Called on connect and token refresh.
tokenExchangeEndpointstringNoYour backend endpoint that calls DropOnAir token exchange
keyDirectoryEndpointstringNoYour backend endpoint base for PUT/GET public keys
autoConnectbooleanNoAuto-connect on initialization. Default: true
autoAckIncomingMessagesbooleanNoAuto-send PROCESSED ack after decryption. Set false for manual ack. Default: true
storageKeyStorageAdapterNoCustom key storage. Default: IndexedDB with in-memory fallback
fetchFntypeof fetchNoCustom fetch (e.g. for React Native). Default: globalThis.fetch
debugbooleanNoVerbose diagnostic logs for all SDK operations