first commit

This commit is contained in:
Myk
2025-07-31 23:47:20 +03:00
commit 2186b278a0
5149 changed files with 537218 additions and 0 deletions

3
node_modules/mqtt/build/lib/connect/ali.d.ts generated vendored Normal file
View 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
View 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
View 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,CAAC,CAAA;IACH,CAAC,C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E1C,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
View 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
View 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

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
View 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
View 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
View File

@@ -0,0 +1 @@
{"version":3,"file":"socks.js","sourceRoot":"","sources":["../../../src/lib/connect/socks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgNA,4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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
View 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
View 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
View 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
View 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
View 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
View 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,KAA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CAAC,CAAA;QACpD,CAAC;IACF,CAAC,CAAC,CAAA;IAEF,SAAS,eAAe,CAAC,GAAU;QAElC,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAC1B,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
View 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
View 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

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
View 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
View 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
View 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,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