@aws-lambda-powertools/kafka 2.36.0 → 2.37.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.
Files changed (37) hide show
  1. package/lib/cjs/constants.d.ts +7 -1
  2. package/lib/cjs/constants.d.ts.map +1 -1
  3. package/lib/cjs/constants.js +8 -1
  4. package/lib/cjs/consumer.d.ts.map +1 -1
  5. package/lib/cjs/consumer.js +3 -1
  6. package/lib/cjs/deserializer/avro.d.ts.map +1 -1
  7. package/lib/cjs/deserializer/avro.js +42 -4
  8. package/lib/cjs/deserializer/json.d.ts.map +1 -1
  9. package/lib/cjs/deserializer/json.js +2 -4
  10. package/lib/cjs/deserializer/protobuf.d.ts.map +1 -1
  11. package/lib/cjs/deserializer/protobuf.js +19 -37
  12. package/lib/cjs/index.d.ts +1 -1
  13. package/lib/cjs/index.d.ts.map +1 -1
  14. package/lib/cjs/index.js +2 -1
  15. package/lib/cjs/types/index.d.ts +1 -1
  16. package/lib/cjs/types/index.d.ts.map +1 -1
  17. package/lib/cjs/types/types.d.ts +18 -4
  18. package/lib/cjs/types/types.d.ts.map +1 -1
  19. package/lib/esm/constants.d.ts +7 -1
  20. package/lib/esm/constants.d.ts.map +1 -1
  21. package/lib/esm/constants.js +7 -1
  22. package/lib/esm/consumer.d.ts.map +1 -1
  23. package/lib/esm/consumer.js +3 -1
  24. package/lib/esm/deserializer/avro.d.ts.map +1 -1
  25. package/lib/esm/deserializer/avro.js +42 -4
  26. package/lib/esm/deserializer/json.d.ts.map +1 -1
  27. package/lib/esm/deserializer/json.js +2 -4
  28. package/lib/esm/deserializer/protobuf.d.ts.map +1 -1
  29. package/lib/esm/deserializer/protobuf.js +19 -37
  30. package/lib/esm/index.d.ts +1 -1
  31. package/lib/esm/index.d.ts.map +1 -1
  32. package/lib/esm/index.js +1 -1
  33. package/lib/esm/types/index.d.ts +1 -1
  34. package/lib/esm/types/index.d.ts.map +1 -1
  35. package/lib/esm/types/types.d.ts +18 -4
  36. package/lib/esm/types/types.d.ts.map +1 -1
  37. package/package.json +4 -4
@@ -6,5 +6,11 @@ declare const SchemaType: {
6
6
  readonly AVRO: "avro";
7
7
  readonly PROTOBUF: "protobuf";
8
8
  };
9
- export { SchemaType };
9
+ /**
10
+ * Wire formats supported for Kafka payloads.
11
+ */
12
+ declare const WireFormat: {
13
+ readonly CONFLUENT: "confluent";
14
+ };
15
+ export { SchemaType, WireFormat };
10
16
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,UAAU;;;;CAIN,CAAC;AAEX,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,UAAU;;;;CAIN,CAAC;AAEX;;GAEG;AACH,QAAA,MAAM,UAAU;;CAEN,CAAC;AAEX,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SchemaType = void 0;
3
+ exports.WireFormat = exports.SchemaType = void 0;
4
4
  /**
5
5
  * Types of Kafka schema formats.
6
6
  */
@@ -10,3 +10,10 @@ const SchemaType = {
10
10
  PROTOBUF: 'protobuf',
11
11
  };
12
12
  exports.SchemaType = SchemaType;
13
+ /**
14
+ * Wire formats supported for Kafka payloads.
15
+ */
16
+ const WireFormat = {
17
+ CONFLUENT: 'confluent',
18
+ };
19
+ exports.WireFormat = WireFormat;
@@ -1 +1 @@
1
- {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../src/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAGzE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASnD,OAAO,KAAK,EAEV,eAAe,EAIf,QAAQ,EACR,YAAY,EAEb,MAAM,kBAAkB,CAAC;AA2M1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,QAAA,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,EACzB,SAAS,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EACrD,SAAS,YAAY,KACpB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAwB1D,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../src/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAGzE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASnD,OAAO,KAAK,EAEV,eAAe,EAIf,QAAQ,EACR,YAAY,EAEb,MAAM,kBAAkB,CAAC;AA6M1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,QAAA,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,EACzB,SAAS,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EACrD,SAAS,YAAY,KACpB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAwB1D,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -95,7 +95,9 @@ const deserialize = ({ value, deserializer, config, schemaMetadata, }) => {
95
95
  if (!config.schema) {
96
96
  throw new errors_js_1.KafkaConsumerMissingSchemaError('Schema string is required for avro deserialization');
97
97
  }
98
- return deserializer(value, config.schema);
98
+ return deserializer(value, config.schema, {
99
+ wireFormat: config.wireFormat,
100
+ });
99
101
  }
100
102
  /* v8 ignore else -- @preserve */
101
103
  if (config.type === 'protobuf') {
@@ -1 +1 @@
1
- {"version":3,"file":"avro.d.ts","sourceRoot":"","sources":["../../../src/deserializer/avro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,gBAAgB,CA2B5D,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"avro.d.ts","sourceRoot":"","sources":["../../../src/deserializer/avro.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAoC1D;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,gBAAgB,CA2C5D,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -34,8 +34,33 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createDeserializer = void 0;
37
+ const constants_js_1 = require("../constants.js");
37
38
  const errors_js_1 = require("../errors.js");
39
+ const CONFLUENT_HEADER_SIZE = 5;
40
+ const CONFLUENT_MAGIC_BYTE = 0x00;
38
41
  let deserializer;
42
+ /**
43
+ * Strip the Confluent wire format header (magic byte and 4-byte schema ID) from an Avro payload.
44
+ *
45
+ * @param buffer - The decoded Avro payload.
46
+ * @param wireFormat - The wire format of the payload. If not provided, the payload is returned as is.
47
+ */
48
+ const stripWireFormatHeader = (buffer, wireFormat) => {
49
+ if (wireFormat === undefined) {
50
+ return buffer;
51
+ }
52
+ // Guards untyped (plain JavaScript) callers
53
+ if (wireFormat !== constants_js_1.WireFormat.CONFLUENT) {
54
+ throw new errors_js_1.KafkaConsumerDeserializationError(`Unsupported Avro wire format: ${wireFormat}`);
55
+ }
56
+ if (buffer.length < CONFLUENT_HEADER_SIZE) {
57
+ throw new errors_js_1.KafkaConsumerDeserializationError('Invalid Confluent wire format: payload must contain a 5-byte header');
58
+ }
59
+ if (buffer[0] !== CONFLUENT_MAGIC_BYTE) {
60
+ throw new errors_js_1.KafkaConsumerDeserializationError('Invalid Confluent wire format: expected magic byte 0x00');
61
+ }
62
+ return buffer.subarray(CONFLUENT_HEADER_SIZE);
63
+ };
39
64
  /**
40
65
  * Create an Avro deserializer, importing `avro-js` on first use.
41
66
  *
@@ -55,15 +80,28 @@ const createDeserializer = async () => {
55
80
  *
56
81
  * @param data - The base64-encoded string representing the Avro binary data.
57
82
  * @param schema - The Avro schema as a JSON string.
83
+ * @param options - Deserialization options. If `options.wireFormat` is `confluent`, the 5-byte header is stripped.
58
84
  */
59
- deserializer = (data, schema) => {
85
+ deserializer = (data, schema, options) => {
86
+ const decodedPayload = Buffer.from(data, 'base64');
87
+ const buffer = stripWireFormatHeader(decodedPayload, options?.wireFormat);
88
+ let type;
89
+ try {
90
+ type = avro.parse(schema);
91
+ }
92
+ catch {
93
+ throw new errors_js_1.KafkaConsumerDeserializationError(`Failed to deserialize Avro message (base64-decoded payload length: ${decodedPayload.length} bytes): invalid Avro schema`);
94
+ }
60
95
  try {
61
- const type = avro.parse(schema);
62
- const buffer = Buffer.from(data, 'base64');
96
+ // Most Confluent serializers write top-level bytes without the Avro length prefix, so return them as-is
97
+ if (options?.wireFormat === constants_js_1.WireFormat.CONFLUENT &&
98
+ type.getName(true) === 'bytes') {
99
+ return buffer;
100
+ }
63
101
  return type.fromBuffer(buffer);
64
102
  }
65
103
  catch (error) {
66
- throw new errors_js_1.KafkaConsumerDeserializationError(`Failed to deserialize Avro message: ${error}, message: ${data}, schema: ${schema}`);
104
+ throw new errors_js_1.KafkaConsumerDeserializationError(`Failed to deserialize Avro message (base64-decoded payload length: ${decodedPayload.length} bytes): ${error}`);
67
105
  }
68
106
  };
69
107
  return deserializer;
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/deserializer/json.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,MAAM,MAAM,QAYhC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/deserializer/json.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,MAAM,MAAM,QAUhC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -15,10 +15,8 @@ const deserialize = (data) => {
15
15
  // we assume it's a JSON but it can also be a string, we don't know
16
16
  return JSON.parse(plainText);
17
17
  }
18
- catch (error) {
19
- // If JSON parsing fails, log the error and return the decoded string
20
- // in case we could not parse it we return the base64 decoded value
21
- console.error(`Failed to parse JSON from base64 value: ${data}`, error);
18
+ catch {
19
+ // If JSON parsing fails, return the base64 decoded value
22
20
  return plainText;
23
21
  }
24
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"protobuf.d.ts","sourceRoot":"","sources":["../../../src/deserializer/protobuf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,oBAAoB,CAuGhE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"protobuf.d.ts","sourceRoot":"","sources":["../../../src/deserializer/protobuf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,oBAAoB,CA4EhE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -52,24 +52,22 @@ const createDeserializer = async () => {
52
52
  const moduleName = 'protobufjs';
53
53
  const { BufferReader } = await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)));
54
54
  /**
55
- * Default order of varint types used in Protobuf to attempt deserializing Confluent Schema Registry messages.
56
- */
57
- const varintOrder = ['int32', 'sint32'];
58
- /**
59
- * Clip the Confluent Schema Registry buffer to remove the index bytes.
55
+ * Skip the Confluent Schema Registry message indexes at the start of the buffer.
60
56
  *
61
- * @param buffer - The buffer to clip.
62
- * @param intType - The type of the integer to read from the buffer, either 'int32' or 'sint32'.
57
+ * Confluent writes the indexes as an array of zigzag varints: the array length
58
+ * first, then each index. The common case `[0]` is written as a single `0` byte.
59
+ *
60
+ * @param buffer - The buffer to read from, positioned after the schema ID.
63
61
  */
64
- const clipConfluentSchemaRegistryBuffer = (buffer, intType) => {
62
+ const skipConfluentMessageIndexes = (buffer) => {
65
63
  const reader = new BufferReader(buffer);
66
- /**
67
- * Read the first varint byte to get the index count or 0.
68
- * Doing so, also advances the reader position to the next byte after the index count.
69
- */
70
- const indexCount = intType === 'int32' ? reader.int32() : reader.sint32();
71
- // Skip the index bytes
72
- reader.skip(indexCount);
64
+ const indexCount = reader.sint32();
65
+ if (indexCount < 0) {
66
+ throw new Error(`Invalid Confluent message index array length: ${indexCount}`);
67
+ }
68
+ for (let i = 0; i < indexCount; i++) {
69
+ reader.sint32();
70
+ }
73
71
  return reader;
74
72
  };
75
73
  /**
@@ -99,30 +97,14 @@ const createDeserializer = async () => {
99
97
  reader.uint32();
100
98
  return messageType.decode(reader);
101
99
  }
100
+ /**
101
+ * If schemaId is numeric, inferred from its length, we know it's coming from Confluent Schema Registry,
102
+ * so we need to remove the message index bytes before decoding.
103
+ */
104
+ return messageType.decode(skipConfluentMessageIndexes(buffer));
102
105
  }
103
106
  catch (error) {
104
- throw new errors_js_1.KafkaConsumerDeserializationError(`Failed to deserialize Protobuf message: ${error}, message: ${data}, messageType: ${JSON.stringify(messageType)}`);
105
- }
106
- /**
107
- * If schemaId is numeric, inferred from its length, we know it's coming from Confluent Schema Registry,
108
- * so we need to remove the MessageIndex bytes.
109
- * We don't know the type of the index, so we try both `int32` and `sint32`. If both fail, we throw an error.
110
- */
111
- try {
112
- const newBuffer = clipConfluentSchemaRegistryBuffer(buffer, varintOrder[0]);
113
- return messageType.decode(newBuffer);
114
- }
115
- catch (error) {
116
- try {
117
- const newBuffer = clipConfluentSchemaRegistryBuffer(buffer, varintOrder[1]);
118
- const decoded = messageType.decode(newBuffer);
119
- // swap varint order if the first attempt failed so we can use the correct one for subsequent messages
120
- varintOrder.reverse();
121
- return decoded;
122
- }
123
- catch {
124
- throw new errors_js_1.KafkaConsumerDeserializationError(`Failed to deserialize Protobuf message: ${error}, message: ${data}, messageType: ${JSON.stringify(messageType)}`);
125
- }
107
+ throw new errors_js_1.KafkaConsumerDeserializationError(`Failed to deserialize Protobuf message (base64-decoded payload length: ${buffer.length} bytes): ${error}`);
126
108
  }
127
109
  };
128
110
  return deserializer;
@@ -1,3 +1,3 @@
1
- export { SchemaType } from './constants.js';
1
+ export { SchemaType, WireFormat } from './constants.js';
2
2
  export { kafkaConsumer } from './consumer.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.kafkaConsumer = exports.SchemaType = void 0;
3
+ exports.kafkaConsumer = exports.WireFormat = exports.SchemaType = void 0;
4
4
  var constants_js_1 = require("./constants.js");
5
5
  Object.defineProperty(exports, "SchemaType", { enumerable: true, get: function () { return constants_js_1.SchemaType; } });
6
+ Object.defineProperty(exports, "WireFormat", { enumerable: true, get: function () { return constants_js_1.WireFormat; } });
6
7
  var consumer_js_1 = require("./consumer.js");
7
8
  Object.defineProperty(exports, "kafkaConsumer", { enumerable: true, get: function () { return consumer_js_1.kafkaConsumer; } });
@@ -1,2 +1,2 @@
1
- export type { ConsumerRecord, ConsumerRecords, MSKEvent, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, } from './types.js';
1
+ export type { ConsumerRecord, ConsumerRecords, MSKEvent, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, WireFormat, } from './types.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -1,10 +1,14 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import type { Reader } from 'protobufjs';
3
- import type { SchemaType as SchemaTypeMap } from '../constants.js';
3
+ import type { SchemaType as SchemaTypeMap, WireFormat as WireFormatMap } from '../constants.js';
4
4
  /**
5
5
  * Union type for supported schema types (JSON, Avro, Protobuf).
6
6
  */
7
7
  type SchemaType = (typeof SchemaTypeMap)[keyof typeof SchemaTypeMap];
8
+ /**
9
+ * Union type for supported wire formats.
10
+ */
11
+ type WireFormat = (typeof WireFormatMap)[keyof typeof WireFormatMap];
8
12
  /**
9
13
  * Metadata about the schema used for the field.
10
14
  */
@@ -115,6 +119,10 @@ type AvroConfig = {
115
119
  * Avro schema definition as a string
116
120
  */
117
121
  schema: string;
122
+ /**
123
+ * Optional wire format of the payload; `confluent` strips the 5-byte Confluent header before decoding.
124
+ */
125
+ wireFormat?: WireFormat;
118
126
  /**
119
127
  * Optional {@link https://github.com/standard-schema/standard-schema | Standard Schema} for runtime validation
120
128
  */
@@ -233,8 +241,14 @@ type MSKEvent = {
233
241
  type ProtobufMessage<T = unknown> = {
234
242
  decode(reader: Reader | Uint8Array, length?: number): T;
235
243
  };
236
- type Deserializer = (input: string | null, schema?: unknown, schemaMetadata?: SchemaMetadata) => unknown;
237
- type AvroDeserializer = (data: string, schema: string) => unknown;
244
+ type Deserializer = (input: string | null, schema?: unknown, options?: SchemaMetadata | AvroDeserializerOptions) => unknown;
245
+ type AvroDeserializerOptions = {
246
+ /**
247
+ * Wire format of the payload; `confluent` strips the 5-byte Confluent header before decoding.
248
+ */
249
+ wireFormat?: WireFormat;
250
+ };
251
+ type AvroDeserializer = (data: string, schema: string, options?: AvroDeserializerOptions) => unknown;
238
252
  type ProtobufDeserializer = <T>(data: string, messageType: ProtobufMessage<T>, schemaMetadata: SchemaMetadata) => T;
239
253
  type DeserializeOptions = {
240
254
  value: string | null;
@@ -242,5 +256,5 @@ type DeserializeOptions = {
242
256
  config?: SchemaConfigValue;
243
257
  schemaMetadata: SchemaMetadata;
244
258
  };
245
- export type { AvroDeserializer, ConsumerRecord, ConsumerRecords, DeserializeOptions, Deserializer, MSKEvent, ProtobufDeserializer, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, };
259
+ export type { AvroDeserializer, AvroDeserializerOptions, ConsumerRecord, ConsumerRecords, DeserializeOptions, Deserializer, MSKEvent, ProtobufDeserializer, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, WireFormat, };
246
260
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEnE;;GAEG;AACH,KAAK,UAAU,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAErE;;GAEG;AACH,KAAK,cAAc,GAAG;IACpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,IAAI;IAC1B;;OAEG;IACH,GAAG,EAAE,CAAC,CAAC;IACP;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAAE,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,eAAe,CAAC,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IACxC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;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CAAC;AAEF,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,UAAU,GACX,CAAC"}
@@ -6,5 +6,11 @@ declare const SchemaType: {
6
6
  readonly AVRO: "avro";
7
7
  readonly PROTOBUF: "protobuf";
8
8
  };
9
- export { SchemaType };
9
+ /**
10
+ * Wire formats supported for Kafka payloads.
11
+ */
12
+ declare const WireFormat: {
13
+ readonly CONFLUENT: "confluent";
14
+ };
15
+ export { SchemaType, WireFormat };
10
16
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,UAAU;;;;CAIN,CAAC;AAEX,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,UAAU;;;;CAIN,CAAC;AAEX;;GAEG;AACH,QAAA,MAAM,UAAU;;CAEN,CAAC;AAEX,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
@@ -6,4 +6,10 @@ const SchemaType = {
6
6
  AVRO: 'avro',
7
7
  PROTOBUF: 'protobuf',
8
8
  };
9
- export { SchemaType };
9
+ /**
10
+ * Wire formats supported for Kafka payloads.
11
+ */
12
+ const WireFormat = {
13
+ CONFLUENT: 'confluent',
14
+ };
15
+ export { SchemaType, WireFormat };
@@ -1 +1 @@
1
- {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../src/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAGzE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASnD,OAAO,KAAK,EAEV,eAAe,EAIf,QAAQ,EACR,YAAY,EAEb,MAAM,kBAAkB,CAAC;AA2M1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,QAAA,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,EACzB,SAAS,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EACrD,SAAS,YAAY,KACpB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAwB1D,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../src/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAGzE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASnD,OAAO,KAAK,EAEV,eAAe,EAIf,QAAQ,EACR,YAAY,EAEb,MAAM,kBAAkB,CAAC;AA6M1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,QAAA,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,EACzB,SAAS,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EACrD,SAAS,YAAY,KACpB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAwB1D,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -59,7 +59,9 @@ const deserialize = ({ value, deserializer, config, schemaMetadata, }) => {
59
59
  if (!config.schema) {
60
60
  throw new KafkaConsumerMissingSchemaError('Schema string is required for avro deserialization');
61
61
  }
62
- return deserializer(value, config.schema);
62
+ return deserializer(value, config.schema, {
63
+ wireFormat: config.wireFormat,
64
+ });
63
65
  }
64
66
  /* v8 ignore else -- @preserve */
65
67
  if (config.type === 'protobuf') {
@@ -1 +1 @@
1
- {"version":3,"file":"avro.d.ts","sourceRoot":"","sources":["../../../src/deserializer/avro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,gBAAgB,CA2B5D,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"avro.d.ts","sourceRoot":"","sources":["../../../src/deserializer/avro.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAoC1D;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,gBAAgB,CA2C5D,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,5 +1,30 @@
1
+ import { WireFormat } from '../constants.js';
1
2
  import { KafkaConsumerDeserializationError } from '../errors.js';
3
+ const CONFLUENT_HEADER_SIZE = 5;
4
+ const CONFLUENT_MAGIC_BYTE = 0x00;
2
5
  let deserializer;
6
+ /**
7
+ * Strip the Confluent wire format header (magic byte and 4-byte schema ID) from an Avro payload.
8
+ *
9
+ * @param buffer - The decoded Avro payload.
10
+ * @param wireFormat - The wire format of the payload. If not provided, the payload is returned as is.
11
+ */
12
+ const stripWireFormatHeader = (buffer, wireFormat) => {
13
+ if (wireFormat === undefined) {
14
+ return buffer;
15
+ }
16
+ // Guards untyped (plain JavaScript) callers
17
+ if (wireFormat !== WireFormat.CONFLUENT) {
18
+ throw new KafkaConsumerDeserializationError(`Unsupported Avro wire format: ${wireFormat}`);
19
+ }
20
+ if (buffer.length < CONFLUENT_HEADER_SIZE) {
21
+ throw new KafkaConsumerDeserializationError('Invalid Confluent wire format: payload must contain a 5-byte header');
22
+ }
23
+ if (buffer[0] !== CONFLUENT_MAGIC_BYTE) {
24
+ throw new KafkaConsumerDeserializationError('Invalid Confluent wire format: expected magic byte 0x00');
25
+ }
26
+ return buffer.subarray(CONFLUENT_HEADER_SIZE);
27
+ };
3
28
  /**
4
29
  * Create an Avro deserializer, importing `avro-js` on first use.
5
30
  *
@@ -19,15 +44,28 @@ const createDeserializer = async () => {
19
44
  *
20
45
  * @param data - The base64-encoded string representing the Avro binary data.
21
46
  * @param schema - The Avro schema as a JSON string.
47
+ * @param options - Deserialization options. If `options.wireFormat` is `confluent`, the 5-byte header is stripped.
22
48
  */
23
- deserializer = (data, schema) => {
49
+ deserializer = (data, schema, options) => {
50
+ const decodedPayload = Buffer.from(data, 'base64');
51
+ const buffer = stripWireFormatHeader(decodedPayload, options?.wireFormat);
52
+ let type;
53
+ try {
54
+ type = avro.parse(schema);
55
+ }
56
+ catch {
57
+ throw new KafkaConsumerDeserializationError(`Failed to deserialize Avro message (base64-decoded payload length: ${decodedPayload.length} bytes): invalid Avro schema`);
58
+ }
24
59
  try {
25
- const type = avro.parse(schema);
26
- const buffer = Buffer.from(data, 'base64');
60
+ // Most Confluent serializers write top-level bytes without the Avro length prefix, so return them as-is
61
+ if (options?.wireFormat === WireFormat.CONFLUENT &&
62
+ type.getName(true) === 'bytes') {
63
+ return buffer;
64
+ }
27
65
  return type.fromBuffer(buffer);
28
66
  }
29
67
  catch (error) {
30
- throw new KafkaConsumerDeserializationError(`Failed to deserialize Avro message: ${error}, message: ${data}, schema: ${schema}`);
68
+ throw new KafkaConsumerDeserializationError(`Failed to deserialize Avro message (base64-decoded payload length: ${decodedPayload.length} bytes): ${error}`);
31
69
  }
32
70
  };
33
71
  return deserializer;
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/deserializer/json.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,MAAM,MAAM,QAYhC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/deserializer/json.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,MAAM,MAAM,QAUhC,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -12,10 +12,8 @@ const deserialize = (data) => {
12
12
  // we assume it's a JSON but it can also be a string, we don't know
13
13
  return JSON.parse(plainText);
14
14
  }
15
- catch (error) {
16
- // If JSON parsing fails, log the error and return the decoded string
17
- // in case we could not parse it we return the base64 decoded value
18
- console.error(`Failed to parse JSON from base64 value: ${data}`, error);
15
+ catch {
16
+ // If JSON parsing fails, return the base64 decoded value
19
17
  return plainText;
20
18
  }
21
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"protobuf.d.ts","sourceRoot":"","sources":["../../../src/deserializer/protobuf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,oBAAoB,CAuGhE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"protobuf.d.ts","sourceRoot":"","sources":["../../../src/deserializer/protobuf.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,mBAAmB,CAAC;AAI3B;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,QAAa,OAAO,CAAC,oBAAoB,CA4EhE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -16,24 +16,22 @@ const createDeserializer = async () => {
16
16
  const moduleName = 'protobufjs';
17
17
  const { BufferReader } = await import(moduleName);
18
18
  /**
19
- * Default order of varint types used in Protobuf to attempt deserializing Confluent Schema Registry messages.
20
- */
21
- const varintOrder = ['int32', 'sint32'];
22
- /**
23
- * Clip the Confluent Schema Registry buffer to remove the index bytes.
19
+ * Skip the Confluent Schema Registry message indexes at the start of the buffer.
24
20
  *
25
- * @param buffer - The buffer to clip.
26
- * @param intType - The type of the integer to read from the buffer, either 'int32' or 'sint32'.
21
+ * Confluent writes the indexes as an array of zigzag varints: the array length
22
+ * first, then each index. The common case `[0]` is written as a single `0` byte.
23
+ *
24
+ * @param buffer - The buffer to read from, positioned after the schema ID.
27
25
  */
28
- const clipConfluentSchemaRegistryBuffer = (buffer, intType) => {
26
+ const skipConfluentMessageIndexes = (buffer) => {
29
27
  const reader = new BufferReader(buffer);
30
- /**
31
- * Read the first varint byte to get the index count or 0.
32
- * Doing so, also advances the reader position to the next byte after the index count.
33
- */
34
- const indexCount = intType === 'int32' ? reader.int32() : reader.sint32();
35
- // Skip the index bytes
36
- reader.skip(indexCount);
28
+ const indexCount = reader.sint32();
29
+ if (indexCount < 0) {
30
+ throw new Error(`Invalid Confluent message index array length: ${indexCount}`);
31
+ }
32
+ for (let i = 0; i < indexCount; i++) {
33
+ reader.sint32();
34
+ }
37
35
  return reader;
38
36
  };
39
37
  /**
@@ -63,30 +61,14 @@ const createDeserializer = async () => {
63
61
  reader.uint32();
64
62
  return messageType.decode(reader);
65
63
  }
64
+ /**
65
+ * If schemaId is numeric, inferred from its length, we know it's coming from Confluent Schema Registry,
66
+ * so we need to remove the message index bytes before decoding.
67
+ */
68
+ return messageType.decode(skipConfluentMessageIndexes(buffer));
66
69
  }
67
70
  catch (error) {
68
- throw new KafkaConsumerDeserializationError(`Failed to deserialize Protobuf message: ${error}, message: ${data}, messageType: ${JSON.stringify(messageType)}`);
69
- }
70
- /**
71
- * If schemaId is numeric, inferred from its length, we know it's coming from Confluent Schema Registry,
72
- * so we need to remove the MessageIndex bytes.
73
- * We don't know the type of the index, so we try both `int32` and `sint32`. If both fail, we throw an error.
74
- */
75
- try {
76
- const newBuffer = clipConfluentSchemaRegistryBuffer(buffer, varintOrder[0]);
77
- return messageType.decode(newBuffer);
78
- }
79
- catch (error) {
80
- try {
81
- const newBuffer = clipConfluentSchemaRegistryBuffer(buffer, varintOrder[1]);
82
- const decoded = messageType.decode(newBuffer);
83
- // swap varint order if the first attempt failed so we can use the correct one for subsequent messages
84
- varintOrder.reverse();
85
- return decoded;
86
- }
87
- catch {
88
- throw new KafkaConsumerDeserializationError(`Failed to deserialize Protobuf message: ${error}, message: ${data}, messageType: ${JSON.stringify(messageType)}`);
89
- }
71
+ throw new KafkaConsumerDeserializationError(`Failed to deserialize Protobuf message (base64-decoded payload length: ${buffer.length} bytes): ${error}`);
90
72
  }
91
73
  };
92
74
  return deserializer;
@@ -1,3 +1,3 @@
1
- export { SchemaType } from './constants.js';
1
+ export { SchemaType, WireFormat } from './constants.js';
2
2
  export { kafkaConsumer } from './consumer.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
package/lib/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { SchemaType } from './constants.js';
1
+ export { SchemaType, WireFormat } from './constants.js';
2
2
  export { kafkaConsumer } from './consumer.js';
@@ -1,2 +1,2 @@
1
- export type { ConsumerRecord, ConsumerRecords, MSKEvent, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, } from './types.js';
1
+ export type { ConsumerRecord, ConsumerRecords, MSKEvent, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, WireFormat, } from './types.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,eAAe,EACf,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC"}
@@ -1,10 +1,14 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import type { Reader } from 'protobufjs';
3
- import type { SchemaType as SchemaTypeMap } from '../constants.js';
3
+ import type { SchemaType as SchemaTypeMap, WireFormat as WireFormatMap } from '../constants.js';
4
4
  /**
5
5
  * Union type for supported schema types (JSON, Avro, Protobuf).
6
6
  */
7
7
  type SchemaType = (typeof SchemaTypeMap)[keyof typeof SchemaTypeMap];
8
+ /**
9
+ * Union type for supported wire formats.
10
+ */
11
+ type WireFormat = (typeof WireFormatMap)[keyof typeof WireFormatMap];
8
12
  /**
9
13
  * Metadata about the schema used for the field.
10
14
  */
@@ -115,6 +119,10 @@ type AvroConfig = {
115
119
  * Avro schema definition as a string
116
120
  */
117
121
  schema: string;
122
+ /**
123
+ * Optional wire format of the payload; `confluent` strips the 5-byte Confluent header before decoding.
124
+ */
125
+ wireFormat?: WireFormat;
118
126
  /**
119
127
  * Optional {@link https://github.com/standard-schema/standard-schema | Standard Schema} for runtime validation
120
128
  */
@@ -233,8 +241,14 @@ type MSKEvent = {
233
241
  type ProtobufMessage<T = unknown> = {
234
242
  decode(reader: Reader | Uint8Array, length?: number): T;
235
243
  };
236
- type Deserializer = (input: string | null, schema?: unknown, schemaMetadata?: SchemaMetadata) => unknown;
237
- type AvroDeserializer = (data: string, schema: string) => unknown;
244
+ type Deserializer = (input: string | null, schema?: unknown, options?: SchemaMetadata | AvroDeserializerOptions) => unknown;
245
+ type AvroDeserializerOptions = {
246
+ /**
247
+ * Wire format of the payload; `confluent` strips the 5-byte Confluent header before decoding.
248
+ */
249
+ wireFormat?: WireFormat;
250
+ };
251
+ type AvroDeserializer = (data: string, schema: string, options?: AvroDeserializerOptions) => unknown;
238
252
  type ProtobufDeserializer = <T>(data: string, messageType: ProtobufMessage<T>, schemaMetadata: SchemaMetadata) => T;
239
253
  type DeserializeOptions = {
240
254
  value: string | null;
@@ -242,5 +256,5 @@ type DeserializeOptions = {
242
256
  config?: SchemaConfigValue;
243
257
  schemaMetadata: SchemaMetadata;
244
258
  };
245
- export type { AvroDeserializer, ConsumerRecord, ConsumerRecords, DeserializeOptions, Deserializer, MSKEvent, ProtobufDeserializer, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, };
259
+ export type { AvroDeserializer, AvroDeserializerOptions, ConsumerRecord, ConsumerRecords, DeserializeOptions, Deserializer, MSKEvent, ProtobufDeserializer, ProtobufMessage, Record, RecordHeader, SchemaConfig, SchemaConfigValue, SchemaMetadata, SchemaType, WireFormat, };
246
260
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEnE;;GA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,GAAG,CAAC,CAAC;CACzD,CAAC;AAEF,KAAK,YAAY,GAAG,CAClB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,MAAM,CAAC,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,cAAc,GAAG,uBAAuB,KAC/C,OAAO,CAAC;AAEb,KAAK,uBAAuB,GAAG;IAC7B;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG,CACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,uBAAuB,KAC9B,OAAO,CAAC;AAEb,KAAK,oBAAoB,GAAG,CAAC,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,EAC/B,cAAc,EAAE,cAAc,KAC3B,CAAC,CAAC;AAEP,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,UAAU,GACX,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-lambda-powertools/kafka",
3
- "version": "2.36.0",
3
+ "version": "2.37.0",
4
4
  "description": "Utility to easily handle message deserialization and parsing of Kafka events in AWS Lambda functions",
5
5
  "author": {
6
6
  "name": "Amazon Web Services",
@@ -27,13 +27,13 @@
27
27
  "nodejs"
28
28
  ],
29
29
  "dependencies": {
30
- "@aws-lambda-powertools/commons": "2.36.0",
30
+ "@aws-lambda-powertools/commons": "2.37.0",
31
31
  "@standard-schema/spec": "^1.1.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "arktype": "^2.2.7",
34
+ "arktype": "^2.2.9",
35
35
  "avro-js": "^1.12.1",
36
- "protobufjs": "^8.8.0",
36
+ "protobufjs": "^8.8.1",
37
37
  "valibot": "^1.5.0",
38
38
  "zod": "^3.25.0 || ^4.0.0"
39
39
  },