Arrow Flight Client Node.js
On this page

Flight client authentication

Use the address of your Flight server. For TLS connections, the client uses the system's trusted root certificates by default.

Bearer token

Set the token in the FLIGHT_TOKEN environment variable. The client sends the authorization metadata with every call.

bearer.ts
import { FlightClient } from 'arrow-flight-client';

async function main() {
  const token = process.env.FLIGHT_TOKEN;

  if (!token) {
    throw new Error('Set FLIGHT_TOKEN before connecting');
  }

  const client = new FlightClient('flight.example.com:443', {
    tls: {},
    metadata: {
      authorization: `Bearer ${token}`
    }
  });

  try {
    for await (const flight of client.listFlights()) {
      console.log(flight);
    }
  }
  finally {
    await client.close();
  }
}

await main();

Mutual TLS

Provide the trusted root certificate and client identity if the server requires mTLS.

mutual-tls.ts
import { readFileSync } from 'node:fs';
import { FlightClient } from 'arrow-flight-client';

async function main() {
  const client = new FlightClient('flight.example.com:443', {
    tls: {
      rootCertificates: readFileSync('./certs/ca.pem'),
      privateKey: readFileSync('./certs/client.key'),
      certificateChain: readFileSync('./certs/client.pem')
    }
  });

  try {
    for await (const flight of client.listFlights()) {
      console.log(flight);
    }
  }
  finally {
    await client.close();
  }
}

await main();

Certificate paths are resolved from the process working directory. Provide privateKey and certificateChain together.