Autenticación del cliente Flight
Usa la dirección de tu servidor Flight. Para las conexiones TLS, el cliente utiliza por defecto los certificados raíz de confianza del sistema.
Token Bearer
Guarda el token en la variable de entorno FLIGHT_TOKEN. El cliente envía los metadatos authorization en cada llamada.
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();
Autenticación TLS mutua
Si el servidor requiere mTLS, proporciona el certificado raíz de confianza y las credenciales del cliente.
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();
Las rutas de los certificados se resuelven a partir del directorio de trabajo del proceso. Proporciona privateKey y certificateChain juntos.