@tak-ps/node-tak
Version: 
Lightweight JavaScript library for communicating with TAK Server
60 lines (59 loc) • 1.98 kB
TypeScript
import EventEmitter from 'node:events';
import type { Static } from '@sinclair/typebox';
import CoT from '@tak-ps/node-cot';
import type { CoTOptions } from '@tak-ps/node-cot';
import type { TLSSocket } from 'node:tls';
import TAKAPI from './lib/api.js';
import { TAKAuth } from './lib/auth.js';
export * from './lib/auth.js';
export declare const REGEX_CONTROL: RegExp;
export declare const REGEX_EVENT: RegExp;
export interface PartialCoT {
    event: string;
    remainder: string;
}
export type TAKOptions = {
    id?: number | string;
    type?: string;
    cot?: CoTOptions;
};
export default class TAK extends EventEmitter {
    id: number | string;
    type: string;
    url: URL;
    auth: Static<typeof TAKAuth>;
    open: boolean;
    destroyed: boolean;
    queue: string[];
    writing: boolean;
    cotOptions: CoTOptions;
    pingInterval?: ReturnType<typeof setTimeout>;
    client?: TLSSocket;
    version?: string;
    /**
     * @constructor
     *
     * @param url   - Full URL of Streaming COT Endpoint IE: "https://ops.cotak.gov:8089"
     * @param auth  - TAK Certificate Pair
     * @param opts  - Options Object
     * @param opts.id   - When using multiple connections in a script, allows a unique ID per connection
     * @param opts.type - When using multiple connections in a script, allows specifying a script provided connection type
     */
    constructor(url: URL, auth: Static<typeof TAKAuth>, opts?: TAKOptions);
    static connect(url: URL, auth: Static<typeof TAKAuth>, opts?: TAKOptions): Promise<TAK>;
    connect_ssl(): Promise<TAK>;
    reconnect(): Promise<void>;
    destroy(): void;
    ping(): Promise<void>;
    writer(body: string): Promise<boolean>;
    process(): Promise<void>;
    /**
     * Write a CoT to the TAK Connection
     *
     * @param {CoT} cot CoT Object
     */
    write(cots: CoT[]): Promise<void>;
    write_xml(body: string): void;
    static findCoT(str: string): null | PartialCoT;
}
export { TAKAPI, CoT, };