### Install Node-TAK Source: https://context7.com/dfpc-coe/node-tak/llms.txt Install the Node-TAK library using npm. For CLI usage, install it globally. ```bash npm install @tak-ps/node-tak ``` ```bash npm install --global @tak-ps/node-tak ``` -------------------------------- ### Install Node-TAK with NPM Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Install the node-tak package using npm. This command is for local project installation. ```bash npm install @tak-ps/node-tak ``` -------------------------------- ### Generate Documentation Locally Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Run this command to generate API documentation locally. Ensure you have npm installed. ```sh npm run doc ``` -------------------------------- ### CLI Usage Source: https://context7.com/dfpc-coe/node-tak/llms.txt Provides examples for using the command-line interface of the Node.js TAK client library. ```APIDOC ## CLI Usage ### Description The library includes a command-line interface (CLI) for interactive TAK Server operations, simplifying common tasks. ### Commands #### Initial Setup Initializes the CLI, creates a profile, and sets up necessary credentials. ```bash tak ``` #### Stream CoT Messages Connects to the TAK server and streams CoT messages in real-time. ```bash tak stream ``` #### Use Specific Profile Connects to a TAK server using a pre-configured profile. ```bash tak --profile myserver stream ``` ``` -------------------------------- ### List Packages with CLI Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Use the TAK CLI to list available packages. This is another example of an API operation accessible via the CLI. ```bash tak package list ``` -------------------------------- ### Install Node-TAK Globally Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Install the node-tak package globally for use with the CLI. This command is for global CLI installation. ```bash npm install --global @tak-ps/node-tak ``` -------------------------------- ### List Missions with CLI Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Use the TAK CLI to list available missions. This is an example of an API operation accessible via the CLI. ```bash tak mission list ``` -------------------------------- ### Basic API Usage with Node-TAK SDK Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Initialize the TAKAPI client to interact with the TAK Server REST API. This example demonstrates fetching a list of missions. ```javascript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak' const api = await TAKAPI.init(new URL('TAK SERVER Marti API & Port'), new APIAuthCertificate(auth.cert, auth.key)); const missions = await api.Mission.list(req.query); console.error(missions); ``` -------------------------------- ### Get Help for a TAK Command Source: https://context7.com/dfpc-coe/node-tak/llms.txt Access help documentation for a specific TAK command, such as 'tak mission help', to understand its options and usage. ```bash tak mission help ``` -------------------------------- ### Get Mission by GUID Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieves mission details using its unique GUID. An empty options object can be passed if no specific retrieval parameters are needed. ```typescript const missionByGuid = await api.Mission.getGuid( 'a1b2c3d4-e5f6-7890-abcd-ef1234567890', {} ); ``` -------------------------------- ### TAK CLI Usage Source: https://context7.com/dfpc-coe/node-tak/llms.txt Provides command-line interface commands for interacting with TAK Server. Use 'tak' for initial setup, 'tak stream' to stream CoT messages, and '--profile' to specify a server profile. ```bash # Initial setup - creates profile and credentials tak # Stream CoT messages from server tak stream # Use specific profile tak --profile myserver stream ``` -------------------------------- ### Get and Update Mission Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieves mission details by name or GUID and updates mission properties. ```APIDOC ## Mission API - Get and Update Mission ### Description Retrieves mission details by name or GUID and updates mission properties. ### Method GET, PUT ### Endpoint `/api/missions/{missionNameOrGuid}` (Assumed) ### Parameters #### Get Mission ##### Path Parameters - **missionNameOrGuid** (string) - Required - The name or GUID of the mission. ##### Query Parameters - **changes** (boolean) - Optional - Include mission changes in the response. - **logs** (boolean) - Optional - Include mission logs in the response. - **secago** (number) - Optional - Fetch changes from the last specified duration in seconds. #### Update Mission ##### Path Parameters - **missionNameOrGuid** (string) - Required - The name or GUID of the mission to update. ##### Request Body - **description** (string) - Optional - Updated description for the mission. - **keywords** (array of strings) - Optional - Updated keywords for the mission. - **inviteOnly** (boolean) - Optional - Updated invite-only status. ##### Query Parameters - **token** (string) - Required - The mission access token. ### Request Example (Get Mission) ```http GET /api/missions/Operation%20Alpha?changes=true&logs=true&secago=3600 ``` ### Request Example (Update Mission) ```http PUT /api/missions/Operation%20Alpha?token=mission-access-token-xyz Content-Type: application/json { "description": "Updated mission description", "keywords": ["operation", "field-team", "alpha", "updated"], "inviteOnly": true } ``` ### Response #### Success Response (200) - Get Mission - **name** (string) - The name of the mission. - **guid** (string) - The unique identifier (GUID) of the mission. - **contents** (array) - Mission content details. - **missionChanges** (array) - List of mission changes (if requested). #### Response Example (Get Mission) ```json { "name": "Operation Alpha", "guid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "contents": [...], "missionChanges": [...] } ``` #### Success Response (200) - Update Mission (Typically returns the updated mission object or a success status) ### Additional Operations #### Set Keywords Updates the keywords for a mission. ##### Method PUT ##### Endpoint `/api/missions/{missionName}/keywords` (Assumed) ##### Parameters - **missionName** (string) - Required - The name of the mission. - **keywords** (array of strings) - Required - The new list of keywords. - **token** (string) - Required - The mission access token. #### Delete Keyword Removes a specific keyword from a mission. ##### Method DELETE ##### Endpoint `/api/missions/{missionName}/keywords/{keyword}` (Assumed) ##### Parameters - **missionName** (string) - Required - The name of the mission. - **keyword** (string) - Required - The keyword to delete. - **token** (string) - Required - The mission access token. ``` -------------------------------- ### Generate Client Credentials Source: https://context7.com/dfpc-coe/node-tak/llms.txt Generates new client certificates using password authentication. This is useful for initial setup or when certificate-based authentication is not yet established. Requires server URL and username/password. ```typescript import { TAKAPI, APIAuthPassword } from '@tak-ps/node-tak'; // Must use password authentication to generate credentials const api = await TAKAPI.init( new URL('https://tak-server.example.com:443'), new APIAuthPassword('username', 'password') ); // Get TLS configuration const tlsConfig = await api.Credentials.config(); console.log('TLS Config:', tlsConfig); // Generate new certificate const newCreds = await api.Credentials.generate(); console.log('New credentials generated:'); console.log('Certificate:', newCreds.cert); console.log('Private Key:', newCreds.key); console.log('CA Chain:', newCreds.ca); // Save credentials to files import fs from 'node:fs'; fs.writeFileSync('./client.crt', newCreds.cert); fs.writeFileSync('./client.key', newCreds.key); fs.writeFileSync('./ca.crt', newCreds.ca.join(' ')); ``` -------------------------------- ### Get Mission by Name Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieves mission details by its name. Options include including mission changes, logs, and specifying a time window for changes. ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // Get mission by name const mission = await api.Mission.get('Operation Alpha', { changes: true, // Include mission changes logs: true, // Include mission logs secago: 3600 // Changes from last hour }); console.log('Mission details:', { name: mission.name, guid: mission.guid, contents: mission.contents.length, missionChanges: mission.missionChanges?.length }); ``` -------------------------------- ### Get Mission Subscription Roles Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieves the roles assigned to each subscriber of a mission. Useful for understanding user permissions within the mission. ```typescript // Get subscription roles const roles = await api.Mission.subscriptionRoles('Operation Alpha'); for (const sub of roles.data) { console.log(`${sub.username}: ${sub.role.type}`); } ``` -------------------------------- ### Manage CoT Repeaters Source: https://context7.com/dfpc-coe/node-tak/llms.txt Manages CoT (Cursor-on-Target) repeaters that periodically rebroadcast CoT messages. Use this to get, set, list, or delete repeater configurations. Requires server URL and certificate-based authentication. ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // Get current rebroadcast period const currentPeriod = await api.Repeater.period(); console.log('Current period:', currentPeriod, 'seconds'); // Set rebroadcast period await api.Repeater.period(30); // 30 seconds // List all repeaters const repeaters = await api.Repeater.list(); for (const repeater of repeaters.data) { console.log({ uid: repeater.uid, callsign: repeater.callsign, cotType: repeater.cotType, repeatType: repeater.repeatType, activated: repeater.dateTimeActivated }); } // Delete a repeater await api.Repeater.delete('repeater-uid-12345'); ``` -------------------------------- ### Set TAK P12 Password via Environment Variable Source: https://context7.com/dfpc-coe/node-tak/llms.txt Set the P12 certificate password using the 'TAK_P12_PASSWORD' environment variable. This avoids exposing the password directly in command-line arguments. The 'tak stream' command is used here as an example. ```bash export TAK_P12_PASSWORD=mypassword tak --auth ./mycert.p12 stream ``` -------------------------------- ### Manage TAK Server Certificates Source: https://context7.com/dfpc-coe/node-tak/llms.txt Handles client certificate operations for TAK Server authentication. Use this to list, get, revoke, or delete certificates. Requires server URL and certificate-based authentication. ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // List all certificates const certs = await api.Certificate.list(); for (const cert of certs.data) { console.log({ id: cert.id, subjectDn: cert.subjectDn, clientUid: cert.clientUid, issuanceDate: cert.issuanceDate, expirationDate: cert.expirationDate, serialNumber: cert.serialNumber }); } // List certificates for specific user const userCerts = await api.Certificate.list('username'); // List revoked certificates const revokedCerts = await api.Certificate.listRevoked(); // List expired certificates const expiredCerts = await api.Certificate.listExpired(); // List replaced certificates const replacedCerts = await api.Certificate.listReplaced(); // Get single certificate by hash const singleCert = await api.Certificate.get('certificate-hash'); // Download certificate const certPem = await api.Certificate.download('certificate-hash'); console.log('Certificate PEM:', certPem); // Revoke a certificate await api.Certificate.revoke('certificate-hash'); // Revoke by ID await api.Certificate.revokeIds(['cert-id-1']); // Delete certificate records await api.Certificate.deleteIds(['cert-id-1']); ``` -------------------------------- ### Manage Mission Hierarchy and Changes Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieve mission change history, manage parent-child mission relationships, and get subscribed contacts. Use 'secago' for time-based filtering of changes. ```typescript const changes = await api.Mission.changes('Operation Alpha', { secago: 86400, // Last 24 hours squashed: false // Don't combine related changes }); for (const change of changes.data) { console.log({ type: change.type, timestamp: change.timestamp, creatorUid: change.creatorUid, details: change.details }); } ``` ```typescript const children = await api.Mission.children('Parent Mission'); console.log('Child missions:', children.data.map(m => m.name)); ``` ```typescript await api.Mission.setParent('Child Mission', 'Parent Mission'); ``` ```typescript const contacts = await api.Mission.contacts('Operation Alpha'); console.log('Mission contacts:', contacts); ``` ```typescript await api.Mission.delete('Operation Alpha', { creatorUid: 'user-uid-12345', deepDelete: true // Also delete associated content }); ``` -------------------------------- ### Initialize TAK CLI Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Run the TAK CLI to generate a new Connection Profile & Credentials. The profile will be used for subsequent commands. ```bash tak ``` -------------------------------- ### Get Current Mission Subscription Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieves the current subscription status for a specific user device on a mission. ```typescript // Get current subscription const currentSub = await api.Mission.subscription('Operation Alpha', { uid: 'user-device-uid-12345' }); ``` -------------------------------- ### Basic Streaming CoT Usage with Node-TAK SDK Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Connect to a TAK Server and listen for incoming CoT data. Ensure you have the necessary connection details and authentication credentials. ```javascript import TAK from '@tak-ps/node-tak'; const tak = await TAK.connect('ConnectionID', new URL('https://tak-server.com:8089'), { key: conn.auth.key, cert: conn.auth.cert }); tak.on('cot', async (cot: CoT) => { console.error('COT', cot); // See node-cot library }).on('end', async () => { console.error(`Connection End`); }).on('timeout', async () => { console.error(`Connection Timeout`); }).on('ping', async () => { console.error(`TAK Server Ping`); }).on('error', async (err) => { console.error(`Connection Error`); }); ``` -------------------------------- ### List TAK Missions in JSON Format Source: https://context7.com/dfpc-coe/node-tak/llms.txt Use the 'tak' command with the '--format json' flag to list missions in JSON format. This is useful for programmatic processing of mission data. ```bash tak --format json mission list ``` -------------------------------- ### Use Custom P12 Certificate Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Specify a custom P12 certificate file for authentication when using the TAK CLI. Replace `` with the actual file path. ```bash --auth ``` -------------------------------- ### Upload and Download Mission Packages Source: https://context7.com/dfpc-coe/node-tak/llms.txt Upload a mission package as a ZIP archive or download the entire mission archive. Requires a file stream for upload and creates a write stream for the archive. ```typescript const fileStream = fs.createReadStream('./mission-package.zip'); await api.Mission.upload( 'Operation Alpha', 'creator-uid-12345', fileStream, { token: missionToken } ); ``` ```typescript const archiveStream = await api.Mission.getArchive('Operation Alpha', { token: missionToken }); const writeStream = fs.createWriteStream('./mission-backup.zip'); archiveStream.pipe(writeStream); ``` -------------------------------- ### Output Raw JSON with CLI Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Use the `--format json` argument with the TAK CLI to output raw JSON data where possible. This is useful for programmatic consumption. ```bash --format json ``` -------------------------------- ### Manage Files with TAK API Source: https://context7.com/dfpc-coe/node-tak/llms.txt Upload, download, list, and manage files on the TAK Server. Ensure the API client is initialized with valid credentials. ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; import fs from 'node:fs'; import crypto from 'node:crypto'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // List all files const files = await api.Files.list(); for (const file of files.data) { console.log({ filename: file.filename, name: file.name, hash: file.hash, size: file.size, mimeType: file.mimeType, submitter: file.submitter, submissionTime: file.submissionTime }); } // Upload a file (private, for sharing between TAK clients) const fileBuffer = fs.readFileSync('./overlay.kml'); const content = await api.Files.upload({ name: 'overlay.kml', contentLength: fileBuffer.length, contentType: 'application/vnd.google-earth.kml+xml', keywords: ['overlay', 'map'], creatorUid: 'user-uid-12345' }, fileBuffer); console.log('Uploaded file hash:', content.Hash); // Upload a mission package (appears in public data packages list) const packageBuffer = fs.readFileSync('./mission-package.zip'); const hash = crypto.createHash('sha256').update(packageBuffer).digest('hex'); await api.Files.uploadPackage({ name: 'mission-package.zip', creatorUid: 'user-uid-12345', hash: hash, keywords: ['mission', 'data'], groups: ['__ANON__'] }, packageBuffer); // Download a file const downloadStream = await api.Files.download('abc123def456...'); const writeStream = fs.createWriteStream('./downloaded-file.zip'); downloadStream.pipe(writeStream); // Get file metadata const metadata = await api.Files.meta('abc123def456...'); console.log('File metadata:', metadata); // Update file keywords and expiration await api.Files.update('abc123def456...', { keywords: ['updated', 'keywords'], expiration: Date.now() + (30 * 24 * 60 * 60 * 1000) // 30 days }); // Delete a file await api.Files.delete('abc123def456...'); // Get file server config const config = await api.Files.config(); console.log('Max upload size:', config.uploadSizeLimit); ``` -------------------------------- ### Manage Video Streams with TAK API Source: https://context7.com/dfpc-coe/node-tak/llms.txt Configure and manage video stream connections for sharing live video feeds with TAK clients. Requires API initialization. ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // List all video connections const videos = await api.Video.list(); for (const connection of videos.videoConnections) { console.log({ uuid: connection.uuid, alias: connection.alias, active: connection.active, feeds: connection.feeds.map(f => ({ alias: f.alias, url: f.url, active: f.active })) }); } // Create a new video connection const newVideo = await api.Video.create({ alias: 'Drone Camera 1', active: true, groups: ['__ANON__'], feeds: [{ alias: 'Main Feed', url: 'rtsp://camera.example.com:554/stream1', active: true }, { alias: 'Thermal Feed', url: 'rtsp://camera.example.com:554/thermal', active: true }] }); console.log('Created video connection:', newVideo.uuid); // Get a specific video connection const video = await api.Video.get(newVideo.uuid); // Update video connection const updated = await api.Video.update({ uuid: newVideo.uuid, alias: 'Drone Camera 1 - Updated', active: true, feeds: video.feeds }); // Delete video connection await api.Video.delete(newVideo.uuid); ``` -------------------------------- ### List All Mission Subscriptions Source: https://context7.com/dfpc-coe/node-tak/llms.txt Fetches a list of all user devices currently subscribed to a given mission. ```typescript // List all subscriptions for a mission const subscriptions = await api.Mission.subscriptions('Operation Alpha'); console.log('Subscribers:', subscriptions.data); ``` -------------------------------- ### Stream CoT Data with CLI Source: https://github.com/dfpc-coe/node-tak/blob/main/README.md Use the TAK CLI to stream Cursor-on-Target (CoT) data. This command initiates the streaming process. ```bash tak stream ``` -------------------------------- ### Create Mission Source: https://context7.com/dfpc-coe/node-tak/llms.txt Creates a new mission on the TAK Server. Missions can be configured with access controls, keywords, and group assignments. ```APIDOC ## Mission API - Create Mission ### Description Creates a new mission (data sync) on the TAK Server. Missions can be configured with access controls, keywords, and group assignments. ### Method POST ### Endpoint `/api/missions` (Assumed based on typical REST patterns, actual endpoint may vary) ### Parameters #### Request Body - **name** (string) - Required - The name of the mission. - **creatorUid** (string) - Required - The unique identifier of the mission creator. - **description** (string) - Optional - A description for the mission. - **tool** (string) - Optional - The tool associated with the mission (e.g., 'public'). - **keywords** (array of strings) - Optional - Keywords associated with the mission. - **group** (array of strings) - Optional - Groups that can access this mission. - **inviteOnly** (boolean) - Optional - Whether the mission is invite-only. - **password** (string) - Optional - Password for protected missions. - **expiration** (number) - Optional - Mission expiration time (-1 for no expiration). - **allowDupe** (boolean) - Optional - Whether duplicate missions are allowed. ### Request Example ```json { "name": "Operation Alpha", "creatorUid": "user-uid-12345", "description": "Field operation coordination mission", "tool": "public", "keywords": ["operation", "field-team", "alpha"], "group": ["__ANON__"], "inviteOnly": false, "password": undefined, "expiration": -1, "allowDupe": false } ``` ### Response #### Success Response (200) - **name** (string) - The name of the created mission. - **guid** (string) - The unique identifier (GUID) of the mission. - **token** (string) - A token for future operations on this mission. #### Response Example ```json { "name": "Operation Alpha", "guid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "token": "mission-access-token-xyz" } ``` ``` -------------------------------- ### Create a New Mission Source: https://context7.com/dfpc-coe/node-tak/llms.txt Use this to create a new mission on the TAK Server. Configure access controls, keywords, and group assignments. Save the returned token for future operations. ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // Create a new mission const mission = await api.Mission.create({ name: 'Operation Alpha', creatorUid: 'user-uid-12345', description: 'Field operation coordination mission', tool: 'public', keywords: ['operation', 'field-team', 'alpha'], group: ['__ANON__'], // Groups that can access this mission inviteOnly: false, password: undefined, // Optional password protection expiration: -1, // -1 for no expiration allowDupe: false }); console.log('Mission created:', { name: mission.name, guid: mission.guid, token: mission.token // Save this token for future operations }); ``` -------------------------------- ### Package API Source: https://context7.com/dfpc-coe/node-tak/llms.txt APIs for managing data packages on the TAK Server. ```APIDOC ## Package API ### Description Manages data packages on the TAK Server. Data packages are ZIP archives containing CoT data, map overlays, and other resources. ### Method GET ### Endpoint `/package` ### Parameters #### Query Parameters - **name** (string) - Optional - Filter packages by name. - **tool** (string) - Optional - Filter packages by tool. ### Response #### Success Response (200) - **resultCount** (integer) - The total number of packages found. - **results** (array[object]) - An array of package objects. - **Name** (string) - The name of the package. - **Hash** (string) - The hash of the package. - **UID** (string) - The UID of the package. - **Size** (integer) - The size of the package in bytes. - **MIMEType** (string) - The MIME type of the package. - **SubmissionDateTime** (string) - The date and time the package was submitted. - **SubmissionUser** (string) - The user who submitted the package. - **Keywords** (array[string]) - Keywords associated with the package. - **EXPIRATION** (string) - The expiration date of the package. ``` -------------------------------- ### Authenticate TAK with Custom P12 Certificate Source: https://context7.com/dfpc-coe/node-tak/llms.txt Authenticate with the TAK server using a custom P12 certificate file by specifying the path with the '--auth' flag. Ensure the certificate file is accessible. ```bash tak --auth ./mycert.p12 mission list ``` -------------------------------- ### Credentials API Source: https://context7.com/dfpc-coe/node-tak/llms.txt Generates new client certificates using password authentication. ```APIDOC ## Credentials API ### Description Generates new client certificates using password authentication. This API is used to obtain credentials for clients that authenticate via username and password. ### Method POST ### Endpoint /api/credentials ### Parameters None ### Request Body None ### Request Example ```bash POST /api/credentials ``` ### Response #### Success Response (200) - **cert** (string) - The client certificate in PEM format. - **key** (string) - The private key for the client certificate in PEM format. - **ca** (array of strings) - An array containing the Certificate Authority (CA) chain in PEM format. #### Response Example ```json { "cert": "-----BEGIN CERTIFICATE-----\nMIIC...\n-----END CERTIFICATE-----", "key": "-----BEGIN PRIVATE KEY-----\nMIIE...\n-----END PRIVATE KEY-----", "ca": [ "-----BEGIN CERTIFICATE-----\nMIIC...\n-----END CERTIFICATE-----" ] } ``` ``` -------------------------------- ### Video API Source: https://context7.com/dfpc-coe/node-tak/llms.txt APIs for managing video stream configurations for sharing live video feeds with TAK clients. ```APIDOC ## Video API Manages video stream configurations for sharing live video feeds with TAK clients. ### List all video connections - **Method**: GET - **Endpoint**: `/api/video` - **Description**: Retrieves a list of all configured video connections. - **Response Example**: ```json { "videoConnections": [ { "uuid": "some-uuid-123", "alias": "Drone Camera 1", "active": true, "feeds": [ { "alias": "Main Feed", "url": "rtsp://camera.example.com:554/stream1", "active": true } ] } ] } ``` ### Create a new video connection - **Method**: POST - **Endpoint**: `/api/video` - **Description**: Creates a new video connection configuration. - **Request Body**: - **alias** (string) - Required - An alias for the video connection. - **active** (boolean) - Required - Whether the connection is active. - **groups** (array of strings) - Optional - Groups to which this video feed is accessible. - **feeds** (array of objects) - Required - A list of video feeds for this connection. - **alias** (string) - Required - Alias for the individual feed. - **url** (string) - Required - The RTSP or other stream URL. - **active** (boolean) - Required - Whether this specific feed is active. - **Request Example**: ```json { "alias": "Drone Camera 1", "active": true, "groups": ["__ANON__"], "feeds": [ { "alias": "Main Feed", "url": "rtsp://camera.example.com:554/stream1", "active": true } ] } ``` - **Response Example**: ```json { "uuid": "new-video-uuid-456" } ``` ### Get a specific video connection - **Method**: GET - **Endpoint**: `/api/video/{uuid}` - **Description**: Retrieves details for a specific video connection. - **Path Parameters**: - **uuid** (string) - Required - The UUID of the video connection. - **Response Example**: ```json { "uuid": "some-uuid-123", "alias": "Drone Camera 1", "active": true, "feeds": [ { "alias": "Main Feed", "url": "rtsp://camera.example.com:554/stream1", "active": true } ] } ``` ### Update video connection - **Method**: PUT - **Endpoint**: `/api/video/{uuid}` - **Description**: Updates an existing video connection configuration. - **Path Parameters**: - **uuid** (string) - Required - The UUID of the video connection to update. - **Request Body**: - **alias** (string) - Optional - The new alias for the video connection. - **active** (boolean) - Optional - The new active status. - **feeds** (array of objects) - Optional - The updated list of video feeds. - **Request Example**: ```json { "alias": "Drone Camera 1 - Updated", "active": true, "feeds": [ { "alias": "Main Feed", "url": "rtsp://camera.example.com:554/stream1", "active": true } ] } ``` ### Delete video connection - **Method**: DELETE - **Endpoint**: `/api/video/{uuid}` - **Description**: Deletes a video connection. - **Path Parameters**: - **uuid** (string) - Required - The UUID of the video connection to delete. ``` -------------------------------- ### List and Filter Data Packages Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieve a list of all data packages on the TAK Server or filter them by name or tool. The results include details like name, hash, size, and submission information. ```typescript const packages = await api.Package.list({}); console.log(`Found ${packages.resultCount} packages`); for (const pkg of packages.results) { console.log({ name: pkg.Name, hash: pkg.Hash, uid: pkg.UID, size: pkg.Size, mimeType: pkg.MIMEType, submissionDateTime: pkg.SubmissionDateTime, submissionUser: pkg.SubmissionUser, keywords: pkg.Keywords, expiration: pkg.EXPIRATION }); } ``` ```typescript const filteredPackages = await api.Package.list({ name: 'mission-data' }); ``` ```typescript const toolPackages = await api.Package.list({ tool: 'public' }); ``` -------------------------------- ### Subscribe to a Mission Source: https://context7.com/dfpc-coe/node-tak/llms.txt Subscribes a user device to a mission, allowing it to receive updates. Specify the user's UID and optionally a password if the mission is protected. 'secago' defines the time window for fetching changes. ```typescript import { TAKAPI, APIAuthCertificate, MissionSubscriberRole } from '@tak-ps/node-tak'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // Subscribe to a mission const subscription = await api.Mission.subscribe('Operation Alpha', { uid: 'user-device-uid-12345', password: undefined, // If mission is password protected secago: 86400 // Get changes from last 24 hours }); console.log('Subscribed:', subscription); ``` -------------------------------- ### TAKAPI Initialization Source: https://context7.com/dfpc-coe/node-tak/llms.txt Initializes the TAK API client for REST operations. Supports certificate-based, password-based, or JWT token authentication methods. ```APIDOC ## TAKAPI Initialization Initializes the TAK API client for REST operations. Supports certificate-based, password-based, or JWT token authentication methods. ### Method `init` (static method of TAKAPI class) ### Parameters - **url** (URL) - Required - The base URL of the TAK Server's REST API (e.g., `https://tak-server.example.com:8443`). - **auth** (object) - Required - An instance of an authentication class. - **APIAuthCertificate** - For certificate-based authentication. - **cert** (string) - Required - The client certificate. - **key** (string) - Required - The client private key. - **APIAuthPassword** - For password-based authentication (generates JWT automatically). - **username** (string) - Required - The username. - **password** (string) - Required - The password. - **APIAuthToken** - For JWT token authentication. - **token** (string) - Required - The JWT token. ### Response - **TAKAPI instance** - An initialized TAKAPI client object with access to various modules (Mission, Package, Files, etc.). ### Request Example (Certificate Authentication) ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; const apiWithCert = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate( '-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----', '-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----' ) ); ``` ### Request Example (Password Authentication) ```typescript import { TAKAPI, APIAuthPassword } from '@tak-ps/node-tak'; const apiWithPassword = await TAKAPI.init( new URL('https://tak-server.example.com:443'), new APIAuthPassword('username', 'password') ); ``` ### Request Example (Token Authentication) ```typescript import { TAKAPI, APIAuthToken } from '@tak-ps/node-tak'; const apiWithToken = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...') ); ``` ``` -------------------------------- ### Files API Source: https://context7.com/dfpc-coe/node-tak/llms.txt APIs for uploading, downloading, and managing files on the TAK Server file manager. ```APIDOC ## Files API Uploads, downloads, and manages files on the TAK Server file manager. ### List all files - **Method**: GET - **Endpoint**: `/api/files` - **Description**: Retrieves a list of all files managed by the TAK Server. - **Response Example**: ```json { "data": [ { "filename": "overlay.kml", "name": "overlay.kml", "hash": "abc123def456...", "size": 1024, "mimeType": "application/vnd.google-earth.kml+xml", "submitter": "user-uid-12345", "submissionTime": "2023-10-27T10:00:00Z" } ] } ``` ### Upload a file - **Method**: POST - **Endpoint**: `/api/files/upload` - **Description**: Uploads a file to the TAK Server file manager. This is typically for private files shared between TAK clients. - **Request Body**: - **name** (string) - Required - The desired name for the file. - **contentLength** (integer) - Required - The size of the file in bytes. - **contentType** (string) - Required - The MIME type of the file. - **keywords** (array of strings) - Optional - Keywords associated with the file. - **creatorUid** (string) - Optional - The unique identifier of the user who created the file. - **Request Example**: ```json { "name": "overlay.kml", "contentLength": 1024, "contentType": "application/vnd.google-earth.kml+xml", "keywords": ["overlay", "map"], "creatorUid": "user-uid-12345" } ``` - **Response Example**: ```json { "Hash": "new_file_hash_123" } ``` ### Upload a mission package - **Method**: POST - **Endpoint**: `/api/files/uploadPackage` - **Description**: Uploads a mission package (e.g., a zip file) which will appear in the public data packages list. - **Request Body**: - **name** (string) - Required - The name of the package file. - **creatorUid** (string) - Optional - The unique identifier of the user who created the package. - **hash** (string) - Required - The SHA256 hash of the package content. - **keywords** (array of strings) - Optional - Keywords associated with the package. - **groups** (array of strings) - Optional - Groups to which the package will be accessible (e.g., `["__ANON__"]`). - **Request Example**: ```json { "name": "mission-package.zip", "creatorUid": "user-uid-12345", "hash": "package_sha256_hash", "keywords": ["mission", "data"], "groups": ["__ANON__"] } ``` ### Download a file - **Method**: GET - **Endpoint**: `/api/files/download/{fileHash}` - **Description**: Downloads a file from the TAK Server using its hash. - **Path Parameters**: - **fileHash** (string) - Required - The hash of the file to download. - **Response Example**: (Returns a stream of the file content) ### Get file metadata - **Method**: GET - **Endpoint**: `/api/files/meta/{fileHash}` - **Description**: Retrieves metadata for a specific file. - **Path Parameters**: - **fileHash** (string) - Required - The hash of the file. - **Response Example**: ```json { "filename": "overlay.kml", "name": "overlay.kml", "hash": "abc123def456...", "size": 1024, "mimeType": "application/vnd.google-earth.kml+xml", "submitter": "user-uid-12345", "submissionTime": "2023-10-27T10:00:00Z", "keywords": ["overlay", "map"], "expiration": 1700000000000 } ``` ### Update file metadata - **Method**: PUT - **Endpoint**: `/api/files/update/{fileHash}` - **Description**: Updates keywords and expiration time for a specific file. - **Path Parameters**: - **fileHash** (string) - Required - The hash of the file to update. - **Request Body**: - **keywords** (array of strings) - Optional - New keywords for the file. - **expiration** (integer) - Optional - New expiration timestamp (milliseconds since epoch). - **Request Example**: ```json { "keywords": ["updated", "keywords"], "expiration": 1700000000000 } ``` ### Delete a file - **Method**: DELETE - **Endpoint**: `/api/files/delete/{fileHash}` - **Description**: Deletes a file from the TAK Server. - **Path Parameters**: - **fileHash** (string) - Required - The hash of the file to delete. ### Get file server configuration - **Method**: GET - **Endpoint**: `/api/files/config` - **Description**: Retrieves the configuration settings for the file server, such as upload limits. - **Response Example**: ```json { "uploadSizeLimit": 104857600, "maxConcurrentUploads": 10 } ``` ``` -------------------------------- ### Establish Streaming CoT Connection Source: https://context7.com/dfpc-coe/node-tak/llms.txt Establishes a secure TLS connection to a TAK Server for real-time bidirectional CoT message streaming. Handles incoming CoT messages, pings, errors, and connection state changes. Use this for real-time data exchange. ```typescript import TAK from '@tak-ps/node-tak'; import type { CoT } from '@tak-ps/node-cot'; // Establish streaming connection with certificate authentication const tak = await TAK.connect( new URL('ssl://tak-server.example.com:8089'), { cert: '-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----', key: '-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----', rejectUnauthorized: false }, { id: 'my-connection-1', type: 'sensor-feed', writeQueueSize: 10000, // Buffer size for outgoing messages socketBatchSize: 64 // Messages per socket write } ); // Handle incoming CoT messages tak.on('cot', (cot: CoT) => { console.log('Received CoT:', cot.raw.event._attributes.uid); console.log('Type:', cot.raw.event._attributes.type); console.log('Position:', cot.raw.event.point._attributes); }); tak.on('ping', () => console.log('Server ping received')); tak.on('secureConnect', () => console.log('TLS connection established')); tak.on('end', () => console.log('Connection ended')); tak.on('error', (err) => console.error('Connection error:', err)); tak.on('close', () => { console.log('Connection closed, attempting reconnect...'); tak.reconnect(); }); // Send CoT messages import { CoT } from '@tak-ps/node-cot'; const pingMessage = CoT.ping(); await tak.write([pingMessage]); // Wait for all queued messages to be sent await tak.flush(); // Cleanup tak.destroy(); ``` -------------------------------- ### List TAK Client Contacts Source: https://context7.com/dfpc-coe/node-tak/llms.txt Retrieves a list of currently connected TAK clients. Requires initialization with server URL and authentication credentials. ```typescript import { TAKAPI, APIAuthCertificate } from '@tak-ps/node-tak'; const api = await TAKAPI.init( new URL('https://tak-server.example.com:8443'), new APIAuthCertificate(cert, key) ); // List all contacts const contacts = await api.Contacts.list(); for (const contact of contacts) { console.log({ uid: contact.uid, callsign: contact.callsign, team: contact.team, role: contact.role, takv: contact.takv, notes: contact.notes }); } ``` -------------------------------- ### Set Mission Keywords Source: https://context7.com/dfpc-coe/node-tak/llms.txt Directly sets the keywords for a mission. This replaces any existing keywords. Requires the mission token. ```typescript // Set keywords directly await api.Mission.setKeywords('Operation Alpha', ['keyword1', 'keyword2'], { token: mission.token }); ``` -------------------------------- ### OAuth API Source: https://context7.com/dfpc-coe/node-tak/llms.txt Handles OAuth password authentication and JWT token management. ```APIDOC ## OAuth API ### Description Handles OAuth password authentication and JWT token management. This API allows clients to log in using username and password to obtain JWT tokens for subsequent authenticated requests. ### Method POST ### Endpoint /api/oauth/token ### Parameters #### Request Body - **username** (string) - Required. The username for authentication. - **password** (string) - Required. The password for authentication. ### Request Example ```json POST /api/oauth/token { "username": "myuser", "password": "mypassword" } ``` ### Response #### Success Response (200) - **token** (string) - The JWT token issued upon successful authentication. - **contents** (object) - An object containing the decoded claims of the JWT. - **sub** (string) - The subject of the token (usually the user ID). - **aud** (string) - The audience of the token. - **iat** (integer) - The time the token was issued (Unix timestamp). - **exp** (integer) - The expiration time of the token (Unix timestamp). - **nbf** (integer) - The time before which the token is not valid (Unix timestamp). #### Response Example ```json { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "contents": { "sub": "user-123", "aud": "tak-server", "iat": 1678886400, "exp": 1678890000, "nbf": 1678886300 } } ``` ### Parsing JWT #### Description Parses an existing JWT token to extract its claims without needing to authenticate. #### Method N/A (Client-side operation) #### Parameters - **token** (string) - The JWT token to parse. #### Request Example ```typescript const parsedToken = api.OAuth.parse(existingToken); ``` #### Response - **parsedToken** (object) - An object containing the decoded claims of the JWT (same structure as `contents` in login response). ``` -------------------------------- ### Attach and Detach Mission Content Source: https://context7.com/dfpc-coe/node-tak/llms.txt Use these methods to manage files associated with a mission. Ensure files are already uploaded to the TAK Server before attaching. ```typescript await api.Mission.attachContents('Operation Alpha', { hashes: ['abc123def456...'], uids: ['content-uid-1'] }, { token: missionToken }); ``` ```typescript await api.Mission.detachContents('Operation Alpha', { hash: 'abc123def456...' }, { token: missionToken }); ```