@netkitty/codec 1.2.0 → 2.0.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 +170 -0
- package/README.md +58 -10
- package/README.zh-CN.md +52 -9
- package/dist/Codec.d.ts +3 -2
- package/dist/Codec.js +106 -10
- package/dist/abstracts/BaseHeader.d.ts +28 -2
- package/dist/abstracts/BaseHeader.js +132 -43
- package/dist/errors/CodecSchemaValidateError.d.ts +34 -1
- package/dist/errors/CodecSchemaValidateError.js +26 -3
- package/dist/headers/ADSAMS.js +2 -0
- package/dist/headers/AH.js +1 -0
- package/dist/headers/AMQP.js +2 -1
- package/dist/headers/ARP.js +16 -10
- package/dist/headers/BACnetIP.js +1 -0
- package/dist/headers/BGP.js +1 -0
- package/dist/headers/Babel.js +2 -1
- package/dist/headers/BitTorrent.d.ts +2 -0
- package/dist/headers/BitTorrent.js +4 -2
- package/dist/headers/C37118.js +1 -0
- package/dist/headers/CAPWAP.js +1 -0
- package/dist/headers/CDP.js +1 -1
- package/dist/headers/CMS.js +2 -2
- package/dist/headers/COTP.d.ts +2 -0
- package/dist/headers/COTP.js +6 -1
- package/dist/headers/CassandraCQL.js +1 -0
- package/dist/headers/Codesys.js +1 -0
- package/dist/headers/Collectd.js +1 -1
- package/dist/headers/DCCP.js +1 -0
- package/dist/headers/DHCPFailover.js +1 -0
- package/dist/headers/DNS.js +3 -3
- package/dist/headers/DTLS.js +1 -0
- package/dist/headers/Diameter.js +3 -2
- package/dist/headers/EAPOL.js +1 -1
- package/dist/headers/EIGRP.js +1 -1
- package/dist/headers/ENIP.js +1 -0
- package/dist/headers/Elasticsearch.js +1 -0
- package/dist/headers/EtherCAT.js +1 -0
- package/dist/headers/EthernetII.js +6 -0
- package/dist/headers/FTP.js +6 -6
- package/dist/headers/Finger.js +3 -3
- package/dist/headers/FoundationFieldbusHSE.js +1 -0
- package/dist/headers/GELF.js +7 -1
- package/dist/headers/GENEVE.js +1 -1
- package/dist/headers/GLBP.js +1 -1
- package/dist/headers/GTPU.js +1 -0
- package/dist/headers/GTPv2C.js +1 -0
- package/dist/headers/GitProtocol.js +2 -2
- package/dist/headers/Goose.d.ts +32 -2
- package/dist/headers/Goose.js +116 -89
- package/dist/headers/Gopher.js +6 -6
- package/dist/headers/HARTIP.js +1 -0
- package/dist/headers/HSR.js +2 -0
- package/dist/headers/HTTP.js +6 -6
- package/dist/headers/HTTP2.js +1 -0
- package/dist/headers/ICMP.js +1 -0
- package/dist/headers/ICMPv6.js +1 -0
- package/dist/headers/IEC104_I_Frame.js +26 -3
- package/dist/headers/IEC104_S_Frame.js +7 -2
- package/dist/headers/IEC104_U_Frame.js +14 -3
- package/dist/headers/IEC61850SampledValues.js +2 -1
- package/dist/headers/IGMP.js +1 -0
- package/dist/headers/IMAP.js +5 -5
- package/dist/headers/IPFIX.js +2 -1
- package/dist/headers/IPv4.js +18 -1
- package/dist/headers/IPv6.js +1 -0
- package/dist/headers/IPv6HopByHopOptions.js +12 -11
- package/dist/headers/IRC.js +4 -4
- package/dist/headers/ISAKMP.js +2 -1
- package/dist/headers/ISCSI.js +2 -0
- package/dist/headers/ISIS.js +2 -1
- package/dist/headers/ISOSession.d.ts +2 -0
- package/dist/headers/ISOSession.js +14 -10
- package/dist/headers/Ident.js +8 -8
- package/dist/headers/KNXnetIP.js +1 -0
- package/dist/headers/Kafka.js +1 -0
- package/dist/headers/Kerberos.js +1 -0
- package/dist/headers/L2TP.js +2 -2
- package/dist/headers/LACP.js +1 -1
- package/dist/headers/LDAP.js +2 -3
- package/dist/headers/LDP.js +1 -0
- package/dist/headers/LLC.d.ts +2 -0
- package/dist/headers/LLC.js +2 -0
- package/dist/headers/LPD.js +3 -3
- package/dist/headers/MGCP.js +7 -7
- package/dist/headers/MMS.d.ts +2 -0
- package/dist/headers/MMS.js +10 -6
- package/dist/headers/MQTT.js +1 -0
- package/dist/headers/MQTTSN.js +1 -0
- package/dist/headers/MarkerProtocol.js +1 -1
- package/dist/headers/Megaco.js +3 -3
- package/dist/headers/Memcached.js +3 -2
- package/dist/headers/ModbusTCP.js +1 -0
- package/dist/headers/ModbusUDP.js +1 -0
- package/dist/headers/MongoDB.js +1 -0
- package/dist/headers/MySQL.js +1 -0
- package/dist/headers/NATS.js +2 -2
- package/dist/headers/NBDS.js +1 -0
- package/dist/headers/NBSS.js +1 -0
- package/dist/headers/NFS.js +1 -0
- package/dist/headers/NHRP.js +1 -0
- package/dist/headers/NNTP.js +6 -6
- package/dist/headers/NetFlowV5.js +1 -0
- package/dist/headers/OLSR.js +2 -1
- package/dist/headers/OPCUA.js +1 -0
- package/dist/headers/OpenFlow.js +1 -0
- package/dist/headers/OpenVPN.js +1 -0
- package/dist/headers/PCWorx.js +1 -0
- package/dist/headers/POP3.js +5 -5
- package/dist/headers/PPPoEDiscovery.js +2 -1
- package/dist/headers/PPPoESession.js +1 -0
- package/dist/headers/PPTP.js +1 -0
- package/dist/headers/PTP.js +1 -0
- package/dist/headers/PostgreSQL.js +2 -0
- package/dist/headers/QUIC.js +2 -0
- package/dist/headers/RADIUS.js +1 -0
- package/dist/headers/RDP.d.ts +2 -0
- package/dist/headers/RDP.js +4 -1
- package/dist/headers/RFB.js +4 -4
- package/dist/headers/RGoose.js +6 -1
- package/dist/headers/RSVP.js +3 -2
- package/dist/headers/RTCP.js +1 -0
- package/dist/headers/RTP.js +2 -1
- package/dist/headers/RTPS.d.ts +2 -0
- package/dist/headers/RTPS.js +4 -1
- package/dist/headers/RTSP.js +7 -7
- package/dist/headers/RawData.js +1 -1
- package/dist/headers/Redis.js +4 -4
- package/dist/headers/Rlogin.js +5 -5
- package/dist/headers/Rsync.js +2 -2
- package/dist/headers/S7comm.d.ts +2 -0
- package/dist/headers/S7comm.js +5 -1
- package/dist/headers/SCTP.js +2 -2
- package/dist/headers/SFlow.js +2 -1
- package/dist/headers/SIP.js +6 -6
- package/dist/headers/SLMP.js +1 -0
- package/dist/headers/SLP.js +2 -0
- package/dist/headers/SLPv1.js +1 -0
- package/dist/headers/SMB1.js +1 -0
- package/dist/headers/SMB2.js +1 -0
- package/dist/headers/SMPP.js +1 -0
- package/dist/headers/SMTP.js +6 -6
- package/dist/headers/SNAP.js +18 -5
- package/dist/headers/SNMP.js +4 -4
- package/dist/headers/SOCKS4.js +11 -5
- package/dist/headers/SSDP.js +7 -7
- package/dist/headers/SSH.js +5 -4
- package/dist/headers/STOMP.js +5 -5
- package/dist/headers/STUN.js +2 -0
- package/dist/headers/Skinny.js +1 -0
- package/dist/headers/StatsD.js +4 -4
- package/dist/headers/SunRPC.js +1 -0
- package/dist/headers/Syslog.js +2 -2
- package/dist/headers/TCP.js +18 -6
- package/dist/headers/TLS_Alert.js +23 -11
- package/dist/headers/TLS_ApplicationData.js +9 -4
- package/dist/headers/TLS_ChangeCipherSpec.js +10 -5
- package/dist/headers/TLS_Handshake.js +41 -26
- package/dist/headers/TLS_Heartbeat.js +10 -1
- package/dist/headers/TPKT.js +3 -1
- package/dist/headers/TacacsPlus.js +1 -0
- package/dist/headers/Telnet.js +2 -1
- package/dist/headers/Teredo.js +2 -2
- package/dist/headers/UDP.js +8 -0
- package/dist/headers/VLAN_802dot1Q.js +7 -0
- package/dist/headers/WCCP.js +1 -0
- package/dist/headers/WHOIS.js +3 -3
- package/dist/headers/WSDiscovery.js +2 -2
- package/dist/headers/XMPP.js +3 -3
- package/dist/headers/Zabbix.js +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/lib/SchemaValidator.d.ts +31 -0
- package/dist/lib/SchemaValidator.js +137 -0
- package/dist/schema/ProtocolFieldJSONSchema.d.ts +4 -1
- package/dist/schema/ProtocolJSONSchema.d.ts +1 -1
- package/dist/types/CodecErrorInfo.d.ts +11 -0
- package/dist/types/LayerGraph.d.ts +14 -1
- package/package.json +2 -2
- package/dist/lib/GetBERIntegerLengthFromBuffer.d.ts +0 -6
- package/dist/lib/GetBERIntegerLengthFromBuffer.js +0 -16
|
@@ -42,13 +42,15 @@ class TLS_ApplicationData extends BaseHeader_1.BaseHeader {
|
|
|
42
42
|
this.instance.contentType.setValue((0, BufferToNumber_1.BufferToInt8)(this.readBytes(0, 1)));
|
|
43
43
|
},
|
|
44
44
|
encode: () => {
|
|
45
|
-
const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
45
|
+
const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
46
46
|
this.writeBytes(0, contentType);
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
version: {
|
|
50
50
|
type: 'string',
|
|
51
51
|
label: 'Legacy Version',
|
|
52
|
+
//Closed set: decode stores one of these names, or '0' for an unrecognized version.
|
|
53
|
+
enum: [...Object.values(TLSver), '0'],
|
|
52
54
|
minimum: 0,
|
|
53
55
|
maximum: 65535,
|
|
54
56
|
decode: () => {
|
|
@@ -85,7 +87,7 @@ class TLS_ApplicationData extends BaseHeader_1.BaseHeader {
|
|
|
85
87
|
}
|
|
86
88
|
},
|
|
87
89
|
encode: () => {
|
|
88
|
-
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
90
|
+
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
89
91
|
switch (version) {
|
|
90
92
|
case TLSver.SSL_3_0:
|
|
91
93
|
{
|
|
@@ -118,6 +120,9 @@ class TLS_ApplicationData extends BaseHeader_1.BaseHeader {
|
|
|
118
120
|
}
|
|
119
121
|
break;
|
|
120
122
|
default: {
|
|
123
|
+
//'0' is what decode stores for an unrecognized version; anything else is not a version.
|
|
124
|
+
if (`${version}` !== '0')
|
|
125
|
+
this.recordError(this.instance.version.getPath(), `Unknown TLS version '${version}', encoded as 0`, 'error');
|
|
121
126
|
this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
|
|
122
127
|
}
|
|
123
128
|
}
|
|
@@ -132,7 +137,7 @@ class TLS_ApplicationData extends BaseHeader_1.BaseHeader {
|
|
|
132
137
|
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
|
|
133
138
|
},
|
|
134
139
|
encode: () => {
|
|
135
|
-
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
140
|
+
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
136
141
|
this.writeBytes(3, length);
|
|
137
142
|
}
|
|
138
143
|
},
|
|
@@ -145,7 +150,7 @@ class TLS_ApplicationData extends BaseHeader_1.BaseHeader {
|
|
|
145
150
|
this.instance.appData.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(5, this.instance.length.getValue())));
|
|
146
151
|
},
|
|
147
152
|
encode: () => {
|
|
148
|
-
const appData = (0, HexToBuffer_1.HexToBuffer)(this.instance.appData.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
153
|
+
const appData = (0, HexToBuffer_1.HexToBuffer)(this.instance.appData.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
149
154
|
this.writeBytes(5, appData);
|
|
150
155
|
}
|
|
151
156
|
}
|
|
@@ -41,13 +41,15 @@ class TLS_ChangeCipherSpec extends BaseHeader_1.BaseHeader {
|
|
|
41
41
|
this.instance.contentType.setValue((0, BufferToNumber_1.BufferToInt8)(this.readBytes(0, 1)));
|
|
42
42
|
},
|
|
43
43
|
encode: () => {
|
|
44
|
-
const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
44
|
+
const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
45
45
|
this.writeBytes(0, contentType);
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
version: {
|
|
49
49
|
type: 'string',
|
|
50
50
|
label: 'Legacy Version',
|
|
51
|
+
//Closed set: decode stores one of these names, or '0' for an unrecognized version.
|
|
52
|
+
enum: [...Object.values(TLSver), '0'],
|
|
51
53
|
minimum: 0,
|
|
52
54
|
maximum: 65535,
|
|
53
55
|
decode: () => {
|
|
@@ -84,7 +86,7 @@ class TLS_ChangeCipherSpec extends BaseHeader_1.BaseHeader {
|
|
|
84
86
|
}
|
|
85
87
|
},
|
|
86
88
|
encode: () => {
|
|
87
|
-
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
89
|
+
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
88
90
|
switch (version) {
|
|
89
91
|
case TLSver.SSL_3_0:
|
|
90
92
|
{
|
|
@@ -117,6 +119,9 @@ class TLS_ChangeCipherSpec extends BaseHeader_1.BaseHeader {
|
|
|
117
119
|
}
|
|
118
120
|
break;
|
|
119
121
|
default: {
|
|
122
|
+
//'0' is what decode stores for an unrecognized version; anything else is not a version.
|
|
123
|
+
if (`${version}` !== '0')
|
|
124
|
+
this.recordError(this.instance.version.getPath(), `Unknown TLS version '${version}', encoded as 0`, 'error');
|
|
120
125
|
this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
|
|
121
126
|
}
|
|
122
127
|
}
|
|
@@ -131,7 +136,7 @@ class TLS_ChangeCipherSpec extends BaseHeader_1.BaseHeader {
|
|
|
131
136
|
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
|
|
132
137
|
},
|
|
133
138
|
encode: () => {
|
|
134
|
-
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
139
|
+
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
135
140
|
this.writeBytes(3, length);
|
|
136
141
|
}
|
|
137
142
|
},
|
|
@@ -139,11 +144,11 @@ class TLS_ChangeCipherSpec extends BaseHeader_1.BaseHeader {
|
|
|
139
144
|
type: 'string',
|
|
140
145
|
label: 'Change Cipher Spec Message',
|
|
141
146
|
decode: () => {
|
|
142
|
-
const length = this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
147
|
+
const length = this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
143
148
|
this.instance.change_cipher_spec_message.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(5, length)));
|
|
144
149
|
},
|
|
145
150
|
encode: () => {
|
|
146
|
-
const message = (0, HexToBuffer_1.HexToBuffer)(this.instance.change_cipher_spec_message.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
151
|
+
const message = (0, HexToBuffer_1.HexToBuffer)(this.instance.change_cipher_spec_message.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
147
152
|
this.writeBytes(5, message);
|
|
148
153
|
}
|
|
149
154
|
}
|
|
@@ -44,13 +44,15 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
44
44
|
this.instance.contentType.setValue((0, BufferToNumber_1.BufferToInt8)(this.readBytes(0, 1)));
|
|
45
45
|
},
|
|
46
46
|
encode: () => {
|
|
47
|
-
const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
47
|
+
const contentType = (0, NumberToBuffer_1.UInt8ToBuffer)(this.instance.contentType.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
48
48
|
this.writeBytes(0, contentType);
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
version: {
|
|
52
52
|
type: 'string',
|
|
53
53
|
label: 'Legacy Version',
|
|
54
|
+
//Closed set: decode stores one of these names, or '0' for an unrecognized version.
|
|
55
|
+
enum: [...Object.values(TLSver), '0'],
|
|
54
56
|
minimum: 0,
|
|
55
57
|
maximum: 65535,
|
|
56
58
|
decode: () => {
|
|
@@ -87,7 +89,7 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
87
89
|
}
|
|
88
90
|
},
|
|
89
91
|
encode: () => {
|
|
90
|
-
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
92
|
+
const version = this.instance.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
91
93
|
switch (version) {
|
|
92
94
|
case TLSver.SSL_3_0:
|
|
93
95
|
{
|
|
@@ -120,6 +122,9 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
120
122
|
}
|
|
121
123
|
break;
|
|
122
124
|
default: {
|
|
125
|
+
//'0' is what decode stores for an unrecognized version; anything else is not a version.
|
|
126
|
+
if (`${version}` !== '0')
|
|
127
|
+
this.recordError(this.instance.version.getPath(), `Unknown TLS version '${version}', encoded as 0`, 'error');
|
|
123
128
|
this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
|
|
124
129
|
}
|
|
125
130
|
}
|
|
@@ -134,7 +139,7 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
134
139
|
this.instance.length.setValue((0, BufferToNumber_1.BufferToUInt16)(this.readBytes(3, 2)));
|
|
135
140
|
},
|
|
136
141
|
encode: () => {
|
|
137
|
-
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
142
|
+
const length = (0, NumberToBuffer_1.UInt16ToBuffer)(this.instance.length.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
138
143
|
this.writeBytes(3, length);
|
|
139
144
|
}
|
|
140
145
|
},
|
|
@@ -287,8 +292,12 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
287
292
|
}
|
|
288
293
|
break;
|
|
289
294
|
default: {
|
|
295
|
+
//Not a known name: a numeric type (what decode stores for an unnamed one).
|
|
290
296
|
const handshakeType1 = parseInt(handshakeType);
|
|
291
|
-
|
|
297
|
+
const known = /^\d+$/.test(`${handshakeType}`) && handshakeType1 <= 255;
|
|
298
|
+
if (!known)
|
|
299
|
+
this.recordError(this.instance.handshakeType.getPath(), `Unknown handshake type '${handshakeType}', encoded as 0`, 'error');
|
|
300
|
+
this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(known ? handshakeType1 : 0));
|
|
292
301
|
}
|
|
293
302
|
}
|
|
294
303
|
}
|
|
@@ -297,12 +306,12 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
297
306
|
type: 'integer',
|
|
298
307
|
label: 'Length',
|
|
299
308
|
minimum: 0,
|
|
300
|
-
maximum:
|
|
309
|
+
maximum: 16777215,
|
|
301
310
|
decode: () => {
|
|
302
311
|
this.instance.handshakeLength.setValue((0, BufferToNumber_1.BufferToUInt32)(this.readBytes(6, 3)));
|
|
303
312
|
},
|
|
304
313
|
encode: () => {
|
|
305
|
-
const length1 = (this.instance.handshakeLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
314
|
+
const length1 = (this.instance.handshakeLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
306
315
|
const length2 = length1.toString(16).padStart(6, '0');
|
|
307
316
|
const length3 = (0, HexToBuffer_1.HexToBuffer)(length2);
|
|
308
317
|
this.writeBytes(6, length3);
|
|
@@ -326,7 +335,7 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
326
335
|
type: 'object',
|
|
327
336
|
properties: {
|
|
328
337
|
type: { type: 'string', label: 'Type' },
|
|
329
|
-
name: { type: 'string', label: 'Name' },
|
|
338
|
+
name: { type: 'string', label: 'Name', readOnly: true },
|
|
330
339
|
//Present only for extensions we cannot structure (unknown type or
|
|
331
340
|
//malformed): the raw extension data, kept as hex so it round-trips.
|
|
332
341
|
data: { type: 'string', contentEncoding: 'hex', label: 'Data' },
|
|
@@ -356,7 +365,7 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
356
365
|
raw: { type: 'string', contentEncoding: 'hex', label: 'Unparsed Body' }
|
|
357
366
|
},
|
|
358
367
|
decode: () => {
|
|
359
|
-
const handshakeLength = (this.instance.handshakeLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not
|
|
368
|
+
const handshakeLength = (this.instance.handshakeLength.getValue(0, (nodePath) => this.recordError(nodePath, 'Not Found')));
|
|
360
369
|
//handshakeLength describes the whole (possibly reassembled) message, which may
|
|
361
370
|
//span multiple TLS records. The body carried by THIS record is bounded by the
|
|
362
371
|
//record-layer length minus the 4-byte handshake header (type + 3-byte length);
|
|
@@ -391,7 +400,7 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
391
400
|
}
|
|
392
401
|
const handshakeType = this.instance.handshakeType.getValue();
|
|
393
402
|
const parts = [];
|
|
394
|
-
parts.push(this.tlsVersionStringToBuffer(md.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not
|
|
403
|
+
parts.push(this.tlsVersionStringToBuffer(md.version.getValue('0', (nodePath) => this.recordError(nodePath, 'Not Found'))));
|
|
395
404
|
parts.push((0, HexToBuffer_1.HexToBuffer)(md.random.getValue('')));
|
|
396
405
|
const sessionId = (0, HexToBuffer_1.HexToBuffer)(md.sessionId.getValue(''));
|
|
397
406
|
parts.push((0, NumberToBuffer_1.UInt8ToBuffer)(sessionId.length), sessionId);
|
|
@@ -407,7 +416,12 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
407
416
|
}
|
|
408
417
|
if (!md.extensions.isUndefined()) {
|
|
409
418
|
const extensionList = md.extensions.getValue([]);
|
|
410
|
-
const extensions = Buffer.concat(extensionList.map((extension) => {
|
|
419
|
+
const extensions = Buffer.concat(extensionList.map((extension, index) => {
|
|
420
|
+
//An extension without its 2-byte type cannot be framed: skip it, reported.
|
|
421
|
+
if (typeof extension.type !== 'string' || !extension.type) {
|
|
422
|
+
this.recordError(`${md.extensions.getPath()}[${index}].type`, 'Not Found, extension ignored');
|
|
423
|
+
return Buffer.alloc(0);
|
|
424
|
+
}
|
|
411
425
|
//Structurally decoded extensions carry their specific fields (no `data`);
|
|
412
426
|
//rebuild those from the fields. Hex-preserved extensions carry `data`.
|
|
413
427
|
const data = extension.data !== undefined ? (0, HexToBuffer_1.HexToBuffer)(extension.data) : this.encodeExtensionData(extension, handshakeType);
|
|
@@ -791,9 +805,9 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
791
805
|
encodeExtensionData(extension, handshakeType) {
|
|
792
806
|
switch (extension.type.toLowerCase()) {
|
|
793
807
|
case '0000': { //server_name
|
|
794
|
-
const entries = Buffer.concat(extension.serverNames.map((serverName) => {
|
|
795
|
-
const host = Buffer.from(serverName.hostName, 'ascii');
|
|
796
|
-
const nameType = serverName.nameType === 'host_name' ? 0 : parseInt(serverName.nameType);
|
|
808
|
+
const entries = Buffer.concat((extension.serverNames ?? []).map((serverName) => {
|
|
809
|
+
const host = Buffer.from(serverName.hostName ?? '', 'ascii');
|
|
810
|
+
const nameType = serverName.nameType === undefined || serverName.nameType === 'host_name' ? 0 : parseInt(serverName.nameType) || 0;
|
|
797
811
|
return Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(nameType), (0, NumberToBuffer_1.UInt16ToBuffer)(host.length), host]);
|
|
798
812
|
}));
|
|
799
813
|
if (entries.length === 0)
|
|
@@ -801,38 +815,39 @@ class TLS_Handshake extends BaseHeader_1.BaseHeader {
|
|
|
801
815
|
return Buffer.concat([(0, NumberToBuffer_1.UInt16ToBuffer)(entries.length), entries]);
|
|
802
816
|
}
|
|
803
817
|
case '000a':
|
|
804
|
-
return this.encodeCodeList16(extension.groups);
|
|
818
|
+
return this.encodeCodeList16(extension.groups ?? []);
|
|
805
819
|
case '000d':
|
|
806
|
-
return this.encodeCodeList16(extension.signatureAlgorithms);
|
|
820
|
+
return this.encodeCodeList16(extension.signatureAlgorithms ?? []);
|
|
807
821
|
case '000b': {
|
|
808
|
-
const list = Buffer.concat(extension.ecPointFormats.map((format) => (0, HexToBuffer_1.HexToBuffer)(format)));
|
|
822
|
+
const list = Buffer.concat((extension.ecPointFormats ?? []).map((format) => (0, HexToBuffer_1.HexToBuffer)(format)));
|
|
809
823
|
return Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(list.length), list]);
|
|
810
824
|
}
|
|
811
825
|
case '002d': {
|
|
812
|
-
const list = Buffer.concat(extension.modes.map((mode) => (0, HexToBuffer_1.HexToBuffer)(mode)));
|
|
826
|
+
const list = Buffer.concat((extension.modes ?? []).map((mode) => (0, HexToBuffer_1.HexToBuffer)(mode)));
|
|
813
827
|
return Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(list.length), list]);
|
|
814
828
|
}
|
|
815
829
|
case '0010': {
|
|
816
|
-
const entries = Buffer.concat(extension.protocols.map((protocol) => {
|
|
817
|
-
const bytes = Buffer.from(protocol, 'ascii');
|
|
830
|
+
const entries = Buffer.concat((extension.protocols ?? []).map((protocol) => {
|
|
831
|
+
const bytes = Buffer.from(protocol ?? '', 'ascii');
|
|
818
832
|
return Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(bytes.length), bytes]);
|
|
819
833
|
}));
|
|
820
834
|
return Buffer.concat([(0, NumberToBuffer_1.UInt16ToBuffer)(entries.length), entries]);
|
|
821
835
|
}
|
|
822
836
|
case '002b': {
|
|
823
837
|
if (handshakeType === HandshakeType.Handshake_3)
|
|
824
|
-
return this.tlsVersionStringToBuffer(extension.selectedVersion);
|
|
825
|
-
const list = Buffer.concat(extension.versions.map((version) => this.tlsVersionStringToBuffer(version)));
|
|
838
|
+
return this.tlsVersionStringToBuffer(extension.selectedVersion ?? '0');
|
|
839
|
+
const list = Buffer.concat((extension.versions ?? []).map((version) => this.tlsVersionStringToBuffer(version)));
|
|
826
840
|
return Buffer.concat([(0, NumberToBuffer_1.UInt8ToBuffer)(list.length), list]);
|
|
827
841
|
}
|
|
828
842
|
case '0033': {
|
|
829
843
|
if (handshakeType === HandshakeType.Handshake_3) {
|
|
830
|
-
const
|
|
831
|
-
|
|
844
|
+
const keyShare = extension.keyShare ?? {};
|
|
845
|
+
const key = (0, HexToBuffer_1.HexToBuffer)(keyShare.keyExchange ?? '');
|
|
846
|
+
return Buffer.concat([(0, HexToBuffer_1.HexToBuffer)(keyShare.group ?? '0000'), (0, NumberToBuffer_1.UInt16ToBuffer)(key.length), key]);
|
|
832
847
|
}
|
|
833
|
-
const entries = Buffer.concat(extension.keyShares.map((keyShare) => {
|
|
834
|
-
const key = (0, HexToBuffer_1.HexToBuffer)(keyShare.keyExchange);
|
|
835
|
-
return Buffer.concat([(0, HexToBuffer_1.HexToBuffer)(keyShare.group), (0, NumberToBuffer_1.UInt16ToBuffer)(key.length), key]);
|
|
848
|
+
const entries = Buffer.concat((extension.keyShares ?? []).map((keyShare) => {
|
|
849
|
+
const key = (0, HexToBuffer_1.HexToBuffer)(keyShare.keyExchange ?? '');
|
|
850
|
+
return Buffer.concat([(0, HexToBuffer_1.HexToBuffer)(keyShare.group ?? '0000'), (0, NumberToBuffer_1.UInt16ToBuffer)(key.length), key]);
|
|
836
851
|
}));
|
|
837
852
|
return Buffer.concat([(0, NumberToBuffer_1.UInt16ToBuffer)(entries.length), entries]);
|
|
838
853
|
}
|
|
@@ -52,6 +52,8 @@ class TLS_Heartbeat extends BaseHeader_1.BaseHeader {
|
|
|
52
52
|
version: {
|
|
53
53
|
type: 'string',
|
|
54
54
|
label: 'Version',
|
|
55
|
+
//Closed set: decode stores one of these names, or '0' for an unrecognized version.
|
|
56
|
+
enum: [...Object.values(TLSver), '0'],
|
|
55
57
|
minimum: 0,
|
|
56
58
|
maximum: 65535,
|
|
57
59
|
decode: () => {
|
|
@@ -116,6 +118,9 @@ class TLS_Heartbeat extends BaseHeader_1.BaseHeader {
|
|
|
116
118
|
}
|
|
117
119
|
break;
|
|
118
120
|
default: {
|
|
121
|
+
//'0' is what decode stores for an unrecognized version; anything else is not a version.
|
|
122
|
+
if (`${version}` !== '0')
|
|
123
|
+
this.recordError(this.instance.version.getPath(), `Unknown TLS version '${version}', encoded as 0`, 'error');
|
|
119
124
|
this.writeBytes(1, (0, NumberToBuffer_1.UInt16ToBuffer)(0));
|
|
120
125
|
}
|
|
121
126
|
}
|
|
@@ -171,8 +176,12 @@ class TLS_Heartbeat extends BaseHeader_1.BaseHeader {
|
|
|
171
176
|
}
|
|
172
177
|
break;
|
|
173
178
|
default: {
|
|
179
|
+
//Not a known name: a numeric type (what decode stores for an unnamed one).
|
|
174
180
|
const heartbeatType1 = parseInt(heartbeatType);
|
|
175
|
-
|
|
181
|
+
const known = /^\d+$/.test(`${heartbeatType}`) && heartbeatType1 <= 255;
|
|
182
|
+
if (!known)
|
|
183
|
+
this.recordError(this.instance.heartbeatType.getPath(), `Unknown heartbeat type '${heartbeatType}', encoded as 0`, 'error');
|
|
184
|
+
this.writeBytes(5, (0, NumberToBuffer_1.UInt8ToBuffer)(known ? heartbeatType1 : 0));
|
|
176
185
|
}
|
|
177
186
|
}
|
|
178
187
|
}
|
package/dist/headers/TPKT.js
CHANGED
|
@@ -38,10 +38,12 @@ class TPKT extends BaseHeader_1.BaseHeader {
|
|
|
38
38
|
type: 'object',
|
|
39
39
|
summary: 'TPKT v${version} len=${length}',
|
|
40
40
|
properties: {
|
|
41
|
-
|
|
41
|
+
//Default 3: the only TPKT version (RFC 1006), and what match() requires.
|
|
42
|
+
version: { ...this.fieldUInt('version', 0, 1, 'Version'), default: 3 },
|
|
42
43
|
reserved: this.fieldUInt('reserved', 1, 1, 'Reserved'),
|
|
43
44
|
length: {
|
|
44
45
|
type: 'integer',
|
|
46
|
+
autoCalculated: true,
|
|
45
47
|
label: 'Length',
|
|
46
48
|
minimum: 0,
|
|
47
49
|
maximum: 65535,
|
package/dist/headers/Telnet.js
CHANGED
|
@@ -137,9 +137,10 @@ class Telnet extends BaseHeader_1.BaseHeader {
|
|
|
137
137
|
//Display-only metadata parsed from the leading IAC command run on decode (no encode —
|
|
138
138
|
//populated by the `message` field below, never read back). isNegotiation flags a payload
|
|
139
139
|
//that opens with an IAC byte; commands lists the leading command sequences for the UI.
|
|
140
|
-
isNegotiation: { type: 'boolean', label: 'Is Negotiation', default: false },
|
|
140
|
+
isNegotiation: { type: 'boolean', label: 'Is Negotiation', readOnly: true, default: false },
|
|
141
141
|
commands: {
|
|
142
142
|
type: 'array',
|
|
143
|
+
readOnly: true,
|
|
143
144
|
label: 'IAC Commands',
|
|
144
145
|
items: {
|
|
145
146
|
type: 'object',
|
package/dist/headers/Teredo.js
CHANGED
|
@@ -106,8 +106,8 @@ class Teredo extends BaseHeader_1.BaseHeader {
|
|
|
106
106
|
type: 'object',
|
|
107
107
|
label: 'Authentication Indication',
|
|
108
108
|
properties: {
|
|
109
|
-
clientIdLength: { type: 'integer', label: 'Client ID Length', minimum: 0, maximum: 255 },
|
|
110
|
-
authDataLength: { type: 'integer', label: 'Authentication Value Length', minimum: 0, maximum: 255 },
|
|
109
|
+
clientIdLength: { type: 'integer', label: 'Client ID Length', readOnly: true, minimum: 0, maximum: 255 },
|
|
110
|
+
authDataLength: { type: 'integer', label: 'Authentication Value Length', readOnly: true, minimum: 0, maximum: 255 },
|
|
111
111
|
clientId: { type: 'string', label: 'Client Identifier', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
|
|
112
112
|
authData: { type: 'string', label: 'Authentication Value', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
|
|
113
113
|
nonce: { type: 'string', label: 'Nonce', contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX },
|
package/dist/headers/UDP.js
CHANGED
|
@@ -25,6 +25,12 @@ class UDP extends BaseHeader_1.BaseHeader {
|
|
|
25
25
|
*/
|
|
26
26
|
calculateUDPChecksum(udpHeaderBuffer) {
|
|
27
27
|
const udpHeaderLength = udpHeaderBuffer.length;
|
|
28
|
+
//Same contract as TCP: a UDP layer with no IP beneath is a legitimate crafted stack, so record
|
|
29
|
+
//an error and leave the checksum 0 instead of dereferencing a missing previous layer.
|
|
30
|
+
if (!this.prevCodecModule) {
|
|
31
|
+
this.recordError(this.instance.checksum.getPath(), 'Cannot compute UDP checksum: no IP layer beneath UDP');
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
28
34
|
const ipVersion = this.prevCodecModule.instance.version.getValue();
|
|
29
35
|
let pseudoHeaderBuffer = Buffer.from([]);
|
|
30
36
|
const sourceIp = this.prevCodecModule.instance.sip.getValue();
|
|
@@ -90,6 +96,7 @@ class UDP extends BaseHeader_1.BaseHeader {
|
|
|
90
96
|
dstport: this.fieldUInt('dstport', 2, 2, 'Destination Port'),
|
|
91
97
|
length: {
|
|
92
98
|
type: 'integer',
|
|
99
|
+
autoCalculated: true,
|
|
93
100
|
label: 'Length',
|
|
94
101
|
minimum: 0,
|
|
95
102
|
maximum: 65535,
|
|
@@ -122,6 +129,7 @@ class UDP extends BaseHeader_1.BaseHeader {
|
|
|
122
129
|
},
|
|
123
130
|
checksum: {
|
|
124
131
|
type: 'integer',
|
|
132
|
+
autoCalculated: true,
|
|
125
133
|
label: 'Checksum',
|
|
126
134
|
minimum: 0,
|
|
127
135
|
maximum: 65535,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VLAN_802dot1Q = void 0;
|
|
4
4
|
const BaseHeader_1 = require("../abstracts/BaseHeader");
|
|
5
|
+
const StringContentEncodingEnum_1 = require("../lib/StringContentEncodingEnum");
|
|
5
6
|
const NumberToHex_1 = require("../helper/NumberToHex");
|
|
6
7
|
const BufferToHex_1 = require("../helper/BufferToHex");
|
|
7
8
|
/**
|
|
@@ -68,10 +69,13 @@ class VLAN_802dot1Q extends BaseHeader_1.BaseHeader {
|
|
|
68
69
|
minLength: 4,
|
|
69
70
|
maxLength: 4,
|
|
70
71
|
label: 'EtherType',
|
|
72
|
+
contentEncoding: StringContentEncodingEnum_1.StringContentEncodingEnum.HEX,
|
|
71
73
|
decode: () => {
|
|
72
74
|
this.instance.etherType.setValue((0, BufferToHex_1.BufferToHex)(this.readBytes(2, 2)));
|
|
73
75
|
},
|
|
74
76
|
encode: () => {
|
|
77
|
+
if (this.instance.etherType.isUndefined())
|
|
78
|
+
return this.encodeOmittedEtherType(this.instance.etherType, 2);
|
|
75
79
|
const etherType = this.instance.etherType.getValue((0, NumberToHex_1.UInt16ToHex)(0x0000), (nodePath) => this.recordError(nodePath, 'Not Found'));
|
|
76
80
|
const typeBuffer = Buffer.from(etherType, 'hex');
|
|
77
81
|
if (typeBuffer.length < 2)
|
|
@@ -90,6 +94,9 @@ class VLAN_802dot1Q extends BaseHeader_1.BaseHeader {
|
|
|
90
94
|
match() {
|
|
91
95
|
if (!this.prevCodecModule)
|
|
92
96
|
return false;
|
|
97
|
+
//Fewer bytes than the 4-octet tag cannot be reproduced by these fields: leave them to raw.
|
|
98
|
+
if (this.packet.length - this.startPos < 4)
|
|
99
|
+
return false;
|
|
93
100
|
return this.prevCodecModule.instance.etherType.getValue() === (0, NumberToHex_1.UInt16ToHex)(0x8100);
|
|
94
101
|
}
|
|
95
102
|
}
|
package/dist/headers/WCCP.js
CHANGED
package/dist/headers/WHOIS.js
CHANGED
|
@@ -81,10 +81,10 @@ class WHOIS extends BaseHeader_1.BaseHeader {
|
|
|
81
81
|
//Display-only metadata parsed from the verbatim payload on decode (no encode — populated
|
|
82
82
|
//by the `message` field below, never read back). `query` is the first line (the request
|
|
83
83
|
//domain or a response's opening line); `isQuery` flags the single-line request shape.
|
|
84
|
-
isQuery: { type: 'boolean', label: 'Is Query', default: false },
|
|
85
|
-
query: { type: 'string', label: 'Query', default: '' },
|
|
84
|
+
isQuery: { type: 'boolean', label: 'Is Query', readOnly: true, default: false },
|
|
85
|
+
query: { type: 'string', label: 'Query', readOnly: true, default: '' },
|
|
86
86
|
//Drives the one-line summary: the first line of the payload, else 'response'.
|
|
87
|
-
summaryInfo: { type: 'string', label: 'Summary', hidden: true, default: '' },
|
|
87
|
+
summaryInfo: { type: 'string', label: 'Summary', readOnly: true, hidden: true, default: '' },
|
|
88
88
|
//The whole raw payload is the single source of truth: decoded verbatim to hex and
|
|
89
89
|
//re-emitted untouched (byte-perfect for any WHOIS payload). The first line is parsed into
|
|
90
90
|
//the display-only metadata above, which carry no codec of their own.
|
|
@@ -96,8 +96,8 @@ class WSDiscovery extends BaseHeader_1.BaseHeader {
|
|
|
96
96
|
//Display-only metadata parsed from the WS-Addressing Action on decode (no encode —
|
|
97
97
|
//populated by the message field above, never read back). action is the full Action URI;
|
|
98
98
|
//messageType is its short trailing segment (Probe / Hello / Bye / …).
|
|
99
|
-
action: { type: 'string', label: 'Action' },
|
|
100
|
-
messageType: { type: 'string', label: 'Message Type' }
|
|
99
|
+
action: { type: 'string', label: 'Action', readOnly: true },
|
|
100
|
+
messageType: { type: 'string', label: 'Message Type', readOnly: true }
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
}
|
package/dist/headers/XMPP.js
CHANGED
|
@@ -124,9 +124,9 @@ class XMPP extends BaseHeader_1.BaseHeader {
|
|
|
124
124
|
//message field above, never read back). rootElement is the first element's tag name (e.g.
|
|
125
125
|
//'stream:stream', 'message', 'iq', 'presence'); isStreamHeader flags the stream preamble;
|
|
126
126
|
//hasXmlDeclaration flags a leading `<?xml … ?>`.
|
|
127
|
-
rootElement: { type: 'string', label: 'Root Element' },
|
|
128
|
-
isStreamHeader: { type: 'boolean', label: 'Is Stream Header' },
|
|
129
|
-
hasXmlDeclaration: { type: 'boolean', label: 'Has XML Declaration' }
|
|
127
|
+
rootElement: { type: 'string', label: 'Root Element', readOnly: true },
|
|
128
|
+
isStreamHeader: { type: 'boolean', label: 'Is Stream Header', readOnly: true },
|
|
129
|
+
hasXmlDeclaration: { type: 'boolean', label: 'Has XML Declaration', readOnly: true }
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
}
|
package/dist/headers/Zabbix.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export { type CodecSchema } from './types/CodecSchema';
|
|
|
20
20
|
export { type HeaderTreeNode } from './types/HeaderTreeNode';
|
|
21
21
|
export { type CodecModuleConstructor } from './types/CodecModuleConstructor';
|
|
22
22
|
export { type CodecModule } from './types/CodecModule';
|
|
23
|
-
export { type CodecErrorInfo } from './types/CodecErrorInfo';
|
|
24
|
-
export { type NextLayer, type ConsistencyIssue } from './types/LayerGraph';
|
|
23
|
+
export { type CodecErrorInfo, type CodecErrorSeverity } from './types/CodecErrorInfo';
|
|
24
|
+
export { type NextLayer, type ConsistencyIssue, type HeuristicParent } from './types/LayerGraph';
|
|
25
25
|
export { type DissectionField, type DissectionLayer } from './types/Dissection';
|
|
26
26
|
/**
|
|
27
27
|
* Schemas
|
|
@@ -53,4 +53,4 @@ export { Float32ToHex, Int16ToHex, Int32ToHex, Int64ToHex, Int8ToHex, UInt16ToHe
|
|
|
53
53
|
/**
|
|
54
54
|
* Error classes (all extend NetKittyError)
|
|
55
55
|
*/
|
|
56
|
-
export { CodecSchemaValidateError } from './errors/CodecSchemaValidateError';
|
|
56
|
+
export { CodecSchemaValidateError, type CodecSchemaValidationIssue } from './errors/CodecSchemaValidateError';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ErrorObject, ValidateFunction } from 'ajv';
|
|
2
|
+
import { ProtocolJSONSchema } from '../schema/ProtocolJSONSchema';
|
|
3
|
+
import { CodecSchemaValidateError } from '../errors/CodecSchemaValidateError';
|
|
4
|
+
/**
|
|
5
|
+
* Derive the validation keywords a string field's `contentEncoding` implies, in place: an ipv4/ipv6/mac
|
|
6
|
+
* field gets `format: 'ipv4'|'ipv6'|'mac'`, a bigint field gets a numeric `pattern`. An explicit
|
|
7
|
+
* `format`/`pattern` on the field is left alone. Applied to every published schema (PROTOCOL_SCHEMA)
|
|
8
|
+
* and to every compiled validator, so the shape a UI sees and the shape encode enforces are the same,
|
|
9
|
+
* and every address field is constrained consistently without repeating the keyword per field.
|
|
10
|
+
*/
|
|
11
|
+
export declare function DeriveContentConstraints<T>(node: T): T;
|
|
12
|
+
/**
|
|
13
|
+
* Compile the Ajv shape validator for a protocol schema. The schema's decode/encode closures are
|
|
14
|
+
* stripped first (the same JSON round-trip that produces PROTOCOL_SCHEMA), so only the declarative
|
|
15
|
+
* shell is compiled. One place for the Ajv options keeps every validator identical.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CompileSchemaValidator(schema: ProtocolJSONSchema): ValidateFunction;
|
|
18
|
+
/**
|
|
19
|
+
* The validator for a header class, compiled on first use and cached on that class. Compiling all
|
|
20
|
+
* ~190 schemas eagerly cost ~0.5 s at `new Codec()`; lazily, a codec only pays for the protocols it
|
|
21
|
+
* actually encodes.
|
|
22
|
+
*/
|
|
23
|
+
export declare function SchemaValidatorOf(headerClass: object, schema: ProtocolJSONSchema): ValidateFunction;
|
|
24
|
+
/**
|
|
25
|
+
* Ajv instancePath (JSON Pointer, '/goosePdu/allData/0/dataType') → the dotted field path the codec
|
|
26
|
+
* uses everywhere else for errors ('goosePdu.allData[0].dataType'). A 'required' /
|
|
27
|
+
* 'additionalProperties' error points at the parent object, so the named property is appended.
|
|
28
|
+
*/
|
|
29
|
+
export declare function AjvErrorFieldPath(error: ErrorObject): string;
|
|
30
|
+
/** Build the thrown error for a failed validation, carrying the layer, the field path and Ajv's errors. */
|
|
31
|
+
export declare function SchemaValidateErrorOf(layerId: string, ajvErrors: ErrorObject[] | null | undefined): CodecSchemaValidateError;
|