UNPKG

node-firewalla

Version:

Package to talk your firewalla box & API

50 lines (49 loc) 1.66 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FWMessage = void 0; const crypto_1 = __importDefault(require("crypto")); class FWMessage { /** * @param {string} type - message type (cmd, init, set, get) * @param {object} data - the payload of the message * @param {string} target - the host that needs to receive the message */ constructor(type, data, target = "0.0.0.0") { this.type = type; this.data = data; this.target = target; this.uuid = crypto_1.default.randomUUID(); } toJSON(eid) { return { mtype: "msg", message: { mtype: "msg", type: "jsondata", msg: "", from: "NodeJS", obj: { type: "jsonmsg", id: this.uuid, mtype: this.type, target: this.target, data: this.data }, appInfo: { deviceName: "NodeJS", appID: "com.rottiesoft.circle", platform: process.platform, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, language: "en", version: "1.51.84", eid }, compressMode: 1 } }; } } exports.FWMessage = FWMessage;