@netkitty/codec 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.2.0](https://github.com/myq1991/netkitty/compare/@netkitty/codec@1.1.0...@netkitty/codec@1.2.0) (2026-07-23)
7
+
8
+
9
+ ### Features
10
+
11
+ * **errors:** add @netkitty/errors — shared NetKittyError base + ErrorCode ([d5a3405](https://github.com/myq1991/netkitty/commit/d5a3405ee1f812ac92ed3d32478c1bece9bdbd89))
12
+ * **errors:** route pcap-core/pcap/analysis/replay/capture errors through NetKittyError ([19b0888](https://github.com/myq1991/netkitty/commit/19b08886f490afaeec3620745e545eb2446b4f83))
13
+
14
+
15
+
16
+
17
+
6
18
  # 1.1.0 (2026-07-22)
7
19
 
8
20
 
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
  <img src="https://raw.githubusercontent.com/myq1991/netkitty/main/assets/NetKittyLogo.webp" alt="NetKitty" width="180">
3
3
  </p>
4
4
 
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/@netkitty/codec"><img src="https://img.shields.io/npm/v/@netkitty/codec?style=flat-square&labelColor=162032&color=2979ff&logo=npm&logoColor=white" alt="npm version"></a>
7
+ <a href="https://www.npmjs.com/package/@netkitty/codec"><img src="https://img.shields.io/npm/dm/@netkitty/codec?style=flat-square&labelColor=162032&color=22c55e&logo=npm&logoColor=white" alt="npm downloads"></a>
8
+ <a href="https://github.com/myq1991/netkitty/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@netkitty/codec?style=flat-square&labelColor=162032&color=2979ff" alt="license"></a>
9
+ </p>
10
+
5
11
  # @netkitty/codec
6
12
 
7
13
  Schema-driven protocol codec for encoding and decoding packet headers — **189 protocols** across the
package/README.zh-CN.md CHANGED
@@ -2,6 +2,12 @@
2
2
  <img src="https://raw.githubusercontent.com/myq1991/netkitty/main/assets/NetKittyLogo.webp" alt="NetKitty" width="180">
3
3
  </p>
4
4
 
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/@netkitty/codec"><img src="https://img.shields.io/npm/v/@netkitty/codec?style=flat-square&labelColor=162032&color=2979ff&logo=npm&logoColor=white" alt="npm version"></a>
7
+ <a href="https://www.npmjs.com/package/@netkitty/codec"><img src="https://img.shields.io/npm/dm/@netkitty/codec?style=flat-square&labelColor=162032&color=22c55e&logo=npm&logoColor=white" alt="npm downloads"></a>
8
+ <a href="https://github.com/myq1991/netkitty/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@netkitty/codec?style=flat-square&labelColor=162032&color=2979ff" alt="license"></a>
9
+ </p>
10
+
5
11
  # @netkitty/codec
6
12
 
7
13
  schema 驱动的协议编解码器,负责把报文各层协议头在字节和结构之间来回转换——覆盖**189 种协议**,贯穿整个
@@ -1,4 +1,6 @@
1
- export declare class CodecSchemaValidateError extends Error implements NodeJS.ErrnoException {
1
+ import { NetKittyError } from '@netkitty/errors';
2
+ /** Thrown at the encode entry point when an input fails Ajv shape validation against the header schema. */
3
+ export declare class CodecSchemaValidateError extends NetKittyError {
2
4
  errno: number;
3
5
  code: string;
4
6
  }
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CodecSchemaValidateError = void 0;
4
- class CodecSchemaValidateError extends Error {
4
+ const errors_1 = require("@netkitty/errors");
5
+ /** Thrown at the encode entry point when an input fails Ajv shape validation against the header schema. */
6
+ class CodecSchemaValidateError extends errors_1.NetKittyError {
5
7
  constructor() {
6
8
  super(...arguments);
7
- this.errno = 2001;
8
- this.code = 'E_CODEC_SCHEMA_VALIDATE';
9
+ this.errno = errors_1.ErrorCode.E_CODEC_SCHEMA_VALIDATE.errno;
10
+ this.code = errors_1.ErrorCode.E_CODEC_SCHEMA_VALIDATE.code;
9
11
  }
10
12
  }
11
13
  exports.CodecSchemaValidateError = CodecSchemaValidateError;
package/dist/index.d.ts CHANGED
@@ -50,3 +50,7 @@ export { Int16ToBERBuffer, Int32ToBERBuffer, Int64ToBERBuffer, Int8ToBERBuffer,
50
50
  export { Int16ToBERHex, Int32ToBERHex, Int64ToBERHex, Int8ToBERHex, UInt16ToBERHex, UInt32ToBERHex, UInt64ToBERHex, UInt8ToBERHex } from './helper/NumberToBERHex';
51
51
  export { Float32ToBuffer, Int16ToBuffer, Int32ToBuffer, Int64ToBuffer, Int8ToBuffer, UInt16ToBuffer, UInt32ToBuffer, UInt64ToBuffer, UInt8ToBuffer } from './helper/NumberToBuffer';
52
52
  export { Float32ToHex, Int16ToHex, Int32ToHex, Int64ToHex, Int8ToHex, UInt16ToHex, UInt32ToHex, UInt64ToHex, UInt8ToHex } from './helper/NumberToHex';
53
+ /**
54
+ * Error classes (all extend NetKittyError)
55
+ */
56
+ export { CodecSchemaValidateError } from './errors/CodecSchemaValidateError';
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.UInt16ToBuffer = exports.Int8ToBuffer = exports.Int64ToBuffer = exports.Int32ToBuffer = exports.Int16ToBuffer = exports.Float32ToBuffer = exports.UInt8ToBERHex = exports.UInt64ToBERHex = exports.UInt32ToBERHex = exports.UInt16ToBERHex = exports.Int8ToBERHex = exports.Int64ToBERHex = exports.Int32ToBERHex = exports.Int16ToBERHex = exports.UInt8ToBERBuffer = exports.UInt64ToBERBuffer = exports.UInt32ToBERBuffer = exports.UInt16ToBERBuffer = exports.Int8ToBERBuffer = exports.Int64ToBERBuffer = exports.Int32ToBERBuffer = exports.Int16ToBERBuffer = exports.HexToUInt8 = exports.HexToUInt64 = exports.HexToUInt32 = exports.HexToUInt16 = exports.HexToInt8 = exports.HexToInt64 = exports.HexToInt32 = exports.HexToInt16 = exports.HexToFloat32 = exports.BufferToUInt8 = exports.BufferToUInt64 = exports.BufferToUInt32 = exports.BufferToUInt16 = exports.BufferToInt8 = exports.BufferToInt64 = exports.BufferToInt32 = exports.BufferToInt16 = exports.BufferToFloat32 = exports.IPv6ToBuffer = exports.IPv4ToBuffer = exports.BufferToIPv6 = exports.BufferToIPv4 = exports.HexToBuffer = exports.BufferToHex = exports.StringContentEncodingEnum = exports.FlexibleObject = exports.Codec = exports.BaseHeader = void 0;
18
- exports.UInt8ToHex = exports.UInt64ToHex = exports.UInt32ToHex = exports.UInt16ToHex = exports.Int8ToHex = exports.Int64ToHex = exports.Int32ToHex = exports.Int16ToHex = exports.Float32ToHex = exports.UInt8ToBuffer = exports.UInt64ToBuffer = exports.UInt32ToBuffer = void 0;
18
+ exports.CodecSchemaValidateError = exports.UInt8ToHex = exports.UInt64ToHex = exports.UInt32ToHex = exports.UInt16ToHex = exports.Int8ToHex = exports.Int64ToHex = exports.Int32ToHex = exports.Int16ToHex = exports.Float32ToHex = exports.UInt8ToBuffer = exports.UInt64ToBuffer = exports.UInt32ToBuffer = void 0;
19
19
  /**
20
20
  * Base header abstract class
21
21
  */
@@ -111,3 +111,8 @@ Object.defineProperty(exports, "UInt16ToHex", { enumerable: true, get: function
111
111
  Object.defineProperty(exports, "UInt32ToHex", { enumerable: true, get: function () { return NumberToHex_1.UInt32ToHex; } });
112
112
  Object.defineProperty(exports, "UInt64ToHex", { enumerable: true, get: function () { return NumberToHex_1.UInt64ToHex; } });
113
113
  Object.defineProperty(exports, "UInt8ToHex", { enumerable: true, get: function () { return NumberToHex_1.UInt8ToHex; } });
114
+ /**
115
+ * Error classes (all extend NetKittyError)
116
+ */
117
+ var CodecSchemaValidateError_1 = require("./errors/CodecSchemaValidateError");
118
+ Object.defineProperty(exports, "CodecSchemaValidateError", { enumerable: true, get: function () { return CodecSchemaValidateError_1.CodecSchemaValidateError; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netkitty/codec",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Schema-driven packet codec: encode/decode 180+ network and industrial (OT/ICS/SCADA) protocol headers — TCP/IP, TLS, HTTP/2, DNS, MQTT, plus Modbus, DNP3, IEC 61850 (GOOSE/SV/MMS), IEC 104, S7comm, OPC UA, PROFINET, EtherCAT, BACnet and more.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -118,6 +118,7 @@
118
118
  "registry": "https://registry.npmjs.org/"
119
119
  },
120
120
  "dependencies": {
121
+ "@netkitty/errors": "^1.2.0",
121
122
  "ajv": "^8.20.0",
122
123
  "ip-address": "^10.0.1",
123
124
  "json-schema": "^0.4.0",
@@ -137,5 +138,5 @@
137
138
  },
138
139
  "homepage": "https://github.com/myq1991/netkitty/tree/main/packages/codec#readme",
139
140
  "bugs": "https://github.com/myq1991/netkitty/issues",
140
- "gitHead": "30d908ea152d30ff58dd26cb6e7e0ae557c055fc"
141
+ "gitHead": "52958b705354ac379a1a6d90a3955773c190d65a"
141
142
  }