Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mqtts

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqtts - npm Package Compare versions

Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1

5

dist/mqtt.client.d.ts

@@ -6,6 +6,5 @@ /// <reference types="node" />

import { Transport } from './transport';
import { ConnectRequestOptions, SubscribeReturnCode } from './packets';
import { ConnectRequestOptions, ConnectResponsePacket, DefaultPacketReadResultMap, DefaultPacketWriteOptions, PacketReadResultMap, PacketWriteOptionsMap, PacketWriter, PublishRequestPacket, SubscribeReturnCode } from './packets';
import { MqttMessageOutgoing } from './mqtt.message';
import { Writable } from 'stream';
import { DefaultPacketReadResultMap, PacketReadResultMap, DefaultPacketWriteOptions, PacketWriteOptionsMap, PacketWriter } from './packets';
import { PacketType } from './mqtt.constants';

@@ -57,2 +56,4 @@ import { MqttBaseClient } from './mqtt.base-client';

protected handlePacket(packet: MqttParseResult<ReadMap, PacketType>): Promise<void>;
protected onConnAck(connAck: ConnectResponsePacket): void;
protected onPublish(publish: PublishRequestPacket): void;
protected logReceivedPacket(packet: {

@@ -59,0 +60,0 @@ type: PacketType;

67

dist/mqtt.client.js

@@ -7,10 +7,10 @@ "use strict";

const transport_1 = require("./transport");
const packets_1 = require("./packets");
const errors_1 = require("./errors");
const stream_1 = require("stream");
const packets_1 = require("./packets");
const mqtt_constants_1 = require("./mqtt.constants");
const debug = require("debug");
const mqtt_base_client_1 = require("./mqtt.base-client");
const mqtt_listener_1 = require("./mqtt.listener");
const mqtt_utilities_1 = require("./mqtt.utilities");
const debug = require("debug");
class MqttClient extends mqtt_base_client_1.MqttBaseClient {

@@ -224,40 +224,15 @@ constructor(options) {

async handlePacket(packet) {
var _a, _b;
this.logReceivedPacket(packet);
let forceCheckFlows = false;
// The following "type assertions" are valid as clients extending MqttClient have to implement their own methods
switch (packet.type) {
case mqtt_constants_1.PacketType.ConnAck: {
const connack = packet;
if (connack.data.isSuccess) {
this.setReady();
this.emitConnect(connack.data);
if ((_a = this.connectOptions) === null || _a === void 0 ? void 0 : _a.keepAlive) {
this.updateKeepAlive(this.connectOptions.keepAlive);
}
}
else {
this.setFatal();
this.emitError(new errors_1.ConnectError(connack.data.errorName));
this.setDisconnected(connack.data.errorName).catch(e => this.emitWarning(e));
}
this.onConnAck(packet.data);
break;
}
case mqtt_constants_1.PacketType.Publish: {
const pub = packet.data;
this.startFlow(flow_1.incomingPublishFlow({
topic: pub.topic,
payload: pub.payload,
qosLevel: pub.qos,
retained: pub.retain,
duplicate: pub.duplicate,
}, (_b = pub.identifier) !== null && _b !== void 0 ? _b : undefined))
.then(async (m) => {
this.emitMessage(m);
await this.messageListener.handleMessage(m);
})
.catch(e => this.emitWarning(e));
this.onPublish(packet.data);
break;
}
case mqtt_constants_1.PacketType.Disconnect: {
// ? this.disconnect();
this.setDisconnected('disconnect packet received').catch(e => this.emitWarning(e));

@@ -273,2 +248,32 @@ break;

}
onConnAck(connAck) {
var _a;
if (connAck.isSuccess) {
this.setReady();
this.emitConnect(connAck);
if ((_a = this.connectOptions) === null || _a === void 0 ? void 0 : _a.keepAlive) {
this.updateKeepAlive(this.connectOptions.keepAlive);
}
}
else {
this.setFatal();
this.emitError(new errors_1.ConnectError(connAck.errorName));
this.setDisconnected(connAck.errorName).catch(e => this.emitWarning(e));
}
}
onPublish(publish) {
var _a;
this.startFlow(flow_1.incomingPublishFlow({
topic: publish.topic,
payload: publish.payload,
qosLevel: publish.qos,
retained: publish.retain,
duplicate: publish.duplicate,
}, (_a = publish.identifier) !== null && _a !== void 0 ? _a : undefined))
.then(async (m) => {
this.emitMessage(m);
await this.messageListener.handleMessage(m);
})
.catch(e => this.emitWarning(e));
}
logReceivedPacket(packet) {

@@ -303,3 +308,3 @@ if (packet.type !== mqtt_constants_1.PacketType.PingReq && packet.type !== mqtt_constants_1.PacketType.PingResp)

super.setDisconnected();
this.emitDisconnect(reason);
this.emitDisconnect(`reason: ${reason} willReconnect: ${willReconnect}`);
if (!this.transport.duplex.destroyed) {

@@ -306,0 +311,0 @@ await new Promise(resolve => this.transport.duplex.end(resolve));

{
"name": "mqtts",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "MQTT client in Typescript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc