kafka-ts
Version:
**KafkaTS** is a Apache Kafka client library for Node.js. It provides both a low-level API for communicating directly with the Apache Kafka cluster and high-level APIs for publishing and subscribing to Kafka topics.
64 lines (61 loc) • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SASL_AUTHENTICATE = void 0;
const api_1 = require("../utils/api");
const error_1 = require("../utils/error");
/*
SaslAuthenticate Request (Version: 0) => auth_bytes
auth_bytes => BYTES
SaslAuthenticate Response (Version: 0) => error_code error_message auth_bytes
error_code => INT16
error_message => NULLABLE_STRING
auth_bytes => BYTES
*/
const SASL_AUTHENTICATE_V0 = (0, api_1.createApi)({
apiKey: 36,
apiVersion: 0,
requestHeaderVersion: 1,
responseHeaderVersion: 0,
request: (encoder, data) => encoder.writeBytes(data.authBytes),
response: (decoder) => {
const result = {
errorCode: decoder.readInt16(),
errorMessage: decoder.readString(),
authBytes: decoder.readBytes(),
sessionLifetimeMs: BigInt(0),
tags: {},
};
if (result.errorCode)
throw new error_1.KafkaTSApiError(result.errorCode, result.errorMessage, result);
return result;
},
});
/*
SaslAuthenticate Request (Version: 2) => auth_bytes _tagged_fields
auth_bytes => COMPACT_BYTES
SaslAuthenticate Response (Version: 2) => error_code error_message auth_bytes session_lifetime_ms _tagged_fields
error_code => INT16
error_message => COMPACT_NULLABLE_STRING
auth_bytes => COMPACT_BYTES
session_lifetime_ms => INT64
*/
exports.SASL_AUTHENTICATE = (0, api_1.createApi)({
apiKey: 36,
apiVersion: 2,
fallback: SASL_AUTHENTICATE_V0,
requestHeaderVersion: 2,
responseHeaderVersion: 1,
request: (encoder, data) => encoder.writeCompactBytes(data.authBytes).writeTagBuffer(),
response: (decoder) => {
const result = {
errorCode: decoder.readInt16(),
errorMessage: decoder.readCompactString(),
authBytes: decoder.readCompactBytes(),
sessionLifetimeMs: decoder.readInt64(),
tags: decoder.readTagBuffer(),
};
if (result.errorCode)
throw new error_1.KafkaTSApiError(result.errorCode, result.errorMessage, result);
return result;
},
});