first commit
This commit is contained in:
20
node_modules/mqtt/build/lib/BufferedDuplex.d.ts
generated
vendored
Normal file
20
node_modules/mqtt/build/lib/BufferedDuplex.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Duplex, type Transform } from 'readable-stream';
|
||||
import { type IClientOptions } from './client';
|
||||
export declare function writev(chunks: {
|
||||
chunk: any;
|
||||
encoding: string;
|
||||
}[], cb: (err?: Error) => void): void;
|
||||
export declare class BufferedDuplex extends Duplex {
|
||||
socket: WebSocket;
|
||||
private proxy;
|
||||
private isSocketOpen;
|
||||
private writeQueue;
|
||||
constructor(opts: IClientOptions, proxy: Transform, socket: WebSocket);
|
||||
_read(size?: number): void;
|
||||
_write(chunk: any, encoding: string, cb: (err?: Error) => void): void;
|
||||
_final(callback: (error?: Error) => void): void;
|
||||
_destroy(err: Error, callback: (error: Error) => void): void;
|
||||
socketReady(): void;
|
||||
private writeToProxy;
|
||||
private processWriteQueue;
|
||||
}
|
82
node_modules/mqtt/build/lib/BufferedDuplex.js
generated
vendored
Normal file
82
node_modules/mqtt/build/lib/BufferedDuplex.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BufferedDuplex = void 0;
|
||||
exports.writev = writev;
|
||||
const readable_stream_1 = require("readable-stream");
|
||||
const buffer_1 = require("buffer");
|
||||
function writev(chunks, cb) {
|
||||
const buffers = new Array(chunks.length);
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
if (typeof chunks[i].chunk === 'string') {
|
||||
buffers[i] = buffer_1.Buffer.from(chunks[i].chunk, 'utf8');
|
||||
}
|
||||
else {
|
||||
buffers[i] = chunks[i].chunk;
|
||||
}
|
||||
}
|
||||
this._write(buffer_1.Buffer.concat(buffers), 'binary', cb);
|
||||
}
|
||||
class BufferedDuplex extends readable_stream_1.Duplex {
|
||||
socket;
|
||||
proxy;
|
||||
isSocketOpen;
|
||||
writeQueue;
|
||||
constructor(opts, proxy, socket) {
|
||||
super({
|
||||
objectMode: true,
|
||||
});
|
||||
this.proxy = proxy;
|
||||
this.socket = socket;
|
||||
this.writeQueue = [];
|
||||
if (!opts.objectMode) {
|
||||
this._writev = writev.bind(this);
|
||||
}
|
||||
this.isSocketOpen = false;
|
||||
this.proxy.on('data', (chunk) => {
|
||||
if (!this.destroyed && this.readable) {
|
||||
this.push(chunk);
|
||||
}
|
||||
});
|
||||
}
|
||||
_read(size) {
|
||||
this.proxy.read(size);
|
||||
}
|
||||
_write(chunk, encoding, cb) {
|
||||
if (!this.isSocketOpen) {
|
||||
this.writeQueue.push({ chunk, encoding, cb });
|
||||
}
|
||||
else {
|
||||
this.writeToProxy(chunk, encoding, cb);
|
||||
}
|
||||
}
|
||||
_final(callback) {
|
||||
this.writeQueue = [];
|
||||
this.proxy.end(callback);
|
||||
}
|
||||
_destroy(err, callback) {
|
||||
this.writeQueue = [];
|
||||
this.proxy.destroy();
|
||||
callback(err);
|
||||
}
|
||||
socketReady() {
|
||||
this.emit('connect');
|
||||
this.isSocketOpen = true;
|
||||
this.processWriteQueue();
|
||||
}
|
||||
writeToProxy(chunk, encoding, cb) {
|
||||
if (this.proxy.write(chunk, encoding) === false) {
|
||||
this.proxy.once('drain', cb);
|
||||
}
|
||||
else {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
processWriteQueue() {
|
||||
while (this.writeQueue.length > 0) {
|
||||
const { chunk, encoding, cb } = this.writeQueue.shift();
|
||||
this.writeToProxy(chunk, encoding, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.BufferedDuplex = BufferedDuplex;
|
||||
//# sourceMappingURL=BufferedDuplex.js.map
|
1
node_modules/mqtt/build/lib/BufferedDuplex.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/BufferedDuplex.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BufferedDuplex.js","sourceRoot":"","sources":["../../src/lib/BufferedDuplex.ts"],"names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AAE,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;YACjD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QAC7B,CAAC;aAAM,CAAC;YACP,EAAE,EAAE,CAAA;QACL,CAAC;IACF,CAAC;IAEO,iBAAiB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAG,CAAA;YACxD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;QACvC,CAAC;IACF,CAAC;CACD;AApFD,wCAoFC"}
|
21
node_modules/mqtt/build/lib/KeepaliveManager.d.ts
generated
vendored
Normal file
21
node_modules/mqtt/build/lib/KeepaliveManager.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import type MqttClient from './client';
|
||||
import { type Timer } from './get-timer';
|
||||
import type { TimerVariant } from './shared';
|
||||
export default class KeepaliveManager {
|
||||
private _keepalive;
|
||||
private timerId;
|
||||
private timer;
|
||||
private destroyed;
|
||||
private counter;
|
||||
private client;
|
||||
private _keepaliveTimeoutTimestamp;
|
||||
private _intervalEvery;
|
||||
get keepaliveTimeoutTimestamp(): number;
|
||||
get intervalEvery(): number;
|
||||
get keepalive(): number;
|
||||
constructor(client: MqttClient, variant: TimerVariant | Timer);
|
||||
private clear;
|
||||
setKeepalive(value: number): void;
|
||||
destroy(): void;
|
||||
reschedule(): void;
|
||||
}
|
80
node_modules/mqtt/build/lib/KeepaliveManager.js
generated
vendored
Normal file
80
node_modules/mqtt/build/lib/KeepaliveManager.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const get_timer_1 = __importDefault(require("./get-timer"));
|
||||
class KeepaliveManager {
|
||||
_keepalive;
|
||||
timerId;
|
||||
timer;
|
||||
destroyed = false;
|
||||
counter;
|
||||
client;
|
||||
_keepaliveTimeoutTimestamp;
|
||||
_intervalEvery;
|
||||
get keepaliveTimeoutTimestamp() {
|
||||
return this._keepaliveTimeoutTimestamp;
|
||||
}
|
||||
get intervalEvery() {
|
||||
return this._intervalEvery;
|
||||
}
|
||||
get keepalive() {
|
||||
return this._keepalive;
|
||||
}
|
||||
constructor(client, variant) {
|
||||
this.client = client;
|
||||
this.timer =
|
||||
typeof variant === 'object' &&
|
||||
'set' in variant &&
|
||||
'clear' in variant
|
||||
? variant
|
||||
: (0, get_timer_1.default)(variant);
|
||||
this.setKeepalive(client.options.keepalive);
|
||||
}
|
||||
clear() {
|
||||
if (this.timerId) {
|
||||
this.timer.clear(this.timerId);
|
||||
this.timerId = null;
|
||||
}
|
||||
}
|
||||
setKeepalive(value) {
|
||||
value *= 1000;
|
||||
if (isNaN(value) ||
|
||||
value <= 0 ||
|
||||
value > 2147483647) {
|
||||
throw new Error(`Keepalive value must be an integer between 0 and 2147483647. Provided value is ${value}`);
|
||||
}
|
||||
this._keepalive = value;
|
||||
this.reschedule();
|
||||
this.client['log'](`KeepaliveManager: set keepalive to ${value}ms`);
|
||||
}
|
||||
destroy() {
|
||||
this.clear();
|
||||
this.destroyed = true;
|
||||
}
|
||||
reschedule() {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
this.clear();
|
||||
this.counter = 0;
|
||||
const keepAliveTimeout = Math.ceil(this._keepalive * 1.5);
|
||||
this._keepaliveTimeoutTimestamp = Date.now() + keepAliveTimeout;
|
||||
this._intervalEvery = Math.ceil(this._keepalive / 2);
|
||||
this.timerId = this.timer.set(() => {
|
||||
if (this.destroyed) {
|
||||
return;
|
||||
}
|
||||
this.counter += 1;
|
||||
if (this.counter === 2) {
|
||||
this.client.sendPing();
|
||||
}
|
||||
else if (this.counter > 2) {
|
||||
this.client.onKeepaliveTimeout();
|
||||
}
|
||||
}, this._intervalEvery);
|
||||
}
|
||||
}
|
||||
exports.default = KeepaliveManager;
|
||||
//# sourceMappingURL=KeepaliveManager.js.map
|
1
node_modules/mqtt/build/lib/KeepaliveManager.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/KeepaliveManager.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"KeepaliveManager.js","sourceRoot":"","sources":["../../src/lib/KeepaliveManager.ts"],"names":[],"mappings":";;;;;AACA,4DAAkD;AAGlD,MAAqB,gBAAgB;IAC5B,UAAU,CAAQ;IAElB,OAAO,CAAQ;IAEf,KAAK,CAAO;IAEZ,SAAS,GAAG,KAAK,CAAA;IAEjB,OAAO,CAAQ;IAEf,MAAM,CAAY;IAElB,0BAA0B,CAAQ;IAElC,cAAc,CAAQ;IAG9B,IAAI,yBAAyB;QAC5B,OAAO,IAAI,CAAC,0BAA0B,CAAA;IACvC,CAAC;IAGD,IAAI,aAAa;QAChB,OAAO,IAAI,CAAC,cAAc,CAAA;IAC3B,CAAC;IAED,IAAI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAA;IACvB,CAAC;IAED,YAAY,MAAkB,EAAE,OAA6B;QAC5D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK;YACT,OAAO,OAAO,KAAK,QAAQ;gBAC3B,KAAK,IAAI,OAAO;gBAChB,OAAO,IAAI,OAAO;gBACjB,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,IAAA,mBAAQ,EAAC,OAAO,CAAC,CAAA;QACrB,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC5C,CAAC;IAEO,KAAK;QACZ,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,KAAK,CAAC,KAAK,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O,KAAK,CAAC,EAAE,CAAC;gBACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;YACvB,CAAC;iBAAM,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC;gBAC7B,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAA;YACjC,CAAC;QACF,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACxB,CAAC;CACD;AA3GD,mCA2GC"}
|
19
node_modules/mqtt/build/lib/TypedEmitter.d.ts
generated
vendored
Normal file
19
node_modules/mqtt/build/lib/TypedEmitter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export type EventHandler = ((arg1: any, arg2: any, arg3: any, arg4: any) => void) | ((arg1: any, arg2: any, arg3: any) => void) | ((arg1: any, arg2: any) => void) | ((arg1: any) => void) | ((...args: any[]) => void);
|
||||
export interface TypedEventEmitter<TEvents extends Record<keyof TEvents, EventHandler>> {
|
||||
on<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
|
||||
once<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
|
||||
prependListener<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
|
||||
prependOnceListener<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
|
||||
removeListener<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
|
||||
off<TEvent extends keyof TEvents>(event: TEvent, callback: TEvents[TEvent]): this;
|
||||
removeAllListeners(event?: keyof TEvents): this;
|
||||
emit<TEvent extends keyof TEvents>(event: TEvent, ...args: Parameters<TEvents[TEvent]>): boolean;
|
||||
setMaxListeners(n: number): this;
|
||||
getMaxListeners(): number;
|
||||
listeners<TEvent extends keyof TEvents>(eventName: TEvent): TEvents[TEvent][];
|
||||
rawListeners<TEvent extends keyof TEvents>(eventName: TEvent): TEvents[TEvent][];
|
||||
listenerCount<TEvent extends keyof TEvents>(event: TEvent, listener?: TEvents[TEvent]): number;
|
||||
eventNames(): Array<keyof TEvents>;
|
||||
}
|
||||
export declare class TypedEventEmitter<TEvents extends Record<keyof TEvents, EventHandler>> {
|
||||
}
|
13
node_modules/mqtt/build/lib/TypedEmitter.js
generated
vendored
Normal file
13
node_modules/mqtt/build/lib/TypedEmitter.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TypedEventEmitter = void 0;
|
||||
const events_1 = __importDefault(require("events"));
|
||||
const shared_1 = require("./shared");
|
||||
class TypedEventEmitter {
|
||||
}
|
||||
exports.TypedEventEmitter = TypedEventEmitter;
|
||||
(0, shared_1.applyMixin)(TypedEventEmitter, events_1.default);
|
||||
//# sourceMappingURL=TypedEmitter.js.map
|
1
node_modules/mqtt/build/lib/TypedEmitter.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/TypedEmitter.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"TypedEmitter.js","sourceRoot":"","sources":["../../src/lib/TypedEmitter.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAiC;AACjC,qCAAqC;AAgErC,MAAa,iBAAiB;CAE1B;AAFJ,8CAEI;AAGJ,IAAA,mBAAU,EAAC,iBAAiB,EAAE,gBAAY,CAAC,CAAA"}
|
237
node_modules/mqtt/build/lib/client.d.ts
generated
vendored
Normal file
237
node_modules/mqtt/build/lib/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
import { type IAuthPacket, IConnackPacket, IDisconnectPacket, IPublishPacket, type ISubscribePacket, type IUnsubscribePacket, Packet, type QoS, type ISubackPacket, type IConnectPacket } from 'mqtt-packet';
|
||||
import { type DuplexOptions } from 'readable-stream';
|
||||
import type { ClientOptions } from 'ws';
|
||||
import { type ClientRequestArgs } from 'http';
|
||||
import Store, { type IStore } from './store';
|
||||
import { type IMessageIdProvider } from './default-message-id-provider';
|
||||
import { type DoneCallback, type ErrorWithReasonCode, type IStream, type StreamBuilder, type TimerVariant, type VoidCallback } from './shared';
|
||||
import { TypedEventEmitter } from './TypedEmitter';
|
||||
import KeepaliveManager from './KeepaliveManager';
|
||||
import { type Timer } from './get-timer';
|
||||
export type BaseMqttProtocol = 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs' | 'ali' | 'alis';
|
||||
export type MqttProtocolWithUnix = `${BaseMqttProtocol}+unix`;
|
||||
export type MqttProtocol = BaseMqttProtocol | MqttProtocolWithUnix;
|
||||
export type StorePutCallback = () => void;
|
||||
export interface ISecureClientOptions {
|
||||
key?: string | string[] | Buffer | Buffer[] | any[];
|
||||
keyPath?: string;
|
||||
cert?: string | string[] | Buffer | Buffer[];
|
||||
certPath?: string;
|
||||
ca?: string | string[] | Buffer | Buffer[];
|
||||
caPaths?: string | string[];
|
||||
rejectUnauthorized?: boolean;
|
||||
ALPNProtocols?: string[] | Buffer[] | Uint8Array[] | Buffer | Uint8Array;
|
||||
}
|
||||
export type AckHandler = (topic: string, message: Buffer, packet: any, cb: (error: Error | number, code?: number) => void) => void;
|
||||
export interface IClientOptions extends ISecureClientOptions {
|
||||
encoding?: BufferEncoding;
|
||||
browserBufferSize?: number;
|
||||
binary?: boolean;
|
||||
my?: any;
|
||||
manualConnect?: boolean;
|
||||
authPacket?: Partial<IAuthPacket>;
|
||||
writeCache?: boolean;
|
||||
servername?: string;
|
||||
defaultProtocol?: MqttProtocol;
|
||||
query?: Record<string, string>;
|
||||
auth?: string;
|
||||
socksProxy?: string;
|
||||
socksTimeout?: number;
|
||||
customHandleAcks?: AckHandler;
|
||||
port?: number;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
unixSocket?: boolean;
|
||||
path?: string;
|
||||
protocol?: MqttProtocol;
|
||||
wsOptions?: ClientOptions | ClientRequestArgs | DuplexOptions;
|
||||
reconnectPeriod?: number;
|
||||
reconnectOnConnackError?: boolean;
|
||||
connectTimeout?: number;
|
||||
incomingStore?: IStore;
|
||||
outgoingStore?: IStore;
|
||||
queueQoSZero?: boolean;
|
||||
log?: (...args: any[]) => void;
|
||||
autoUseTopicAlias?: boolean;
|
||||
autoAssignTopicAlias?: boolean;
|
||||
reschedulePings?: boolean;
|
||||
servers?: Array<{
|
||||
host: string;
|
||||
port: number;
|
||||
protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs';
|
||||
}>;
|
||||
resubscribe?: boolean;
|
||||
subscribeBatchSize?: number;
|
||||
transformWsUrl?: (url: string, options: IClientOptions, client: MqttClient) => string;
|
||||
createWebsocket?: (url: string, websocketSubProtocols: string[], options: IClientOptions) => any;
|
||||
messageIdProvider?: IMessageIdProvider;
|
||||
browserBufferTimeout?: number;
|
||||
objectMode?: boolean;
|
||||
clientId?: string;
|
||||
protocolVersion?: IConnectPacket['protocolVersion'];
|
||||
protocolId?: IConnectPacket['protocolId'];
|
||||
clean?: boolean;
|
||||
keepalive?: number;
|
||||
username?: string;
|
||||
password?: Buffer | string;
|
||||
will?: IConnectPacket['will'];
|
||||
properties?: IConnectPacket['properties'];
|
||||
timerVariant?: TimerVariant | Timer;
|
||||
forceNativeWebSocket?: boolean;
|
||||
}
|
||||
export interface IClientPublishOptions {
|
||||
qos?: QoS;
|
||||
retain?: boolean;
|
||||
dup?: boolean;
|
||||
properties?: IPublishPacket['properties'];
|
||||
cbStorePut?: StorePutCallback;
|
||||
}
|
||||
export interface IClientReconnectOptions {
|
||||
incomingStore?: Store;
|
||||
outgoingStore?: Store;
|
||||
}
|
||||
export interface IClientSubscribeProperties {
|
||||
properties?: ISubscribePacket['properties'];
|
||||
}
|
||||
export interface IClientSubscribeOptions extends IClientSubscribeProperties {
|
||||
qos: QoS;
|
||||
nl?: boolean;
|
||||
rap?: boolean;
|
||||
rh?: number;
|
||||
}
|
||||
export interface ISubscriptionRequest extends IClientSubscribeOptions {
|
||||
topic: string;
|
||||
}
|
||||
export interface ISubscriptionGrant extends Omit<ISubscriptionRequest, 'qos' | 'properties'> {
|
||||
qos: QoS | 128;
|
||||
}
|
||||
export type ISubscriptionMap = {
|
||||
[topic: string]: IClientSubscribeOptions;
|
||||
} & {
|
||||
resubscribe?: boolean;
|
||||
};
|
||||
export interface IClientUnsubscribeProperties {
|
||||
properties?: IUnsubscribePacket['properties'];
|
||||
}
|
||||
export { IConnackPacket, IDisconnectPacket, IPublishPacket, Packet };
|
||||
export type OnConnectCallback = (packet: IConnackPacket) => void;
|
||||
export type OnDisconnectCallback = (packet: IDisconnectPacket) => void;
|
||||
export type ClientSubscribeCallback = (err: Error | null, granted?: ISubscriptionGrant[], packet?: ISubackPacket) => void;
|
||||
export type OnMessageCallback = (topic: string, payload: Buffer, packet: IPublishPacket) => void;
|
||||
export type OnPacketCallback = (packet: Packet) => void;
|
||||
export type OnCloseCallback = () => void;
|
||||
export type OnErrorCallback = (error: Error | ErrorWithReasonCode) => void;
|
||||
export type PacketCallback = (error?: Error | ErrorWithReasonCode, packet?: Packet) => any;
|
||||
export type CloseCallback = (error?: Error) => void;
|
||||
export interface MqttClientEventCallbacks {
|
||||
connect: OnConnectCallback;
|
||||
message: OnMessageCallback;
|
||||
packetsend: OnPacketCallback;
|
||||
packetreceive: OnPacketCallback;
|
||||
disconnect: OnDisconnectCallback;
|
||||
error: OnErrorCallback;
|
||||
close: OnCloseCallback;
|
||||
end: VoidCallback;
|
||||
reconnect: VoidCallback;
|
||||
offline: VoidCallback;
|
||||
outgoingEmpty: VoidCallback;
|
||||
}
|
||||
export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbacks> {
|
||||
static VERSION: any;
|
||||
connected: boolean;
|
||||
disconnecting: boolean;
|
||||
disconnected: boolean;
|
||||
reconnecting: boolean;
|
||||
incomingStore: IStore;
|
||||
outgoingStore: IStore;
|
||||
options: IClientOptions;
|
||||
queueQoSZero: boolean;
|
||||
_reconnectCount: number;
|
||||
log: (...args: any[]) => void;
|
||||
messageIdProvider: IMessageIdProvider;
|
||||
outgoing: Record<number, {
|
||||
volatile: boolean;
|
||||
cb: (err: Error, packet?: Packet) => void;
|
||||
}>;
|
||||
messageIdToTopic: Record<number, string[]>;
|
||||
noop: (error?: any) => void;
|
||||
keepaliveManager: KeepaliveManager;
|
||||
stream: IStream;
|
||||
queue: {
|
||||
packet: Packet;
|
||||
cb: PacketCallback;
|
||||
}[];
|
||||
private streamBuilder;
|
||||
private _resubscribeTopics;
|
||||
private connackTimer;
|
||||
private reconnectTimer;
|
||||
private _storeProcessing;
|
||||
private _packetIdsDuringStoreProcessing;
|
||||
private _storeProcessingQueue;
|
||||
private _firstConnection;
|
||||
private topicAliasRecv;
|
||||
private topicAliasSend;
|
||||
private _deferredReconnect;
|
||||
private connackPacket;
|
||||
static defaultId(): string;
|
||||
constructor(streamBuilder: StreamBuilder, options: IClientOptions);
|
||||
handleAuth(packet: IAuthPacket, callback: PacketCallback): void;
|
||||
handleMessage(packet: IPublishPacket, callback: DoneCallback): void;
|
||||
private _nextId;
|
||||
getLastMessageId(): number;
|
||||
connect(): this;
|
||||
publish(topic: string, message: string | Buffer): MqttClient;
|
||||
publish(topic: string, message: string | Buffer, callback?: PacketCallback): MqttClient;
|
||||
publish(topic: string, message: string | Buffer, opts?: IClientPublishOptions, callback?: PacketCallback): MqttClient;
|
||||
publishAsync(topic: string, message: string | Buffer): Promise<Packet | undefined>;
|
||||
publishAsync(topic: string, message: string | Buffer, opts?: IClientPublishOptions): Promise<Packet | undefined>;
|
||||
subscribe(topicObject: string | string[] | ISubscriptionMap): MqttClient;
|
||||
subscribe(topicObject: string | string[] | ISubscriptionMap, callback?: ClientSubscribeCallback): MqttClient;
|
||||
subscribe(topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties): MqttClient;
|
||||
subscribe(topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties, callback?: ClientSubscribeCallback): MqttClient;
|
||||
subscribeAsync(topicObject: string | string[] | ISubscriptionMap): Promise<ISubscriptionGrant[]>;
|
||||
subscribeAsync(topicObject: string | string[] | ISubscriptionMap, opts?: IClientSubscribeOptions | IClientSubscribeProperties): Promise<ISubscriptionGrant[]>;
|
||||
unsubscribe(topic: string | string[]): MqttClient;
|
||||
unsubscribe(topic: string | string[], opts?: IClientUnsubscribeProperties): MqttClient;
|
||||
unsubscribe(topic: string | string[], callback?: PacketCallback): MqttClient;
|
||||
unsubscribe(topic: string | string[], opts?: IClientUnsubscribeProperties, callback?: PacketCallback): MqttClient;
|
||||
unsubscribeAsync(topic: string | string[]): Promise<Packet | undefined>;
|
||||
unsubscribeAsync(topic: string | string[], opts?: IClientUnsubscribeProperties): Promise<Packet | undefined>;
|
||||
end(cb?: DoneCallback): MqttClient;
|
||||
end(force?: boolean): MqttClient;
|
||||
end(opts?: Partial<IDisconnectPacket>, cb?: DoneCallback): MqttClient;
|
||||
end(force?: boolean, cb?: DoneCallback): MqttClient;
|
||||
end(force?: boolean, opts?: Partial<IDisconnectPacket>, cb?: DoneCallback): MqttClient;
|
||||
endAsync(): Promise<void>;
|
||||
endAsync(force?: boolean): Promise<void>;
|
||||
endAsync(opts?: Partial<IDisconnectPacket>): Promise<void>;
|
||||
endAsync(force?: boolean, opts?: Partial<IDisconnectPacket>): Promise<void>;
|
||||
removeOutgoingMessage(messageId: number): MqttClient;
|
||||
reconnect(opts?: Pick<IClientOptions, 'incomingStore' | 'outgoingStore'>): MqttClient;
|
||||
private _flushVolatile;
|
||||
private _flush;
|
||||
private _removeTopicAliasAndRecoverTopicName;
|
||||
private _checkDisconnecting;
|
||||
private _reconnect;
|
||||
private _setupReconnect;
|
||||
private _clearReconnect;
|
||||
private _cleanUp;
|
||||
private _storeAndSend;
|
||||
private _applyTopicAlias;
|
||||
private _noop;
|
||||
private _writePacket;
|
||||
private _sendPacket;
|
||||
private _storePacket;
|
||||
private _setupKeepaliveManager;
|
||||
private _destroyKeepaliveManager;
|
||||
reschedulePing(force?: boolean): void;
|
||||
private _reschedulePing;
|
||||
sendPing(): void;
|
||||
onKeepaliveTimeout(): void;
|
||||
private _resubscribe;
|
||||
private _onConnect;
|
||||
private _invokeStoreProcessingQueue;
|
||||
private _invokeAllStoreProcessingQueue;
|
||||
private _flushStoreProcessingQueue;
|
||||
private _removeOutgoingAndStoreMessage;
|
||||
}
|
1289
node_modules/mqtt/build/lib/client.js
generated
vendored
Normal file
1289
node_modules/mqtt/build/lib/client.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/mqtt/build/lib/client.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/client.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/mqtt/build/lib/connect/ali.d.ts
generated
vendored
Normal file
3
node_modules/mqtt/build/lib/connect/ali.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type StreamBuilder } from '../shared';
|
||||
declare const buildStream: StreamBuilder;
|
||||
export default buildStream;
|
107
node_modules/mqtt/build/lib/connect/ali.js
generated
vendored
Normal file
107
node_modules/mqtt/build/lib/connect/ali.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const buffer_1 = require("buffer");
|
||||
const readable_stream_1 = require("readable-stream");
|
||||
const BufferedDuplex_1 = require("../BufferedDuplex");
|
||||
let my;
|
||||
let proxy;
|
||||
let stream;
|
||||
let isInitialized = false;
|
||||
function buildProxy() {
|
||||
const _proxy = new readable_stream_1.Transform();
|
||||
_proxy._write = (chunk, encoding, next) => {
|
||||
my.sendSocketMessage({
|
||||
data: chunk.buffer,
|
||||
success() {
|
||||
next();
|
||||
},
|
||||
fail() {
|
||||
next(new Error());
|
||||
},
|
||||
});
|
||||
};
|
||||
_proxy._flush = (done) => {
|
||||
my.closeSocket({
|
||||
success() {
|
||||
done();
|
||||
},
|
||||
});
|
||||
};
|
||||
return _proxy;
|
||||
}
|
||||
function setDefaultOpts(opts) {
|
||||
if (!opts.hostname) {
|
||||
opts.hostname = 'localhost';
|
||||
}
|
||||
if (!opts.path) {
|
||||
opts.path = '/';
|
||||
}
|
||||
if (!opts.wsOptions) {
|
||||
opts.wsOptions = {};
|
||||
}
|
||||
}
|
||||
function buildUrl(opts, client) {
|
||||
const protocol = opts.protocol === 'alis' ? 'wss' : 'ws';
|
||||
let url = `${protocol}://${opts.hostname}${opts.path}`;
|
||||
if (opts.port && opts.port !== 80 && opts.port !== 443) {
|
||||
url = `${protocol}://${opts.hostname}:${opts.port}${opts.path}`;
|
||||
}
|
||||
if (typeof opts.transformWsUrl === 'function') {
|
||||
url = opts.transformWsUrl(url, opts, client);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
function bindEventHandler() {
|
||||
if (isInitialized)
|
||||
return;
|
||||
isInitialized = true;
|
||||
my.onSocketOpen(() => {
|
||||
stream.socketReady();
|
||||
});
|
||||
my.onSocketMessage((res) => {
|
||||
if (typeof res.data === 'string') {
|
||||
const buffer = buffer_1.Buffer.from(res.data, 'base64');
|
||||
proxy.push(buffer);
|
||||
}
|
||||
else {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener('load', () => {
|
||||
if (reader.result instanceof ArrayBuffer) {
|
||||
proxy.push(buffer_1.Buffer.from(reader.result));
|
||||
return;
|
||||
}
|
||||
proxy.push(buffer_1.Buffer.from(reader.result, 'utf-8'));
|
||||
});
|
||||
reader.readAsArrayBuffer(res.data);
|
||||
}
|
||||
});
|
||||
my.onSocketClose(() => {
|
||||
stream.end();
|
||||
stream.destroy();
|
||||
});
|
||||
my.onSocketError((err) => {
|
||||
stream.destroy(err);
|
||||
});
|
||||
}
|
||||
const buildStream = (client, opts) => {
|
||||
opts.hostname = opts.hostname || opts.host;
|
||||
if (!opts.hostname) {
|
||||
throw new Error('Could not determine host. Specify host manually.');
|
||||
}
|
||||
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
|
||||
? 'mqttv3.1'
|
||||
: 'mqtt';
|
||||
setDefaultOpts(opts);
|
||||
const url = buildUrl(opts, client);
|
||||
my = opts.my;
|
||||
my.connectSocket({
|
||||
url,
|
||||
protocols: websocketSubProtocol,
|
||||
});
|
||||
proxy = buildProxy();
|
||||
stream = new BufferedDuplex_1.BufferedDuplex(opts, proxy, my);
|
||||
bindEventHandler();
|
||||
return stream;
|
||||
};
|
||||
exports.default = buildStream;
|
||||
//# sourceMappingURL=ali.js.map
|
1
node_modules/mqtt/build/lib/connect/ali.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/connect/ali.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ali.js","sourceRoot":"","sources":["../../../src/lib/connect/ali.ts"],"names":[],"mappings":";;AAAA,mCAA+B;AAC/B,qDAA2C;AAI3C,sDAAkD;AAElD,IAAI,EAAO,CAAA;AACX,IAAI,KAAgB,CAAA;AACpB,IAAI,MAAsB,CAAA;AAC1B,IAAI,aAAa,GAAG,KAAK,CAAA;AAEzB,SAAS,UAAU;IAClB,MAAM,MAAM,GAAG,IAAI,2BAAS,EAAE,CAAA;IAC9B,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;QACzC,EAAE,CAAC,iBAAiB,CAAC;YACpB,IAAI,EAAE,KAAK,CAAC,MAAM;YAClB,OAAO;gBACN,IAAI,EAAE,CAAA;YACP,CAAC;YACD,IAAI;gBACH,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC,CAAA;YAClB,CAAC;SACD,CAAC,CAAA;IACH,CAAC,CAAA;IACD,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE;QACxB,EAAE,CAAC,WAAW,CAAC;YACd,OAAO;gBACN,IAAI,EAAE,CAAA;YACP,CAAC;SACD,C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I,CAAC,IAAI,CAAA;IAE1C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACpE,CAAC;IAED,MAAM,oBAAoB,GACzB,IAAI,CAAC,UAAU,KAAK,QAAQ,IAAI,IAAI,CAAC,eAAe,KAAK,CAAC;QACzD,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,MAAM,CAAA;IAEV,cAAc,CAAC,IAAI,CAAC,CAAA;IAEpB,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAClC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;IAEZ,EAAE,CAAC,aAAa,CAAC;QAChB,GAAG;QACH,SAAS,EAAE,oBAAoB;KAC/B,CAAC,CAAA;IAEF,KAAK,GAAG,UAAU,EAAE,CAAA;IACpB,MAAM,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;IAE5C,gBAAgB,EAAE,CAAA;IAElB,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
10
node_modules/mqtt/build/lib/connect/index.d.ts
generated
vendored
Normal file
10
node_modules/mqtt/build/lib/connect/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import MqttClient, { type IClientOptions } from '../client';
|
||||
declare function connect(brokerUrl: string): MqttClient;
|
||||
declare function connect(opts: IClientOptions): MqttClient;
|
||||
declare function connect(brokerUrl: string, opts?: IClientOptions): MqttClient;
|
||||
declare function connectAsync(brokerUrl: string): Promise<MqttClient>;
|
||||
declare function connectAsync(opts: IClientOptions): Promise<MqttClient>;
|
||||
declare function connectAsync(brokerUrl: string, opts?: IClientOptions): Promise<MqttClient>;
|
||||
declare function connectAsync(brokerUrl: string, opts: IClientOptions, allowRetries: boolean): Promise<MqttClient>;
|
||||
export default connect;
|
||||
export { connectAsync };
|
198
node_modules/mqtt/build/lib/connect/index.js
generated
vendored
Normal file
198
node_modules/mqtt/build/lib/connect/index.js
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.connectAsync = connectAsync;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const url_1 = __importDefault(require("url"));
|
||||
const client_1 = __importDefault(require("../client"));
|
||||
const is_browser_1 = __importDefault(require("../is-browser"));
|
||||
if (typeof process?.nextTick !== 'function') {
|
||||
process.nextTick = setImmediate;
|
||||
}
|
||||
const debug = (0, debug_1.default)('mqttjs');
|
||||
let protocols = null;
|
||||
function parseAuthOptions(opts) {
|
||||
let matches;
|
||||
if (opts.auth) {
|
||||
matches = opts.auth.match(/^(.+):(.+)$/);
|
||||
if (matches) {
|
||||
const [, username, password] = matches;
|
||||
opts.username = username;
|
||||
opts.password = password;
|
||||
}
|
||||
else {
|
||||
opts.username = opts.auth;
|
||||
}
|
||||
}
|
||||
}
|
||||
function connect(brokerUrl, opts) {
|
||||
debug('connecting to an MQTT broker...');
|
||||
if (typeof brokerUrl === 'object' && !opts) {
|
||||
opts = brokerUrl;
|
||||
brokerUrl = '';
|
||||
}
|
||||
opts = opts || {};
|
||||
if (brokerUrl && typeof brokerUrl === 'string') {
|
||||
const parsedUrl = url_1.default.parse(brokerUrl, true);
|
||||
const parsedOptions = {};
|
||||
if (parsedUrl.port != null) {
|
||||
parsedOptions.port = Number(parsedUrl.port);
|
||||
}
|
||||
parsedOptions.host = parsedUrl.hostname;
|
||||
parsedOptions.query = parsedUrl.query;
|
||||
parsedOptions.auth = parsedUrl.auth;
|
||||
parsedOptions.protocol = parsedUrl.protocol;
|
||||
parsedOptions.path = parsedUrl.path;
|
||||
opts = { ...parsedOptions, ...opts };
|
||||
if (!opts.protocol) {
|
||||
throw new Error('Missing protocol');
|
||||
}
|
||||
opts.protocol = opts.protocol.replace(/:$/, '');
|
||||
}
|
||||
opts.unixSocket = opts.unixSocket || opts.protocol?.includes('+unix');
|
||||
if (opts.unixSocket) {
|
||||
opts.protocol = opts.protocol.replace('+unix', '');
|
||||
}
|
||||
else if (!opts.protocol?.startsWith('ws') &&
|
||||
!opts.protocol?.startsWith('wx')) {
|
||||
delete opts.path;
|
||||
}
|
||||
parseAuthOptions(opts);
|
||||
if (opts.query && typeof opts.query.clientId === 'string') {
|
||||
opts.clientId = opts.query.clientId;
|
||||
}
|
||||
if (is_browser_1.default || opts.unixSocket) {
|
||||
opts.socksProxy = undefined;
|
||||
}
|
||||
else if (opts.socksProxy === undefined &&
|
||||
typeof process !== 'undefined') {
|
||||
opts.socksProxy = process.env['MQTTJS_SOCKS_PROXY'];
|
||||
}
|
||||
if (opts.cert && opts.key) {
|
||||
if (opts.protocol) {
|
||||
if (['mqtts', 'wss', 'wxs', 'alis'].indexOf(opts.protocol) === -1) {
|
||||
switch (opts.protocol) {
|
||||
case 'mqtt':
|
||||
opts.protocol = 'mqtts';
|
||||
break;
|
||||
case 'ws':
|
||||
opts.protocol = 'wss';
|
||||
break;
|
||||
case 'wx':
|
||||
opts.protocol = 'wxs';
|
||||
break;
|
||||
case 'ali':
|
||||
opts.protocol = 'alis';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown protocol for secure connection: "${opts.protocol}"!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error('Missing secure protocol key');
|
||||
}
|
||||
}
|
||||
if (!protocols) {
|
||||
protocols = {};
|
||||
if (!is_browser_1.default && !opts.forceNativeWebSocket) {
|
||||
protocols.ws = require('./ws').streamBuilder;
|
||||
protocols.wss = require('./ws').streamBuilder;
|
||||
protocols.mqtt = require('./tcp').default;
|
||||
protocols.tcp = require('./tcp').default;
|
||||
protocols.ssl = require('./tls').default;
|
||||
protocols.tls = protocols.ssl;
|
||||
protocols.mqtts = require('./tls').default;
|
||||
}
|
||||
else {
|
||||
protocols.ws = require('./ws').browserStreamBuilder;
|
||||
protocols.wss = require('./ws').browserStreamBuilder;
|
||||
protocols.wx = require('./wx').default;
|
||||
protocols.wxs = require('./wx').default;
|
||||
protocols.ali = require('./ali').default;
|
||||
protocols.alis = require('./ali').default;
|
||||
}
|
||||
}
|
||||
if (!protocols[opts.protocol]) {
|
||||
const isSecure = ['mqtts', 'wss'].indexOf(opts.protocol) !== -1;
|
||||
opts.protocol = [
|
||||
'mqtt',
|
||||
'mqtts',
|
||||
'ws',
|
||||
'wss',
|
||||
'wx',
|
||||
'wxs',
|
||||
'ali',
|
||||
'alis',
|
||||
].filter((key, index) => {
|
||||
if (isSecure && index % 2 === 0) {
|
||||
return false;
|
||||
}
|
||||
return typeof protocols[key] === 'function';
|
||||
})[0];
|
||||
}
|
||||
if (opts.clean === false && !opts.clientId) {
|
||||
throw new Error('Missing clientId for unclean clients');
|
||||
}
|
||||
if (opts.protocol) {
|
||||
opts.defaultProtocol = opts.protocol;
|
||||
}
|
||||
function wrapper(client) {
|
||||
if (opts.servers) {
|
||||
if (!client._reconnectCount ||
|
||||
client._reconnectCount === opts.servers.length) {
|
||||
client._reconnectCount = 0;
|
||||
}
|
||||
opts.host = opts.servers[client._reconnectCount].host;
|
||||
opts.port = opts.servers[client._reconnectCount].port;
|
||||
opts.protocol = !opts.servers[client._reconnectCount].protocol
|
||||
? opts.defaultProtocol
|
||||
: opts.servers[client._reconnectCount].protocol;
|
||||
opts.hostname = opts.host;
|
||||
client._reconnectCount++;
|
||||
}
|
||||
debug('calling streambuilder for', opts.protocol);
|
||||
return protocols[opts.protocol](client, opts);
|
||||
}
|
||||
const client = new client_1.default(wrapper, opts);
|
||||
client.on('error', () => {
|
||||
});
|
||||
return client;
|
||||
}
|
||||
function connectAsync(brokerUrl, opts, allowRetries = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const client = connect(brokerUrl, opts);
|
||||
const promiseResolutionListeners = {
|
||||
connect: (connack) => {
|
||||
removePromiseResolutionListeners();
|
||||
resolve(client);
|
||||
},
|
||||
end: () => {
|
||||
removePromiseResolutionListeners();
|
||||
resolve(client);
|
||||
},
|
||||
error: (err) => {
|
||||
removePromiseResolutionListeners();
|
||||
client.end();
|
||||
reject(err);
|
||||
},
|
||||
};
|
||||
if (allowRetries === false) {
|
||||
promiseResolutionListeners.close = () => {
|
||||
promiseResolutionListeners.error(new Error("Couldn't connect to server"));
|
||||
};
|
||||
}
|
||||
function removePromiseResolutionListeners() {
|
||||
Object.keys(promiseResolutionListeners).forEach((eventName) => {
|
||||
client.off(eventName, promiseResolutionListeners[eventName]);
|
||||
});
|
||||
}
|
||||
Object.keys(promiseResolutionListeners).forEach((eventName) => {
|
||||
client.on(eventName, promiseResolutionListeners[eventName]);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.default = connect;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/mqtt/build/lib/connect/index.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/connect/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
8
node_modules/mqtt/build/lib/connect/socks.d.ts
generated
vendored
Normal file
8
node_modules/mqtt/build/lib/connect/socks.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { type IStream } from '../shared';
|
||||
export interface SocksConnectionOptions {
|
||||
timeout?: number;
|
||||
lookup?: (hostname: string) => Promise<{
|
||||
address: string;
|
||||
}>;
|
||||
}
|
||||
export default function openSocks(destinationHost: string, destinationPort: number, socksUrl: string, options?: SocksConnectionOptions): IStream;
|
181
node_modules/mqtt/build/lib/connect/socks.js
generated
vendored
Normal file
181
node_modules/mqtt/build/lib/connect/socks.js
generated
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = openSocks;
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const stream_1 = require("stream");
|
||||
const socks_1 = require("socks");
|
||||
const dns = __importStar(require("dns"));
|
||||
const util_1 = require("util");
|
||||
const assert_1 = __importDefault(require("assert"));
|
||||
const debug = (0, debug_1.default)('mqttjs:socks');
|
||||
class ProxyStream extends stream_1.Duplex {
|
||||
_flowing = false;
|
||||
_socket;
|
||||
constructor() {
|
||||
super({ autoDestroy: false });
|
||||
this.cork();
|
||||
}
|
||||
_start(socket) {
|
||||
debug('proxy stream started');
|
||||
(0, assert_1.default)(!this._socket);
|
||||
if (this.destroyed) {
|
||||
socket.destroy(this.errored);
|
||||
return;
|
||||
}
|
||||
this._socket = socket;
|
||||
if (!this._flowing)
|
||||
socket.pause();
|
||||
socket.on('data', this._onData);
|
||||
socket.on('end', this._onEnd);
|
||||
socket.on('error', this._onError);
|
||||
socket.on('close', this._onClose);
|
||||
socket.emit('connect');
|
||||
this.uncork();
|
||||
}
|
||||
_write(chunk, encoding, callback) {
|
||||
(0, assert_1.default)(this._socket);
|
||||
this._socket.write(chunk, callback);
|
||||
}
|
||||
_read(size) {
|
||||
this._flowing = true;
|
||||
this._socket?.resume?.();
|
||||
}
|
||||
_destroy(error, callback) {
|
||||
this._socket?.destroy?.(error);
|
||||
callback(error);
|
||||
}
|
||||
_onData = (chunk) => {
|
||||
(0, assert_1.default)(this._socket);
|
||||
this._flowing = this.push(chunk);
|
||||
if (!this._flowing)
|
||||
this._socket.pause();
|
||||
};
|
||||
_onEnd = () => {
|
||||
debug('proxy stream received EOF');
|
||||
this.push(null);
|
||||
};
|
||||
_onClose = () => {
|
||||
debug('proxy stream closed');
|
||||
this.destroy();
|
||||
};
|
||||
_onError = (err) => {
|
||||
debug('proxy stream died with error %s', err);
|
||||
this.destroy(err);
|
||||
};
|
||||
}
|
||||
function fatal(e) {
|
||||
try {
|
||||
if (e.code === undefined)
|
||||
e.code = 'SOCKS';
|
||||
return e;
|
||||
}
|
||||
catch {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
function typeFromProtocol(proto) {
|
||||
switch (proto) {
|
||||
case 'socks5h:':
|
||||
return [5, true];
|
||||
case 'socks4a:':
|
||||
return [4, true];
|
||||
case 'socks5:':
|
||||
return [5, false];
|
||||
case 'socks4:':
|
||||
return [4, false];
|
||||
default:
|
||||
return [undefined, false];
|
||||
}
|
||||
}
|
||||
function parseSocksUrl(url) {
|
||||
const parsedUrl = new URL(url);
|
||||
if (parsedUrl.pathname || parsedUrl.hash || parsedUrl.search) {
|
||||
throw fatal(new Error('bad SOCKS URL'));
|
||||
}
|
||||
const [type, resolveThroughProxy] = typeFromProtocol(parsedUrl.protocol);
|
||||
if (!type) {
|
||||
throw fatal(new Error('bad SOCKS URL: invalid protocol'));
|
||||
}
|
||||
const port = parseInt(parsedUrl.port, 10);
|
||||
if (Number.isNaN(port)) {
|
||||
throw fatal(new Error('bad SOCKS URL: invalid port'));
|
||||
}
|
||||
const proxy = {
|
||||
host: parsedUrl.hostname,
|
||||
port,
|
||||
type,
|
||||
};
|
||||
return [proxy, resolveThroughProxy];
|
||||
}
|
||||
async function connectSocks(destinationHost, destinationPort, socksUrl, stream, options = {}) {
|
||||
const lookup = options.lookup ?? (0, util_1.promisify)(dns.lookup);
|
||||
const [proxy, resolveThroughProxy] = parseSocksUrl(socksUrl);
|
||||
if (!resolveThroughProxy) {
|
||||
debug('resolving %s locally', destinationHost);
|
||||
destinationHost = (await lookup(destinationHost, {
|
||||
family: proxy.type === 4 ? 4 : 0,
|
||||
})).address;
|
||||
}
|
||||
debug('establishing SOCKS%d connection to %s:%d via %s:%d', proxy.type, destinationHost, destinationPort, proxy.host, proxy.port);
|
||||
const socksClient = new socks_1.SocksClient({
|
||||
command: 'connect',
|
||||
destination: {
|
||||
host: destinationHost,
|
||||
port: destinationPort,
|
||||
},
|
||||
proxy: { ...proxy },
|
||||
timeout: options.timeout,
|
||||
});
|
||||
socksClient.connect();
|
||||
socksClient.on('established', ({ socket }) => stream._start(socket));
|
||||
socksClient.on('error', (e) => {
|
||||
debug('SOCKS failed: %s', e);
|
||||
stream.destroy(fatal(e));
|
||||
});
|
||||
}
|
||||
function openSocks(destinationHost, destinationPort, socksUrl, options) {
|
||||
debug('SOCKS connection to %s:%d via %s', destinationHost, destinationPort, socksUrl);
|
||||
const stream = new ProxyStream();
|
||||
connectSocks(destinationHost, destinationPort, socksUrl, stream, options).catch((e) => {
|
||||
debug('SOCKS failed: %s', e);
|
||||
stream.destroy(e);
|
||||
});
|
||||
return stream;
|
||||
}
|
||||
//# sourceMappingURL=socks.js.map
|
1
node_modules/mqtt/build/lib/connect/socks.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/connect/socks.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"socks.js","sourceRoot":"","sources":["../../../src/lib/connect/socks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgNA,4BA2BC;AA3OD,kDAA0B;AAC1B,mCAA+B;AAC/B,iCAAoD;AACpD,yCAA0B;AAE1B,+BAAgC;AAEhC,oDAA2B;AAG3B,MAAM,KAAK,GAAG,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;AAOpC,MAAM,WAAY,SAAQ,eAAM;IACvB,QAAQ,GAAG,KAAK,CAAA;IAEhB,OAAO,CAAS;IAExB;QACC,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAA;QAE7B,IAAI,CAAC,IAAI,EAAE,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,MAAc;QACpB,KAAK,CAAC,sBAAsB,CAAC,CAAA;QAE7B,IAAA,gBAAM,EAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAErB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAC5B,OAAM;QACP,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QAErB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,CAAC,KAAK,EAAE,CAAA;QAElC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAC7B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QACjC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IA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AO;KACxB,CAAC,CAAA;IACF,WAAW,CAAC,OAAO,EAAE,CAAA;IAErB,WAAW,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAEpE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QAC7B,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAA;QAC5B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACzB,CAAC,CAAC,CAAA;AACH,CAAC;AAED,SAAwB,SAAS,CAChC,eAAuB,EACvB,eAAuB,EACvB,QAAgB,EAChB,OAAgC;IAEhC,KAAK,CACJ,kCAAkC,EAClC,eAAe,EACf,eAAe,EACf,QAAQ,CACR,CAAA;IAED,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;IAEhC,YAAY,CACX,eAAe,EACf,eAAe,EACf,QAAQ,EACR,MAAM,EACN,OAAO,CACP,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACb,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAA;QAC5B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACd,CAAC"}
|
3
node_modules/mqtt/build/lib/connect/tcp.d.ts
generated
vendored
Normal file
3
node_modules/mqtt/build/lib/connect/tcp.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type StreamBuilder } from '../shared';
|
||||
declare const buildStream: StreamBuilder;
|
||||
export default buildStream;
|
24
node_modules/mqtt/build/lib/connect/tcp.js
generated
vendored
Normal file
24
node_modules/mqtt/build/lib/connect/tcp.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const net_1 = __importDefault(require("net"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const socks_1 = __importDefault(require("./socks"));
|
||||
const debug = (0, debug_1.default)('mqttjs:tcp');
|
||||
const buildStream = (client, opts) => {
|
||||
opts.port = opts.port || 1883;
|
||||
opts.hostname = opts.hostname || opts.host || 'localhost';
|
||||
if (opts.socksProxy) {
|
||||
return (0, socks_1.default)(opts.hostname, opts.port, opts.socksProxy, {
|
||||
timeout: opts.socksTimeout,
|
||||
});
|
||||
}
|
||||
const { port, path } = opts;
|
||||
const host = opts.hostname;
|
||||
debug('port %d and host %s', port, host);
|
||||
return net_1.default.createConnection({ port, host, path });
|
||||
};
|
||||
exports.default = buildStream;
|
||||
//# sourceMappingURL=tcp.js.map
|
1
node_modules/mqtt/build/lib/connect/tcp.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/connect/tcp.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tcp.js","sourceRoot":"","sources":["../../../src/lib/connect/tcp.ts"],"names":[],"mappings":";;;;;AAAA,8CAAqB;AACrB,kDAA0B;AAE1B,oDAA+B;AAE/B,MAAM,KAAK,GAAG,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;AAKlC,MAAM,WAAW,GAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;IACnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAA;IAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,WAAW,CAAA;IAEzD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACrB,OAAO,IAAA,eAAS,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE;YAC3D,OAAO,EAAE,IAAI,CAAC,YAAY;SAC1B,CAAC,CAAA;IACH,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAA;IAE1B,KAAK,CAAC,qBAAqB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACxC,OAAO,aAAG,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;AAClD,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
3
node_modules/mqtt/build/lib/connect/tls.d.ts
generated
vendored
Normal file
3
node_modules/mqtt/build/lib/connect/tls.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type StreamBuilder } from '../shared';
|
||||
declare const buildStream: StreamBuilder;
|
||||
export default buildStream;
|
52
node_modules/mqtt/build/lib/connect/tls.js
generated
vendored
Normal file
52
node_modules/mqtt/build/lib/connect/tls.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tls_1 = require("tls");
|
||||
const net_1 = __importDefault(require("net"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const socks_1 = __importDefault(require("./socks"));
|
||||
const debug = (0, debug_1.default)('mqttjs:tls');
|
||||
function connect(opts) {
|
||||
const { host, port, socksProxy, ...rest } = opts;
|
||||
if (socksProxy !== undefined) {
|
||||
const socket = (0, socks_1.default)(host, port, socksProxy, {
|
||||
timeout: opts.socksTimeout,
|
||||
});
|
||||
return (0, tls_1.connect)({
|
||||
...rest,
|
||||
socket,
|
||||
});
|
||||
}
|
||||
return (0, tls_1.connect)(opts);
|
||||
}
|
||||
const buildStream = (client, opts) => {
|
||||
opts.port = opts.port || 8883;
|
||||
opts.host = opts.hostname || opts.host || 'localhost';
|
||||
if (net_1.default.isIP(opts.host) === 0) {
|
||||
opts.servername = opts.host;
|
||||
}
|
||||
opts.rejectUnauthorized = opts.rejectUnauthorized !== false;
|
||||
delete opts.path;
|
||||
debug('port %d host %s rejectUnauthorized %b', opts.port, opts.host, opts.rejectUnauthorized);
|
||||
const connection = connect(opts);
|
||||
connection.on('secureConnect', () => {
|
||||
if (opts.rejectUnauthorized && !connection.authorized) {
|
||||
connection.emit('error', new Error('TLS not authorized'));
|
||||
}
|
||||
else {
|
||||
connection.removeListener('error', handleTLSerrors);
|
||||
}
|
||||
});
|
||||
function handleTLSerrors(err) {
|
||||
if (opts.rejectUnauthorized) {
|
||||
client.emit('error', err);
|
||||
}
|
||||
connection.end();
|
||||
}
|
||||
connection.on('error', handleTLSerrors);
|
||||
return connection;
|
||||
};
|
||||
exports.default = buildStream;
|
||||
//# sourceMappingURL=tls.js.map
|
1
node_modules/mqtt/build/lib/connect/tls.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/connect/tls.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"tls.js","sourceRoot":"","sources":["../../../src/lib/connect/tls.ts"],"names":[],"mappings":";;;;;AAAA,6BAA2D;AAC3D,8CAAqB;AACrB,kDAA0B;AAG1B,oDAA+B;AAE/B,MAAM,KAAK,GAAG,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;AAElC,SAAS,OAAO,CAAC,IAAoB;IACpC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;IAEhD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAA,eAAS,EAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE;YAChD,OAAO,EAAE,IAAI,CAAC,YAAY;SAC1B,CAAC,CAAA;QAEF,OAAO,IAAA,aAAU,EAAC;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C1B,CAAC;QAOD,UAAU,CAAC,GAAG,EAAE,CAAA;IACjB,CAAC;IAED,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IACvC,OAAO,UAAU,CAAA;AAClB,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
4
node_modules/mqtt/build/lib/connect/ws.d.ts
generated
vendored
Normal file
4
node_modules/mqtt/build/lib/connect/ws.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { type StreamBuilder } from '../shared';
|
||||
declare const streamBuilder: StreamBuilder;
|
||||
declare const browserStreamBuilder: StreamBuilder;
|
||||
export { browserStreamBuilder, streamBuilder };
|
220
node_modules/mqtt/build/lib/connect/ws.js
generated
vendored
Normal file
220
node_modules/mqtt/build/lib/connect/ws.js
generated
vendored
Normal file
@@ -0,0 +1,220 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.streamBuilder = exports.browserStreamBuilder = void 0;
|
||||
const buffer_1 = require("buffer");
|
||||
const ws_1 = __importDefault(require("ws"));
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const readable_stream_1 = require("readable-stream");
|
||||
const is_browser_1 = __importDefault(require("../is-browser"));
|
||||
const BufferedDuplex_1 = require("../BufferedDuplex");
|
||||
const debug = (0, debug_1.default)('mqttjs:ws');
|
||||
const WSS_OPTIONS = [
|
||||
'rejectUnauthorized',
|
||||
'ca',
|
||||
'cert',
|
||||
'key',
|
||||
'pfx',
|
||||
'passphrase',
|
||||
];
|
||||
function buildUrl(opts, client) {
|
||||
let url = `${opts.protocol}://${opts.hostname}:${opts.port}${opts.path}`;
|
||||
if (typeof opts.transformWsUrl === 'function') {
|
||||
url = opts.transformWsUrl(url, opts, client);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
function setDefaultOpts(opts) {
|
||||
const options = opts;
|
||||
if (!opts.port) {
|
||||
if (opts.protocol === 'wss') {
|
||||
options.port = 443;
|
||||
}
|
||||
else {
|
||||
options.port = 80;
|
||||
}
|
||||
}
|
||||
if (!opts.path) {
|
||||
options.path = '/';
|
||||
}
|
||||
if (!opts.wsOptions) {
|
||||
options.wsOptions = {};
|
||||
}
|
||||
if (!is_browser_1.default && !opts.forceNativeWebSocket && opts.protocol === 'wss') {
|
||||
WSS_OPTIONS.forEach((prop) => {
|
||||
if (Object.prototype.hasOwnProperty.call(opts, prop) &&
|
||||
!Object.prototype.hasOwnProperty.call(opts.wsOptions, prop)) {
|
||||
options.wsOptions[prop] = opts[prop];
|
||||
}
|
||||
});
|
||||
}
|
||||
return options;
|
||||
}
|
||||
function setDefaultBrowserOpts(opts) {
|
||||
const options = setDefaultOpts(opts);
|
||||
if (!options.hostname) {
|
||||
options.hostname = options.host;
|
||||
}
|
||||
if (!options.hostname) {
|
||||
if (typeof document === 'undefined') {
|
||||
throw new Error('Could not determine host. Specify host manually.');
|
||||
}
|
||||
const parsed = new URL(document.URL);
|
||||
options.hostname = parsed.hostname;
|
||||
if (!options.port) {
|
||||
options.port = Number(parsed.port);
|
||||
}
|
||||
}
|
||||
if (options.objectMode === undefined) {
|
||||
options.objectMode = !(options.binary === true || options.binary === undefined);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
function createWebSocket(client, url, opts) {
|
||||
debug('createWebSocket');
|
||||
debug(`protocol: ${opts.protocolId} ${opts.protocolVersion}`);
|
||||
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
|
||||
? 'mqttv3.1'
|
||||
: 'mqtt';
|
||||
debug(`creating new Websocket for url: ${url} and protocol: ${websocketSubProtocol}`);
|
||||
let socket;
|
||||
if (opts.createWebsocket) {
|
||||
socket = opts.createWebsocket(url, [websocketSubProtocol], opts);
|
||||
}
|
||||
else {
|
||||
socket = new ws_1.default(url, [websocketSubProtocol], opts.wsOptions);
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
function createBrowserWebSocket(client, opts) {
|
||||
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
|
||||
? 'mqttv3.1'
|
||||
: 'mqtt';
|
||||
const url = buildUrl(opts, client);
|
||||
let socket;
|
||||
if (opts.createWebsocket) {
|
||||
socket = opts.createWebsocket(url, [websocketSubProtocol], opts);
|
||||
}
|
||||
else {
|
||||
socket = new WebSocket(url, [websocketSubProtocol]);
|
||||
}
|
||||
socket.binaryType = 'arraybuffer';
|
||||
return socket;
|
||||
}
|
||||
const streamBuilder = (client, opts) => {
|
||||
debug('streamBuilder');
|
||||
const options = setDefaultOpts(opts);
|
||||
options.hostname = options.hostname || options.host || 'localhost';
|
||||
const url = buildUrl(options, client);
|
||||
const socket = createWebSocket(client, url, options);
|
||||
const webSocketStream = ws_1.default.createWebSocketStream(socket, options.wsOptions);
|
||||
webSocketStream['url'] = url;
|
||||
socket.on('close', () => {
|
||||
webSocketStream.destroy();
|
||||
});
|
||||
return webSocketStream;
|
||||
};
|
||||
exports.streamBuilder = streamBuilder;
|
||||
const browserStreamBuilder = (client, opts) => {
|
||||
debug('browserStreamBuilder');
|
||||
let stream;
|
||||
const options = setDefaultBrowserOpts(opts);
|
||||
const bufferSize = options.browserBufferSize || 1024 * 512;
|
||||
const bufferTimeout = opts.browserBufferTimeout || 1000;
|
||||
const coerceToBuffer = !opts.objectMode;
|
||||
const socket = createBrowserWebSocket(client, opts);
|
||||
const proxy = buildProxy(opts, socketWriteBrowser, socketEndBrowser);
|
||||
if (!opts.objectMode) {
|
||||
proxy._writev = BufferedDuplex_1.writev.bind(proxy);
|
||||
}
|
||||
proxy.on('close', () => {
|
||||
socket.close();
|
||||
});
|
||||
const eventListenerSupport = typeof socket.addEventListener !== 'undefined';
|
||||
if (socket.readyState === socket.OPEN) {
|
||||
stream = proxy;
|
||||
stream.socket = socket;
|
||||
}
|
||||
else {
|
||||
stream = new BufferedDuplex_1.BufferedDuplex(opts, proxy, socket);
|
||||
if (eventListenerSupport) {
|
||||
socket.addEventListener('open', onOpen);
|
||||
}
|
||||
else {
|
||||
socket.onopen = onOpen;
|
||||
}
|
||||
}
|
||||
if (eventListenerSupport) {
|
||||
socket.addEventListener('close', onClose);
|
||||
socket.addEventListener('error', onError);
|
||||
socket.addEventListener('message', onMessage);
|
||||
}
|
||||
else {
|
||||
socket.onclose = onClose;
|
||||
socket.onerror = onError;
|
||||
socket.onmessage = onMessage;
|
||||
}
|
||||
function buildProxy(pOptions, socketWrite, socketEnd) {
|
||||
const _proxy = new readable_stream_1.Transform({
|
||||
objectMode: pOptions.objectMode,
|
||||
});
|
||||
_proxy._write = socketWrite;
|
||||
_proxy._flush = socketEnd;
|
||||
return _proxy;
|
||||
}
|
||||
function onOpen() {
|
||||
debug('WebSocket onOpen');
|
||||
if (stream instanceof BufferedDuplex_1.BufferedDuplex) {
|
||||
stream.socketReady();
|
||||
}
|
||||
}
|
||||
function onClose(event) {
|
||||
debug('WebSocket onClose', event);
|
||||
stream.end();
|
||||
stream.destroy();
|
||||
}
|
||||
function onError(err) {
|
||||
debug('WebSocket onError', err);
|
||||
const error = new Error('WebSocket error');
|
||||
error['event'] = err;
|
||||
stream.destroy(error);
|
||||
}
|
||||
async function onMessage(event) {
|
||||
if (!proxy || proxy.destroyed || !proxy.readable) {
|
||||
return;
|
||||
}
|
||||
let { data } = event;
|
||||
if (data instanceof ArrayBuffer)
|
||||
data = buffer_1.Buffer.from(data);
|
||||
else if (data instanceof Blob)
|
||||
data = buffer_1.Buffer.from(await new Response(data).arrayBuffer());
|
||||
else
|
||||
data = buffer_1.Buffer.from(data, 'utf8');
|
||||
proxy.push(data);
|
||||
}
|
||||
function socketWriteBrowser(chunk, enc, next) {
|
||||
if (socket.bufferedAmount > bufferSize) {
|
||||
setTimeout(socketWriteBrowser, bufferTimeout, chunk, enc, next);
|
||||
return;
|
||||
}
|
||||
if (coerceToBuffer && typeof chunk === 'string') {
|
||||
chunk = buffer_1.Buffer.from(chunk, 'utf8');
|
||||
}
|
||||
try {
|
||||
socket.send(chunk);
|
||||
}
|
||||
catch (err) {
|
||||
return next(err);
|
||||
}
|
||||
next();
|
||||
}
|
||||
function socketEndBrowser(done) {
|
||||
socket.close();
|
||||
done();
|
||||
}
|
||||
return stream;
|
||||
};
|
||||
exports.browserStreamBuilder = browserStreamBuilder;
|
||||
//# sourceMappingURL=ws.js.map
|
1
node_modules/mqtt/build/lib/connect/ws.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/connect/ws.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/mqtt/build/lib/connect/wx.d.ts
generated
vendored
Normal file
6
node_modules/mqtt/build/lib/connect/wx.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { type StreamBuilder } from '../shared';
|
||||
declare global {
|
||||
const wx: any;
|
||||
}
|
||||
declare const buildStream: StreamBuilder;
|
||||
export default buildStream;
|
115
node_modules/mqtt/build/lib/connect/wx.js
generated
vendored
Normal file
115
node_modules/mqtt/build/lib/connect/wx.js
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const buffer_1 = require("buffer");
|
||||
const readable_stream_1 = require("readable-stream");
|
||||
const BufferedDuplex_1 = require("../BufferedDuplex");
|
||||
let socketTask;
|
||||
let proxy;
|
||||
let stream;
|
||||
function buildProxy() {
|
||||
const _proxy = new readable_stream_1.Transform();
|
||||
_proxy._write = (chunk, encoding, next) => {
|
||||
socketTask.send({
|
||||
data: chunk.buffer,
|
||||
success() {
|
||||
next();
|
||||
},
|
||||
fail(errMsg) {
|
||||
next(new Error(errMsg));
|
||||
},
|
||||
});
|
||||
};
|
||||
_proxy._flush = (done) => {
|
||||
socketTask.close({
|
||||
success() {
|
||||
done();
|
||||
},
|
||||
});
|
||||
};
|
||||
return _proxy;
|
||||
}
|
||||
function setDefaultOpts(opts) {
|
||||
if (!opts.hostname) {
|
||||
opts.hostname = 'localhost';
|
||||
}
|
||||
if (!opts.path) {
|
||||
opts.path = '/';
|
||||
}
|
||||
if (!opts.wsOptions) {
|
||||
opts.wsOptions = {};
|
||||
}
|
||||
}
|
||||
function buildUrl(opts, client) {
|
||||
const protocol = opts.protocol === 'wxs' ? 'wss' : 'ws';
|
||||
let url = `${protocol}://${opts.hostname}${opts.path}`;
|
||||
if (opts.port && opts.port !== 80 && opts.port !== 443) {
|
||||
url = `${protocol}://${opts.hostname}:${opts.port}${opts.path}`;
|
||||
}
|
||||
if (typeof opts.transformWsUrl === 'function') {
|
||||
url = opts.transformWsUrl(url, opts, client);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
function bindEventHandler() {
|
||||
socketTask.onOpen(() => {
|
||||
stream.socketReady();
|
||||
});
|
||||
socketTask.onMessage((res) => {
|
||||
let { data } = res;
|
||||
if (data instanceof ArrayBuffer)
|
||||
data = buffer_1.Buffer.from(data);
|
||||
else
|
||||
data = buffer_1.Buffer.from(data, 'utf8');
|
||||
proxy.push(data);
|
||||
});
|
||||
socketTask.onClose(() => {
|
||||
stream.emit('close');
|
||||
stream.end();
|
||||
stream.destroy();
|
||||
});
|
||||
socketTask.onError((error) => {
|
||||
const err = new Error(error.errMsg);
|
||||
stream.destroy(err);
|
||||
});
|
||||
}
|
||||
const buildStream = (client, opts) => {
|
||||
opts.hostname = opts.hostname || opts.host;
|
||||
if (!opts.hostname) {
|
||||
throw new Error('Could not determine host. Specify host manually.');
|
||||
}
|
||||
const websocketSubProtocol = opts.protocolId === 'MQIsdp' && opts.protocolVersion === 3
|
||||
? 'mqttv3.1'
|
||||
: 'mqtt';
|
||||
setDefaultOpts(opts);
|
||||
const url = buildUrl(opts, client);
|
||||
socketTask = wx.connectSocket({
|
||||
url,
|
||||
protocols: [websocketSubProtocol],
|
||||
});
|
||||
proxy = buildProxy();
|
||||
stream = new BufferedDuplex_1.BufferedDuplex(opts, proxy, socketTask);
|
||||
stream._destroy = (err, cb) => {
|
||||
socketTask.close({
|
||||
success() {
|
||||
if (cb)
|
||||
cb(err);
|
||||
},
|
||||
});
|
||||
};
|
||||
const destroyRef = stream.destroy;
|
||||
stream.destroy = (err, cb) => {
|
||||
stream.destroy = destroyRef;
|
||||
setTimeout(() => {
|
||||
socketTask.close({
|
||||
fail() {
|
||||
stream._destroy(err, cb);
|
||||
},
|
||||
});
|
||||
}, 0);
|
||||
return stream;
|
||||
};
|
||||
bindEventHandler();
|
||||
return stream;
|
||||
};
|
||||
exports.default = buildStream;
|
||||
//# sourceMappingURL=wx.js.map
|
1
node_modules/mqtt/build/lib/connect/wx.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/connect/wx.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"wx.js","sourceRoot":"","sources":["../../../src/lib/connect/wx.ts"],"names":[],"mappings":";;AAAA,mCAA+B;AAC/B,qDAA2C;AAI3C,sDAAkD;AAGlD,IAAI,UAAe,CAAA;AACnB,IAAI,KAAgB,CAAA;AACpB,IAAI,MAAsB,CAAA;AAM1B,SAAS,UAAU;IAClB,MAAM,MAAM,GAAG,IAAI,2BAAS,EAAE,CAAA;IAC9B,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;QACzC,UAAU,CAAC,IAAI,CAAC;YACf,IAAI,EAAE,KAAK,CAAC,MAAM;YAClB,OAAO;gBACN,IAAI,EAAE,CAAA;YACP,CAAC;YACD,IAAI,CAAC,MAAM;gBACV,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;YACxB,CAAC;SACD,CAAC,CAAA;IACH,CAAC,CAAA;IACD,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE;QACxB,UAAU,CAAC,KAAK,CAAC;YAChB,OAAO;gBACN,IAAI,EAAE,CAAA;YACP,CAAC;SACD,CAAC,CAAA;IACH,CAAC,CAAA;IAED,OAAO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C;QAC7B,GAAG;QACH,SAAS,EAAE,CAAC,oBAAoB,CAAC;KACjC,CAAC,CAAA;IAEF,KAAK,GAAG,UAAU,EAAE,CAAA;IACpB,MAAM,GAAG,IAAI,+BAAc,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;IACpD,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;QAC7B,UAAU,CAAC,KAAK,CAAC;YAChB,OAAO;gBACN,IAAI,EAAE;oBAAE,EAAE,CAAC,GAAG,CAAC,CAAA;YAChB,CAAC;SACD,CAAC,CAAA;IACH,CAAC,CAAA;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAA;IACjC,MAAM,CAAC,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;QAC5B,MAAM,CAAC,OAAO,GAAG,UAAU,CAAA;QAE3B,UAAU,CAAC,GAAG,EAAE;YACf,UAAU,CAAC,KAAK,CAAC;gBAChB,IAAI;oBACH,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;gBACzB,CAAC;aACD,CAAC,CAAA;QACH,CAAC,EAAE,CAAC,CAAC,CAAA;QAEL,OAAO,MAAM,CAAA;IACd,CAAC,CAAA;IAED,gBAAgB,EAAE,CAAA;IAElB,OAAO,MAAM,CAAA;AACd,CAAC,CAAA;AAED,kBAAe,WAAW,CAAA"}
|
16
node_modules/mqtt/build/lib/default-message-id-provider.d.ts
generated
vendored
Normal file
16
node_modules/mqtt/build/lib/default-message-id-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
export interface IMessageIdProvider {
|
||||
allocate(): number | null;
|
||||
getLastAllocated(): number | null;
|
||||
register(num: number): boolean;
|
||||
deallocate(num: number): void;
|
||||
clear(): void;
|
||||
}
|
||||
export default class DefaultMessageIdProvider implements IMessageIdProvider {
|
||||
private nextId;
|
||||
constructor();
|
||||
allocate(): number;
|
||||
getLastAllocated(): number;
|
||||
register(messageId: number): boolean;
|
||||
deallocate(messageId: number): void;
|
||||
clear(): void;
|
||||
}
|
25
node_modules/mqtt/build/lib/default-message-id-provider.js
generated
vendored
Normal file
25
node_modules/mqtt/build/lib/default-message-id-provider.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class DefaultMessageIdProvider {
|
||||
nextId;
|
||||
constructor() {
|
||||
this.nextId = Math.max(1, Math.floor(Math.random() * 65535));
|
||||
}
|
||||
allocate() {
|
||||
const id = this.nextId++;
|
||||
if (this.nextId === 65536) {
|
||||
this.nextId = 1;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
getLastAllocated() {
|
||||
return this.nextId === 1 ? 65535 : this.nextId - 1;
|
||||
}
|
||||
register(messageId) {
|
||||
return true;
|
||||
}
|
||||
deallocate(messageId) { }
|
||||
clear() { }
|
||||
}
|
||||
exports.default = DefaultMessageIdProvider;
|
||||
//# sourceMappingURL=default-message-id-provider.js.map
|
1
node_modules/mqtt/build/lib/default-message-id-provider.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/default-message-id-provider.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"default-message-id-provider.js","sourceRoot":"","sources":["../../src/lib/default-message-id-provider.ts"],"names":[],"mappings":";;AAwCA,MAAqB,wBAAwB;IACpC,MAAM,CAAQ;IAEtB;QAKC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,CAAA;IAC7D,CAAC;IAQD,QAAQ;QAEP,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QAExB,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QAChB,CAAC;QACD,OAAO,EAAE,CAAA;IACV,CAAC;IAOD,gBAAgB;QACf,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IACnD,CAAC;IAQD,QAAQ,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAA;IACZ,CAAC;IAOD,UAAU,CAAC,SAAiB,IAAG,CAAC;IAMhC,KAAK,KAAI,CAAC;CACV;AA1DD,2CA0DC"}
|
8
node_modules/mqtt/build/lib/get-timer.d.ts
generated
vendored
Normal file
8
node_modules/mqtt/build/lib/get-timer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { clearInterval as clearI, setInterval as setI } from 'worker-timers';
|
||||
import type { TimerVariant } from './shared';
|
||||
export interface Timer {
|
||||
set: typeof setI;
|
||||
clear: typeof clearI;
|
||||
}
|
||||
declare const getTimer: (variant: TimerVariant) => Timer;
|
||||
export default getTimer;
|
63
node_modules/mqtt/build/lib/get-timer.js
generated
vendored
Normal file
63
node_modules/mqtt/build/lib/get-timer.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const worker_timers_1 = require("worker-timers");
|
||||
const is_browser_1 = __importStar(require("./is-browser"));
|
||||
const workerTimer = {
|
||||
set: worker_timers_1.setInterval,
|
||||
clear: worker_timers_1.clearInterval,
|
||||
};
|
||||
const nativeTimer = {
|
||||
set: (func, time) => setInterval(func, time),
|
||||
clear: (timerId) => clearInterval(timerId),
|
||||
};
|
||||
const getTimer = (variant) => {
|
||||
switch (variant) {
|
||||
case 'native': {
|
||||
return nativeTimer;
|
||||
}
|
||||
case 'worker': {
|
||||
return workerTimer;
|
||||
}
|
||||
case 'auto':
|
||||
default: {
|
||||
return is_browser_1.default && !is_browser_1.isWebWorker && !is_browser_1.isReactNativeBrowser
|
||||
? workerTimer
|
||||
: nativeTimer;
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.default = getTimer;
|
||||
//# sourceMappingURL=get-timer.js.map
|
1
node_modules/mqtt/build/lib/get-timer.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/get-timer.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"get-timer.js","sourceRoot":"","sources":["../../src/lib/get-timer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA4E;AAC5E,2DAA2E;AAW3E,MAAM,WAAW,GAAU;IAC1B,GAAG,EAAE,2BAAI;IACT,KAAK,EAAE,6BAAM;CACb,CAAA;AAED,MAAM,WAAW,GAAU;IAC1B,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;IAC5C,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC;CAC1C,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,OAAqB,EAAS,EAAE;IACjD,QAAQ,OAAO,EAAE,CAAC;QACjB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACf,OAAO,WAAW,CAAA;QACnB,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACf,OAAO,WAAW,CAAA;QACnB,CAAC;QACD,KAAK,MAAM,CAAC;QACZ,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,oBAAS,IAAI,CAAC,wBAAW,IAAI,CAAC,iCAAoB;gBACxD,CAAC,CAAC,WAAW;gBACb,CAAC,CAAC,WAAW,CAAA;QACf,CAAC;IACF,CAAC;AACF,CAAC,CAAA;AAED,kBAAe,QAAQ,CAAA"}
|
48
node_modules/mqtt/build/lib/handlers/ack.d.ts
generated
vendored
Normal file
48
node_modules/mqtt/build/lib/handlers/ack.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import { type PacketHandler } from '../shared';
|
||||
export declare const ReasonCodes: {
|
||||
0: string;
|
||||
1: string;
|
||||
2: string;
|
||||
3: string;
|
||||
4: string;
|
||||
5: string;
|
||||
16: string;
|
||||
17: string;
|
||||
128: string;
|
||||
129: string;
|
||||
130: string;
|
||||
131: string;
|
||||
132: string;
|
||||
133: string;
|
||||
134: string;
|
||||
135: string;
|
||||
136: string;
|
||||
137: string;
|
||||
138: string;
|
||||
139: string;
|
||||
140: string;
|
||||
141: string;
|
||||
142: string;
|
||||
143: string;
|
||||
144: string;
|
||||
145: string;
|
||||
146: string;
|
||||
147: string;
|
||||
148: string;
|
||||
149: string;
|
||||
150: string;
|
||||
151: string;
|
||||
152: string;
|
||||
153: string;
|
||||
154: string;
|
||||
155: string;
|
||||
156: string;
|
||||
157: string;
|
||||
158: string;
|
||||
159: string;
|
||||
160: string;
|
||||
161: string;
|
||||
162: string;
|
||||
};
|
||||
declare const handleAck: PacketHandler;
|
||||
export default handleAck;
|
131
node_modules/mqtt/build/lib/handlers/ack.js
generated
vendored
Normal file
131
node_modules/mqtt/build/lib/handlers/ack.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ReasonCodes = void 0;
|
||||
const shared_1 = require("../shared");
|
||||
exports.ReasonCodes = {
|
||||
0: '',
|
||||
1: 'Unacceptable protocol version',
|
||||
2: 'Identifier rejected',
|
||||
3: 'Server unavailable',
|
||||
4: 'Bad username or password',
|
||||
5: 'Not authorized',
|
||||
16: 'No matching subscribers',
|
||||
17: 'No subscription existed',
|
||||
128: 'Unspecified error',
|
||||
129: 'Malformed Packet',
|
||||
130: 'Protocol Error',
|
||||
131: 'Implementation specific error',
|
||||
132: 'Unsupported Protocol Version',
|
||||
133: 'Client Identifier not valid',
|
||||
134: 'Bad User Name or Password',
|
||||
135: 'Not authorized',
|
||||
136: 'Server unavailable',
|
||||
137: 'Server busy',
|
||||
138: 'Banned',
|
||||
139: 'Server shutting down',
|
||||
140: 'Bad authentication method',
|
||||
141: 'Keep Alive timeout',
|
||||
142: 'Session taken over',
|
||||
143: 'Topic Filter invalid',
|
||||
144: 'Topic Name invalid',
|
||||
145: 'Packet identifier in use',
|
||||
146: 'Packet Identifier not found',
|
||||
147: 'Receive Maximum exceeded',
|
||||
148: 'Topic Alias invalid',
|
||||
149: 'Packet too large',
|
||||
150: 'Message rate too high',
|
||||
151: 'Quota exceeded',
|
||||
152: 'Administrative action',
|
||||
153: 'Payload format invalid',
|
||||
154: 'Retain not supported',
|
||||
155: 'QoS not supported',
|
||||
156: 'Use another server',
|
||||
157: 'Server moved',
|
||||
158: 'Shared Subscriptions not supported',
|
||||
159: 'Connection rate exceeded',
|
||||
160: 'Maximum connect time',
|
||||
161: 'Subscription Identifiers not supported',
|
||||
162: 'Wildcard Subscriptions not supported',
|
||||
};
|
||||
const handleAck = (client, packet) => {
|
||||
const { messageId } = packet;
|
||||
const type = packet.cmd;
|
||||
let response = null;
|
||||
const cb = client.outgoing[messageId] ? client.outgoing[messageId].cb : null;
|
||||
let err = null;
|
||||
if (!cb) {
|
||||
client.log('_handleAck :: Server sent an ack in error. Ignoring.');
|
||||
return;
|
||||
}
|
||||
client.log('_handleAck :: packet type', type);
|
||||
switch (type) {
|
||||
case 'pubcomp':
|
||||
case 'puback': {
|
||||
const pubackRC = packet.reasonCode;
|
||||
if (pubackRC && pubackRC > 0 && pubackRC !== 16) {
|
||||
err = new shared_1.ErrorWithReasonCode(`Publish error: ${exports.ReasonCodes[pubackRC]}`, pubackRC);
|
||||
client['_removeOutgoingAndStoreMessage'](messageId, () => {
|
||||
cb(err, packet);
|
||||
});
|
||||
}
|
||||
else {
|
||||
client['_removeOutgoingAndStoreMessage'](messageId, cb);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'pubrec': {
|
||||
response = {
|
||||
cmd: 'pubrel',
|
||||
qos: 2,
|
||||
messageId,
|
||||
};
|
||||
const pubrecRC = packet.reasonCode;
|
||||
if (pubrecRC && pubrecRC > 0 && pubrecRC !== 16) {
|
||||
err = new shared_1.ErrorWithReasonCode(`Publish error: ${exports.ReasonCodes[pubrecRC]}`, pubrecRC);
|
||||
client['_removeOutgoingAndStoreMessage'](messageId, () => {
|
||||
cb(err, packet);
|
||||
});
|
||||
}
|
||||
else {
|
||||
client['_sendPacket'](response);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'suback': {
|
||||
delete client.outgoing[messageId];
|
||||
client.messageIdProvider.deallocate(messageId);
|
||||
const granted = packet.granted;
|
||||
for (let grantedI = 0; grantedI < granted.length; grantedI++) {
|
||||
const subackRC = granted[grantedI];
|
||||
if ((subackRC & 0x80) !== 0) {
|
||||
err = new Error(`Subscribe error: ${exports.ReasonCodes[subackRC]}`);
|
||||
err.code = subackRC;
|
||||
const topics = client.messageIdToTopic[messageId];
|
||||
if (topics) {
|
||||
topics.forEach((topic) => {
|
||||
delete client['_resubscribeTopics'][topic];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
delete client.messageIdToTopic[messageId];
|
||||
client['_invokeStoreProcessingQueue']();
|
||||
cb(err, packet);
|
||||
break;
|
||||
}
|
||||
case 'unsuback': {
|
||||
delete client.outgoing[messageId];
|
||||
client.messageIdProvider.deallocate(messageId);
|
||||
client['_invokeStoreProcessingQueue']();
|
||||
cb(null, packet);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
client.emit('error', new Error('unrecognized packet type'));
|
||||
}
|
||||
if (client.disconnecting && Object.keys(client.outgoing).length === 0) {
|
||||
client.emit('outgoingEmpty');
|
||||
}
|
||||
};
|
||||
exports.default = handleAck;
|
||||
//# sourceMappingURL=ack.js.map
|
1
node_modules/mqtt/build/lib/handlers/ack.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/handlers/ack.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ack.js","sourceRoot":"","sources":["../../../src/lib/handlers/ack.ts"],"names":[],"mappings":";;;AAEA,sCAAmE;AAEtD,QAAA,WAAW,GAAG;IAC1B,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,+BAA+B;IAClC,CAAC,EAAE,qBAAqB;IACxB,CAAC,EAAE,oBAAoB;IACvB,CAAC,EAAE,0BAA0B;IAC7B,CAAC,EAAE,gBAAgB;IACnB,EAAE,EAAE,yBAAyB;IAC7B,EAAE,EAAE,yBAAyB;IAC7B,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,+BAA+B;IACpC,GAAG,EA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S,CAAC,CAAA;YACjC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;YAC9C,MAAM,CAAC,6BAA6B,CAAC,EAAE,CAAA;YACvC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAChB,MAAK;QACN,CAAC;QACD;YACC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,IAAI,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC7B,CAAC;AACF,CAAC,CAAA;AAED,kBAAe,SAAS,CAAA"}
|
3
node_modules/mqtt/build/lib/handlers/auth.d.ts
generated
vendored
Normal file
3
node_modules/mqtt/build/lib/handlers/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type PacketHandler } from '../shared';
|
||||
declare const handleAuth: PacketHandler;
|
||||
export default handleAuth;
|
30
node_modules/mqtt/build/lib/handlers/auth.js
generated
vendored
Normal file
30
node_modules/mqtt/build/lib/handlers/auth.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const shared_1 = require("../shared");
|
||||
const ack_1 = require("./ack");
|
||||
const handleAuth = (client, packet) => {
|
||||
const { options } = client;
|
||||
const version = options.protocolVersion;
|
||||
const rc = version === 5 ? packet.reasonCode : packet.returnCode;
|
||||
if (version !== 5) {
|
||||
const err = new shared_1.ErrorWithReasonCode(`Protocol error: Auth packets are only supported in MQTT 5. Your version:${version}`, rc);
|
||||
client.emit('error', err);
|
||||
return;
|
||||
}
|
||||
client.handleAuth(packet, (err, packet2) => {
|
||||
if (err) {
|
||||
client.emit('error', err);
|
||||
return;
|
||||
}
|
||||
if (rc === 24) {
|
||||
client.reconnecting = false;
|
||||
client['_sendPacket'](packet2);
|
||||
}
|
||||
else {
|
||||
const error = new shared_1.ErrorWithReasonCode(`Connection refused: ${ack_1.ReasonCodes[rc]}`, rc);
|
||||
client.emit('error', error);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.default = handleAuth;
|
||||
//# sourceMappingURL=auth.js.map
|
1
node_modules/mqtt/build/lib/handlers/auth.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/handlers/auth.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/handlers/auth.ts"],"names":[],"mappings":";;AACA,sCAAmE;AACnE,+BAAmC;AAEnC,MAAM,UAAU,GAAkB,CACjC,MAAM,EACN,MAA4C,EAC3C,EAAE;IACH,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAA;IACvC,MAAM,EAAE,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAA;IAEhE,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,GAAG,GAAG,IAAI,4BAAmB,CAClC,2EAA2E,OAAO,EAAE,EACpF,EAAE,CACF,CAAA;QACD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACzB,OAAM;IACP,CAAC;IAED,MAAM,CAAC,UAAU,CAChB,MAAM,EACN,CAAC,GAAwB,EAAE,OAAoB,EAAE,EAAE;QAClD,IAAI,GAAG,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;YACzB,OAAM;QACP,CAAC;QAED,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACf,MAAM,CAAC,YAAY,GAAG,KAAK,CAAA;YAC3B,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,CAAA;QAC/B,CAAC;aAAM,CAAC;YACP,MAAM,KAAK,GAAG,IAAI,4BAAmB,CACpC,uBAAuB,iBAAW,CAAC,EAAE,CAAC,EAAE,EACxC,EAAE,CACF,CAAA;YACD,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC;IACF,CAAC,CACD,CAAA;AACF,CAAC,CAAA;AAED,kBAAe,UAAU,CAAA"}
|
3
node_modules/mqtt/build/lib/handlers/connack.d.ts
generated
vendored
Normal file
3
node_modules/mqtt/build/lib/handlers/connack.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type PacketHandler } from '../shared';
|
||||
declare const handleConnack: PacketHandler;
|
||||
export default handleConnack;
|
50
node_modules/mqtt/build/lib/handlers/connack.js
generated
vendored
Normal file
50
node_modules/mqtt/build/lib/handlers/connack.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ack_1 = require("./ack");
|
||||
const topic_alias_send_1 = __importDefault(require("../topic-alias-send"));
|
||||
const shared_1 = require("../shared");
|
||||
const handleConnack = (client, packet) => {
|
||||
client.log('_handleConnack');
|
||||
const { options } = client;
|
||||
const version = options.protocolVersion;
|
||||
const rc = version === 5 ? packet.reasonCode : packet.returnCode;
|
||||
clearTimeout(client['connackTimer']);
|
||||
delete client['topicAliasSend'];
|
||||
if (packet.properties) {
|
||||
if (packet.properties.topicAliasMaximum) {
|
||||
if (packet.properties.topicAliasMaximum > 0xffff) {
|
||||
client.emit('error', new Error('topicAliasMaximum from broker is out of range'));
|
||||
return;
|
||||
}
|
||||
if (packet.properties.topicAliasMaximum > 0) {
|
||||
client['topicAliasSend'] = new topic_alias_send_1.default(packet.properties.topicAliasMaximum);
|
||||
}
|
||||
}
|
||||
if (packet.properties.serverKeepAlive && options.keepalive) {
|
||||
options.keepalive = packet.properties.serverKeepAlive;
|
||||
}
|
||||
if (packet.properties.maximumPacketSize) {
|
||||
if (!options.properties) {
|
||||
options.properties = {};
|
||||
}
|
||||
options.properties.maximumPacketSize =
|
||||
packet.properties.maximumPacketSize;
|
||||
}
|
||||
}
|
||||
if (rc === 0) {
|
||||
client.reconnecting = false;
|
||||
client['_onConnect'](packet);
|
||||
}
|
||||
else if (rc > 0) {
|
||||
const err = new shared_1.ErrorWithReasonCode(`Connection refused: ${ack_1.ReasonCodes[rc]}`, rc);
|
||||
client.emit('error', err);
|
||||
if (client.options.reconnectOnConnackError) {
|
||||
client['_cleanUp'](true);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.default = handleConnack;
|
||||
//# sourceMappingURL=connack.js.map
|
1
node_modules/mqtt/build/lib/handlers/connack.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/handlers/connack.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"connack.js","sourceRoot":"","sources":["../../../src/lib/handlers/connack.ts"],"names":[],"mappings":";;;;;AACA,+BAAmC;AACnC,2EAAgD;AAChD,sCAAmE;AAEnE,MAAM,aAAa,GAAkB,CAAC,MAAM,EAAE,MAAsB,EAAE,EAAE;IACvE,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,CAAA;IACvC,MAAM,EAAE,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAA;IAEhE,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAA;IACpC,OAAO,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAE/B,IA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AAC,CAAA;QACzB,IAAI,MAAM,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC;YAC5C,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;IACF,CAAC;AACF,CAAC,CAAA;AAED,kBAAe,aAAa,CAAA"}
|
3
node_modules/mqtt/build/lib/handlers/index.d.ts
generated
vendored
Normal file
3
node_modules/mqtt/build/lib/handlers/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type PacketHandler } from '../shared';
|
||||
declare const handle: PacketHandler;
|
||||
export default handle;
|
68
node_modules/mqtt/build/lib/handlers/index.js
generated
vendored
Normal file
68
node_modules/mqtt/build/lib/handlers/index.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const publish_1 = __importDefault(require("./publish"));
|
||||
const auth_1 = __importDefault(require("./auth"));
|
||||
const connack_1 = __importDefault(require("./connack"));
|
||||
const ack_1 = __importDefault(require("./ack"));
|
||||
const pubrel_1 = __importDefault(require("./pubrel"));
|
||||
const handle = (client, packet, done) => {
|
||||
const { options } = client;
|
||||
if (options.protocolVersion === 5 &&
|
||||
options.properties &&
|
||||
options.properties.maximumPacketSize &&
|
||||
options.properties.maximumPacketSize < packet.length) {
|
||||
client.emit('error', new Error(`exceeding packets size ${packet.cmd}`));
|
||||
client.end({
|
||||
reasonCode: 149,
|
||||
properties: { reasonString: 'Maximum packet size was exceeded' },
|
||||
});
|
||||
return client;
|
||||
}
|
||||
client.log('_handlePacket :: emitting packetreceive');
|
||||
client.emit('packetreceive', packet);
|
||||
switch (packet.cmd) {
|
||||
case 'publish':
|
||||
(0, publish_1.default)(client, packet, done);
|
||||
break;
|
||||
case 'puback':
|
||||
case 'pubrec':
|
||||
case 'pubcomp':
|
||||
case 'suback':
|
||||
case 'unsuback':
|
||||
client.reschedulePing();
|
||||
(0, ack_1.default)(client, packet);
|
||||
done();
|
||||
break;
|
||||
case 'pubrel':
|
||||
client.reschedulePing();
|
||||
(0, pubrel_1.default)(client, packet, done);
|
||||
break;
|
||||
case 'connack':
|
||||
(0, connack_1.default)(client, packet);
|
||||
done();
|
||||
break;
|
||||
case 'auth':
|
||||
client.reschedulePing();
|
||||
(0, auth_1.default)(client, packet);
|
||||
done();
|
||||
break;
|
||||
case 'pingresp':
|
||||
client.log('_handlePacket :: received pingresp');
|
||||
client.reschedulePing(true);
|
||||
done();
|
||||
break;
|
||||
case 'disconnect':
|
||||
client.emit('disconnect', packet);
|
||||
done();
|
||||
break;
|
||||
default:
|
||||
client.log('_handlePacket :: unknown command');
|
||||
done();
|
||||
break;
|
||||
}
|
||||
};
|
||||
exports.default = handle;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/mqtt/build/lib/handlers/index.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/handlers/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/handlers/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAqC;AACrC,kDAA+B;AAC/B,wDAAqC;AACrC,gDAA6B;AAC7B,sDAAmC;AAGnC,MAAM,MAAM,GAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IACtD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAE1B,IACC,OAAO,CAAC,eAAe,KAAK,CAAC;QAC7B,OAAO,CAAC,UAAU;QAClB,OAAO,CAAC,UAAU,CAAC,iBAAiB;QACpC,OAAO,CAAC,UAAU,CAAC,iBAAiB,GAAG,MAAM,CAAC,MAAM,EACnD,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,GAAG,EAAE,CAAC,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C,YAAY,EAAE,MAAM,CAAC,CAAA;YACjC,IAAI,EAAE,CAAA;YACN,MAAK;QACN;YAEC,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;YAC9C,IAAI,EAAE,CAAA;YACN,MAAK;IACP,CAAC;AACF,CAAC,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
3
node_modules/mqtt/build/lib/handlers/publish.d.ts
generated
vendored
Normal file
3
node_modules/mqtt/build/lib/handlers/publish.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type PacketHandler } from '../shared';
|
||||
declare const handlePublish: PacketHandler;
|
||||
export default handlePublish;
|
106
node_modules/mqtt/build/lib/handlers/publish.js
generated
vendored
Normal file
106
node_modules/mqtt/build/lib/handlers/publish.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const validReasonCodes = [0, 16, 128, 131, 135, 144, 145, 151, 153];
|
||||
const handlePublish = (client, packet, done) => {
|
||||
client.log('handlePublish: packet %o', packet);
|
||||
done = typeof done !== 'undefined' ? done : client.noop;
|
||||
let topic = packet.topic.toString();
|
||||
const message = packet.payload;
|
||||
const { qos } = packet;
|
||||
const { messageId } = packet;
|
||||
const { options } = client;
|
||||
if (client.options.protocolVersion === 5) {
|
||||
let alias;
|
||||
if (packet.properties) {
|
||||
alias = packet.properties.topicAlias;
|
||||
}
|
||||
if (typeof alias !== 'undefined') {
|
||||
if (topic.length === 0) {
|
||||
if (alias > 0 && alias <= 0xffff) {
|
||||
const gotTopic = client['topicAliasRecv'].getTopicByAlias(alias);
|
||||
if (gotTopic) {
|
||||
topic = gotTopic;
|
||||
client.log('handlePublish :: topic complemented by alias. topic: %s - alias: %d', topic, alias);
|
||||
}
|
||||
else {
|
||||
client.log('handlePublish :: unregistered topic alias. alias: %d', alias);
|
||||
client.emit('error', new Error('Received unregistered Topic Alias'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
client.log('handlePublish :: topic alias out of range. alias: %d', alias);
|
||||
client.emit('error', new Error('Received Topic Alias is out of range'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (client['topicAliasRecv'].put(topic, alias)) {
|
||||
client.log('handlePublish :: registered topic: %s - alias: %d', topic, alias);
|
||||
}
|
||||
else {
|
||||
client.log('handlePublish :: topic alias out of range. alias: %d', alias);
|
||||
client.emit('error', new Error('Received Topic Alias is out of range'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
client.log('handlePublish: qos %d', qos);
|
||||
switch (qos) {
|
||||
case 2: {
|
||||
options.customHandleAcks(topic, message, packet, (error, code) => {
|
||||
if (typeof error === 'number') {
|
||||
code = error;
|
||||
error = null;
|
||||
}
|
||||
if (error) {
|
||||
return client.emit('error', error);
|
||||
}
|
||||
if (validReasonCodes.indexOf(code) === -1) {
|
||||
return client.emit('error', new Error('Wrong reason code for pubrec'));
|
||||
}
|
||||
if (code) {
|
||||
client['_sendPacket']({ cmd: 'pubrec', messageId, reasonCode: code }, done);
|
||||
}
|
||||
else {
|
||||
client.incomingStore.put(packet, () => {
|
||||
client['_sendPacket']({ cmd: 'pubrec', messageId }, done);
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
options.customHandleAcks(topic, message, packet, (error, code) => {
|
||||
if (typeof error === 'number') {
|
||||
code = error;
|
||||
error = null;
|
||||
}
|
||||
if (error) {
|
||||
return client.emit('error', error);
|
||||
}
|
||||
if (validReasonCodes.indexOf(code) === -1) {
|
||||
return client.emit('error', new Error('Wrong reason code for puback'));
|
||||
}
|
||||
if (!code) {
|
||||
client.emit('message', topic, message, packet);
|
||||
}
|
||||
client.handleMessage(packet, (err) => {
|
||||
if (err) {
|
||||
return done && done(err);
|
||||
}
|
||||
client['_sendPacket']({ cmd: 'puback', messageId, reasonCode: code }, done);
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
client.emit('message', topic, message, packet);
|
||||
client.handleMessage(packet, done);
|
||||
break;
|
||||
default:
|
||||
client.log('handlePublish: unknown QoS. Doing nothing.');
|
||||
break;
|
||||
}
|
||||
};
|
||||
exports.default = handlePublish;
|
||||
//# sourceMappingURL=publish.js.map
|
1
node_modules/mqtt/build/lib/handlers/publish.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/handlers/publish.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../../src/lib/handlers/publish.ts"],"names":[],"mappings":";;AAGA,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AA0BnE,MAAM,aAAa,GAAkB,CAAC,MAAM,EAAE,MAAsB,EAAE,IAAI,EAAE,EAAE;IAC7E,MAAM,CAAC,GAAG,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;IAC9C,IAAI,GAAG,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA;IACvD,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAA;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;IAC9B,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;IACtB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;IAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAC1B,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,KAAK,CAAC,EAAE,CAAC;QAC1C,IAAI,KAAa,CAAA;QACjB,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAA;QACrC,CAAC;QACD,IAAI,O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
Normal file
@@ -0,0 +1,3 @@
|
||||
import { type PacketHandler } from '../shared';
|
||||
declare const handlePubrel: PacketHandler;
|
||||
export default handlePubrel;
|
25
node_modules/mqtt/build/lib/handlers/pubrel.js
generated
vendored
Normal file
25
node_modules/mqtt/build/lib/handlers/pubrel.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const handlePubrel = (client, packet, done) => {
|
||||
client.log('handling pubrel packet');
|
||||
const callback = typeof done !== 'undefined' ? done : client.noop;
|
||||
const { messageId } = packet;
|
||||
const comp = { cmd: 'pubcomp', messageId };
|
||||
client.incomingStore.get(packet, (err, pub) => {
|
||||
if (!err) {
|
||||
client.emit('message', pub.topic, pub.payload, pub);
|
||||
client.handleMessage(pub, (err2) => {
|
||||
if (err2) {
|
||||
return callback(err2);
|
||||
}
|
||||
client.incomingStore.del(pub, client.noop);
|
||||
client['_sendPacket'](comp, callback);
|
||||
});
|
||||
}
|
||||
else {
|
||||
client['_sendPacket'](comp, callback);
|
||||
}
|
||||
});
|
||||
};
|
||||
exports.default = handlePubrel;
|
||||
//# sourceMappingURL=pubrel.js.map
|
1
node_modules/mqtt/build/lib/handlers/pubrel.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/handlers/pubrel.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pubrel.js","sourceRoot":"","sources":["../../../src/lib/handlers/pubrel.ts"],"names":[],"mappings":";;AAOA,MAAM,YAAY,GAAkB,CAAC,MAAM,EAAE,MAAqB,EAAE,IAAI,EAAE,EAAE;IAC3E,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;IACpC,MAAM,QAAQ,GAAG,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA;IACjE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAA;IAE5B,MAAM,IAAI,GAAmB,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;IAE1D,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAmB,EAAE,EAAE;QAC7D,IAAI,CAAC,GAAG,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAiB,EAAE,GAAG,CAAC,CAAA;YAC7D,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClC,IAAI,IAAI,EAAE,CAAC;oBACV,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;gBACtB,CAAC;gBACD,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC1C,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YACtC,CAAC,CAAC,CAAA;QACH,CAAC;aAAM,CAAC;YACP,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACtC,CAAC;IACF,CAAC,CAAC,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,YAAY,CAAA"}
|
4
node_modules/mqtt/build/lib/is-browser.d.ts
generated
vendored
Normal file
4
node_modules/mqtt/build/lib/is-browser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare const isBrowser: boolean;
|
||||
export declare const isWebWorker: boolean;
|
||||
export declare const isReactNativeBrowser: boolean;
|
||||
export default isBrowser;
|
23
node_modules/mqtt/build/lib/is-browser.js
generated
vendored
Normal file
23
node_modules/mqtt/build/lib/is-browser.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isReactNativeBrowser = exports.isWebWorker = void 0;
|
||||
const isStandardBrowserEnv = () => {
|
||||
if (typeof window !== 'undefined') {
|
||||
const electronRenderCheck = typeof navigator !== 'undefined' &&
|
||||
navigator.userAgent?.toLowerCase().indexOf(' electron/') > -1;
|
||||
if (electronRenderCheck && process?.versions) {
|
||||
const electronMainCheck = Object.prototype.hasOwnProperty.call(process.versions, 'electron');
|
||||
return !electronMainCheck;
|
||||
}
|
||||
return typeof window.document !== 'undefined';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const isWebWorkerEnv = () => Boolean(typeof self === 'object' &&
|
||||
self?.constructor?.name?.includes('WorkerGlobalScope'));
|
||||
const isReactNativeEnv = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
||||
const isBrowser = isStandardBrowserEnv() || isWebWorkerEnv() || isReactNativeEnv();
|
||||
exports.isWebWorker = isWebWorkerEnv();
|
||||
exports.isReactNativeBrowser = isReactNativeEnv();
|
||||
exports.default = isBrowser;
|
||||
//# sourceMappingURL=is-browser.js.map
|
1
node_modules/mqtt/build/lib/is-browser.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/is-browser.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"is-browser.js","sourceRoot":"","sources":["../../src/lib/is-browser.ts"],"names":[],"mappings":";;;AAAA,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAEjC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAGnC,MAAM,mBAAmB,GACxB,OAAO,SAAS,KAAK,WAAW;YAChC,SAAS,CAAC,SAAS,EAAE,WAAW,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;QAC9D,IAAI,mBAAmB,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC9C,MAAM,iBAAiB,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAC7D,OAAO,CAAC,QAAQ,EAChB,UAAU,CACV,CAAA;YAOD,OAAO,CAAC,iBAAiB,CAAA;QAC1B,CAAC;QACD,OAAO,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAA;IAC9C,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,GAAG,EAAE,CAC3B,OAAO,CAEN,OAAO,IAAI,KAAK,QAAQ;IAEvB,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CACvD,CAAA;AAEF,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAC7B,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa,CAAA;AAExE,MAAM,SAAS,GACd,oBAAoB,EAAE,IAAI,cAAc,EAAE,IAAI,gBAAgB,EAAE,CAAA;AAEpD,QAAA,WAAW,GAAG,cAAc,EAAE,CAAA;AAE9B,QAAA,oBAAoB,GAAG,gBAAgB,EAAE,CAAA;AAEtD,kBAAe,SAAS,CAAA"}
|
27
node_modules/mqtt/build/lib/shared.d.ts
generated
vendored
Normal file
27
node_modules/mqtt/build/lib/shared.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { Packet, ISubackPacket } from 'mqtt-packet';
|
||||
import type { Duplex as NativeDuplex } from 'node:stream';
|
||||
import type { Duplex } from 'readable-stream';
|
||||
import type MqttClient from './client';
|
||||
import type { IClientOptions } from './client';
|
||||
export type DoneCallback = (error?: Error) => void;
|
||||
export type GenericCallback<T> = (error?: Error, result?: T) => void;
|
||||
export type VoidCallback = () => void;
|
||||
export type IStream = (Duplex | NativeDuplex) & {
|
||||
socket?: any;
|
||||
};
|
||||
export type StreamBuilder = (client: MqttClient, opts?: IClientOptions) => IStream;
|
||||
export type Callback = () => void;
|
||||
export type PacketHandler = (client: MqttClient, packet: Packet, done?: DoneCallback) => void;
|
||||
export type TimerVariant = 'auto' | 'worker' | 'native';
|
||||
export declare class ErrorWithReasonCode extends Error {
|
||||
code: number;
|
||||
constructor(message: string, code: number);
|
||||
}
|
||||
export declare class ErrorWithSubackPacket extends Error {
|
||||
packet: ISubackPacket;
|
||||
constructor(message: string, packet: ISubackPacket);
|
||||
}
|
||||
export type Constructor<T = {}> = new (...args: any[]) => T;
|
||||
export declare function applyMixin(target: Constructor, mixin: Constructor, includeConstructor?: boolean): void;
|
||||
export declare const nextTick: (callback: Function, ...args: any[]) => void;
|
||||
export declare const MQTTJS_VERSION: any;
|
52
node_modules/mqtt/build/lib/shared.js
generated
vendored
Normal file
52
node_modules/mqtt/build/lib/shared.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MQTTJS_VERSION = exports.nextTick = exports.ErrorWithSubackPacket = exports.ErrorWithReasonCode = void 0;
|
||||
exports.applyMixin = applyMixin;
|
||||
class ErrorWithReasonCode extends Error {
|
||||
code;
|
||||
constructor(message, code) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
Object.setPrototypeOf(this, ErrorWithReasonCode.prototype);
|
||||
Object.getPrototypeOf(this).name = 'ErrorWithReasonCode';
|
||||
}
|
||||
}
|
||||
exports.ErrorWithReasonCode = ErrorWithReasonCode;
|
||||
class ErrorWithSubackPacket extends Error {
|
||||
packet;
|
||||
constructor(message, packet) {
|
||||
super(message);
|
||||
this.packet = packet;
|
||||
Object.setPrototypeOf(this, ErrorWithSubackPacket.prototype);
|
||||
Object.getPrototypeOf(this).name = 'ErrorWithSubackPacket';
|
||||
}
|
||||
}
|
||||
exports.ErrorWithSubackPacket = ErrorWithSubackPacket;
|
||||
function applyMixin(target, mixin, includeConstructor = false) {
|
||||
const inheritanceChain = [mixin];
|
||||
while (true) {
|
||||
const current = inheritanceChain[0];
|
||||
const base = Object.getPrototypeOf(current);
|
||||
if (base?.prototype) {
|
||||
inheritanceChain.unshift(base);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (const ctor of inheritanceChain) {
|
||||
for (const prop of Object.getOwnPropertyNames(ctor.prototype)) {
|
||||
if (includeConstructor || prop !== 'constructor') {
|
||||
Object.defineProperty(target.prototype, prop, Object.getOwnPropertyDescriptor(ctor.prototype, prop) ??
|
||||
Object.create(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.nextTick = typeof process?.nextTick === 'function'
|
||||
? process.nextTick
|
||||
: (callback) => {
|
||||
setTimeout(callback, 0);
|
||||
};
|
||||
exports.MQTTJS_VERSION = require('../../package.json').version;
|
||||
//# sourceMappingURL=shared.js.map
|
1
node_modules/mqtt/build/lib/shared.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/shared.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/lib/shared.ts"],"names":[],"mappings":";;;AA6DA,gCA8BC;AA3DD,MAAa,mBAAoB,SAAQ,KAAK;IACtC,IAAI,CAAQ;IAEnB,YAAmB,OAAe,EAAE,IAAY;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAGhB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAA;QAC1D,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACzD,CAAC;CACD;AAXD,kDAWC;AAED,MAAa,qBAAsB,SAAQ,KAAK;IACxC,MAAM,CAAe;IAE5B,YAAmB,OAAe,EAAE,MAAqB;QACxD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAGpB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAA;QAC5D,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,uBAAuB,CAAA;IAC3D,CAAC;CACD;AAXD,sDAWC;AAKD,SAAgB,UAAU,C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import { Readable } from 'readable-stream';
|
||||
import { type Packet } from 'mqtt-packet';
|
||||
import { type DoneCallback } from './shared';
|
||||
export interface IStoreOptions {
|
||||
clean?: boolean;
|
||||
}
|
||||
export type PacketCallback = (error?: Error, packet?: Packet) => void;
|
||||
export interface IStore {
|
||||
put(packet: Packet, cb: DoneCallback): IStore;
|
||||
createStream(): Readable;
|
||||
del(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): IStore;
|
||||
get(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): IStore;
|
||||
close(cb: DoneCallback): void;
|
||||
}
|
||||
export default class Store implements IStore {
|
||||
private options;
|
||||
private _inflights;
|
||||
constructor(options?: IStoreOptions);
|
||||
put(packet: Packet, cb: DoneCallback): this;
|
||||
createStream(): Readable;
|
||||
del(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): this;
|
||||
get(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): this;
|
||||
close(cb: DoneCallback): void;
|
||||
}
|
82
node_modules/mqtt/build/lib/store.js
generated
vendored
Normal file
82
node_modules/mqtt/build/lib/store.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const readable_stream_1 = require("readable-stream");
|
||||
const streamsOpts = { objectMode: true };
|
||||
const defaultStoreOptions = {
|
||||
clean: true,
|
||||
};
|
||||
class Store {
|
||||
options;
|
||||
_inflights;
|
||||
constructor(options) {
|
||||
this.options = options || {};
|
||||
this.options = { ...defaultStoreOptions, ...options };
|
||||
this._inflights = new Map();
|
||||
}
|
||||
put(packet, cb) {
|
||||
this._inflights.set(packet.messageId, packet);
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
createStream() {
|
||||
const stream = new readable_stream_1.Readable(streamsOpts);
|
||||
const values = [];
|
||||
let destroyed = false;
|
||||
let i = 0;
|
||||
this._inflights.forEach((value, key) => {
|
||||
values.push(value);
|
||||
});
|
||||
stream._read = () => {
|
||||
if (!destroyed && i < values.length) {
|
||||
stream.push(values[i++]);
|
||||
}
|
||||
else {
|
||||
stream.push(null);
|
||||
}
|
||||
};
|
||||
stream.destroy = (err) => {
|
||||
if (destroyed) {
|
||||
return;
|
||||
}
|
||||
destroyed = true;
|
||||
setTimeout(() => {
|
||||
stream.emit('close');
|
||||
}, 0);
|
||||
return stream;
|
||||
};
|
||||
return stream;
|
||||
}
|
||||
del(packet, cb) {
|
||||
const toDelete = this._inflights.get(packet.messageId);
|
||||
if (toDelete) {
|
||||
this._inflights.delete(packet.messageId);
|
||||
cb(null, toDelete);
|
||||
}
|
||||
else if (cb) {
|
||||
cb(new Error('missing packet'));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
get(packet, cb) {
|
||||
const storedPacket = this._inflights.get(packet.messageId);
|
||||
if (storedPacket) {
|
||||
cb(null, storedPacket);
|
||||
}
|
||||
else if (cb) {
|
||||
cb(new Error('missing packet'));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
close(cb) {
|
||||
if (this.options.clean) {
|
||||
this._inflights = null;
|
||||
}
|
||||
if (cb) {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = Store;
|
||||
//# sourceMappingURL=store.js.map
|
1
node_modules/mqtt/build/lib/store.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/store.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/lib/store.ts"],"names":[],"mappings":";;AAGA,qDAA0C;AAI1C,MAAM,WAAW,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;AACxC,MAAM,mBAAmB,GAAG;IAC3B,KAAK,EAAE,IAAI;CACX,CAAA;AA+CD,MAAqB,KAAK;IACjB,OAAO,CAAe;IAEtB,UAAU,CAAqB;IAEvC,YAAY,OAAuB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;QAG5B,IAAI,CA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OAAO,MAAM,CAAA;QACd,CAAC,CAAA;QAED,OAAO,MAAM,CAAA;IACd,CAAC;IAKD,GAAG,CAAC,MAAiC,EAAE,EAAkB;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YACxC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACnB,CAAC;aAAM,IAAI,EAAE,EAAE,CAAC;YACf,EAAE,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;QAChC,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAKD,GAAG,CAAC,MAAiC,EAAE,EAAkB;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAC1D,IAAI,YAAY,EAAE,CAAC;YAClB,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;QACvB,CAAC;aAAM,IAAI,EAAE,EAAE,CAAC;YACf,EAAE,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;QAChC,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC;IAKD,KAAK,CAAC,EAAgB;QACrB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QACvB,CAAC;QACD,IAAI,EAAE,EAAE,CAAC;YACR,EAAE,EAAE,CAAA;QACL,CAAC;IACF,CAAC;CACD;AA5GD,wBA4GC"}
|
9
node_modules/mqtt/build/lib/topic-alias-recv.d.ts
generated
vendored
Normal file
9
node_modules/mqtt/build/lib/topic-alias-recv.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export default class TopicAliasRecv {
|
||||
private aliasToTopic;
|
||||
max: number;
|
||||
length: number;
|
||||
constructor(max: number);
|
||||
put(topic: string, alias: number): boolean;
|
||||
getTopicByAlias(alias: number): string;
|
||||
clear(): void;
|
||||
}
|
27
node_modules/mqtt/build/lib/topic-alias-recv.js
generated
vendored
Normal file
27
node_modules/mqtt/build/lib/topic-alias-recv.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class TopicAliasRecv {
|
||||
aliasToTopic;
|
||||
max;
|
||||
length;
|
||||
constructor(max) {
|
||||
this.aliasToTopic = {};
|
||||
this.max = max;
|
||||
}
|
||||
put(topic, alias) {
|
||||
if (alias === 0 || alias > this.max) {
|
||||
return false;
|
||||
}
|
||||
this.aliasToTopic[alias] = topic;
|
||||
this.length = Object.keys(this.aliasToTopic).length;
|
||||
return true;
|
||||
}
|
||||
getTopicByAlias(alias) {
|
||||
return this.aliasToTopic[alias];
|
||||
}
|
||||
clear() {
|
||||
this.aliasToTopic = {};
|
||||
}
|
||||
}
|
||||
exports.default = TopicAliasRecv;
|
||||
//# sourceMappingURL=topic-alias-recv.js.map
|
1
node_modules/mqtt/build/lib/topic-alias-recv.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/topic-alias-recv.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"topic-alias-recv.js","sourceRoot":"","sources":["../../src/lib/topic-alias-recv.ts"],"names":[],"mappings":";;AAKA,MAAqB,cAAc;IAC1B,YAAY,CAAwB;IAErC,GAAG,CAAQ;IAEX,MAAM,CAAQ;IAErB,YAAY,GAAW;QACtB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IACf,CAAC;IAQD,GAAG,CAAC,KAAa,EAAE,KAAa;QAC/B,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACrC,OAAO,KAAK,CAAA;QACb,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK,CAAA;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAA;QACnD,OAAO,IAAI,CAAA;IACZ,CAAC;IAOD,eAAe,CAAC,KAAa;QAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IAKD,KAAK;QACJ,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;IACvB,CAAC;CACD;AA1CD,iCA0CC"}
|
13
node_modules/mqtt/build/lib/topic-alias-send.d.ts
generated
vendored
Normal file
13
node_modules/mqtt/build/lib/topic-alias-send.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export default class TopicAliasSend {
|
||||
private aliasToTopic;
|
||||
private topicToAlias;
|
||||
private max;
|
||||
private numberAllocator;
|
||||
length: number;
|
||||
constructor(max: number);
|
||||
put(topic: string, alias: number): boolean;
|
||||
getTopicByAlias(alias: number): string;
|
||||
getAliasByTopic(topic: string): number | undefined;
|
||||
clear(): void;
|
||||
getLruAlias(): number;
|
||||
}
|
58
node_modules/mqtt/build/lib/topic-alias-send.js
generated
vendored
Normal file
58
node_modules/mqtt/build/lib/topic-alias-send.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const lru_cache_1 = require("lru-cache");
|
||||
const number_allocator_1 = require("number-allocator");
|
||||
class TopicAliasSend {
|
||||
aliasToTopic;
|
||||
topicToAlias;
|
||||
max;
|
||||
numberAllocator;
|
||||
length;
|
||||
constructor(max) {
|
||||
if (max > 0) {
|
||||
this.aliasToTopic = new lru_cache_1.LRUCache({ max });
|
||||
this.topicToAlias = {};
|
||||
this.numberAllocator = new number_allocator_1.NumberAllocator(1, max);
|
||||
this.max = max;
|
||||
this.length = 0;
|
||||
}
|
||||
}
|
||||
put(topic, alias) {
|
||||
if (alias === 0 || alias > this.max) {
|
||||
return false;
|
||||
}
|
||||
const entry = this.aliasToTopic.get(alias);
|
||||
if (entry) {
|
||||
delete this.topicToAlias[entry];
|
||||
}
|
||||
this.aliasToTopic.set(alias, topic);
|
||||
this.topicToAlias[topic] = alias;
|
||||
this.numberAllocator.use(alias);
|
||||
this.length = this.aliasToTopic.size;
|
||||
return true;
|
||||
}
|
||||
getTopicByAlias(alias) {
|
||||
return this.aliasToTopic.get(alias);
|
||||
}
|
||||
getAliasByTopic(topic) {
|
||||
const alias = this.topicToAlias[topic];
|
||||
if (typeof alias !== 'undefined') {
|
||||
this.aliasToTopic.get(alias);
|
||||
}
|
||||
return alias;
|
||||
}
|
||||
clear() {
|
||||
this.aliasToTopic.clear();
|
||||
this.topicToAlias = {};
|
||||
this.numberAllocator.clear();
|
||||
this.length = 0;
|
||||
}
|
||||
getLruAlias() {
|
||||
const alias = this.numberAllocator.firstVacant();
|
||||
if (alias)
|
||||
return alias;
|
||||
return [...this.aliasToTopic.keys()][this.aliasToTopic.size - 1];
|
||||
}
|
||||
}
|
||||
exports.default = TopicAliasSend;
|
||||
//# sourceMappingURL=topic-alias-send.js.map
|
1
node_modules/mqtt/build/lib/topic-alias-send.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/topic-alias-send.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"topic-alias-send.js","sourceRoot":"","sources":["../../src/lib/topic-alias-send.ts"],"names":[],"mappings":";;AAGA,yCAAoC;AACpC,uDAAkD;AAOlD,MAAqB,cAAc;IAC1B,YAAY,CAA0B;IAEtC,YAAY,CAAwB;IAEpC,GAAG,CAAQ;IAEX,eAAe,CAAiB;IAEjC,MAAM,CAAQ;IAErB,YAAY,GAAW;QACtB,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;YACb,IAAI,CAAC,YAAY,GAAG,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AAA;IACb,CAAC;IAKD,KAAK;QACJ,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IAChB,CAAC;IAMD,WAAW;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,CAAA;QAChD,IAAI,KAAK;YAAE,OAAO,KAAK,CAAA;QAEvB,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,CAAC,CAAA;IACjE,CAAC;CACD;AApFD,iCAoFC"}
|
11
node_modules/mqtt/build/lib/unique-message-id-provider.d.ts
generated
vendored
Normal file
11
node_modules/mqtt/build/lib/unique-message-id-provider.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { type IMessageIdProvider } from './default-message-id-provider';
|
||||
export default class UniqueMessageIdProvider implements IMessageIdProvider {
|
||||
private numberAllocator;
|
||||
private lastId;
|
||||
constructor();
|
||||
allocate(): number;
|
||||
getLastAllocated(): number;
|
||||
register(messageId: number): boolean;
|
||||
deallocate(messageId: number): void;
|
||||
clear(): void;
|
||||
}
|
28
node_modules/mqtt/build/lib/unique-message-id-provider.js
generated
vendored
Normal file
28
node_modules/mqtt/build/lib/unique-message-id-provider.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const number_allocator_1 = require("number-allocator");
|
||||
class UniqueMessageIdProvider {
|
||||
numberAllocator;
|
||||
lastId;
|
||||
constructor() {
|
||||
this.numberAllocator = new number_allocator_1.NumberAllocator(1, 65535);
|
||||
}
|
||||
allocate() {
|
||||
this.lastId = this.numberAllocator.alloc();
|
||||
return this.lastId;
|
||||
}
|
||||
getLastAllocated() {
|
||||
return this.lastId;
|
||||
}
|
||||
register(messageId) {
|
||||
return this.numberAllocator.use(messageId);
|
||||
}
|
||||
deallocate(messageId) {
|
||||
this.numberAllocator.free(messageId);
|
||||
}
|
||||
clear() {
|
||||
this.numberAllocator.clear();
|
||||
}
|
||||
}
|
||||
exports.default = UniqueMessageIdProvider;
|
||||
//# sourceMappingURL=unique-message-id-provider.js.map
|
1
node_modules/mqtt/build/lib/unique-message-id-provider.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/unique-message-id-provider.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unique-message-id-provider.js","sourceRoot":"","sources":["../../src/lib/unique-message-id-provider.ts"],"names":[],"mappings":";;AAAA,uDAAkD;AAOlD,MAAqB,uBAAuB;IACnC,eAAe,CAAiB;IAEhC,MAAM,CAAQ;IAEtB;QACC,IAAI,CAAC,eAAe,GAAG,IAAI,kCAAe,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;IASD,QAAQ;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAA;IACnB,CAAC;IAOD,gBAAgB;QACf,OAAO,IAAI,CAAC,MAAM,CAAA;IACnB,CAAC;IAQD,QAAQ,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAY,CAAA;IACtD,CAAC;IAOD,UAAU,CAAC,SAAiB;QAC3B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;IAMD,KAAK;QACJ,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;IAC7B,CAAC;CACD;AAxDD,0CAwDC"}
|
2
node_modules/mqtt/build/lib/validations.d.ts
generated
vendored
Normal file
2
node_modules/mqtt/build/lib/validations.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function validateTopic(topic: string): boolean;
|
||||
export declare function validateTopics(topics: string[]): string | null;
|
31
node_modules/mqtt/build/lib/validations.js
generated
vendored
Normal file
31
node_modules/mqtt/build/lib/validations.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateTopic = validateTopic;
|
||||
exports.validateTopics = validateTopics;
|
||||
function validateTopic(topic) {
|
||||
const parts = topic.split('/');
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
if (parts[i] === '+') {
|
||||
continue;
|
||||
}
|
||||
if (parts[i] === '#') {
|
||||
return i === parts.length - 1;
|
||||
}
|
||||
if (parts[i].indexOf('+') !== -1 || parts[i].indexOf('#') !== -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function validateTopics(topics) {
|
||||
if (topics.length === 0) {
|
||||
return 'empty_topic_list';
|
||||
}
|
||||
for (let i = 0; i < topics.length; i++) {
|
||||
if (!validateTopic(topics[i])) {
|
||||
return topics[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//# sourceMappingURL=validations.js.map
|
1
node_modules/mqtt/build/lib/validations.js.map
generated
vendored
Normal file
1
node_modules/mqtt/build/lib/validations.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../src/lib/validations.ts"],"names":[],"mappings":";;AASA,sCAmBC;AAOD,wCAUC;AApCD,SAAgB,aAAa,CAAC,KAAa;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACtB,SAAQ;QACT,CAAC;QAED,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAEtB,OAAO,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;QAC9B,CAAC;QAED,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YAClE,OAAO,KAAK,CAAA;QACb,CAAC;IACF,CAAC;IAED,OAAO,IAAI,CAAA;AACZ,CAAC;AAOD,SAAgB,cAAc,CAAC,MAAgB;IAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,kBAAkB,CAAA;IAC1B,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC"}
|
Reference in New Issue
Block a user