@netkitty/codec 1.1.0 → 1.2.1

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,29 @@
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.1](https://github.com/myq1991/netkitty/compare/@netkitty/codec@1.2.0...@netkitty/codec@1.2.1) (2026-09-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **codec:** decode GOOSE allData INTEGER and BIT STRING items without data loss ([eeca0a5](https://github.com/myq1991/netkitty/commit/eeca0a54a942ed84917d37b5df10d77c83d5ad06))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.2.0](https://github.com/myq1991/netkitty/compare/@netkitty/codec@1.1.0...@netkitty/codec@1.2.0) (2026-07-23)
18
+
19
+
20
+ ### Features
21
+
22
+ * **errors:** add @netkitty/errors — shared NetKittyError base + ErrorCode ([d5a3405](https://github.com/myq1991/netkitty/commit/d5a3405ee1f812ac92ed3d32478c1bece9bdbd89))
23
+ * **errors:** route pcap-core/pcap/analysis/replay/capture errors through NetKittyError ([19b0888](https://github.com/myq1991/netkitty/commit/19b08886f490afaeec3620745e545eb2446b4f83))
24
+
25
+
26
+
27
+
28
+
6
29
  # 1.1.0 (2026-07-22)
7
30
 
8
31
 
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;
@@ -36,7 +36,7 @@ type INT32DataItem = {
36
36
  };
37
37
  type INT64DataItem = {
38
38
  dataType: ItemDataType.INT64;
39
- value: bigint;
39
+ value: string;
40
40
  };
41
41
  type INT8UDataItem = {
42
42
  dataType: ItemDataType.INT8U;
@@ -99,7 +99,37 @@ export declare class Goose extends BaseHeader {
99
99
  * @param dataTLVs
100
100
  * @protected
101
101
  */
102
- protected decodeDataTLVItem(dataTLVs: TLV[]): DataItem[];
102
+ protected decodeDataTLVItem(dataTLVs: TLV[], path: string): DataItem[];
103
+ /**
104
+ * Decode a BIT STRING (tag 0x84) data item
105
+ * CODED-ENUM is 2 octets and Quality 3 octets (the leading unused-bits octet included in the
106
+ * value). A 1-octet content is still a CODED-ENUM; longer bit strings are kept as a Quality bit
107
+ * string of the full content width so no bits are lost.
108
+ * @param value
109
+ * @param path
110
+ * @protected
111
+ */
112
+ protected decodeBitStringItem(value: Buffer, path: string): DataItem;
113
+ /**
114
+ * Decode a signed BER INTEGER (tag 0x85) data item
115
+ * The content is two's complement (X.690 8.3), so a leading 00 is the sign-extension byte of a
116
+ * positive value and must be kept (00 c8 = +200). The data type is inferred from the content
117
+ * length since the minimal BER encoding carries no declared width.
118
+ * @param value
119
+ * @param path
120
+ * @protected
121
+ */
122
+ protected decodeSignedIntegerItem(value: Buffer, path: string): DataItem;
123
+ /**
124
+ * Decode an unsigned BER INTEGER (tag 0x86) data item
125
+ * A leading 00 is dropped only when it is the mandatory positive-sign pad (next byte has its high
126
+ * bit set), so fixed-width encodings keep their declared width. The data type is then inferred
127
+ * from the remaining content length.
128
+ * @param value
129
+ * @param path
130
+ * @protected
131
+ */
132
+ protected decodeUnsignedIntegerItem(value: Buffer, path: string): DataItem;
103
133
  /**
104
134
  * Encode data TLV items
105
135
  * @param dataItems
@@ -14,7 +14,6 @@ const NumberToBERBuffer_1 = require("../helper/NumberToBERBuffer");
14
14
  const BufferToNumber_1 = require("../helper/BufferToNumber");
15
15
  const BufferToHex_1 = require("../helper/BufferToHex");
16
16
  const NumberToBuffer_1 = require("../helper/NumberToBuffer");
17
- const GetBERIntegerLengthFromBuffer_1 = require("../lib/GetBERIntegerLengthFromBuffer");
18
17
  var ItemDataType;
19
18
  (function (ItemDataType) {
20
19
  ItemDataType["Boolean"] = "Boolean";
@@ -720,7 +719,7 @@ class Goose extends BaseHeader_1.BaseHeader {
720
719
  decode: () => {
721
720
  const allDataTLV = this.TLVChild.find((tlv) => tlv.getTag('number') === 0xAB);
722
721
  const dataTLVs = allDataTLV ? allDataTLV.getChild() : [];
723
- const allData = this.decodeDataTLVItem(dataTLVs);
722
+ const allData = this.decodeDataTLVItem(dataTLVs, this.instance.goosePdu.allData.getPath());
724
723
  if (allData.length)
725
724
  this.instance.goosePdu.allData.setValue(allData);
726
725
  },
@@ -772,9 +771,10 @@ class Goose extends BaseHeader_1.BaseHeader {
772
771
  * @param dataTLVs
773
772
  * @protected
774
773
  */
775
- decodeDataTLVItem(dataTLVs) {
774
+ decodeDataTLVItem(dataTLVs, path) {
776
775
  const dataItems = [];
777
- dataTLVs.forEach((dataTLV) => {
776
+ dataTLVs.forEach((dataTLV, index) => {
777
+ const itemPath = `${path}[${index}]`;
778
778
  const length = dataTLV.getLength('number');
779
779
  const value = dataTLV.getValue('buffer');
780
780
  switch (dataTLV.getTag('number')) {
@@ -788,84 +788,17 @@ class Goose extends BaseHeader_1.BaseHeader {
788
788
  break;
789
789
  case 0x84:
790
790
  {
791
- switch (length) {
792
- case 2:
793
- {
794
- dataItems.push({
795
- dataType: ItemDataType.CODEDENUM,
796
- value: parseInt(value.toString('hex'), 16)
797
- });
798
- }
799
- break;
800
- case 3:
801
- {
802
- dataItems.push({
803
- dataType: ItemDataType.Quality,
804
- value: parseInt(value.toString('hex'), 16).toString(2).padStart(24, '0')
805
- });
806
- }
807
- break;
808
- }
791
+ dataItems.push(this.decodeBitStringItem(value, itemPath));
809
792
  }
810
793
  break;
811
794
  case 0x85:
812
795
  {
813
- const integerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
814
- if (integerRealLength === 1) {
815
- dataItems.push({
816
- dataType: ItemDataType.INT8,
817
- value: (0, HexToNumber_1.HexToInt8)(value.toString('hex'))
818
- });
819
- }
820
- else if (integerRealLength === 2) {
821
- dataItems.push({
822
- dataType: ItemDataType.INT16,
823
- value: (0, HexToNumber_1.HexToInt16)(value.toString('hex'))
824
- });
825
- }
826
- else if (integerRealLength === 4) {
827
- dataItems.push({
828
- dataType: ItemDataType.INT32,
829
- value: (0, HexToNumber_1.HexToInt32)(value.toString('hex'))
830
- });
831
- }
832
- else if (integerRealLength === 8) {
833
- dataItems.push({
834
- dataType: ItemDataType.INT64,
835
- value: (0, HexToNumber_1.HexToInt64)(value.toString('hex'))
836
- });
837
- }
796
+ dataItems.push(this.decodeSignedIntegerItem(value, itemPath));
838
797
  }
839
798
  break;
840
799
  case 0x86:
841
800
  {
842
- const unsignedIntegerRealLength = (0, GetBERIntegerLengthFromBuffer_1.GetBERIntegerLengthFromBuffer)(value);
843
- switch (unsignedIntegerRealLength) {
844
- case 1:
845
- {
846
- dataItems.push({
847
- dataType: ItemDataType.INT8U,
848
- value: (0, HexToNumber_1.HexToUInt8)(value.toString('hex'))
849
- });
850
- }
851
- break;
852
- case 2:
853
- {
854
- dataItems.push({
855
- dataType: ItemDataType.INT16U,
856
- value: (0, HexToNumber_1.HexToUInt16)(value.toString('hex'))
857
- });
858
- }
859
- break;
860
- case 4:
861
- {
862
- dataItems.push({
863
- dataType: ItemDataType.INT32U,
864
- value: (0, HexToNumber_1.HexToUInt32)(value.toString('hex'))
865
- });
866
- }
867
- break;
868
- }
801
+ dataItems.push(this.decodeUnsignedIntegerItem(value, itemPath));
869
802
  }
870
803
  break;
871
804
  case 0x87:
@@ -906,7 +839,7 @@ class Goose extends BaseHeader_1.BaseHeader {
906
839
  const subDataTLVs = node_tlv_1.default.parseList(value);
907
840
  dataItems.push({
908
841
  dataType: ItemDataType.Structure,
909
- value: this.decodeDataTLVItem(subDataTLVs)
842
+ value: this.decodeDataTLVItem(subDataTLVs, `${itemPath}.value`)
910
843
  });
911
844
  }
912
845
  break;
@@ -914,6 +847,79 @@ class Goose extends BaseHeader_1.BaseHeader {
914
847
  });
915
848
  return dataItems;
916
849
  }
850
+ /**
851
+ * Decode a BIT STRING (tag 0x84) data item
852
+ * CODED-ENUM is 2 octets and Quality 3 octets (the leading unused-bits octet included in the
853
+ * value). A 1-octet content is still a CODED-ENUM; longer bit strings are kept as a Quality bit
854
+ * string of the full content width so no bits are lost.
855
+ * @param value
856
+ * @param path
857
+ * @protected
858
+ */
859
+ decodeBitStringItem(value, path) {
860
+ if (!value.length) {
861
+ this.recordError(path, 'Empty BIT STRING content, decoded as 0');
862
+ return { dataType: ItemDataType.CODEDENUM, value: 0 };
863
+ }
864
+ if (value.length <= 2)
865
+ return { dataType: ItemDataType.CODEDENUM, value: parseInt(value.toString('hex'), 16) };
866
+ return {
867
+ dataType: ItemDataType.Quality,
868
+ //BigInt so bit strings wider than 53 bits keep every bit.
869
+ value: BigInt(`0x${value.toString('hex')}`).toString(2).padStart(value.length * 8, '0')
870
+ };
871
+ }
872
+ /**
873
+ * Decode a signed BER INTEGER (tag 0x85) data item
874
+ * The content is two's complement (X.690 8.3), so a leading 00 is the sign-extension byte of a
875
+ * positive value and must be kept (00 c8 = +200). The data type is inferred from the content
876
+ * length since the minimal BER encoding carries no declared width.
877
+ * @param value
878
+ * @param path
879
+ * @protected
880
+ */
881
+ decodeSignedIntegerItem(value, path) {
882
+ if (!value.length) {
883
+ this.recordError(path, 'Empty INTEGER content, decoded as 0');
884
+ return { dataType: ItemDataType.INT8, value: 0 };
885
+ }
886
+ let intValue = BigInt(`0x${value.toString('hex')}`);
887
+ if (value[0] & 0x80)
888
+ intValue -= 1n << BigInt(value.length * 8);
889
+ if (value.length === 1)
890
+ return { dataType: ItemDataType.INT8, value: Number(intValue) };
891
+ if (value.length === 2)
892
+ return { dataType: ItemDataType.INT16, value: Number(intValue) };
893
+ if (value.length <= 4)
894
+ return { dataType: ItemDataType.INT32, value: Number(intValue) };
895
+ if (value.length > 8)
896
+ this.recordError(path, 'INTEGER exceeds 64 bits');
897
+ return { dataType: ItemDataType.INT64, value: intValue.toString() };
898
+ }
899
+ /**
900
+ * Decode an unsigned BER INTEGER (tag 0x86) data item
901
+ * A leading 00 is dropped only when it is the mandatory positive-sign pad (next byte has its high
902
+ * bit set), so fixed-width encodings keep their declared width. The data type is then inferred
903
+ * from the remaining content length.
904
+ * @param value
905
+ * @param path
906
+ * @protected
907
+ */
908
+ decodeUnsignedIntegerItem(value, path) {
909
+ if (!value.length) {
910
+ this.recordError(path, 'Empty INTEGER content, decoded as 0');
911
+ return { dataType: ItemDataType.INT8U, value: 0 };
912
+ }
913
+ const content = value.length > 1 && value[0] === 0x00 && value[1] & 0x80 ? value.subarray(1) : value;
914
+ const uintValue = Number(BigInt(`0x${content.toString('hex')}`));
915
+ if (content.length === 1)
916
+ return { dataType: ItemDataType.INT8U, value: uintValue };
917
+ if (content.length === 2)
918
+ return { dataType: ItemDataType.INT16U, value: uintValue };
919
+ if (content.length > 4)
920
+ this.recordError(path, 'Unsigned INTEGER exceeds 32 bits');
921
+ return { dataType: ItemDataType.INT32U, value: uintValue };
922
+ }
917
923
  /**
918
924
  * Encode data TLV items
919
925
  * @param dataItems
@@ -1000,7 +1006,13 @@ class Goose extends BaseHeader_1.BaseHeader {
1000
1006
  if (isNaN(codedEnumValue))
1001
1007
  this.recordError(errorNodePath, 'Invalid CODED-ENUM value');
1002
1008
  codedEnumValue = codedEnumValue ? codedEnumValue : 0;
1003
- return new node_tlv_1.default(0x84, Buffer.from((0, NumberToBERHex_1.UInt16ToBERHex)(codedEnumValue), 'hex'));
1009
+ if (codedEnumValue < 0 || codedEnumValue > 65535) {
1010
+ this.recordError(errorNodePath, 'Invalid CODED-ENUM value');
1011
+ codedEnumValue = Math.min(Math.max(codedEnumValue, 0), 65535);
1012
+ }
1013
+ //A BIT STRING, not an INTEGER: always 2 octets and never sign-padded, so it
1014
+ //re-decodes as CODED-ENUM (a 1-octet or 00-padded 3-octet form did not).
1015
+ return new node_tlv_1.default(0x84, Buffer.from((0, NumberToHex_1.UInt16ToHex)(codedEnumValue), 'hex'));
1004
1016
  }
1005
1017
  case ItemDataType.OCTETSTRING: {
1006
1018
  const hexText = dataItem.value;
@@ -1040,12 +1052,15 @@ class Goose extends BaseHeader_1.BaseHeader {
1040
1052
  return new node_tlv_1.default(0x91, Buffer.from(timestamp.toString(16).padStart(8 * 2, '0'), 'hex'));
1041
1053
  }
1042
1054
  case ItemDataType.Quality: {
1043
- const bitString = dataItem.value;
1044
- let intValue = parseInt(bitString, 2);
1045
- if (isNaN(intValue))
1055
+ let bitString = `${dataItem.value}`;
1056
+ if (!/^[01]+$/.test(bitString)) {
1046
1057
  this.recordError(errorNodePath, 'Invalid Quality value');
1047
- intValue = intValue ? intValue : 0;
1048
- return new node_tlv_1.default(0x84, Buffer.from(intValue.toString(16).padStart(3 * 2, '0'), 'hex'));
1058
+ bitString = '0';
1059
+ }
1060
+ //At least 3 octets; a wider bit string keeps its full width. BigInt + padStart
1061
+ //avoids the odd-length hex that Buffer.from(...,'hex') silently truncated.
1062
+ const octets = Math.max(3, Math.ceil(bitString.length / 8));
1063
+ return new node_tlv_1.default(0x84, Buffer.from(BigInt(`0b${bitString}`).toString(16).padStart(octets * 2, '0'), 'hex'));
1049
1064
  }
1050
1065
  case ItemDataType.Structure: {
1051
1066
  return new node_tlv_1.default(0xa2, Buffer.concat(this.encodeDataTLVItem(dataItem.value).map((tlv) => Buffer.concat([tlv.bTag, tlv.bLength, tlv.bValue]))));
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.1",
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": "519fdefcb5c76f69fade408cc36e0c2fa69ccad4"
141
142
  }
@@ -1,6 +0,0 @@
1
- /**
2
- * Get BER encoded integer real length from buffer
3
- * @param buffer
4
- * @constructor
5
- */
6
- export declare function GetBERIntegerLengthFromBuffer(buffer: Buffer): number;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetBERIntegerLengthFromBuffer = GetBERIntegerLengthFromBuffer;
4
- /**
5
- * Get BER encoded integer real length from buffer
6
- * @param buffer
7
- * @constructor
8
- */
9
- function GetBERIntegerLengthFromBuffer(buffer) {
10
- if (buffer[0] === 0) {
11
- return buffer.length - 1;
12
- }
13
- else {
14
- return buffer.length;
15
- }
16
- }