Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

duml-packet

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duml-packet - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

11

dist/cli.js

@@ -1,9 +0,4 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const yargs_1 = __importDefault(require("yargs"));
const helpers_1 = require("yargs/helpers");
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
yargs(hideBin(process.argv))
// Use the commands directory to scaffold.

@@ -10,0 +5,0 @@ .commandDir('cmds')

@@ -1,4 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const packet_1 = require("../packet");
import { Packet } from '../packet.js';
exports.command = 'pretty-print <buffer>';

@@ -8,4 +6,4 @@ exports.desc = 'Print a DUML packet buffer in long form';

exports.handler = function (argv) {
console.log(packet_1.Packet.fromBuffer(Buffer.from(argv.buffer, 'hex')).toLongString());
console.log(Packet.fromBuffer(Buffer.from(argv.buffer, 'hex')).toLongString());
};
//# sourceMappingURL=pretty-print.js.map

@@ -1,4 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const packet_1 = require("../packet");
import { Packet } from '../packet.js';
exports.command = 'print <buffer>';

@@ -8,4 +6,4 @@ exports.desc = 'Print a DUML packet buffer in short form';

exports.handler = function (argv) {
console.log(packet_1.Packet.fromBuffer(Buffer.from(argv.buffer, 'hex')).toShortString());
console.log(Packet.fromBuffer(Buffer.from(argv.buffer, 'hex')).toShortString());
};
//# sourceMappingURL=print.js.map

@@ -1,7 +0,4 @@

"use strict";
// Based off
// https://github.com/alexgorbatchev/node-crc
// Specific this is MIT licensing due to where it was borrowed from
Object.defineProperty(exports, "__esModule", { value: true });
exports.crc16KermitJam = exports.crc8Wire = void 0;
// Generated by `./pycrc.py --algorithm=table-driven --model=dallas-1-wire --generate=c`

@@ -26,3 +23,3 @@ const crc8WireTable = new Int8Array([

]);
const crc8Wire = (buffer) => {
export const crc8Wire = (buffer) => {
let crc = 0x77;

@@ -34,3 +31,2 @@ for (let index = 0; index < buffer.length; index++) {

};
exports.crc8Wire = crc8Wire;
// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c`

@@ -61,3 +57,3 @@ const crc16KermitTable = new Int16Array([

]);
const crc16KermitJam = (buffer) => {
export const crc16KermitJam = (buffer) => {
// Specific previous count for DUML

@@ -70,3 +66,2 @@ let crc = 0x3692;

};
exports.crc16KermitJam = crc16KermitJam;
//# sourceMappingURL=crc.js.map
/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from 'events';
import { PacketOptions, GeneralTypes, DeviceType, CommandType, AckType, EncryptionType, SetType } from './types';
import { PacketOptions, GeneralTypes, DeviceType, CommandType, AckType, EncryptionType, SetType } from './types.js';
export interface DumlPacket {

@@ -6,0 +6,0 @@ raw: Buffer;

@@ -1,13 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetType = exports.EncryptionType = exports.AckType = exports.CommandType = exports.DeviceType = exports.GeneralTypes = exports.Packet = void 0;
const crc_1 = require("./crc");
const types_1 = require("./types");
Object.defineProperty(exports, "GeneralTypes", { enumerable: true, get: function () { return types_1.GeneralTypes; } });
Object.defineProperty(exports, "DeviceType", { enumerable: true, get: function () { return types_1.DeviceType; } });
Object.defineProperty(exports, "CommandType", { enumerable: true, get: function () { return types_1.CommandType; } });
Object.defineProperty(exports, "AckType", { enumerable: true, get: function () { return types_1.AckType; } });
Object.defineProperty(exports, "EncryptionType", { enumerable: true, get: function () { return types_1.EncryptionType; } });
Object.defineProperty(exports, "SetType", { enumerable: true, get: function () { return types_1.SetType; } });
class Packet {
import { crc8Wire, crc16KermitJam } from './crc.js';
import { GeneralTypes, DeviceType, CommandType, AckType, EncryptionType, SetType, } from './types.js';
export class Packet {
/**

@@ -34,4 +25,4 @@ *

else {
this.sourceType = packet.sourceType ? packet.sourceType : types_1.DeviceType.ANY;
this.sourceIndex = packet.sourceIndex ? packet.sourceIndex : types_1.DeviceType.ANY;
this.sourceType = packet.sourceType ? packet.sourceType : DeviceType.ANY;
this.sourceIndex = packet.sourceIndex ? packet.sourceIndex : DeviceType.ANY;
this.sourceRaw = this.sourceType | (this.sourceIndex << 0x5);

@@ -45,4 +36,4 @@ }

else {
this.destinationType = packet.destinationType ? packet.destinationType : types_1.DeviceType.ANY;
this.destinationIndex = packet.destinationIndex ? packet.destinationIndex : types_1.DeviceType.ANY;
this.destinationType = packet.destinationType ? packet.destinationType : DeviceType.ANY;
this.destinationIndex = packet.destinationIndex ? packet.destinationIndex : DeviceType.ANY;
this.destinationRaw = this.destinationType | (this.destinationIndex << 0x5);

@@ -63,8 +54,8 @@ }

else {
this.commandType = packet.commandType ? packet.commandType : types_1.CommandType.REQUEST;
this.ackType = packet.ackType ? packet.ackType : types_1.AckType.NO_ACK;
this.encryptionType = packet.encryptionType ? packet.encryptionType : types_1.EncryptionType.NONE;
this.commandType = packet.commandType ? packet.commandType : CommandType.REQUEST;
this.ackType = packet.ackType ? packet.ackType : AckType.NO_ACK;
this.encryptionType = packet.encryptionType ? packet.encryptionType : EncryptionType.NONE;
this.commandTypeRaw = (this.commandType << 7) | (this.ackType << 5) | this.encryptionType;
}
this.commandSet = packet.commandSet ? packet.commandSet : types_1.SetType.GENERAL;
this.commandSet = packet.commandSet ? packet.commandSet : SetType.GENERAL;
// Command payload done first for length

@@ -176,3 +167,3 @@ this.command = packet.command ? packet.command : 0x00;

if (generate) {
this.crcHead = (0, crc_1.crc8Wire)(buffer.subarray(0, 3));
this.crcHead = crc8Wire(buffer.subarray(0, 3));
}

@@ -195,3 +186,3 @@ buffer.writeUInt8(this.crcHead, 3);

if (generate) {
this.crc = (0, crc_1.crc16KermitJam)(buffer.subarray(0, buffer.length - 2));
this.crc = crc16KermitJam(buffer.subarray(0, buffer.length - 2));
}

@@ -205,4 +196,4 @@ buffer.writeUInt16LE(this.crc, buffer.length - 2);

isValid() {
return (this.crcHead === (0, crc_1.crc8Wire)(this.raw.subarray(0, 3)) &&
this.crc === (0, crc_1.crc16KermitJam)(this.raw.subarray(0, this.raw.length - 2)));
return (this.crcHead === crc8Wire(this.raw.subarray(0, 3)) &&
this.crc === crc16KermitJam(this.raw.subarray(0, this.raw.length - 2)));
}

@@ -214,4 +205,4 @@ /**

let commandSubType = 'UNKNOWN';
if (this.commandSet === types_1.SetType.GENERAL && types_1.GeneralTypes[this.command]) {
commandSubType = types_1.GeneralTypes[this.command];
if (this.commandSet === SetType.GENERAL && GeneralTypes[this.command]) {
commandSubType = GeneralTypes[this.command];
}

@@ -231,4 +222,4 @@ return (`Source (0x${this.sourceRaw.toString(16)}), ` +

let commandSubType = 'UNKNOWN';
if (this.commandSet === types_1.SetType.GENERAL && types_1.GeneralTypes[this.command]) {
commandSubType = types_1.GeneralTypes[this.command];
if (this.commandSet === SetType.GENERAL && GeneralTypes[this.command]) {
commandSubType = GeneralTypes[this.command];
}

@@ -240,10 +231,10 @@ return (`Packet HEX(${this.toHexString()})\n` +

`CRC Head:\t0x${this.crcHead.toString(16)}\n` +
`Source ID:\t${types_1.DeviceType[this.sourceType]}, 0x${this.sourceIndex.toString(16)} (0x${this.sourceRaw.toString(16)})\n` +
`Dest ID:\t${types_1.DeviceType[this.destinationType]}, 0x${this.destinationIndex.toString(16)} (0x${this.destinationRaw.toString(16)})\n` +
`Source ID:\t${DeviceType[this.sourceType]}, 0x${this.sourceIndex.toString(16)} (0x${this.sourceRaw.toString(16)})\n` +
`Dest ID:\t${DeviceType[this.destinationType]}, 0x${this.destinationIndex.toString(16)} (0x${this.destinationRaw.toString(16)})\n` +
`Sequence ID:\t0x${this.sequenceID.toString(16)}\n` +
`Cmd Type (raw):\t0x${this.commandTypeRaw.toString(16)}\n` +
`Cmd Type:\t${types_1.CommandType[this.commandType]}\t(0x${this.commandType.toString(16)})\n` +
`Ack Type:\t${types_1.AckType[this.ackType]}\t(0x${this.ackType.toString(16)})\n` +
`Encryption:\t${types_1.EncryptionType[this.encryptionType]}\t(0x${this.encryptionType.toString(16)})\n` +
`Cmd Set:\t${types_1.SetType[this.commandSet]}\t(0x${this.commandSet.toString(16)})\n` +
`Cmd Type:\t${CommandType[this.commandType]}\t(0x${this.commandType.toString(16)})\n` +
`Ack Type:\t${AckType[this.ackType]}\t(0x${this.ackType.toString(16)})\n` +
`Encryption:\t${EncryptionType[this.encryptionType]}\t(0x${this.encryptionType.toString(16)})\n` +
`Cmd Set:\t${SetType[this.commandSet]}\t(0x${this.commandSet.toString(16)})\n` +
`Cmd SubType:\t${commandSubType} (0x${this.command.toString(16)})\n` +

@@ -286,12 +277,3 @@ `Cmd Payload:\t${this.commandPayload ? `(0x${this.commandPayload.toString('hex')})` : 'NULL'}\n` +

}
exports.Packet = Packet;
module.exports = {
Packet,
GeneralTypes: types_1.GeneralTypes,
DeviceType: types_1.DeviceType,
CommandType: types_1.CommandType,
AckType: types_1.AckType,
EncryptionType: types_1.EncryptionType,
SetType: types_1.SetType,
};
export { GeneralTypes, DeviceType, CommandType, AckType, EncryptionType, SetType };
//# sourceMappingURL=packet.js.map

@@ -212,3 +212,3 @@ /// <reference types="node" />

}
import { DumlPacket } from './packet';
import { DumlPacket } from './packet.js';
export type Packet = DumlPacket;

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RadioTypes = exports.CenterBoardTypes = exports.GimbalTypes = exports.FlightControllerTypes = exports.CameraTypes = exports.SpecialTypes = exports.GeneralTypes = exports.SetType = exports.EncryptionType = exports.AckType = exports.CommandType = exports.DeviceType = void 0;
var DeviceType;
export var DeviceType;
(function (DeviceType) {

@@ -38,9 +35,9 @@ DeviceType[DeviceType["ANY"] = 0] = "ANY";

DeviceType[DeviceType["WM330_OR_WM220"] = 31] = "WM330_OR_WM220";
})(DeviceType || (exports.DeviceType = DeviceType = {}));
var CommandType;
})(DeviceType || (DeviceType = {}));
export var CommandType;
(function (CommandType) {
CommandType[CommandType["REQUEST"] = 0] = "REQUEST";
CommandType[CommandType["ACK"] = 1] = "ACK";
})(CommandType || (exports.CommandType = CommandType = {}));
var AckType;
})(CommandType || (CommandType = {}));
export var AckType;
(function (AckType) {

@@ -51,4 +48,4 @@ AckType[AckType["NO_ACK"] = 0] = "NO_ACK";

AckType[AckType["RESPONSE"] = 3] = "RESPONSE";
})(AckType || (exports.AckType = AckType = {}));
var EncryptionType;
})(AckType || (AckType = {}));
export var EncryptionType;
(function (EncryptionType) {

@@ -63,4 +60,4 @@ EncryptionType[EncryptionType["NONE"] = 0] = "NONE";

EncryptionType[EncryptionType["AES_256"] = 7] = "AES_256";
})(EncryptionType || (exports.EncryptionType = EncryptionType = {}));
var SetType;
})(EncryptionType || (EncryptionType = {}));
export var SetType;
(function (SetType) {

@@ -99,6 +96,6 @@ SetType[SetType["GENERAL"] = 0] = "GENERAL";

SetType[SetType["UNKNOWN_31"] = 31] = "UNKNOWN_31";
})(SetType || (exports.SetType = SetType = {}));
})(SetType || (SetType = {}));
// Many of these inferred from binaries and others taken from
// https://github.com/o-gs/dji-firmware-tools/blob/05e24cb12803943f63ac5ae1574e517e59a2dd0a/comm_dissector/wireshark/dji-dumlv1-general.lua#L9
var GeneralTypes;
export var GeneralTypes;
(function (GeneralTypes) {

@@ -180,4 +177,4 @@ GeneralTypes[GeneralTypes["PING"] = 0] = "PING";

GeneralTypes[GeneralTypes["QUERY_DEVICE_INFO"] = 255] = "QUERY_DEVICE_INFO";
})(GeneralTypes || (exports.GeneralTypes = GeneralTypes = {}));
var SpecialTypes;
})(GeneralTypes || (GeneralTypes = {}));
export var SpecialTypes;
(function (SpecialTypes) {

@@ -196,35 +193,21 @@ SpecialTypes[SpecialTypes["SDK_CONTROL_NAV_MODE_TOGGLE"] = 0] = "SDK_CONTROL_NAV_MODE_TOGGLE";

SpecialTypes[SpecialTypes["UAV_LOOPBACK"] = 255] = "UAV_LOOPBACK";
})(SpecialTypes || (exports.SpecialTypes = SpecialTypes = {}));
})(SpecialTypes || (SpecialTypes = {}));
// TODO : Add support for these
var CameraTypes;
export var CameraTypes;
(function (CameraTypes) {
})(CameraTypes || (exports.CameraTypes = CameraTypes = {}));
})(CameraTypes || (CameraTypes = {}));
// https://github.com/o-gs/dji-firmware-tools/blob/05e24cb12803943f63ac5ae1574e517e59a2dd0a/comm_dissector/wireshark/dji-dumlv1-camera.lua#L9
// https://github.com/o-gs/dji-firmware-tools/blob/1a4c177ece5ea1023017db272e0dcace3838c639/comm_dissector/wireshark/dji-dumlv1-flyc.lua#L9
var FlightControllerTypes;
export var FlightControllerTypes;
(function (FlightControllerTypes) {
})(FlightControllerTypes || (exports.FlightControllerTypes = FlightControllerTypes = {}));
var GimbalTypes;
})(FlightControllerTypes || (FlightControllerTypes = {}));
export var GimbalTypes;
(function (GimbalTypes) {
})(GimbalTypes || (exports.GimbalTypes = GimbalTypes = {}));
var CenterBoardTypes;
})(GimbalTypes || (GimbalTypes = {}));
export var CenterBoardTypes;
(function (CenterBoardTypes) {
})(CenterBoardTypes || (exports.CenterBoardTypes = CenterBoardTypes = {}));
var RadioTypes;
})(CenterBoardTypes || (CenterBoardTypes = {}));
export var RadioTypes;
(function (RadioTypes) {
})(RadioTypes || (exports.RadioTypes = RadioTypes = {}));
module.exports = {
DeviceType,
CommandType,
AckType,
EncryptionType,
SetType,
GeneralTypes,
SpecialTypes,
CameraTypes,
FlightControllerTypes,
GimbalTypes,
CenterBoardTypes,
RadioTypes,
};
})(RadioTypes || (RadioTypes = {}));
//# sourceMappingURL=types.js.map
{
"name": "duml-packet",
"version": "1.0.7",
"version": "1.0.8",
"description": "For use when parsing and modifying DUML packets for DJI drones",
"main": "dist/packet.js",
"exports": "./dist/packet.js",
"bin": {
"dumlpacket": "./dist/cli.js"
},
"type": "module",
"types": "./dist/types.d.ts",

@@ -18,4 +19,4 @@ "scripts": {

"test": "mocha",
"test:coverage": "nyc mocha",
"test:coverage:html": "nyc --reporter=html --reporter=text mocha",
"test:coverage": "c8 mocha",
"test:coverage:html": "c8 --reporter=html --reporter=text mocha",
"package": "pkg . --output dumlpacket",

@@ -49,3 +50,4 @@ "prepublishOnly": "npm run prepare && npm run prepare:defs",

"arkit": "^1.6.4",
"chai": "^4.3.7",
"c8": "^9.1.0",
"chai": "^5.0.0",
"eslint": "^8.38.0",

@@ -55,3 +57,2 @@ "eslint-config-prettier": "^9.0.0",

"mocha": "^10.2.0",
"nyc": "^15.1.0",
"pkg": "^5.8.1",

@@ -58,0 +59,0 @@ "prettier": "^3.0.3",

@@ -1,2 +0,2 @@

import { Packet } from '../packet';
import { Packet } from '../packet.js';
import { Arguments } from 'yargs';

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

import { Packet } from '../packet';
import { Packet } from '../packet.js';
import { Arguments } from 'yargs';

@@ -3,0 +3,0 @@

import { EventEmitter } from 'events';
import { crc8Wire, crc16KermitJam } from './crc';
import { crc8Wire, crc16KermitJam } from './crc.js';

@@ -12,3 +12,3 @@ import {

SetType,
} from './types';
} from './types.js';

@@ -412,13 +412,2 @@ export interface DumlPacket {

module.exports = {
Packet,
GeneralTypes,
DeviceType,
CommandType,
AckType,
EncryptionType,
SetType,
};
export { GeneralTypes, DeviceType, CommandType, AckType, EncryptionType, SetType };

@@ -247,20 +247,4 @@ export interface PacketOptions {

import { DumlPacket } from './packet';
import { DumlPacket } from './packet.js';
export type Packet = DumlPacket;
module.exports = {
DeviceType,
CommandType,
AckType,
EncryptionType,
SetType,
GeneralTypes,
SpecialTypes,
CameraTypes,
FlightControllerTypes,
GimbalTypes,
CenterBoardTypes,
RadioTypes,
};
{
"compilerOptions": {
"module": "commonjs",
"module": "ESNext",
"esModuleInterop": true,

@@ -5,0 +5,0 @@ "target": "es2021",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc