UNPKG

amqplib

Version:

An AMQP 0-9-1 (e.g., RabbitMQ) library and client.

1,525 lines (1,455 loc) 137 kB
/** @preserve This file is generated by the script * ../bin/generate-defs.js, which is not in general included in a * distribution, but is available in the source repository e.g. at * https://github.com/squaremo/amqp.node/ */ "use strict"; function decodeBasicQos(buffer) { var val, offset = 0, fields = { prefetchSize: void 0, prefetchCount: void 0, global: void 0 }; val = buffer.readUInt32BE(offset); offset += 4; fields.prefetchSize = val; val = buffer.readUInt16BE(offset); offset += 2; fields.prefetchCount = val; val = !!(1 & buffer[offset]); fields.global = val; return fields; } function encodeBasicQos(channel, fields) { var offset = 0, val = null, bits = 0, buffer = Buffer.alloc(19); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932170, 7); offset = 11; val = fields.prefetchSize; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'prefetchSize' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt32BE(val, offset); offset += 4; val = fields.prefetchCount; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'prefetchCount' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.global; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicQosOk(buffer) { return {}; } function encodeBasicQosOk(channel, fields) { var offset = 0, buffer = Buffer.alloc(12); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932171, 7); offset = 11; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicConsume(buffer) { var val, len, offset = 0, fields = { ticket: void 0, queue: void 0, consumerTag: void 0, noLocal: void 0, noAck: void 0, exclusive: void 0, nowait: void 0, arguments: void 0 }; val = buffer.readUInt16BE(offset); offset += 2; fields.ticket = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.queue = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.consumerTag = val; val = !!(1 & buffer[offset]); fields.noLocal = val; val = !!(2 & buffer[offset]); fields.noAck = val; val = !!(4 & buffer[offset]); fields.exclusive = val; val = !!(8 & buffer[offset]); fields.nowait = val; offset++; len = buffer.readUInt32BE(offset); offset += 4; val = decodeFields(buffer.subarray(offset, offset + len)); offset += len; fields.arguments = val; return fields; } function encodeBasicConsume(channel, fields) { var len, offset = 0, val = null, bits = 0, varyingSize = 0, scratchOffset = 0; val = fields.queue; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)"); var queue_len = Buffer.byteLength(val, "utf8"); varyingSize += queue_len; val = fields.consumerTag; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)"); var consumerTag_len = Buffer.byteLength(val, "utf8"); varyingSize += consumerTag_len; val = fields.arguments; if (void 0 === val) val = {}; else if ("object" != typeof val) throw new TypeError("Field 'arguments' is the wrong type; must be an object"); len = encodeTable(SCRATCH, val, scratchOffset); var arguments_encoded = SCRATCH.slice(scratchOffset, scratchOffset + len); scratchOffset += len; varyingSize += arguments_encoded.length; var buffer = Buffer.alloc(17 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932180, 7); offset = 11; val = fields.ticket; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.queue; void 0 === val && (val = ""); buffer[offset] = queue_len; offset++; buffer.write(val, offset, "utf8"); offset += queue_len; val = fields.consumerTag; void 0 === val && (val = ""); buffer[offset] = consumerTag_len; offset++; buffer.write(val, offset, "utf8"); offset += consumerTag_len; val = fields.noLocal; void 0 === val && (val = !1); val && (bits += 1); val = fields.noAck; void 0 === val && (val = !1); val && (bits += 2); val = fields.exclusive; void 0 === val && (val = !1); val && (bits += 4); val = fields.nowait; void 0 === val && (val = !1); val && (bits += 8); buffer[offset] = bits; offset++; bits = 0; offset += arguments_encoded.copy(buffer, offset); buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicConsumeOk(buffer) { var val, len, offset = 0, fields = { consumerTag: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.consumerTag = val; return fields; } function encodeBasicConsumeOk(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.consumerTag; if (void 0 === val) throw new Error("Missing value for mandatory field 'consumerTag'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)"); var consumerTag_len = Buffer.byteLength(val, "utf8"); varyingSize += consumerTag_len; var buffer = Buffer.alloc(13 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932181, 7); offset = 11; val = fields.consumerTag; void 0 === val && (val = void 0); buffer[offset] = consumerTag_len; offset++; buffer.write(val, offset, "utf8"); offset += consumerTag_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicCancel(buffer) { var val, len, offset = 0, fields = { consumerTag: void 0, nowait: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.consumerTag = val; val = !!(1 & buffer[offset]); fields.nowait = val; return fields; } function encodeBasicCancel(channel, fields) { var offset = 0, val = null, bits = 0, varyingSize = 0; val = fields.consumerTag; if (void 0 === val) throw new Error("Missing value for mandatory field 'consumerTag'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)"); var consumerTag_len = Buffer.byteLength(val, "utf8"); varyingSize += consumerTag_len; var buffer = Buffer.alloc(14 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932190, 7); offset = 11; val = fields.consumerTag; void 0 === val && (val = void 0); buffer[offset] = consumerTag_len; offset++; buffer.write(val, offset, "utf8"); offset += consumerTag_len; val = fields.nowait; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicCancelOk(buffer) { var val, len, offset = 0, fields = { consumerTag: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.consumerTag = val; return fields; } function encodeBasicCancelOk(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.consumerTag; if (void 0 === val) throw new Error("Missing value for mandatory field 'consumerTag'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)"); var consumerTag_len = Buffer.byteLength(val, "utf8"); varyingSize += consumerTag_len; var buffer = Buffer.alloc(13 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932191, 7); offset = 11; val = fields.consumerTag; void 0 === val && (val = void 0); buffer[offset] = consumerTag_len; offset++; buffer.write(val, offset, "utf8"); offset += consumerTag_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicPublish(buffer) { var val, len, offset = 0, fields = { ticket: void 0, exchange: void 0, routingKey: void 0, mandatory: void 0, immediate: void 0 }; val = buffer.readUInt16BE(offset); offset += 2; fields.ticket = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.exchange = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.routingKey = val; val = !!(1 & buffer[offset]); fields.mandatory = val; val = !!(2 & buffer[offset]); fields.immediate = val; return fields; } function encodeBasicPublish(channel, fields) { var offset = 0, val = null, bits = 0, varyingSize = 0; val = fields.exchange; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)"); var exchange_len = Buffer.byteLength(val, "utf8"); varyingSize += exchange_len; val = fields.routingKey; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)"); var routingKey_len = Buffer.byteLength(val, "utf8"); varyingSize += routingKey_len; var buffer = Buffer.alloc(17 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932200, 7); offset = 11; val = fields.ticket; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.exchange; void 0 === val && (val = ""); buffer[offset] = exchange_len; offset++; buffer.write(val, offset, "utf8"); offset += exchange_len; val = fields.routingKey; void 0 === val && (val = ""); buffer[offset] = routingKey_len; offset++; buffer.write(val, offset, "utf8"); offset += routingKey_len; val = fields.mandatory; void 0 === val && (val = !1); val && (bits += 1); val = fields.immediate; void 0 === val && (val = !1); val && (bits += 2); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicReturn(buffer) { var val, len, offset = 0, fields = { replyCode: void 0, replyText: void 0, exchange: void 0, routingKey: void 0 }; val = buffer.readUInt16BE(offset); offset += 2; fields.replyCode = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.replyText = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.exchange = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.routingKey = val; return fields; } function encodeBasicReturn(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.replyText; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)"); var replyText_len = Buffer.byteLength(val, "utf8"); varyingSize += replyText_len; val = fields.exchange; if (void 0 === val) throw new Error("Missing value for mandatory field 'exchange'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)"); var exchange_len = Buffer.byteLength(val, "utf8"); varyingSize += exchange_len; val = fields.routingKey; if (void 0 === val) throw new Error("Missing value for mandatory field 'routingKey'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)"); var routingKey_len = Buffer.byteLength(val, "utf8"); varyingSize += routingKey_len; var buffer = Buffer.alloc(17 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932210, 7); offset = 11; val = fields.replyCode; if (void 0 === val) throw new Error("Missing value for mandatory field 'replyCode'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.replyText; void 0 === val && (val = ""); buffer[offset] = replyText_len; offset++; buffer.write(val, offset, "utf8"); offset += replyText_len; val = fields.exchange; void 0 === val && (val = void 0); buffer[offset] = exchange_len; offset++; buffer.write(val, offset, "utf8"); offset += exchange_len; val = fields.routingKey; void 0 === val && (val = void 0); buffer[offset] = routingKey_len; offset++; buffer.write(val, offset, "utf8"); offset += routingKey_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicDeliver(buffer) { var val, len, offset = 0, fields = { consumerTag: void 0, deliveryTag: void 0, redelivered: void 0, exchange: void 0, routingKey: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.consumerTag = val; val = ints.readUInt64BE(buffer, offset); offset += 8; fields.deliveryTag = val; val = !!(1 & buffer[offset]); fields.redelivered = val; offset++; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.exchange = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.routingKey = val; return fields; } function encodeBasicDeliver(channel, fields) { var offset = 0, val = null, bits = 0, varyingSize = 0; val = fields.consumerTag; if (void 0 === val) throw new Error("Missing value for mandatory field 'consumerTag'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'consumerTag' is the wrong type; must be a string (up to 255 chars)"); var consumerTag_len = Buffer.byteLength(val, "utf8"); varyingSize += consumerTag_len; val = fields.exchange; if (void 0 === val) throw new Error("Missing value for mandatory field 'exchange'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)"); var exchange_len = Buffer.byteLength(val, "utf8"); varyingSize += exchange_len; val = fields.routingKey; if (void 0 === val) throw new Error("Missing value for mandatory field 'routingKey'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)"); var routingKey_len = Buffer.byteLength(val, "utf8"); varyingSize += routingKey_len; var buffer = Buffer.alloc(24 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932220, 7); offset = 11; val = fields.consumerTag; void 0 === val && (val = void 0); buffer[offset] = consumerTag_len; offset++; buffer.write(val, offset, "utf8"); offset += consumerTag_len; val = fields.deliveryTag; if (void 0 === val) throw new Error("Missing value for mandatory field 'deliveryTag'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)"); ints.writeUInt64BE(buffer, val, offset); offset += 8; val = fields.redelivered; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; bits = 0; val = fields.exchange; void 0 === val && (val = void 0); buffer[offset] = exchange_len; offset++; buffer.write(val, offset, "utf8"); offset += exchange_len; val = fields.routingKey; void 0 === val && (val = void 0); buffer[offset] = routingKey_len; offset++; buffer.write(val, offset, "utf8"); offset += routingKey_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicGet(buffer) { var val, len, offset = 0, fields = { ticket: void 0, queue: void 0, noAck: void 0 }; val = buffer.readUInt16BE(offset); offset += 2; fields.ticket = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.queue = val; val = !!(1 & buffer[offset]); fields.noAck = val; return fields; } function encodeBasicGet(channel, fields) { var offset = 0, val = null, bits = 0, varyingSize = 0; val = fields.queue; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'queue' is the wrong type; must be a string (up to 255 chars)"); var queue_len = Buffer.byteLength(val, "utf8"); varyingSize += queue_len; var buffer = Buffer.alloc(16 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932230, 7); offset = 11; val = fields.ticket; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'ticket' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.queue; void 0 === val && (val = ""); buffer[offset] = queue_len; offset++; buffer.write(val, offset, "utf8"); offset += queue_len; val = fields.noAck; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicGetOk(buffer) { var val, len, offset = 0, fields = { deliveryTag: void 0, redelivered: void 0, exchange: void 0, routingKey: void 0, messageCount: void 0 }; val = ints.readUInt64BE(buffer, offset); offset += 8; fields.deliveryTag = val; val = !!(1 & buffer[offset]); fields.redelivered = val; offset++; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.exchange = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.routingKey = val; val = buffer.readUInt32BE(offset); offset += 4; fields.messageCount = val; return fields; } function encodeBasicGetOk(channel, fields) { var offset = 0, val = null, bits = 0, varyingSize = 0; val = fields.exchange; if (void 0 === val) throw new Error("Missing value for mandatory field 'exchange'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'exchange' is the wrong type; must be a string (up to 255 chars)"); var exchange_len = Buffer.byteLength(val, "utf8"); varyingSize += exchange_len; val = fields.routingKey; if (void 0 === val) throw new Error("Missing value for mandatory field 'routingKey'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'routingKey' is the wrong type; must be a string (up to 255 chars)"); var routingKey_len = Buffer.byteLength(val, "utf8"); varyingSize += routingKey_len; var buffer = Buffer.alloc(27 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932231, 7); offset = 11; val = fields.deliveryTag; if (void 0 === val) throw new Error("Missing value for mandatory field 'deliveryTag'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)"); ints.writeUInt64BE(buffer, val, offset); offset += 8; val = fields.redelivered; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; bits = 0; val = fields.exchange; void 0 === val && (val = void 0); buffer[offset] = exchange_len; offset++; buffer.write(val, offset, "utf8"); offset += exchange_len; val = fields.routingKey; void 0 === val && (val = void 0); buffer[offset] = routingKey_len; offset++; buffer.write(val, offset, "utf8"); offset += routingKey_len; val = fields.messageCount; if (void 0 === val) throw new Error("Missing value for mandatory field 'messageCount'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'messageCount' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt32BE(val, offset); offset += 4; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicGetEmpty(buffer) { var val, len, offset = 0, fields = { clusterId: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.clusterId = val; return fields; } function encodeBasicGetEmpty(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.clusterId; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'clusterId' is the wrong type; must be a string (up to 255 chars)"); var clusterId_len = Buffer.byteLength(val, "utf8"); varyingSize += clusterId_len; var buffer = Buffer.alloc(13 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932232, 7); offset = 11; val = fields.clusterId; void 0 === val && (val = ""); buffer[offset] = clusterId_len; offset++; buffer.write(val, offset, "utf8"); offset += clusterId_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicAck(buffer) { var val, offset = 0, fields = { deliveryTag: void 0, multiple: void 0 }; val = ints.readUInt64BE(buffer, offset); offset += 8; fields.deliveryTag = val; val = !!(1 & buffer[offset]); fields.multiple = val; return fields; } function encodeBasicAck(channel, fields) { var offset = 0, val = null, bits = 0, buffer = Buffer.alloc(21); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932240, 7); offset = 11; val = fields.deliveryTag; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)"); ints.writeUInt64BE(buffer, val, offset); offset += 8; val = fields.multiple; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicReject(buffer) { var val, offset = 0, fields = { deliveryTag: void 0, requeue: void 0 }; val = ints.readUInt64BE(buffer, offset); offset += 8; fields.deliveryTag = val; val = !!(1 & buffer[offset]); fields.requeue = val; return fields; } function encodeBasicReject(channel, fields) { var offset = 0, val = null, bits = 0, buffer = Buffer.alloc(21); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932250, 7); offset = 11; val = fields.deliveryTag; if (void 0 === val) throw new Error("Missing value for mandatory field 'deliveryTag'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)"); ints.writeUInt64BE(buffer, val, offset); offset += 8; val = fields.requeue; void 0 === val && (val = !0); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicRecoverAsync(buffer) { var val, fields = { requeue: void 0 }; val = !!(1 & buffer[0]); fields.requeue = val; return fields; } function encodeBasicRecoverAsync(channel, fields) { var offset = 0, val = null, bits = 0, buffer = Buffer.alloc(13); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932260, 7); offset = 11; val = fields.requeue; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicRecover(buffer) { var val, fields = { requeue: void 0 }; val = !!(1 & buffer[0]); fields.requeue = val; return fields; } function encodeBasicRecover(channel, fields) { var offset = 0, val = null, bits = 0, buffer = Buffer.alloc(13); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932270, 7); offset = 11; val = fields.requeue; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicRecoverOk(buffer) { return {}; } function encodeBasicRecoverOk(channel, fields) { var offset = 0, buffer = Buffer.alloc(12); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932271, 7); offset = 11; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeBasicNack(buffer) { var val, offset = 0, fields = { deliveryTag: void 0, multiple: void 0, requeue: void 0 }; val = ints.readUInt64BE(buffer, offset); offset += 8; fields.deliveryTag = val; val = !!(1 & buffer[offset]); fields.multiple = val; val = !!(2 & buffer[offset]); fields.requeue = val; return fields; } function encodeBasicNack(channel, fields) { var offset = 0, val = null, bits = 0, buffer = Buffer.alloc(21); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(3932280, 7); offset = 11; val = fields.deliveryTag; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'deliveryTag' is the wrong type; must be a number (but not NaN)"); ints.writeUInt64BE(buffer, val, offset); offset += 8; val = fields.multiple; void 0 === val && (val = !1); val && (bits += 1); val = fields.requeue; void 0 === val && (val = !0); val && (bits += 2); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionStart(buffer) { var val, len, offset = 0, fields = { versionMajor: void 0, versionMinor: void 0, serverProperties: void 0, mechanisms: void 0, locales: void 0 }; val = buffer[offset]; offset++; fields.versionMajor = val; val = buffer[offset]; offset++; fields.versionMinor = val; len = buffer.readUInt32BE(offset); offset += 4; val = decodeFields(buffer.subarray(offset, offset + len)); offset += len; fields.serverProperties = val; len = buffer.readUInt32BE(offset); offset += 4; val = buffer.subarray(offset, offset + len); offset += len; fields.mechanisms = val; len = buffer.readUInt32BE(offset); offset += 4; val = buffer.subarray(offset, offset + len); offset += len; fields.locales = val; return fields; } function encodeConnectionStart(channel, fields) { var len, offset = 0, val = null, varyingSize = 0, scratchOffset = 0; val = fields.serverProperties; if (void 0 === val) throw new Error("Missing value for mandatory field 'serverProperties'"); if ("object" != typeof val) throw new TypeError("Field 'serverProperties' is the wrong type; must be an object"); len = encodeTable(SCRATCH, val, scratchOffset); var serverProperties_encoded = SCRATCH.slice(scratchOffset, scratchOffset + len); scratchOffset += len; varyingSize += serverProperties_encoded.length; val = fields.mechanisms; if (void 0 === val) val = Buffer.from("PLAIN"); else if (!Buffer.isBuffer(val)) throw new TypeError("Field 'mechanisms' is the wrong type; must be a Buffer"); varyingSize += val.length; val = fields.locales; if (void 0 === val) val = Buffer.from("en_US"); else if (!Buffer.isBuffer(val)) throw new TypeError("Field 'locales' is the wrong type; must be a Buffer"); varyingSize += val.length; var buffer = Buffer.alloc(22 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655370, 7); offset = 11; val = fields.versionMajor; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'versionMajor' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt8(val, offset); offset++; val = fields.versionMinor; if (void 0 === val) val = 9; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'versionMinor' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt8(val, offset); offset++; offset += serverProperties_encoded.copy(buffer, offset); val = fields.mechanisms; void 0 === val && (val = Buffer.from("PLAIN")); len = val.length; buffer.writeUInt32BE(len, offset); offset += 4; val.copy(buffer, offset); offset += len; val = fields.locales; void 0 === val && (val = Buffer.from("en_US")); len = val.length; buffer.writeUInt32BE(len, offset); offset += 4; val.copy(buffer, offset); offset += len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionStartOk(buffer) { var val, len, offset = 0, fields = { clientProperties: void 0, mechanism: void 0, response: void 0, locale: void 0 }; len = buffer.readUInt32BE(offset); offset += 4; val = decodeFields(buffer.subarray(offset, offset + len)); offset += len; fields.clientProperties = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.mechanism = val; len = buffer.readUInt32BE(offset); offset += 4; val = buffer.subarray(offset, offset + len); offset += len; fields.response = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.locale = val; return fields; } function encodeConnectionStartOk(channel, fields) { var len, offset = 0, val = null, varyingSize = 0, scratchOffset = 0; val = fields.clientProperties; if (void 0 === val) throw new Error("Missing value for mandatory field 'clientProperties'"); if ("object" != typeof val) throw new TypeError("Field 'clientProperties' is the wrong type; must be an object"); len = encodeTable(SCRATCH, val, scratchOffset); var clientProperties_encoded = SCRATCH.slice(scratchOffset, scratchOffset + len); scratchOffset += len; varyingSize += clientProperties_encoded.length; val = fields.mechanism; if (void 0 === val) val = "PLAIN"; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'mechanism' is the wrong type; must be a string (up to 255 chars)"); var mechanism_len = Buffer.byteLength(val, "utf8"); varyingSize += mechanism_len; val = fields.response; if (void 0 === val) throw new Error("Missing value for mandatory field 'response'"); if (!Buffer.isBuffer(val)) throw new TypeError("Field 'response' is the wrong type; must be a Buffer"); varyingSize += val.length; val = fields.locale; if (void 0 === val) val = "en_US"; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'locale' is the wrong type; must be a string (up to 255 chars)"); var locale_len = Buffer.byteLength(val, "utf8"); varyingSize += locale_len; var buffer = Buffer.alloc(18 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655371, 7); offset = 11; offset += clientProperties_encoded.copy(buffer, offset); val = fields.mechanism; void 0 === val && (val = "PLAIN"); buffer[offset] = mechanism_len; offset++; buffer.write(val, offset, "utf8"); offset += mechanism_len; val = fields.response; void 0 === val && (val = Buffer.from(void 0)); len = val.length; buffer.writeUInt32BE(len, offset); offset += 4; val.copy(buffer, offset); offset += len; val = fields.locale; void 0 === val && (val = "en_US"); buffer[offset] = locale_len; offset++; buffer.write(val, offset, "utf8"); offset += locale_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionSecure(buffer) { var val, len, offset = 0, fields = { challenge: void 0 }; len = buffer.readUInt32BE(offset); offset += 4; val = buffer.subarray(offset, offset + len); offset += len; fields.challenge = val; return fields; } function encodeConnectionSecure(channel, fields) { var len, offset = 0, val = null, varyingSize = 0; val = fields.challenge; if (void 0 === val) throw new Error("Missing value for mandatory field 'challenge'"); if (!Buffer.isBuffer(val)) throw new TypeError("Field 'challenge' is the wrong type; must be a Buffer"); varyingSize += val.length; var buffer = Buffer.alloc(16 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655380, 7); offset = 11; val = fields.challenge; void 0 === val && (val = Buffer.from(void 0)); len = val.length; buffer.writeUInt32BE(len, offset); offset += 4; val.copy(buffer, offset); offset += len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionSecureOk(buffer) { var val, len, offset = 0, fields = { response: void 0 }; len = buffer.readUInt32BE(offset); offset += 4; val = buffer.subarray(offset, offset + len); offset += len; fields.response = val; return fields; } function encodeConnectionSecureOk(channel, fields) { var len, offset = 0, val = null, varyingSize = 0; val = fields.response; if (void 0 === val) throw new Error("Missing value for mandatory field 'response'"); if (!Buffer.isBuffer(val)) throw new TypeError("Field 'response' is the wrong type; must be a Buffer"); varyingSize += val.length; var buffer = Buffer.alloc(16 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655381, 7); offset = 11; val = fields.response; void 0 === val && (val = Buffer.from(void 0)); len = val.length; buffer.writeUInt32BE(len, offset); offset += 4; val.copy(buffer, offset); offset += len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionTune(buffer) { var val, offset = 0, fields = { channelMax: void 0, frameMax: void 0, heartbeat: void 0 }; val = buffer.readUInt16BE(offset); offset += 2; fields.channelMax = val; val = buffer.readUInt32BE(offset); offset += 4; fields.frameMax = val; val = buffer.readUInt16BE(offset); offset += 2; fields.heartbeat = val; return fields; } function encodeConnectionTune(channel, fields) { var offset = 0, val = null, buffer = Buffer.alloc(20); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655390, 7); offset = 11; val = fields.channelMax; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'channelMax' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.frameMax; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'frameMax' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt32BE(val, offset); offset += 4; val = fields.heartbeat; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'heartbeat' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionTuneOk(buffer) { var val, offset = 0, fields = { channelMax: void 0, frameMax: void 0, heartbeat: void 0 }; val = buffer.readUInt16BE(offset); offset += 2; fields.channelMax = val; val = buffer.readUInt32BE(offset); offset += 4; fields.frameMax = val; val = buffer.readUInt16BE(offset); offset += 2; fields.heartbeat = val; return fields; } function encodeConnectionTuneOk(channel, fields) { var offset = 0, val = null, buffer = Buffer.alloc(20); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655391, 7); offset = 11; val = fields.channelMax; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'channelMax' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.frameMax; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'frameMax' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt32BE(val, offset); offset += 4; val = fields.heartbeat; if (void 0 === val) val = 0; else if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'heartbeat' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionOpen(buffer) { var val, len, offset = 0, fields = { virtualHost: void 0, capabilities: void 0, insist: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.virtualHost = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.capabilities = val; val = !!(1 & buffer[offset]); fields.insist = val; return fields; } function encodeConnectionOpen(channel, fields) { var offset = 0, val = null, bits = 0, varyingSize = 0; val = fields.virtualHost; if (void 0 === val) val = "/"; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'virtualHost' is the wrong type; must be a string (up to 255 chars)"); var virtualHost_len = Buffer.byteLength(val, "utf8"); varyingSize += virtualHost_len; val = fields.capabilities; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'capabilities' is the wrong type; must be a string (up to 255 chars)"); var capabilities_len = Buffer.byteLength(val, "utf8"); varyingSize += capabilities_len; var buffer = Buffer.alloc(15 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655400, 7); offset = 11; val = fields.virtualHost; void 0 === val && (val = "/"); buffer[offset] = virtualHost_len; offset++; buffer.write(val, offset, "utf8"); offset += virtualHost_len; val = fields.capabilities; void 0 === val && (val = ""); buffer[offset] = capabilities_len; offset++; buffer.write(val, offset, "utf8"); offset += capabilities_len; val = fields.insist; void 0 === val && (val = !1); val && (bits += 1); buffer[offset] = bits; offset++; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionOpenOk(buffer) { var val, len, offset = 0, fields = { knownHosts: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.knownHosts = val; return fields; } function encodeConnectionOpenOk(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.knownHosts; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'knownHosts' is the wrong type; must be a string (up to 255 chars)"); var knownHosts_len = Buffer.byteLength(val, "utf8"); varyingSize += knownHosts_len; var buffer = Buffer.alloc(13 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655401, 7); offset = 11; val = fields.knownHosts; void 0 === val && (val = ""); buffer[offset] = knownHosts_len; offset++; buffer.write(val, offset, "utf8"); offset += knownHosts_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionClose(buffer) { var val, len, offset = 0, fields = { replyCode: void 0, replyText: void 0, classId: void 0, methodId: void 0 }; val = buffer.readUInt16BE(offset); offset += 2; fields.replyCode = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.replyText = val; val = buffer.readUInt16BE(offset); offset += 2; fields.classId = val; val = buffer.readUInt16BE(offset); offset += 2; fields.methodId = val; return fields; } function encodeConnectionClose(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.replyText; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'replyText' is the wrong type; must be a string (up to 255 chars)"); var replyText_len = Buffer.byteLength(val, "utf8"); varyingSize += replyText_len; var buffer = Buffer.alloc(19 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655410, 7); offset = 11; val = fields.replyCode; if (void 0 === val) throw new Error("Missing value for mandatory field 'replyCode'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'replyCode' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.replyText; void 0 === val && (val = ""); buffer[offset] = replyText_len; offset++; buffer.write(val, offset, "utf8"); offset += replyText_len; val = fields.classId; if (void 0 === val) throw new Error("Missing value for mandatory field 'classId'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'classId' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; val = fields.methodId; if (void 0 === val) throw new Error("Missing value for mandatory field 'methodId'"); if ("number" != typeof val || isNaN(val)) throw new TypeError("Field 'methodId' is the wrong type; must be a number (but not NaN)"); buffer.writeUInt16BE(val, offset); offset += 2; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionCloseOk(buffer) { return {}; } function encodeConnectionCloseOk(channel, fields) { var offset = 0, buffer = Buffer.alloc(12); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655411, 7); offset = 11; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionBlocked(buffer) { var val, len, offset = 0, fields = { reason: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.reason = val; return fields; } function encodeConnectionBlocked(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.reason; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'reason' is the wrong type; must be a string (up to 255 chars)"); var reason_len = Buffer.byteLength(val, "utf8"); varyingSize += reason_len; var buffer = Buffer.alloc(13 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655420, 7); offset = 11; val = fields.reason; void 0 === val && (val = ""); buffer[offset] = reason_len; offset++; buffer.write(val, offset, "utf8"); offset += reason_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionUnblocked(buffer) { return {}; } function encodeConnectionUnblocked(channel, fields) { var offset = 0, buffer = Buffer.alloc(12); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655421, 7); offset = 11; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionUpdateSecret(buffer) { var val, len, offset = 0, fields = { newSecret: void 0, reason: void 0 }; len = buffer.readUInt32BE(offset); offset += 4; val = buffer.subarray(offset, offset + len); offset += len; fields.newSecret = val; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.reason = val; return fields; } function encodeConnectionUpdateSecret(channel, fields) { var len, offset = 0, val = null, varyingSize = 0; val = fields.newSecret; if (void 0 === val) throw new Error("Missing value for mandatory field 'newSecret'"); if (!Buffer.isBuffer(val)) throw new TypeError("Field 'newSecret' is the wrong type; must be a Buffer"); varyingSize += val.length; val = fields.reason; if (void 0 === val) throw new Error("Missing value for mandatory field 'reason'"); if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'reason' is the wrong type; must be a string (up to 255 chars)"); var reason_len = Buffer.byteLength(val, "utf8"); varyingSize += reason_len; var buffer = Buffer.alloc(17 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655430, 7); offset = 11; val = fields.newSecret; void 0 === val && (val = Buffer.from(void 0)); len = val.length; buffer.writeUInt32BE(len, offset); offset += 4; val.copy(buffer, offset); offset += len; val = fields.reason; void 0 === val && (val = void 0); buffer[offset] = reason_len; offset++; buffer.write(val, offset, "utf8"); offset += reason_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeConnectionUpdateSecretOk(buffer) { return {}; } function encodeConnectionUpdateSecretOk(channel, fields) { var offset = 0, buffer = Buffer.alloc(12); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(655431, 7); offset = 11; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeChannelOpen(buffer) { var val, len, offset = 0, fields = { outOfBand: void 0 }; len = buffer.readUInt8(offset); offset++; val = buffer.toString("utf8", offset, offset + len); offset += len; fields.outOfBand = val; return fields; } function encodeChannelOpen(channel, fields) { var offset = 0, val = null, varyingSize = 0; val = fields.outOfBand; if (void 0 === val) val = ""; else if (!("string" == typeof val && Buffer.byteLength(val) < 256)) throw new TypeError("Field 'outOfBand' is the wrong type; must be a string (up to 255 chars)"); var outOfBand_len = Buffer.byteLength(val, "utf8"); varyingSize += outOfBand_len; var buffer = Buffer.alloc(13 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(1310730, 7); offset = 11; val = fields.outOfBand; void 0 === val && (val = ""); buffer[offset] = outOfBand_len; offset++; buffer.write(val, offset, "utf8"); offset += outOfBand_len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeChannelOpenOk(buffer) { var val, len, offset = 0, fields = { channelId: void 0 }; len = buffer.readUInt32BE(offset); offset += 4; val = buffer.subarray(offset, offset + len); offset += len; fields.channelId = val; return fields; } function encodeChannelOpenOk(channel, fields) { var len, offset = 0, val = null, varyingSize = 0; val = fields.channelId; if (void 0 === val) val = Buffer.from(""); else if (!Buffer.isBuffer(val)) throw new TypeError("Field 'channelId' is the wrong type; must be a Buffer"); varyingSize += val.length; var buffer = Buffer.alloc(16 + varyingSize); buffer[0] = 1; buffer.writeUInt16BE(channel, 1); buffer.writeUInt32BE(1310731, 7); offset = 11; val = fields.channelId; void 0 === val && (val = Buffer.from("")); len = val.length; buffer.writeUInt32BE(len, offset); offset += 4; val.copy(buffer, offset); offset += len; buffer[offset] = 206; buffer.writeUInt32BE(offset - 7, 3); return buffer; } function decodeChannelFlow(buffer) { var val, fields = { active: void 0 }; val = !!(1 & buffer[0]); fields.active = val; return fields; } function encodeChannelFlow(channel, fields) { var offset = 0, val = null, bits = 0, buffer = Buffer.alloc(13); buffer[0] = 1; buffer.writeUI