mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
* fix: remove spinner, make dev mode notice infrequent * fix: make dev mode notice less frequent * fix: improve dev mode closure warning * fix: improve disconnection notice for dev mode functions * feat: improve dev mode messaging and list endpoints and functions * fix: do not display dev mode notice for non-node functions
14241 lines
408 KiB
JavaScript
14241 lines
408 KiB
JavaScript
var nh = Object.create
|
|
var Nr = Object.defineProperty
|
|
var sh = Object.getOwnPropertyDescriptor
|
|
var oh = Object.getOwnPropertyNames
|
|
var ah = Object.getPrototypeOf,
|
|
fh = Object.prototype.hasOwnProperty
|
|
var b = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports),
|
|
lh = (e, t) => {
|
|
for (var r in t) Nr(e, r, { get: t[r], enumerable: !0 })
|
|
},
|
|
Eo = (e, t, r, i) => {
|
|
if ((t && typeof t == 'object') || typeof t == 'function')
|
|
for (let n of oh(t))
|
|
!fh.call(e, n) &&
|
|
n !== r &&
|
|
Nr(e, n, {
|
|
get: () => t[n],
|
|
enumerable: !(i = sh(t, n)) || i.enumerable,
|
|
})
|
|
return e
|
|
}
|
|
var uh = (e, t, r) => (
|
|
(r = e != null ? nh(ah(e)) : {}),
|
|
Eo(
|
|
t || !e || !e.__esModule
|
|
? Nr(r, 'default', { value: e, enumerable: !0 })
|
|
: r,
|
|
e,
|
|
)
|
|
),
|
|
ch = (e) => Eo(Nr({}, '__esModule', { value: !0 }), e)
|
|
var Mr = b((Pm, xo) => {
|
|
xo.exports = dh
|
|
var hh = Object.prototype.hasOwnProperty
|
|
function dh() {
|
|
for (var e = {}, t = 0; t < arguments.length; t++) {
|
|
var r = arguments[t]
|
|
for (var i in r) hh.call(r, i) && (e[i] = r[i])
|
|
}
|
|
return e
|
|
}
|
|
})
|
|
var Zi = b((Bm, Co) => {
|
|
Co.exports = require('stream')
|
|
})
|
|
var Po = b((Am, Ro) => {
|
|
'use strict'
|
|
function To(e, t) {
|
|
var r = Object.keys(e)
|
|
if (Object.getOwnPropertySymbols) {
|
|
var i = Object.getOwnPropertySymbols(e)
|
|
t &&
|
|
(i = i.filter(function (n) {
|
|
return Object.getOwnPropertyDescriptor(e, n).enumerable
|
|
})),
|
|
r.push.apply(r, i)
|
|
}
|
|
return r
|
|
}
|
|
function Io(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = arguments[t] != null ? arguments[t] : {}
|
|
t % 2
|
|
? To(Object(r), !0).forEach(function (i) {
|
|
ph(e, i, r[i])
|
|
})
|
|
: Object.getOwnPropertyDescriptors
|
|
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r))
|
|
: To(Object(r)).forEach(function (i) {
|
|
Object.defineProperty(e, i, Object.getOwnPropertyDescriptor(r, i))
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
function ph(e, t, r) {
|
|
return (
|
|
(t = ko(t)),
|
|
t in e
|
|
? Object.defineProperty(e, t, {
|
|
value: r,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0,
|
|
})
|
|
: (e[t] = r),
|
|
e
|
|
)
|
|
}
|
|
function _h(e, t) {
|
|
if (!(e instanceof t))
|
|
throw new TypeError('Cannot call a class as a function')
|
|
}
|
|
function Oo(e, t) {
|
|
for (var r = 0; r < t.length; r++) {
|
|
var i = t[r]
|
|
;(i.enumerable = i.enumerable || !1),
|
|
(i.configurable = !0),
|
|
'value' in i && (i.writable = !0),
|
|
Object.defineProperty(e, ko(i.key), i)
|
|
}
|
|
}
|
|
function gh(e, t, r) {
|
|
return (
|
|
t && Oo(e.prototype, t),
|
|
r && Oo(e, r),
|
|
Object.defineProperty(e, 'prototype', { writable: !1 }),
|
|
e
|
|
)
|
|
}
|
|
function ko(e) {
|
|
var t = bh(e, 'string')
|
|
return typeof t == 'symbol' ? t : String(t)
|
|
}
|
|
function bh(e, t) {
|
|
if (typeof e != 'object' || e === null) return e
|
|
var r = e[Symbol.toPrimitive]
|
|
if (r !== void 0) {
|
|
var i = r.call(e, t || 'default')
|
|
if (typeof i != 'object') return i
|
|
throw new TypeError('@@toPrimitive must return a primitive value.')
|
|
}
|
|
return (t === 'string' ? String : Number)(e)
|
|
}
|
|
var yh = require('buffer'),
|
|
Lr = yh.Buffer,
|
|
vh = require('util'),
|
|
en = vh.inspect,
|
|
mh = (en && en.custom) || 'inspect'
|
|
function wh(e, t, r) {
|
|
Lr.prototype.copy.call(e, t, r)
|
|
}
|
|
Ro.exports = (function () {
|
|
function e() {
|
|
_h(this, e), (this.head = null), (this.tail = null), (this.length = 0)
|
|
}
|
|
return (
|
|
gh(e, [
|
|
{
|
|
key: 'push',
|
|
value: function (r) {
|
|
var i = { data: r, next: null }
|
|
this.length > 0 ? (this.tail.next = i) : (this.head = i),
|
|
(this.tail = i),
|
|
++this.length
|
|
},
|
|
},
|
|
{
|
|
key: 'unshift',
|
|
value: function (r) {
|
|
var i = { data: r, next: this.head }
|
|
this.length === 0 && (this.tail = i), (this.head = i), ++this.length
|
|
},
|
|
},
|
|
{
|
|
key: 'shift',
|
|
value: function () {
|
|
if (this.length !== 0) {
|
|
var r = this.head.data
|
|
return (
|
|
this.length === 1
|
|
? (this.head = this.tail = null)
|
|
: (this.head = this.head.next),
|
|
--this.length,
|
|
r
|
|
)
|
|
}
|
|
},
|
|
},
|
|
{
|
|
key: 'clear',
|
|
value: function () {
|
|
;(this.head = this.tail = null), (this.length = 0)
|
|
},
|
|
},
|
|
{
|
|
key: 'join',
|
|
value: function (r) {
|
|
if (this.length === 0) return ''
|
|
for (var i = this.head, n = '' + i.data; (i = i.next); )
|
|
n += r + i.data
|
|
return n
|
|
},
|
|
},
|
|
{
|
|
key: 'concat',
|
|
value: function (r) {
|
|
if (this.length === 0) return Lr.alloc(0)
|
|
for (var i = Lr.allocUnsafe(r >>> 0), n = this.head, s = 0; n; )
|
|
wh(n.data, i, s), (s += n.data.length), (n = n.next)
|
|
return i
|
|
},
|
|
},
|
|
{
|
|
key: 'consume',
|
|
value: function (r, i) {
|
|
var n
|
|
return (
|
|
r < this.head.data.length
|
|
? ((n = this.head.data.slice(0, r)),
|
|
(this.head.data = this.head.data.slice(r)))
|
|
: r === this.head.data.length
|
|
? (n = this.shift())
|
|
: (n = i ? this._getString(r) : this._getBuffer(r)),
|
|
n
|
|
)
|
|
},
|
|
},
|
|
{
|
|
key: 'first',
|
|
value: function () {
|
|
return this.head.data
|
|
},
|
|
},
|
|
{
|
|
key: '_getString',
|
|
value: function (r) {
|
|
var i = this.head,
|
|
n = 1,
|
|
s = i.data
|
|
for (r -= s.length; (i = i.next); ) {
|
|
var o = i.data,
|
|
f = r > o.length ? o.length : r
|
|
if (
|
|
(f === o.length ? (s += o) : (s += o.slice(0, r)),
|
|
(r -= f),
|
|
r === 0)
|
|
) {
|
|
f === o.length
|
|
? (++n,
|
|
i.next
|
|
? (this.head = i.next)
|
|
: (this.head = this.tail = null))
|
|
: ((this.head = i), (i.data = o.slice(f)))
|
|
break
|
|
}
|
|
++n
|
|
}
|
|
return (this.length -= n), s
|
|
},
|
|
},
|
|
{
|
|
key: '_getBuffer',
|
|
value: function (r) {
|
|
var i = Lr.allocUnsafe(r),
|
|
n = this.head,
|
|
s = 1
|
|
for (n.data.copy(i), r -= n.data.length; (n = n.next); ) {
|
|
var o = n.data,
|
|
f = r > o.length ? o.length : r
|
|
if ((o.copy(i, i.length - r, 0, f), (r -= f), r === 0)) {
|
|
f === o.length
|
|
? (++s,
|
|
n.next
|
|
? (this.head = n.next)
|
|
: (this.head = this.tail = null))
|
|
: ((this.head = n), (n.data = o.slice(f)))
|
|
break
|
|
}
|
|
++s
|
|
}
|
|
return (this.length -= s), i
|
|
},
|
|
},
|
|
{
|
|
key: mh,
|
|
value: function (r, i) {
|
|
return en(this, Io(Io({}, i), {}, { depth: 0, customInspect: !1 }))
|
|
},
|
|
},
|
|
]),
|
|
e
|
|
)
|
|
})()
|
|
})
|
|
var rn = b((Nm, Ao) => {
|
|
'use strict'
|
|
function Sh(e, t) {
|
|
var r = this,
|
|
i = this._readableState && this._readableState.destroyed,
|
|
n = this._writableState && this._writableState.destroyed
|
|
return i || n
|
|
? (t
|
|
? t(e)
|
|
: e &&
|
|
(this._writableState
|
|
? this._writableState.errorEmitted ||
|
|
((this._writableState.errorEmitted = !0),
|
|
process.nextTick(tn, this, e))
|
|
: process.nextTick(tn, this, e)),
|
|
this)
|
|
: (this._readableState && (this._readableState.destroyed = !0),
|
|
this._writableState && (this._writableState.destroyed = !0),
|
|
this._destroy(e || null, function (s) {
|
|
!t && s
|
|
? r._writableState
|
|
? r._writableState.errorEmitted
|
|
? process.nextTick(qr, r)
|
|
: ((r._writableState.errorEmitted = !0),
|
|
process.nextTick(Bo, r, s))
|
|
: process.nextTick(Bo, r, s)
|
|
: t
|
|
? (process.nextTick(qr, r), t(s))
|
|
: process.nextTick(qr, r)
|
|
}),
|
|
this)
|
|
}
|
|
function Bo(e, t) {
|
|
tn(e, t), qr(e)
|
|
}
|
|
function qr(e) {
|
|
;(e._writableState && !e._writableState.emitClose) ||
|
|
(e._readableState && !e._readableState.emitClose) ||
|
|
e.emit('close')
|
|
}
|
|
function Eh() {
|
|
this._readableState &&
|
|
((this._readableState.destroyed = !1),
|
|
(this._readableState.reading = !1),
|
|
(this._readableState.ended = !1),
|
|
(this._readableState.endEmitted = !1)),
|
|
this._writableState &&
|
|
((this._writableState.destroyed = !1),
|
|
(this._writableState.ended = !1),
|
|
(this._writableState.ending = !1),
|
|
(this._writableState.finalCalled = !1),
|
|
(this._writableState.prefinished = !1),
|
|
(this._writableState.finished = !1),
|
|
(this._writableState.errorEmitted = !1))
|
|
}
|
|
function tn(e, t) {
|
|
e.emit('error', t)
|
|
}
|
|
function xh(e, t) {
|
|
var r = e._readableState,
|
|
i = e._writableState
|
|
;(r && r.autoDestroy) || (i && i.autoDestroy)
|
|
? e.destroy(t)
|
|
: e.emit('error', t)
|
|
}
|
|
Ao.exports = { destroy: Sh, undestroy: Eh, errorOrDestroy: xh }
|
|
})
|
|
var Ue = b((Mm, Lo) => {
|
|
'use strict'
|
|
var Mo = {}
|
|
function he(e, t, r) {
|
|
r || (r = Error)
|
|
function i(s, o, f) {
|
|
return typeof t == 'string' ? t : t(s, o, f)
|
|
}
|
|
class n extends r {
|
|
constructor(o, f, a) {
|
|
super(i(o, f, a))
|
|
}
|
|
}
|
|
;(n.prototype.name = r.name), (n.prototype.code = e), (Mo[e] = n)
|
|
}
|
|
function No(e, t) {
|
|
if (Array.isArray(e)) {
|
|
let r = e.length
|
|
return (
|
|
(e = e.map((i) => String(i))),
|
|
r > 2
|
|
? `one of ${t} ${e.slice(0, r - 1).join(', ')}, or ` + e[r - 1]
|
|
: r === 2
|
|
? `one of ${t} ${e[0]} or ${e[1]}`
|
|
: `of ${t} ${e[0]}`
|
|
)
|
|
} else return `of ${t} ${String(e)}`
|
|
}
|
|
function Ch(e, t, r) {
|
|
return e.substr(!r || r < 0 ? 0 : +r, t.length) === t
|
|
}
|
|
function Th(e, t, r) {
|
|
return (
|
|
(r === void 0 || r > e.length) && (r = e.length),
|
|
e.substring(r - t.length, r) === t
|
|
)
|
|
}
|
|
function Ih(e, t, r) {
|
|
return (
|
|
typeof r != 'number' && (r = 0),
|
|
r + t.length > e.length ? !1 : e.indexOf(t, r) !== -1
|
|
)
|
|
}
|
|
he(
|
|
'ERR_INVALID_OPT_VALUE',
|
|
function (e, t) {
|
|
return 'The value "' + t + '" is invalid for option "' + e + '"'
|
|
},
|
|
TypeError,
|
|
)
|
|
he(
|
|
'ERR_INVALID_ARG_TYPE',
|
|
function (e, t, r) {
|
|
let i
|
|
typeof t == 'string' && Ch(t, 'not ')
|
|
? ((i = 'must not be'), (t = t.replace(/^not /, '')))
|
|
: (i = 'must be')
|
|
let n
|
|
if (Th(e, ' argument')) n = `The ${e} ${i} ${No(t, 'type')}`
|
|
else {
|
|
let s = Ih(e, '.') ? 'property' : 'argument'
|
|
n = `The "${e}" ${s} ${i} ${No(t, 'type')}`
|
|
}
|
|
return (n += `. Received type ${typeof r}`), n
|
|
},
|
|
TypeError,
|
|
)
|
|
he('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF')
|
|
he('ERR_METHOD_NOT_IMPLEMENTED', function (e) {
|
|
return 'The ' + e + ' method is not implemented'
|
|
})
|
|
he('ERR_STREAM_PREMATURE_CLOSE', 'Premature close')
|
|
he('ERR_STREAM_DESTROYED', function (e) {
|
|
return 'Cannot call ' + e + ' after a stream was destroyed'
|
|
})
|
|
he('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times')
|
|
he('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable')
|
|
he('ERR_STREAM_WRITE_AFTER_END', 'write after end')
|
|
he('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError)
|
|
he(
|
|
'ERR_UNKNOWN_ENCODING',
|
|
function (e) {
|
|
return 'Unknown encoding: ' + e
|
|
},
|
|
TypeError,
|
|
)
|
|
he('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event')
|
|
Lo.exports.codes = Mo
|
|
})
|
|
var nn = b((Lm, qo) => {
|
|
'use strict'
|
|
var Oh = Ue().codes.ERR_INVALID_OPT_VALUE
|
|
function kh(e, t, r) {
|
|
return e.highWaterMark != null ? e.highWaterMark : t ? e[r] : null
|
|
}
|
|
function Rh(e, t, r, i) {
|
|
var n = kh(t, i, r)
|
|
if (n != null) {
|
|
if (!(isFinite(n) && Math.floor(n) === n) || n < 0) {
|
|
var s = i ? r : 'highWaterMark'
|
|
throw new Oh(s, n)
|
|
}
|
|
return Math.floor(n)
|
|
}
|
|
return e.objectMode ? 16 : 16 * 1024
|
|
}
|
|
qo.exports = { getHighWaterMark: Rh }
|
|
})
|
|
var Do = b((qm, sn) => {
|
|
typeof Object.create == 'function'
|
|
? (sn.exports = function (t, r) {
|
|
r &&
|
|
((t.super_ = r),
|
|
(t.prototype = Object.create(r.prototype, {
|
|
constructor: {
|
|
value: t,
|
|
enumerable: !1,
|
|
writable: !0,
|
|
configurable: !0,
|
|
},
|
|
})))
|
|
})
|
|
: (sn.exports = function (t, r) {
|
|
if (r) {
|
|
t.super_ = r
|
|
var i = function () {}
|
|
;(i.prototype = r.prototype),
|
|
(t.prototype = new i()),
|
|
(t.prototype.constructor = t)
|
|
}
|
|
})
|
|
})
|
|
var ie = b((Dm, an) => {
|
|
try {
|
|
if (((on = require('util')), typeof on.inherits != 'function')) throw ''
|
|
an.exports = on.inherits
|
|
} catch {
|
|
an.exports = Do()
|
|
}
|
|
var on
|
|
})
|
|
var fn = b((Um, Uo) => {
|
|
Uo.exports = require('util').deprecate
|
|
})
|
|
var cn = b((jm, $o) => {
|
|
'use strict'
|
|
$o.exports = $
|
|
function Fo(e) {
|
|
var t = this
|
|
;(this.next = null),
|
|
(this.entry = null),
|
|
(this.finish = function () {
|
|
id(t, e)
|
|
})
|
|
}
|
|
var wt
|
|
$.WritableState = Ft
|
|
var Ph = { deprecate: fn() },
|
|
Wo = Zi(),
|
|
Ur = require('buffer').Buffer,
|
|
Bh =
|
|
(typeof global < 'u'
|
|
? global
|
|
: typeof window < 'u'
|
|
? window
|
|
: typeof self < 'u'
|
|
? self
|
|
: {}
|
|
).Uint8Array || function () {}
|
|
function Ah(e) {
|
|
return Ur.from(e)
|
|
}
|
|
function Nh(e) {
|
|
return Ur.isBuffer(e) || e instanceof Bh
|
|
}
|
|
var un = rn(),
|
|
Mh = nn(),
|
|
Lh = Mh.getHighWaterMark,
|
|
je = Ue().codes,
|
|
qh = je.ERR_INVALID_ARG_TYPE,
|
|
Dh = je.ERR_METHOD_NOT_IMPLEMENTED,
|
|
Uh = je.ERR_MULTIPLE_CALLBACK,
|
|
jh = je.ERR_STREAM_CANNOT_PIPE,
|
|
Fh = je.ERR_STREAM_DESTROYED,
|
|
Wh = je.ERR_STREAM_NULL_VALUES,
|
|
Vh = je.ERR_STREAM_WRITE_AFTER_END,
|
|
Hh = je.ERR_UNKNOWN_ENCODING,
|
|
St = un.errorOrDestroy
|
|
ie()($, Wo)
|
|
function $h() {}
|
|
function Ft(e, t, r) {
|
|
;(wt = wt || it()),
|
|
(e = e || {}),
|
|
typeof r != 'boolean' && (r = t instanceof wt),
|
|
(this.objectMode = !!e.objectMode),
|
|
r && (this.objectMode = this.objectMode || !!e.writableObjectMode),
|
|
(this.highWaterMark = Lh(this, e, 'writableHighWaterMark', r)),
|
|
(this.finalCalled = !1),
|
|
(this.needDrain = !1),
|
|
(this.ending = !1),
|
|
(this.ended = !1),
|
|
(this.finished = !1),
|
|
(this.destroyed = !1)
|
|
var i = e.decodeStrings === !1
|
|
;(this.decodeStrings = !i),
|
|
(this.defaultEncoding = e.defaultEncoding || 'utf8'),
|
|
(this.length = 0),
|
|
(this.writing = !1),
|
|
(this.corked = 0),
|
|
(this.sync = !0),
|
|
(this.bufferProcessing = !1),
|
|
(this.onwrite = function (n) {
|
|
Xh(t, n)
|
|
}),
|
|
(this.writecb = null),
|
|
(this.writelen = 0),
|
|
(this.bufferedRequest = null),
|
|
(this.lastBufferedRequest = null),
|
|
(this.pendingcb = 0),
|
|
(this.prefinished = !1),
|
|
(this.errorEmitted = !1),
|
|
(this.emitClose = e.emitClose !== !1),
|
|
(this.autoDestroy = !!e.autoDestroy),
|
|
(this.bufferedRequestCount = 0),
|
|
(this.corkedRequestsFree = new Fo(this))
|
|
}
|
|
Ft.prototype.getBuffer = function () {
|
|
for (var t = this.bufferedRequest, r = []; t; ) r.push(t), (t = t.next)
|
|
return r
|
|
}
|
|
;(function () {
|
|
try {
|
|
Object.defineProperty(Ft.prototype, 'buffer', {
|
|
get: Ph.deprecate(
|
|
function () {
|
|
return this.getBuffer()
|
|
},
|
|
'_writableState.buffer is deprecated. Use _writableState.getBuffer instead.',
|
|
'DEP0003',
|
|
),
|
|
})
|
|
} catch {}
|
|
})()
|
|
var Dr
|
|
typeof Symbol == 'function' &&
|
|
Symbol.hasInstance &&
|
|
typeof Function.prototype[Symbol.hasInstance] == 'function'
|
|
? ((Dr = Function.prototype[Symbol.hasInstance]),
|
|
Object.defineProperty($, Symbol.hasInstance, {
|
|
value: function (t) {
|
|
return Dr.call(this, t)
|
|
? !0
|
|
: this !== $
|
|
? !1
|
|
: t && t._writableState instanceof Ft
|
|
},
|
|
}))
|
|
: (Dr = function (t) {
|
|
return t instanceof this
|
|
})
|
|
function $(e) {
|
|
wt = wt || it()
|
|
var t = this instanceof wt
|
|
if (!t && !Dr.call($, this)) return new $(e)
|
|
;(this._writableState = new Ft(e, this, t)),
|
|
(this.writable = !0),
|
|
e &&
|
|
(typeof e.write == 'function' && (this._write = e.write),
|
|
typeof e.writev == 'function' && (this._writev = e.writev),
|
|
typeof e.destroy == 'function' && (this._destroy = e.destroy),
|
|
typeof e.final == 'function' && (this._final = e.final)),
|
|
Wo.call(this)
|
|
}
|
|
$.prototype.pipe = function () {
|
|
St(this, new jh())
|
|
}
|
|
function Gh(e, t) {
|
|
var r = new Vh()
|
|
St(e, r), process.nextTick(t, r)
|
|
}
|
|
function zh(e, t, r, i) {
|
|
var n
|
|
return (
|
|
r === null
|
|
? (n = new Wh())
|
|
: typeof r != 'string' &&
|
|
!t.objectMode &&
|
|
(n = new qh('chunk', ['string', 'Buffer'], r)),
|
|
n ? (St(e, n), process.nextTick(i, n), !1) : !0
|
|
)
|
|
}
|
|
$.prototype.write = function (e, t, r) {
|
|
var i = this._writableState,
|
|
n = !1,
|
|
s = !i.objectMode && Nh(e)
|
|
return (
|
|
s && !Ur.isBuffer(e) && (e = Ah(e)),
|
|
typeof t == 'function' && ((r = t), (t = null)),
|
|
s ? (t = 'buffer') : t || (t = i.defaultEncoding),
|
|
typeof r != 'function' && (r = $h),
|
|
i.ending
|
|
? Gh(this, r)
|
|
: (s || zh(this, i, e, r)) &&
|
|
(i.pendingcb++, (n = Yh(this, i, s, e, t, r))),
|
|
n
|
|
)
|
|
}
|
|
$.prototype.cork = function () {
|
|
this._writableState.corked++
|
|
}
|
|
$.prototype.uncork = function () {
|
|
var e = this._writableState
|
|
e.corked &&
|
|
(e.corked--,
|
|
!e.writing &&
|
|
!e.corked &&
|
|
!e.bufferProcessing &&
|
|
e.bufferedRequest &&
|
|
Vo(this, e))
|
|
}
|
|
$.prototype.setDefaultEncoding = function (t) {
|
|
if (
|
|
(typeof t == 'string' && (t = t.toLowerCase()),
|
|
!(
|
|
[
|
|
'hex',
|
|
'utf8',
|
|
'utf-8',
|
|
'ascii',
|
|
'binary',
|
|
'base64',
|
|
'ucs2',
|
|
'ucs-2',
|
|
'utf16le',
|
|
'utf-16le',
|
|
'raw',
|
|
].indexOf((t + '').toLowerCase()) > -1
|
|
))
|
|
)
|
|
throw new Hh(t)
|
|
return (this._writableState.defaultEncoding = t), this
|
|
}
|
|
Object.defineProperty($.prototype, 'writableBuffer', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState && this._writableState.getBuffer()
|
|
},
|
|
})
|
|
function Kh(e, t, r) {
|
|
return (
|
|
!e.objectMode &&
|
|
e.decodeStrings !== !1 &&
|
|
typeof t == 'string' &&
|
|
(t = Ur.from(t, r)),
|
|
t
|
|
)
|
|
}
|
|
Object.defineProperty($.prototype, 'writableHighWaterMark', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState.highWaterMark
|
|
},
|
|
})
|
|
function Yh(e, t, r, i, n, s) {
|
|
if (!r) {
|
|
var o = Kh(t, i, n)
|
|
i !== o && ((r = !0), (n = 'buffer'), (i = o))
|
|
}
|
|
var f = t.objectMode ? 1 : i.length
|
|
t.length += f
|
|
var a = t.length < t.highWaterMark
|
|
if ((a || (t.needDrain = !0), t.writing || t.corked)) {
|
|
var l = t.lastBufferedRequest
|
|
;(t.lastBufferedRequest = {
|
|
chunk: i,
|
|
encoding: n,
|
|
isBuf: r,
|
|
callback: s,
|
|
next: null,
|
|
}),
|
|
l
|
|
? (l.next = t.lastBufferedRequest)
|
|
: (t.bufferedRequest = t.lastBufferedRequest),
|
|
(t.bufferedRequestCount += 1)
|
|
} else ln(e, t, !1, f, i, n, s)
|
|
return a
|
|
}
|
|
function ln(e, t, r, i, n, s, o) {
|
|
;(t.writelen = i),
|
|
(t.writecb = o),
|
|
(t.writing = !0),
|
|
(t.sync = !0),
|
|
t.destroyed
|
|
? t.onwrite(new Fh('write'))
|
|
: r
|
|
? e._writev(n, t.onwrite)
|
|
: e._write(n, s, t.onwrite),
|
|
(t.sync = !1)
|
|
}
|
|
function Qh(e, t, r, i, n) {
|
|
--t.pendingcb,
|
|
r
|
|
? (process.nextTick(n, i),
|
|
process.nextTick(jt, e, t),
|
|
(e._writableState.errorEmitted = !0),
|
|
St(e, i))
|
|
: (n(i), (e._writableState.errorEmitted = !0), St(e, i), jt(e, t))
|
|
}
|
|
function Jh(e) {
|
|
;(e.writing = !1),
|
|
(e.writecb = null),
|
|
(e.length -= e.writelen),
|
|
(e.writelen = 0)
|
|
}
|
|
function Xh(e, t) {
|
|
var r = e._writableState,
|
|
i = r.sync,
|
|
n = r.writecb
|
|
if (typeof n != 'function') throw new Uh()
|
|
if ((Jh(r), t)) Qh(e, r, i, t, n)
|
|
else {
|
|
var s = Ho(r) || e.destroyed
|
|
!s && !r.corked && !r.bufferProcessing && r.bufferedRequest && Vo(e, r),
|
|
i ? process.nextTick(jo, e, r, s, n) : jo(e, r, s, n)
|
|
}
|
|
}
|
|
function jo(e, t, r, i) {
|
|
r || Zh(e, t), t.pendingcb--, i(), jt(e, t)
|
|
}
|
|
function Zh(e, t) {
|
|
t.length === 0 && t.needDrain && ((t.needDrain = !1), e.emit('drain'))
|
|
}
|
|
function Vo(e, t) {
|
|
t.bufferProcessing = !0
|
|
var r = t.bufferedRequest
|
|
if (e._writev && r && r.next) {
|
|
var i = t.bufferedRequestCount,
|
|
n = new Array(i),
|
|
s = t.corkedRequestsFree
|
|
s.entry = r
|
|
for (var o = 0, f = !0; r; )
|
|
(n[o] = r), r.isBuf || (f = !1), (r = r.next), (o += 1)
|
|
;(n.allBuffers = f),
|
|
ln(e, t, !0, t.length, n, '', s.finish),
|
|
t.pendingcb++,
|
|
(t.lastBufferedRequest = null),
|
|
s.next
|
|
? ((t.corkedRequestsFree = s.next), (s.next = null))
|
|
: (t.corkedRequestsFree = new Fo(t)),
|
|
(t.bufferedRequestCount = 0)
|
|
} else {
|
|
for (; r; ) {
|
|
var a = r.chunk,
|
|
l = r.encoding,
|
|
u = r.callback,
|
|
h = t.objectMode ? 1 : a.length
|
|
if (
|
|
(ln(e, t, !1, h, a, l, u),
|
|
(r = r.next),
|
|
t.bufferedRequestCount--,
|
|
t.writing)
|
|
)
|
|
break
|
|
}
|
|
r === null && (t.lastBufferedRequest = null)
|
|
}
|
|
;(t.bufferedRequest = r), (t.bufferProcessing = !1)
|
|
}
|
|
$.prototype._write = function (e, t, r) {
|
|
r(new Dh('_write()'))
|
|
}
|
|
$.prototype._writev = null
|
|
$.prototype.end = function (e, t, r) {
|
|
var i = this._writableState
|
|
return (
|
|
typeof e == 'function'
|
|
? ((r = e), (e = null), (t = null))
|
|
: typeof t == 'function' && ((r = t), (t = null)),
|
|
e != null && this.write(e, t),
|
|
i.corked && ((i.corked = 1), this.uncork()),
|
|
i.ending || rd(this, i, r),
|
|
this
|
|
)
|
|
}
|
|
Object.defineProperty($.prototype, 'writableLength', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState.length
|
|
},
|
|
})
|
|
function Ho(e) {
|
|
return (
|
|
e.ending &&
|
|
e.length === 0 &&
|
|
e.bufferedRequest === null &&
|
|
!e.finished &&
|
|
!e.writing
|
|
)
|
|
}
|
|
function ed(e, t) {
|
|
e._final(function (r) {
|
|
t.pendingcb--,
|
|
r && St(e, r),
|
|
(t.prefinished = !0),
|
|
e.emit('prefinish'),
|
|
jt(e, t)
|
|
})
|
|
}
|
|
function td(e, t) {
|
|
!t.prefinished &&
|
|
!t.finalCalled &&
|
|
(typeof e._final == 'function' && !t.destroyed
|
|
? (t.pendingcb++, (t.finalCalled = !0), process.nextTick(ed, e, t))
|
|
: ((t.prefinished = !0), e.emit('prefinish')))
|
|
}
|
|
function jt(e, t) {
|
|
var r = Ho(t)
|
|
if (
|
|
r &&
|
|
(td(e, t),
|
|
t.pendingcb === 0 && ((t.finished = !0), e.emit('finish'), t.autoDestroy))
|
|
) {
|
|
var i = e._readableState
|
|
;(!i || (i.autoDestroy && i.endEmitted)) && e.destroy()
|
|
}
|
|
return r
|
|
}
|
|
function rd(e, t, r) {
|
|
;(t.ending = !0),
|
|
jt(e, t),
|
|
r && (t.finished ? process.nextTick(r) : e.once('finish', r)),
|
|
(t.ended = !0),
|
|
(e.writable = !1)
|
|
}
|
|
function id(e, t, r) {
|
|
var i = e.entry
|
|
for (e.entry = null; i; ) {
|
|
var n = i.callback
|
|
t.pendingcb--, n(r), (i = i.next)
|
|
}
|
|
t.corkedRequestsFree.next = e
|
|
}
|
|
Object.defineProperty($.prototype, 'destroyed', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState === void 0 ? !1 : this._writableState.destroyed
|
|
},
|
|
set: function (t) {
|
|
this._writableState && (this._writableState.destroyed = t)
|
|
},
|
|
})
|
|
$.prototype.destroy = un.destroy
|
|
$.prototype._undestroy = un.undestroy
|
|
$.prototype._destroy = function (e, t) {
|
|
t(e)
|
|
}
|
|
})
|
|
var it = b((Fm, zo) => {
|
|
'use strict'
|
|
var nd =
|
|
Object.keys ||
|
|
function (e) {
|
|
var t = []
|
|
for (var r in e) t.push(r)
|
|
return t
|
|
}
|
|
zo.exports = Ee
|
|
var Go = pn(),
|
|
dn = cn()
|
|
ie()(Ee, Go)
|
|
for (hn = nd(dn.prototype), jr = 0; jr < hn.length; jr++)
|
|
(Fr = hn[jr]), Ee.prototype[Fr] || (Ee.prototype[Fr] = dn.prototype[Fr])
|
|
var hn, Fr, jr
|
|
function Ee(e) {
|
|
if (!(this instanceof Ee)) return new Ee(e)
|
|
Go.call(this, e),
|
|
dn.call(this, e),
|
|
(this.allowHalfOpen = !0),
|
|
e &&
|
|
(e.readable === !1 && (this.readable = !1),
|
|
e.writable === !1 && (this.writable = !1),
|
|
e.allowHalfOpen === !1 &&
|
|
((this.allowHalfOpen = !1), this.once('end', sd)))
|
|
}
|
|
Object.defineProperty(Ee.prototype, 'writableHighWaterMark', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState.highWaterMark
|
|
},
|
|
})
|
|
Object.defineProperty(Ee.prototype, 'writableBuffer', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState && this._writableState.getBuffer()
|
|
},
|
|
})
|
|
Object.defineProperty(Ee.prototype, 'writableLength', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState.length
|
|
},
|
|
})
|
|
function sd() {
|
|
this._writableState.ended || process.nextTick(od, this)
|
|
}
|
|
function od(e) {
|
|
e.end()
|
|
}
|
|
Object.defineProperty(Ee.prototype, 'destroyed', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._readableState === void 0 || this._writableState === void 0
|
|
? !1
|
|
: this._readableState.destroyed && this._writableState.destroyed
|
|
},
|
|
set: function (t) {
|
|
this._readableState === void 0 ||
|
|
this._writableState === void 0 ||
|
|
((this._readableState.destroyed = t),
|
|
(this._writableState.destroyed = t))
|
|
},
|
|
})
|
|
})
|
|
var Qo = b((_n, Yo) => {
|
|
var Wr = require('buffer'),
|
|
xe = Wr.Buffer
|
|
function Ko(e, t) {
|
|
for (var r in e) t[r] = e[r]
|
|
}
|
|
xe.from && xe.alloc && xe.allocUnsafe && xe.allocUnsafeSlow
|
|
? (Yo.exports = Wr)
|
|
: (Ko(Wr, _n), (_n.Buffer = nt))
|
|
function nt(e, t, r) {
|
|
return xe(e, t, r)
|
|
}
|
|
nt.prototype = Object.create(xe.prototype)
|
|
Ko(xe, nt)
|
|
nt.from = function (e, t, r) {
|
|
if (typeof e == 'number')
|
|
throw new TypeError('Argument must not be a number')
|
|
return xe(e, t, r)
|
|
}
|
|
nt.alloc = function (e, t, r) {
|
|
if (typeof e != 'number') throw new TypeError('Argument must be a number')
|
|
var i = xe(e)
|
|
return (
|
|
t !== void 0
|
|
? typeof r == 'string'
|
|
? i.fill(t, r)
|
|
: i.fill(t)
|
|
: i.fill(0),
|
|
i
|
|
)
|
|
}
|
|
nt.allocUnsafe = function (e) {
|
|
if (typeof e != 'number') throw new TypeError('Argument must be a number')
|
|
return xe(e)
|
|
}
|
|
nt.allocUnsafeSlow = function (e) {
|
|
if (typeof e != 'number') throw new TypeError('Argument must be a number')
|
|
return Wr.SlowBuffer(e)
|
|
}
|
|
})
|
|
var yn = b((Xo) => {
|
|
'use strict'
|
|
var bn = Qo().Buffer,
|
|
Jo =
|
|
bn.isEncoding ||
|
|
function (e) {
|
|
switch (((e = '' + e), e && e.toLowerCase())) {
|
|
case 'hex':
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'base64':
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
case 'raw':
|
|
return !0
|
|
default:
|
|
return !1
|
|
}
|
|
}
|
|
function ad(e) {
|
|
if (!e) return 'utf8'
|
|
for (var t; ; )
|
|
switch (e) {
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return 'utf8'
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return 'utf16le'
|
|
case 'latin1':
|
|
case 'binary':
|
|
return 'latin1'
|
|
case 'base64':
|
|
case 'ascii':
|
|
case 'hex':
|
|
return e
|
|
default:
|
|
if (t) return
|
|
;(e = ('' + e).toLowerCase()), (t = !0)
|
|
}
|
|
}
|
|
function fd(e) {
|
|
var t = ad(e)
|
|
if (typeof t != 'string' && (bn.isEncoding === Jo || !Jo(e)))
|
|
throw new Error('Unknown encoding: ' + e)
|
|
return t || e
|
|
}
|
|
Xo.StringDecoder = Wt
|
|
function Wt(e) {
|
|
this.encoding = fd(e)
|
|
var t
|
|
switch (this.encoding) {
|
|
case 'utf16le':
|
|
;(this.text = pd), (this.end = _d), (t = 4)
|
|
break
|
|
case 'utf8':
|
|
;(this.fillLast = cd), (t = 4)
|
|
break
|
|
case 'base64':
|
|
;(this.text = gd), (this.end = bd), (t = 3)
|
|
break
|
|
default:
|
|
;(this.write = yd), (this.end = vd)
|
|
return
|
|
}
|
|
;(this.lastNeed = 0),
|
|
(this.lastTotal = 0),
|
|
(this.lastChar = bn.allocUnsafe(t))
|
|
}
|
|
Wt.prototype.write = function (e) {
|
|
if (e.length === 0) return ''
|
|
var t, r
|
|
if (this.lastNeed) {
|
|
if (((t = this.fillLast(e)), t === void 0)) return ''
|
|
;(r = this.lastNeed), (this.lastNeed = 0)
|
|
} else r = 0
|
|
return r < e.length ? (t ? t + this.text(e, r) : this.text(e, r)) : t || ''
|
|
}
|
|
Wt.prototype.end = dd
|
|
Wt.prototype.text = hd
|
|
Wt.prototype.fillLast = function (e) {
|
|
if (this.lastNeed <= e.length)
|
|
return (
|
|
e.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed),
|
|
this.lastChar.toString(this.encoding, 0, this.lastTotal)
|
|
)
|
|
e.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, e.length),
|
|
(this.lastNeed -= e.length)
|
|
}
|
|
function gn(e) {
|
|
return e <= 127
|
|
? 0
|
|
: e >> 5 === 6
|
|
? 2
|
|
: e >> 4 === 14
|
|
? 3
|
|
: e >> 3 === 30
|
|
? 4
|
|
: e >> 6 === 2
|
|
? -1
|
|
: -2
|
|
}
|
|
function ld(e, t, r) {
|
|
var i = t.length - 1
|
|
if (i < r) return 0
|
|
var n = gn(t[i])
|
|
return n >= 0
|
|
? (n > 0 && (e.lastNeed = n - 1), n)
|
|
: --i < r || n === -2
|
|
? 0
|
|
: ((n = gn(t[i])),
|
|
n >= 0
|
|
? (n > 0 && (e.lastNeed = n - 2), n)
|
|
: --i < r || n === -2
|
|
? 0
|
|
: ((n = gn(t[i])),
|
|
n >= 0
|
|
? (n > 0 && (n === 2 ? (n = 0) : (e.lastNeed = n - 3)), n)
|
|
: 0))
|
|
}
|
|
function ud(e, t, r) {
|
|
if ((t[0] & 192) !== 128) return (e.lastNeed = 0), '\uFFFD'
|
|
if (e.lastNeed > 1 && t.length > 1) {
|
|
if ((t[1] & 192) !== 128) return (e.lastNeed = 1), '\uFFFD'
|
|
if (e.lastNeed > 2 && t.length > 2 && (t[2] & 192) !== 128)
|
|
return (e.lastNeed = 2), '\uFFFD'
|
|
}
|
|
}
|
|
function cd(e) {
|
|
var t = this.lastTotal - this.lastNeed,
|
|
r = ud(this, e, t)
|
|
if (r !== void 0) return r
|
|
if (this.lastNeed <= e.length)
|
|
return (
|
|
e.copy(this.lastChar, t, 0, this.lastNeed),
|
|
this.lastChar.toString(this.encoding, 0, this.lastTotal)
|
|
)
|
|
e.copy(this.lastChar, t, 0, e.length), (this.lastNeed -= e.length)
|
|
}
|
|
function hd(e, t) {
|
|
var r = ld(this, e, t)
|
|
if (!this.lastNeed) return e.toString('utf8', t)
|
|
this.lastTotal = r
|
|
var i = e.length - (r - this.lastNeed)
|
|
return e.copy(this.lastChar, 0, i), e.toString('utf8', t, i)
|
|
}
|
|
function dd(e) {
|
|
var t = e && e.length ? this.write(e) : ''
|
|
return this.lastNeed ? t + '\uFFFD' : t
|
|
}
|
|
function pd(e, t) {
|
|
if ((e.length - t) % 2 === 0) {
|
|
var r = e.toString('utf16le', t)
|
|
if (r) {
|
|
var i = r.charCodeAt(r.length - 1)
|
|
if (i >= 55296 && i <= 56319)
|
|
return (
|
|
(this.lastNeed = 2),
|
|
(this.lastTotal = 4),
|
|
(this.lastChar[0] = e[e.length - 2]),
|
|
(this.lastChar[1] = e[e.length - 1]),
|
|
r.slice(0, -1)
|
|
)
|
|
}
|
|
return r
|
|
}
|
|
return (
|
|
(this.lastNeed = 1),
|
|
(this.lastTotal = 2),
|
|
(this.lastChar[0] = e[e.length - 1]),
|
|
e.toString('utf16le', t, e.length - 1)
|
|
)
|
|
}
|
|
function _d(e) {
|
|
var t = e && e.length ? this.write(e) : ''
|
|
if (this.lastNeed) {
|
|
var r = this.lastTotal - this.lastNeed
|
|
return t + this.lastChar.toString('utf16le', 0, r)
|
|
}
|
|
return t
|
|
}
|
|
function gd(e, t) {
|
|
var r = (e.length - t) % 3
|
|
return r === 0
|
|
? e.toString('base64', t)
|
|
: ((this.lastNeed = 3 - r),
|
|
(this.lastTotal = 3),
|
|
r === 1
|
|
? (this.lastChar[0] = e[e.length - 1])
|
|
: ((this.lastChar[0] = e[e.length - 2]),
|
|
(this.lastChar[1] = e[e.length - 1])),
|
|
e.toString('base64', t, e.length - r))
|
|
}
|
|
function bd(e) {
|
|
var t = e && e.length ? this.write(e) : ''
|
|
return this.lastNeed
|
|
? t + this.lastChar.toString('base64', 0, 3 - this.lastNeed)
|
|
: t
|
|
}
|
|
function yd(e) {
|
|
return e.toString(this.encoding)
|
|
}
|
|
function vd(e) {
|
|
return e && e.length ? this.write(e) : ''
|
|
}
|
|
})
|
|
var Vr = b((Vm, ta) => {
|
|
'use strict'
|
|
var Zo = Ue().codes.ERR_STREAM_PREMATURE_CLOSE
|
|
function md(e) {
|
|
var t = !1
|
|
return function () {
|
|
if (!t) {
|
|
t = !0
|
|
for (var r = arguments.length, i = new Array(r), n = 0; n < r; n++)
|
|
i[n] = arguments[n]
|
|
e.apply(this, i)
|
|
}
|
|
}
|
|
}
|
|
function wd() {}
|
|
function Sd(e) {
|
|
return e.setHeader && typeof e.abort == 'function'
|
|
}
|
|
function ea(e, t, r) {
|
|
if (typeof t == 'function') return ea(e, null, t)
|
|
t || (t = {}), (r = md(r || wd))
|
|
var i = t.readable || (t.readable !== !1 && e.readable),
|
|
n = t.writable || (t.writable !== !1 && e.writable),
|
|
s = function () {
|
|
e.writable || f()
|
|
},
|
|
o = e._writableState && e._writableState.finished,
|
|
f = function () {
|
|
;(n = !1), (o = !0), i || r.call(e)
|
|
},
|
|
a = e._readableState && e._readableState.endEmitted,
|
|
l = function () {
|
|
;(i = !1), (a = !0), n || r.call(e)
|
|
},
|
|
u = function (_) {
|
|
r.call(e, _)
|
|
},
|
|
h = function () {
|
|
var _
|
|
if (i && !a)
|
|
return (
|
|
(!e._readableState || !e._readableState.ended) && (_ = new Zo()),
|
|
r.call(e, _)
|
|
)
|
|
if (n && !o)
|
|
return (
|
|
(!e._writableState || !e._writableState.ended) && (_ = new Zo()),
|
|
r.call(e, _)
|
|
)
|
|
},
|
|
c = function () {
|
|
e.req.on('finish', f)
|
|
}
|
|
return (
|
|
Sd(e)
|
|
? (e.on('complete', f),
|
|
e.on('abort', h),
|
|
e.req ? c() : e.on('request', c))
|
|
: n && !e._writableState && (e.on('end', s), e.on('close', s)),
|
|
e.on('end', l),
|
|
e.on('finish', f),
|
|
t.error !== !1 && e.on('error', u),
|
|
e.on('close', h),
|
|
function () {
|
|
e.removeListener('complete', f),
|
|
e.removeListener('abort', h),
|
|
e.removeListener('request', c),
|
|
e.req && e.req.removeListener('finish', f),
|
|
e.removeListener('end', s),
|
|
e.removeListener('close', s),
|
|
e.removeListener('finish', f),
|
|
e.removeListener('end', l),
|
|
e.removeListener('error', u),
|
|
e.removeListener('close', h)
|
|
}
|
|
)
|
|
}
|
|
ta.exports = ea
|
|
})
|
|
var ia = b((Hm, ra) => {
|
|
'use strict'
|
|
var Hr
|
|
function Fe(e, t, r) {
|
|
return (
|
|
(t = Ed(t)),
|
|
t in e
|
|
? Object.defineProperty(e, t, {
|
|
value: r,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0,
|
|
})
|
|
: (e[t] = r),
|
|
e
|
|
)
|
|
}
|
|
function Ed(e) {
|
|
var t = xd(e, 'string')
|
|
return typeof t == 'symbol' ? t : String(t)
|
|
}
|
|
function xd(e, t) {
|
|
if (typeof e != 'object' || e === null) return e
|
|
var r = e[Symbol.toPrimitive]
|
|
if (r !== void 0) {
|
|
var i = r.call(e, t || 'default')
|
|
if (typeof i != 'object') return i
|
|
throw new TypeError('@@toPrimitive must return a primitive value.')
|
|
}
|
|
return (t === 'string' ? String : Number)(e)
|
|
}
|
|
var Cd = Vr(),
|
|
We = Symbol('lastResolve'),
|
|
st = Symbol('lastReject'),
|
|
Vt = Symbol('error'),
|
|
$r = Symbol('ended'),
|
|
ot = Symbol('lastPromise'),
|
|
vn = Symbol('handlePromise'),
|
|
at = Symbol('stream')
|
|
function Ve(e, t) {
|
|
return { value: e, done: t }
|
|
}
|
|
function Td(e) {
|
|
var t = e[We]
|
|
if (t !== null) {
|
|
var r = e[at].read()
|
|
r !== null &&
|
|
((e[ot] = null), (e[We] = null), (e[st] = null), t(Ve(r, !1)))
|
|
}
|
|
}
|
|
function Id(e) {
|
|
process.nextTick(Td, e)
|
|
}
|
|
function Od(e, t) {
|
|
return function (r, i) {
|
|
e.then(function () {
|
|
if (t[$r]) {
|
|
r(Ve(void 0, !0))
|
|
return
|
|
}
|
|
t[vn](r, i)
|
|
}, i)
|
|
}
|
|
}
|
|
var kd = Object.getPrototypeOf(function () {}),
|
|
Rd = Object.setPrototypeOf(
|
|
((Hr = {
|
|
get stream() {
|
|
return this[at]
|
|
},
|
|
next: function () {
|
|
var t = this,
|
|
r = this[Vt]
|
|
if (r !== null) return Promise.reject(r)
|
|
if (this[$r]) return Promise.resolve(Ve(void 0, !0))
|
|
if (this[at].destroyed)
|
|
return new Promise(function (o, f) {
|
|
process.nextTick(function () {
|
|
t[Vt] ? f(t[Vt]) : o(Ve(void 0, !0))
|
|
})
|
|
})
|
|
var i = this[ot],
|
|
n
|
|
if (i) n = new Promise(Od(i, this))
|
|
else {
|
|
var s = this[at].read()
|
|
if (s !== null) return Promise.resolve(Ve(s, !1))
|
|
n = new Promise(this[vn])
|
|
}
|
|
return (this[ot] = n), n
|
|
},
|
|
}),
|
|
Fe(Hr, Symbol.asyncIterator, function () {
|
|
return this
|
|
}),
|
|
Fe(Hr, 'return', function () {
|
|
var t = this
|
|
return new Promise(function (r, i) {
|
|
t[at].destroy(null, function (n) {
|
|
if (n) {
|
|
i(n)
|
|
return
|
|
}
|
|
r(Ve(void 0, !0))
|
|
})
|
|
})
|
|
}),
|
|
Hr),
|
|
kd,
|
|
),
|
|
Pd = function (t) {
|
|
var r,
|
|
i = Object.create(
|
|
Rd,
|
|
((r = {}),
|
|
Fe(r, at, { value: t, writable: !0 }),
|
|
Fe(r, We, { value: null, writable: !0 }),
|
|
Fe(r, st, { value: null, writable: !0 }),
|
|
Fe(r, Vt, { value: null, writable: !0 }),
|
|
Fe(r, $r, { value: t._readableState.endEmitted, writable: !0 }),
|
|
Fe(r, vn, {
|
|
value: function (s, o) {
|
|
var f = i[at].read()
|
|
f
|
|
? ((i[ot] = null), (i[We] = null), (i[st] = null), s(Ve(f, !1)))
|
|
: ((i[We] = s), (i[st] = o))
|
|
},
|
|
writable: !0,
|
|
}),
|
|
r),
|
|
)
|
|
return (
|
|
(i[ot] = null),
|
|
Cd(t, function (n) {
|
|
if (n && n.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
|
|
var s = i[st]
|
|
s !== null &&
|
|
((i[ot] = null), (i[We] = null), (i[st] = null), s(n)),
|
|
(i[Vt] = n)
|
|
return
|
|
}
|
|
var o = i[We]
|
|
o !== null &&
|
|
((i[ot] = null), (i[We] = null), (i[st] = null), o(Ve(void 0, !0))),
|
|
(i[$r] = !0)
|
|
}),
|
|
t.on('readable', Id.bind(null, i)),
|
|
i
|
|
)
|
|
}
|
|
ra.exports = Pd
|
|
})
|
|
var aa = b(($m, oa) => {
|
|
'use strict'
|
|
function na(e, t, r, i, n, s, o) {
|
|
try {
|
|
var f = e[s](o),
|
|
a = f.value
|
|
} catch (l) {
|
|
r(l)
|
|
return
|
|
}
|
|
f.done ? t(a) : Promise.resolve(a).then(i, n)
|
|
}
|
|
function Bd(e) {
|
|
return function () {
|
|
var t = this,
|
|
r = arguments
|
|
return new Promise(function (i, n) {
|
|
var s = e.apply(t, r)
|
|
function o(a) {
|
|
na(s, i, n, o, f, 'next', a)
|
|
}
|
|
function f(a) {
|
|
na(s, i, n, o, f, 'throw', a)
|
|
}
|
|
o(void 0)
|
|
})
|
|
}
|
|
}
|
|
function sa(e, t) {
|
|
var r = Object.keys(e)
|
|
if (Object.getOwnPropertySymbols) {
|
|
var i = Object.getOwnPropertySymbols(e)
|
|
t &&
|
|
(i = i.filter(function (n) {
|
|
return Object.getOwnPropertyDescriptor(e, n).enumerable
|
|
})),
|
|
r.push.apply(r, i)
|
|
}
|
|
return r
|
|
}
|
|
function Ad(e) {
|
|
for (var t = 1; t < arguments.length; t++) {
|
|
var r = arguments[t] != null ? arguments[t] : {}
|
|
t % 2
|
|
? sa(Object(r), !0).forEach(function (i) {
|
|
Nd(e, i, r[i])
|
|
})
|
|
: Object.getOwnPropertyDescriptors
|
|
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r))
|
|
: sa(Object(r)).forEach(function (i) {
|
|
Object.defineProperty(e, i, Object.getOwnPropertyDescriptor(r, i))
|
|
})
|
|
}
|
|
return e
|
|
}
|
|
function Nd(e, t, r) {
|
|
return (
|
|
(t = Md(t)),
|
|
t in e
|
|
? Object.defineProperty(e, t, {
|
|
value: r,
|
|
enumerable: !0,
|
|
configurable: !0,
|
|
writable: !0,
|
|
})
|
|
: (e[t] = r),
|
|
e
|
|
)
|
|
}
|
|
function Md(e) {
|
|
var t = Ld(e, 'string')
|
|
return typeof t == 'symbol' ? t : String(t)
|
|
}
|
|
function Ld(e, t) {
|
|
if (typeof e != 'object' || e === null) return e
|
|
var r = e[Symbol.toPrimitive]
|
|
if (r !== void 0) {
|
|
var i = r.call(e, t || 'default')
|
|
if (typeof i != 'object') return i
|
|
throw new TypeError('@@toPrimitive must return a primitive value.')
|
|
}
|
|
return (t === 'string' ? String : Number)(e)
|
|
}
|
|
var qd = Ue().codes.ERR_INVALID_ARG_TYPE
|
|
function Dd(e, t, r) {
|
|
var i
|
|
if (t && typeof t.next == 'function') i = t
|
|
else if (t && t[Symbol.asyncIterator]) i = t[Symbol.asyncIterator]()
|
|
else if (t && t[Symbol.iterator]) i = t[Symbol.iterator]()
|
|
else throw new qd('iterable', ['Iterable'], t)
|
|
var n = new e(Ad({ objectMode: !0 }, r)),
|
|
s = !1
|
|
n._read = function () {
|
|
s || ((s = !0), o())
|
|
}
|
|
function o() {
|
|
return f.apply(this, arguments)
|
|
}
|
|
function f() {
|
|
return (
|
|
(f = Bd(function* () {
|
|
try {
|
|
var a = yield i.next(),
|
|
l = a.value,
|
|
u = a.done
|
|
u ? n.push(null) : n.push(yield l) ? o() : (s = !1)
|
|
} catch (h) {
|
|
n.destroy(h)
|
|
}
|
|
})),
|
|
f.apply(this, arguments)
|
|
)
|
|
}
|
|
return n
|
|
}
|
|
oa.exports = Dd
|
|
})
|
|
var pn = b((zm, ba) => {
|
|
'use strict'
|
|
ba.exports = A
|
|
var Et
|
|
A.ReadableState = ca
|
|
var Gm = require('events').EventEmitter,
|
|
ua = function (t, r) {
|
|
return t.listeners(r).length
|
|
},
|
|
$t = Zi(),
|
|
Gr = require('buffer').Buffer,
|
|
Ud =
|
|
(typeof global < 'u'
|
|
? global
|
|
: typeof window < 'u'
|
|
? window
|
|
: typeof self < 'u'
|
|
? self
|
|
: {}
|
|
).Uint8Array || function () {}
|
|
function jd(e) {
|
|
return Gr.from(e)
|
|
}
|
|
function Fd(e) {
|
|
return Gr.isBuffer(e) || e instanceof Ud
|
|
}
|
|
var mn = require('util'),
|
|
P
|
|
mn && mn.debuglog ? (P = mn.debuglog('stream')) : (P = function () {})
|
|
var Wd = Po(),
|
|
In = rn(),
|
|
Vd = nn(),
|
|
Hd = Vd.getHighWaterMark,
|
|
zr = Ue().codes,
|
|
$d = zr.ERR_INVALID_ARG_TYPE,
|
|
Gd = zr.ERR_STREAM_PUSH_AFTER_EOF,
|
|
zd = zr.ERR_METHOD_NOT_IMPLEMENTED,
|
|
Kd = zr.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,
|
|
xt,
|
|
wn,
|
|
Sn
|
|
ie()(A, $t)
|
|
var Ht = In.errorOrDestroy,
|
|
En = ['error', 'close', 'destroy', 'pause', 'resume']
|
|
function Yd(e, t, r) {
|
|
if (typeof e.prependListener == 'function') return e.prependListener(t, r)
|
|
!e._events || !e._events[t]
|
|
? e.on(t, r)
|
|
: Array.isArray(e._events[t])
|
|
? e._events[t].unshift(r)
|
|
: (e._events[t] = [r, e._events[t]])
|
|
}
|
|
function ca(e, t, r) {
|
|
;(Et = Et || it()),
|
|
(e = e || {}),
|
|
typeof r != 'boolean' && (r = t instanceof Et),
|
|
(this.objectMode = !!e.objectMode),
|
|
r && (this.objectMode = this.objectMode || !!e.readableObjectMode),
|
|
(this.highWaterMark = Hd(this, e, 'readableHighWaterMark', r)),
|
|
(this.buffer = new Wd()),
|
|
(this.length = 0),
|
|
(this.pipes = null),
|
|
(this.pipesCount = 0),
|
|
(this.flowing = null),
|
|
(this.ended = !1),
|
|
(this.endEmitted = !1),
|
|
(this.reading = !1),
|
|
(this.sync = !0),
|
|
(this.needReadable = !1),
|
|
(this.emittedReadable = !1),
|
|
(this.readableListening = !1),
|
|
(this.resumeScheduled = !1),
|
|
(this.paused = !0),
|
|
(this.emitClose = e.emitClose !== !1),
|
|
(this.autoDestroy = !!e.autoDestroy),
|
|
(this.destroyed = !1),
|
|
(this.defaultEncoding = e.defaultEncoding || 'utf8'),
|
|
(this.awaitDrain = 0),
|
|
(this.readingMore = !1),
|
|
(this.decoder = null),
|
|
(this.encoding = null),
|
|
e.encoding &&
|
|
(xt || (xt = yn().StringDecoder),
|
|
(this.decoder = new xt(e.encoding)),
|
|
(this.encoding = e.encoding))
|
|
}
|
|
function A(e) {
|
|
if (((Et = Et || it()), !(this instanceof A))) return new A(e)
|
|
var t = this instanceof Et
|
|
;(this._readableState = new ca(e, this, t)),
|
|
(this.readable = !0),
|
|
e &&
|
|
(typeof e.read == 'function' && (this._read = e.read),
|
|
typeof e.destroy == 'function' && (this._destroy = e.destroy)),
|
|
$t.call(this)
|
|
}
|
|
Object.defineProperty(A.prototype, 'destroyed', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._readableState === void 0 ? !1 : this._readableState.destroyed
|
|
},
|
|
set: function (t) {
|
|
this._readableState && (this._readableState.destroyed = t)
|
|
},
|
|
})
|
|
A.prototype.destroy = In.destroy
|
|
A.prototype._undestroy = In.undestroy
|
|
A.prototype._destroy = function (e, t) {
|
|
t(e)
|
|
}
|
|
A.prototype.push = function (e, t) {
|
|
var r = this._readableState,
|
|
i
|
|
return (
|
|
r.objectMode
|
|
? (i = !0)
|
|
: typeof e == 'string' &&
|
|
((t = t || r.defaultEncoding),
|
|
t !== r.encoding && ((e = Gr.from(e, t)), (t = '')),
|
|
(i = !0)),
|
|
ha(this, e, t, !1, i)
|
|
)
|
|
}
|
|
A.prototype.unshift = function (e) {
|
|
return ha(this, e, null, !0, !1)
|
|
}
|
|
function ha(e, t, r, i, n) {
|
|
P('readableAddChunk', t)
|
|
var s = e._readableState
|
|
if (t === null) (s.reading = !1), Xd(e, s)
|
|
else {
|
|
var o
|
|
if ((n || (o = Qd(s, t)), o)) Ht(e, o)
|
|
else if (s.objectMode || (t && t.length > 0))
|
|
if (
|
|
(typeof t != 'string' &&
|
|
!s.objectMode &&
|
|
Object.getPrototypeOf(t) !== Gr.prototype &&
|
|
(t = jd(t)),
|
|
i)
|
|
)
|
|
s.endEmitted ? Ht(e, new Kd()) : xn(e, s, t, !0)
|
|
else if (s.ended) Ht(e, new Gd())
|
|
else {
|
|
if (s.destroyed) return !1
|
|
;(s.reading = !1),
|
|
s.decoder && !r
|
|
? ((t = s.decoder.write(t)),
|
|
s.objectMode || t.length !== 0 ? xn(e, s, t, !1) : Tn(e, s))
|
|
: xn(e, s, t, !1)
|
|
}
|
|
else i || ((s.reading = !1), Tn(e, s))
|
|
}
|
|
return !s.ended && (s.length < s.highWaterMark || s.length === 0)
|
|
}
|
|
function xn(e, t, r, i) {
|
|
t.flowing && t.length === 0 && !t.sync
|
|
? ((t.awaitDrain = 0), e.emit('data', r))
|
|
: ((t.length += t.objectMode ? 1 : r.length),
|
|
i ? t.buffer.unshift(r) : t.buffer.push(r),
|
|
t.needReadable && Kr(e)),
|
|
Tn(e, t)
|
|
}
|
|
function Qd(e, t) {
|
|
var r
|
|
return (
|
|
!Fd(t) &&
|
|
typeof t != 'string' &&
|
|
t !== void 0 &&
|
|
!e.objectMode &&
|
|
(r = new $d('chunk', ['string', 'Buffer', 'Uint8Array'], t)),
|
|
r
|
|
)
|
|
}
|
|
A.prototype.isPaused = function () {
|
|
return this._readableState.flowing === !1
|
|
}
|
|
A.prototype.setEncoding = function (e) {
|
|
xt || (xt = yn().StringDecoder)
|
|
var t = new xt(e)
|
|
;(this._readableState.decoder = t),
|
|
(this._readableState.encoding = this._readableState.decoder.encoding)
|
|
for (var r = this._readableState.buffer.head, i = ''; r !== null; )
|
|
(i += t.write(r.data)), (r = r.next)
|
|
return (
|
|
this._readableState.buffer.clear(),
|
|
i !== '' && this._readableState.buffer.push(i),
|
|
(this._readableState.length = i.length),
|
|
this
|
|
)
|
|
}
|
|
var fa = 1073741824
|
|
function Jd(e) {
|
|
return (
|
|
e >= fa
|
|
? (e = fa)
|
|
: (e--,
|
|
(e |= e >>> 1),
|
|
(e |= e >>> 2),
|
|
(e |= e >>> 4),
|
|
(e |= e >>> 8),
|
|
(e |= e >>> 16),
|
|
e++),
|
|
e
|
|
)
|
|
}
|
|
function la(e, t) {
|
|
return e <= 0 || (t.length === 0 && t.ended)
|
|
? 0
|
|
: t.objectMode
|
|
? 1
|
|
: e !== e
|
|
? t.flowing && t.length
|
|
? t.buffer.head.data.length
|
|
: t.length
|
|
: (e > t.highWaterMark && (t.highWaterMark = Jd(e)),
|
|
e <= t.length ? e : t.ended ? t.length : ((t.needReadable = !0), 0))
|
|
}
|
|
A.prototype.read = function (e) {
|
|
P('read', e), (e = parseInt(e, 10))
|
|
var t = this._readableState,
|
|
r = e
|
|
if (
|
|
(e !== 0 && (t.emittedReadable = !1),
|
|
e === 0 &&
|
|
t.needReadable &&
|
|
((t.highWaterMark !== 0 ? t.length >= t.highWaterMark : t.length > 0) ||
|
|
t.ended))
|
|
)
|
|
return (
|
|
P('read: emitReadable', t.length, t.ended),
|
|
t.length === 0 && t.ended ? Cn(this) : Kr(this),
|
|
null
|
|
)
|
|
if (((e = la(e, t)), e === 0 && t.ended))
|
|
return t.length === 0 && Cn(this), null
|
|
var i = t.needReadable
|
|
P('need readable', i),
|
|
(t.length === 0 || t.length - e < t.highWaterMark) &&
|
|
((i = !0), P('length less than watermark', i)),
|
|
t.ended || t.reading
|
|
? ((i = !1), P('reading or ended', i))
|
|
: i &&
|
|
(P('do read'),
|
|
(t.reading = !0),
|
|
(t.sync = !0),
|
|
t.length === 0 && (t.needReadable = !0),
|
|
this._read(t.highWaterMark),
|
|
(t.sync = !1),
|
|
t.reading || (e = la(r, t)))
|
|
var n
|
|
return (
|
|
e > 0 ? (n = _a(e, t)) : (n = null),
|
|
n === null
|
|
? ((t.needReadable = t.length <= t.highWaterMark), (e = 0))
|
|
: ((t.length -= e), (t.awaitDrain = 0)),
|
|
t.length === 0 &&
|
|
(t.ended || (t.needReadable = !0), r !== e && t.ended && Cn(this)),
|
|
n !== null && this.emit('data', n),
|
|
n
|
|
)
|
|
}
|
|
function Xd(e, t) {
|
|
if ((P('onEofChunk'), !t.ended)) {
|
|
if (t.decoder) {
|
|
var r = t.decoder.end()
|
|
r &&
|
|
r.length &&
|
|
(t.buffer.push(r), (t.length += t.objectMode ? 1 : r.length))
|
|
}
|
|
;(t.ended = !0),
|
|
t.sync
|
|
? Kr(e)
|
|
: ((t.needReadable = !1),
|
|
t.emittedReadable || ((t.emittedReadable = !0), da(e)))
|
|
}
|
|
}
|
|
function Kr(e) {
|
|
var t = e._readableState
|
|
P('emitReadable', t.needReadable, t.emittedReadable),
|
|
(t.needReadable = !1),
|
|
t.emittedReadable ||
|
|
(P('emitReadable', t.flowing),
|
|
(t.emittedReadable = !0),
|
|
process.nextTick(da, e))
|
|
}
|
|
function da(e) {
|
|
var t = e._readableState
|
|
P('emitReadable_', t.destroyed, t.length, t.ended),
|
|
!t.destroyed &&
|
|
(t.length || t.ended) &&
|
|
(e.emit('readable'), (t.emittedReadable = !1)),
|
|
(t.needReadable = !t.flowing && !t.ended && t.length <= t.highWaterMark),
|
|
On(e)
|
|
}
|
|
function Tn(e, t) {
|
|
t.readingMore || ((t.readingMore = !0), process.nextTick(Zd, e, t))
|
|
}
|
|
function Zd(e, t) {
|
|
for (
|
|
;
|
|
!t.reading &&
|
|
!t.ended &&
|
|
(t.length < t.highWaterMark || (t.flowing && t.length === 0));
|
|
|
|
) {
|
|
var r = t.length
|
|
if ((P('maybeReadMore read 0'), e.read(0), r === t.length)) break
|
|
}
|
|
t.readingMore = !1
|
|
}
|
|
A.prototype._read = function (e) {
|
|
Ht(this, new zd('_read()'))
|
|
}
|
|
A.prototype.pipe = function (e, t) {
|
|
var r = this,
|
|
i = this._readableState
|
|
switch (i.pipesCount) {
|
|
case 0:
|
|
i.pipes = e
|
|
break
|
|
case 1:
|
|
i.pipes = [i.pipes, e]
|
|
break
|
|
default:
|
|
i.pipes.push(e)
|
|
break
|
|
}
|
|
;(i.pipesCount += 1), P('pipe count=%d opts=%j', i.pipesCount, t)
|
|
var n =
|
|
(!t || t.end !== !1) && e !== process.stdout && e !== process.stderr,
|
|
s = n ? f : v
|
|
i.endEmitted ? process.nextTick(s) : r.once('end', s), e.on('unpipe', o)
|
|
function o(m, p) {
|
|
P('onunpipe'),
|
|
m === r && p && p.hasUnpiped === !1 && ((p.hasUnpiped = !0), u())
|
|
}
|
|
function f() {
|
|
P('onend'), e.end()
|
|
}
|
|
var a = ep(r)
|
|
e.on('drain', a)
|
|
var l = !1
|
|
function u() {
|
|
P('cleanup'),
|
|
e.removeListener('close', d),
|
|
e.removeListener('finish', _),
|
|
e.removeListener('drain', a),
|
|
e.removeListener('error', c),
|
|
e.removeListener('unpipe', o),
|
|
r.removeListener('end', f),
|
|
r.removeListener('end', v),
|
|
r.removeListener('data', h),
|
|
(l = !0),
|
|
i.awaitDrain && (!e._writableState || e._writableState.needDrain) && a()
|
|
}
|
|
r.on('data', h)
|
|
function h(m) {
|
|
P('ondata')
|
|
var p = e.write(m)
|
|
P('dest.write', p),
|
|
p === !1 &&
|
|
(((i.pipesCount === 1 && i.pipes === e) ||
|
|
(i.pipesCount > 1 && ga(i.pipes, e) !== -1)) &&
|
|
!l &&
|
|
(P('false write response, pause', i.awaitDrain), i.awaitDrain++),
|
|
r.pause())
|
|
}
|
|
function c(m) {
|
|
P('onerror', m),
|
|
v(),
|
|
e.removeListener('error', c),
|
|
ua(e, 'error') === 0 && Ht(e, m)
|
|
}
|
|
Yd(e, 'error', c)
|
|
function d() {
|
|
e.removeListener('finish', _), v()
|
|
}
|
|
e.once('close', d)
|
|
function _() {
|
|
P('onfinish'), e.removeListener('close', d), v()
|
|
}
|
|
e.once('finish', _)
|
|
function v() {
|
|
P('unpipe'), r.unpipe(e)
|
|
}
|
|
return e.emit('pipe', r), i.flowing || (P('pipe resume'), r.resume()), e
|
|
}
|
|
function ep(e) {
|
|
return function () {
|
|
var r = e._readableState
|
|
P('pipeOnDrain', r.awaitDrain),
|
|
r.awaitDrain && r.awaitDrain--,
|
|
r.awaitDrain === 0 && ua(e, 'data') && ((r.flowing = !0), On(e))
|
|
}
|
|
}
|
|
A.prototype.unpipe = function (e) {
|
|
var t = this._readableState,
|
|
r = { hasUnpiped: !1 }
|
|
if (t.pipesCount === 0) return this
|
|
if (t.pipesCount === 1)
|
|
return e && e !== t.pipes
|
|
? this
|
|
: (e || (e = t.pipes),
|
|
(t.pipes = null),
|
|
(t.pipesCount = 0),
|
|
(t.flowing = !1),
|
|
e && e.emit('unpipe', this, r),
|
|
this)
|
|
if (!e) {
|
|
var i = t.pipes,
|
|
n = t.pipesCount
|
|
;(t.pipes = null), (t.pipesCount = 0), (t.flowing = !1)
|
|
for (var s = 0; s < n; s++) i[s].emit('unpipe', this, { hasUnpiped: !1 })
|
|
return this
|
|
}
|
|
var o = ga(t.pipes, e)
|
|
return o === -1
|
|
? this
|
|
: (t.pipes.splice(o, 1),
|
|
(t.pipesCount -= 1),
|
|
t.pipesCount === 1 && (t.pipes = t.pipes[0]),
|
|
e.emit('unpipe', this, r),
|
|
this)
|
|
}
|
|
A.prototype.on = function (e, t) {
|
|
var r = $t.prototype.on.call(this, e, t),
|
|
i = this._readableState
|
|
return (
|
|
e === 'data'
|
|
? ((i.readableListening = this.listenerCount('readable') > 0),
|
|
i.flowing !== !1 && this.resume())
|
|
: e === 'readable' &&
|
|
!i.endEmitted &&
|
|
!i.readableListening &&
|
|
((i.readableListening = i.needReadable = !0),
|
|
(i.flowing = !1),
|
|
(i.emittedReadable = !1),
|
|
P('on readable', i.length, i.reading),
|
|
i.length ? Kr(this) : i.reading || process.nextTick(tp, this)),
|
|
r
|
|
)
|
|
}
|
|
A.prototype.addListener = A.prototype.on
|
|
A.prototype.removeListener = function (e, t) {
|
|
var r = $t.prototype.removeListener.call(this, e, t)
|
|
return e === 'readable' && process.nextTick(pa, this), r
|
|
}
|
|
A.prototype.removeAllListeners = function (e) {
|
|
var t = $t.prototype.removeAllListeners.apply(this, arguments)
|
|
return (e === 'readable' || e === void 0) && process.nextTick(pa, this), t
|
|
}
|
|
function pa(e) {
|
|
var t = e._readableState
|
|
;(t.readableListening = e.listenerCount('readable') > 0),
|
|
t.resumeScheduled && !t.paused
|
|
? (t.flowing = !0)
|
|
: e.listenerCount('data') > 0 && e.resume()
|
|
}
|
|
function tp(e) {
|
|
P('readable nexttick read 0'), e.read(0)
|
|
}
|
|
A.prototype.resume = function () {
|
|
var e = this._readableState
|
|
return (
|
|
e.flowing ||
|
|
(P('resume'), (e.flowing = !e.readableListening), rp(this, e)),
|
|
(e.paused = !1),
|
|
this
|
|
)
|
|
}
|
|
function rp(e, t) {
|
|
t.resumeScheduled || ((t.resumeScheduled = !0), process.nextTick(ip, e, t))
|
|
}
|
|
function ip(e, t) {
|
|
P('resume', t.reading),
|
|
t.reading || e.read(0),
|
|
(t.resumeScheduled = !1),
|
|
e.emit('resume'),
|
|
On(e),
|
|
t.flowing && !t.reading && e.read(0)
|
|
}
|
|
A.prototype.pause = function () {
|
|
return (
|
|
P('call pause flowing=%j', this._readableState.flowing),
|
|
this._readableState.flowing !== !1 &&
|
|
(P('pause'), (this._readableState.flowing = !1), this.emit('pause')),
|
|
(this._readableState.paused = !0),
|
|
this
|
|
)
|
|
}
|
|
function On(e) {
|
|
var t = e._readableState
|
|
for (P('flow', t.flowing); t.flowing && e.read() !== null; );
|
|
}
|
|
A.prototype.wrap = function (e) {
|
|
var t = this,
|
|
r = this._readableState,
|
|
i = !1
|
|
e.on('end', function () {
|
|
if ((P('wrapped end'), r.decoder && !r.ended)) {
|
|
var o = r.decoder.end()
|
|
o && o.length && t.push(o)
|
|
}
|
|
t.push(null)
|
|
}),
|
|
e.on('data', function (o) {
|
|
if (
|
|
(P('wrapped data'),
|
|
r.decoder && (o = r.decoder.write(o)),
|
|
!(r.objectMode && o == null) && !(!r.objectMode && (!o || !o.length)))
|
|
) {
|
|
var f = t.push(o)
|
|
f || ((i = !0), e.pause())
|
|
}
|
|
})
|
|
for (var n in e)
|
|
this[n] === void 0 &&
|
|
typeof e[n] == 'function' &&
|
|
(this[n] = (function (f) {
|
|
return function () {
|
|
return e[f].apply(e, arguments)
|
|
}
|
|
})(n))
|
|
for (var s = 0; s < En.length; s++) e.on(En[s], this.emit.bind(this, En[s]))
|
|
return (
|
|
(this._read = function (o) {
|
|
P('wrapped _read', o), i && ((i = !1), e.resume())
|
|
}),
|
|
this
|
|
)
|
|
}
|
|
typeof Symbol == 'function' &&
|
|
(A.prototype[Symbol.asyncIterator] = function () {
|
|
return wn === void 0 && (wn = ia()), wn(this)
|
|
})
|
|
Object.defineProperty(A.prototype, 'readableHighWaterMark', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._readableState.highWaterMark
|
|
},
|
|
})
|
|
Object.defineProperty(A.prototype, 'readableBuffer', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._readableState && this._readableState.buffer
|
|
},
|
|
})
|
|
Object.defineProperty(A.prototype, 'readableFlowing', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._readableState.flowing
|
|
},
|
|
set: function (t) {
|
|
this._readableState && (this._readableState.flowing = t)
|
|
},
|
|
})
|
|
A._fromList = _a
|
|
Object.defineProperty(A.prototype, 'readableLength', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._readableState.length
|
|
},
|
|
})
|
|
function _a(e, t) {
|
|
if (t.length === 0) return null
|
|
var r
|
|
return (
|
|
t.objectMode
|
|
? (r = t.buffer.shift())
|
|
: !e || e >= t.length
|
|
? (t.decoder
|
|
? (r = t.buffer.join(''))
|
|
: t.buffer.length === 1
|
|
? (r = t.buffer.first())
|
|
: (r = t.buffer.concat(t.length)),
|
|
t.buffer.clear())
|
|
: (r = t.buffer.consume(e, t.decoder)),
|
|
r
|
|
)
|
|
}
|
|
function Cn(e) {
|
|
var t = e._readableState
|
|
P('endReadable', t.endEmitted),
|
|
t.endEmitted || ((t.ended = !0), process.nextTick(np, t, e))
|
|
}
|
|
function np(e, t) {
|
|
if (
|
|
(P('endReadableNT', e.endEmitted, e.length),
|
|
!e.endEmitted &&
|
|
e.length === 0 &&
|
|
((e.endEmitted = !0), (t.readable = !1), t.emit('end'), e.autoDestroy))
|
|
) {
|
|
var r = t._writableState
|
|
;(!r || (r.autoDestroy && r.finished)) && t.destroy()
|
|
}
|
|
}
|
|
typeof Symbol == 'function' &&
|
|
(A.from = function (e, t) {
|
|
return Sn === void 0 && (Sn = aa()), Sn(A, e, t)
|
|
})
|
|
function ga(e, t) {
|
|
for (var r = 0, i = e.length; r < i; r++) if (e[r] === t) return r
|
|
return -1
|
|
}
|
|
})
|
|
var kn = b((Km, va) => {
|
|
'use strict'
|
|
va.exports = ke
|
|
var Yr = Ue().codes,
|
|
sp = Yr.ERR_METHOD_NOT_IMPLEMENTED,
|
|
op = Yr.ERR_MULTIPLE_CALLBACK,
|
|
ap = Yr.ERR_TRANSFORM_ALREADY_TRANSFORMING,
|
|
fp = Yr.ERR_TRANSFORM_WITH_LENGTH_0,
|
|
Qr = it()
|
|
ie()(ke, Qr)
|
|
function lp(e, t) {
|
|
var r = this._transformState
|
|
r.transforming = !1
|
|
var i = r.writecb
|
|
if (i === null) return this.emit('error', new op())
|
|
;(r.writechunk = null), (r.writecb = null), t != null && this.push(t), i(e)
|
|
var n = this._readableState
|
|
;(n.reading = !1),
|
|
(n.needReadable || n.length < n.highWaterMark) &&
|
|
this._read(n.highWaterMark)
|
|
}
|
|
function ke(e) {
|
|
if (!(this instanceof ke)) return new ke(e)
|
|
Qr.call(this, e),
|
|
(this._transformState = {
|
|
afterTransform: lp.bind(this),
|
|
needTransform: !1,
|
|
transforming: !1,
|
|
writecb: null,
|
|
writechunk: null,
|
|
writeencoding: null,
|
|
}),
|
|
(this._readableState.needReadable = !0),
|
|
(this._readableState.sync = !1),
|
|
e &&
|
|
(typeof e.transform == 'function' && (this._transform = e.transform),
|
|
typeof e.flush == 'function' && (this._flush = e.flush)),
|
|
this.on('prefinish', up)
|
|
}
|
|
function up() {
|
|
var e = this
|
|
typeof this._flush == 'function' && !this._readableState.destroyed
|
|
? this._flush(function (t, r) {
|
|
ya(e, t, r)
|
|
})
|
|
: ya(this, null, null)
|
|
}
|
|
ke.prototype.push = function (e, t) {
|
|
return (
|
|
(this._transformState.needTransform = !1),
|
|
Qr.prototype.push.call(this, e, t)
|
|
)
|
|
}
|
|
ke.prototype._transform = function (e, t, r) {
|
|
r(new sp('_transform()'))
|
|
}
|
|
ke.prototype._write = function (e, t, r) {
|
|
var i = this._transformState
|
|
if (
|
|
((i.writecb = r),
|
|
(i.writechunk = e),
|
|
(i.writeencoding = t),
|
|
!i.transforming)
|
|
) {
|
|
var n = this._readableState
|
|
;(i.needTransform || n.needReadable || n.length < n.highWaterMark) &&
|
|
this._read(n.highWaterMark)
|
|
}
|
|
}
|
|
ke.prototype._read = function (e) {
|
|
var t = this._transformState
|
|
t.writechunk !== null && !t.transforming
|
|
? ((t.transforming = !0),
|
|
this._transform(t.writechunk, t.writeencoding, t.afterTransform))
|
|
: (t.needTransform = !0)
|
|
}
|
|
ke.prototype._destroy = function (e, t) {
|
|
Qr.prototype._destroy.call(this, e, function (r) {
|
|
t(r)
|
|
})
|
|
}
|
|
function ya(e, t, r) {
|
|
if (t) return e.emit('error', t)
|
|
if ((r != null && e.push(r), e._writableState.length)) throw new fp()
|
|
if (e._transformState.transforming) throw new ap()
|
|
return e.push(null)
|
|
}
|
|
})
|
|
var Sa = b((Ym, wa) => {
|
|
'use strict'
|
|
wa.exports = Gt
|
|
var ma = kn()
|
|
ie()(Gt, ma)
|
|
function Gt(e) {
|
|
if (!(this instanceof Gt)) return new Gt(e)
|
|
ma.call(this, e)
|
|
}
|
|
Gt.prototype._transform = function (e, t, r) {
|
|
r(null, e)
|
|
}
|
|
})
|
|
var Ia = b((Qm, Ta) => {
|
|
'use strict'
|
|
var Rn
|
|
function cp(e) {
|
|
var t = !1
|
|
return function () {
|
|
t || ((t = !0), e.apply(void 0, arguments))
|
|
}
|
|
}
|
|
var Ca = Ue().codes,
|
|
hp = Ca.ERR_MISSING_ARGS,
|
|
dp = Ca.ERR_STREAM_DESTROYED
|
|
function Ea(e) {
|
|
if (e) throw e
|
|
}
|
|
function pp(e) {
|
|
return e.setHeader && typeof e.abort == 'function'
|
|
}
|
|
function _p(e, t, r, i) {
|
|
i = cp(i)
|
|
var n = !1
|
|
e.on('close', function () {
|
|
n = !0
|
|
}),
|
|
Rn === void 0 && (Rn = Vr()),
|
|
Rn(e, { readable: t, writable: r }, function (o) {
|
|
if (o) return i(o)
|
|
;(n = !0), i()
|
|
})
|
|
var s = !1
|
|
return function (o) {
|
|
if (!n && !s) {
|
|
if (((s = !0), pp(e))) return e.abort()
|
|
if (typeof e.destroy == 'function') return e.destroy()
|
|
i(o || new dp('pipe'))
|
|
}
|
|
}
|
|
}
|
|
function xa(e) {
|
|
e()
|
|
}
|
|
function gp(e, t) {
|
|
return e.pipe(t)
|
|
}
|
|
function bp(e) {
|
|
return !e.length || typeof e[e.length - 1] != 'function' ? Ea : e.pop()
|
|
}
|
|
function yp() {
|
|
for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
|
|
t[r] = arguments[r]
|
|
var i = bp(t)
|
|
if ((Array.isArray(t[0]) && (t = t[0]), t.length < 2))
|
|
throw new hp('streams')
|
|
var n,
|
|
s = t.map(function (o, f) {
|
|
var a = f < t.length - 1,
|
|
l = f > 0
|
|
return _p(o, a, l, function (u) {
|
|
n || (n = u), u && s.forEach(xa), !a && (s.forEach(xa), i(n))
|
|
})
|
|
})
|
|
return t.reduce(gp)
|
|
}
|
|
Ta.exports = yp
|
|
})
|
|
var He = b((de, Kt) => {
|
|
var zt = require('stream')
|
|
process.env.READABLE_STREAM === 'disable' && zt
|
|
? ((Kt.exports = zt.Readable),
|
|
Object.assign(Kt.exports, zt),
|
|
(Kt.exports.Stream = zt))
|
|
: ((de = Kt.exports = pn()),
|
|
(de.Stream = zt || de),
|
|
(de.Readable = de),
|
|
(de.Writable = cn()),
|
|
(de.Duplex = it()),
|
|
(de.Transform = kn()),
|
|
(de.PassThrough = Sa()),
|
|
(de.finished = Vr()),
|
|
(de.pipeline = Ia()))
|
|
})
|
|
var Jr = b((Jm, Oa) => {
|
|
'use strict'
|
|
var vp = Mr(),
|
|
mp = He().Readable,
|
|
wp = { objectMode: !0 },
|
|
Sp = { clean: !0 }
|
|
function $e(e) {
|
|
if (!(this instanceof $e)) return new $e(e)
|
|
;(this.options = e || {}),
|
|
(this.options = vp(Sp, e)),
|
|
(this._inflights = new Map())
|
|
}
|
|
$e.prototype.put = function (e, t) {
|
|
return this._inflights.set(e.messageId, e), t && t(), this
|
|
}
|
|
$e.prototype.createStream = function () {
|
|
var e = new mp(wp),
|
|
t = !1,
|
|
r = [],
|
|
i = 0
|
|
return (
|
|
this._inflights.forEach(function (n, s) {
|
|
r.push(n)
|
|
}),
|
|
(e._read = function () {
|
|
!t && i < r.length ? this.push(r[i++]) : this.push(null)
|
|
}),
|
|
(e.destroy = function () {
|
|
if (!t) {
|
|
var n = this
|
|
;(t = !0),
|
|
setTimeout(function () {
|
|
n.emit('close')
|
|
}, 0)
|
|
}
|
|
}),
|
|
e
|
|
)
|
|
}
|
|
$e.prototype.del = function (e, t) {
|
|
return (
|
|
(e = this._inflights.get(e.messageId)),
|
|
e
|
|
? (this._inflights.delete(e.messageId), t(null, e))
|
|
: t && t(new Error('missing packet')),
|
|
this
|
|
)
|
|
}
|
|
$e.prototype.get = function (e, t) {
|
|
return (
|
|
(e = this._inflights.get(e.messageId)),
|
|
e ? t(null, e) : t && t(new Error('missing packet')),
|
|
this
|
|
)
|
|
}
|
|
$e.prototype.close = function (e) {
|
|
this.options.clean && (this._inflights = null), e && e()
|
|
}
|
|
Oa.exports = $e
|
|
})
|
|
var Pa = b((Xm, Ra) => {
|
|
'use strict'
|
|
var { Buffer: me } = require('buffer'),
|
|
ka = Symbol.for('BufferList')
|
|
function W(e) {
|
|
if (!(this instanceof W)) return new W(e)
|
|
W._init.call(this, e)
|
|
}
|
|
W._init = function (t) {
|
|
Object.defineProperty(this, ka, { value: !0 }),
|
|
(this._bufs = []),
|
|
(this.length = 0),
|
|
t && this.append(t)
|
|
}
|
|
W.prototype._new = function (t) {
|
|
return new W(t)
|
|
}
|
|
W.prototype._offset = function (t) {
|
|
if (t === 0) return [0, 0]
|
|
let r = 0
|
|
for (let i = 0; i < this._bufs.length; i++) {
|
|
let n = r + this._bufs[i].length
|
|
if (t < n || i === this._bufs.length - 1) return [i, t - r]
|
|
r = n
|
|
}
|
|
}
|
|
W.prototype._reverseOffset = function (e) {
|
|
let t = e[0],
|
|
r = e[1]
|
|
for (let i = 0; i < t; i++) r += this._bufs[i].length
|
|
return r
|
|
}
|
|
W.prototype.get = function (t) {
|
|
if (t > this.length || t < 0) return
|
|
let r = this._offset(t)
|
|
return this._bufs[r[0]][r[1]]
|
|
}
|
|
W.prototype.slice = function (t, r) {
|
|
return (
|
|
typeof t == 'number' && t < 0 && (t += this.length),
|
|
typeof r == 'number' && r < 0 && (r += this.length),
|
|
this.copy(null, 0, t, r)
|
|
)
|
|
}
|
|
W.prototype.copy = function (t, r, i, n) {
|
|
if (
|
|
((typeof i != 'number' || i < 0) && (i = 0),
|
|
(typeof n != 'number' || n > this.length) && (n = this.length),
|
|
i >= this.length || n <= 0)
|
|
)
|
|
return t || me.alloc(0)
|
|
let s = !!t,
|
|
o = this._offset(i),
|
|
f = n - i,
|
|
a = f,
|
|
l = (s && r) || 0,
|
|
u = o[1]
|
|
if (i === 0 && n === this.length) {
|
|
if (!s)
|
|
return this._bufs.length === 1
|
|
? this._bufs[0]
|
|
: me.concat(this._bufs, this.length)
|
|
for (let h = 0; h < this._bufs.length; h++)
|
|
this._bufs[h].copy(t, l), (l += this._bufs[h].length)
|
|
return t
|
|
}
|
|
if (a <= this._bufs[o[0]].length - u)
|
|
return s
|
|
? this._bufs[o[0]].copy(t, r, u, u + a)
|
|
: this._bufs[o[0]].slice(u, u + a)
|
|
s || (t = me.allocUnsafe(f))
|
|
for (let h = o[0]; h < this._bufs.length; h++) {
|
|
let c = this._bufs[h].length - u
|
|
if (a > c) this._bufs[h].copy(t, l, u), (l += c)
|
|
else {
|
|
this._bufs[h].copy(t, l, u, u + a), (l += c)
|
|
break
|
|
}
|
|
;(a -= c), u && (u = 0)
|
|
}
|
|
return t.length > l ? t.slice(0, l) : t
|
|
}
|
|
W.prototype.shallowSlice = function (t, r) {
|
|
if (
|
|
((t = t || 0),
|
|
(r = typeof r != 'number' ? this.length : r),
|
|
t < 0 && (t += this.length),
|
|
r < 0 && (r += this.length),
|
|
t === r)
|
|
)
|
|
return this._new()
|
|
let i = this._offset(t),
|
|
n = this._offset(r),
|
|
s = this._bufs.slice(i[0], n[0] + 1)
|
|
return (
|
|
n[1] === 0 ? s.pop() : (s[s.length - 1] = s[s.length - 1].slice(0, n[1])),
|
|
i[1] !== 0 && (s[0] = s[0].slice(i[1])),
|
|
this._new(s)
|
|
)
|
|
}
|
|
W.prototype.toString = function (t, r, i) {
|
|
return this.slice(r, i).toString(t)
|
|
}
|
|
W.prototype.consume = function (t) {
|
|
if (((t = Math.trunc(t)), Number.isNaN(t) || t <= 0)) return this
|
|
for (; this._bufs.length; )
|
|
if (t >= this._bufs[0].length)
|
|
(t -= this._bufs[0].length),
|
|
(this.length -= this._bufs[0].length),
|
|
this._bufs.shift()
|
|
else {
|
|
;(this._bufs[0] = this._bufs[0].slice(t)), (this.length -= t)
|
|
break
|
|
}
|
|
return this
|
|
}
|
|
W.prototype.duplicate = function () {
|
|
let t = this._new()
|
|
for (let r = 0; r < this._bufs.length; r++) t.append(this._bufs[r])
|
|
return t
|
|
}
|
|
W.prototype.append = function (t) {
|
|
if (t == null) return this
|
|
if (t.buffer)
|
|
this._appendBuffer(me.from(t.buffer, t.byteOffset, t.byteLength))
|
|
else if (Array.isArray(t))
|
|
for (let r = 0; r < t.length; r++) this.append(t[r])
|
|
else if (this._isBufferList(t))
|
|
for (let r = 0; r < t._bufs.length; r++) this.append(t._bufs[r])
|
|
else
|
|
typeof t == 'number' && (t = t.toString()), this._appendBuffer(me.from(t))
|
|
return this
|
|
}
|
|
W.prototype._appendBuffer = function (t) {
|
|
this._bufs.push(t), (this.length += t.length)
|
|
}
|
|
W.prototype.indexOf = function (e, t, r) {
|
|
if (
|
|
(r === void 0 && typeof t == 'string' && ((r = t), (t = void 0)),
|
|
typeof e == 'function' || Array.isArray(e))
|
|
)
|
|
throw new TypeError(
|
|
'The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.',
|
|
)
|
|
if (
|
|
(typeof e == 'number'
|
|
? (e = me.from([e]))
|
|
: typeof e == 'string'
|
|
? (e = me.from(e, r))
|
|
: this._isBufferList(e)
|
|
? (e = e.slice())
|
|
: Array.isArray(e.buffer)
|
|
? (e = me.from(e.buffer, e.byteOffset, e.byteLength))
|
|
: me.isBuffer(e) || (e = me.from(e)),
|
|
(t = Number(t || 0)),
|
|
isNaN(t) && (t = 0),
|
|
t < 0 && (t = this.length + t),
|
|
t < 0 && (t = 0),
|
|
e.length === 0)
|
|
)
|
|
return t > this.length ? this.length : t
|
|
let i = this._offset(t),
|
|
n = i[0],
|
|
s = i[1]
|
|
for (; n < this._bufs.length; n++) {
|
|
let o = this._bufs[n]
|
|
for (; s < o.length; )
|
|
if (o.length - s >= e.length) {
|
|
let a = o.indexOf(e, s)
|
|
if (a !== -1) return this._reverseOffset([n, a])
|
|
s = o.length - e.length + 1
|
|
} else {
|
|
let a = this._reverseOffset([n, s])
|
|
if (this._match(a, e)) return a
|
|
s++
|
|
}
|
|
s = 0
|
|
}
|
|
return -1
|
|
}
|
|
W.prototype._match = function (e, t) {
|
|
if (this.length - e < t.length) return !1
|
|
for (let r = 0; r < t.length; r++) if (this.get(e + r) !== t[r]) return !1
|
|
return !0
|
|
}
|
|
;(function () {
|
|
let e = {
|
|
readDoubleBE: 8,
|
|
readDoubleLE: 8,
|
|
readFloatBE: 4,
|
|
readFloatLE: 4,
|
|
readInt32BE: 4,
|
|
readInt32LE: 4,
|
|
readUInt32BE: 4,
|
|
readUInt32LE: 4,
|
|
readInt16BE: 2,
|
|
readInt16LE: 2,
|
|
readUInt16BE: 2,
|
|
readUInt16LE: 2,
|
|
readInt8: 1,
|
|
readUInt8: 1,
|
|
readIntBE: null,
|
|
readIntLE: null,
|
|
readUIntBE: null,
|
|
readUIntLE: null,
|
|
}
|
|
for (let t in e)
|
|
(function (r) {
|
|
e[r] === null
|
|
? (W.prototype[r] = function (i, n) {
|
|
return this.slice(i, i + n)[r](0, n)
|
|
})
|
|
: (W.prototype[r] = function (i = 0) {
|
|
return this.slice(i, i + e[r])[r](0)
|
|
})
|
|
})(t)
|
|
})()
|
|
W.prototype._isBufferList = function (t) {
|
|
return t instanceof W || W.isBufferList(t)
|
|
}
|
|
W.isBufferList = function (t) {
|
|
return t != null && t[ka]
|
|
}
|
|
Ra.exports = W
|
|
})
|
|
var Ba = b((Zm, Xr) => {
|
|
'use strict'
|
|
var Pn = He().Duplex,
|
|
Ep = ie(),
|
|
Yt = Pa()
|
|
function ee(e) {
|
|
if (!(this instanceof ee)) return new ee(e)
|
|
if (typeof e == 'function') {
|
|
this._callback = e
|
|
let t = function (i) {
|
|
this._callback && (this._callback(i), (this._callback = null))
|
|
}.bind(this)
|
|
this.on('pipe', function (i) {
|
|
i.on('error', t)
|
|
}),
|
|
this.on('unpipe', function (i) {
|
|
i.removeListener('error', t)
|
|
}),
|
|
(e = null)
|
|
}
|
|
Yt._init.call(this, e), Pn.call(this)
|
|
}
|
|
Ep(ee, Pn)
|
|
Object.assign(ee.prototype, Yt.prototype)
|
|
ee.prototype._new = function (t) {
|
|
return new ee(t)
|
|
}
|
|
ee.prototype._write = function (t, r, i) {
|
|
this._appendBuffer(t), typeof i == 'function' && i()
|
|
}
|
|
ee.prototype._read = function (t) {
|
|
if (!this.length) return this.push(null)
|
|
;(t = Math.min(t, this.length)),
|
|
this.push(this.slice(0, t)),
|
|
this.consume(t)
|
|
}
|
|
ee.prototype.end = function (t) {
|
|
Pn.prototype.end.call(this, t),
|
|
this._callback &&
|
|
(this._callback(null, this.slice()), (this._callback = null))
|
|
}
|
|
ee.prototype._destroy = function (t, r) {
|
|
;(this._bufs.length = 0), (this.length = 0), r(t)
|
|
}
|
|
ee.prototype._isBufferList = function (t) {
|
|
return t instanceof ee || t instanceof Yt || ee.isBufferList(t)
|
|
}
|
|
ee.isBufferList = Yt.isBufferList
|
|
Xr.exports = ee
|
|
Xr.exports.BufferListStream = ee
|
|
Xr.exports.BufferList = Yt
|
|
})
|
|
var Na = b((ew, Aa) => {
|
|
var Bn = class {
|
|
constructor() {
|
|
;(this.cmd = null),
|
|
(this.retain = !1),
|
|
(this.qos = 0),
|
|
(this.dup = !1),
|
|
(this.length = -1),
|
|
(this.topic = null),
|
|
(this.payload = null)
|
|
}
|
|
}
|
|
Aa.exports = Bn
|
|
})
|
|
var An = b((tw, Ma) => {
|
|
var E = Ma.exports
|
|
E.types = {
|
|
0: 'reserved',
|
|
1: 'connect',
|
|
2: 'connack',
|
|
3: 'publish',
|
|
4: 'puback',
|
|
5: 'pubrec',
|
|
6: 'pubrel',
|
|
7: 'pubcomp',
|
|
8: 'subscribe',
|
|
9: 'suback',
|
|
10: 'unsubscribe',
|
|
11: 'unsuback',
|
|
12: 'pingreq',
|
|
13: 'pingresp',
|
|
14: 'disconnect',
|
|
15: 'auth',
|
|
}
|
|
E.codes = {}
|
|
for (let e in E.types) {
|
|
let t = E.types[e]
|
|
E.codes[t] = e
|
|
}
|
|
E.CMD_SHIFT = 4
|
|
E.CMD_MASK = 240
|
|
E.DUP_MASK = 8
|
|
E.QOS_MASK = 3
|
|
E.QOS_SHIFT = 1
|
|
E.RETAIN_MASK = 1
|
|
E.VARBYTEINT_MASK = 127
|
|
E.VARBYTEINT_FIN_MASK = 128
|
|
E.VARBYTEINT_MAX = 268435455
|
|
E.SESSIONPRESENT_MASK = 1
|
|
E.SESSIONPRESENT_HEADER = Buffer.from([E.SESSIONPRESENT_MASK])
|
|
E.CONNACK_HEADER = Buffer.from([E.codes.connack << E.CMD_SHIFT])
|
|
E.USERNAME_MASK = 128
|
|
E.PASSWORD_MASK = 64
|
|
E.WILL_RETAIN_MASK = 32
|
|
E.WILL_QOS_MASK = 24
|
|
E.WILL_QOS_SHIFT = 3
|
|
E.WILL_FLAG_MASK = 4
|
|
E.CLEAN_SESSION_MASK = 2
|
|
E.CONNECT_HEADER = Buffer.from([E.codes.connect << E.CMD_SHIFT])
|
|
E.properties = {
|
|
sessionExpiryInterval: 17,
|
|
willDelayInterval: 24,
|
|
receiveMaximum: 33,
|
|
maximumPacketSize: 39,
|
|
topicAliasMaximum: 34,
|
|
requestResponseInformation: 25,
|
|
requestProblemInformation: 23,
|
|
userProperties: 38,
|
|
authenticationMethod: 21,
|
|
authenticationData: 22,
|
|
payloadFormatIndicator: 1,
|
|
messageExpiryInterval: 2,
|
|
contentType: 3,
|
|
responseTopic: 8,
|
|
correlationData: 9,
|
|
maximumQoS: 36,
|
|
retainAvailable: 37,
|
|
assignedClientIdentifier: 18,
|
|
reasonString: 31,
|
|
wildcardSubscriptionAvailable: 40,
|
|
subscriptionIdentifiersAvailable: 41,
|
|
sharedSubscriptionAvailable: 42,
|
|
serverKeepAlive: 19,
|
|
responseInformation: 26,
|
|
serverReference: 28,
|
|
topicAlias: 35,
|
|
subscriptionIdentifier: 11,
|
|
}
|
|
E.propertiesCodes = {}
|
|
for (let e in E.properties) {
|
|
let t = E.properties[e]
|
|
E.propertiesCodes[t] = e
|
|
}
|
|
E.propertiesTypes = {
|
|
sessionExpiryInterval: 'int32',
|
|
willDelayInterval: 'int32',
|
|
receiveMaximum: 'int16',
|
|
maximumPacketSize: 'int32',
|
|
topicAliasMaximum: 'int16',
|
|
requestResponseInformation: 'byte',
|
|
requestProblemInformation: 'byte',
|
|
userProperties: 'pair',
|
|
authenticationMethod: 'string',
|
|
authenticationData: 'binary',
|
|
payloadFormatIndicator: 'byte',
|
|
messageExpiryInterval: 'int32',
|
|
contentType: 'string',
|
|
responseTopic: 'string',
|
|
correlationData: 'binary',
|
|
maximumQoS: 'int8',
|
|
retainAvailable: 'byte',
|
|
assignedClientIdentifier: 'string',
|
|
reasonString: 'string',
|
|
wildcardSubscriptionAvailable: 'byte',
|
|
subscriptionIdentifiersAvailable: 'byte',
|
|
sharedSubscriptionAvailable: 'byte',
|
|
serverKeepAlive: 'int16',
|
|
responseInformation: 'string',
|
|
serverReference: 'string',
|
|
topicAlias: 'int16',
|
|
subscriptionIdentifier: 'var',
|
|
}
|
|
function Ge(e) {
|
|
return [0, 1, 2].map((t) =>
|
|
[0, 1].map((r) =>
|
|
[0, 1].map((i) => {
|
|
let n = Buffer.alloc(1)
|
|
return (
|
|
n.writeUInt8(
|
|
(E.codes[e] << E.CMD_SHIFT) |
|
|
(r ? E.DUP_MASK : 0) |
|
|
(t << E.QOS_SHIFT) |
|
|
i,
|
|
0,
|
|
!0,
|
|
),
|
|
n
|
|
)
|
|
}),
|
|
),
|
|
)
|
|
}
|
|
E.PUBLISH_HEADER = Ge('publish')
|
|
E.SUBSCRIBE_HEADER = Ge('subscribe')
|
|
E.SUBSCRIBE_OPTIONS_QOS_MASK = 3
|
|
E.SUBSCRIBE_OPTIONS_NL_MASK = 1
|
|
E.SUBSCRIBE_OPTIONS_NL_SHIFT = 2
|
|
E.SUBSCRIBE_OPTIONS_RAP_MASK = 1
|
|
E.SUBSCRIBE_OPTIONS_RAP_SHIFT = 3
|
|
E.SUBSCRIBE_OPTIONS_RH_MASK = 3
|
|
E.SUBSCRIBE_OPTIONS_RH_SHIFT = 4
|
|
E.SUBSCRIBE_OPTIONS_RH = [0, 16, 32]
|
|
E.SUBSCRIBE_OPTIONS_NL = 4
|
|
E.SUBSCRIBE_OPTIONS_RAP = 8
|
|
E.SUBSCRIBE_OPTIONS_QOS = [0, 1, 2]
|
|
E.UNSUBSCRIBE_HEADER = Ge('unsubscribe')
|
|
E.ACKS = {
|
|
unsuback: Ge('unsuback'),
|
|
puback: Ge('puback'),
|
|
pubcomp: Ge('pubcomp'),
|
|
pubrel: Ge('pubrel'),
|
|
pubrec: Ge('pubrec'),
|
|
}
|
|
E.SUBACK_HEADER = Buffer.from([E.codes.suback << E.CMD_SHIFT])
|
|
E.VERSION3 = Buffer.from([3])
|
|
E.VERSION4 = Buffer.from([4])
|
|
E.VERSION5 = Buffer.from([5])
|
|
E.VERSION131 = Buffer.from([131])
|
|
E.VERSION132 = Buffer.from([132])
|
|
E.QOS = [0, 1, 2].map((e) => Buffer.from([e]))
|
|
E.EMPTY = {
|
|
pingreq: Buffer.from([E.codes.pingreq << 4, 0]),
|
|
pingresp: Buffer.from([E.codes.pingresp << 4, 0]),
|
|
disconnect: Buffer.from([E.codes.disconnect << 4, 0]),
|
|
}
|
|
})
|
|
var qa = b((rw, La) => {
|
|
var Ct = 1e3,
|
|
Tt = Ct * 60,
|
|
It = Tt * 60,
|
|
ft = It * 24,
|
|
xp = ft * 7,
|
|
Cp = ft * 365.25
|
|
La.exports = function (e, t) {
|
|
t = t || {}
|
|
var r = typeof e
|
|
if (r === 'string' && e.length > 0) return Tp(e)
|
|
if (r === 'number' && isFinite(e)) return t.long ? Op(e) : Ip(e)
|
|
throw new Error(
|
|
'val is not a non-empty string or a valid number. val=' +
|
|
JSON.stringify(e),
|
|
)
|
|
}
|
|
function Tp(e) {
|
|
if (((e = String(e)), !(e.length > 100))) {
|
|
var t =
|
|
/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
e,
|
|
)
|
|
if (t) {
|
|
var r = parseFloat(t[1]),
|
|
i = (t[2] || 'ms').toLowerCase()
|
|
switch (i) {
|
|
case 'years':
|
|
case 'year':
|
|
case 'yrs':
|
|
case 'yr':
|
|
case 'y':
|
|
return r * Cp
|
|
case 'weeks':
|
|
case 'week':
|
|
case 'w':
|
|
return r * xp
|
|
case 'days':
|
|
case 'day':
|
|
case 'd':
|
|
return r * ft
|
|
case 'hours':
|
|
case 'hour':
|
|
case 'hrs':
|
|
case 'hr':
|
|
case 'h':
|
|
return r * It
|
|
case 'minutes':
|
|
case 'minute':
|
|
case 'mins':
|
|
case 'min':
|
|
case 'm':
|
|
return r * Tt
|
|
case 'seconds':
|
|
case 'second':
|
|
case 'secs':
|
|
case 'sec':
|
|
case 's':
|
|
return r * Ct
|
|
case 'milliseconds':
|
|
case 'millisecond':
|
|
case 'msecs':
|
|
case 'msec':
|
|
case 'ms':
|
|
return r
|
|
default:
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function Ip(e) {
|
|
var t = Math.abs(e)
|
|
return t >= ft
|
|
? Math.round(e / ft) + 'd'
|
|
: t >= It
|
|
? Math.round(e / It) + 'h'
|
|
: t >= Tt
|
|
? Math.round(e / Tt) + 'm'
|
|
: t >= Ct
|
|
? Math.round(e / Ct) + 's'
|
|
: e + 'ms'
|
|
}
|
|
function Op(e) {
|
|
var t = Math.abs(e)
|
|
return t >= ft
|
|
? Zr(e, t, ft, 'day')
|
|
: t >= It
|
|
? Zr(e, t, It, 'hour')
|
|
: t >= Tt
|
|
? Zr(e, t, Tt, 'minute')
|
|
: t >= Ct
|
|
? Zr(e, t, Ct, 'second')
|
|
: e + ' ms'
|
|
}
|
|
function Zr(e, t, r, i) {
|
|
var n = t >= r * 1.5
|
|
return Math.round(e / r) + ' ' + i + (n ? 's' : '')
|
|
}
|
|
})
|
|
var Nn = b((iw, Da) => {
|
|
function kp(e) {
|
|
;(r.debug = r),
|
|
(r.default = r),
|
|
(r.coerce = a),
|
|
(r.disable = s),
|
|
(r.enable = n),
|
|
(r.enabled = o),
|
|
(r.humanize = qa()),
|
|
(r.destroy = l),
|
|
Object.keys(e).forEach((u) => {
|
|
r[u] = e[u]
|
|
}),
|
|
(r.names = []),
|
|
(r.skips = []),
|
|
(r.formatters = {})
|
|
function t(u) {
|
|
let h = 0
|
|
for (let c = 0; c < u.length; c++)
|
|
(h = (h << 5) - h + u.charCodeAt(c)), (h |= 0)
|
|
return r.colors[Math.abs(h) % r.colors.length]
|
|
}
|
|
r.selectColor = t
|
|
function r(u) {
|
|
let h,
|
|
c = null,
|
|
d,
|
|
_
|
|
function v(...m) {
|
|
if (!v.enabled) return
|
|
let p = v,
|
|
g = Number(new Date()),
|
|
S = g - (h || g)
|
|
;(p.diff = S),
|
|
(p.prev = h),
|
|
(p.curr = g),
|
|
(h = g),
|
|
(m[0] = r.coerce(m[0])),
|
|
typeof m[0] != 'string' && m.unshift('%O')
|
|
let x = 0
|
|
;(m[0] = m[0].replace(/%([a-zA-Z%])/g, (w, B) => {
|
|
if (w === '%%') return '%'
|
|
x++
|
|
let M = r.formatters[B]
|
|
if (typeof M == 'function') {
|
|
let H = m[x]
|
|
;(w = M.call(p, H)), m.splice(x, 1), x--
|
|
}
|
|
return w
|
|
})),
|
|
r.formatArgs.call(p, m),
|
|
(p.log || r.log).apply(p, m)
|
|
}
|
|
return (
|
|
(v.namespace = u),
|
|
(v.useColors = r.useColors()),
|
|
(v.color = r.selectColor(u)),
|
|
(v.extend = i),
|
|
(v.destroy = r.destroy),
|
|
Object.defineProperty(v, 'enabled', {
|
|
enumerable: !0,
|
|
configurable: !1,
|
|
get: () =>
|
|
c !== null
|
|
? c
|
|
: (d !== r.namespaces && ((d = r.namespaces), (_ = r.enabled(u))),
|
|
_),
|
|
set: (m) => {
|
|
c = m
|
|
},
|
|
}),
|
|
typeof r.init == 'function' && r.init(v),
|
|
v
|
|
)
|
|
}
|
|
function i(u, h) {
|
|
let c = r(this.namespace + (typeof h > 'u' ? ':' : h) + u)
|
|
return (c.log = this.log), c
|
|
}
|
|
function n(u) {
|
|
r.save(u), (r.namespaces = u), (r.names = []), (r.skips = [])
|
|
let h,
|
|
c = (typeof u == 'string' ? u : '').split(/[\s,]+/),
|
|
d = c.length
|
|
for (h = 0; h < d; h++)
|
|
c[h] &&
|
|
((u = c[h].replace(/\*/g, '.*?')),
|
|
u[0] === '-'
|
|
? r.skips.push(new RegExp('^' + u.slice(1) + '$'))
|
|
: r.names.push(new RegExp('^' + u + '$')))
|
|
}
|
|
function s() {
|
|
let u = [...r.names.map(f), ...r.skips.map(f).map((h) => '-' + h)].join(
|
|
',',
|
|
)
|
|
return r.enable(''), u
|
|
}
|
|
function o(u) {
|
|
if (u[u.length - 1] === '*') return !0
|
|
let h, c
|
|
for (h = 0, c = r.skips.length; h < c; h++)
|
|
if (r.skips[h].test(u)) return !1
|
|
for (h = 0, c = r.names.length; h < c; h++)
|
|
if (r.names[h].test(u)) return !0
|
|
return !1
|
|
}
|
|
function f(u) {
|
|
return u
|
|
.toString()
|
|
.substring(2, u.toString().length - 2)
|
|
.replace(/\.\*\?$/, '*')
|
|
}
|
|
function a(u) {
|
|
return u instanceof Error ? u.stack || u.message : u
|
|
}
|
|
function l() {
|
|
console.warn(
|
|
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.',
|
|
)
|
|
}
|
|
return r.enable(r.load()), r
|
|
}
|
|
Da.exports = kp
|
|
})
|
|
var Ua = b((fe, ei) => {
|
|
fe.formatArgs = Pp
|
|
fe.save = Bp
|
|
fe.load = Ap
|
|
fe.useColors = Rp
|
|
fe.storage = Np()
|
|
fe.destroy = (() => {
|
|
let e = !1
|
|
return () => {
|
|
e ||
|
|
((e = !0),
|
|
console.warn(
|
|
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.',
|
|
))
|
|
}
|
|
})()
|
|
fe.colors = [
|
|
'#0000CC',
|
|
'#0000FF',
|
|
'#0033CC',
|
|
'#0033FF',
|
|
'#0066CC',
|
|
'#0066FF',
|
|
'#0099CC',
|
|
'#0099FF',
|
|
'#00CC00',
|
|
'#00CC33',
|
|
'#00CC66',
|
|
'#00CC99',
|
|
'#00CCCC',
|
|
'#00CCFF',
|
|
'#3300CC',
|
|
'#3300FF',
|
|
'#3333CC',
|
|
'#3333FF',
|
|
'#3366CC',
|
|
'#3366FF',
|
|
'#3399CC',
|
|
'#3399FF',
|
|
'#33CC00',
|
|
'#33CC33',
|
|
'#33CC66',
|
|
'#33CC99',
|
|
'#33CCCC',
|
|
'#33CCFF',
|
|
'#6600CC',
|
|
'#6600FF',
|
|
'#6633CC',
|
|
'#6633FF',
|
|
'#66CC00',
|
|
'#66CC33',
|
|
'#9900CC',
|
|
'#9900FF',
|
|
'#9933CC',
|
|
'#9933FF',
|
|
'#99CC00',
|
|
'#99CC33',
|
|
'#CC0000',
|
|
'#CC0033',
|
|
'#CC0066',
|
|
'#CC0099',
|
|
'#CC00CC',
|
|
'#CC00FF',
|
|
'#CC3300',
|
|
'#CC3333',
|
|
'#CC3366',
|
|
'#CC3399',
|
|
'#CC33CC',
|
|
'#CC33FF',
|
|
'#CC6600',
|
|
'#CC6633',
|
|
'#CC9900',
|
|
'#CC9933',
|
|
'#CCCC00',
|
|
'#CCCC33',
|
|
'#FF0000',
|
|
'#FF0033',
|
|
'#FF0066',
|
|
'#FF0099',
|
|
'#FF00CC',
|
|
'#FF00FF',
|
|
'#FF3300',
|
|
'#FF3333',
|
|
'#FF3366',
|
|
'#FF3399',
|
|
'#FF33CC',
|
|
'#FF33FF',
|
|
'#FF6600',
|
|
'#FF6633',
|
|
'#FF9900',
|
|
'#FF9933',
|
|
'#FFCC00',
|
|
'#FFCC33',
|
|
]
|
|
function Rp() {
|
|
return typeof window < 'u' &&
|
|
window.process &&
|
|
(window.process.type === 'renderer' || window.process.__nwjs)
|
|
? !0
|
|
: typeof navigator < 'u' &&
|
|
navigator.userAgent &&
|
|
navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)
|
|
? !1
|
|
: (typeof document < 'u' &&
|
|
document.documentElement &&
|
|
document.documentElement.style &&
|
|
document.documentElement.style.WebkitAppearance) ||
|
|
(typeof window < 'u' &&
|
|
window.console &&
|
|
(window.console.firebug ||
|
|
(window.console.exception && window.console.table))) ||
|
|
(typeof navigator < 'u' &&
|
|
navigator.userAgent &&
|
|
navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) &&
|
|
parseInt(RegExp.$1, 10) >= 31) ||
|
|
(typeof navigator < 'u' &&
|
|
navigator.userAgent &&
|
|
navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))
|
|
}
|
|
function Pp(e) {
|
|
if (
|
|
((e[0] =
|
|
(this.useColors ? '%c' : '') +
|
|
this.namespace +
|
|
(this.useColors ? ' %c' : ' ') +
|
|
e[0] +
|
|
(this.useColors ? '%c ' : ' ') +
|
|
'+' +
|
|
ei.exports.humanize(this.diff)),
|
|
!this.useColors)
|
|
)
|
|
return
|
|
let t = 'color: ' + this.color
|
|
e.splice(1, 0, t, 'color: inherit')
|
|
let r = 0,
|
|
i = 0
|
|
e[0].replace(/%[a-zA-Z%]/g, (n) => {
|
|
n !== '%%' && (r++, n === '%c' && (i = r))
|
|
}),
|
|
e.splice(i, 0, t)
|
|
}
|
|
fe.log = console.debug || console.log || (() => {})
|
|
function Bp(e) {
|
|
try {
|
|
e ? fe.storage.setItem('debug', e) : fe.storage.removeItem('debug')
|
|
} catch {}
|
|
}
|
|
function Ap() {
|
|
let e
|
|
try {
|
|
e = fe.storage.getItem('debug')
|
|
} catch {}
|
|
return (
|
|
!e && typeof process < 'u' && 'env' in process && (e = process.env.DEBUG),
|
|
e
|
|
)
|
|
}
|
|
function Np() {
|
|
try {
|
|
return localStorage
|
|
} catch {}
|
|
}
|
|
ei.exports = Nn()(fe)
|
|
var { formatters: Mp } = ei.exports
|
|
Mp.j = function (e) {
|
|
try {
|
|
return JSON.stringify(e)
|
|
} catch (t) {
|
|
return '[UnexpectedJSONParseError]: ' + t.message
|
|
}
|
|
}
|
|
})
|
|
var Fa = b((nw, ja) => {
|
|
'use strict'
|
|
ja.exports = (e, t = process.argv) => {
|
|
let r = e.startsWith('-') ? '' : e.length === 1 ? '-' : '--',
|
|
i = t.indexOf(r + e),
|
|
n = t.indexOf('--')
|
|
return i !== -1 && (n === -1 || i < n)
|
|
}
|
|
})
|
|
var Ha = b((sw, Va) => {
|
|
'use strict'
|
|
var Lp = require('os'),
|
|
Wa = require('tty'),
|
|
pe = Fa(),
|
|
{ env: Y } = process,
|
|
ti
|
|
pe('no-color') || pe('no-colors') || pe('color=false') || pe('color=never')
|
|
? (ti = 0)
|
|
: (pe('color') || pe('colors') || pe('color=true') || pe('color=always')) &&
|
|
(ti = 1)
|
|
function qp() {
|
|
if ('FORCE_COLOR' in Y)
|
|
return Y.FORCE_COLOR === 'true'
|
|
? 1
|
|
: Y.FORCE_COLOR === 'false'
|
|
? 0
|
|
: Y.FORCE_COLOR.length === 0
|
|
? 1
|
|
: Math.min(Number.parseInt(Y.FORCE_COLOR, 10), 3)
|
|
}
|
|
function Dp(e) {
|
|
return e === 0
|
|
? !1
|
|
: { level: e, hasBasic: !0, has256: e >= 2, has16m: e >= 3 }
|
|
}
|
|
function Up(e, { streamIsTTY: t, sniffFlags: r = !0 } = {}) {
|
|
let i = qp()
|
|
i !== void 0 && (ti = i)
|
|
let n = r ? ti : i
|
|
if (n === 0) return 0
|
|
if (r) {
|
|
if (pe('color=16m') || pe('color=full') || pe('color=truecolor')) return 3
|
|
if (pe('color=256')) return 2
|
|
}
|
|
if (e && !t && n === void 0) return 0
|
|
let s = n || 0
|
|
if (Y.TERM === 'dumb') return s
|
|
if (process.platform === 'win32') {
|
|
let o = Lp.release().split('.')
|
|
return Number(o[0]) >= 10 && Number(o[2]) >= 10586
|
|
? Number(o[2]) >= 14931
|
|
? 3
|
|
: 2
|
|
: 1
|
|
}
|
|
if ('CI' in Y)
|
|
return [
|
|
'TRAVIS',
|
|
'CIRCLECI',
|
|
'APPVEYOR',
|
|
'GITLAB_CI',
|
|
'GITHUB_ACTIONS',
|
|
'BUILDKITE',
|
|
'DRONE',
|
|
].some((o) => o in Y) || Y.CI_NAME === 'codeship'
|
|
? 1
|
|
: s
|
|
if ('TEAMCITY_VERSION' in Y)
|
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Y.TEAMCITY_VERSION) ? 1 : 0
|
|
if (Y.COLORTERM === 'truecolor') return 3
|
|
if ('TERM_PROGRAM' in Y) {
|
|
let o = Number.parseInt((Y.TERM_PROGRAM_VERSION || '').split('.')[0], 10)
|
|
switch (Y.TERM_PROGRAM) {
|
|
case 'iTerm.app':
|
|
return o >= 3 ? 3 : 2
|
|
case 'Apple_Terminal':
|
|
return 2
|
|
}
|
|
}
|
|
return /-256(color)?$/i.test(Y.TERM)
|
|
? 2
|
|
: /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
|
|
Y.TERM,
|
|
) || 'COLORTERM' in Y
|
|
? 1
|
|
: s
|
|
}
|
|
function Mn(e, t = {}) {
|
|
let r = Up(e, { streamIsTTY: e && e.isTTY, ...t })
|
|
return Dp(r)
|
|
}
|
|
Va.exports = {
|
|
supportsColor: Mn,
|
|
stdout: Mn({ isTTY: Wa.isatty(1) }),
|
|
stderr: Mn({ isTTY: Wa.isatty(2) }),
|
|
}
|
|
})
|
|
var Ga = b((Q, ii) => {
|
|
var jp = require('tty'),
|
|
ri = require('util')
|
|
Q.init = zp
|
|
Q.log = Hp
|
|
Q.formatArgs = Wp
|
|
Q.save = $p
|
|
Q.load = Gp
|
|
Q.useColors = Fp
|
|
Q.destroy = ri.deprecate(
|
|
() => {},
|
|
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.',
|
|
)
|
|
Q.colors = [6, 2, 3, 4, 5, 1]
|
|
try {
|
|
let e = Ha()
|
|
e &&
|
|
(e.stderr || e).level >= 2 &&
|
|
(Q.colors = [
|
|
20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63,
|
|
68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128,
|
|
129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168,
|
|
169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200,
|
|
201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221,
|
|
])
|
|
} catch {}
|
|
Q.inspectOpts = Object.keys(process.env)
|
|
.filter((e) => /^debug_/i.test(e))
|
|
.reduce((e, t) => {
|
|
let r = t
|
|
.substring(6)
|
|
.toLowerCase()
|
|
.replace(/_([a-z])/g, (n, s) => s.toUpperCase()),
|
|
i = process.env[t]
|
|
return (
|
|
/^(yes|on|true|enabled)$/i.test(i)
|
|
? (i = !0)
|
|
: /^(no|off|false|disabled)$/i.test(i)
|
|
? (i = !1)
|
|
: i === 'null'
|
|
? (i = null)
|
|
: (i = Number(i)),
|
|
(e[r] = i),
|
|
e
|
|
)
|
|
}, {})
|
|
function Fp() {
|
|
return 'colors' in Q.inspectOpts
|
|
? !!Q.inspectOpts.colors
|
|
: jp.isatty(process.stderr.fd)
|
|
}
|
|
function Wp(e) {
|
|
let { namespace: t, useColors: r } = this
|
|
if (r) {
|
|
let i = this.color,
|
|
n = '\x1B[3' + (i < 8 ? i : '8;5;' + i),
|
|
s = ` ${n};1m${t} \x1B[0m`
|
|
;(e[0] =
|
|
s +
|
|
e[0]
|
|
.split(
|
|
`
|
|
`,
|
|
)
|
|
.join(
|
|
`
|
|
` + s,
|
|
)),
|
|
e.push(n + 'm+' + ii.exports.humanize(this.diff) + '\x1B[0m')
|
|
} else e[0] = Vp() + t + ' ' + e[0]
|
|
}
|
|
function Vp() {
|
|
return Q.inspectOpts.hideDate ? '' : new Date().toISOString() + ' '
|
|
}
|
|
function Hp(...e) {
|
|
return process.stderr.write(
|
|
ri.format(...e) +
|
|
`
|
|
`,
|
|
)
|
|
}
|
|
function $p(e) {
|
|
e ? (process.env.DEBUG = e) : delete process.env.DEBUG
|
|
}
|
|
function Gp() {
|
|
return process.env.DEBUG
|
|
}
|
|
function zp(e) {
|
|
e.inspectOpts = {}
|
|
let t = Object.keys(Q.inspectOpts)
|
|
for (let r = 0; r < t.length; r++) e.inspectOpts[t[r]] = Q.inspectOpts[t[r]]
|
|
}
|
|
ii.exports = Nn()(Q)
|
|
var { formatters: $a } = ii.exports
|
|
$a.o = function (e) {
|
|
return (
|
|
(this.inspectOpts.colors = this.useColors),
|
|
ri
|
|
.inspect(e, this.inspectOpts)
|
|
.split(
|
|
`
|
|
`,
|
|
)
|
|
.map((t) => t.trim())
|
|
.join(' ')
|
|
)
|
|
}
|
|
$a.O = function (e) {
|
|
return (
|
|
(this.inspectOpts.colors = this.useColors),
|
|
ri.inspect(e, this.inspectOpts)
|
|
)
|
|
}
|
|
})
|
|
var ze = b((ow, Ln) => {
|
|
typeof process > 'u' ||
|
|
process.type === 'renderer' ||
|
|
process.browser === !0 ||
|
|
process.__nwjs
|
|
? (Ln.exports = Ua())
|
|
: (Ln.exports = Ga())
|
|
})
|
|
var Ya = b((aw, Ka) => {
|
|
var Kp = Ba(),
|
|
Yp = require('events'),
|
|
za = Na(),
|
|
j = An(),
|
|
I = ze()('mqtt-packet:parser'),
|
|
qn = class e extends Yp {
|
|
constructor() {
|
|
super(), (this.parser = this.constructor.parser)
|
|
}
|
|
static parser(t) {
|
|
return this instanceof e
|
|
? ((this.settings = t || {}),
|
|
(this._states = [
|
|
'_parseHeader',
|
|
'_parseLength',
|
|
'_parsePayload',
|
|
'_newPacket',
|
|
]),
|
|
this._resetState(),
|
|
this)
|
|
: new e().parser(t)
|
|
}
|
|
_resetState() {
|
|
I('_resetState: resetting packet, error, _list, and _stateCounter'),
|
|
(this.packet = new za()),
|
|
(this.error = null),
|
|
(this._list = Kp()),
|
|
(this._stateCounter = 0)
|
|
}
|
|
parse(t) {
|
|
for (
|
|
this.error && this._resetState(),
|
|
this._list.append(t),
|
|
I('parse: current state: %s', this._states[this._stateCounter]);
|
|
(this.packet.length !== -1 || this._list.length > 0) &&
|
|
this[this._states[this._stateCounter]]() &&
|
|
!this.error;
|
|
|
|
)
|
|
this._stateCounter++,
|
|
I(
|
|
'parse: state complete. _stateCounter is now: %d',
|
|
this._stateCounter,
|
|
),
|
|
I(
|
|
'parse: packet.length: %d, buffer list length: %d',
|
|
this.packet.length,
|
|
this._list.length,
|
|
),
|
|
this._stateCounter >= this._states.length &&
|
|
(this._stateCounter = 0)
|
|
return (
|
|
I(
|
|
'parse: exited while loop. packet: %d, buffer list length: %d',
|
|
this.packet.length,
|
|
this._list.length,
|
|
),
|
|
this._list.length
|
|
)
|
|
}
|
|
_parseHeader() {
|
|
let t = this._list.readUInt8(0)
|
|
return (
|
|
(this.packet.cmd = j.types[t >> j.CMD_SHIFT]),
|
|
(this.packet.retain = (t & j.RETAIN_MASK) !== 0),
|
|
(this.packet.qos = (t >> j.QOS_SHIFT) & j.QOS_MASK),
|
|
(this.packet.dup = (t & j.DUP_MASK) !== 0),
|
|
I('_parseHeader: packet: %o', this.packet),
|
|
this._list.consume(1),
|
|
!0
|
|
)
|
|
}
|
|
_parseLength() {
|
|
let t = this._parseVarByteNum(!0)
|
|
return (
|
|
t && ((this.packet.length = t.value), this._list.consume(t.bytes)),
|
|
I('_parseLength %d', t.value),
|
|
!!t
|
|
)
|
|
}
|
|
_parsePayload() {
|
|
I('_parsePayload: payload %O', this._list)
|
|
let t = !1
|
|
if (
|
|
this.packet.length === 0 ||
|
|
this._list.length >= this.packet.length
|
|
) {
|
|
switch (((this._pos = 0), this.packet.cmd)) {
|
|
case 'connect':
|
|
this._parseConnect()
|
|
break
|
|
case 'connack':
|
|
this._parseConnack()
|
|
break
|
|
case 'publish':
|
|
this._parsePublish()
|
|
break
|
|
case 'puback':
|
|
case 'pubrec':
|
|
case 'pubrel':
|
|
case 'pubcomp':
|
|
this._parseConfirmation()
|
|
break
|
|
case 'subscribe':
|
|
this._parseSubscribe()
|
|
break
|
|
case 'suback':
|
|
this._parseSuback()
|
|
break
|
|
case 'unsubscribe':
|
|
this._parseUnsubscribe()
|
|
break
|
|
case 'unsuback':
|
|
this._parseUnsuback()
|
|
break
|
|
case 'pingreq':
|
|
case 'pingresp':
|
|
break
|
|
case 'disconnect':
|
|
this._parseDisconnect()
|
|
break
|
|
case 'auth':
|
|
this._parseAuth()
|
|
break
|
|
default:
|
|
this._emitError(new Error('Not supported'))
|
|
}
|
|
t = !0
|
|
}
|
|
return I('_parsePayload complete result: %s', t), t
|
|
}
|
|
_parseConnect() {
|
|
I('_parseConnect')
|
|
let t,
|
|
r,
|
|
i,
|
|
n,
|
|
s = {},
|
|
o = this.packet,
|
|
f = this._parseString()
|
|
if (f === null)
|
|
return this._emitError(new Error('Cannot parse protocolId'))
|
|
if (f !== 'MQTT' && f !== 'MQIsdp')
|
|
return this._emitError(new Error('Invalid protocolId'))
|
|
if (((o.protocolId = f), this._pos >= this._list.length))
|
|
return this._emitError(new Error('Packet too short'))
|
|
if (
|
|
((o.protocolVersion = this._list.readUInt8(this._pos)),
|
|
o.protocolVersion >= 128 &&
|
|
((o.bridgeMode = !0),
|
|
(o.protocolVersion = o.protocolVersion - 128)),
|
|
o.protocolVersion !== 3 &&
|
|
o.protocolVersion !== 4 &&
|
|
o.protocolVersion !== 5)
|
|
)
|
|
return this._emitError(new Error('Invalid protocol version'))
|
|
if ((this._pos++, this._pos >= this._list.length))
|
|
return this._emitError(new Error('Packet too short'))
|
|
if (
|
|
((s.username = this._list.readUInt8(this._pos) & j.USERNAME_MASK),
|
|
(s.password = this._list.readUInt8(this._pos) & j.PASSWORD_MASK),
|
|
(s.will = this._list.readUInt8(this._pos) & j.WILL_FLAG_MASK),
|
|
s.will &&
|
|
((o.will = {}),
|
|
(o.will.retain =
|
|
(this._list.readUInt8(this._pos) & j.WILL_RETAIN_MASK) !== 0),
|
|
(o.will.qos =
|
|
(this._list.readUInt8(this._pos) & j.WILL_QOS_MASK) >>
|
|
j.WILL_QOS_SHIFT)),
|
|
(o.clean =
|
|
(this._list.readUInt8(this._pos) & j.CLEAN_SESSION_MASK) !== 0),
|
|
this._pos++,
|
|
(o.keepalive = this._parseNum()),
|
|
o.keepalive === -1)
|
|
)
|
|
return this._emitError(new Error('Packet too short'))
|
|
if (o.protocolVersion === 5) {
|
|
let l = this._parseProperties()
|
|
Object.getOwnPropertyNames(l).length && (o.properties = l)
|
|
}
|
|
let a = this._parseString()
|
|
if (a === null) return this._emitError(new Error('Packet too short'))
|
|
if (
|
|
((o.clientId = a),
|
|
I('_parseConnect: packet.clientId: %s', o.clientId),
|
|
s.will)
|
|
) {
|
|
if (o.protocolVersion === 5) {
|
|
let l = this._parseProperties()
|
|
Object.getOwnPropertyNames(l).length && (o.will.properties = l)
|
|
}
|
|
if (((t = this._parseString()), t === null))
|
|
return this._emitError(new Error('Cannot parse will topic'))
|
|
if (
|
|
((o.will.topic = t),
|
|
I('_parseConnect: packet.will.topic: %s', o.will.topic),
|
|
(r = this._parseBuffer()),
|
|
r === null)
|
|
)
|
|
return this._emitError(new Error('Cannot parse will payload'))
|
|
;(o.will.payload = r),
|
|
I('_parseConnect: packet.will.paylaod: %s', o.will.payload)
|
|
}
|
|
if (s.username) {
|
|
if (((n = this._parseString()), n === null))
|
|
return this._emitError(new Error('Cannot parse username'))
|
|
;(o.username = n), I('_parseConnect: packet.username: %s', o.username)
|
|
}
|
|
if (s.password) {
|
|
if (((i = this._parseBuffer()), i === null))
|
|
return this._emitError(new Error('Cannot parse password'))
|
|
o.password = i
|
|
}
|
|
return (this.settings = o), I('_parseConnect: complete'), o
|
|
}
|
|
_parseConnack() {
|
|
I('_parseConnack')
|
|
let t = this.packet
|
|
if (this._list.length < 1) return null
|
|
if (
|
|
((t.sessionPresent = !!(
|
|
this._list.readUInt8(this._pos++) & j.SESSIONPRESENT_MASK
|
|
)),
|
|
this.settings.protocolVersion === 5)
|
|
)
|
|
this._list.length >= 2
|
|
? (t.reasonCode = this._list.readUInt8(this._pos++))
|
|
: (t.reasonCode = 0)
|
|
else {
|
|
if (this._list.length < 2) return null
|
|
t.returnCode = this._list.readUInt8(this._pos++)
|
|
}
|
|
if (t.returnCode === -1 || t.reasonCode === -1)
|
|
return this._emitError(new Error('Cannot parse return code'))
|
|
if (this.settings.protocolVersion === 5) {
|
|
let r = this._parseProperties()
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r)
|
|
}
|
|
I('_parseConnack: complete')
|
|
}
|
|
_parsePublish() {
|
|
I('_parsePublish')
|
|
let t = this.packet
|
|
if (((t.topic = this._parseString()), t.topic === null))
|
|
return this._emitError(new Error('Cannot parse topic'))
|
|
if (!(t.qos > 0 && !this._parseMessageId())) {
|
|
if (this.settings.protocolVersion === 5) {
|
|
let r = this._parseProperties()
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r)
|
|
}
|
|
;(t.payload = this._list.slice(this._pos, t.length)),
|
|
I('_parsePublish: payload from buffer list: %o', t.payload)
|
|
}
|
|
}
|
|
_parseSubscribe() {
|
|
I('_parseSubscribe')
|
|
let t = this.packet,
|
|
r,
|
|
i,
|
|
n,
|
|
s,
|
|
o,
|
|
f,
|
|
a
|
|
if (t.qos !== 1)
|
|
return this._emitError(new Error('Wrong subscribe header'))
|
|
if (((t.subscriptions = []), !!this._parseMessageId())) {
|
|
if (this.settings.protocolVersion === 5) {
|
|
let l = this._parseProperties()
|
|
Object.getOwnPropertyNames(l).length && (t.properties = l)
|
|
}
|
|
for (; this._pos < t.length; ) {
|
|
if (((r = this._parseString()), r === null))
|
|
return this._emitError(new Error('Cannot parse topic'))
|
|
if (this._pos >= t.length)
|
|
return this._emitError(new Error('Malformed Subscribe Payload'))
|
|
;(i = this._parseByte()),
|
|
(n = i & j.SUBSCRIBE_OPTIONS_QOS_MASK),
|
|
(f =
|
|
((i >> j.SUBSCRIBE_OPTIONS_NL_SHIFT) &
|
|
j.SUBSCRIBE_OPTIONS_NL_MASK) !==
|
|
0),
|
|
(o =
|
|
((i >> j.SUBSCRIBE_OPTIONS_RAP_SHIFT) &
|
|
j.SUBSCRIBE_OPTIONS_RAP_MASK) !==
|
|
0),
|
|
(s =
|
|
(i >> j.SUBSCRIBE_OPTIONS_RH_SHIFT) &
|
|
j.SUBSCRIBE_OPTIONS_RH_MASK),
|
|
(a = { topic: r, qos: n }),
|
|
this.settings.protocolVersion === 5
|
|
? ((a.nl = f), (a.rap = o), (a.rh = s))
|
|
: this.settings.bridgeMode &&
|
|
((a.rh = 0), (a.rap = !0), (a.nl = !0)),
|
|
I('_parseSubscribe: push subscription `%s` to subscription', a),
|
|
t.subscriptions.push(a)
|
|
}
|
|
}
|
|
}
|
|
_parseSuback() {
|
|
I('_parseSuback')
|
|
let t = this.packet
|
|
if (((this.packet.granted = []), !!this._parseMessageId())) {
|
|
if (this.settings.protocolVersion === 5) {
|
|
let r = this._parseProperties()
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r)
|
|
}
|
|
for (; this._pos < this.packet.length; )
|
|
this.packet.granted.push(this._list.readUInt8(this._pos++))
|
|
}
|
|
}
|
|
_parseUnsubscribe() {
|
|
I('_parseUnsubscribe')
|
|
let t = this.packet
|
|
if (((t.unsubscriptions = []), !!this._parseMessageId())) {
|
|
if (this.settings.protocolVersion === 5) {
|
|
let r = this._parseProperties()
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r)
|
|
}
|
|
for (; this._pos < t.length; ) {
|
|
let r = this._parseString()
|
|
if (r === null)
|
|
return this._emitError(new Error('Cannot parse topic'))
|
|
I('_parseUnsubscribe: push topic `%s` to unsubscriptions', r),
|
|
t.unsubscriptions.push(r)
|
|
}
|
|
}
|
|
}
|
|
_parseUnsuback() {
|
|
I('_parseUnsuback')
|
|
let t = this.packet
|
|
if (!this._parseMessageId())
|
|
return this._emitError(new Error('Cannot parse messageId'))
|
|
if (this.settings.protocolVersion === 5) {
|
|
let r = this._parseProperties()
|
|
for (
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r),
|
|
t.granted = [];
|
|
this._pos < this.packet.length;
|
|
|
|
)
|
|
this.packet.granted.push(this._list.readUInt8(this._pos++))
|
|
}
|
|
}
|
|
_parseConfirmation() {
|
|
I('_parseConfirmation: packet.cmd: `%s`', this.packet.cmd)
|
|
let t = this.packet
|
|
if (
|
|
(this._parseMessageId(),
|
|
this.settings.protocolVersion === 5 &&
|
|
(t.length > 2
|
|
? ((t.reasonCode = this._parseByte()),
|
|
I('_parseConfirmation: packet.reasonCode `%d`', t.reasonCode))
|
|
: (t.reasonCode = 0),
|
|
t.length > 3))
|
|
) {
|
|
let r = this._parseProperties()
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r)
|
|
}
|
|
return !0
|
|
}
|
|
_parseDisconnect() {
|
|
let t = this.packet
|
|
if ((I('_parseDisconnect'), this.settings.protocolVersion === 5)) {
|
|
this._list.length > 0
|
|
? (t.reasonCode = this._parseByte())
|
|
: (t.reasonCode = 0)
|
|
let r = this._parseProperties()
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r)
|
|
}
|
|
return I('_parseDisconnect result: true'), !0
|
|
}
|
|
_parseAuth() {
|
|
I('_parseAuth')
|
|
let t = this.packet
|
|
if (this.settings.protocolVersion !== 5)
|
|
return this._emitError(
|
|
new Error('Not supported auth packet for this version MQTT'),
|
|
)
|
|
t.reasonCode = this._parseByte()
|
|
let r = this._parseProperties()
|
|
return (
|
|
Object.getOwnPropertyNames(r).length && (t.properties = r),
|
|
I('_parseAuth: result: true'),
|
|
!0
|
|
)
|
|
}
|
|
_parseMessageId() {
|
|
let t = this.packet
|
|
return (
|
|
(t.messageId = this._parseNum()),
|
|
t.messageId === null
|
|
? (this._emitError(new Error('Cannot parse messageId')), !1)
|
|
: (I('_parseMessageId: packet.messageId %d', t.messageId), !0)
|
|
)
|
|
}
|
|
_parseString(t) {
|
|
let r = this._parseNum(),
|
|
i = r + this._pos
|
|
if (r === -1 || i > this._list.length || i > this.packet.length)
|
|
return null
|
|
let n = this._list.toString('utf8', this._pos, i)
|
|
return (this._pos += r), I('_parseString: result: %s', n), n
|
|
}
|
|
_parseStringPair() {
|
|
return (
|
|
I('_parseStringPair'),
|
|
{ name: this._parseString(), value: this._parseString() }
|
|
)
|
|
}
|
|
_parseBuffer() {
|
|
let t = this._parseNum(),
|
|
r = t + this._pos
|
|
if (t === -1 || r > this._list.length || r > this.packet.length)
|
|
return null
|
|
let i = this._list.slice(this._pos, r)
|
|
return (this._pos += t), I('_parseBuffer: result: %o', i), i
|
|
}
|
|
_parseNum() {
|
|
if (this._list.length - this._pos < 2) return -1
|
|
let t = this._list.readUInt16BE(this._pos)
|
|
return (this._pos += 2), I('_parseNum: result: %s', t), t
|
|
}
|
|
_parse4ByteNum() {
|
|
if (this._list.length - this._pos < 4) return -1
|
|
let t = this._list.readUInt32BE(this._pos)
|
|
return (this._pos += 4), I('_parse4ByteNum: result: %s', t), t
|
|
}
|
|
_parseVarByteNum(t) {
|
|
I('_parseVarByteNum')
|
|
let r = 4,
|
|
i = 0,
|
|
n = 1,
|
|
s = 0,
|
|
o = !1,
|
|
f,
|
|
a = this._pos ? this._pos : 0
|
|
for (; i < r && a + i < this._list.length; ) {
|
|
if (
|
|
((f = this._list.readUInt8(a + i++)),
|
|
(s += n * (f & j.VARBYTEINT_MASK)),
|
|
(n *= 128),
|
|
!(f & j.VARBYTEINT_FIN_MASK))
|
|
) {
|
|
o = !0
|
|
break
|
|
}
|
|
if (this._list.length <= i) break
|
|
}
|
|
return (
|
|
!o &&
|
|
i === r &&
|
|
this._list.length >= i &&
|
|
this._emitError(new Error('Invalid variable byte integer')),
|
|
a && (this._pos += i),
|
|
(o = o ? (t ? { bytes: i, value: s } : s) : !1),
|
|
I('_parseVarByteNum: result: %o', o),
|
|
o
|
|
)
|
|
}
|
|
_parseByte() {
|
|
let t
|
|
return (
|
|
this._pos < this._list.length &&
|
|
((t = this._list.readUInt8(this._pos)), this._pos++),
|
|
I('_parseByte: result: %o', t),
|
|
t
|
|
)
|
|
}
|
|
_parseByType(t) {
|
|
switch ((I('_parseByType: type: %s', t), t)) {
|
|
case 'byte':
|
|
return this._parseByte() !== 0
|
|
case 'int8':
|
|
return this._parseByte()
|
|
case 'int16':
|
|
return this._parseNum()
|
|
case 'int32':
|
|
return this._parse4ByteNum()
|
|
case 'var':
|
|
return this._parseVarByteNum()
|
|
case 'string':
|
|
return this._parseString()
|
|
case 'pair':
|
|
return this._parseStringPair()
|
|
case 'binary':
|
|
return this._parseBuffer()
|
|
}
|
|
}
|
|
_parseProperties() {
|
|
I('_parseProperties')
|
|
let t = this._parseVarByteNum(),
|
|
i = this._pos + t,
|
|
n = {}
|
|
for (; this._pos < i; ) {
|
|
let s = this._parseByte()
|
|
if (!s)
|
|
return (
|
|
this._emitError(new Error('Cannot parse property code type')), !1
|
|
)
|
|
let o = j.propertiesCodes[s]
|
|
if (!o) return this._emitError(new Error('Unknown property')), !1
|
|
if (o === 'userProperties') {
|
|
n[o] || (n[o] = Object.create(null))
|
|
let f = this._parseByType(j.propertiesTypes[o])
|
|
if (n[o][f.name])
|
|
if (Array.isArray(n[o][f.name])) n[o][f.name].push(f.value)
|
|
else {
|
|
let a = n[o][f.name]
|
|
;(n[o][f.name] = [a]), n[o][f.name].push(f.value)
|
|
}
|
|
else n[o][f.name] = f.value
|
|
continue
|
|
}
|
|
n[o]
|
|
? Array.isArray(n[o])
|
|
? n[o].push(this._parseByType(j.propertiesTypes[o]))
|
|
: ((n[o] = [n[o]]),
|
|
n[o].push(this._parseByType(j.propertiesTypes[o])))
|
|
: (n[o] = this._parseByType(j.propertiesTypes[o]))
|
|
}
|
|
return n
|
|
}
|
|
_newPacket() {
|
|
return (
|
|
I('_newPacket'),
|
|
this.packet &&
|
|
(this._list.consume(this.packet.length),
|
|
I(
|
|
'_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d',
|
|
this.packet.cmd,
|
|
this.packet.payload,
|
|
this.packet.length,
|
|
),
|
|
this.emit('packet', this.packet)),
|
|
I('_newPacket: new packet'),
|
|
(this.packet = new za()),
|
|
(this._pos = 0),
|
|
!0
|
|
)
|
|
}
|
|
_emitError(t) {
|
|
I('_emitError'), (this.error = t), this.emit('error', t)
|
|
}
|
|
}
|
|
Ka.exports = qn
|
|
})
|
|
var Za = b((fw, Xa) => {
|
|
var Qa = {},
|
|
Qp = Buffer.isBuffer(Buffer.from([1, 2]).subarray(0, 1))
|
|
function Ja(e) {
|
|
let t = Buffer.allocUnsafe(2)
|
|
return t.writeUInt8(e >> 8, 0), t.writeUInt8(e & 255, 1), t
|
|
}
|
|
function Jp() {
|
|
for (let e = 0; e < 65536; e++) Qa[e] = Ja(e)
|
|
}
|
|
function Xp(e) {
|
|
let r = 0,
|
|
i = 0,
|
|
n = Buffer.allocUnsafe(4)
|
|
do
|
|
(r = e % 128 | 0),
|
|
(e = (e / 128) | 0),
|
|
e > 0 && (r = r | 128),
|
|
n.writeUInt8(r, i++)
|
|
while (e > 0 && i < 4)
|
|
return e > 0 && (i = 0), Qp ? n.subarray(0, i) : n.slice(0, i)
|
|
}
|
|
function Zp(e) {
|
|
let t = Buffer.allocUnsafe(4)
|
|
return t.writeUInt32BE(e, 0), t
|
|
}
|
|
Xa.exports = {
|
|
cache: Qa,
|
|
generateCache: Jp,
|
|
generateNumber: Ja,
|
|
genBufVariableByteInt: Xp,
|
|
generate4ByteBuffer: Zp,
|
|
}
|
|
})
|
|
var Ot = b((lw, Dn) => {
|
|
'use strict'
|
|
typeof process > 'u' ||
|
|
!process.version ||
|
|
process.version.indexOf('v0.') === 0 ||
|
|
(process.version.indexOf('v1.') === 0 &&
|
|
process.version.indexOf('v1.8.') !== 0)
|
|
? (Dn.exports = { nextTick: e_ })
|
|
: (Dn.exports = process)
|
|
function e_(e, t, r, i) {
|
|
if (typeof e != 'function')
|
|
throw new TypeError('"callback" argument must be a function')
|
|
var n = arguments.length,
|
|
s,
|
|
o
|
|
switch (n) {
|
|
case 0:
|
|
case 1:
|
|
return process.nextTick(e)
|
|
case 2:
|
|
return process.nextTick(function () {
|
|
e.call(null, t)
|
|
})
|
|
case 3:
|
|
return process.nextTick(function () {
|
|
e.call(null, t, r)
|
|
})
|
|
case 4:
|
|
return process.nextTick(function () {
|
|
e.call(null, t, r, i)
|
|
})
|
|
default:
|
|
for (s = new Array(n - 1), o = 0; o < s.length; ) s[o++] = arguments[o]
|
|
return process.nextTick(function () {
|
|
e.apply(null, s)
|
|
})
|
|
}
|
|
}
|
|
})
|
|
var Fn = b((uw, ff) => {
|
|
var k = An(),
|
|
t_ = Buffer.allocUnsafe(0),
|
|
r_ = Buffer.from([0]),
|
|
Qt = Za(),
|
|
i_ = Ot().nextTick,
|
|
_e = ze()('mqtt-packet:writeToStream'),
|
|
ni = Qt.cache,
|
|
n_ = Qt.generateNumber,
|
|
s_ = Qt.generateCache,
|
|
Un = Qt.genBufVariableByteInt,
|
|
o_ = Qt.generate4ByteBuffer,
|
|
ne = jn,
|
|
si = !0
|
|
function of(e, t, r) {
|
|
switch (
|
|
(_e('generate called'),
|
|
t.cork && (t.cork(), i_(a_, t)),
|
|
si && ((si = !1), s_()),
|
|
_e('generate: packet.cmd: %s', e.cmd),
|
|
e.cmd)
|
|
) {
|
|
case 'connect':
|
|
return f_(e, t, r)
|
|
case 'connack':
|
|
return l_(e, t, r)
|
|
case 'publish':
|
|
return u_(e, t, r)
|
|
case 'puback':
|
|
case 'pubrec':
|
|
case 'pubrel':
|
|
case 'pubcomp':
|
|
return c_(e, t, r)
|
|
case 'subscribe':
|
|
return h_(e, t, r)
|
|
case 'suback':
|
|
return d_(e, t, r)
|
|
case 'unsubscribe':
|
|
return p_(e, t, r)
|
|
case 'unsuback':
|
|
return __(e, t, r)
|
|
case 'pingreq':
|
|
case 'pingresp':
|
|
return g_(e, t, r)
|
|
case 'disconnect':
|
|
return b_(e, t, r)
|
|
case 'auth':
|
|
return y_(e, t, r)
|
|
default:
|
|
return t.emit('error', new Error('Unknown command')), !1
|
|
}
|
|
}
|
|
Object.defineProperty(of, 'cacheNumbers', {
|
|
get() {
|
|
return ne === jn
|
|
},
|
|
set(e) {
|
|
e
|
|
? ((!ni || Object.keys(ni).length === 0) && (si = !0), (ne = jn))
|
|
: ((si = !1), (ne = v_))
|
|
},
|
|
})
|
|
function a_(e) {
|
|
e.uncork()
|
|
}
|
|
function f_(e, t, r) {
|
|
let i = e || {},
|
|
n = i.protocolId || 'MQTT',
|
|
s = i.protocolVersion || 4,
|
|
o = i.will,
|
|
f = i.clean,
|
|
a = i.keepalive || 0,
|
|
l = i.clientId || '',
|
|
u = i.username,
|
|
h = i.password,
|
|
c = i.properties
|
|
f === void 0 && (f = !0)
|
|
let d = 0
|
|
if (!n || (typeof n != 'string' && !Buffer.isBuffer(n)))
|
|
return t.emit('error', new Error('Invalid protocolId')), !1
|
|
if (((d += n.length + 2), s !== 3 && s !== 4 && s !== 5))
|
|
return t.emit('error', new Error('Invalid protocol version')), !1
|
|
if (
|
|
((d += 1),
|
|
(typeof l == 'string' || Buffer.isBuffer(l)) && (l || s >= 4) && (l || f))
|
|
)
|
|
d += Buffer.byteLength(l) + 2
|
|
else {
|
|
if (s < 4)
|
|
return (
|
|
t.emit('error', new Error('clientId must be supplied before 3.1.1')),
|
|
!1
|
|
)
|
|
if (f * 1 === 0)
|
|
return (
|
|
t.emit(
|
|
'error',
|
|
new Error('clientId must be given if cleanSession set to 0'),
|
|
),
|
|
!1
|
|
)
|
|
}
|
|
if (typeof a != 'number' || a < 0 || a > 65535 || a % 1 !== 0)
|
|
return t.emit('error', new Error('Invalid keepalive')), !1
|
|
if (((d += 2), (d += 1), s === 5)) {
|
|
var _ = Ke(t, c)
|
|
if (!_) return !1
|
|
d += _.length
|
|
}
|
|
if (o) {
|
|
if (typeof o != 'object')
|
|
return t.emit('error', new Error('Invalid will')), !1
|
|
if (!o.topic || typeof o.topic != 'string')
|
|
return t.emit('error', new Error('Invalid will topic')), !1
|
|
if (((d += Buffer.byteLength(o.topic) + 2), (d += 2), o.payload))
|
|
if (o.payload.length >= 0)
|
|
typeof o.payload == 'string'
|
|
? (d += Buffer.byteLength(o.payload))
|
|
: (d += o.payload.length)
|
|
else return t.emit('error', new Error('Invalid will payload')), !1
|
|
var v = {}
|
|
if (s === 5) {
|
|
if (((v = Ke(t, o.properties)), !v)) return !1
|
|
d += v.length
|
|
}
|
|
}
|
|
let m = !1
|
|
if (u != null)
|
|
if (sf(u)) (m = !0), (d += Buffer.byteLength(u) + 2)
|
|
else return t.emit('error', new Error('Invalid username')), !1
|
|
if (h != null) {
|
|
if (!m)
|
|
return (
|
|
t.emit('error', new Error('Username is required to use password')), !1
|
|
)
|
|
if (sf(h)) d += af(h) + 2
|
|
else return t.emit('error', new Error('Invalid password')), !1
|
|
}
|
|
t.write(k.CONNECT_HEADER),
|
|
ge(t, d),
|
|
kt(t, n),
|
|
i.bridgeMode && (s += 128),
|
|
t.write(
|
|
s === 131
|
|
? k.VERSION131
|
|
: s === 132
|
|
? k.VERSION132
|
|
: s === 4
|
|
? k.VERSION4
|
|
: s === 5
|
|
? k.VERSION5
|
|
: k.VERSION3,
|
|
)
|
|
let p = 0
|
|
return (
|
|
(p |= u != null ? k.USERNAME_MASK : 0),
|
|
(p |= h != null ? k.PASSWORD_MASK : 0),
|
|
(p |= o && o.retain ? k.WILL_RETAIN_MASK : 0),
|
|
(p |= o && o.qos ? o.qos << k.WILL_QOS_SHIFT : 0),
|
|
(p |= o ? k.WILL_FLAG_MASK : 0),
|
|
(p |= f ? k.CLEAN_SESSION_MASK : 0),
|
|
t.write(Buffer.from([p])),
|
|
ne(t, a),
|
|
s === 5 && _.write(),
|
|
kt(t, l),
|
|
o && (s === 5 && v.write(), lt(t, o.topic), kt(t, o.payload)),
|
|
u != null && kt(t, u),
|
|
h != null && kt(t, h),
|
|
!0
|
|
)
|
|
}
|
|
function l_(e, t, r) {
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = i === 5 ? n.reasonCode : n.returnCode,
|
|
o = n.properties,
|
|
f = 2
|
|
if (typeof s != 'number')
|
|
return t.emit('error', new Error('Invalid return code')), !1
|
|
let a = null
|
|
if (i === 5) {
|
|
if (((a = Ke(t, o)), !a)) return !1
|
|
f += a.length
|
|
}
|
|
return (
|
|
t.write(k.CONNACK_HEADER),
|
|
ge(t, f),
|
|
t.write(n.sessionPresent ? k.SESSIONPRESENT_HEADER : r_),
|
|
t.write(Buffer.from([s])),
|
|
a?.write(),
|
|
!0
|
|
)
|
|
}
|
|
function u_(e, t, r) {
|
|
_e('publish: packet: %o', e)
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.qos || 0,
|
|
o = n.retain ? k.RETAIN_MASK : 0,
|
|
f = n.topic,
|
|
a = n.payload || t_,
|
|
l = n.messageId,
|
|
u = n.properties,
|
|
h = 0
|
|
if (typeof f == 'string') h += Buffer.byteLength(f) + 2
|
|
else if (Buffer.isBuffer(f)) h += f.length + 2
|
|
else return t.emit('error', new Error('Invalid topic')), !1
|
|
if (
|
|
(Buffer.isBuffer(a) ? (h += a.length) : (h += Buffer.byteLength(a)),
|
|
s && typeof l != 'number')
|
|
)
|
|
return t.emit('error', new Error('Invalid messageId')), !1
|
|
s && (h += 2)
|
|
let c = null
|
|
if (i === 5) {
|
|
if (((c = Ke(t, u)), !c)) return !1
|
|
h += c.length
|
|
}
|
|
return (
|
|
t.write(k.PUBLISH_HEADER[s][n.dup ? 1 : 0][o ? 1 : 0]),
|
|
ge(t, h),
|
|
ne(t, af(f)),
|
|
t.write(f),
|
|
s > 0 && ne(t, l),
|
|
c?.write(),
|
|
_e('publish: payload: %o', a),
|
|
t.write(a)
|
|
)
|
|
}
|
|
function c_(e, t, r) {
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.cmd || 'puback',
|
|
o = n.messageId,
|
|
f = n.dup && s === 'pubrel' ? k.DUP_MASK : 0,
|
|
a = 0,
|
|
l = n.reasonCode,
|
|
u = n.properties,
|
|
h = i === 5 ? 3 : 2
|
|
if ((s === 'pubrel' && (a = 1), typeof o != 'number'))
|
|
return t.emit('error', new Error('Invalid messageId')), !1
|
|
let c = null
|
|
if (i === 5 && typeof u == 'object') {
|
|
if (((c = Jt(t, u, r, h)), !c)) return !1
|
|
h += c.length
|
|
}
|
|
return (
|
|
t.write(k.ACKS[s][a][f][0]),
|
|
ge(t, h),
|
|
ne(t, o),
|
|
i === 5 && t.write(Buffer.from([l])),
|
|
c !== null && c.write(),
|
|
!0
|
|
)
|
|
}
|
|
function h_(e, t, r) {
|
|
_e('subscribe: packet: ')
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.dup ? k.DUP_MASK : 0,
|
|
o = n.messageId,
|
|
f = n.subscriptions,
|
|
a = n.properties,
|
|
l = 0
|
|
if (typeof o != 'number')
|
|
return t.emit('error', new Error('Invalid messageId')), !1
|
|
l += 2
|
|
let u = null
|
|
if (i === 5) {
|
|
if (((u = Ke(t, a)), !u)) return !1
|
|
l += u.length
|
|
}
|
|
if (typeof f == 'object' && f.length)
|
|
for (let c = 0; c < f.length; c += 1) {
|
|
let d = f[c].topic,
|
|
_ = f[c].qos
|
|
if (typeof d != 'string')
|
|
return (
|
|
t.emit('error', new Error('Invalid subscriptions - invalid topic')),
|
|
!1
|
|
)
|
|
if (typeof _ != 'number')
|
|
return (
|
|
t.emit('error', new Error('Invalid subscriptions - invalid qos')),
|
|
!1
|
|
)
|
|
if (i === 5) {
|
|
if (typeof (f[c].nl || !1) != 'boolean')
|
|
return (
|
|
t.emit(
|
|
'error',
|
|
new Error('Invalid subscriptions - invalid No Local'),
|
|
),
|
|
!1
|
|
)
|
|
if (typeof (f[c].rap || !1) != 'boolean')
|
|
return (
|
|
t.emit(
|
|
'error',
|
|
new Error(
|
|
'Invalid subscriptions - invalid Retain as Published',
|
|
),
|
|
),
|
|
!1
|
|
)
|
|
let p = f[c].rh || 0
|
|
if (typeof p != 'number' || p > 2)
|
|
return (
|
|
t.emit(
|
|
'error',
|
|
new Error('Invalid subscriptions - invalid Retain Handling'),
|
|
),
|
|
!1
|
|
)
|
|
}
|
|
l += Buffer.byteLength(d) + 2 + 1
|
|
}
|
|
else return t.emit('error', new Error('Invalid subscriptions')), !1
|
|
_e('subscribe: writing to stream: %o', k.SUBSCRIBE_HEADER),
|
|
t.write(k.SUBSCRIBE_HEADER[1][s ? 1 : 0][0]),
|
|
ge(t, l),
|
|
ne(t, o),
|
|
u !== null && u.write()
|
|
let h = !0
|
|
for (let c of f) {
|
|
let d = c.topic,
|
|
_ = c.qos,
|
|
v = +c.nl,
|
|
m = +c.rap,
|
|
p = c.rh,
|
|
g
|
|
lt(t, d),
|
|
(g = k.SUBSCRIBE_OPTIONS_QOS[_]),
|
|
i === 5 &&
|
|
((g |= v ? k.SUBSCRIBE_OPTIONS_NL : 0),
|
|
(g |= m ? k.SUBSCRIBE_OPTIONS_RAP : 0),
|
|
(g |= p ? k.SUBSCRIBE_OPTIONS_RH[p] : 0)),
|
|
(h = t.write(Buffer.from([g])))
|
|
}
|
|
return h
|
|
}
|
|
function d_(e, t, r) {
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.messageId,
|
|
o = n.granted,
|
|
f = n.properties,
|
|
a = 0
|
|
if (typeof s != 'number')
|
|
return t.emit('error', new Error('Invalid messageId')), !1
|
|
if (((a += 2), typeof o == 'object' && o.length))
|
|
for (let u = 0; u < o.length; u += 1) {
|
|
if (typeof o[u] != 'number')
|
|
return t.emit('error', new Error('Invalid qos vector')), !1
|
|
a += 1
|
|
}
|
|
else return t.emit('error', new Error('Invalid qos vector')), !1
|
|
let l = null
|
|
if (i === 5) {
|
|
if (((l = Jt(t, f, r, a)), !l)) return !1
|
|
a += l.length
|
|
}
|
|
return (
|
|
t.write(k.SUBACK_HEADER),
|
|
ge(t, a),
|
|
ne(t, s),
|
|
l !== null && l.write(),
|
|
t.write(Buffer.from(o))
|
|
)
|
|
}
|
|
function p_(e, t, r) {
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.messageId,
|
|
o = n.dup ? k.DUP_MASK : 0,
|
|
f = n.unsubscriptions,
|
|
a = n.properties,
|
|
l = 0
|
|
if (typeof s != 'number')
|
|
return t.emit('error', new Error('Invalid messageId')), !1
|
|
if (((l += 2), typeof f == 'object' && f.length))
|
|
for (let c = 0; c < f.length; c += 1) {
|
|
if (typeof f[c] != 'string')
|
|
return t.emit('error', new Error('Invalid unsubscriptions')), !1
|
|
l += Buffer.byteLength(f[c]) + 2
|
|
}
|
|
else return t.emit('error', new Error('Invalid unsubscriptions')), !1
|
|
let u = null
|
|
if (i === 5) {
|
|
if (((u = Ke(t, a)), !u)) return !1
|
|
l += u.length
|
|
}
|
|
t.write(k.UNSUBSCRIBE_HEADER[1][o ? 1 : 0][0]),
|
|
ge(t, l),
|
|
ne(t, s),
|
|
u !== null && u.write()
|
|
let h = !0
|
|
for (let c = 0; c < f.length; c++) h = lt(t, f[c])
|
|
return h
|
|
}
|
|
function __(e, t, r) {
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.messageId,
|
|
o = n.dup ? k.DUP_MASK : 0,
|
|
f = n.granted,
|
|
a = n.properties,
|
|
l = n.cmd,
|
|
u = 0,
|
|
h = 2
|
|
if (typeof s != 'number')
|
|
return t.emit('error', new Error('Invalid messageId')), !1
|
|
if (i === 5)
|
|
if (typeof f == 'object' && f.length)
|
|
for (let d = 0; d < f.length; d += 1) {
|
|
if (typeof f[d] != 'number')
|
|
return t.emit('error', new Error('Invalid qos vector')), !1
|
|
h += 1
|
|
}
|
|
else return t.emit('error', new Error('Invalid qos vector')), !1
|
|
let c = null
|
|
if (i === 5) {
|
|
if (((c = Jt(t, a, r, h)), !c)) return !1
|
|
h += c.length
|
|
}
|
|
return (
|
|
t.write(k.ACKS[l][u][o][0]),
|
|
ge(t, h),
|
|
ne(t, s),
|
|
c !== null && c.write(),
|
|
i === 5 && t.write(Buffer.from(f)),
|
|
!0
|
|
)
|
|
}
|
|
function g_(e, t, r) {
|
|
return t.write(k.EMPTY[e.cmd])
|
|
}
|
|
function b_(e, t, r) {
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.reasonCode,
|
|
o = n.properties,
|
|
f = i === 5 ? 1 : 0,
|
|
a = null
|
|
if (i === 5) {
|
|
if (((a = Jt(t, o, r, f)), !a)) return !1
|
|
f += a.length
|
|
}
|
|
return (
|
|
t.write(Buffer.from([k.codes.disconnect << 4])),
|
|
ge(t, f),
|
|
i === 5 && t.write(Buffer.from([s])),
|
|
a !== null && a.write(),
|
|
!0
|
|
)
|
|
}
|
|
function y_(e, t, r) {
|
|
let i = r ? r.protocolVersion : 4,
|
|
n = e || {},
|
|
s = n.reasonCode,
|
|
o = n.properties,
|
|
f = i === 5 ? 1 : 0
|
|
i !== 5 &&
|
|
t.emit('error', new Error('Invalid mqtt version for auth packet'))
|
|
let a = Jt(t, o, r, f)
|
|
return a
|
|
? ((f += a.length),
|
|
t.write(Buffer.from([k.codes.auth << 4])),
|
|
ge(t, f),
|
|
t.write(Buffer.from([s])),
|
|
a !== null && a.write(),
|
|
!0)
|
|
: !1
|
|
}
|
|
var ef = {}
|
|
function ge(e, t) {
|
|
if (t > k.VARBYTEINT_MAX)
|
|
return (
|
|
e.emit('error', new Error(`Invalid variable byte integer: ${t}`)), !1
|
|
)
|
|
let r = ef[t]
|
|
return (
|
|
r || ((r = Un(t)), t < 16384 && (ef[t] = r)),
|
|
_e('writeVarByteInt: writing to stream: %o', r),
|
|
e.write(r)
|
|
)
|
|
}
|
|
function lt(e, t) {
|
|
let r = Buffer.byteLength(t)
|
|
return ne(e, r), _e('writeString: %s', t), e.write(t, 'utf8')
|
|
}
|
|
function tf(e, t, r) {
|
|
lt(e, t), lt(e, r)
|
|
}
|
|
function jn(e, t) {
|
|
return (
|
|
_e('writeNumberCached: number: %d', t),
|
|
_e('writeNumberCached: %o', ni[t]),
|
|
e.write(ni[t])
|
|
)
|
|
}
|
|
function v_(e, t) {
|
|
let r = n_(t)
|
|
return _e('writeNumberGenerated: %o', r), e.write(r)
|
|
}
|
|
function m_(e, t) {
|
|
let r = o_(t)
|
|
return _e('write4ByteNumber: %o', r), e.write(r)
|
|
}
|
|
function kt(e, t) {
|
|
typeof t == 'string'
|
|
? lt(e, t)
|
|
: t
|
|
? (ne(e, t.length), e.write(t))
|
|
: ne(e, 0)
|
|
}
|
|
function Ke(e, t) {
|
|
if (typeof t != 'object' || t.length != null)
|
|
return {
|
|
length: 1,
|
|
write() {
|
|
nf(e, {}, 0)
|
|
},
|
|
}
|
|
let r = 0
|
|
function i(s, o) {
|
|
let f = k.propertiesTypes[s],
|
|
a = 0
|
|
switch (f) {
|
|
case 'byte': {
|
|
if (typeof o != 'boolean')
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += 2
|
|
break
|
|
}
|
|
case 'int8': {
|
|
if (typeof o != 'number' || o < 0 || o > 255)
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += 2
|
|
break
|
|
}
|
|
case 'binary': {
|
|
if (o && o === null)
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += 1 + Buffer.byteLength(o) + 2
|
|
break
|
|
}
|
|
case 'int16': {
|
|
if (typeof o != 'number' || o < 0 || o > 65535)
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += 3
|
|
break
|
|
}
|
|
case 'int32': {
|
|
if (typeof o != 'number' || o < 0 || o > 4294967295)
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += 5
|
|
break
|
|
}
|
|
case 'var': {
|
|
if (typeof o != 'number' || o < 0 || o > 268435455)
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += 1 + Buffer.byteLength(Un(o))
|
|
break
|
|
}
|
|
case 'string': {
|
|
if (typeof o != 'string')
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += 3 + Buffer.byteLength(o.toString())
|
|
break
|
|
}
|
|
case 'pair': {
|
|
if (typeof o != 'object')
|
|
return e.emit('error', new Error(`Invalid ${s}: ${o}`)), !1
|
|
a += Object.getOwnPropertyNames(o).reduce((l, u) => {
|
|
let h = o[u]
|
|
return (
|
|
Array.isArray(h)
|
|
? (l += h.reduce(
|
|
(c, d) => (
|
|
(c +=
|
|
3 +
|
|
Buffer.byteLength(u.toString()) +
|
|
2 +
|
|
Buffer.byteLength(d.toString())),
|
|
c
|
|
),
|
|
0,
|
|
))
|
|
: (l +=
|
|
3 +
|
|
Buffer.byteLength(u.toString()) +
|
|
2 +
|
|
Buffer.byteLength(o[u].toString())),
|
|
l
|
|
)
|
|
}, 0)
|
|
break
|
|
}
|
|
default:
|
|
return e.emit('error', new Error(`Invalid property ${s}: ${o}`)), !1
|
|
}
|
|
return a
|
|
}
|
|
if (t)
|
|
for (let s in t) {
|
|
let o = 0,
|
|
f = 0,
|
|
a = t[s]
|
|
if (Array.isArray(a))
|
|
for (let l = 0; l < a.length; l++) {
|
|
if (((f = i(s, a[l])), !f)) return !1
|
|
o += f
|
|
}
|
|
else {
|
|
if (((f = i(s, a)), !f)) return !1
|
|
o = f
|
|
}
|
|
if (!o) return !1
|
|
r += o
|
|
}
|
|
return {
|
|
length: Buffer.byteLength(Un(r)) + r,
|
|
write() {
|
|
nf(e, t, r)
|
|
},
|
|
}
|
|
}
|
|
function Jt(e, t, r, i) {
|
|
let n = ['reasonString', 'userProperties'],
|
|
s =
|
|
r && r.properties && r.properties.maximumPacketSize
|
|
? r.properties.maximumPacketSize
|
|
: 0,
|
|
o = Ke(e, t)
|
|
if (s)
|
|
for (; i + o.length > s; ) {
|
|
let f = n.shift()
|
|
if (f && t[f]) delete t[f], (o = Ke(e, t))
|
|
else return !1
|
|
}
|
|
return o
|
|
}
|
|
function rf(e, t, r) {
|
|
switch (k.propertiesTypes[t]) {
|
|
case 'byte': {
|
|
e.write(Buffer.from([k.properties[t]])), e.write(Buffer.from([+r]))
|
|
break
|
|
}
|
|
case 'int8': {
|
|
e.write(Buffer.from([k.properties[t]])), e.write(Buffer.from([r]))
|
|
break
|
|
}
|
|
case 'binary': {
|
|
e.write(Buffer.from([k.properties[t]])), kt(e, r)
|
|
break
|
|
}
|
|
case 'int16': {
|
|
e.write(Buffer.from([k.properties[t]])), ne(e, r)
|
|
break
|
|
}
|
|
case 'int32': {
|
|
e.write(Buffer.from([k.properties[t]])), m_(e, r)
|
|
break
|
|
}
|
|
case 'var': {
|
|
e.write(Buffer.from([k.properties[t]])), ge(e, r)
|
|
break
|
|
}
|
|
case 'string': {
|
|
e.write(Buffer.from([k.properties[t]])), lt(e, r)
|
|
break
|
|
}
|
|
case 'pair': {
|
|
Object.getOwnPropertyNames(r).forEach((n) => {
|
|
let s = r[n]
|
|
Array.isArray(s)
|
|
? s.forEach((o) => {
|
|
e.write(Buffer.from([k.properties[t]])),
|
|
tf(e, n.toString(), o.toString())
|
|
})
|
|
: (e.write(Buffer.from([k.properties[t]])),
|
|
tf(e, n.toString(), s.toString()))
|
|
})
|
|
break
|
|
}
|
|
default:
|
|
return (
|
|
e.emit('error', new Error(`Invalid property ${t} value: ${r}`)), !1
|
|
)
|
|
}
|
|
}
|
|
function nf(e, t, r) {
|
|
ge(e, r)
|
|
for (let i in t)
|
|
if (Object.prototype.hasOwnProperty.call(t, i) && t[i] !== null) {
|
|
let n = t[i]
|
|
if (Array.isArray(n)) for (let s = 0; s < n.length; s++) rf(e, i, n[s])
|
|
else rf(e, i, n)
|
|
}
|
|
}
|
|
function af(e) {
|
|
return e ? (e instanceof Buffer ? e.length : Buffer.byteLength(e)) : 0
|
|
}
|
|
function sf(e) {
|
|
return typeof e == 'string' || e instanceof Buffer
|
|
}
|
|
ff.exports = of
|
|
})
|
|
var uf = b((cw, lf) => {
|
|
var w_ = Fn(),
|
|
S_ = require('events')
|
|
function E_(e, t) {
|
|
let r = new Wn()
|
|
return w_(e, r, t), r.concat()
|
|
}
|
|
var Wn = class extends S_ {
|
|
constructor() {
|
|
super(), (this._array = new Array(20)), (this._i = 0)
|
|
}
|
|
write(t) {
|
|
return (this._array[this._i++] = t), !0
|
|
}
|
|
concat() {
|
|
let t = 0,
|
|
r = new Array(this._array.length),
|
|
i = this._array,
|
|
n = 0,
|
|
s
|
|
for (s = 0; s < i.length && i[s] !== void 0; s++)
|
|
typeof i[s] != 'string'
|
|
? (r[s] = i[s].length)
|
|
: (r[s] = Buffer.byteLength(i[s])),
|
|
(t += r[s])
|
|
let o = Buffer.allocUnsafe(t)
|
|
for (s = 0; s < i.length && i[s] !== void 0; s++)
|
|
typeof i[s] != 'string'
|
|
? (i[s].copy(o, n), (n += r[s]))
|
|
: (o.write(i[s], n), (n += r[s]))
|
|
return o
|
|
}
|
|
}
|
|
lf.exports = E_
|
|
})
|
|
var cf = b((oi) => {
|
|
oi.parser = Ya().parser
|
|
oi.generate = uf()
|
|
oi.writeToStream = Fn()
|
|
})
|
|
var df = b((dw, hf) => {
|
|
'use strict'
|
|
function x_(e, t, r) {
|
|
var i = this
|
|
;(this._callback = e),
|
|
(this._args = r),
|
|
(this._interval = setInterval(e, t, this._args)),
|
|
(this.reschedule = function (n) {
|
|
n || (n = i._interval),
|
|
i._interval && clearInterval(i._interval),
|
|
(i._interval = setInterval(i._callback, n, i._args))
|
|
}),
|
|
(this.clear = function () {
|
|
i._interval && (clearInterval(i._interval), (i._interval = void 0))
|
|
}),
|
|
(this.destroy = function () {
|
|
i._interval && clearInterval(i._interval),
|
|
(i._callback = void 0),
|
|
(i._interval = void 0),
|
|
(i._args = void 0)
|
|
})
|
|
}
|
|
function C_() {
|
|
if (typeof arguments[0] != 'function') throw new Error('callback needed')
|
|
if (typeof arguments[1] != 'number') throw new Error('interval needed')
|
|
var e
|
|
if (arguments.length > 0) {
|
|
e = new Array(arguments.length - 2)
|
|
for (var t = 0; t < e.length; t++) e[t] = arguments[t + 2]
|
|
}
|
|
return new x_(arguments[0], arguments[1], e)
|
|
}
|
|
hf.exports = C_
|
|
})
|
|
var _f = b((pw, pf) => {
|
|
'use strict'
|
|
function T_(e) {
|
|
for (var t = e.split('/'), r = 0; r < t.length; r++)
|
|
if (t[r] !== '+') {
|
|
if (t[r] === '#') return r === t.length - 1
|
|
if (t[r].indexOf('+') !== -1 || t[r].indexOf('#') !== -1) return !1
|
|
}
|
|
return !0
|
|
}
|
|
function I_(e) {
|
|
if (e.length === 0) return 'empty_topic_list'
|
|
for (var t = 0; t < e.length; t++) if (!T_(e[t])) return e[t]
|
|
return null
|
|
}
|
|
pf.exports = { validateTopics: I_ }
|
|
})
|
|
var $n = b((_w, wf) => {
|
|
'use strict'
|
|
var yf = require('events').EventEmitter,
|
|
ai = Jr(),
|
|
vf = cf(),
|
|
O_ = He().Writable,
|
|
k_ = ie(),
|
|
R_ = df(),
|
|
P_ = _f(),
|
|
fi = Mr(),
|
|
y = ze()('mqttjs:client'),
|
|
Hn = process
|
|
? process.nextTick
|
|
: function (e) {
|
|
setTimeout(e, 0)
|
|
},
|
|
mf =
|
|
global.setImmediate ||
|
|
function (e) {
|
|
Hn(e)
|
|
},
|
|
gf = {
|
|
keepalive: 60,
|
|
reschedulePings: !0,
|
|
protocolId: 'MQTT',
|
|
protocolVersion: 4,
|
|
reconnectPeriod: 1e3,
|
|
connectTimeout: 30 * 1e3,
|
|
clean: !0,
|
|
resubscribe: !0,
|
|
},
|
|
B_ = ['ECONNREFUSED', 'EADDRINUSE', 'ECONNRESET', 'ENOTFOUND'],
|
|
Vn = {
|
|
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',
|
|
}
|
|
function A_() {
|
|
return 'mqttjs_' + Math.random().toString(16).substr(2, 8)
|
|
}
|
|
function Xt(e, t, r) {
|
|
y('sendPacket :: packet: %O', t),
|
|
y('sendPacket :: emitting `packetsend`'),
|
|
e.emit('packetsend', t),
|
|
y('sendPacket :: writing to stream')
|
|
var i = vf.writeToStream(t, e.stream, e.options)
|
|
y('sendPacket :: writeToStream result %s', i),
|
|
!i && r
|
|
? (y('sendPacket :: handle events on `drain` once through callback.'),
|
|
e.stream.once('drain', r))
|
|
: r && (y('sendPacket :: invoking cb'), r())
|
|
}
|
|
function N_(e) {
|
|
e &&
|
|
(y('flush: queue exists? %b', !!e),
|
|
Object.keys(e).forEach(function (t) {
|
|
typeof e[t].cb == 'function' &&
|
|
(e[t].cb(new Error('Connection closed')), delete e[t])
|
|
}))
|
|
}
|
|
function M_(e) {
|
|
e &&
|
|
(y(
|
|
'flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function',
|
|
),
|
|
Object.keys(e).forEach(function (t) {
|
|
e[t].volatile &&
|
|
typeof e[t].cb == 'function' &&
|
|
(e[t].cb(new Error('Connection closed')), delete e[t])
|
|
}))
|
|
}
|
|
function bf(e, t, r, i) {
|
|
y('storeAndSend :: store packet with cmd %s to outgoingStore', t.cmd),
|
|
e.outgoingStore.put(t, function (s) {
|
|
if (s) return r && r(s)
|
|
i(), Xt(e, t, r)
|
|
})
|
|
}
|
|
function se(e) {
|
|
y('nop ::', e)
|
|
}
|
|
function N(e, t) {
|
|
var r,
|
|
i = this
|
|
if (!(this instanceof N)) return new N(e, t)
|
|
this.options = t || {}
|
|
for (r in gf)
|
|
typeof this.options[r] > 'u'
|
|
? (this.options[r] = gf[r])
|
|
: (this.options[r] = t[r])
|
|
y('MqttClient :: options.protocol', t.protocol),
|
|
y('MqttClient :: options.protocolVersion', t.protocolVersion),
|
|
y('MqttClient :: options.username', t.username),
|
|
y('MqttClient :: options.keepalive', t.keepalive),
|
|
y('MqttClient :: options.reconnectPeriod', t.reconnectPeriod),
|
|
y('MqttClient :: options.rejectUnauthorized', t.rejectUnauthorized),
|
|
(this.options.clientId =
|
|
typeof t.clientId == 'string' ? t.clientId : A_()),
|
|
y('MqttClient :: clientId', this.options.clientId),
|
|
(this.options.customHandleAcks =
|
|
t.protocolVersion === 5 && t.customHandleAcks
|
|
? t.customHandleAcks
|
|
: function () {
|
|
arguments[3](0)
|
|
}),
|
|
(this.streamBuilder = e),
|
|
(this.outgoingStore = t.outgoingStore || new ai()),
|
|
(this.incomingStore = t.incomingStore || new ai()),
|
|
(this.queueQoSZero = t.queueQoSZero === void 0 ? !0 : t.queueQoSZero),
|
|
(this._resubscribeTopics = {}),
|
|
(this.messageIdToTopic = {}),
|
|
(this.pingTimer = null),
|
|
(this.connected = !1),
|
|
(this.disconnecting = !1),
|
|
(this.queue = []),
|
|
(this.connackTimer = null),
|
|
(this.reconnectTimer = null),
|
|
(this._storeProcessing = !1),
|
|
(this._packetIdsDuringStoreProcessing = {}),
|
|
(this.nextId = Math.max(1, Math.floor(Math.random() * 65535))),
|
|
(this.outgoing = {}),
|
|
(this._firstConnection = !0),
|
|
this.on('connect', function () {
|
|
var n = this.queue
|
|
function s() {
|
|
var o = n.shift()
|
|
y('deliver :: entry %o', o)
|
|
var f = null
|
|
o &&
|
|
((f = o.packet),
|
|
y('deliver :: call _sendPacket for %o', f),
|
|
i._sendPacket(f, function (a) {
|
|
o.cb && o.cb(a), s()
|
|
}))
|
|
}
|
|
y('connect :: sending queued packets'), s()
|
|
}),
|
|
this.on('close', function () {
|
|
y('close :: connected set to `false`'),
|
|
(this.connected = !1),
|
|
y('close :: clearing connackTimer'),
|
|
clearTimeout(this.connackTimer),
|
|
y('close :: clearing ping timer'),
|
|
i.pingTimer !== null && (i.pingTimer.clear(), (i.pingTimer = null)),
|
|
y('close :: calling _setupReconnect'),
|
|
this._setupReconnect()
|
|
}),
|
|
yf.call(this),
|
|
y('MqttClient :: setting up stream'),
|
|
this._setupStream()
|
|
}
|
|
k_(N, yf)
|
|
N.prototype._setupStream = function () {
|
|
var e,
|
|
t = this,
|
|
r = new O_(),
|
|
i = vf.parser(this.options),
|
|
n = null,
|
|
s = []
|
|
y('_setupStream :: calling method to clear reconnect'),
|
|
this._clearReconnect(),
|
|
y(
|
|
'_setupStream :: using streamBuilder provided to client to create stream',
|
|
),
|
|
(this.stream = this.streamBuilder(this)),
|
|
i.on('packet', function (u) {
|
|
y('parser :: on packet push to packets array.'), s.push(u)
|
|
})
|
|
function o() {
|
|
if (s.length) Hn(f)
|
|
else {
|
|
var u = n
|
|
;(n = null), u()
|
|
}
|
|
}
|
|
function f() {
|
|
y('work :: getting next packet in queue')
|
|
var u = s.shift()
|
|
if (u) y('work :: packet pulled from queue'), t._handlePacket(u, o)
|
|
else {
|
|
y('work :: no packets in queue')
|
|
var h = n
|
|
;(n = null), y('work :: done flag is %s', !!h), h && h()
|
|
}
|
|
}
|
|
r._write = function (u, h, c) {
|
|
;(n = c), y('writable stream :: parsing buffer'), i.parse(u), f()
|
|
}
|
|
function a(u) {
|
|
y('streamErrorHandler :: error', u.message),
|
|
B_.includes(u.code)
|
|
? (y('streamErrorHandler :: emitting error'), t.emit('error', u))
|
|
: se(u)
|
|
}
|
|
if (
|
|
(y('_setupStream :: pipe stream to writable stream'),
|
|
this.stream.pipe(r),
|
|
this.stream.on('error', a),
|
|
this.stream.on('close', function () {
|
|
y('(%s)stream :: on close', t.options.clientId),
|
|
M_(t.outgoing),
|
|
y('stream: emit close to MqttClient'),
|
|
t.emit('close')
|
|
}),
|
|
y('_setupStream: sending packet `connect`'),
|
|
(e = Object.create(this.options)),
|
|
(e.cmd = 'connect'),
|
|
Xt(this, e),
|
|
i.on('error', this.emit.bind(this, 'error')),
|
|
this.options.properties)
|
|
) {
|
|
if (
|
|
!this.options.properties.authenticationMethod &&
|
|
this.options.properties.authenticationData
|
|
)
|
|
return (
|
|
t.end(() =>
|
|
this.emit(
|
|
'error',
|
|
new Error('Packet has no Authentication Method'),
|
|
),
|
|
),
|
|
this
|
|
)
|
|
if (
|
|
this.options.properties.authenticationMethod &&
|
|
this.options.authPacket &&
|
|
typeof this.options.authPacket == 'object'
|
|
) {
|
|
var l = fi({ cmd: 'auth', reasonCode: 0 }, this.options.authPacket)
|
|
Xt(this, l)
|
|
}
|
|
}
|
|
this.stream.setMaxListeners(1e3),
|
|
clearTimeout(this.connackTimer),
|
|
(this.connackTimer = setTimeout(function () {
|
|
y('!!connectTimeout hit!! Calling _cleanUp with force `true`'),
|
|
t._cleanUp(!0)
|
|
}, this.options.connectTimeout))
|
|
}
|
|
N.prototype._handlePacket = function (e, t) {
|
|
var r = this.options
|
|
if (
|
|
r.protocolVersion === 5 &&
|
|
r.properties &&
|
|
r.properties.maximumPacketSize &&
|
|
r.properties.maximumPacketSize < e.length
|
|
)
|
|
return (
|
|
this.emit('error', new Error('exceeding packets size ' + e.cmd)),
|
|
this.end({
|
|
reasonCode: 149,
|
|
properties: { reasonString: 'Maximum packet size was exceeded' },
|
|
}),
|
|
this
|
|
)
|
|
switch (
|
|
(y('_handlePacket :: emitting packetreceive'),
|
|
this.emit('packetreceive', e),
|
|
e.cmd)
|
|
) {
|
|
case 'publish':
|
|
this._handlePublish(e, t)
|
|
break
|
|
case 'puback':
|
|
case 'pubrec':
|
|
case 'pubcomp':
|
|
case 'suback':
|
|
case 'unsuback':
|
|
this._handleAck(e), t()
|
|
break
|
|
case 'pubrel':
|
|
this._handlePubrel(e, t)
|
|
break
|
|
case 'connack':
|
|
this._handleConnack(e), t()
|
|
break
|
|
case 'pingresp':
|
|
this._handlePingresp(e), t()
|
|
break
|
|
case 'disconnect':
|
|
this._handleDisconnect(e), t()
|
|
break
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
N.prototype._checkDisconnecting = function (e) {
|
|
return (
|
|
this.disconnecting &&
|
|
(e
|
|
? e(new Error('client disconnecting'))
|
|
: this.emit('error', new Error('client disconnecting'))),
|
|
this.disconnecting
|
|
)
|
|
}
|
|
N.prototype.publish = function (e, t, r, i) {
|
|
y('publish :: message `%s` to topic `%s`', t, e)
|
|
var n,
|
|
s = this.options
|
|
typeof r == 'function' && ((i = r), (r = null))
|
|
var o = { qos: 0, retain: !1, dup: !1 }
|
|
if (((r = fi(o, r)), this._checkDisconnecting(i))) return this
|
|
switch (
|
|
((n = {
|
|
cmd: 'publish',
|
|
topic: e,
|
|
payload: t,
|
|
qos: r.qos,
|
|
retain: r.retain,
|
|
messageId: this._nextId(),
|
|
dup: r.dup,
|
|
}),
|
|
s.protocolVersion === 5 &&
|
|
((n.properties = r.properties),
|
|
((!s.properties && n.properties && n.properties.topicAlias) ||
|
|
(r.properties &&
|
|
s.properties &&
|
|
((r.properties.topicAlias &&
|
|
s.properties.topicAliasMaximum &&
|
|
r.properties.topicAlias > s.properties.topicAliasMaximum) ||
|
|
(!s.properties.topicAliasMaximum && r.properties.topicAlias)))) &&
|
|
delete n.properties.topicAlias),
|
|
y('publish :: qos', r.qos),
|
|
r.qos)
|
|
) {
|
|
case 1:
|
|
case 2:
|
|
;(this.outgoing[n.messageId] = { volatile: !1, cb: i || se }),
|
|
this._storeProcessing
|
|
? (y('_storeProcessing enabled'),
|
|
(this._packetIdsDuringStoreProcessing[n.messageId] = !1),
|
|
this._storePacket(n, void 0, r.cbStorePut))
|
|
: (y('MqttClient:publish: packet cmd: %s', n.cmd),
|
|
this._sendPacket(n, void 0, r.cbStorePut))
|
|
break
|
|
default:
|
|
this._storeProcessing
|
|
? (y('_storeProcessing enabled'),
|
|
this._storePacket(n, i, r.cbStorePut))
|
|
: (y('MqttClient:publish: packet cmd: %s', n.cmd),
|
|
this._sendPacket(n, i, r.cbStorePut))
|
|
break
|
|
}
|
|
return this
|
|
}
|
|
N.prototype.subscribe = function () {
|
|
for (
|
|
var e, t = new Array(arguments.length), r = 0;
|
|
r < arguments.length;
|
|
r++
|
|
)
|
|
t[r] = arguments[r]
|
|
var i = [],
|
|
n = t.shift(),
|
|
s = n.resubscribe,
|
|
o = t.pop() || se,
|
|
f = t.pop(),
|
|
a,
|
|
l = this,
|
|
u = this.options.protocolVersion
|
|
if (
|
|
(delete n.resubscribe,
|
|
typeof n == 'string' && (n = [n]),
|
|
typeof o != 'function' && ((f = o), (o = se)),
|
|
(a = P_.validateTopics(n)),
|
|
a !== null)
|
|
)
|
|
return mf(o, new Error('Invalid topic ' + a)), this
|
|
if (this._checkDisconnecting(o))
|
|
return y('subscribe: discconecting true'), this
|
|
var h = { qos: 0 }
|
|
if (
|
|
(u === 5 && ((h.nl = !1), (h.rap = !1), (h.rh = 0)),
|
|
(f = fi(h, f)),
|
|
Array.isArray(n)
|
|
? n.forEach(function (d) {
|
|
if (
|
|
(y('subscribe: array topic %s', d),
|
|
!l._resubscribeTopics.hasOwnProperty(d) ||
|
|
l._resubscribeTopics[d].qos < f.qos ||
|
|
s)
|
|
) {
|
|
var _ = { topic: d, qos: f.qos }
|
|
u === 5 &&
|
|
((_.nl = f.nl),
|
|
(_.rap = f.rap),
|
|
(_.rh = f.rh),
|
|
(_.properties = f.properties)),
|
|
y(
|
|
'subscribe: pushing topic `%s` and qos `%s` to subs list',
|
|
_.topic,
|
|
_.qos,
|
|
),
|
|
i.push(_)
|
|
}
|
|
})
|
|
: Object.keys(n).forEach(function (d) {
|
|
if (
|
|
(y('subscribe: object topic %s', d),
|
|
!l._resubscribeTopics.hasOwnProperty(d) ||
|
|
l._resubscribeTopics[d].qos < n[d].qos ||
|
|
s)
|
|
) {
|
|
var _ = { topic: d, qos: n[d].qos }
|
|
u === 5 &&
|
|
((_.nl = n[d].nl),
|
|
(_.rap = n[d].rap),
|
|
(_.rh = n[d].rh),
|
|
(_.properties = f.properties)),
|
|
y('subscribe: pushing `%s` to subs list', _),
|
|
i.push(_)
|
|
}
|
|
}),
|
|
(e = {
|
|
cmd: 'subscribe',
|
|
subscriptions: i,
|
|
qos: 1,
|
|
retain: !1,
|
|
dup: !1,
|
|
messageId: this._nextId(),
|
|
}),
|
|
f.properties && (e.properties = f.properties),
|
|
!i.length)
|
|
) {
|
|
o(null, [])
|
|
return
|
|
}
|
|
if (this.options.resubscribe) {
|
|
y('subscribe :: resubscribe true')
|
|
var c = []
|
|
i.forEach(function (d) {
|
|
if (l.options.reconnectPeriod > 0) {
|
|
var _ = { qos: d.qos }
|
|
u === 5 &&
|
|
((_.nl = d.nl || !1),
|
|
(_.rap = d.rap || !1),
|
|
(_.rh = d.rh || 0),
|
|
(_.properties = d.properties)),
|
|
(l._resubscribeTopics[d.topic] = _),
|
|
c.push(d.topic)
|
|
}
|
|
}),
|
|
(l.messageIdToTopic[e.messageId] = c)
|
|
}
|
|
return (
|
|
(this.outgoing[e.messageId] = {
|
|
volatile: !0,
|
|
cb: function (d, _) {
|
|
if (!d)
|
|
for (var v = _.granted, m = 0; m < v.length; m += 1) i[m].qos = v[m]
|
|
o(d, i)
|
|
},
|
|
}),
|
|
y('subscribe :: call _sendPacket'),
|
|
this._sendPacket(e),
|
|
this
|
|
)
|
|
}
|
|
N.prototype.unsubscribe = function () {
|
|
for (
|
|
var e = { cmd: 'unsubscribe', qos: 1, messageId: this._nextId() },
|
|
t = this,
|
|
r = new Array(arguments.length),
|
|
i = 0;
|
|
i < arguments.length;
|
|
i++
|
|
)
|
|
r[i] = arguments[i]
|
|
var n = r.shift(),
|
|
s = r.pop() || se,
|
|
o = r.pop()
|
|
return (
|
|
typeof n == 'string' && (n = [n]),
|
|
typeof s != 'function' && ((o = s), (s = se)),
|
|
this._checkDisconnecting(s)
|
|
? this
|
|
: (typeof n == 'string'
|
|
? (e.unsubscriptions = [n])
|
|
: Array.isArray(n) && (e.unsubscriptions = n),
|
|
this.options.resubscribe &&
|
|
e.unsubscriptions.forEach(function (f) {
|
|
delete t._resubscribeTopics[f]
|
|
}),
|
|
typeof o == 'object' && o.properties && (e.properties = o.properties),
|
|
(this.outgoing[e.messageId] = { volatile: !0, cb: s }),
|
|
y('unsubscribe: call _sendPacket'),
|
|
this._sendPacket(e),
|
|
this)
|
|
)
|
|
}
|
|
N.prototype.end = function (e, t, r) {
|
|
var i = this
|
|
y('end :: (%s)', this.options.clientId),
|
|
(e == null || typeof e != 'boolean') &&
|
|
((r = t || se),
|
|
(t = e),
|
|
(e = !1),
|
|
typeof t != 'object' &&
|
|
((r = t), (t = null), typeof r != 'function' && (r = se))),
|
|
typeof t != 'object' && ((r = t), (t = null)),
|
|
y('end :: cb? %s', !!r),
|
|
(r = r || se)
|
|
function n() {
|
|
y('end :: closeStores: closing incoming and outgoing stores'),
|
|
(i.disconnected = !0),
|
|
i.incomingStore.close(function (o) {
|
|
i.outgoingStore.close(function (f) {
|
|
if ((y('end :: closeStores: emitting end'), i.emit('end'), r)) {
|
|
let a = o || f
|
|
y('end :: closeStores: invoking callback with args'), r(a)
|
|
}
|
|
})
|
|
}),
|
|
i._deferredReconnect && i._deferredReconnect()
|
|
}
|
|
function s() {
|
|
y(
|
|
'end :: (%s) :: finish :: calling _cleanUp with force %s',
|
|
i.options.clientId,
|
|
e,
|
|
),
|
|
i._cleanUp(
|
|
e,
|
|
() => {
|
|
y('end :: finish :: calling process.nextTick on closeStores'),
|
|
Hn(n.bind(i))
|
|
},
|
|
t,
|
|
)
|
|
}
|
|
return this.disconnecting
|
|
? (r(), this)
|
|
: (this._clearReconnect(),
|
|
(this.disconnecting = !0),
|
|
!e && Object.keys(this.outgoing).length > 0
|
|
? (y(
|
|
'end :: (%s) :: calling finish in 10ms once outgoing is empty',
|
|
i.options.clientId,
|
|
),
|
|
this.once('outgoingEmpty', setTimeout.bind(null, s, 10)))
|
|
: (y('end :: (%s) :: immediately calling finish', i.options.clientId),
|
|
s()),
|
|
this)
|
|
}
|
|
N.prototype.removeOutgoingMessage = function (e) {
|
|
var t = this.outgoing[e] ? this.outgoing[e].cb : null
|
|
return (
|
|
delete this.outgoing[e],
|
|
this.outgoingStore.del({ messageId: e }, function () {
|
|
t(new Error('Message removed'))
|
|
}),
|
|
this
|
|
)
|
|
}
|
|
N.prototype.reconnect = function (e) {
|
|
y('client reconnect')
|
|
var t = this,
|
|
r = function () {
|
|
e
|
|
? ((t.options.incomingStore = e.incomingStore),
|
|
(t.options.outgoingStore = e.outgoingStore))
|
|
: ((t.options.incomingStore = null),
|
|
(t.options.outgoingStore = null)),
|
|
(t.incomingStore = t.options.incomingStore || new ai()),
|
|
(t.outgoingStore = t.options.outgoingStore || new ai()),
|
|
(t.disconnecting = !1),
|
|
(t.disconnected = !1),
|
|
(t._deferredReconnect = null),
|
|
t._reconnect()
|
|
}
|
|
return (
|
|
this.disconnecting && !this.disconnected
|
|
? (this._deferredReconnect = r)
|
|
: r(),
|
|
this
|
|
)
|
|
}
|
|
N.prototype._reconnect = function () {
|
|
y('_reconnect: emitting reconnect to client'),
|
|
this.emit('reconnect'),
|
|
this.connected
|
|
? (this.end(() => {
|
|
this._setupStream()
|
|
}),
|
|
y('client already connected. disconnecting first.'))
|
|
: (y('_reconnect: calling _setupStream'), this._setupStream())
|
|
}
|
|
N.prototype._setupReconnect = function () {
|
|
var e = this
|
|
!e.disconnecting && !e.reconnectTimer && e.options.reconnectPeriod > 0
|
|
? (this.reconnecting ||
|
|
(y('_setupReconnect :: emit `offline` state'),
|
|
this.emit('offline'),
|
|
y('_setupReconnect :: set `reconnecting` to `true`'),
|
|
(this.reconnecting = !0)),
|
|
y(
|
|
'_setupReconnect :: setting reconnectTimer for %d ms',
|
|
e.options.reconnectPeriod,
|
|
),
|
|
(e.reconnectTimer = setInterval(function () {
|
|
y('reconnectTimer :: reconnect triggered!'), e._reconnect()
|
|
}, e.options.reconnectPeriod)))
|
|
: y('_setupReconnect :: doing nothing...')
|
|
}
|
|
N.prototype._clearReconnect = function () {
|
|
y('_clearReconnect : clearing reconnect timer'),
|
|
this.reconnectTimer &&
|
|
(clearInterval(this.reconnectTimer), (this.reconnectTimer = null))
|
|
}
|
|
N.prototype._cleanUp = function (e, t) {
|
|
var r = arguments[2]
|
|
if (
|
|
(t &&
|
|
(y('_cleanUp :: done callback provided for on stream close'),
|
|
this.stream.on('close', t)),
|
|
y('_cleanUp :: forced? %s', e),
|
|
e)
|
|
)
|
|
this.options.reconnectPeriod === 0 &&
|
|
this.options.clean &&
|
|
N_(this.outgoing),
|
|
y('_cleanUp :: (%s) :: destroying stream', this.options.clientId),
|
|
this.stream.destroy()
|
|
else {
|
|
var i = fi({ cmd: 'disconnect' }, r)
|
|
y(
|
|
'_cleanUp :: (%s) :: call _sendPacket with disconnect packet',
|
|
this.options.clientId,
|
|
),
|
|
this._sendPacket(i, mf.bind(null, this.stream.end.bind(this.stream)))
|
|
}
|
|
this.disconnecting ||
|
|
(y(
|
|
'_cleanUp :: client not disconnecting. Clearing and resetting reconnect.',
|
|
),
|
|
this._clearReconnect(),
|
|
this._setupReconnect()),
|
|
this.pingTimer !== null &&
|
|
(y('_cleanUp :: clearing pingTimer'),
|
|
this.pingTimer.clear(),
|
|
(this.pingTimer = null)),
|
|
t &&
|
|
!this.connected &&
|
|
(y(
|
|
'_cleanUp :: (%s) :: removing stream `done` callback `close` listener',
|
|
this.options.clientId,
|
|
),
|
|
this.stream.removeListener('close', t),
|
|
t())
|
|
}
|
|
N.prototype._sendPacket = function (e, t, r) {
|
|
if (
|
|
(y('_sendPacket :: (%s) :: start', this.options.clientId),
|
|
(r = r || se),
|
|
!this.connected)
|
|
) {
|
|
y('_sendPacket :: client not connected. Storing packet offline.'),
|
|
this._storePacket(e, t, r)
|
|
return
|
|
}
|
|
switch ((this._shiftPingInterval(), e.cmd)) {
|
|
case 'publish':
|
|
break
|
|
case 'pubrel':
|
|
bf(this, e, t, r)
|
|
return
|
|
default:
|
|
Xt(this, e, t)
|
|
return
|
|
}
|
|
switch (e.qos) {
|
|
case 2:
|
|
case 1:
|
|
bf(this, e, t, r)
|
|
break
|
|
case 0:
|
|
default:
|
|
Xt(this, e, t)
|
|
break
|
|
}
|
|
y('_sendPacket :: (%s) :: end', this.options.clientId)
|
|
}
|
|
N.prototype._storePacket = function (e, t, r) {
|
|
y('_storePacket :: packet: %o', e),
|
|
y('_storePacket :: cb? %s', !!t),
|
|
(r = r || se),
|
|
((e.qos || 0) === 0 && this.queueQoSZero) || e.cmd !== 'publish'
|
|
? this.queue.push({ packet: e, cb: t })
|
|
: e.qos > 0
|
|
? ((t = this.outgoing[e.messageId]
|
|
? this.outgoing[e.messageId].cb
|
|
: null),
|
|
this.outgoingStore.put(e, function (i) {
|
|
if (i) return t && t(i)
|
|
r()
|
|
}))
|
|
: t && t(new Error('No connection to broker'))
|
|
}
|
|
N.prototype._setupPingTimer = function () {
|
|
y('_setupPingTimer :: keepalive %d (seconds)', this.options.keepalive)
|
|
var e = this
|
|
!this.pingTimer &&
|
|
this.options.keepalive &&
|
|
((this.pingResp = !0),
|
|
(this.pingTimer = R_(function () {
|
|
e._checkPing()
|
|
}, this.options.keepalive * 1e3)))
|
|
}
|
|
N.prototype._shiftPingInterval = function () {
|
|
this.pingTimer &&
|
|
this.options.keepalive &&
|
|
this.options.reschedulePings &&
|
|
this.pingTimer.reschedule(this.options.keepalive * 1e3)
|
|
}
|
|
N.prototype._checkPing = function () {
|
|
y('_checkPing :: checking ping...'),
|
|
this.pingResp
|
|
? (y(
|
|
'_checkPing :: ping response received. Clearing flag and sending `pingreq`',
|
|
),
|
|
(this.pingResp = !1),
|
|
this._sendPacket({ cmd: 'pingreq' }))
|
|
: (y('_checkPing :: calling _cleanUp with force true'),
|
|
this._cleanUp(!0))
|
|
}
|
|
N.prototype._handlePingresp = function () {
|
|
this.pingResp = !0
|
|
}
|
|
N.prototype._handleConnack = function (e) {
|
|
y('_handleConnack')
|
|
var t = this.options,
|
|
r = t.protocolVersion,
|
|
i = r === 5 ? e.reasonCode : e.returnCode
|
|
if (
|
|
(clearTimeout(this.connackTimer),
|
|
e.properties &&
|
|
(e.properties.topicAliasMaximum &&
|
|
(t.properties || (t.properties = {}),
|
|
(t.properties.topicAliasMaximum = e.properties.topicAliasMaximum)),
|
|
e.properties.serverKeepAlive &&
|
|
t.keepalive &&
|
|
((t.keepalive = e.properties.serverKeepAlive),
|
|
this._shiftPingInterval()),
|
|
e.properties.maximumPacketSize &&
|
|
(t.properties || (t.properties = {}),
|
|
(t.properties.maximumPacketSize = e.properties.maximumPacketSize))),
|
|
i === 0)
|
|
)
|
|
(this.reconnecting = !1), this._onConnect(e)
|
|
else if (i > 0) {
|
|
var n = new Error('Connection refused: ' + Vn[i])
|
|
;(n.code = i), this.emit('error', n)
|
|
}
|
|
}
|
|
N.prototype._handlePublish = function (e, t) {
|
|
y('_handlePublish: packet %o', e), (t = typeof t < 'u' ? t : se)
|
|
var r = e.topic.toString(),
|
|
i = e.payload,
|
|
n = e.qos,
|
|
s = e.messageId,
|
|
o = this,
|
|
f = this.options,
|
|
a = [0, 16, 128, 131, 135, 144, 145, 151, 153]
|
|
switch ((y('_handlePublish: qos %d', n), n)) {
|
|
case 2: {
|
|
f.customHandleAcks(r, i, e, function (l, u) {
|
|
if ((l instanceof Error || ((u = l), (l = null)), l))
|
|
return o.emit('error', l)
|
|
if (a.indexOf(u) === -1)
|
|
return o.emit('error', new Error('Wrong reason code for pubrec'))
|
|
u
|
|
? o._sendPacket({ cmd: 'pubrec', messageId: s, reasonCode: u }, t)
|
|
: o.incomingStore.put(e, function () {
|
|
o._sendPacket({ cmd: 'pubrec', messageId: s }, t)
|
|
})
|
|
})
|
|
break
|
|
}
|
|
case 1: {
|
|
f.customHandleAcks(r, i, e, function (l, u) {
|
|
if ((l instanceof Error || ((u = l), (l = null)), l))
|
|
return o.emit('error', l)
|
|
if (a.indexOf(u) === -1)
|
|
return o.emit('error', new Error('Wrong reason code for puback'))
|
|
u || o.emit('message', r, i, e),
|
|
o.handleMessage(e, function (h) {
|
|
if (h) return t && t(h)
|
|
o._sendPacket({ cmd: 'puback', messageId: s, reasonCode: u }, t)
|
|
})
|
|
})
|
|
break
|
|
}
|
|
case 0:
|
|
this.emit('message', r, i, e), this.handleMessage(e, t)
|
|
break
|
|
default:
|
|
y('_handlePublish: unknown QoS. Doing nothing.')
|
|
break
|
|
}
|
|
}
|
|
N.prototype.handleMessage = function (e, t) {
|
|
t()
|
|
}
|
|
N.prototype._handleAck = function (e) {
|
|
var t = e.messageId,
|
|
r = e.cmd,
|
|
i = null,
|
|
n = this.outgoing[t] ? this.outgoing[t].cb : null,
|
|
s = this,
|
|
o
|
|
if (!n) {
|
|
y('_handleAck :: Server sent an ack in error. Ignoring.')
|
|
return
|
|
}
|
|
switch ((y('_handleAck :: packet type', r), r)) {
|
|
case 'pubcomp':
|
|
case 'puback':
|
|
var f = e.reasonCode
|
|
f &&
|
|
f > 0 &&
|
|
f !== 16 &&
|
|
((o = new Error('Publish error: ' + Vn[f])), (o.code = f), n(o, e)),
|
|
delete this.outgoing[t],
|
|
this.outgoingStore.del(e, n)
|
|
break
|
|
case 'pubrec':
|
|
i = { cmd: 'pubrel', qos: 2, messageId: t }
|
|
var a = e.reasonCode
|
|
a && a > 0 && a !== 16
|
|
? ((o = new Error('Publish error: ' + Vn[a])), (o.code = a), n(o, e))
|
|
: this._sendPacket(i)
|
|
break
|
|
case 'suback':
|
|
delete this.outgoing[t]
|
|
for (var l = 0; l < e.granted.length; l++)
|
|
if (e.granted[l] & 128) {
|
|
var u = this.messageIdToTopic[t]
|
|
u &&
|
|
u.forEach(function (h) {
|
|
delete s._resubscribeTopics[h]
|
|
})
|
|
}
|
|
n(null, e)
|
|
break
|
|
case 'unsuback':
|
|
delete this.outgoing[t], n(null)
|
|
break
|
|
default:
|
|
s.emit('error', new Error('unrecognized packet type'))
|
|
}
|
|
this.disconnecting &&
|
|
Object.keys(this.outgoing).length === 0 &&
|
|
this.emit('outgoingEmpty')
|
|
}
|
|
N.prototype._handlePubrel = function (e, t) {
|
|
y('handling pubrel packet'), (t = typeof t < 'u' ? t : se)
|
|
var r = e.messageId,
|
|
i = this,
|
|
n = { cmd: 'pubcomp', messageId: r }
|
|
i.incomingStore.get(e, function (s, o) {
|
|
s
|
|
? i._sendPacket(n, t)
|
|
: (i.emit('message', o.topic, o.payload, o),
|
|
i.handleMessage(o, function (f) {
|
|
if (f) return t(f)
|
|
i.incomingStore.del(o, se), i._sendPacket(n, t)
|
|
}))
|
|
})
|
|
}
|
|
N.prototype._handleDisconnect = function (e) {
|
|
this.emit('disconnect', e)
|
|
}
|
|
N.prototype._nextId = function () {
|
|
var e = this.nextId++
|
|
return this.nextId === 65536 && (this.nextId = 1), e
|
|
}
|
|
N.prototype.getLastMessageId = function () {
|
|
return this.nextId === 1 ? 65535 : this.nextId - 1
|
|
}
|
|
N.prototype._resubscribe = function (e) {
|
|
y('_resubscribe')
|
|
var t = Object.keys(this._resubscribeTopics)
|
|
if (
|
|
!this._firstConnection &&
|
|
(this.options.clean ||
|
|
(this.options.protocolVersion === 5 && !e.sessionPresent)) &&
|
|
t.length > 0
|
|
)
|
|
if (this.options.resubscribe)
|
|
if (this.options.protocolVersion === 5) {
|
|
y('_resubscribe: protocolVersion 5')
|
|
for (var r = 0; r < t.length; r++) {
|
|
var i = {}
|
|
;(i[t[r]] = this._resubscribeTopics[t[r]]),
|
|
(i.resubscribe = !0),
|
|
this.subscribe(i, { properties: i[t[r]].properties })
|
|
}
|
|
} else
|
|
(this._resubscribeTopics.resubscribe = !0),
|
|
this.subscribe(this._resubscribeTopics)
|
|
else this._resubscribeTopics = {}
|
|
this._firstConnection = !1
|
|
}
|
|
N.prototype._onConnect = function (e) {
|
|
if (this.disconnected) {
|
|
this.emit('connect', e)
|
|
return
|
|
}
|
|
var t = this
|
|
this._setupPingTimer(), this._resubscribe(e), (this.connected = !0)
|
|
function r() {
|
|
var i = t.outgoingStore.createStream()
|
|
function n() {
|
|
;(t._storeProcessing = !1), (t._packetIdsDuringStoreProcessing = {})
|
|
}
|
|
t.once('close', s),
|
|
i.on('error', function (f) {
|
|
n(), t.removeListener('close', s), t.emit('error', f)
|
|
})
|
|
function s() {
|
|
i.destroy(), (i = null), n()
|
|
}
|
|
function o() {
|
|
if (i) {
|
|
t._storeProcessing = !0
|
|
var f = i.read(1),
|
|
a
|
|
if (!f) {
|
|
i.once('readable', o)
|
|
return
|
|
}
|
|
if (t._packetIdsDuringStoreProcessing[f.messageId]) {
|
|
o()
|
|
return
|
|
}
|
|
!t.disconnecting && !t.reconnectTimer
|
|
? ((a = t.outgoing[f.messageId]
|
|
? t.outgoing[f.messageId].cb
|
|
: null),
|
|
(t.outgoing[f.messageId] = {
|
|
volatile: !1,
|
|
cb: function (l, u) {
|
|
a && a(l, u), o()
|
|
},
|
|
}),
|
|
(t._packetIdsDuringStoreProcessing[f.messageId] = !0),
|
|
t._sendPacket(f))
|
|
: i.destroy && i.destroy()
|
|
}
|
|
}
|
|
i.on('end', function () {
|
|
var f = !0
|
|
for (var a in t._packetIdsDuringStoreProcessing)
|
|
if (!t._packetIdsDuringStoreProcessing[a]) {
|
|
f = !1
|
|
break
|
|
}
|
|
f ? (n(), t.removeListener('close', s), t.emit('connect', e)) : r()
|
|
}),
|
|
o()
|
|
}
|
|
r()
|
|
}
|
|
wf.exports = N
|
|
})
|
|
var Gn = b((gw, Sf) => {
|
|
'use strict'
|
|
var L_ = require('net'),
|
|
q_ = ze()('mqttjs:tcp')
|
|
function D_(e, t) {
|
|
var r, i
|
|
return (
|
|
(t.port = t.port || 1883),
|
|
(t.hostname = t.hostname || t.host || 'localhost'),
|
|
(r = t.port),
|
|
(i = t.hostname),
|
|
q_('port %d and host %s', r, i),
|
|
L_.createConnection(r, i)
|
|
)
|
|
}
|
|
Sf.exports = D_
|
|
})
|
|
var li = b((bw, Ef) => {
|
|
'use strict'
|
|
var U_ = require('tls'),
|
|
j_ = ze()('mqttjs:tls')
|
|
function F_(e, t) {
|
|
var r
|
|
;(t.port = t.port || 8883),
|
|
(t.host = t.hostname || t.host || 'localhost'),
|
|
(t.servername = t.host),
|
|
(t.rejectUnauthorized = t.rejectUnauthorized !== !1),
|
|
delete t.path,
|
|
j_(
|
|
'port %d host %s rejectUnauthorized %b',
|
|
t.port,
|
|
t.host,
|
|
t.rejectUnauthorized,
|
|
),
|
|
(r = U_.connect(t)),
|
|
r.on('secureConnect', function () {
|
|
t.rejectUnauthorized && !r.authorized
|
|
? r.emit('error', new Error('TLS not authorized'))
|
|
: r.removeListener('error', i)
|
|
})
|
|
function i(n) {
|
|
t.rejectUnauthorized && e.emit('error', n), r.end()
|
|
}
|
|
return r.on('error', i), r
|
|
}
|
|
Ef.exports = F_
|
|
})
|
|
var Tf = b((yw, Cf) => {
|
|
Cf.exports = xf
|
|
function xf(e, t) {
|
|
if (e && t) return xf(e)(t)
|
|
if (typeof e != 'function') throw new TypeError('need wrapper function')
|
|
return (
|
|
Object.keys(e).forEach(function (i) {
|
|
r[i] = e[i]
|
|
}),
|
|
r
|
|
)
|
|
function r() {
|
|
for (var i = new Array(arguments.length), n = 0; n < i.length; n++)
|
|
i[n] = arguments[n]
|
|
var s = e.apply(this, i),
|
|
o = i[i.length - 1]
|
|
return (
|
|
typeof s == 'function' &&
|
|
s !== o &&
|
|
Object.keys(o).forEach(function (f) {
|
|
s[f] = o[f]
|
|
}),
|
|
s
|
|
)
|
|
}
|
|
}
|
|
})
|
|
var kf = b((vw, zn) => {
|
|
var If = Tf()
|
|
zn.exports = If(ui)
|
|
zn.exports.strict = If(Of)
|
|
ui.proto = ui(function () {
|
|
Object.defineProperty(Function.prototype, 'once', {
|
|
value: function () {
|
|
return ui(this)
|
|
},
|
|
configurable: !0,
|
|
}),
|
|
Object.defineProperty(Function.prototype, 'onceStrict', {
|
|
value: function () {
|
|
return Of(this)
|
|
},
|
|
configurable: !0,
|
|
})
|
|
})
|
|
function ui(e) {
|
|
var t = function () {
|
|
return t.called
|
|
? t.value
|
|
: ((t.called = !0), (t.value = e.apply(this, arguments)))
|
|
}
|
|
return (t.called = !1), t
|
|
}
|
|
function Of(e) {
|
|
var t = function () {
|
|
if (t.called) throw new Error(t.onceError)
|
|
return (t.called = !0), (t.value = e.apply(this, arguments))
|
|
},
|
|
r = e.name || 'Function wrapped with `once`'
|
|
return (
|
|
(t.onceError = r + " shouldn't be called more than once"),
|
|
(t.called = !1),
|
|
t
|
|
)
|
|
}
|
|
})
|
|
var Kn = b((mw, Pf) => {
|
|
var W_ = kf(),
|
|
V_ = function () {},
|
|
H_ = function (e) {
|
|
return e.setHeader && typeof e.abort == 'function'
|
|
},
|
|
$_ = function (e) {
|
|
return e.stdio && Array.isArray(e.stdio) && e.stdio.length === 3
|
|
},
|
|
Rf = function (e, t, r) {
|
|
if (typeof t == 'function') return Rf(e, null, t)
|
|
t || (t = {}), (r = W_(r || V_))
|
|
var i = e._writableState,
|
|
n = e._readableState,
|
|
s = t.readable || (t.readable !== !1 && e.readable),
|
|
o = t.writable || (t.writable !== !1 && e.writable),
|
|
f = !1,
|
|
a = function () {
|
|
e.writable || l()
|
|
},
|
|
l = function () {
|
|
;(o = !1), s || r.call(e)
|
|
},
|
|
u = function () {
|
|
;(s = !1), o || r.call(e)
|
|
},
|
|
h = function (m) {
|
|
r.call(e, m ? new Error('exited with error code: ' + m) : null)
|
|
},
|
|
c = function (m) {
|
|
r.call(e, m)
|
|
},
|
|
d = function () {
|
|
process.nextTick(_)
|
|
},
|
|
_ = function () {
|
|
if (!f) {
|
|
if (s && !(n && n.ended && !n.destroyed))
|
|
return r.call(e, new Error('premature close'))
|
|
if (o && !(i && i.ended && !i.destroyed))
|
|
return r.call(e, new Error('premature close'))
|
|
}
|
|
},
|
|
v = function () {
|
|
e.req.on('finish', l)
|
|
}
|
|
return (
|
|
H_(e)
|
|
? (e.on('complete', l),
|
|
e.on('abort', d),
|
|
e.req ? v() : e.on('request', v))
|
|
: o && !i && (e.on('end', a), e.on('close', a)),
|
|
$_(e) && e.on('exit', h),
|
|
e.on('end', u),
|
|
e.on('finish', l),
|
|
t.error !== !1 && e.on('error', c),
|
|
e.on('close', d),
|
|
function () {
|
|
;(f = !0),
|
|
e.removeListener('complete', l),
|
|
e.removeListener('abort', d),
|
|
e.removeListener('request', v),
|
|
e.req && e.req.removeListener('finish', l),
|
|
e.removeListener('end', a),
|
|
e.removeListener('close', a),
|
|
e.removeListener('finish', l),
|
|
e.removeListener('exit', h),
|
|
e.removeListener('end', u),
|
|
e.removeListener('error', c),
|
|
e.removeListener('close', d)
|
|
}
|
|
)
|
|
}
|
|
Pf.exports = Rf
|
|
})
|
|
var Yn = b((ww, Bf) => {
|
|
Bf.exports = G_
|
|
function G_(e) {
|
|
var t = e._readableState
|
|
return t
|
|
? t.objectMode || typeof e._duplexState == 'number'
|
|
? e.read()
|
|
: e.read(z_(t))
|
|
: null
|
|
}
|
|
function z_(e) {
|
|
if (e.buffer.length) {
|
|
var t = e.bufferIndex || 0
|
|
if (e.buffer.head) return e.buffer.head.data.length
|
|
if (e.buffer.length - t > 0 && e.buffer[t]) return e.buffer[t].length
|
|
}
|
|
return e.length
|
|
}
|
|
})
|
|
var hi = b((Sw, Lf) => {
|
|
var ci = He(),
|
|
Af = Kn(),
|
|
K_ = ie(),
|
|
Y_ = Yn(),
|
|
Nf =
|
|
Buffer.from && Buffer.from !== Uint8Array.from
|
|
? Buffer.from([0])
|
|
: new Buffer([0]),
|
|
Qn = function (e, t) {
|
|
e._corked ? e.once('uncork', t) : t()
|
|
},
|
|
Q_ = function (e, t) {
|
|
e._autoDestroy && e.destroy(t)
|
|
},
|
|
Mf = function (e, t) {
|
|
return function (r) {
|
|
r
|
|
? Q_(e, r.message === 'premature close' ? null : r)
|
|
: t && !e._ended && e.end()
|
|
}
|
|
},
|
|
J_ = function (e, t) {
|
|
if (!e || (e._writableState && e._writableState.finished)) return t()
|
|
if (e._writableState) return e.end(t)
|
|
e.end(), t()
|
|
},
|
|
X_ = function () {},
|
|
Z_ = function (e) {
|
|
return new ci.Readable({ objectMode: !0, highWaterMark: 16 }).wrap(e)
|
|
},
|
|
J = function (e, t, r) {
|
|
if (!(this instanceof J)) return new J(e, t, r)
|
|
ci.Duplex.call(this, r),
|
|
(this._writable = null),
|
|
(this._readable = null),
|
|
(this._readable2 = null),
|
|
(this._autoDestroy = !r || r.autoDestroy !== !1),
|
|
(this._forwardDestroy = !r || r.destroy !== !1),
|
|
(this._forwardEnd = !r || r.end !== !1),
|
|
(this._corked = 1),
|
|
(this._ondrain = null),
|
|
(this._drained = !1),
|
|
(this._forwarding = !1),
|
|
(this._unwrite = null),
|
|
(this._unread = null),
|
|
(this._ended = !1),
|
|
(this.destroyed = !1),
|
|
e && this.setWritable(e),
|
|
t && this.setReadable(t)
|
|
}
|
|
K_(J, ci.Duplex)
|
|
J.obj = function (e, t, r) {
|
|
return (
|
|
r || (r = {}), (r.objectMode = !0), (r.highWaterMark = 16), new J(e, t, r)
|
|
)
|
|
}
|
|
J.prototype.cork = function () {
|
|
++this._corked === 1 && this.emit('cork')
|
|
}
|
|
J.prototype.uncork = function () {
|
|
this._corked && --this._corked === 0 && this.emit('uncork')
|
|
}
|
|
J.prototype.setWritable = function (e) {
|
|
if ((this._unwrite && this._unwrite(), this.destroyed)) {
|
|
e && e.destroy && e.destroy()
|
|
return
|
|
}
|
|
if (e === null || e === !1) {
|
|
this.end()
|
|
return
|
|
}
|
|
var t = this,
|
|
r = Af(e, { writable: !0, readable: !1 }, Mf(this, this._forwardEnd)),
|
|
i = function () {
|
|
var s = t._ondrain
|
|
;(t._ondrain = null), s && s()
|
|
},
|
|
n = function () {
|
|
t._writable.removeListener('drain', i), r()
|
|
}
|
|
this._unwrite && process.nextTick(i),
|
|
(this._writable = e),
|
|
this._writable.on('drain', i),
|
|
(this._unwrite = n),
|
|
this.uncork()
|
|
}
|
|
J.prototype.setReadable = function (e) {
|
|
if ((this._unread && this._unread(), this.destroyed)) {
|
|
e && e.destroy && e.destroy()
|
|
return
|
|
}
|
|
if (e === null || e === !1) {
|
|
this.push(null), this.resume()
|
|
return
|
|
}
|
|
var t = this,
|
|
r = Af(e, { writable: !1, readable: !0 }, Mf(this)),
|
|
i = function () {
|
|
t._forward()
|
|
},
|
|
n = function () {
|
|
t.push(null)
|
|
},
|
|
s = function () {
|
|
t._readable2.removeListener('readable', i),
|
|
t._readable2.removeListener('end', n),
|
|
r()
|
|
}
|
|
;(this._drained = !0),
|
|
(this._readable = e),
|
|
(this._readable2 = e._readableState ? e : Z_(e)),
|
|
this._readable2.on('readable', i),
|
|
this._readable2.on('end', n),
|
|
(this._unread = s),
|
|
this._forward()
|
|
}
|
|
J.prototype._read = function () {
|
|
;(this._drained = !0), this._forward()
|
|
}
|
|
J.prototype._forward = function () {
|
|
if (!(this._forwarding || !this._readable2 || !this._drained)) {
|
|
this._forwarding = !0
|
|
for (var e; this._drained && (e = Y_(this._readable2)) !== null; )
|
|
this.destroyed || (this._drained = this.push(e))
|
|
this._forwarding = !1
|
|
}
|
|
}
|
|
J.prototype.destroy = function (e, t) {
|
|
if ((t || (t = X_), this.destroyed)) return t(null)
|
|
this.destroyed = !0
|
|
var r = this
|
|
process.nextTick(function () {
|
|
r._destroy(e), t(null)
|
|
})
|
|
}
|
|
J.prototype._destroy = function (e) {
|
|
if (e) {
|
|
var t = this._ondrain
|
|
;(this._ondrain = null), t ? t(e) : this.emit('error', e)
|
|
}
|
|
this._forwardDestroy &&
|
|
(this._readable && this._readable.destroy && this._readable.destroy(),
|
|
this._writable && this._writable.destroy && this._writable.destroy()),
|
|
this.emit('close')
|
|
}
|
|
J.prototype._write = function (e, t, r) {
|
|
if (!this.destroyed) {
|
|
if (this._corked) return Qn(this, this._write.bind(this, e, t, r))
|
|
if (e === Nf) return this._finish(r)
|
|
if (!this._writable) return r()
|
|
this._writable.write(e) === !1
|
|
? (this._ondrain = r)
|
|
: this.destroyed || r()
|
|
}
|
|
}
|
|
J.prototype._finish = function (e) {
|
|
var t = this
|
|
this.emit('preend'),
|
|
Qn(this, function () {
|
|
J_(t._forwardEnd && t._writable, function () {
|
|
t._writableState.prefinished === !1 &&
|
|
(t._writableState.prefinished = !0),
|
|
t.emit('prefinish'),
|
|
Qn(t, e)
|
|
})
|
|
})
|
|
}
|
|
J.prototype.end = function (e, t, r) {
|
|
return typeof e == 'function'
|
|
? this.end(null, null, e)
|
|
: typeof t == 'function'
|
|
? this.end(e, null, t)
|
|
: ((this._ended = !0),
|
|
e && this.write(e),
|
|
!this._writableState.ending &&
|
|
!this._writableState.destroyed &&
|
|
this.write(Nf),
|
|
ci.Writable.prototype.end.call(this, r))
|
|
}
|
|
Lf.exports = J
|
|
})
|
|
var Jn = b((Ew, qf) => {
|
|
'use strict'
|
|
var eg = He().Transform,
|
|
tg = hi(),
|
|
Re,
|
|
di,
|
|
le
|
|
function rg() {
|
|
var e = new eg()
|
|
return (
|
|
(e._write = function (t, r, i) {
|
|
Re.send({
|
|
data: t.buffer,
|
|
success: function () {
|
|
i()
|
|
},
|
|
fail: function (n) {
|
|
i(new Error(n))
|
|
},
|
|
})
|
|
}),
|
|
(e._flush = function (r) {
|
|
Re.close({
|
|
success: function () {
|
|
r()
|
|
},
|
|
})
|
|
}),
|
|
e
|
|
)
|
|
}
|
|
function ig(e) {
|
|
e.hostname || (e.hostname = 'localhost'),
|
|
e.path || (e.path = '/'),
|
|
e.wsOptions || (e.wsOptions = {})
|
|
}
|
|
function ng(e, t) {
|
|
var r = e.protocol === 'wxs' ? 'wss' : 'ws',
|
|
i = r + '://' + e.hostname + e.path
|
|
return (
|
|
e.port &&
|
|
e.port !== 80 &&
|
|
e.port !== 443 &&
|
|
(i = r + '://' + e.hostname + ':' + e.port + e.path),
|
|
typeof e.transformWsUrl == 'function' && (i = e.transformWsUrl(i, e, t)),
|
|
i
|
|
)
|
|
}
|
|
function sg() {
|
|
Re.onOpen(function () {
|
|
le.setReadable(di), le.setWritable(di), le.emit('connect')
|
|
}),
|
|
Re.onMessage(function (e) {
|
|
var t = e.data
|
|
t instanceof ArrayBuffer
|
|
? (t = Buffer.from(t))
|
|
: (t = Buffer.from(t, 'utf8')),
|
|
di.push(t)
|
|
}),
|
|
Re.onClose(function () {
|
|
le.end(), le.destroy()
|
|
}),
|
|
Re.onError(function (e) {
|
|
le.destroy(new Error(e.errMsg))
|
|
})
|
|
}
|
|
function og(e, t) {
|
|
if (((t.hostname = t.hostname || t.host), !t.hostname))
|
|
throw new Error('Could not determine host. Specify host manually.')
|
|
var r =
|
|
t.protocolId === 'MQIsdp' && t.protocolVersion === 3 ? 'mqttv3.1' : 'mqtt'
|
|
ig(t)
|
|
var i = ng(t, e)
|
|
;(Re = wx.connectSocket({ url: i, protocols: [r] })),
|
|
(di = rg()),
|
|
(le = tg.obj()),
|
|
(le._destroy = function (s, o) {
|
|
Re.close({
|
|
success: function () {
|
|
o && o(s)
|
|
},
|
|
})
|
|
})
|
|
var n = le.destroy
|
|
return (
|
|
(le.destroy = function () {
|
|
le.destroy = n
|
|
var s = this
|
|
setTimeout(function () {
|
|
Re.close({
|
|
fail: function () {
|
|
s._destroy(new Error())
|
|
},
|
|
})
|
|
}, 0)
|
|
}.bind(le)),
|
|
sg(),
|
|
le
|
|
)
|
|
}
|
|
qf.exports = og
|
|
})
|
|
var Xn = b((xw, Uf) => {
|
|
'use strict'
|
|
var ag = He().Transform,
|
|
fg = hi(),
|
|
Qe,
|
|
Zt,
|
|
Ye,
|
|
Df = !1
|
|
function lg() {
|
|
var e = new ag()
|
|
return (
|
|
(e._write = function (t, r, i) {
|
|
Qe.sendSocketMessage({
|
|
data: t.buffer,
|
|
success: function () {
|
|
i()
|
|
},
|
|
fail: function () {
|
|
i(new Error())
|
|
},
|
|
})
|
|
}),
|
|
(e._flush = function (r) {
|
|
Qe.closeSocket({
|
|
success: function () {
|
|
r()
|
|
},
|
|
})
|
|
}),
|
|
e
|
|
)
|
|
}
|
|
function ug(e) {
|
|
e.hostname || (e.hostname = 'localhost'),
|
|
e.path || (e.path = '/'),
|
|
e.wsOptions || (e.wsOptions = {})
|
|
}
|
|
function cg(e, t) {
|
|
var r = e.protocol === 'alis' ? 'wss' : 'ws',
|
|
i = r + '://' + e.hostname + e.path
|
|
return (
|
|
e.port &&
|
|
e.port !== 80 &&
|
|
e.port !== 443 &&
|
|
(i = r + '://' + e.hostname + ':' + e.port + e.path),
|
|
typeof e.transformWsUrl == 'function' && (i = e.transformWsUrl(i, e, t)),
|
|
i
|
|
)
|
|
}
|
|
function hg() {
|
|
Df ||
|
|
((Df = !0),
|
|
Qe.onSocketOpen(function () {
|
|
Ye.setReadable(Zt), Ye.setWritable(Zt), Ye.emit('connect')
|
|
}),
|
|
Qe.onSocketMessage(function (e) {
|
|
if (typeof e.data == 'string') {
|
|
var t = Buffer.from(e.data, 'base64')
|
|
Zt.push(t)
|
|
} else {
|
|
var r = new FileReader()
|
|
r.addEventListener('load', function () {
|
|
var i = r.result
|
|
i instanceof ArrayBuffer
|
|
? (i = Buffer.from(i))
|
|
: (i = Buffer.from(i, 'utf8')),
|
|
Zt.push(i)
|
|
}),
|
|
r.readAsArrayBuffer(e.data)
|
|
}
|
|
}),
|
|
Qe.onSocketClose(function () {
|
|
Ye.end(), Ye.destroy()
|
|
}),
|
|
Qe.onSocketError(function (e) {
|
|
Ye.destroy(e)
|
|
}))
|
|
}
|
|
function dg(e, t) {
|
|
if (((t.hostname = t.hostname || t.host), !t.hostname))
|
|
throw new Error('Could not determine host. Specify host manually.')
|
|
var r =
|
|
t.protocolId === 'MQIsdp' && t.protocolVersion === 3 ? 'mqttv3.1' : 'mqtt'
|
|
ug(t)
|
|
var i = cg(t, e)
|
|
return (
|
|
(Qe = t.my),
|
|
Qe.connectSocket({ url: i, protocols: r }),
|
|
(Zt = lg()),
|
|
(Ye = fg.obj()),
|
|
hg(),
|
|
Ye
|
|
)
|
|
}
|
|
Uf.exports = dg
|
|
})
|
|
var ut = b((Cw, jf) => {
|
|
'use strict'
|
|
jf.exports = {
|
|
BINARY_TYPES: ['nodebuffer', 'arraybuffer', 'fragments'],
|
|
GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
|
|
kStatusCode: Symbol('status-code'),
|
|
kWebSocket: Symbol('websocket'),
|
|
EMPTY_BUFFER: Buffer.alloc(0),
|
|
NOOP: () => {},
|
|
}
|
|
})
|
|
var er = b((Tw, Zn) => {
|
|
'use strict'
|
|
var { EMPTY_BUFFER: pg } = ut()
|
|
function Ff(e, t) {
|
|
if (e.length === 0) return pg
|
|
if (e.length === 1) return e[0]
|
|
let r = Buffer.allocUnsafe(t),
|
|
i = 0
|
|
for (let n = 0; n < e.length; n++) {
|
|
let s = e[n]
|
|
r.set(s, i), (i += s.length)
|
|
}
|
|
return i < t ? r.slice(0, i) : r
|
|
}
|
|
function Wf(e, t, r, i, n) {
|
|
for (let s = 0; s < n; s++) r[i + s] = e[s] ^ t[s & 3]
|
|
}
|
|
function Vf(e, t) {
|
|
let r = e.length
|
|
for (let i = 0; i < r; i++) e[i] ^= t[i & 3]
|
|
}
|
|
function Hf(e) {
|
|
return e.byteLength === e.buffer.byteLength
|
|
? e.buffer
|
|
: e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength)
|
|
}
|
|
function pi(e) {
|
|
if (((pi.readOnly = !0), Buffer.isBuffer(e))) return e
|
|
let t
|
|
return (
|
|
e instanceof ArrayBuffer
|
|
? (t = Buffer.from(e))
|
|
: ArrayBuffer.isView(e)
|
|
? (t = Buffer.from(e.buffer, e.byteOffset, e.byteLength))
|
|
: ((t = Buffer.from(e)), (pi.readOnly = !1)),
|
|
t
|
|
)
|
|
}
|
|
try {
|
|
let e = require('bufferutil'),
|
|
t = e.BufferUtil || e
|
|
Zn.exports = {
|
|
concat: Ff,
|
|
mask(r, i, n, s, o) {
|
|
o < 48 ? Wf(r, i, n, s, o) : t.mask(r, i, n, s, o)
|
|
},
|
|
toArrayBuffer: Hf,
|
|
toBuffer: pi,
|
|
unmask(r, i) {
|
|
r.length < 32 ? Vf(r, i) : t.unmask(r, i)
|
|
},
|
|
}
|
|
} catch {
|
|
Zn.exports = {
|
|
concat: Ff,
|
|
mask: Wf,
|
|
toArrayBuffer: Hf,
|
|
toBuffer: pi,
|
|
unmask: Vf,
|
|
}
|
|
}
|
|
})
|
|
var zf = b((Iw, Gf) => {
|
|
'use strict'
|
|
var $f = Symbol('kDone'),
|
|
es = Symbol('kRun'),
|
|
ts = class {
|
|
constructor(t) {
|
|
;(this[$f] = () => {
|
|
this.pending--, this[es]()
|
|
}),
|
|
(this.concurrency = t || 1 / 0),
|
|
(this.jobs = []),
|
|
(this.pending = 0)
|
|
}
|
|
add(t) {
|
|
this.jobs.push(t), this[es]()
|
|
}
|
|
[es]() {
|
|
if (this.pending !== this.concurrency && this.jobs.length) {
|
|
let t = this.jobs.shift()
|
|
this.pending++, t(this[$f])
|
|
}
|
|
}
|
|
}
|
|
Gf.exports = ts
|
|
})
|
|
var ir = b((Ow, Jf) => {
|
|
'use strict'
|
|
var tr = require('zlib'),
|
|
Kf = er(),
|
|
_g = zf(),
|
|
{ kStatusCode: Yf, NOOP: gg } = ut(),
|
|
bg = Buffer.from([0, 0, 255, 255]),
|
|
bi = Symbol('permessage-deflate'),
|
|
Pe = Symbol('total-length'),
|
|
rr = Symbol('callback'),
|
|
Je = Symbol('buffers'),
|
|
gi = Symbol('error'),
|
|
_i,
|
|
rs = class {
|
|
constructor(t, r, i) {
|
|
if (
|
|
((this._maxPayload = i | 0),
|
|
(this._options = t || {}),
|
|
(this._threshold =
|
|
this._options.threshold !== void 0
|
|
? this._options.threshold
|
|
: 1024),
|
|
(this._isServer = !!r),
|
|
(this._deflate = null),
|
|
(this._inflate = null),
|
|
(this.params = null),
|
|
!_i)
|
|
) {
|
|
let n =
|
|
this._options.concurrencyLimit !== void 0
|
|
? this._options.concurrencyLimit
|
|
: 10
|
|
_i = new _g(n)
|
|
}
|
|
}
|
|
static get extensionName() {
|
|
return 'permessage-deflate'
|
|
}
|
|
offer() {
|
|
let t = {}
|
|
return (
|
|
this._options.serverNoContextTakeover &&
|
|
(t.server_no_context_takeover = !0),
|
|
this._options.clientNoContextTakeover &&
|
|
(t.client_no_context_takeover = !0),
|
|
this._options.serverMaxWindowBits &&
|
|
(t.server_max_window_bits = this._options.serverMaxWindowBits),
|
|
this._options.clientMaxWindowBits
|
|
? (t.client_max_window_bits = this._options.clientMaxWindowBits)
|
|
: this._options.clientMaxWindowBits == null &&
|
|
(t.client_max_window_bits = !0),
|
|
t
|
|
)
|
|
}
|
|
accept(t) {
|
|
return (
|
|
(t = this.normalizeParams(t)),
|
|
(this.params = this._isServer
|
|
? this.acceptAsServer(t)
|
|
: this.acceptAsClient(t)),
|
|
this.params
|
|
)
|
|
}
|
|
cleanup() {
|
|
if (
|
|
(this._inflate && (this._inflate.close(), (this._inflate = null)),
|
|
this._deflate)
|
|
) {
|
|
let t = this._deflate[rr]
|
|
this._deflate.close(),
|
|
(this._deflate = null),
|
|
t &&
|
|
t(
|
|
new Error(
|
|
'The deflate stream was closed while data was being processed',
|
|
),
|
|
)
|
|
}
|
|
}
|
|
acceptAsServer(t) {
|
|
let r = this._options,
|
|
i = t.find(
|
|
(n) =>
|
|
!(
|
|
(r.serverNoContextTakeover === !1 &&
|
|
n.server_no_context_takeover) ||
|
|
(n.server_max_window_bits &&
|
|
(r.serverMaxWindowBits === !1 ||
|
|
(typeof r.serverMaxWindowBits == 'number' &&
|
|
r.serverMaxWindowBits > n.server_max_window_bits))) ||
|
|
(typeof r.clientMaxWindowBits == 'number' &&
|
|
!n.client_max_window_bits)
|
|
),
|
|
)
|
|
if (!i) throw new Error('None of the extension offers can be accepted')
|
|
return (
|
|
r.serverNoContextTakeover && (i.server_no_context_takeover = !0),
|
|
r.clientNoContextTakeover && (i.client_no_context_takeover = !0),
|
|
typeof r.serverMaxWindowBits == 'number' &&
|
|
(i.server_max_window_bits = r.serverMaxWindowBits),
|
|
typeof r.clientMaxWindowBits == 'number'
|
|
? (i.client_max_window_bits = r.clientMaxWindowBits)
|
|
: (i.client_max_window_bits === !0 ||
|
|
r.clientMaxWindowBits === !1) &&
|
|
delete i.client_max_window_bits,
|
|
i
|
|
)
|
|
}
|
|
acceptAsClient(t) {
|
|
let r = t[0]
|
|
if (
|
|
this._options.clientNoContextTakeover === !1 &&
|
|
r.client_no_context_takeover
|
|
)
|
|
throw new Error('Unexpected parameter "client_no_context_takeover"')
|
|
if (!r.client_max_window_bits)
|
|
typeof this._options.clientMaxWindowBits == 'number' &&
|
|
(r.client_max_window_bits = this._options.clientMaxWindowBits)
|
|
else if (
|
|
this._options.clientMaxWindowBits === !1 ||
|
|
(typeof this._options.clientMaxWindowBits == 'number' &&
|
|
r.client_max_window_bits > this._options.clientMaxWindowBits)
|
|
)
|
|
throw new Error(
|
|
'Unexpected or invalid parameter "client_max_window_bits"',
|
|
)
|
|
return r
|
|
}
|
|
normalizeParams(t) {
|
|
return (
|
|
t.forEach((r) => {
|
|
Object.keys(r).forEach((i) => {
|
|
let n = r[i]
|
|
if (n.length > 1)
|
|
throw new Error(
|
|
`Parameter "${i}" must have only a single value`,
|
|
)
|
|
if (((n = n[0]), i === 'client_max_window_bits')) {
|
|
if (n !== !0) {
|
|
let s = +n
|
|
if (!Number.isInteger(s) || s < 8 || s > 15)
|
|
throw new TypeError(
|
|
`Invalid value for parameter "${i}": ${n}`,
|
|
)
|
|
n = s
|
|
} else if (!this._isServer)
|
|
throw new TypeError(
|
|
`Invalid value for parameter "${i}": ${n}`,
|
|
)
|
|
} else if (i === 'server_max_window_bits') {
|
|
let s = +n
|
|
if (!Number.isInteger(s) || s < 8 || s > 15)
|
|
throw new TypeError(
|
|
`Invalid value for parameter "${i}": ${n}`,
|
|
)
|
|
n = s
|
|
} else if (
|
|
i === 'client_no_context_takeover' ||
|
|
i === 'server_no_context_takeover'
|
|
) {
|
|
if (n !== !0)
|
|
throw new TypeError(
|
|
`Invalid value for parameter "${i}": ${n}`,
|
|
)
|
|
} else throw new Error(`Unknown parameter "${i}"`)
|
|
r[i] = n
|
|
})
|
|
}),
|
|
t
|
|
)
|
|
}
|
|
decompress(t, r, i) {
|
|
_i.add((n) => {
|
|
this._decompress(t, r, (s, o) => {
|
|
n(), i(s, o)
|
|
})
|
|
})
|
|
}
|
|
compress(t, r, i) {
|
|
_i.add((n) => {
|
|
this._compress(t, r, (s, o) => {
|
|
n(), i(s, o)
|
|
})
|
|
})
|
|
}
|
|
_decompress(t, r, i) {
|
|
let n = this._isServer ? 'client' : 'server'
|
|
if (!this._inflate) {
|
|
let s = `${n}_max_window_bits`,
|
|
o =
|
|
typeof this.params[s] != 'number'
|
|
? tr.Z_DEFAULT_WINDOWBITS
|
|
: this.params[s]
|
|
;(this._inflate = tr.createInflateRaw({
|
|
...this._options.zlibInflateOptions,
|
|
windowBits: o,
|
|
})),
|
|
(this._inflate[bi] = this),
|
|
(this._inflate[Pe] = 0),
|
|
(this._inflate[Je] = []),
|
|
this._inflate.on('error', vg),
|
|
this._inflate.on('data', Qf)
|
|
}
|
|
;(this._inflate[rr] = i),
|
|
this._inflate.write(t),
|
|
r && this._inflate.write(bg),
|
|
this._inflate.flush(() => {
|
|
let s = this._inflate[gi]
|
|
if (s) {
|
|
this._inflate.close(), (this._inflate = null), i(s)
|
|
return
|
|
}
|
|
let o = Kf.concat(this._inflate[Je], this._inflate[Pe])
|
|
this._inflate._readableState.endEmitted
|
|
? (this._inflate.close(), (this._inflate = null))
|
|
: ((this._inflate[Pe] = 0),
|
|
(this._inflate[Je] = []),
|
|
r &&
|
|
this.params[`${n}_no_context_takeover`] &&
|
|
this._inflate.reset()),
|
|
i(null, o)
|
|
})
|
|
}
|
|
_compress(t, r, i) {
|
|
let n = this._isServer ? 'server' : 'client'
|
|
if (!this._deflate) {
|
|
let s = `${n}_max_window_bits`,
|
|
o =
|
|
typeof this.params[s] != 'number'
|
|
? tr.Z_DEFAULT_WINDOWBITS
|
|
: this.params[s]
|
|
;(this._deflate = tr.createDeflateRaw({
|
|
...this._options.zlibDeflateOptions,
|
|
windowBits: o,
|
|
})),
|
|
(this._deflate[Pe] = 0),
|
|
(this._deflate[Je] = []),
|
|
this._deflate.on('error', gg),
|
|
this._deflate.on('data', yg)
|
|
}
|
|
;(this._deflate[rr] = i),
|
|
this._deflate.write(t),
|
|
this._deflate.flush(tr.Z_SYNC_FLUSH, () => {
|
|
if (!this._deflate) return
|
|
let s = Kf.concat(this._deflate[Je], this._deflate[Pe])
|
|
r && (s = s.slice(0, s.length - 4)),
|
|
(this._deflate[rr] = null),
|
|
(this._deflate[Pe] = 0),
|
|
(this._deflate[Je] = []),
|
|
r &&
|
|
this.params[`${n}_no_context_takeover`] &&
|
|
this._deflate.reset(),
|
|
i(null, s)
|
|
})
|
|
}
|
|
}
|
|
Jf.exports = rs
|
|
function yg(e) {
|
|
this[Je].push(e), (this[Pe] += e.length)
|
|
}
|
|
function Qf(e) {
|
|
if (
|
|
((this[Pe] += e.length),
|
|
this[bi]._maxPayload < 1 || this[Pe] <= this[bi]._maxPayload)
|
|
) {
|
|
this[Je].push(e)
|
|
return
|
|
}
|
|
;(this[gi] = new RangeError('Max payload size exceeded')),
|
|
(this[gi].code = 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH'),
|
|
(this[gi][Yf] = 1009),
|
|
this.removeListener('data', Qf),
|
|
this.reset()
|
|
}
|
|
function vg(e) {
|
|
;(this[bi]._inflate = null), (e[Yf] = 1007), this[rr](e)
|
|
}
|
|
})
|
|
var ns = b((kw, is) => {
|
|
'use strict'
|
|
function Xf(e) {
|
|
return (
|
|
(e >= 1e3 && e <= 1014 && e !== 1004 && e !== 1005 && e !== 1006) ||
|
|
(e >= 3e3 && e <= 4999)
|
|
)
|
|
}
|
|
function Zf(e) {
|
|
let t = e.length,
|
|
r = 0
|
|
for (; r < t; )
|
|
if (!(e[r] & 128)) r++
|
|
else if ((e[r] & 224) === 192) {
|
|
if (r + 1 === t || (e[r + 1] & 192) !== 128 || (e[r] & 254) === 192)
|
|
return !1
|
|
r += 2
|
|
} else if ((e[r] & 240) === 224) {
|
|
if (
|
|
r + 2 >= t ||
|
|
(e[r + 1] & 192) !== 128 ||
|
|
(e[r + 2] & 192) !== 128 ||
|
|
(e[r] === 224 && (e[r + 1] & 224) === 128) ||
|
|
(e[r] === 237 && (e[r + 1] & 224) === 160)
|
|
)
|
|
return !1
|
|
r += 3
|
|
} else if ((e[r] & 248) === 240) {
|
|
if (
|
|
r + 3 >= t ||
|
|
(e[r + 1] & 192) !== 128 ||
|
|
(e[r + 2] & 192) !== 128 ||
|
|
(e[r + 3] & 192) !== 128 ||
|
|
(e[r] === 240 && (e[r + 1] & 240) === 128) ||
|
|
(e[r] === 244 && e[r + 1] > 143) ||
|
|
e[r] > 244
|
|
)
|
|
return !1
|
|
r += 4
|
|
} else return !1
|
|
return !0
|
|
}
|
|
try {
|
|
let e = require('utf-8-validate')
|
|
typeof e == 'object' && (e = e.Validation.isValidUTF8),
|
|
(is.exports = {
|
|
isValidStatusCode: Xf,
|
|
isValidUTF8(t) {
|
|
return t.length < 150 ? Zf(t) : e(t)
|
|
},
|
|
})
|
|
} catch {
|
|
is.exports = { isValidStatusCode: Xf, isValidUTF8: Zf }
|
|
}
|
|
})
|
|
var fs = b((Rw, sl) => {
|
|
'use strict'
|
|
var { Writable: mg } = require('stream'),
|
|
el = ir(),
|
|
{
|
|
BINARY_TYPES: wg,
|
|
EMPTY_BUFFER: Sg,
|
|
kStatusCode: Eg,
|
|
kWebSocket: xg,
|
|
} = ut(),
|
|
{ concat: ss, toArrayBuffer: Cg, unmask: Tg } = er(),
|
|
{ isValidStatusCode: Ig, isValidUTF8: tl } = ns(),
|
|
nr = 0,
|
|
rl = 1,
|
|
il = 2,
|
|
nl = 3,
|
|
os = 4,
|
|
Og = 5,
|
|
as = class extends mg {
|
|
constructor(t, r, i, n) {
|
|
super(),
|
|
(this._binaryType = t || wg[0]),
|
|
(this[xg] = void 0),
|
|
(this._extensions = r || {}),
|
|
(this._isServer = !!i),
|
|
(this._maxPayload = n | 0),
|
|
(this._bufferedBytes = 0),
|
|
(this._buffers = []),
|
|
(this._compressed = !1),
|
|
(this._payloadLength = 0),
|
|
(this._mask = void 0),
|
|
(this._fragmented = 0),
|
|
(this._masked = !1),
|
|
(this._fin = !1),
|
|
(this._opcode = 0),
|
|
(this._totalPayloadLength = 0),
|
|
(this._messageLength = 0),
|
|
(this._fragments = []),
|
|
(this._state = nr),
|
|
(this._loop = !1)
|
|
}
|
|
_write(t, r, i) {
|
|
if (this._opcode === 8 && this._state == nr) return i()
|
|
;(this._bufferedBytes += t.length),
|
|
this._buffers.push(t),
|
|
this.startLoop(i)
|
|
}
|
|
consume(t) {
|
|
if (((this._bufferedBytes -= t), t === this._buffers[0].length))
|
|
return this._buffers.shift()
|
|
if (t < this._buffers[0].length) {
|
|
let i = this._buffers[0]
|
|
return (this._buffers[0] = i.slice(t)), i.slice(0, t)
|
|
}
|
|
let r = Buffer.allocUnsafe(t)
|
|
do {
|
|
let i = this._buffers[0],
|
|
n = r.length - t
|
|
t >= i.length
|
|
? r.set(this._buffers.shift(), n)
|
|
: (r.set(new Uint8Array(i.buffer, i.byteOffset, t), n),
|
|
(this._buffers[0] = i.slice(t))),
|
|
(t -= i.length)
|
|
} while (t > 0)
|
|
return r
|
|
}
|
|
startLoop(t) {
|
|
let r
|
|
this._loop = !0
|
|
do
|
|
switch (this._state) {
|
|
case nr:
|
|
r = this.getInfo()
|
|
break
|
|
case rl:
|
|
r = this.getPayloadLength16()
|
|
break
|
|
case il:
|
|
r = this.getPayloadLength64()
|
|
break
|
|
case nl:
|
|
this.getMask()
|
|
break
|
|
case os:
|
|
r = this.getData(t)
|
|
break
|
|
default:
|
|
this._loop = !1
|
|
return
|
|
}
|
|
while (this._loop)
|
|
t(r)
|
|
}
|
|
getInfo() {
|
|
if (this._bufferedBytes < 2) {
|
|
this._loop = !1
|
|
return
|
|
}
|
|
let t = this.consume(2)
|
|
if (t[0] & 48)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'RSV2 and RSV3 must be clear',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_UNEXPECTED_RSV_2_3',
|
|
)
|
|
)
|
|
let r = (t[0] & 64) === 64
|
|
if (r && !this._extensions[el.extensionName])
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'RSV1 must be clear',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_UNEXPECTED_RSV_1',
|
|
)
|
|
)
|
|
if (
|
|
((this._fin = (t[0] & 128) === 128),
|
|
(this._opcode = t[0] & 15),
|
|
(this._payloadLength = t[1] & 127),
|
|
this._opcode === 0)
|
|
) {
|
|
if (r)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'RSV1 must be clear',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_UNEXPECTED_RSV_1',
|
|
)
|
|
)
|
|
if (!this._fragmented)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'invalid opcode 0',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_INVALID_OPCODE',
|
|
)
|
|
)
|
|
this._opcode = this._fragmented
|
|
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
if (this._fragmented)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
`invalid opcode ${this._opcode}`,
|
|
!0,
|
|
1002,
|
|
'WS_ERR_INVALID_OPCODE',
|
|
)
|
|
)
|
|
this._compressed = r
|
|
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
if (!this._fin)
|
|
return (
|
|
(this._loop = !1),
|
|
K(RangeError, 'FIN must be set', !0, 1002, 'WS_ERR_EXPECTED_FIN')
|
|
)
|
|
if (r)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'RSV1 must be clear',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_UNEXPECTED_RSV_1',
|
|
)
|
|
)
|
|
if (this._payloadLength > 125)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
`invalid payload length ${this._payloadLength}`,
|
|
!0,
|
|
1002,
|
|
'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH',
|
|
)
|
|
)
|
|
} else
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
`invalid opcode ${this._opcode}`,
|
|
!0,
|
|
1002,
|
|
'WS_ERR_INVALID_OPCODE',
|
|
)
|
|
)
|
|
if (
|
|
(!this._fin && !this._fragmented && (this._fragmented = this._opcode),
|
|
(this._masked = (t[1] & 128) === 128),
|
|
this._isServer)
|
|
) {
|
|
if (!this._masked)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'MASK must be set',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_EXPECTED_MASK',
|
|
)
|
|
)
|
|
} else if (this._masked)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'MASK must be clear',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_UNEXPECTED_MASK',
|
|
)
|
|
)
|
|
if (this._payloadLength === 126) this._state = rl
|
|
else if (this._payloadLength === 127) this._state = il
|
|
else return this.haveLength()
|
|
}
|
|
getPayloadLength16() {
|
|
if (this._bufferedBytes < 2) {
|
|
this._loop = !1
|
|
return
|
|
}
|
|
return (
|
|
(this._payloadLength = this.consume(2).readUInt16BE(0)),
|
|
this.haveLength()
|
|
)
|
|
}
|
|
getPayloadLength64() {
|
|
if (this._bufferedBytes < 8) {
|
|
this._loop = !1
|
|
return
|
|
}
|
|
let t = this.consume(8),
|
|
r = t.readUInt32BE(0)
|
|
return r > Math.pow(2, 21) - 1
|
|
? ((this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'Unsupported WebSocket frame: payload length > 2^53 - 1',
|
|
!1,
|
|
1009,
|
|
'WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH',
|
|
))
|
|
: ((this._payloadLength = r * Math.pow(2, 32) + t.readUInt32BE(4)),
|
|
this.haveLength())
|
|
}
|
|
haveLength() {
|
|
if (
|
|
this._payloadLength &&
|
|
this._opcode < 8 &&
|
|
((this._totalPayloadLength += this._payloadLength),
|
|
this._totalPayloadLength > this._maxPayload && this._maxPayload > 0)
|
|
)
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
RangeError,
|
|
'Max payload size exceeded',
|
|
!1,
|
|
1009,
|
|
'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH',
|
|
)
|
|
)
|
|
this._masked ? (this._state = nl) : (this._state = os)
|
|
}
|
|
getMask() {
|
|
if (this._bufferedBytes < 4) {
|
|
this._loop = !1
|
|
return
|
|
}
|
|
;(this._mask = this.consume(4)), (this._state = os)
|
|
}
|
|
getData(t) {
|
|
let r = Sg
|
|
if (this._payloadLength) {
|
|
if (this._bufferedBytes < this._payloadLength) {
|
|
this._loop = !1
|
|
return
|
|
}
|
|
;(r = this.consume(this._payloadLength)),
|
|
this._masked && Tg(r, this._mask)
|
|
}
|
|
if (this._opcode > 7) return this.controlMessage(r)
|
|
if (this._compressed) {
|
|
;(this._state = Og), this.decompress(r, t)
|
|
return
|
|
}
|
|
return (
|
|
r.length &&
|
|
((this._messageLength = this._totalPayloadLength),
|
|
this._fragments.push(r)),
|
|
this.dataMessage()
|
|
)
|
|
}
|
|
decompress(t, r) {
|
|
this._extensions[el.extensionName].decompress(t, this._fin, (n, s) => {
|
|
if (n) return r(n)
|
|
if (s.length) {
|
|
if (
|
|
((this._messageLength += s.length),
|
|
this._messageLength > this._maxPayload && this._maxPayload > 0)
|
|
)
|
|
return r(
|
|
K(
|
|
RangeError,
|
|
'Max payload size exceeded',
|
|
!1,
|
|
1009,
|
|
'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH',
|
|
),
|
|
)
|
|
this._fragments.push(s)
|
|
}
|
|
let o = this.dataMessage()
|
|
if (o) return r(o)
|
|
this.startLoop(r)
|
|
})
|
|
}
|
|
dataMessage() {
|
|
if (this._fin) {
|
|
let t = this._messageLength,
|
|
r = this._fragments
|
|
if (
|
|
((this._totalPayloadLength = 0),
|
|
(this._messageLength = 0),
|
|
(this._fragmented = 0),
|
|
(this._fragments = []),
|
|
this._opcode === 2)
|
|
) {
|
|
let i
|
|
this._binaryType === 'nodebuffer'
|
|
? (i = ss(r, t))
|
|
: this._binaryType === 'arraybuffer'
|
|
? (i = Cg(ss(r, t)))
|
|
: (i = r),
|
|
this.emit('message', i)
|
|
} else {
|
|
let i = ss(r, t)
|
|
if (!tl(i))
|
|
return (
|
|
(this._loop = !1),
|
|
K(
|
|
Error,
|
|
'invalid UTF-8 sequence',
|
|
!0,
|
|
1007,
|
|
'WS_ERR_INVALID_UTF8',
|
|
)
|
|
)
|
|
this.emit('message', i.toString())
|
|
}
|
|
}
|
|
this._state = nr
|
|
}
|
|
controlMessage(t) {
|
|
if (this._opcode === 8)
|
|
if (((this._loop = !1), t.length === 0))
|
|
this.emit('conclude', 1005, ''), this.end()
|
|
else {
|
|
if (t.length === 1)
|
|
return K(
|
|
RangeError,
|
|
'invalid payload length 1',
|
|
!0,
|
|
1002,
|
|
'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH',
|
|
)
|
|
{
|
|
let r = t.readUInt16BE(0)
|
|
if (!Ig(r))
|
|
return K(
|
|
RangeError,
|
|
`invalid status code ${r}`,
|
|
!0,
|
|
1002,
|
|
'WS_ERR_INVALID_CLOSE_CODE',
|
|
)
|
|
let i = t.slice(2)
|
|
if (!tl(i))
|
|
return K(
|
|
Error,
|
|
'invalid UTF-8 sequence',
|
|
!0,
|
|
1007,
|
|
'WS_ERR_INVALID_UTF8',
|
|
)
|
|
this.emit('conclude', r, i.toString()), this.end()
|
|
}
|
|
}
|
|
else this._opcode === 9 ? this.emit('ping', t) : this.emit('pong', t)
|
|
this._state = nr
|
|
}
|
|
}
|
|
sl.exports = as
|
|
function K(e, t, r, i, n) {
|
|
let s = new e(r ? `Invalid WebSocket frame: ${t}` : t)
|
|
return Error.captureStackTrace(s, K), (s.code = n), (s[Eg] = i), s
|
|
}
|
|
})
|
|
var us = b((Aw, fl) => {
|
|
'use strict'
|
|
var Pw = require('net'),
|
|
Bw = require('tls'),
|
|
{ randomFillSync: kg } = require('crypto'),
|
|
ol = ir(),
|
|
{ EMPTY_BUFFER: Rg } = ut(),
|
|
{ isValidStatusCode: Pg } = ns(),
|
|
{ mask: al, toBuffer: Be } = er(),
|
|
ct = Buffer.alloc(4),
|
|
ls = class e {
|
|
constructor(t, r) {
|
|
;(this._extensions = r || {}),
|
|
(this._socket = t),
|
|
(this._firstFragment = !0),
|
|
(this._compress = !1),
|
|
(this._bufferedBytes = 0),
|
|
(this._deflating = !1),
|
|
(this._queue = [])
|
|
}
|
|
static frame(t, r) {
|
|
let i = r.mask && r.readOnly,
|
|
n = r.mask ? 6 : 2,
|
|
s = t.length
|
|
t.length >= 65536
|
|
? ((n += 8), (s = 127))
|
|
: t.length > 125 && ((n += 2), (s = 126))
|
|
let o = Buffer.allocUnsafe(i ? t.length + n : n)
|
|
return (
|
|
(o[0] = r.fin ? r.opcode | 128 : r.opcode),
|
|
r.rsv1 && (o[0] |= 64),
|
|
(o[1] = s),
|
|
s === 126
|
|
? o.writeUInt16BE(t.length, 2)
|
|
: s === 127 &&
|
|
(o.writeUInt32BE(0, 2), o.writeUInt32BE(t.length, 6)),
|
|
r.mask
|
|
? (kg(ct, 0, 4),
|
|
(o[1] |= 128),
|
|
(o[n - 4] = ct[0]),
|
|
(o[n - 3] = ct[1]),
|
|
(o[n - 2] = ct[2]),
|
|
(o[n - 1] = ct[3]),
|
|
i
|
|
? (al(t, ct, o, n, t.length), [o])
|
|
: (al(t, ct, t, 0, t.length), [o, t]))
|
|
: [o, t]
|
|
)
|
|
}
|
|
close(t, r, i, n) {
|
|
let s
|
|
if (t === void 0) s = Rg
|
|
else {
|
|
if (typeof t != 'number' || !Pg(t))
|
|
throw new TypeError(
|
|
'First argument must be a valid error code number',
|
|
)
|
|
if (r === void 0 || r === '')
|
|
(s = Buffer.allocUnsafe(2)), s.writeUInt16BE(t, 0)
|
|
else {
|
|
let o = Buffer.byteLength(r)
|
|
if (o > 123)
|
|
throw new RangeError(
|
|
'The message must not be greater than 123 bytes',
|
|
)
|
|
;(s = Buffer.allocUnsafe(2 + o)),
|
|
s.writeUInt16BE(t, 0),
|
|
s.write(r, 2)
|
|
}
|
|
}
|
|
this._deflating
|
|
? this.enqueue([this.doClose, s, i, n])
|
|
: this.doClose(s, i, n)
|
|
}
|
|
doClose(t, r, i) {
|
|
this.sendFrame(
|
|
e.frame(t, { fin: !0, rsv1: !1, opcode: 8, mask: r, readOnly: !1 }),
|
|
i,
|
|
)
|
|
}
|
|
ping(t, r, i) {
|
|
let n = Be(t)
|
|
if (n.length > 125)
|
|
throw new RangeError(
|
|
'The data size must not be greater than 125 bytes',
|
|
)
|
|
this._deflating
|
|
? this.enqueue([this.doPing, n, r, Be.readOnly, i])
|
|
: this.doPing(n, r, Be.readOnly, i)
|
|
}
|
|
doPing(t, r, i, n) {
|
|
this.sendFrame(
|
|
e.frame(t, { fin: !0, rsv1: !1, opcode: 9, mask: r, readOnly: i }),
|
|
n,
|
|
)
|
|
}
|
|
pong(t, r, i) {
|
|
let n = Be(t)
|
|
if (n.length > 125)
|
|
throw new RangeError(
|
|
'The data size must not be greater than 125 bytes',
|
|
)
|
|
this._deflating
|
|
? this.enqueue([this.doPong, n, r, Be.readOnly, i])
|
|
: this.doPong(n, r, Be.readOnly, i)
|
|
}
|
|
doPong(t, r, i, n) {
|
|
this.sendFrame(
|
|
e.frame(t, { fin: !0, rsv1: !1, opcode: 10, mask: r, readOnly: i }),
|
|
n,
|
|
)
|
|
}
|
|
send(t, r, i) {
|
|
let n = Be(t),
|
|
s = this._extensions[ol.extensionName],
|
|
o = r.binary ? 2 : 1,
|
|
f = r.compress
|
|
if (
|
|
(this._firstFragment
|
|
? ((this._firstFragment = !1),
|
|
f && s && (f = n.length >= s._threshold),
|
|
(this._compress = f))
|
|
: ((f = !1), (o = 0)),
|
|
r.fin && (this._firstFragment = !0),
|
|
s)
|
|
) {
|
|
let a = {
|
|
fin: r.fin,
|
|
rsv1: f,
|
|
opcode: o,
|
|
mask: r.mask,
|
|
readOnly: Be.readOnly,
|
|
}
|
|
this._deflating
|
|
? this.enqueue([this.dispatch, n, this._compress, a, i])
|
|
: this.dispatch(n, this._compress, a, i)
|
|
} else
|
|
this.sendFrame(
|
|
e.frame(n, {
|
|
fin: r.fin,
|
|
rsv1: !1,
|
|
opcode: o,
|
|
mask: r.mask,
|
|
readOnly: Be.readOnly,
|
|
}),
|
|
i,
|
|
)
|
|
}
|
|
dispatch(t, r, i, n) {
|
|
if (!r) {
|
|
this.sendFrame(e.frame(t, i), n)
|
|
return
|
|
}
|
|
let s = this._extensions[ol.extensionName]
|
|
;(this._bufferedBytes += t.length),
|
|
(this._deflating = !0),
|
|
s.compress(t, i.fin, (o, f) => {
|
|
if (this._socket.destroyed) {
|
|
let a = new Error(
|
|
'The socket was closed while data was being compressed',
|
|
)
|
|
typeof n == 'function' && n(a)
|
|
for (let l = 0; l < this._queue.length; l++) {
|
|
let u = this._queue[l][4]
|
|
typeof u == 'function' && u(a)
|
|
}
|
|
return
|
|
}
|
|
;(this._bufferedBytes -= t.length),
|
|
(this._deflating = !1),
|
|
(i.readOnly = !1),
|
|
this.sendFrame(e.frame(f, i), n),
|
|
this.dequeue()
|
|
})
|
|
}
|
|
dequeue() {
|
|
for (; !this._deflating && this._queue.length; ) {
|
|
let t = this._queue.shift()
|
|
;(this._bufferedBytes -= t[1].length),
|
|
Reflect.apply(t[0], this, t.slice(1))
|
|
}
|
|
}
|
|
enqueue(t) {
|
|
;(this._bufferedBytes += t[1].length), this._queue.push(t)
|
|
}
|
|
sendFrame(t, r) {
|
|
t.length === 2
|
|
? (this._socket.cork(),
|
|
this._socket.write(t[0]),
|
|
this._socket.write(t[1], r),
|
|
this._socket.uncork())
|
|
: this._socket.write(t[0], r)
|
|
}
|
|
}
|
|
fl.exports = ls
|
|
})
|
|
var ul = b((Nw, ll) => {
|
|
'use strict'
|
|
var Rt = class {
|
|
constructor(t, r) {
|
|
;(this.target = r), (this.type = t)
|
|
}
|
|
},
|
|
cs = class extends Rt {
|
|
constructor(t, r) {
|
|
super('message', r), (this.data = t)
|
|
}
|
|
},
|
|
hs = class extends Rt {
|
|
constructor(t, r, i) {
|
|
super('close', i),
|
|
(this.wasClean = i._closeFrameReceived && i._closeFrameSent),
|
|
(this.reason = r),
|
|
(this.code = t)
|
|
}
|
|
},
|
|
ds = class extends Rt {
|
|
constructor(t) {
|
|
super('open', t)
|
|
}
|
|
},
|
|
ps = class extends Rt {
|
|
constructor(t, r) {
|
|
super('error', r), (this.message = t.message), (this.error = t)
|
|
}
|
|
},
|
|
Bg = {
|
|
addEventListener(e, t, r) {
|
|
if (typeof t != 'function') return
|
|
function i(a) {
|
|
t.call(this, new cs(a, this))
|
|
}
|
|
function n(a, l) {
|
|
t.call(this, new hs(a, l, this))
|
|
}
|
|
function s(a) {
|
|
t.call(this, new ps(a, this))
|
|
}
|
|
function o() {
|
|
t.call(this, new ds(this))
|
|
}
|
|
let f = r && r.once ? 'once' : 'on'
|
|
e === 'message'
|
|
? ((i._listener = t), this[f](e, i))
|
|
: e === 'close'
|
|
? ((n._listener = t), this[f](e, n))
|
|
: e === 'error'
|
|
? ((s._listener = t), this[f](e, s))
|
|
: e === 'open'
|
|
? ((o._listener = t), this[f](e, o))
|
|
: this[f](e, t)
|
|
},
|
|
removeEventListener(e, t) {
|
|
let r = this.listeners(e)
|
|
for (let i = 0; i < r.length; i++)
|
|
(r[i] === t || r[i]._listener === t) && this.removeListener(e, r[i])
|
|
},
|
|
}
|
|
ll.exports = Bg
|
|
})
|
|
var _s = b((Mw, cl) => {
|
|
'use strict'
|
|
var sr = [
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
|
|
0, 1, 0,
|
|
]
|
|
function Ce(e, t, r) {
|
|
e[t] === void 0 ? (e[t] = [r]) : e[t].push(r)
|
|
}
|
|
function Ag(e) {
|
|
let t = Object.create(null)
|
|
if (e === void 0 || e === '') return t
|
|
let r = Object.create(null),
|
|
i = !1,
|
|
n = !1,
|
|
s = !1,
|
|
o,
|
|
f,
|
|
a = -1,
|
|
l = -1,
|
|
u = 0
|
|
for (; u < e.length; u++) {
|
|
let c = e.charCodeAt(u)
|
|
if (o === void 0)
|
|
if (l === -1 && sr[c] === 1) a === -1 && (a = u)
|
|
else if (c === 32 || c === 9) l === -1 && a !== -1 && (l = u)
|
|
else if (c === 59 || c === 44) {
|
|
if (a === -1)
|
|
throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
l === -1 && (l = u)
|
|
let d = e.slice(a, l)
|
|
c === 44 ? (Ce(t, d, r), (r = Object.create(null))) : (o = d),
|
|
(a = l = -1)
|
|
} else throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
else if (f === void 0)
|
|
if (l === -1 && sr[c] === 1) a === -1 && (a = u)
|
|
else if (c === 32 || c === 9) l === -1 && a !== -1 && (l = u)
|
|
else if (c === 59 || c === 44) {
|
|
if (a === -1)
|
|
throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
l === -1 && (l = u),
|
|
Ce(r, e.slice(a, l), !0),
|
|
c === 44 && (Ce(t, o, r), (r = Object.create(null)), (o = void 0)),
|
|
(a = l = -1)
|
|
} else if (c === 61 && a !== -1 && l === -1)
|
|
(f = e.slice(a, u)), (a = l = -1)
|
|
else throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
else if (n) {
|
|
if (sr[c] !== 1)
|
|
throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
a === -1 ? (a = u) : i || (i = !0), (n = !1)
|
|
} else if (s)
|
|
if (sr[c] === 1) a === -1 && (a = u)
|
|
else if (c === 34 && a !== -1) (s = !1), (l = u)
|
|
else if (c === 92) n = !0
|
|
else throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
else if (c === 34 && e.charCodeAt(u - 1) === 61) s = !0
|
|
else if (l === -1 && sr[c] === 1) a === -1 && (a = u)
|
|
else if (a !== -1 && (c === 32 || c === 9)) l === -1 && (l = u)
|
|
else if (c === 59 || c === 44) {
|
|
if (a === -1)
|
|
throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
l === -1 && (l = u)
|
|
let d = e.slice(a, l)
|
|
i && ((d = d.replace(/\\/g, '')), (i = !1)),
|
|
Ce(r, f, d),
|
|
c === 44 && (Ce(t, o, r), (r = Object.create(null)), (o = void 0)),
|
|
(f = void 0),
|
|
(a = l = -1)
|
|
} else throw new SyntaxError(`Unexpected character at index ${u}`)
|
|
}
|
|
if (a === -1 || s) throw new SyntaxError('Unexpected end of input')
|
|
l === -1 && (l = u)
|
|
let h = e.slice(a, l)
|
|
return (
|
|
o === void 0
|
|
? Ce(t, h, r)
|
|
: (f === void 0
|
|
? Ce(r, h, !0)
|
|
: i
|
|
? Ce(r, f, h.replace(/\\/g, ''))
|
|
: Ce(r, f, h),
|
|
Ce(t, o, r)),
|
|
t
|
|
)
|
|
}
|
|
function Ng(e) {
|
|
return Object.keys(e)
|
|
.map((t) => {
|
|
let r = e[t]
|
|
return (
|
|
Array.isArray(r) || (r = [r]),
|
|
r
|
|
.map((i) =>
|
|
[t]
|
|
.concat(
|
|
Object.keys(i).map((n) => {
|
|
let s = i[n]
|
|
return (
|
|
Array.isArray(s) || (s = [s]),
|
|
s.map((o) => (o === !0 ? n : `${n}=${o}`)).join('; ')
|
|
)
|
|
}),
|
|
)
|
|
.join('; '),
|
|
)
|
|
.join(', ')
|
|
)
|
|
})
|
|
.join(', ')
|
|
}
|
|
cl.exports = { format: Ng, parse: Ag }
|
|
})
|
|
var ws = b((qw, wl) => {
|
|
'use strict'
|
|
var Mg = require('events'),
|
|
Lg = require('https'),
|
|
qg = require('http'),
|
|
pl = require('net'),
|
|
Dg = require('tls'),
|
|
{ randomBytes: Ug, createHash: jg } = require('crypto'),
|
|
{ Readable: Lw } = require('stream'),
|
|
{ URL: gs } = require('url'),
|
|
Xe = ir(),
|
|
Fg = fs(),
|
|
Wg = us(),
|
|
{
|
|
BINARY_TYPES: hl,
|
|
EMPTY_BUFFER: bs,
|
|
GUID: Vg,
|
|
kStatusCode: Hg,
|
|
kWebSocket: te,
|
|
NOOP: _l,
|
|
} = ut(),
|
|
{ addEventListener: $g, removeEventListener: Gg } = ul(),
|
|
{ format: zg, parse: Kg } = _s(),
|
|
{ toBuffer: Yg } = er(),
|
|
Ae = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'],
|
|
ys = [8, 13],
|
|
Qg = 30 * 1e3,
|
|
G = class e extends Mg {
|
|
constructor(t, r, i) {
|
|
super(),
|
|
(this._binaryType = hl[0]),
|
|
(this._closeCode = 1006),
|
|
(this._closeFrameReceived = !1),
|
|
(this._closeFrameSent = !1),
|
|
(this._closeMessage = ''),
|
|
(this._closeTimer = null),
|
|
(this._extensions = {}),
|
|
(this._protocol = ''),
|
|
(this._readyState = e.CONNECTING),
|
|
(this._receiver = null),
|
|
(this._sender = null),
|
|
(this._socket = null),
|
|
t !== null
|
|
? ((this._bufferedAmount = 0),
|
|
(this._isServer = !1),
|
|
(this._redirects = 0),
|
|
Array.isArray(r)
|
|
? (r = r.join(', '))
|
|
: typeof r == 'object' && r !== null && ((i = r), (r = void 0)),
|
|
gl(this, t, r, i))
|
|
: (this._isServer = !0)
|
|
}
|
|
get binaryType() {
|
|
return this._binaryType
|
|
}
|
|
set binaryType(t) {
|
|
hl.includes(t) &&
|
|
((this._binaryType = t),
|
|
this._receiver && (this._receiver._binaryType = t))
|
|
}
|
|
get bufferedAmount() {
|
|
return this._socket
|
|
? this._socket._writableState.length + this._sender._bufferedBytes
|
|
: this._bufferedAmount
|
|
}
|
|
get extensions() {
|
|
return Object.keys(this._extensions).join()
|
|
}
|
|
get onclose() {}
|
|
set onclose(t) {}
|
|
get onerror() {}
|
|
set onerror(t) {}
|
|
get onopen() {}
|
|
set onopen(t) {}
|
|
get onmessage() {}
|
|
set onmessage(t) {}
|
|
get protocol() {
|
|
return this._protocol
|
|
}
|
|
get readyState() {
|
|
return this._readyState
|
|
}
|
|
get url() {
|
|
return this._url
|
|
}
|
|
setSocket(t, r, i) {
|
|
let n = new Fg(this.binaryType, this._extensions, this._isServer, i)
|
|
;(this._sender = new Wg(t, this._extensions)),
|
|
(this._receiver = n),
|
|
(this._socket = t),
|
|
(n[te] = this),
|
|
(t[te] = this),
|
|
n.on('conclude', Zg),
|
|
n.on('drain', eb),
|
|
n.on('error', tb),
|
|
n.on('message', rb),
|
|
n.on('ping', ib),
|
|
n.on('pong', nb),
|
|
t.setTimeout(0),
|
|
t.setNoDelay(),
|
|
r.length > 0 && t.unshift(r),
|
|
t.on('close', yl),
|
|
t.on('data', yi),
|
|
t.on('end', vl),
|
|
t.on('error', ml),
|
|
(this._readyState = e.OPEN),
|
|
this.emit('open')
|
|
}
|
|
emitClose() {
|
|
if (!this._socket) {
|
|
;(this._readyState = e.CLOSED),
|
|
this.emit('close', this._closeCode, this._closeMessage)
|
|
return
|
|
}
|
|
this._extensions[Xe.extensionName] &&
|
|
this._extensions[Xe.extensionName].cleanup(),
|
|
this._receiver.removeAllListeners(),
|
|
(this._readyState = e.CLOSED),
|
|
this.emit('close', this._closeCode, this._closeMessage)
|
|
}
|
|
close(t, r) {
|
|
if (this.readyState !== e.CLOSED) {
|
|
if (this.readyState === e.CONNECTING)
|
|
return ue(
|
|
this,
|
|
this._req,
|
|
'WebSocket was closed before the connection was established',
|
|
)
|
|
if (this.readyState === e.CLOSING) {
|
|
this._closeFrameSent &&
|
|
(this._closeFrameReceived ||
|
|
this._receiver._writableState.errorEmitted) &&
|
|
this._socket.end()
|
|
return
|
|
}
|
|
;(this._readyState = e.CLOSING),
|
|
this._sender.close(t, r, !this._isServer, (i) => {
|
|
i ||
|
|
((this._closeFrameSent = !0),
|
|
(this._closeFrameReceived ||
|
|
this._receiver._writableState.errorEmitted) &&
|
|
this._socket.end())
|
|
}),
|
|
(this._closeTimer = setTimeout(
|
|
this._socket.destroy.bind(this._socket),
|
|
Qg,
|
|
))
|
|
}
|
|
}
|
|
ping(t, r, i) {
|
|
if (this.readyState === e.CONNECTING)
|
|
throw new Error('WebSocket is not open: readyState 0 (CONNECTING)')
|
|
if (
|
|
(typeof t == 'function'
|
|
? ((i = t), (t = r = void 0))
|
|
: typeof r == 'function' && ((i = r), (r = void 0)),
|
|
typeof t == 'number' && (t = t.toString()),
|
|
this.readyState !== e.OPEN)
|
|
) {
|
|
ms(this, t, i)
|
|
return
|
|
}
|
|
r === void 0 && (r = !this._isServer), this._sender.ping(t || bs, r, i)
|
|
}
|
|
pong(t, r, i) {
|
|
if (this.readyState === e.CONNECTING)
|
|
throw new Error('WebSocket is not open: readyState 0 (CONNECTING)')
|
|
if (
|
|
(typeof t == 'function'
|
|
? ((i = t), (t = r = void 0))
|
|
: typeof r == 'function' && ((i = r), (r = void 0)),
|
|
typeof t == 'number' && (t = t.toString()),
|
|
this.readyState !== e.OPEN)
|
|
) {
|
|
ms(this, t, i)
|
|
return
|
|
}
|
|
r === void 0 && (r = !this._isServer), this._sender.pong(t || bs, r, i)
|
|
}
|
|
send(t, r, i) {
|
|
if (this.readyState === e.CONNECTING)
|
|
throw new Error('WebSocket is not open: readyState 0 (CONNECTING)')
|
|
if (
|
|
(typeof r == 'function' && ((i = r), (r = {})),
|
|
typeof t == 'number' && (t = t.toString()),
|
|
this.readyState !== e.OPEN)
|
|
) {
|
|
ms(this, t, i)
|
|
return
|
|
}
|
|
let n = {
|
|
binary: typeof t != 'string',
|
|
mask: !this._isServer,
|
|
compress: !0,
|
|
fin: !0,
|
|
...r,
|
|
}
|
|
this._extensions[Xe.extensionName] || (n.compress = !1),
|
|
this._sender.send(t || bs, n, i)
|
|
}
|
|
terminate() {
|
|
if (this.readyState !== e.CLOSED) {
|
|
if (this.readyState === e.CONNECTING)
|
|
return ue(
|
|
this,
|
|
this._req,
|
|
'WebSocket was closed before the connection was established',
|
|
)
|
|
this._socket &&
|
|
((this._readyState = e.CLOSING), this._socket.destroy())
|
|
}
|
|
}
|
|
}
|
|
Object.defineProperty(G, 'CONNECTING', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('CONNECTING'),
|
|
})
|
|
Object.defineProperty(G.prototype, 'CONNECTING', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('CONNECTING'),
|
|
})
|
|
Object.defineProperty(G, 'OPEN', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('OPEN'),
|
|
})
|
|
Object.defineProperty(G.prototype, 'OPEN', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('OPEN'),
|
|
})
|
|
Object.defineProperty(G, 'CLOSING', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('CLOSING'),
|
|
})
|
|
Object.defineProperty(G.prototype, 'CLOSING', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('CLOSING'),
|
|
})
|
|
Object.defineProperty(G, 'CLOSED', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('CLOSED'),
|
|
})
|
|
Object.defineProperty(G.prototype, 'CLOSED', {
|
|
enumerable: !0,
|
|
value: Ae.indexOf('CLOSED'),
|
|
})
|
|
;[
|
|
'binaryType',
|
|
'bufferedAmount',
|
|
'extensions',
|
|
'protocol',
|
|
'readyState',
|
|
'url',
|
|
].forEach((e) => {
|
|
Object.defineProperty(G.prototype, e, { enumerable: !0 })
|
|
})
|
|
;['open', 'error', 'close', 'message'].forEach((e) => {
|
|
Object.defineProperty(G.prototype, `on${e}`, {
|
|
enumerable: !0,
|
|
get() {
|
|
let t = this.listeners(e)
|
|
for (let r = 0; r < t.length; r++)
|
|
if (t[r]._listener) return t[r]._listener
|
|
},
|
|
set(t) {
|
|
let r = this.listeners(e)
|
|
for (let i = 0; i < r.length; i++)
|
|
r[i]._listener && this.removeListener(e, r[i])
|
|
this.addEventListener(e, t)
|
|
},
|
|
})
|
|
})
|
|
G.prototype.addEventListener = $g
|
|
G.prototype.removeEventListener = Gg
|
|
wl.exports = G
|
|
function gl(e, t, r, i) {
|
|
let n = {
|
|
protocolVersion: ys[1],
|
|
maxPayload: 104857600,
|
|
perMessageDeflate: !0,
|
|
followRedirects: !1,
|
|
maxRedirects: 10,
|
|
...i,
|
|
createConnection: void 0,
|
|
socketPath: void 0,
|
|
hostname: void 0,
|
|
protocol: void 0,
|
|
timeout: void 0,
|
|
method: void 0,
|
|
host: void 0,
|
|
path: void 0,
|
|
port: void 0,
|
|
}
|
|
if (!ys.includes(n.protocolVersion))
|
|
throw new RangeError(
|
|
`Unsupported protocol version: ${
|
|
n.protocolVersion
|
|
} (supported versions: ${ys.join(', ')})`,
|
|
)
|
|
let s
|
|
t instanceof gs
|
|
? ((s = t), (e._url = t.href))
|
|
: ((s = new gs(t)), (e._url = t))
|
|
let o = s.protocol === 'ws+unix:'
|
|
if (!s.host && (!o || !s.pathname)) {
|
|
let d = new Error(`Invalid URL: ${e.url}`)
|
|
if (e._redirects === 0) throw d
|
|
vs(e, d)
|
|
return
|
|
}
|
|
let f = s.protocol === 'wss:' || s.protocol === 'https:',
|
|
a = f ? 443 : 80,
|
|
l = Ug(16).toString('base64'),
|
|
u = f ? Lg.get : qg.get,
|
|
h
|
|
if (
|
|
((n.createConnection = f ? Xg : Jg),
|
|
(n.defaultPort = n.defaultPort || a),
|
|
(n.port = s.port || a),
|
|
(n.host = s.hostname.startsWith('[')
|
|
? s.hostname.slice(1, -1)
|
|
: s.hostname),
|
|
(n.headers = {
|
|
'Sec-WebSocket-Version': n.protocolVersion,
|
|
'Sec-WebSocket-Key': l,
|
|
Connection: 'Upgrade',
|
|
Upgrade: 'websocket',
|
|
...n.headers,
|
|
}),
|
|
(n.path = s.pathname + s.search),
|
|
(n.timeout = n.handshakeTimeout),
|
|
n.perMessageDeflate &&
|
|
((h = new Xe(
|
|
n.perMessageDeflate !== !0 ? n.perMessageDeflate : {},
|
|
!1,
|
|
n.maxPayload,
|
|
)),
|
|
(n.headers['Sec-WebSocket-Extensions'] = zg({
|
|
[Xe.extensionName]: h.offer(),
|
|
}))),
|
|
r && (n.headers['Sec-WebSocket-Protocol'] = r),
|
|
n.origin &&
|
|
(n.protocolVersion < 13
|
|
? (n.headers['Sec-WebSocket-Origin'] = n.origin)
|
|
: (n.headers.Origin = n.origin)),
|
|
(s.username || s.password) && (n.auth = `${s.username}:${s.password}`),
|
|
o)
|
|
) {
|
|
let d = n.path.split(':')
|
|
;(n.socketPath = d[0]), (n.path = d[1])
|
|
}
|
|
if (n.followRedirects) {
|
|
if (e._redirects === 0) {
|
|
;(e._originalUnixSocket = o),
|
|
(e._originalSecure = f),
|
|
(e._originalHostOrSocketPath = o ? n.socketPath : s.host)
|
|
let d = i && i.headers
|
|
if (((i = { ...i, headers: {} }), d))
|
|
for (let [_, v] of Object.entries(d)) i.headers[_.toLowerCase()] = v
|
|
} else {
|
|
let d = o
|
|
? e._originalUnixSocket
|
|
? n.socketPath === e._originalHostOrSocketPath
|
|
: !1
|
|
: e._originalUnixSocket
|
|
? !1
|
|
: s.host === e._originalHostOrSocketPath
|
|
;(!d || (e._originalSecure && !f)) &&
|
|
(delete n.headers.authorization,
|
|
delete n.headers.cookie,
|
|
d || delete n.headers.host,
|
|
(n.auth = void 0))
|
|
}
|
|
n.auth &&
|
|
!i.headers.authorization &&
|
|
(i.headers.authorization =
|
|
'Basic ' + Buffer.from(n.auth).toString('base64'))
|
|
}
|
|
let c = (e._req = u(n))
|
|
n.timeout &&
|
|
c.on('timeout', () => {
|
|
ue(e, c, 'Opening handshake has timed out')
|
|
}),
|
|
c.on('error', (d) => {
|
|
c === null || c.aborted || ((c = e._req = null), vs(e, d))
|
|
}),
|
|
c.on('response', (d) => {
|
|
let _ = d.headers.location,
|
|
v = d.statusCode
|
|
if (_ && n.followRedirects && v >= 300 && v < 400) {
|
|
if (++e._redirects > n.maxRedirects) {
|
|
ue(e, c, 'Maximum redirects exceeded')
|
|
return
|
|
}
|
|
c.abort()
|
|
let m
|
|
try {
|
|
m = new gs(_, t)
|
|
} catch (p) {
|
|
vs(e, p)
|
|
return
|
|
}
|
|
gl(e, m, r, i)
|
|
} else
|
|
e.emit('unexpected-response', c, d) ||
|
|
ue(e, c, `Unexpected server response: ${d.statusCode}`)
|
|
}),
|
|
c.on('upgrade', (d, _, v) => {
|
|
if ((e.emit('upgrade', d), e.readyState !== G.CONNECTING)) return
|
|
if (
|
|
((c = e._req = null), d.headers.upgrade.toLowerCase() !== 'websocket')
|
|
) {
|
|
ue(e, _, 'Invalid Upgrade header')
|
|
return
|
|
}
|
|
let m = jg('sha1')
|
|
.update(l + Vg)
|
|
.digest('base64')
|
|
if (d.headers['sec-websocket-accept'] !== m) {
|
|
ue(e, _, 'Invalid Sec-WebSocket-Accept header')
|
|
return
|
|
}
|
|
let p = d.headers['sec-websocket-protocol'],
|
|
g = (r || '').split(/, */),
|
|
S
|
|
if (
|
|
(!r && p
|
|
? (S = 'Server sent a subprotocol but none was requested')
|
|
: r && !p
|
|
? (S = 'Server sent no subprotocol')
|
|
: p &&
|
|
!g.includes(p) &&
|
|
(S = 'Server sent an invalid subprotocol'),
|
|
S)
|
|
) {
|
|
ue(e, _, S)
|
|
return
|
|
}
|
|
p && (e._protocol = p)
|
|
let x = d.headers['sec-websocket-extensions']
|
|
if (x !== void 0) {
|
|
if (!h) {
|
|
ue(
|
|
e,
|
|
_,
|
|
'Server sent a Sec-WebSocket-Extensions header but no extension was requested',
|
|
)
|
|
return
|
|
}
|
|
let C
|
|
try {
|
|
C = Kg(x)
|
|
} catch {
|
|
ue(e, _, 'Invalid Sec-WebSocket-Extensions header')
|
|
return
|
|
}
|
|
let w = Object.keys(C)
|
|
if (w.length) {
|
|
if (w.length !== 1 || w[0] !== Xe.extensionName) {
|
|
ue(e, _, 'Server indicated an extension that was not requested')
|
|
return
|
|
}
|
|
try {
|
|
h.accept(C[Xe.extensionName])
|
|
} catch {
|
|
ue(e, _, 'Invalid Sec-WebSocket-Extensions header')
|
|
return
|
|
}
|
|
e._extensions[Xe.extensionName] = h
|
|
}
|
|
}
|
|
e.setSocket(_, v, n.maxPayload)
|
|
})
|
|
}
|
|
function vs(e, t) {
|
|
;(e._readyState = G.CLOSING), e.emit('error', t), e.emitClose()
|
|
}
|
|
function Jg(e) {
|
|
return (e.path = e.socketPath), pl.connect(e)
|
|
}
|
|
function Xg(e) {
|
|
return (
|
|
(e.path = void 0),
|
|
!e.servername &&
|
|
e.servername !== '' &&
|
|
(e.servername = pl.isIP(e.host) ? '' : e.host),
|
|
Dg.connect(e)
|
|
)
|
|
}
|
|
function ue(e, t, r) {
|
|
e._readyState = G.CLOSING
|
|
let i = new Error(r)
|
|
Error.captureStackTrace(i, ue),
|
|
t.setHeader
|
|
? (t.abort(),
|
|
t.socket && !t.socket.destroyed && t.socket.destroy(),
|
|
t.once('abort', e.emitClose.bind(e)),
|
|
e.emit('error', i))
|
|
: (t.destroy(i),
|
|
t.once('error', e.emit.bind(e, 'error')),
|
|
t.once('close', e.emitClose.bind(e)))
|
|
}
|
|
function ms(e, t, r) {
|
|
if (t) {
|
|
let i = Yg(t).length
|
|
e._socket ? (e._sender._bufferedBytes += i) : (e._bufferedAmount += i)
|
|
}
|
|
if (r) {
|
|
let i = new Error(
|
|
`WebSocket is not open: readyState ${e.readyState} (${
|
|
Ae[e.readyState]
|
|
})`,
|
|
)
|
|
r(i)
|
|
}
|
|
}
|
|
function Zg(e, t) {
|
|
let r = this[te]
|
|
;(r._closeFrameReceived = !0),
|
|
(r._closeMessage = t),
|
|
(r._closeCode = e),
|
|
r._socket[te] !== void 0 &&
|
|
(r._socket.removeListener('data', yi),
|
|
process.nextTick(bl, r._socket),
|
|
e === 1005 ? r.close() : r.close(e, t))
|
|
}
|
|
function eb() {
|
|
this[te]._socket.resume()
|
|
}
|
|
function tb(e) {
|
|
let t = this[te]
|
|
t._socket[te] !== void 0 &&
|
|
(t._socket.removeListener('data', yi),
|
|
process.nextTick(bl, t._socket),
|
|
t.close(e[Hg])),
|
|
t.emit('error', e)
|
|
}
|
|
function dl() {
|
|
this[te].emitClose()
|
|
}
|
|
function rb(e) {
|
|
this[te].emit('message', e)
|
|
}
|
|
function ib(e) {
|
|
let t = this[te]
|
|
t.pong(e, !t._isServer, _l), t.emit('ping', e)
|
|
}
|
|
function nb(e) {
|
|
this[te].emit('pong', e)
|
|
}
|
|
function bl(e) {
|
|
e.resume()
|
|
}
|
|
function yl() {
|
|
let e = this[te]
|
|
this.removeListener('close', yl),
|
|
this.removeListener('data', yi),
|
|
this.removeListener('end', vl),
|
|
(e._readyState = G.CLOSING)
|
|
let t
|
|
!this._readableState.endEmitted &&
|
|
!e._closeFrameReceived &&
|
|
!e._receiver._writableState.errorEmitted &&
|
|
(t = e._socket.read()) !== null &&
|
|
e._receiver.write(t),
|
|
e._receiver.end(),
|
|
(this[te] = void 0),
|
|
clearTimeout(e._closeTimer),
|
|
e._receiver._writableState.finished ||
|
|
e._receiver._writableState.errorEmitted
|
|
? e.emitClose()
|
|
: (e._receiver.on('error', dl), e._receiver.on('finish', dl))
|
|
}
|
|
function yi(e) {
|
|
this[te]._receiver.write(e) || this.pause()
|
|
}
|
|
function vl() {
|
|
let e = this[te]
|
|
;(e._readyState = G.CLOSING), e._receiver.end(), this.end()
|
|
}
|
|
function ml() {
|
|
let e = this[te]
|
|
this.removeListener('error', ml),
|
|
this.on('error', _l),
|
|
e && ((e._readyState = G.CLOSING), this.destroy())
|
|
}
|
|
})
|
|
var Cl = b((Dw, xl) => {
|
|
'use strict'
|
|
var { Duplex: sb } = require('stream')
|
|
function Sl(e) {
|
|
e.emit('close')
|
|
}
|
|
function ob() {
|
|
!this.destroyed && this._writableState.finished && this.destroy()
|
|
}
|
|
function El(e) {
|
|
this.removeListener('error', El),
|
|
this.destroy(),
|
|
this.listenerCount('error') === 0 && this.emit('error', e)
|
|
}
|
|
function ab(e, t) {
|
|
let r = !0,
|
|
i = !0
|
|
function n() {
|
|
r && e._socket.resume()
|
|
}
|
|
e.readyState === e.CONNECTING
|
|
? e.once('open', function () {
|
|
e._receiver.removeAllListeners('drain'), e._receiver.on('drain', n)
|
|
})
|
|
: (e._receiver.removeAllListeners('drain'), e._receiver.on('drain', n))
|
|
let s = new sb({
|
|
...t,
|
|
autoDestroy: !1,
|
|
emitClose: !1,
|
|
objectMode: !1,
|
|
writableObjectMode: !1,
|
|
})
|
|
return (
|
|
e.on('message', function (f) {
|
|
s.push(f) || ((r = !1), e._socket.pause())
|
|
}),
|
|
e.once('error', function (f) {
|
|
s.destroyed || ((i = !1), s.destroy(f))
|
|
}),
|
|
e.once('close', function () {
|
|
s.destroyed || s.push(null)
|
|
}),
|
|
(s._destroy = function (o, f) {
|
|
if (e.readyState === e.CLOSED) {
|
|
f(o), process.nextTick(Sl, s)
|
|
return
|
|
}
|
|
let a = !1
|
|
e.once('error', function (u) {
|
|
;(a = !0), f(u)
|
|
}),
|
|
e.once('close', function () {
|
|
a || f(o), process.nextTick(Sl, s)
|
|
}),
|
|
i && e.terminate()
|
|
}),
|
|
(s._final = function (o) {
|
|
if (e.readyState === e.CONNECTING) {
|
|
e.once('open', function () {
|
|
s._final(o)
|
|
})
|
|
return
|
|
}
|
|
e._socket !== null &&
|
|
(e._socket._writableState.finished
|
|
? (o(), s._readableState.endEmitted && s.destroy())
|
|
: (e._socket.once('finish', function () {
|
|
o()
|
|
}),
|
|
e.close()))
|
|
}),
|
|
(s._read = function () {
|
|
;(e.readyState === e.OPEN || e.readyState === e.CLOSING) &&
|
|
!r &&
|
|
((r = !0), e._receiver._writableState.needDrain || e._socket.resume())
|
|
}),
|
|
(s._write = function (o, f, a) {
|
|
if (e.readyState === e.CONNECTING) {
|
|
e.once('open', function () {
|
|
s._write(o, f, a)
|
|
})
|
|
return
|
|
}
|
|
e.send(o, a)
|
|
}),
|
|
s.on('end', ob),
|
|
s.on('error', El),
|
|
s
|
|
)
|
|
}
|
|
xl.exports = ab
|
|
})
|
|
var Rl = b((Ww, kl) => {
|
|
'use strict'
|
|
var fb = require('events'),
|
|
vi = require('http'),
|
|
Uw = require('https'),
|
|
jw = require('net'),
|
|
Fw = require('tls'),
|
|
{ createHash: lb } = require('crypto'),
|
|
ht = ir(),
|
|
ub = ws(),
|
|
{ format: cb, parse: hb } = _s(),
|
|
{ GUID: db, kWebSocket: pb } = ut(),
|
|
_b = /^[+/0-9A-Za-z]{22}==$/,
|
|
Tl = 0,
|
|
Il = 1,
|
|
Ol = 2,
|
|
Es = class extends fb {
|
|
constructor(t, r) {
|
|
if (
|
|
(super(),
|
|
(t = {
|
|
maxPayload: 100 * 1024 * 1024,
|
|
perMessageDeflate: !1,
|
|
handleProtocols: null,
|
|
clientTracking: !0,
|
|
verifyClient: null,
|
|
noServer: !1,
|
|
backlog: null,
|
|
server: null,
|
|
host: null,
|
|
path: null,
|
|
port: null,
|
|
...t,
|
|
}),
|
|
(t.port == null && !t.server && !t.noServer) ||
|
|
(t.port != null && (t.server || t.noServer)) ||
|
|
(t.server && t.noServer))
|
|
)
|
|
throw new TypeError(
|
|
'One and only one of the "port", "server", or "noServer" options must be specified',
|
|
)
|
|
if (
|
|
(t.port != null
|
|
? ((this._server = vi.createServer((i, n) => {
|
|
let s = vi.STATUS_CODES[426]
|
|
n.writeHead(426, {
|
|
'Content-Length': s.length,
|
|
'Content-Type': 'text/plain',
|
|
}),
|
|
n.end(s)
|
|
})),
|
|
this._server.listen(t.port, t.host, t.backlog, r))
|
|
: t.server && (this._server = t.server),
|
|
this._server)
|
|
) {
|
|
let i = this.emit.bind(this, 'connection')
|
|
this._removeListeners = gb(this._server, {
|
|
listening: this.emit.bind(this, 'listening'),
|
|
error: this.emit.bind(this, 'error'),
|
|
upgrade: (n, s, o) => {
|
|
this.handleUpgrade(n, s, o, i)
|
|
},
|
|
})
|
|
}
|
|
t.perMessageDeflate === !0 && (t.perMessageDeflate = {}),
|
|
t.clientTracking && (this.clients = new Set()),
|
|
(this.options = t),
|
|
(this._state = Tl)
|
|
}
|
|
address() {
|
|
if (this.options.noServer)
|
|
throw new Error('The server is operating in "noServer" mode')
|
|
return this._server ? this._server.address() : null
|
|
}
|
|
close(t) {
|
|
if ((t && this.once('close', t), this._state === Ol)) {
|
|
process.nextTick(Ss, this)
|
|
return
|
|
}
|
|
if (this._state === Il) return
|
|
if (((this._state = Il), this.clients))
|
|
for (let i of this.clients) i.terminate()
|
|
let r = this._server
|
|
if (
|
|
r &&
|
|
(this._removeListeners(),
|
|
(this._removeListeners = this._server = null),
|
|
this.options.port != null)
|
|
) {
|
|
r.close(Ss.bind(void 0, this))
|
|
return
|
|
}
|
|
process.nextTick(Ss, this)
|
|
}
|
|
shouldHandle(t) {
|
|
if (this.options.path) {
|
|
let r = t.url.indexOf('?')
|
|
if ((r !== -1 ? t.url.slice(0, r) : t.url) !== this.options.path)
|
|
return !1
|
|
}
|
|
return !0
|
|
}
|
|
handleUpgrade(t, r, i, n) {
|
|
r.on('error', xs)
|
|
let s =
|
|
t.headers['sec-websocket-key'] !== void 0
|
|
? t.headers['sec-websocket-key'].trim()
|
|
: !1,
|
|
o = +t.headers['sec-websocket-version'],
|
|
f = {}
|
|
if (
|
|
t.method !== 'GET' ||
|
|
t.headers.upgrade.toLowerCase() !== 'websocket' ||
|
|
!s ||
|
|
!_b.test(s) ||
|
|
(o !== 8 && o !== 13) ||
|
|
!this.shouldHandle(t)
|
|
)
|
|
return or(r, 400)
|
|
if (this.options.perMessageDeflate) {
|
|
let a = new ht(
|
|
this.options.perMessageDeflate,
|
|
!0,
|
|
this.options.maxPayload,
|
|
)
|
|
try {
|
|
let l = hb(t.headers['sec-websocket-extensions'])
|
|
l[ht.extensionName] &&
|
|
(a.accept(l[ht.extensionName]), (f[ht.extensionName] = a))
|
|
} catch {
|
|
return or(r, 400)
|
|
}
|
|
}
|
|
if (this.options.verifyClient) {
|
|
let a = {
|
|
origin: t.headers[`${o === 8 ? 'sec-websocket-origin' : 'origin'}`],
|
|
secure: !!(t.socket.authorized || t.socket.encrypted),
|
|
req: t,
|
|
}
|
|
if (this.options.verifyClient.length === 2) {
|
|
this.options.verifyClient(a, (l, u, h, c) => {
|
|
if (!l) return or(r, u || 401, h, c)
|
|
this.completeUpgrade(s, f, t, r, i, n)
|
|
})
|
|
return
|
|
}
|
|
if (!this.options.verifyClient(a)) return or(r, 401)
|
|
}
|
|
this.completeUpgrade(s, f, t, r, i, n)
|
|
}
|
|
completeUpgrade(t, r, i, n, s, o) {
|
|
if (!n.readable || !n.writable) return n.destroy()
|
|
if (n[pb])
|
|
throw new Error(
|
|
'server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration',
|
|
)
|
|
if (this._state > Tl) return or(n, 503)
|
|
let a = [
|
|
'HTTP/1.1 101 Switching Protocols',
|
|
'Upgrade: websocket',
|
|
'Connection: Upgrade',
|
|
`Sec-WebSocket-Accept: ${lb('sha1')
|
|
.update(t + db)
|
|
.digest('base64')}`,
|
|
],
|
|
l = new ub(null),
|
|
u = i.headers['sec-websocket-protocol']
|
|
if (
|
|
(u &&
|
|
((u = u.split(',').map(bb)),
|
|
this.options.handleProtocols
|
|
? (u = this.options.handleProtocols(u, i))
|
|
: (u = u[0]),
|
|
u && (a.push(`Sec-WebSocket-Protocol: ${u}`), (l._protocol = u))),
|
|
r[ht.extensionName])
|
|
) {
|
|
let h = r[ht.extensionName].params,
|
|
c = cb({ [ht.extensionName]: [h] })
|
|
a.push(`Sec-WebSocket-Extensions: ${c}`), (l._extensions = r)
|
|
}
|
|
this.emit('headers', a, i),
|
|
n.write(
|
|
a.concat(`\r
|
|
`).join(`\r
|
|
`),
|
|
),
|
|
n.removeListener('error', xs),
|
|
l.setSocket(n, s, this.options.maxPayload),
|
|
this.clients &&
|
|
(this.clients.add(l), l.on('close', () => this.clients.delete(l))),
|
|
o(l, i)
|
|
}
|
|
}
|
|
kl.exports = Es
|
|
function gb(e, t) {
|
|
for (let r of Object.keys(t)) e.on(r, t[r])
|
|
return function () {
|
|
for (let i of Object.keys(t)) e.removeListener(i, t[i])
|
|
}
|
|
}
|
|
function Ss(e) {
|
|
;(e._state = Ol), e.emit('close')
|
|
}
|
|
function xs() {
|
|
this.destroy()
|
|
}
|
|
function or(e, t, r, i) {
|
|
e.writable &&
|
|
((r = r || vi.STATUS_CODES[t]),
|
|
(i = {
|
|
Connection: 'close',
|
|
'Content-Type': 'text/html',
|
|
'Content-Length': Buffer.byteLength(r),
|
|
...i,
|
|
}),
|
|
e.write(
|
|
`HTTP/1.1 ${t} ${vi.STATUS_CODES[t]}\r
|
|
` +
|
|
Object.keys(i).map((n) => `${n}: ${i[n]}`).join(`\r
|
|
`) +
|
|
`\r
|
|
\r
|
|
` +
|
|
r,
|
|
)),
|
|
e.removeListener('error', xs),
|
|
e.destroy()
|
|
}
|
|
function bb(e) {
|
|
return e.trim()
|
|
}
|
|
})
|
|
var Bl = b((Vw, Pl) => {
|
|
'use strict'
|
|
var ar = ws()
|
|
ar.createWebSocketStream = Cl()
|
|
ar.Server = Rl()
|
|
ar.Receiver = fs()
|
|
ar.Sender = us()
|
|
Pl.exports = ar
|
|
})
|
|
var Ts = b((Hw, Cs) => {
|
|
'use strict'
|
|
var Al = Bl(),
|
|
fr = ze()('mqttjs:ws'),
|
|
yb = hi(),
|
|
vb = He().Transform,
|
|
mb = ['rejectUnauthorized', 'ca', 'cert', 'key', 'pfx', 'passphrase'],
|
|
Nl =
|
|
(typeof process < 'u' && process.title === 'browser') ||
|
|
typeof __webpack_require__ == 'function'
|
|
function Ml(e, t) {
|
|
let r = e.protocol + '://' + e.hostname + ':' + e.port + e.path
|
|
return (
|
|
typeof e.transformWsUrl == 'function' && (r = e.transformWsUrl(r, e, t)),
|
|
r
|
|
)
|
|
}
|
|
function Ll(e) {
|
|
let t = e
|
|
return (
|
|
e.hostname || (t.hostname = 'localhost'),
|
|
e.port || (e.protocol === 'wss' ? (t.port = 443) : (t.port = 80)),
|
|
e.path || (t.path = '/'),
|
|
e.wsOptions || (t.wsOptions = {}),
|
|
!Nl &&
|
|
e.protocol === 'wss' &&
|
|
mb.forEach(function (r) {
|
|
e.hasOwnProperty(r) &&
|
|
!e.wsOptions.hasOwnProperty(r) &&
|
|
(t.wsOptions[r] = e[r])
|
|
}),
|
|
t
|
|
)
|
|
}
|
|
function wb(e) {
|
|
let t = Ll(e)
|
|
if ((t.hostname || (t.hostname = t.host), !t.hostname)) {
|
|
if (typeof document > 'u')
|
|
throw new Error('Could not determine host. Specify host manually.')
|
|
let r = new URL(document.URL)
|
|
;(t.hostname = r.hostname), t.port || (t.port = r.port)
|
|
}
|
|
return (
|
|
t.objectMode === void 0 &&
|
|
(t.objectMode = !(t.binary === !0 || t.binary === void 0)),
|
|
t
|
|
)
|
|
}
|
|
function Sb(e, t, r) {
|
|
fr('createWebSocket'),
|
|
fr('protocol: ' + r.protocolId + ' ' + r.protocolVersion)
|
|
let i =
|
|
r.protocolId === 'MQIsdp' && r.protocolVersion === 3 ? 'mqttv3.1' : 'mqtt'
|
|
return (
|
|
fr('creating new Websocket for url: ' + t + ' and protocol: ' + i),
|
|
new Al(t, [i], r.wsOptions)
|
|
)
|
|
}
|
|
function Eb(e, t) {
|
|
let r =
|
|
t.protocolId === 'MQIsdp' && t.protocolVersion === 3
|
|
? 'mqttv3.1'
|
|
: 'mqtt',
|
|
i = Ml(t, e),
|
|
n = new WebSocket(i, [r])
|
|
return (n.binaryType = 'arraybuffer'), n
|
|
}
|
|
function xb(e, t) {
|
|
fr('streamBuilder')
|
|
let r = Ll(t),
|
|
i = Ml(r, e),
|
|
n = Sb(e, i, r),
|
|
s = Al.createWebSocketStream(n, r.wsOptions)
|
|
return (
|
|
(s.url = i),
|
|
n.on('close', () => {
|
|
s.destroy()
|
|
}),
|
|
s
|
|
)
|
|
}
|
|
function Cb(e, t) {
|
|
fr('browserStreamBuilder')
|
|
let r,
|
|
n = wb(t).browserBufferSize || 1024 * 512,
|
|
s = t.browserBufferTimeout || 1e3,
|
|
o = !t.objectMode,
|
|
f = Eb(e, t),
|
|
a = u(t, m, p)
|
|
t.objectMode || (a._writev = v),
|
|
a.on('close', () => {
|
|
f.close()
|
|
})
|
|
let l = typeof f.addEventListener < 'u'
|
|
f.readyState === f.OPEN
|
|
? (r = a)
|
|
: ((r = r = yb(void 0, void 0, t)),
|
|
t.objectMode || (r._writev = v),
|
|
l ? f.addEventListener('open', h) : (f.onopen = h)),
|
|
(r.socket = f),
|
|
l
|
|
? (f.addEventListener('close', c),
|
|
f.addEventListener('error', d),
|
|
f.addEventListener('message', _))
|
|
: ((f.onclose = c), (f.onerror = d), (f.onmessage = _))
|
|
function u(g, S, x) {
|
|
let C = new vb({ objectModeMode: g.objectMode })
|
|
return (C._write = S), (C._flush = x), C
|
|
}
|
|
function h() {
|
|
r.setReadable(a), r.setWritable(a), r.emit('connect')
|
|
}
|
|
function c() {
|
|
r.end(), r.destroy()
|
|
}
|
|
function d(g) {
|
|
r.destroy(g)
|
|
}
|
|
function _(g) {
|
|
let S = g.data
|
|
S instanceof ArrayBuffer
|
|
? (S = Buffer.from(S))
|
|
: (S = Buffer.from(S, 'utf8')),
|
|
a.push(S)
|
|
}
|
|
function v(g, S) {
|
|
let x = new Array(g.length)
|
|
for (let C = 0; C < g.length; C++)
|
|
typeof g[C].chunk == 'string'
|
|
? (x[C] = Buffer.from(g[C], 'utf8'))
|
|
: (x[C] = g[C].chunk)
|
|
this._write(Buffer.concat(x), 'binary', S)
|
|
}
|
|
function m(g, S, x) {
|
|
f.bufferedAmount > n && setTimeout(m, s, g, S, x),
|
|
o && typeof g == 'string' && (g = Buffer.from(g, 'utf8'))
|
|
try {
|
|
f.send(g)
|
|
} catch (C) {
|
|
return x(C)
|
|
}
|
|
x()
|
|
}
|
|
function p(g) {
|
|
f.close(), g()
|
|
}
|
|
return r
|
|
}
|
|
Nl ? (Cs.exports = Cb) : (Cs.exports = xb)
|
|
})
|
|
var jl = b(($w, lr) => {
|
|
'use strict'
|
|
var Dl = $n(),
|
|
Tb = Jr(),
|
|
Ib = require('url'),
|
|
Ob = Mr(),
|
|
ql = ze()('mqttjs'),
|
|
oe = {}
|
|
;(typeof process < 'u' && process.title !== 'browser') ||
|
|
typeof __webpack_require__ != 'function'
|
|
? ((oe.mqtt = Gn()),
|
|
(oe.tcp = Gn()),
|
|
(oe.ssl = li()),
|
|
(oe.tls = li()),
|
|
(oe.mqtts = li()))
|
|
: ((oe.wx = Jn()), (oe.wxs = Jn()), (oe.ali = Xn()), (oe.alis = Xn()))
|
|
oe.ws = Ts()
|
|
oe.wss = Ts()
|
|
function kb(e) {
|
|
var t
|
|
e.auth &&
|
|
((t = e.auth.match(/^(.+):(.+)$/)),
|
|
t ? ((e.username = t[1]), (e.password = t[2])) : (e.username = e.auth))
|
|
}
|
|
function Ul(e, t) {
|
|
if (
|
|
(ql('connecting to an MQTT broker...'),
|
|
typeof e == 'object' && !t && ((t = e), (e = null)),
|
|
(t = t || {}),
|
|
e)
|
|
) {
|
|
var r = Ib.parse(e, !0)
|
|
if (
|
|
(r.port != null && (r.port = Number(r.port)),
|
|
(t = Ob(r, t)),
|
|
t.protocol === null)
|
|
)
|
|
throw new Error('Missing protocol')
|
|
t.protocol = t.protocol.replace(/:$/, '')
|
|
}
|
|
if (
|
|
(kb(t),
|
|
t.query &&
|
|
typeof t.query.clientId == 'string' &&
|
|
(t.clientId = t.query.clientId),
|
|
t.cert && t.key)
|
|
)
|
|
if (t.protocol) {
|
|
if (['mqtts', 'wss', 'wxs', 'alis'].indexOf(t.protocol) === -1)
|
|
switch (t.protocol) {
|
|
case 'mqtt':
|
|
t.protocol = 'mqtts'
|
|
break
|
|
case 'ws':
|
|
t.protocol = 'wss'
|
|
break
|
|
case 'wx':
|
|
t.protocol = 'wxs'
|
|
break
|
|
case 'ali':
|
|
t.protocol = 'alis'
|
|
break
|
|
default:
|
|
throw new Error(
|
|
'Unknown protocol for secure connection: "' + t.protocol + '"!',
|
|
)
|
|
}
|
|
} else throw new Error('Missing secure protocol key')
|
|
if (!oe[t.protocol]) {
|
|
var i = ['mqtts', 'wss'].indexOf(t.protocol) !== -1
|
|
t.protocol = [
|
|
'mqtt',
|
|
'mqtts',
|
|
'ws',
|
|
'wss',
|
|
'wx',
|
|
'wxs',
|
|
'ali',
|
|
'alis',
|
|
].filter(function (o, f) {
|
|
return i && f % 2 === 0 ? !1 : typeof oe[o] == 'function'
|
|
})[0]
|
|
}
|
|
if (t.clean === !1 && !t.clientId)
|
|
throw new Error('Missing clientId for unclean clients')
|
|
t.protocol && (t.defaultProtocol = t.protocol)
|
|
function n(o) {
|
|
return (
|
|
t.servers &&
|
|
((!o._reconnectCount || o._reconnectCount === t.servers.length) &&
|
|
(o._reconnectCount = 0),
|
|
(t.host = t.servers[o._reconnectCount].host),
|
|
(t.port = t.servers[o._reconnectCount].port),
|
|
(t.protocol = t.servers[o._reconnectCount].protocol
|
|
? t.servers[o._reconnectCount].protocol
|
|
: t.defaultProtocol),
|
|
(t.hostname = t.host),
|
|
o._reconnectCount++),
|
|
ql('calling streambuilder for', t.protocol),
|
|
oe[t.protocol](o, t)
|
|
)
|
|
}
|
|
var s = new Dl(n, t)
|
|
return s.on('error', function () {}), s
|
|
}
|
|
lr.exports = Ul
|
|
lr.exports.connect = Ul
|
|
lr.exports.MqttClient = Dl
|
|
lr.exports.Store = Tb
|
|
})
|
|
var Wl = b((Gw, ur) => {
|
|
var Fl = $n(),
|
|
Rb = jl(),
|
|
Pb = Jr()
|
|
ur.exports.connect = Rb
|
|
ur.exports.MqttClient = Fl
|
|
ur.exports.Client = Fl
|
|
ur.exports.Store = Pb
|
|
})
|
|
var wi = b((mi, Vl) => {
|
|
;(function (e, t) {
|
|
typeof mi == 'object'
|
|
? (Vl.exports = mi = t())
|
|
: typeof define == 'function' && define.amd
|
|
? define([], t)
|
|
: (e.CryptoJS = t())
|
|
})(mi, function () {
|
|
var e =
|
|
e ||
|
|
(function (t, r) {
|
|
var i
|
|
if (
|
|
(typeof window < 'u' && window.crypto && (i = window.crypto),
|
|
typeof self < 'u' && self.crypto && (i = self.crypto),
|
|
typeof globalThis < 'u' &&
|
|
globalThis.crypto &&
|
|
(i = globalThis.crypto),
|
|
!i && typeof window < 'u' && window.msCrypto && (i = window.msCrypto),
|
|
!i && typeof global < 'u' && global.crypto && (i = global.crypto),
|
|
!i && typeof require == 'function')
|
|
)
|
|
try {
|
|
i = require('crypto')
|
|
} catch {}
|
|
var n = function () {
|
|
if (i) {
|
|
if (typeof i.getRandomValues == 'function')
|
|
try {
|
|
return i.getRandomValues(new Uint32Array(1))[0]
|
|
} catch {}
|
|
if (typeof i.randomBytes == 'function')
|
|
try {
|
|
return i.randomBytes(4).readInt32LE()
|
|
} catch {}
|
|
}
|
|
throw new Error(
|
|
'Native crypto module could not be used to get secure random number.',
|
|
)
|
|
},
|
|
s =
|
|
Object.create ||
|
|
(function () {
|
|
function p() {}
|
|
return function (g) {
|
|
var S
|
|
return (p.prototype = g), (S = new p()), (p.prototype = null), S
|
|
}
|
|
})(),
|
|
o = {},
|
|
f = (o.lib = {}),
|
|
a = (f.Base = (function () {
|
|
return {
|
|
extend: function (p) {
|
|
var g = s(this)
|
|
return (
|
|
p && g.mixIn(p),
|
|
(!g.hasOwnProperty('init') || this.init === g.init) &&
|
|
(g.init = function () {
|
|
g.$super.init.apply(this, arguments)
|
|
}),
|
|
(g.init.prototype = g),
|
|
(g.$super = this),
|
|
g
|
|
)
|
|
},
|
|
create: function () {
|
|
var p = this.extend()
|
|
return p.init.apply(p, arguments), p
|
|
},
|
|
init: function () {},
|
|
mixIn: function (p) {
|
|
for (var g in p) p.hasOwnProperty(g) && (this[g] = p[g])
|
|
p.hasOwnProperty('toString') && (this.toString = p.toString)
|
|
},
|
|
clone: function () {
|
|
return this.init.prototype.extend(this)
|
|
},
|
|
}
|
|
})()),
|
|
l = (f.WordArray = a.extend({
|
|
init: function (p, g) {
|
|
;(p = this.words = p || []),
|
|
g != r ? (this.sigBytes = g) : (this.sigBytes = p.length * 4)
|
|
},
|
|
toString: function (p) {
|
|
return (p || h).stringify(this)
|
|
},
|
|
concat: function (p) {
|
|
var g = this.words,
|
|
S = p.words,
|
|
x = this.sigBytes,
|
|
C = p.sigBytes
|
|
if ((this.clamp(), x % 4))
|
|
for (var w = 0; w < C; w++) {
|
|
var B = (S[w >>> 2] >>> (24 - (w % 4) * 8)) & 255
|
|
g[(x + w) >>> 2] |= B << (24 - ((x + w) % 4) * 8)
|
|
}
|
|
else for (var M = 0; M < C; M += 4) g[(x + M) >>> 2] = S[M >>> 2]
|
|
return (this.sigBytes += C), this
|
|
},
|
|
clamp: function () {
|
|
var p = this.words,
|
|
g = this.sigBytes
|
|
;(p[g >>> 2] &= 4294967295 << (32 - (g % 4) * 8)),
|
|
(p.length = t.ceil(g / 4))
|
|
},
|
|
clone: function () {
|
|
var p = a.clone.call(this)
|
|
return (p.words = this.words.slice(0)), p
|
|
},
|
|
random: function (p) {
|
|
for (var g = [], S = 0; S < p; S += 4) g.push(n())
|
|
return new l.init(g, p)
|
|
},
|
|
})),
|
|
u = (o.enc = {}),
|
|
h = (u.Hex = {
|
|
stringify: function (p) {
|
|
for (var g = p.words, S = p.sigBytes, x = [], C = 0; C < S; C++) {
|
|
var w = (g[C >>> 2] >>> (24 - (C % 4) * 8)) & 255
|
|
x.push((w >>> 4).toString(16)), x.push((w & 15).toString(16))
|
|
}
|
|
return x.join('')
|
|
},
|
|
parse: function (p) {
|
|
for (var g = p.length, S = [], x = 0; x < g; x += 2)
|
|
S[x >>> 3] |= parseInt(p.substr(x, 2), 16) << (24 - (x % 8) * 4)
|
|
return new l.init(S, g / 2)
|
|
},
|
|
}),
|
|
c = (u.Latin1 = {
|
|
stringify: function (p) {
|
|
for (var g = p.words, S = p.sigBytes, x = [], C = 0; C < S; C++) {
|
|
var w = (g[C >>> 2] >>> (24 - (C % 4) * 8)) & 255
|
|
x.push(String.fromCharCode(w))
|
|
}
|
|
return x.join('')
|
|
},
|
|
parse: function (p) {
|
|
for (var g = p.length, S = [], x = 0; x < g; x++)
|
|
S[x >>> 2] |= (p.charCodeAt(x) & 255) << (24 - (x % 4) * 8)
|
|
return new l.init(S, g)
|
|
},
|
|
}),
|
|
d = (u.Utf8 = {
|
|
stringify: function (p) {
|
|
try {
|
|
return decodeURIComponent(escape(c.stringify(p)))
|
|
} catch {
|
|
throw new Error('Malformed UTF-8 data')
|
|
}
|
|
},
|
|
parse: function (p) {
|
|
return c.parse(unescape(encodeURIComponent(p)))
|
|
},
|
|
}),
|
|
_ = (f.BufferedBlockAlgorithm = a.extend({
|
|
reset: function () {
|
|
;(this._data = new l.init()), (this._nDataBytes = 0)
|
|
},
|
|
_append: function (p) {
|
|
typeof p == 'string' && (p = d.parse(p)),
|
|
this._data.concat(p),
|
|
(this._nDataBytes += p.sigBytes)
|
|
},
|
|
_process: function (p) {
|
|
var g,
|
|
S = this._data,
|
|
x = S.words,
|
|
C = S.sigBytes,
|
|
w = this.blockSize,
|
|
B = w * 4,
|
|
M = C / B
|
|
p
|
|
? (M = t.ceil(M))
|
|
: (M = t.max((M | 0) - this._minBufferSize, 0))
|
|
var H = M * w,
|
|
rt = t.min(H * 4, C)
|
|
if (H) {
|
|
for (var Se = 0; Se < H; Se += w) this._doProcessBlock(x, Se)
|
|
;(g = x.splice(0, H)), (S.sigBytes -= rt)
|
|
}
|
|
return new l.init(g, rt)
|
|
},
|
|
clone: function () {
|
|
var p = a.clone.call(this)
|
|
return (p._data = this._data.clone()), p
|
|
},
|
|
_minBufferSize: 0,
|
|
})),
|
|
v = (f.Hasher = _.extend({
|
|
cfg: a.extend(),
|
|
init: function (p) {
|
|
;(this.cfg = this.cfg.extend(p)), this.reset()
|
|
},
|
|
reset: function () {
|
|
_.reset.call(this), this._doReset()
|
|
},
|
|
update: function (p) {
|
|
return this._append(p), this._process(), this
|
|
},
|
|
finalize: function (p) {
|
|
p && this._append(p)
|
|
var g = this._doFinalize()
|
|
return g
|
|
},
|
|
blockSize: 512 / 32,
|
|
_createHelper: function (p) {
|
|
return function (g, S) {
|
|
return new p.init(S).finalize(g)
|
|
}
|
|
},
|
|
_createHmacHelper: function (p) {
|
|
return function (g, S) {
|
|
return new m.HMAC.init(p, S).finalize(g)
|
|
}
|
|
},
|
|
})),
|
|
m = (o.algo = {})
|
|
return o
|
|
})(Math)
|
|
return e
|
|
})
|
|
})
|
|
var Is = b((Si, Hl) => {
|
|
;(function (e, t) {
|
|
typeof Si == 'object'
|
|
? (Hl.exports = Si = t(wi()))
|
|
: typeof define == 'function' && define.amd
|
|
? define(['./core'], t)
|
|
: t(e.CryptoJS)
|
|
})(Si, function (e) {
|
|
return (
|
|
(function (t) {
|
|
var r = e,
|
|
i = r.lib,
|
|
n = i.WordArray,
|
|
s = i.Hasher,
|
|
o = r.algo,
|
|
f = [],
|
|
a = []
|
|
;(function () {
|
|
function h(v) {
|
|
for (var m = t.sqrt(v), p = 2; p <= m; p++) if (!(v % p)) return !1
|
|
return !0
|
|
}
|
|
function c(v) {
|
|
return ((v - (v | 0)) * 4294967296) | 0
|
|
}
|
|
for (var d = 2, _ = 0; _ < 64; )
|
|
h(d) &&
|
|
(_ < 8 && (f[_] = c(t.pow(d, 1 / 2))),
|
|
(a[_] = c(t.pow(d, 1 / 3))),
|
|
_++),
|
|
d++
|
|
})()
|
|
var l = [],
|
|
u = (o.SHA256 = s.extend({
|
|
_doReset: function () {
|
|
this._hash = new n.init(f.slice(0))
|
|
},
|
|
_doProcessBlock: function (h, c) {
|
|
for (
|
|
var d = this._hash.words,
|
|
_ = d[0],
|
|
v = d[1],
|
|
m = d[2],
|
|
p = d[3],
|
|
g = d[4],
|
|
S = d[5],
|
|
x = d[6],
|
|
C = d[7],
|
|
w = 0;
|
|
w < 64;
|
|
w++
|
|
) {
|
|
if (w < 16) l[w] = h[c + w] | 0
|
|
else {
|
|
var B = l[w - 15],
|
|
M =
|
|
((B << 25) | (B >>> 7)) ^
|
|
((B << 14) | (B >>> 18)) ^
|
|
(B >>> 3),
|
|
H = l[w - 2],
|
|
rt =
|
|
((H << 15) | (H >>> 17)) ^
|
|
((H << 13) | (H >>> 19)) ^
|
|
(H >>> 10)
|
|
l[w] = M + l[w - 7] + rt + l[w - 16]
|
|
}
|
|
var Se = (g & S) ^ (~g & x),
|
|
Rr = (_ & v) ^ (_ & m) ^ (v & m),
|
|
Qi =
|
|
((_ << 30) | (_ >>> 2)) ^
|
|
((_ << 19) | (_ >>> 13)) ^
|
|
((_ << 10) | (_ >>> 22)),
|
|
Ut =
|
|
((g << 26) | (g >>> 6)) ^
|
|
((g << 21) | (g >>> 11)) ^
|
|
((g << 7) | (g >>> 25)),
|
|
Pr = C + Ut + Se + a[w] + l[w],
|
|
Br = Qi + Rr
|
|
;(C = x),
|
|
(x = S),
|
|
(S = g),
|
|
(g = (p + Pr) | 0),
|
|
(p = m),
|
|
(m = v),
|
|
(v = _),
|
|
(_ = (Pr + Br) | 0)
|
|
}
|
|
;(d[0] = (d[0] + _) | 0),
|
|
(d[1] = (d[1] + v) | 0),
|
|
(d[2] = (d[2] + m) | 0),
|
|
(d[3] = (d[3] + p) | 0),
|
|
(d[4] = (d[4] + g) | 0),
|
|
(d[5] = (d[5] + S) | 0),
|
|
(d[6] = (d[6] + x) | 0),
|
|
(d[7] = (d[7] + C) | 0)
|
|
},
|
|
_doFinalize: function () {
|
|
var h = this._data,
|
|
c = h.words,
|
|
d = this._nDataBytes * 8,
|
|
_ = h.sigBytes * 8
|
|
return (
|
|
(c[_ >>> 5] |= 128 << (24 - (_ % 32))),
|
|
(c[(((_ + 64) >>> 9) << 4) + 14] = t.floor(d / 4294967296)),
|
|
(c[(((_ + 64) >>> 9) << 4) + 15] = d),
|
|
(h.sigBytes = c.length * 4),
|
|
this._process(),
|
|
this._hash
|
|
)
|
|
},
|
|
clone: function () {
|
|
var h = s.clone.call(this)
|
|
return (h._hash = this._hash.clone()), h
|
|
},
|
|
}))
|
|
;(r.SHA256 = s._createHelper(u)),
|
|
(r.HmacSHA256 = s._createHmacHelper(u))
|
|
})(Math),
|
|
e.SHA256
|
|
)
|
|
})
|
|
})
|
|
var Gl = b((Ei, $l) => {
|
|
;(function (e, t) {
|
|
typeof Ei == 'object'
|
|
? ($l.exports = Ei = t(wi()))
|
|
: typeof define == 'function' && define.amd
|
|
? define(['./core'], t)
|
|
: t(e.CryptoJS)
|
|
})(Ei, function (e) {
|
|
;(function () {
|
|
var t = e,
|
|
r = t.lib,
|
|
i = r.Base,
|
|
n = t.enc,
|
|
s = n.Utf8,
|
|
o = t.algo,
|
|
f = (o.HMAC = i.extend({
|
|
init: function (a, l) {
|
|
;(a = this._hasher = new a.init()),
|
|
typeof l == 'string' && (l = s.parse(l))
|
|
var u = a.blockSize,
|
|
h = u * 4
|
|
l.sigBytes > h && (l = a.finalize(l)), l.clamp()
|
|
for (
|
|
var c = (this._oKey = l.clone()),
|
|
d = (this._iKey = l.clone()),
|
|
_ = c.words,
|
|
v = d.words,
|
|
m = 0;
|
|
m < u;
|
|
m++
|
|
)
|
|
(_[m] ^= 1549556828), (v[m] ^= 909522486)
|
|
;(c.sigBytes = d.sigBytes = h), this.reset()
|
|
},
|
|
reset: function () {
|
|
var a = this._hasher
|
|
a.reset(), a.update(this._iKey)
|
|
},
|
|
update: function (a) {
|
|
return this._hasher.update(a), this
|
|
},
|
|
finalize: function (a) {
|
|
var l = this._hasher,
|
|
u = l.finalize(a)
|
|
l.reset()
|
|
var h = l.finalize(this._oKey.clone().concat(u))
|
|
return h
|
|
},
|
|
}))
|
|
})()
|
|
})
|
|
})
|
|
var Kl = b((xi, zl) => {
|
|
;(function (e, t, r) {
|
|
typeof xi == 'object'
|
|
? (zl.exports = xi = t(wi(), Is(), Gl()))
|
|
: typeof define == 'function' && define.amd
|
|
? define(['./core', './sha256', './hmac'], t)
|
|
: t(e.CryptoJS)
|
|
})(xi, function (e) {
|
|
return e.HmacSHA256
|
|
})
|
|
})
|
|
var Ql = b((zw, Yl) => {
|
|
Yl.exports = {
|
|
INVALID_CONNECT_OPTIONS: 'Invalid connect options supplied.',
|
|
INVALID_CLIENT_ID_OPTION:
|
|
'Invalid "clientId" (mqtt client id) option supplied.',
|
|
INVALID_RECONNECT_TIMING: 'Invalid reconnect timing options supplied.',
|
|
INVALID_OFFLINE_QUEUEING_PARAMETERS:
|
|
'Invalid offline queueing options supplied.',
|
|
}
|
|
})
|
|
var cr = b((Kw, Jl) => {
|
|
Jl.exports = function (e) {
|
|
return typeof e > 'u' || e === null
|
|
}
|
|
})
|
|
var Zl = b((Yw, Xl) => {
|
|
Xl.exports = {
|
|
NO_KEY_OPTION: 'No "keyPath" or "privateKey" option supplied.',
|
|
NO_CERT_OPTION: 'No "certPath" or "clientCert" option supplied.',
|
|
NO_CA_OPTION: 'No "caPath" or "caCert" option supplied.',
|
|
INVALID_KEY_PATH_OPTION: 'Invalid "keyPath" option supplied.',
|
|
INVALID_CERT_PATH_OPTION: 'Invalid "certPath" option supplied.',
|
|
INVALID_CA_PATH_OPTION: 'Invalid "caPath" option supplied.',
|
|
INVALID_CLIENT_CERT_OPTION: 'Invalid "clientCert" option supplied.',
|
|
INVALID_PRIVATE_KEY_OPTION: 'Invalid "privateKey" option supplied.',
|
|
INVALID_CA_CERT_OPTION: 'Invalid "caCert" option supplied.',
|
|
}
|
|
})
|
|
var tu = b((Qw, eu) => {
|
|
var be = require('fs'),
|
|
ye = cr(),
|
|
Ne = Zl()
|
|
eu.exports = function (e) {
|
|
if (ye(e.keyPath) && ye(e.privateKey)) throw new Error(Ne.NO_KEY_OPTION)
|
|
if (ye(e.certPath) && ye(e.clientCert)) throw new Error(Ne.NO_CERT_OPTION)
|
|
if (ye(e.caPath) && ye(e.caCert)) throw new Error(Ne.NO_CA_OPTION)
|
|
if (!ye(e.caCert))
|
|
if (Buffer.isBuffer(e.caCert)) e.ca = e.caCert
|
|
else if (be.existsSync(e.caCert)) e.ca = be.readFileSync(e.caCert)
|
|
else throw new Error(Ne.INVALID_CA_CERT_OPTION)
|
|
if (!ye(e.privateKey))
|
|
if (Buffer.isBuffer(e.privateKey)) e.key = e.privateKey
|
|
else if (be.existsSync(e.privateKey))
|
|
e.key = be.readFileSync(e.privateKey)
|
|
else throw new Error(Ne.INVALID_PRIVATE_KEY_OPTION)
|
|
if (!ye(e.clientCert))
|
|
if (Buffer.isBuffer(e.clientCert)) e.cert = e.clientCert
|
|
else if (be.existsSync(e.clientCert))
|
|
e.cert = be.readFileSync(e.clientCert)
|
|
else throw new Error(Ne.INVALID_CLIENT_CERT_OPTION)
|
|
if (be.existsSync(e.keyPath)) e.key = be.readFileSync(e.keyPath)
|
|
else if (!ye(e.keyPath)) throw new Error(Ne.INVALID_KEY_PATH_OPTION)
|
|
if (be.existsSync(e.certPath)) e.cert = be.readFileSync(e.certPath)
|
|
else if (!ye(e.certPath)) throw new Error(Ne.INVALID_CERT_PATH_OPTION)
|
|
if (be.existsSync(e.caPath)) e.ca = be.readFileSync(e.caPath)
|
|
else if (!ye(e.caPath)) throw new Error(Ne.INVALID_CA_PATH_OPTION)
|
|
;(e.requestCert = !0), (e.rejectUnauthorized = !0)
|
|
}
|
|
})
|
|
var ru = b((Jw, Bb) => {
|
|
Bb.exports = {
|
|
name: 'aws-iot-device-sdk',
|
|
description: 'AWS IoT Node.js SDK for Embedded Devices',
|
|
version: '2.2.13',
|
|
author: {
|
|
name: 'Amazon Web Services',
|
|
email: '',
|
|
url: 'http://aws.amazon.com',
|
|
},
|
|
homepage: 'https://github.com/aws/aws-iot-device-sdk-js',
|
|
main: 'index.js',
|
|
engines: { node: '>=4.0.0' },
|
|
repository: {
|
|
type: 'git',
|
|
url: 'git://github.com/aws/aws-iot-device-sdk-js',
|
|
},
|
|
bugs: { url: 'http://github.com/aws/aws-iot-device-sdk-js/issues' },
|
|
license: 'Apache-2.0',
|
|
keywords: ['api', 'amazon', 'aws', 'iot', 'mqtt'],
|
|
dependencies: {
|
|
'crypto-js': '4.2.0',
|
|
minimist: '1.2.6',
|
|
mqtt: '4.2.8',
|
|
'websocket-stream': '^5.5.2',
|
|
},
|
|
devDependencies: {
|
|
gulp: '^3.9.0',
|
|
'gulp-beautify': '^2.0.0',
|
|
'gulp-concat': '^2.6.0',
|
|
'gulp-coverage': '^0.3.38',
|
|
'gulp-jscs': '^4.0.0',
|
|
'gulp-jshint': '^2.0.0',
|
|
'gulp-mocha': '^3.0.1',
|
|
jshint: '^2.9.1',
|
|
'jshint-stylish': '^2.2.1',
|
|
rewire: '^2.5.1',
|
|
sinon: '^1.17.3',
|
|
},
|
|
scripts: {
|
|
test: 'node ./node_modules/gulp/bin/gulp.js test --verbose',
|
|
browserize: './scripts/browserize.sh',
|
|
beautify: 'node ./node_modules/gulp/bin/gulp.js beautify',
|
|
},
|
|
}
|
|
})
|
|
var nu = b((Xw, iu) => {
|
|
var Ab = require('tls')
|
|
function Nb(e, t) {
|
|
var r
|
|
r = Ab.connect(t)
|
|
function i(n) {
|
|
e.emit('error', n), r.end()
|
|
}
|
|
return (
|
|
r.on('secureConnect', function () {
|
|
r.authorized
|
|
? r.removeListener('error', i)
|
|
: r.emit('error', new Error('TLS not authorized'))
|
|
}),
|
|
r.on('error', i),
|
|
r
|
|
)
|
|
}
|
|
iu.exports = Nb
|
|
})
|
|
var Os = b((Zw, su) => {
|
|
'use strict'
|
|
var Mb = Object.prototype.hasOwnProperty,
|
|
Lb = 0
|
|
function dt(e) {
|
|
if (!(this instanceof dt)) return new dt(e)
|
|
;(this.id = Lb++), (this.ee = e)
|
|
}
|
|
dt.prototype.on = function (t, r, i) {
|
|
return (r.__ultron = this.id), this.ee.on(t, r, i), this
|
|
}
|
|
dt.prototype.once = function (t, r, i) {
|
|
return (r.__ultron = this.id), this.ee.once(t, r, i), this
|
|
}
|
|
dt.prototype.remove = function () {
|
|
var t = arguments,
|
|
r = this.ee,
|
|
i
|
|
if (t.length === 1 && typeof t[0] == 'string') t = t[0].split(/[, ]+/)
|
|
else if (!t.length) {
|
|
if (r.eventNames) t = r.eventNames()
|
|
else if (r._events) {
|
|
t = []
|
|
for (i in r._events) Mb.call(r._events, i) && t.push(i)
|
|
Object.getOwnPropertySymbols &&
|
|
(t = t.concat(Object.getOwnPropertySymbols(r._events)))
|
|
}
|
|
}
|
|
for (var n = 0; n < t.length; n++)
|
|
for (var s = r.listeners(t[n]), o = 0; o < s.length; o++) {
|
|
if (((i = s[o]), i.listener)) {
|
|
if (i.listener.__ultron !== this.id) continue
|
|
} else if (i.__ultron !== this.id) continue
|
|
r.removeListener(t[n], i)
|
|
}
|
|
return this
|
|
}
|
|
dt.prototype.destroy = function () {
|
|
return this.ee ? (this.remove(), (this.ee = null), !0) : !1
|
|
}
|
|
su.exports = dt
|
|
})
|
|
var ve = b((ks, au) => {
|
|
var Ci = require('buffer'),
|
|
Me = Ci.Buffer
|
|
function ou(e, t) {
|
|
for (var r in e) t[r] = e[r]
|
|
}
|
|
Me.from && Me.alloc && Me.allocUnsafe && Me.allocUnsafeSlow
|
|
? (au.exports = Ci)
|
|
: (ou(Ci, ks), (ks.Buffer = Pt))
|
|
function Pt(e, t, r) {
|
|
return Me(e, t, r)
|
|
}
|
|
ou(Me, Pt)
|
|
Pt.from = function (e, t, r) {
|
|
if (typeof e == 'number')
|
|
throw new TypeError('Argument must not be a number')
|
|
return Me(e, t, r)
|
|
}
|
|
Pt.alloc = function (e, t, r) {
|
|
if (typeof e != 'number') throw new TypeError('Argument must be a number')
|
|
var i = Me(e)
|
|
return (
|
|
t !== void 0
|
|
? typeof r == 'string'
|
|
? i.fill(t, r)
|
|
: i.fill(t)
|
|
: i.fill(0),
|
|
i
|
|
)
|
|
}
|
|
Pt.allocUnsafe = function (e) {
|
|
if (typeof e != 'number') throw new TypeError('Argument must be a number')
|
|
return Me(e)
|
|
}
|
|
Pt.allocUnsafeSlow = function (e) {
|
|
if (typeof e != 'number') throw new TypeError('Argument must be a number')
|
|
return Ci.SlowBuffer(e)
|
|
}
|
|
})
|
|
var lu = b((e0, fu) => {
|
|
'use strict'
|
|
function pt(e) {
|
|
if (!(this instanceof pt)) return new pt(e)
|
|
;(e = e || {}),
|
|
(this.concurrency = e.concurrency || 1 / 0),
|
|
(this.pending = 0),
|
|
(this.jobs = []),
|
|
(this.cbs = []),
|
|
(this._done = Db.bind(this))
|
|
}
|
|
var qb = ['push', 'unshift', 'splice']
|
|
qb.forEach(function (e) {
|
|
pt.prototype[e] = function () {
|
|
var t = Array.prototype[e].apply(this.jobs, arguments)
|
|
return this._run(), t
|
|
}
|
|
})
|
|
Object.defineProperty(pt.prototype, 'length', {
|
|
get: function () {
|
|
return this.pending + this.jobs.length
|
|
},
|
|
})
|
|
pt.prototype._run = function () {
|
|
if (this.pending !== this.concurrency) {
|
|
if (this.jobs.length) {
|
|
var e = this.jobs.shift()
|
|
this.pending++, e(this._done), this._run()
|
|
}
|
|
if (this.pending === 0)
|
|
for (; this.cbs.length !== 0; ) {
|
|
var t = this.cbs.pop()
|
|
process.nextTick(t)
|
|
}
|
|
}
|
|
}
|
|
pt.prototype.onDone = function (e) {
|
|
typeof e == 'function' && (this.cbs.push(e), this._run())
|
|
}
|
|
function Db() {
|
|
this.pending--, this._run()
|
|
}
|
|
fu.exports = pt
|
|
})
|
|
var Ti = b((t0, Rs) => {
|
|
'use strict'
|
|
var Ub = ve(),
|
|
jb = Ub.Buffer,
|
|
uu = (e, t) => {
|
|
let r = jb.allocUnsafe(t)
|
|
for (var i = 0, n = 0; n < e.length; n++) {
|
|
let s = e[n]
|
|
s.copy(r, i), (i += s.length)
|
|
}
|
|
return r
|
|
}
|
|
try {
|
|
let e = require('bufferutil')
|
|
Rs.exports = Object.assign({ concat: uu }, e.BufferUtil || e)
|
|
} catch {
|
|
let t = (i, n, s, o, f) => {
|
|
for (var a = 0; a < f; a++) s[o + a] = i[a] ^ n[a & 3]
|
|
},
|
|
r = (i, n) => {
|
|
let s = i.length
|
|
for (var o = 0; o < s; o++) i[o] ^= n[o & 3]
|
|
}
|
|
Rs.exports = { concat: uu, mask: t, unmask: r }
|
|
}
|
|
})
|
|
var hr = b((r0, _u) => {
|
|
'use strict'
|
|
var Fb = ve(),
|
|
Wb = lu(),
|
|
Ze = require('zlib'),
|
|
cu = Ti(),
|
|
hu = Fb.Buffer,
|
|
Vb = hu.from([0, 0, 255, 255]),
|
|
Hb = hu.from([0]),
|
|
Bt = Symbol('write-in-progress'),
|
|
Ii = Symbol('pending-close'),
|
|
Le = Symbol('total-length'),
|
|
du = Symbol('callback'),
|
|
et = Symbol('buffers'),
|
|
Ps = Symbol('error'),
|
|
ki = Symbol('owner'),
|
|
Oi,
|
|
Bs = class {
|
|
constructor(t, r, i) {
|
|
if (
|
|
((this._maxPayload = i | 0),
|
|
(this._options = t || {}),
|
|
(this._threshold =
|
|
this._options.threshold !== void 0
|
|
? this._options.threshold
|
|
: 1024),
|
|
(this._isServer = !!r),
|
|
(this._deflate = null),
|
|
(this._inflate = null),
|
|
(this.params = null),
|
|
!Oi)
|
|
) {
|
|
let n =
|
|
this._options.concurrencyLimit !== void 0
|
|
? this._options.concurrencyLimit
|
|
: 10
|
|
Oi = new Wb({ concurrency: n })
|
|
}
|
|
}
|
|
static get extensionName() {
|
|
return 'permessage-deflate'
|
|
}
|
|
offer() {
|
|
let t = {}
|
|
return (
|
|
this._options.serverNoContextTakeover &&
|
|
(t.server_no_context_takeover = !0),
|
|
this._options.clientNoContextTakeover &&
|
|
(t.client_no_context_takeover = !0),
|
|
this._options.serverMaxWindowBits &&
|
|
(t.server_max_window_bits = this._options.serverMaxWindowBits),
|
|
this._options.clientMaxWindowBits
|
|
? (t.client_max_window_bits = this._options.clientMaxWindowBits)
|
|
: this._options.clientMaxWindowBits == null &&
|
|
(t.client_max_window_bits = !0),
|
|
t
|
|
)
|
|
}
|
|
accept(t) {
|
|
t = this.normalizeParams(t)
|
|
var r
|
|
return (
|
|
this._isServer
|
|
? (r = this.acceptAsServer(t))
|
|
: (r = this.acceptAsClient(t)),
|
|
(this.params = r),
|
|
r
|
|
)
|
|
}
|
|
cleanup() {
|
|
this._inflate &&
|
|
(this._inflate[Bt]
|
|
? (this._inflate[Ii] = !0)
|
|
: (this._inflate.close(), (this._inflate = null))),
|
|
this._deflate &&
|
|
(this._deflate[Bt]
|
|
? (this._deflate[Ii] = !0)
|
|
: (this._deflate.close(), (this._deflate = null)))
|
|
}
|
|
acceptAsServer(t) {
|
|
let r = {}
|
|
if (
|
|
!t.some((n) => {
|
|
if (
|
|
!(
|
|
(this._options.serverNoContextTakeover === !1 &&
|
|
n.server_no_context_takeover) ||
|
|
(this._options.serverMaxWindowBits === !1 &&
|
|
n.server_max_window_bits) ||
|
|
(typeof this._options.serverMaxWindowBits == 'number' &&
|
|
typeof n.server_max_window_bits == 'number' &&
|
|
this._options.serverMaxWindowBits >
|
|
n.server_max_window_bits) ||
|
|
(typeof this._options.clientMaxWindowBits == 'number' &&
|
|
!n.client_max_window_bits)
|
|
)
|
|
)
|
|
return (
|
|
(this._options.serverNoContextTakeover ||
|
|
n.server_no_context_takeover) &&
|
|
(r.server_no_context_takeover = !0),
|
|
(this._options.clientNoContextTakeover ||
|
|
(this._options.clientNoContextTakeover !== !1 &&
|
|
n.client_no_context_takeover)) &&
|
|
(r.client_no_context_takeover = !0),
|
|
typeof this._options.serverMaxWindowBits == 'number'
|
|
? (r.server_max_window_bits =
|
|
this._options.serverMaxWindowBits)
|
|
: typeof n.server_max_window_bits == 'number' &&
|
|
(r.server_max_window_bits = n.server_max_window_bits),
|
|
typeof this._options.clientMaxWindowBits == 'number'
|
|
? (r.client_max_window_bits =
|
|
this._options.clientMaxWindowBits)
|
|
: this._options.clientMaxWindowBits !== !1 &&
|
|
typeof n.client_max_window_bits == 'number' &&
|
|
(r.client_max_window_bits = n.client_max_window_bits),
|
|
!0
|
|
)
|
|
})
|
|
)
|
|
throw new Error("Doesn't support the offered configuration")
|
|
return r
|
|
}
|
|
acceptAsClient(t) {
|
|
let r = t[0]
|
|
if (
|
|
this._options.clientNoContextTakeover === !1 &&
|
|
r.client_no_context_takeover
|
|
)
|
|
throw new Error('Invalid value for "client_no_context_takeover"')
|
|
if (
|
|
(typeof this._options.clientMaxWindowBits == 'number' &&
|
|
(!r.client_max_window_bits ||
|
|
r.client_max_window_bits > this._options.clientMaxWindowBits)) ||
|
|
(this._options.clientMaxWindowBits === !1 && r.client_max_window_bits)
|
|
)
|
|
throw new Error('Invalid value for "client_max_window_bits"')
|
|
return r
|
|
}
|
|
normalizeParams(t) {
|
|
return t.map(
|
|
(r) => (
|
|
Object.keys(r).forEach((i) => {
|
|
var n = r[i]
|
|
if (n.length > 1)
|
|
throw new Error(`Multiple extension parameters for ${i}`)
|
|
switch (((n = n[0]), i)) {
|
|
case 'server_no_context_takeover':
|
|
case 'client_no_context_takeover':
|
|
if (n !== !0)
|
|
throw new Error(
|
|
`invalid extension parameter value for ${i} (${n})`,
|
|
)
|
|
r[i] = !0
|
|
break
|
|
case 'server_max_window_bits':
|
|
case 'client_max_window_bits':
|
|
if (
|
|
typeof n == 'string' &&
|
|
((n = parseInt(n, 10)),
|
|
Number.isNaN(n) ||
|
|
n < Ze.Z_MIN_WINDOWBITS ||
|
|
n > Ze.Z_MAX_WINDOWBITS)
|
|
)
|
|
throw new Error(
|
|
`invalid extension parameter value for ${i} (${n})`,
|
|
)
|
|
if (!this._isServer && n === !0)
|
|
throw new Error(
|
|
`Missing extension parameter value for ${i}`,
|
|
)
|
|
r[i] = n
|
|
break
|
|
default:
|
|
throw new Error(`Not defined extension parameter (${i})`)
|
|
}
|
|
}),
|
|
r
|
|
),
|
|
)
|
|
}
|
|
decompress(t, r, i) {
|
|
Oi.push((n) => {
|
|
this._decompress(t, r, (s, o) => {
|
|
n(), i(s, o)
|
|
})
|
|
})
|
|
}
|
|
compress(t, r, i) {
|
|
Oi.push((n) => {
|
|
this._compress(t, r, (s, o) => {
|
|
n(), i(s, o)
|
|
})
|
|
})
|
|
}
|
|
_decompress(t, r, i) {
|
|
let n = this._isServer ? 'client' : 'server'
|
|
if (!this._inflate) {
|
|
let s = `${n}_max_window_bits`,
|
|
o =
|
|
typeof this.params[s] != 'number'
|
|
? Ze.Z_DEFAULT_WINDOWBITS
|
|
: this.params[s]
|
|
;(this._inflate = Ze.createInflateRaw({ windowBits: o })),
|
|
(this._inflate[Le] = 0),
|
|
(this._inflate[et] = []),
|
|
(this._inflate[ki] = this),
|
|
this._inflate.on('error', Gb),
|
|
this._inflate.on('data', pu)
|
|
}
|
|
;(this._inflate[du] = i),
|
|
(this._inflate[Bt] = !0),
|
|
this._inflate.write(t),
|
|
r && this._inflate.write(Vb),
|
|
this._inflate.flush(() => {
|
|
let s = this._inflate[Ps]
|
|
if (s) {
|
|
this._inflate.close(), (this._inflate = null), i(s)
|
|
return
|
|
}
|
|
let o = cu.concat(this._inflate[et], this._inflate[Le])
|
|
;(r && this.params[`${n}_no_context_takeover`]) || this._inflate[Ii]
|
|
? (this._inflate.close(), (this._inflate = null))
|
|
: ((this._inflate[Bt] = !1),
|
|
(this._inflate[Le] = 0),
|
|
(this._inflate[et] = [])),
|
|
i(null, o)
|
|
})
|
|
}
|
|
_compress(t, r, i) {
|
|
if (!t || t.length === 0) {
|
|
process.nextTick(i, null, Hb)
|
|
return
|
|
}
|
|
let n = this._isServer ? 'server' : 'client'
|
|
if (!this._deflate) {
|
|
let s = `${n}_max_window_bits`,
|
|
o =
|
|
typeof this.params[s] != 'number'
|
|
? Ze.Z_DEFAULT_WINDOWBITS
|
|
: this.params[s]
|
|
;(this._deflate = Ze.createDeflateRaw({
|
|
memLevel: this._options.memLevel,
|
|
level: this._options.level,
|
|
flush: Ze.Z_SYNC_FLUSH,
|
|
windowBits: o,
|
|
})),
|
|
(this._deflate[Le] = 0),
|
|
(this._deflate[et] = []),
|
|
this._deflate.on('data', $b)
|
|
}
|
|
;(this._deflate[Bt] = !0),
|
|
this._deflate.write(t),
|
|
this._deflate.flush(Ze.Z_SYNC_FLUSH, () => {
|
|
var s = cu.concat(this._deflate[et], this._deflate[Le])
|
|
r && (s = s.slice(0, s.length - 4)),
|
|
(r && this.params[`${n}_no_context_takeover`]) ||
|
|
this._deflate[Ii]
|
|
? (this._deflate.close(), (this._deflate = null))
|
|
: ((this._deflate[Bt] = !1),
|
|
(this._deflate[Le] = 0),
|
|
(this._deflate[et] = [])),
|
|
i(null, s)
|
|
})
|
|
}
|
|
}
|
|
_u.exports = Bs
|
|
function $b(e) {
|
|
this[et].push(e), (this[Le] += e.length)
|
|
}
|
|
function pu(e) {
|
|
if (
|
|
((this[Le] += e.length),
|
|
this[ki]._maxPayload < 1 || this[Le] <= this[ki]._maxPayload)
|
|
) {
|
|
this[et].push(e)
|
|
return
|
|
}
|
|
;(this[Ps] = new Error('max payload size exceeded')),
|
|
(this[Ps].closeCode = 1009),
|
|
this.removeListener('data', pu),
|
|
this.reset()
|
|
}
|
|
function Gb(e) {
|
|
;(this[ki]._inflate = null), this[du](e)
|
|
}
|
|
})
|
|
var bu = b((i0, gu) => {
|
|
'use strict'
|
|
var dr = class {
|
|
constructor(t, r) {
|
|
;(this.target = r), (this.type = t)
|
|
}
|
|
},
|
|
As = class extends dr {
|
|
constructor(t, r) {
|
|
super('message', r), (this.data = t)
|
|
}
|
|
},
|
|
Ns = class extends dr {
|
|
constructor(t, r, i) {
|
|
super('close', i),
|
|
(this.wasClean = i._closeFrameReceived && i._closeFrameSent),
|
|
(this.reason = r),
|
|
(this.code = t)
|
|
}
|
|
},
|
|
Ms = class extends dr {
|
|
constructor(t) {
|
|
super('open', t)
|
|
}
|
|
},
|
|
zb = {
|
|
addEventListener(e, t) {
|
|
if (typeof t != 'function') return
|
|
function r(o) {
|
|
t.call(this, new As(o, this))
|
|
}
|
|
function i(o, f) {
|
|
t.call(this, new Ns(o, f, this))
|
|
}
|
|
function n(o) {
|
|
;(o.type = 'error'), (o.target = this), t.call(this, o)
|
|
}
|
|
function s() {
|
|
t.call(this, new Ms(this))
|
|
}
|
|
e === 'message'
|
|
? ((r._listener = t), this.on(e, r))
|
|
: e === 'close'
|
|
? ((i._listener = t), this.on(e, i))
|
|
: e === 'error'
|
|
? ((n._listener = t), this.on(e, n))
|
|
: e === 'open'
|
|
? ((s._listener = t), this.on(e, s))
|
|
: this.on(e, t)
|
|
},
|
|
removeEventListener(e, t) {
|
|
let r = this.listeners(e)
|
|
for (var i = 0; i < r.length; i++)
|
|
(r[i] === t || r[i]._listener === t) && this.removeListener(e, r[i])
|
|
},
|
|
}
|
|
gu.exports = zb
|
|
})
|
|
var Ls = b((n0, yu) => {
|
|
'use strict'
|
|
var pr = [
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1,
|
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
|
|
0, 1, 0,
|
|
]
|
|
function Te(e, t, r) {
|
|
Object.prototype.hasOwnProperty.call(e, t) ? e[t].push(r) : (e[t] = [r])
|
|
}
|
|
function Kb(e) {
|
|
let t = {}
|
|
if (e === void 0 || e === '') return t
|
|
for (
|
|
var r = {}, i = !1, n = !1, s = !1, o, f, a = -1, l = -1, u = 0;
|
|
u < e.length;
|
|
u++
|
|
) {
|
|
let d = e.charCodeAt(u)
|
|
if (o === void 0)
|
|
if (l === -1 && pr[d] === 1) a === -1 && (a = u)
|
|
else if (d === 32 || d === 9) l === -1 && a !== -1 && (l = u)
|
|
else if (d === 59 || d === 44) {
|
|
if (a === -1) throw new Error(`unexpected character at index ${u}`)
|
|
l === -1 && (l = u)
|
|
let _ = e.slice(a, l)
|
|
d === 44 ? (Te(t, _, r), (r = {})) : (o = _), (a = l = -1)
|
|
} else throw new Error(`unexpected character at index ${u}`)
|
|
else if (f === void 0)
|
|
if (l === -1 && pr[d] === 1) a === -1 && (a = u)
|
|
else if (d === 32 || d === 9) l === -1 && a !== -1 && (l = u)
|
|
else if (d === 59 || d === 44) {
|
|
if (a === -1) throw new Error(`unexpected character at index ${u}`)
|
|
l === -1 && (l = u),
|
|
Te(r, e.slice(a, l), !0),
|
|
d === 44 && (Te(t, o, r), (r = {}), (o = void 0)),
|
|
(a = l = -1)
|
|
} else if (d === 61 && a !== -1 && l === -1)
|
|
(f = e.slice(a, u)), (a = l = -1)
|
|
else throw new Error(`unexpected character at index ${u}`)
|
|
else if (n) {
|
|
if (pr[d] !== 1) throw new Error(`unexpected character at index ${u}`)
|
|
a === -1 ? (a = u) : i || (i = !0), (n = !1)
|
|
} else if (s)
|
|
if (pr[d] === 1) a === -1 && (a = u)
|
|
else if (d === 34 && a !== -1) (s = !1), (l = u)
|
|
else if (d === 92) n = !0
|
|
else throw new Error(`unexpected character at index ${u}`)
|
|
else if (d === 34 && e.charCodeAt(u - 1) === 61) s = !0
|
|
else if (l === -1 && pr[d] === 1) a === -1 && (a = u)
|
|
else if (a !== -1 && (d === 32 || d === 9)) l === -1 && (l = u)
|
|
else if (d === 59 || d === 44) {
|
|
if (a === -1) throw new Error(`unexpected character at index ${u}`)
|
|
l === -1 && (l = u)
|
|
var h = e.slice(a, l)
|
|
i && ((h = h.replace(/\\/g, '')), (i = !1)),
|
|
Te(r, f, h),
|
|
d === 44 && (Te(t, o, r), (r = {}), (o = void 0)),
|
|
(f = void 0),
|
|
(a = l = -1)
|
|
} else throw new Error(`unexpected character at index ${u}`)
|
|
}
|
|
if (a === -1 || s) throw new Error('unexpected end of input')
|
|
l === -1 && (l = u)
|
|
let c = e.slice(a, l)
|
|
return (
|
|
o === void 0
|
|
? Te(t, c, {})
|
|
: (f === void 0
|
|
? Te(r, c, !0)
|
|
: i
|
|
? Te(r, f, c.replace(/\\/g, ''))
|
|
: Te(r, f, c),
|
|
Te(t, o, r)),
|
|
t
|
|
)
|
|
}
|
|
function Yb(e) {
|
|
return Object.keys(e)
|
|
.map((t) => {
|
|
var r = e[t]
|
|
return (
|
|
Array.isArray(r) || (r = [r]),
|
|
r
|
|
.map((i) =>
|
|
[t]
|
|
.concat(
|
|
Object.keys(i).map((n) => {
|
|
var s = i[n]
|
|
return (
|
|
Array.isArray(s) || (s = [s]),
|
|
s.map((o) => (o === !0 ? n : `${n}=${o}`)).join('; ')
|
|
)
|
|
}),
|
|
)
|
|
.join('; '),
|
|
)
|
|
.join(', ')
|
|
)
|
|
})
|
|
.join(', ')
|
|
}
|
|
yu.exports = { format: Yb, parse: Kb }
|
|
})
|
|
var gr = b((_r) => {
|
|
'use strict'
|
|
var Qb = ve(),
|
|
Jb = Qb.Buffer
|
|
_r.BINARY_TYPES = ['nodebuffer', 'arraybuffer', 'fragments']
|
|
_r.GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'
|
|
_r.EMPTY_BUFFER = Jb.alloc(0)
|
|
_r.NOOP = () => {}
|
|
})
|
|
var vu = b((o0, qs) => {
|
|
'use strict'
|
|
try {
|
|
let e = require('utf-8-validate')
|
|
qs.exports = typeof e == 'object' ? e.Validation.isValidUTF8 : e
|
|
} catch {
|
|
qs.exports = () => !0
|
|
}
|
|
})
|
|
var Ds = b((a0, mu) => {
|
|
'use strict'
|
|
mu.exports = {
|
|
isValidErrorCode: function (e) {
|
|
return (
|
|
(e >= 1e3 && e <= 1013 && e !== 1004 && e !== 1005 && e !== 1006) ||
|
|
(e >= 3e3 && e <= 4999)
|
|
)
|
|
},
|
|
1e3: 'normal',
|
|
1001: 'going away',
|
|
1002: 'protocol error',
|
|
1003: 'unsupported data',
|
|
1004: 'reserved',
|
|
1005: 'reserved for extensions',
|
|
1006: 'reserved for extensions',
|
|
1007: 'inconsistent or invalid data',
|
|
1008: 'policy violation',
|
|
1009: 'message too big',
|
|
1010: 'extension handshake missing',
|
|
1011: 'an unexpected condition prevented the request from being fulfilled',
|
|
1012: 'service restart',
|
|
1013: 'try again later',
|
|
}
|
|
})
|
|
var Vs = b((f0, Ou) => {
|
|
'use strict'
|
|
var Xb = ve(),
|
|
wu = hr(),
|
|
Su = vu(),
|
|
Iu = Ti(),
|
|
Zb = Ds(),
|
|
Fs = gr(),
|
|
ey = Xb.Buffer,
|
|
Ri = 0,
|
|
Eu = 1,
|
|
xu = 2,
|
|
Cu = 3,
|
|
Us = 4,
|
|
Tu = 5,
|
|
Ws = class {
|
|
constructor(t, r, i) {
|
|
;(this._binaryType = i || Fs.BINARY_TYPES[0]),
|
|
(this._extensions = t || {}),
|
|
(this._maxPayload = r | 0),
|
|
(this._bufferedBytes = 0),
|
|
(this._buffers = []),
|
|
(this._compressed = !1),
|
|
(this._payloadLength = 0),
|
|
(this._fragmented = 0),
|
|
(this._masked = !1),
|
|
(this._fin = !1),
|
|
(this._mask = null),
|
|
(this._opcode = 0),
|
|
(this._totalPayloadLength = 0),
|
|
(this._messageLength = 0),
|
|
(this._fragments = []),
|
|
(this._cleanupCallback = null),
|
|
(this._hadError = !1),
|
|
(this._dead = !1),
|
|
(this._loop = !1),
|
|
(this.onmessage = null),
|
|
(this.onclose = null),
|
|
(this.onerror = null),
|
|
(this.onping = null),
|
|
(this.onpong = null),
|
|
(this._state = Ri)
|
|
}
|
|
readBuffer(t) {
|
|
var r = 0,
|
|
i,
|
|
n
|
|
if (((this._bufferedBytes -= t), t === this._buffers[0].length))
|
|
return this._buffers.shift()
|
|
if (t < this._buffers[0].length)
|
|
return (
|
|
(i = this._buffers[0].slice(0, t)),
|
|
(this._buffers[0] = this._buffers[0].slice(t)),
|
|
i
|
|
)
|
|
for (i = ey.allocUnsafe(t); t > 0; )
|
|
(n = this._buffers[0].length),
|
|
t >= n
|
|
? (this._buffers[0].copy(i, r), (r += n), this._buffers.shift())
|
|
: (this._buffers[0].copy(i, r, 0, t),
|
|
(this._buffers[0] = this._buffers[0].slice(t))),
|
|
(t -= n)
|
|
return i
|
|
}
|
|
hasBufferedBytes(t) {
|
|
return this._bufferedBytes >= t
|
|
? !0
|
|
: ((this._loop = !1),
|
|
this._dead && this.cleanup(this._cleanupCallback),
|
|
!1)
|
|
}
|
|
add(t) {
|
|
this._dead ||
|
|
((this._bufferedBytes += t.length),
|
|
this._buffers.push(t),
|
|
this.startLoop())
|
|
}
|
|
startLoop() {
|
|
for (this._loop = !0; this._loop; )
|
|
switch (this._state) {
|
|
case Ri:
|
|
this.getInfo()
|
|
break
|
|
case Eu:
|
|
this.getPayloadLength16()
|
|
break
|
|
case xu:
|
|
this.getPayloadLength64()
|
|
break
|
|
case Cu:
|
|
this.getMask()
|
|
break
|
|
case Us:
|
|
this.getData()
|
|
break
|
|
default:
|
|
this._loop = !1
|
|
}
|
|
}
|
|
getInfo() {
|
|
if (!this.hasBufferedBytes(2)) return
|
|
let t = this.readBuffer(2)
|
|
if (t[0] & 48) {
|
|
this.error(new Error('RSV2 and RSV3 must be clear'), 1002)
|
|
return
|
|
}
|
|
let r = (t[0] & 64) === 64
|
|
if (r && !this._extensions[wu.extensionName]) {
|
|
this.error(new Error('RSV1 must be clear'), 1002)
|
|
return
|
|
}
|
|
if (
|
|
((this._fin = (t[0] & 128) === 128),
|
|
(this._opcode = t[0] & 15),
|
|
(this._payloadLength = t[1] & 127),
|
|
this._opcode === 0)
|
|
) {
|
|
if (r) {
|
|
this.error(new Error('RSV1 must be clear'), 1002)
|
|
return
|
|
}
|
|
if (this._fragmented) this._opcode = this._fragmented
|
|
else {
|
|
this.error(new Error(`invalid opcode: ${this._opcode}`), 1002)
|
|
return
|
|
}
|
|
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
if (this._fragmented) {
|
|
this.error(new Error(`invalid opcode: ${this._opcode}`), 1002)
|
|
return
|
|
}
|
|
this._compressed = r
|
|
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
if (!this._fin) {
|
|
this.error(new Error('FIN must be set'), 1002)
|
|
return
|
|
}
|
|
if (r) {
|
|
this.error(new Error('RSV1 must be clear'), 1002)
|
|
return
|
|
}
|
|
if (this._payloadLength > 125) {
|
|
this.error(new Error('invalid payload length'), 1002)
|
|
return
|
|
}
|
|
} else {
|
|
this.error(new Error(`invalid opcode: ${this._opcode}`), 1002)
|
|
return
|
|
}
|
|
!this._fin && !this._fragmented && (this._fragmented = this._opcode),
|
|
(this._masked = (t[1] & 128) === 128),
|
|
this._payloadLength === 126
|
|
? (this._state = Eu)
|
|
: this._payloadLength === 127
|
|
? (this._state = xu)
|
|
: this.haveLength()
|
|
}
|
|
getPayloadLength16() {
|
|
this.hasBufferedBytes(2) &&
|
|
((this._payloadLength = this.readBuffer(2).readUInt16BE(0, !0)),
|
|
this.haveLength())
|
|
}
|
|
getPayloadLength64() {
|
|
if (!this.hasBufferedBytes(8)) return
|
|
let t = this.readBuffer(8),
|
|
r = t.readUInt32BE(0, !0)
|
|
if (r > Math.pow(2, 21) - 1) {
|
|
this.error(new Error('max payload size exceeded'), 1009)
|
|
return
|
|
}
|
|
;(this._payloadLength = r * Math.pow(2, 32) + t.readUInt32BE(4, !0)),
|
|
this.haveLength()
|
|
}
|
|
haveLength() {
|
|
;(this._opcode < 8 && this.maxPayloadExceeded(this._payloadLength)) ||
|
|
(this._masked ? (this._state = Cu) : (this._state = Us))
|
|
}
|
|
getMask() {
|
|
this.hasBufferedBytes(4) &&
|
|
((this._mask = this.readBuffer(4)), (this._state = Us))
|
|
}
|
|
getData() {
|
|
var t = Fs.EMPTY_BUFFER
|
|
if (this._payloadLength) {
|
|
if (!this.hasBufferedBytes(this._payloadLength)) return
|
|
;(t = this.readBuffer(this._payloadLength)),
|
|
this._masked && Iu.unmask(t, this._mask)
|
|
}
|
|
this._opcode > 7
|
|
? this.controlMessage(t)
|
|
: this._compressed
|
|
? ((this._state = Tu), this.decompress(t))
|
|
: this.pushFragment(t) && this.dataMessage()
|
|
}
|
|
decompress(t) {
|
|
this._extensions[wu.extensionName].decompress(t, this._fin, (i, n) => {
|
|
if (i) {
|
|
this.error(i, i.closeCode === 1009 ? 1009 : 1007)
|
|
return
|
|
}
|
|
this.pushFragment(n) && this.dataMessage(), this.startLoop()
|
|
})
|
|
}
|
|
dataMessage() {
|
|
if (this._fin) {
|
|
let r = this._messageLength,
|
|
i = this._fragments
|
|
if (
|
|
((this._totalPayloadLength = 0),
|
|
(this._messageLength = 0),
|
|
(this._fragmented = 0),
|
|
(this._fragments = []),
|
|
this._opcode === 2)
|
|
) {
|
|
var t
|
|
this._binaryType === 'nodebuffer'
|
|
? (t = js(i, r))
|
|
: this._binaryType === 'arraybuffer'
|
|
? (t = ty(js(i, r)))
|
|
: (t = i),
|
|
this.onmessage(t)
|
|
} else {
|
|
let n = js(i, r)
|
|
if (!Su(n)) {
|
|
this.error(new Error('invalid utf8 sequence'), 1007)
|
|
return
|
|
}
|
|
this.onmessage(n.toString())
|
|
}
|
|
}
|
|
this._state = Ri
|
|
}
|
|
controlMessage(t) {
|
|
if (this._opcode === 8) {
|
|
if (t.length === 0)
|
|
this.onclose(1e3, ''),
|
|
(this._loop = !1),
|
|
this.cleanup(this._cleanupCallback)
|
|
else if (t.length === 1)
|
|
this.error(new Error('invalid payload length'), 1002)
|
|
else {
|
|
let r = t.readUInt16BE(0, !0)
|
|
if (!Zb.isValidErrorCode(r)) {
|
|
this.error(new Error(`invalid status code: ${r}`), 1002)
|
|
return
|
|
}
|
|
let i = t.slice(2)
|
|
if (!Su(i)) {
|
|
this.error(new Error('invalid utf8 sequence'), 1007)
|
|
return
|
|
}
|
|
this.onclose(r, i.toString()),
|
|
(this._loop = !1),
|
|
this.cleanup(this._cleanupCallback)
|
|
}
|
|
return
|
|
}
|
|
this._opcode === 9 ? this.onping(t) : this.onpong(t), (this._state = Ri)
|
|
}
|
|
error(t, r) {
|
|
this.onerror(t, r),
|
|
(this._hadError = !0),
|
|
(this._loop = !1),
|
|
this.cleanup(this._cleanupCallback)
|
|
}
|
|
maxPayloadExceeded(t) {
|
|
if (t === 0 || this._maxPayload < 1) return !1
|
|
let r = this._totalPayloadLength + t
|
|
return r <= this._maxPayload
|
|
? ((this._totalPayloadLength = r), !1)
|
|
: (this.error(new Error('max payload size exceeded'), 1009), !0)
|
|
}
|
|
pushFragment(t) {
|
|
if (t.length === 0) return !0
|
|
let r = this._messageLength + t.length
|
|
return this._maxPayload < 1 || r <= this._maxPayload
|
|
? ((this._messageLength = r), this._fragments.push(t), !0)
|
|
: (this.error(new Error('max payload size exceeded'), 1009), !1)
|
|
}
|
|
cleanup(t) {
|
|
;(this._dead = !0),
|
|
!this._hadError && (this._loop || this._state === Tu)
|
|
? (this._cleanupCallback = t)
|
|
: ((this._extensions = null),
|
|
(this._fragments = null),
|
|
(this._buffers = null),
|
|
(this._mask = null),
|
|
(this._cleanupCallback = null),
|
|
(this.onmessage = null),
|
|
(this.onclose = null),
|
|
(this.onerror = null),
|
|
(this.onping = null),
|
|
(this.onpong = null),
|
|
t && t())
|
|
}
|
|
}
|
|
Ou.exports = Ws
|
|
function js(e, t) {
|
|
return e.length === 1
|
|
? e[0]
|
|
: e.length > 1
|
|
? Iu.concat(e, t)
|
|
: Fs.EMPTY_BUFFER
|
|
}
|
|
function ty(e) {
|
|
return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength
|
|
? e.buffer
|
|
: e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength)
|
|
}
|
|
})
|
|
var Gs = b((l0, Pu) => {
|
|
'use strict'
|
|
var ry = ve(),
|
|
iy = require('crypto'),
|
|
ku = hr(),
|
|
Ru = Ti(),
|
|
ny = Ds(),
|
|
sy = gr(),
|
|
ae = ry.Buffer,
|
|
$s = class e {
|
|
constructor(t, r) {
|
|
;(this._extensions = r || {}),
|
|
(this._socket = t),
|
|
(this._firstFragment = !0),
|
|
(this._compress = !1),
|
|
(this._bufferedBytes = 0),
|
|
(this._deflating = !1),
|
|
(this._queue = [])
|
|
}
|
|
static frame(t, r) {
|
|
let i = t.length < 1024 || (r.mask && r.readOnly)
|
|
var n = r.mask ? 6 : 2,
|
|
s = t.length
|
|
t.length >= 65536
|
|
? ((n += 8), (s = 127))
|
|
: t.length > 125 && ((n += 2), (s = 126))
|
|
let o = ae.allocUnsafe(i ? t.length + n : n)
|
|
if (
|
|
((o[0] = r.fin ? r.opcode | 128 : r.opcode),
|
|
r.rsv1 && (o[0] |= 64),
|
|
s === 126
|
|
? o.writeUInt16BE(t.length, 2, !0)
|
|
: s === 127 &&
|
|
(o.writeUInt32BE(0, 2, !0), o.writeUInt32BE(t.length, 6, !0)),
|
|
!r.mask)
|
|
)
|
|
return (o[1] = s), i ? (t.copy(o, n), [o]) : [o, t]
|
|
let f = iy.randomBytes(4)
|
|
return (
|
|
(o[1] = s | 128),
|
|
(o[n - 4] = f[0]),
|
|
(o[n - 3] = f[1]),
|
|
(o[n - 2] = f[2]),
|
|
(o[n - 1] = f[3]),
|
|
i
|
|
? (Ru.mask(t, f, o, n, t.length), [o])
|
|
: (Ru.mask(t, f, t, 0, t.length), [o, t])
|
|
)
|
|
}
|
|
close(t, r, i, n) {
|
|
var s
|
|
if (t === void 0) t = 1e3
|
|
else if (typeof t != 'number' || !ny.isValidErrorCode(t))
|
|
throw new Error('first argument must be a valid error code number')
|
|
r === void 0 || r === ''
|
|
? t === 1e3
|
|
? (s = sy.EMPTY_BUFFER)
|
|
: ((s = ae.allocUnsafe(2)), s.writeUInt16BE(t, 0, !0))
|
|
: ((s = ae.allocUnsafe(2 + ae.byteLength(r))),
|
|
s.writeUInt16BE(t, 0, !0),
|
|
s.write(r, 2)),
|
|
this._deflating
|
|
? this.enqueue([this.doClose, s, i, n])
|
|
: this.doClose(s, i, n)
|
|
}
|
|
doClose(t, r, i) {
|
|
this.sendFrame(
|
|
e.frame(t, { fin: !0, rsv1: !1, opcode: 8, mask: r, readOnly: !1 }),
|
|
i,
|
|
)
|
|
}
|
|
ping(t, r) {
|
|
var i = !0
|
|
ae.isBuffer(t) ||
|
|
(t instanceof ArrayBuffer
|
|
? (t = ae.from(t))
|
|
: ArrayBuffer.isView(t)
|
|
? (t = Hs(t))
|
|
: ((t = ae.from(t)), (i = !1))),
|
|
this._deflating
|
|
? this.enqueue([this.doPing, t, r, i])
|
|
: this.doPing(t, r, i)
|
|
}
|
|
doPing(t, r, i) {
|
|
this.sendFrame(
|
|
e.frame(t, { fin: !0, rsv1: !1, opcode: 9, mask: r, readOnly: i }),
|
|
)
|
|
}
|
|
pong(t, r) {
|
|
var i = !0
|
|
ae.isBuffer(t) ||
|
|
(t instanceof ArrayBuffer
|
|
? (t = ae.from(t))
|
|
: ArrayBuffer.isView(t)
|
|
? (t = Hs(t))
|
|
: ((t = ae.from(t)), (i = !1))),
|
|
this._deflating
|
|
? this.enqueue([this.doPong, t, r, i])
|
|
: this.doPong(t, r, i)
|
|
}
|
|
doPong(t, r, i) {
|
|
this.sendFrame(
|
|
e.frame(t, { fin: !0, rsv1: !1, opcode: 10, mask: r, readOnly: i }),
|
|
)
|
|
}
|
|
send(t, r, i) {
|
|
var n = r.binary ? 2 : 1,
|
|
s = r.compress,
|
|
o = !0
|
|
ae.isBuffer(t) ||
|
|
(t instanceof ArrayBuffer
|
|
? (t = ae.from(t))
|
|
: ArrayBuffer.isView(t)
|
|
? (t = Hs(t))
|
|
: ((t = ae.from(t)), (o = !1)))
|
|
let f = this._extensions[ku.extensionName]
|
|
if (
|
|
(this._firstFragment
|
|
? ((this._firstFragment = !1),
|
|
s && f && (s = t.length >= f._threshold),
|
|
(this._compress = s))
|
|
: ((s = !1), (n = 0)),
|
|
r.fin && (this._firstFragment = !0),
|
|
f)
|
|
) {
|
|
let a = { fin: r.fin, rsv1: s, opcode: n, mask: r.mask, readOnly: o }
|
|
this._deflating
|
|
? this.enqueue([this.dispatch, t, this._compress, a, i])
|
|
: this.dispatch(t, this._compress, a, i)
|
|
} else
|
|
this.sendFrame(
|
|
e.frame(t, {
|
|
fin: r.fin,
|
|
rsv1: !1,
|
|
opcode: n,
|
|
mask: r.mask,
|
|
readOnly: o,
|
|
}),
|
|
i,
|
|
)
|
|
}
|
|
dispatch(t, r, i, n) {
|
|
if (!r) {
|
|
this.sendFrame(e.frame(t, i), n)
|
|
return
|
|
}
|
|
let s = this._extensions[ku.extensionName]
|
|
;(this._deflating = !0),
|
|
s.compress(t, i.fin, (o, f) => {
|
|
;(i.readOnly = !1),
|
|
this.sendFrame(e.frame(f, i), n),
|
|
(this._deflating = !1),
|
|
this.dequeue()
|
|
})
|
|
}
|
|
dequeue() {
|
|
for (; !this._deflating && this._queue.length; ) {
|
|
let t = this._queue.shift()
|
|
;(this._bufferedBytes -= t[1].length), t[0].apply(this, t.slice(1))
|
|
}
|
|
}
|
|
enqueue(t) {
|
|
;(this._bufferedBytes += t[1].length), this._queue.push(t)
|
|
}
|
|
sendFrame(t, r) {
|
|
t.length === 2
|
|
? (this._socket.write(t[0]), this._socket.write(t[1], r))
|
|
: this._socket.write(t[0], r)
|
|
}
|
|
}
|
|
Pu.exports = $s
|
|
function Hs(e) {
|
|
let t = ae.from(e.buffer)
|
|
return e.byteLength !== e.buffer.byteLength
|
|
? t.slice(e.byteOffset, e.byteOffset + e.byteLength)
|
|
: t
|
|
}
|
|
})
|
|
var Ks = b((u0, Mu) => {
|
|
'use strict'
|
|
var oy = require('events'),
|
|
Bu = require('crypto'),
|
|
ay = Os(),
|
|
fy = require('https'),
|
|
ly = require('http'),
|
|
uy = require('url'),
|
|
tt = hr(),
|
|
Nu = bu(),
|
|
Au = Ls(),
|
|
_t = gr(),
|
|
cy = Vs(),
|
|
hy = Gs(),
|
|
zs = [8, 13],
|
|
dy = 30 * 1e3,
|
|
we = class e extends oy {
|
|
constructor(t, r, i) {
|
|
super(),
|
|
r
|
|
? typeof r == 'string'
|
|
? (r = [r])
|
|
: Array.isArray(r) || ((i = r), (r = []))
|
|
: (r = []),
|
|
(this.readyState = e.CONNECTING),
|
|
(this.bytesReceived = 0),
|
|
(this.extensions = {}),
|
|
(this.protocol = ''),
|
|
(this._binaryType = _t.BINARY_TYPES[0]),
|
|
(this._finalize = this.finalize.bind(this)),
|
|
(this._closeFrameReceived = !1),
|
|
(this._closeFrameSent = !1),
|
|
(this._closeMessage = ''),
|
|
(this._closeTimer = null),
|
|
(this._finalized = !1),
|
|
(this._closeCode = 1006),
|
|
(this._receiver = null),
|
|
(this._sender = null),
|
|
(this._socket = null),
|
|
(this._ultron = null),
|
|
Array.isArray(t)
|
|
? py.call(this, t[0], t[1], i)
|
|
: _y.call(this, t, r, i)
|
|
}
|
|
get CONNECTING() {
|
|
return e.CONNECTING
|
|
}
|
|
get CLOSING() {
|
|
return e.CLOSING
|
|
}
|
|
get CLOSED() {
|
|
return e.CLOSED
|
|
}
|
|
get OPEN() {
|
|
return e.OPEN
|
|
}
|
|
get bufferedAmount() {
|
|
var t = 0
|
|
return (
|
|
this._socket &&
|
|
(t = this._socket.bufferSize + this._sender._bufferedBytes),
|
|
t
|
|
)
|
|
}
|
|
get binaryType() {
|
|
return this._binaryType
|
|
}
|
|
set binaryType(t) {
|
|
_t.BINARY_TYPES.indexOf(t) < 0 ||
|
|
((this._binaryType = t),
|
|
this._receiver && (this._receiver._binaryType = t))
|
|
}
|
|
setSocket(t, r) {
|
|
t.setTimeout(0),
|
|
t.setNoDelay(),
|
|
(this._receiver = new cy(
|
|
this.extensions,
|
|
this._maxPayload,
|
|
this.binaryType,
|
|
)),
|
|
(this._sender = new hy(t, this.extensions)),
|
|
(this._ultron = new ay(t)),
|
|
(this._socket = t),
|
|
this._ultron.on('close', this._finalize),
|
|
this._ultron.on('error', this._finalize),
|
|
this._ultron.on('end', this._finalize),
|
|
r.length > 0 && t.unshift(r),
|
|
this._ultron.on('data', (i) => {
|
|
;(this.bytesReceived += i.length), this._receiver.add(i)
|
|
}),
|
|
(this._receiver.onmessage = (i) => this.emit('message', i)),
|
|
(this._receiver.onping = (i) => {
|
|
this.pong(i, !this._isServer, !0), this.emit('ping', i)
|
|
}),
|
|
(this._receiver.onpong = (i) => this.emit('pong', i)),
|
|
(this._receiver.onclose = (i, n) => {
|
|
;(this._closeFrameReceived = !0),
|
|
(this._closeMessage = n),
|
|
(this._closeCode = i),
|
|
this._finalized || this.close(i, n)
|
|
}),
|
|
(this._receiver.onerror = (i, n) => {
|
|
;(this._closeMessage = ''),
|
|
(this._closeCode = n),
|
|
(this.readyState = e.CLOSING),
|
|
this.emit('error', i),
|
|
this.finalize(!0)
|
|
}),
|
|
(this.readyState = e.OPEN),
|
|
this.emit('open')
|
|
}
|
|
finalize(t) {
|
|
if (!this._finalized) {
|
|
if (
|
|
((this.readyState = e.CLOSING),
|
|
(this._finalized = !0),
|
|
typeof t == 'object' && this.emit('error', t),
|
|
!this._socket)
|
|
)
|
|
return this.emitClose()
|
|
clearTimeout(this._closeTimer),
|
|
(this._closeTimer = null),
|
|
this._ultron.destroy(),
|
|
(this._ultron = null),
|
|
this._socket.on('error', _t.NOOP),
|
|
t ? this._socket.destroy() : this._socket.end(),
|
|
(this._socket = null),
|
|
(this._sender = null),
|
|
this._receiver.cleanup(() => this.emitClose()),
|
|
(this._receiver = null)
|
|
}
|
|
}
|
|
emitClose() {
|
|
;(this.readyState = e.CLOSED),
|
|
this.emit('close', this._closeCode, this._closeMessage),
|
|
this.extensions[tt.extensionName] &&
|
|
this.extensions[tt.extensionName].cleanup(),
|
|
(this.extensions = null),
|
|
this.removeAllListeners()
|
|
}
|
|
pause() {
|
|
if (this.readyState !== e.OPEN) throw new Error('not opened')
|
|
this._socket.pause()
|
|
}
|
|
resume() {
|
|
if (this.readyState !== e.OPEN) throw new Error('not opened')
|
|
this._socket.resume()
|
|
}
|
|
close(t, r) {
|
|
if (this.readyState !== e.CLOSED) {
|
|
if (this.readyState === e.CONNECTING) {
|
|
this._req.abort(),
|
|
this.finalize(
|
|
new Error('closed before the connection is established'),
|
|
)
|
|
return
|
|
}
|
|
if (this.readyState === e.CLOSING) {
|
|
this._closeFrameSent &&
|
|
this._closeFrameReceived &&
|
|
this._socket.end()
|
|
return
|
|
}
|
|
;(this.readyState = e.CLOSING),
|
|
this._sender.close(t, r, !this._isServer, (i) => {
|
|
i ||
|
|
((this._closeFrameSent = !0),
|
|
this._finalized ||
|
|
(this._closeFrameReceived && this._socket.end(),
|
|
(this._closeTimer = setTimeout(this._finalize, dy, !0))))
|
|
})
|
|
}
|
|
}
|
|
ping(t, r, i) {
|
|
if (this.readyState !== e.OPEN) {
|
|
if (i) return
|
|
throw new Error('not opened')
|
|
}
|
|
typeof t == 'number' && (t = t.toString()),
|
|
r === void 0 && (r = !this._isServer),
|
|
this._sender.ping(t || _t.EMPTY_BUFFER, r)
|
|
}
|
|
pong(t, r, i) {
|
|
if (this.readyState !== e.OPEN) {
|
|
if (i) return
|
|
throw new Error('not opened')
|
|
}
|
|
typeof t == 'number' && (t = t.toString()),
|
|
r === void 0 && (r = !this._isServer),
|
|
this._sender.pong(t || _t.EMPTY_BUFFER, r)
|
|
}
|
|
send(t, r, i) {
|
|
if (
|
|
(typeof r == 'function' && ((i = r), (r = {})),
|
|
this.readyState !== e.OPEN)
|
|
) {
|
|
if (i) i(new Error('not opened'))
|
|
else throw new Error('not opened')
|
|
return
|
|
}
|
|
typeof t == 'number' && (t = t.toString())
|
|
let n = Object.assign(
|
|
{
|
|
binary: typeof t != 'string',
|
|
mask: !this._isServer,
|
|
compress: !0,
|
|
fin: !0,
|
|
},
|
|
r,
|
|
)
|
|
this.extensions[tt.extensionName] || (n.compress = !1),
|
|
this._sender.send(t || _t.EMPTY_BUFFER, n, i)
|
|
}
|
|
terminate() {
|
|
if (this.readyState !== e.CLOSED) {
|
|
if (this.readyState === e.CONNECTING) {
|
|
this._req.abort(),
|
|
this.finalize(
|
|
new Error('closed before the connection is established'),
|
|
)
|
|
return
|
|
}
|
|
this.finalize(!0)
|
|
}
|
|
}
|
|
}
|
|
we.CONNECTING = 0
|
|
we.OPEN = 1
|
|
we.CLOSING = 2
|
|
we.CLOSED = 3
|
|
;['open', 'error', 'close', 'message'].forEach((e) => {
|
|
Object.defineProperty(we.prototype, `on${e}`, {
|
|
get() {
|
|
let t = this.listeners(e)
|
|
for (var r = 0; r < t.length; r++)
|
|
if (t[r]._listener) return t[r]._listener
|
|
},
|
|
set(t) {
|
|
let r = this.listeners(e)
|
|
for (var i = 0; i < r.length; i++)
|
|
r[i]._listener && this.removeListener(e, r[i])
|
|
this.addEventListener(e, t)
|
|
},
|
|
})
|
|
})
|
|
we.prototype.addEventListener = Nu.addEventListener
|
|
we.prototype.removeEventListener = Nu.removeEventListener
|
|
Mu.exports = we
|
|
function py(e, t, r) {
|
|
;(this.protocolVersion = r.protocolVersion),
|
|
(this._maxPayload = r.maxPayload),
|
|
(this.extensions = r.extensions),
|
|
(this.protocol = r.protocol),
|
|
(this._isServer = !0),
|
|
this.setSocket(e, t)
|
|
}
|
|
function _y(e, t, r) {
|
|
if (
|
|
((r = Object.assign(
|
|
{
|
|
protocolVersion: zs[1],
|
|
protocol: t.join(','),
|
|
perMessageDeflate: !0,
|
|
handshakeTimeout: null,
|
|
localAddress: null,
|
|
headers: null,
|
|
family: null,
|
|
origin: null,
|
|
agent: null,
|
|
host: null,
|
|
checkServerIdentity: null,
|
|
rejectUnauthorized: null,
|
|
passphrase: null,
|
|
ciphers: null,
|
|
ecdhCurve: null,
|
|
cert: null,
|
|
key: null,
|
|
pfx: null,
|
|
ca: null,
|
|
},
|
|
r,
|
|
)),
|
|
zs.indexOf(r.protocolVersion) === -1)
|
|
)
|
|
throw new Error(
|
|
`unsupported protocol version: ${
|
|
r.protocolVersion
|
|
} (supported versions: ${zs.join(', ')})`,
|
|
)
|
|
;(this.protocolVersion = r.protocolVersion),
|
|
(this._isServer = !1),
|
|
(this.url = e)
|
|
let i = uy.parse(e),
|
|
n = i.protocol === 'ws+unix:'
|
|
if (!i.host && (!n || !i.path)) throw new Error('invalid url')
|
|
let s = i.protocol === 'wss:' || i.protocol === 'https:',
|
|
o = Bu.randomBytes(16).toString('base64'),
|
|
f = s ? fy : ly
|
|
var a
|
|
let l = {
|
|
port: i.port || (s ? 443 : 80),
|
|
host: i.hostname,
|
|
path: '/',
|
|
headers: {
|
|
'Sec-WebSocket-Version': r.protocolVersion,
|
|
'Sec-WebSocket-Key': o,
|
|
Connection: 'Upgrade',
|
|
Upgrade: 'websocket',
|
|
},
|
|
}
|
|
if (
|
|
(r.headers && Object.assign(l.headers, r.headers),
|
|
r.perMessageDeflate &&
|
|
((a = new tt(
|
|
r.perMessageDeflate !== !0 ? r.perMessageDeflate : {},
|
|
!1,
|
|
)),
|
|
(l.headers['Sec-WebSocket-Extensions'] = Au.format({
|
|
[tt.extensionName]: a.offer(),
|
|
}))),
|
|
r.protocol && (l.headers['Sec-WebSocket-Protocol'] = r.protocol),
|
|
r.origin &&
|
|
(r.protocolVersion < 13
|
|
? (l.headers['Sec-WebSocket-Origin'] = r.origin)
|
|
: (l.headers.Origin = r.origin)),
|
|
r.host && (l.headers.Host = r.host),
|
|
i.auth && (l.auth = i.auth),
|
|
r.localAddress && (l.localAddress = r.localAddress),
|
|
r.family && (l.family = r.family),
|
|
n)
|
|
) {
|
|
let h = i.path.split(':')
|
|
;(l.socketPath = h[0]), (l.path = h[1])
|
|
} else
|
|
i.path &&
|
|
(i.path.charAt(0) !== '/' ? (l.path = `/${i.path}`) : (l.path = i.path))
|
|
var u = r.agent
|
|
;(r.rejectUnauthorized != null ||
|
|
r.checkServerIdentity ||
|
|
r.passphrase ||
|
|
r.ciphers ||
|
|
r.ecdhCurve ||
|
|
r.cert ||
|
|
r.key ||
|
|
r.pfx ||
|
|
r.ca) &&
|
|
(r.passphrase && (l.passphrase = r.passphrase),
|
|
r.ciphers && (l.ciphers = r.ciphers),
|
|
r.ecdhCurve && (l.ecdhCurve = r.ecdhCurve),
|
|
r.cert && (l.cert = r.cert),
|
|
r.key && (l.key = r.key),
|
|
r.pfx && (l.pfx = r.pfx),
|
|
r.ca && (l.ca = r.ca),
|
|
r.checkServerIdentity && (l.checkServerIdentity = r.checkServerIdentity),
|
|
r.rejectUnauthorized != null &&
|
|
(l.rejectUnauthorized = r.rejectUnauthorized),
|
|
u || (u = new f.Agent(l))),
|
|
u && (l.agent = u),
|
|
(this._req = f.get(l)),
|
|
r.handshakeTimeout &&
|
|
this._req.setTimeout(r.handshakeTimeout, () => {
|
|
this._req.abort(),
|
|
this.finalize(new Error('opening handshake has timed out'))
|
|
}),
|
|
this._req.on('error', (h) => {
|
|
this._req.aborted || ((this._req = null), this.finalize(h))
|
|
}),
|
|
this._req.on('response', (h) => {
|
|
this.emit('unexpected-response', this._req, h) ||
|
|
(this._req.abort(),
|
|
this.finalize(
|
|
new Error(`unexpected server response (${h.statusCode})`),
|
|
))
|
|
}),
|
|
this._req.on('upgrade', (h, c, d) => {
|
|
if (
|
|
(this.emit('headers', h.headers, h),
|
|
this.readyState !== we.CONNECTING)
|
|
)
|
|
return
|
|
this._req = null
|
|
let _ = Bu.createHash('sha1')
|
|
.update(o + _t.GUID, 'binary')
|
|
.digest('base64')
|
|
if (h.headers['sec-websocket-accept'] !== _)
|
|
return c.destroy(), this.finalize(new Error('invalid server key'))
|
|
let v = h.headers['sec-websocket-protocol'],
|
|
m = (r.protocol || '').split(/, */)
|
|
var p
|
|
if (
|
|
(!r.protocol && v
|
|
? (p = 'server sent a subprotocol even though none requested')
|
|
: r.protocol && !v
|
|
? (p = 'server sent no subprotocol even though requested')
|
|
: v &&
|
|
m.indexOf(v) === -1 &&
|
|
(p = 'server responded with an invalid protocol'),
|
|
p)
|
|
)
|
|
return c.destroy(), this.finalize(new Error(p))
|
|
if ((v && (this.protocol = v), a))
|
|
try {
|
|
let g = Au.parse(h.headers['sec-websocket-extensions'])
|
|
g[tt.extensionName] &&
|
|
(a.accept(g[tt.extensionName]),
|
|
(this.extensions[tt.extensionName] = a))
|
|
} catch {
|
|
c.destroy(),
|
|
this.finalize(
|
|
new Error('invalid Sec-WebSocket-Extensions header'),
|
|
)
|
|
return
|
|
}
|
|
this.setSocket(c, d)
|
|
})
|
|
}
|
|
})
|
|
var Du = b((c0, qu) => {
|
|
'use strict'
|
|
var gy = ve(),
|
|
by = require('events'),
|
|
yy = require('crypto'),
|
|
vy = Os(),
|
|
Pi = require('http'),
|
|
my = require('url'),
|
|
gt = hr(),
|
|
Lu = Ls(),
|
|
wy = gr(),
|
|
Sy = Ks(),
|
|
Ey = gy.Buffer,
|
|
Ys = class extends by {
|
|
constructor(t, r) {
|
|
if (
|
|
(super(),
|
|
(t = Object.assign(
|
|
{
|
|
maxPayload: 100 * 1024 * 1024,
|
|
perMessageDeflate: !1,
|
|
handleProtocols: null,
|
|
clientTracking: !0,
|
|
verifyClient: null,
|
|
noServer: !1,
|
|
backlog: null,
|
|
server: null,
|
|
host: null,
|
|
path: null,
|
|
port: null,
|
|
},
|
|
t,
|
|
)),
|
|
t.port == null && !t.server && !t.noServer)
|
|
)
|
|
throw new TypeError('missing or invalid options')
|
|
t.port != null
|
|
? ((this._server = Pi.createServer((i, n) => {
|
|
let s = Pi.STATUS_CODES[426]
|
|
n.writeHead(426, {
|
|
'Content-Length': s.length,
|
|
'Content-Type': 'text/plain',
|
|
}),
|
|
n.end(s)
|
|
})),
|
|
this._server.listen(t.port, t.host, t.backlog, r))
|
|
: t.server && (this._server = t.server),
|
|
this._server &&
|
|
((this._ultron = new vy(this._server)),
|
|
this._ultron.on('listening', () => this.emit('listening')),
|
|
this._ultron.on('error', (i) => this.emit('error', i)),
|
|
this._ultron.on('upgrade', (i, n, s) => {
|
|
this.handleUpgrade(i, n, s, (o) => {
|
|
this.emit('connection', o, i)
|
|
})
|
|
})),
|
|
t.perMessageDeflate === !0 && (t.perMessageDeflate = {}),
|
|
t.clientTracking && (this.clients = new Set()),
|
|
(this.options = t)
|
|
}
|
|
close(t) {
|
|
if (this.clients) for (let i of this.clients) i.terminate()
|
|
let r = this._server
|
|
if (
|
|
r &&
|
|
(this._ultron.destroy(),
|
|
(this._ultron = this._server = null),
|
|
this.options.port != null)
|
|
)
|
|
return r.close(t)
|
|
t && t()
|
|
}
|
|
shouldHandle(t) {
|
|
return !(
|
|
this.options.path && my.parse(t.url).pathname !== this.options.path
|
|
)
|
|
}
|
|
handleUpgrade(t, r, i, n) {
|
|
r.on('error', Qs)
|
|
let s = +t.headers['sec-websocket-version'],
|
|
o = {}
|
|
if (
|
|
t.method !== 'GET' ||
|
|
t.headers.upgrade.toLowerCase() !== 'websocket' ||
|
|
!t.headers['sec-websocket-key'] ||
|
|
(s !== 8 && s !== 13) ||
|
|
!this.shouldHandle(t)
|
|
)
|
|
return br(r, 400)
|
|
if (this.options.perMessageDeflate) {
|
|
let a = new gt(
|
|
this.options.perMessageDeflate,
|
|
!0,
|
|
this.options.maxPayload,
|
|
)
|
|
try {
|
|
let l = Lu.parse(t.headers['sec-websocket-extensions'])
|
|
l[gt.extensionName] &&
|
|
(a.accept(l[gt.extensionName]), (o[gt.extensionName] = a))
|
|
} catch {
|
|
return br(r, 400)
|
|
}
|
|
}
|
|
var f = (t.headers['sec-websocket-protocol'] || '').split(/, */)
|
|
if (this.options.handleProtocols) {
|
|
if (((f = this.options.handleProtocols(f, t)), f === !1))
|
|
return br(r, 401)
|
|
} else f = f[0]
|
|
if (this.options.verifyClient) {
|
|
let a = {
|
|
origin: t.headers[`${s === 8 ? 'sec-websocket-origin' : 'origin'}`],
|
|
secure: !!(t.connection.authorized || t.connection.encrypted),
|
|
req: t,
|
|
}
|
|
if (this.options.verifyClient.length === 2) {
|
|
this.options.verifyClient(a, (l, u, h) => {
|
|
if (!l) return br(r, u || 401, h)
|
|
this.completeUpgrade(f, o, s, t, r, i, n)
|
|
})
|
|
return
|
|
}
|
|
if (!this.options.verifyClient(a)) return br(r, 401)
|
|
}
|
|
this.completeUpgrade(f, o, s, t, r, i, n)
|
|
}
|
|
completeUpgrade(t, r, i, n, s, o, f) {
|
|
if (!s.readable || !s.writable) return s.destroy()
|
|
let l = [
|
|
'HTTP/1.1 101 Switching Protocols',
|
|
'Upgrade: websocket',
|
|
'Connection: Upgrade',
|
|
`Sec-WebSocket-Accept: ${yy
|
|
.createHash('sha1')
|
|
.update(n.headers['sec-websocket-key'] + wy.GUID, 'binary')
|
|
.digest('base64')}`,
|
|
]
|
|
if (
|
|
(t && l.push(`Sec-WebSocket-Protocol: ${t}`), r[gt.extensionName])
|
|
) {
|
|
let h = r[gt.extensionName].params,
|
|
c = Lu.format({ [gt.extensionName]: [h] })
|
|
l.push(`Sec-WebSocket-Extensions: ${c}`)
|
|
}
|
|
this.emit('headers', l, n),
|
|
s.write(
|
|
l.concat(`\r
|
|
`).join(`\r
|
|
`),
|
|
)
|
|
let u = new Sy([s, o], null, {
|
|
maxPayload: this.options.maxPayload,
|
|
protocolVersion: i,
|
|
extensions: r,
|
|
protocol: t,
|
|
})
|
|
this.clients &&
|
|
(this.clients.add(u), u.on('close', () => this.clients.delete(u))),
|
|
s.removeListener('error', Qs),
|
|
f(u)
|
|
}
|
|
}
|
|
qu.exports = Ys
|
|
function Qs() {
|
|
this.destroy()
|
|
}
|
|
function br(e, t, r) {
|
|
e.writable &&
|
|
((r = r || Pi.STATUS_CODES[t]),
|
|
e.write(
|
|
`HTTP/1.1 ${t} ${Pi.STATUS_CODES[t]}\r
|
|
Connection: close\r
|
|
Content-type: text/html\r
|
|
Content-Length: ${Ey.byteLength(r)}\r
|
|
\r
|
|
` + r,
|
|
)),
|
|
e.removeListener('error', Qs),
|
|
e.destroy()
|
|
}
|
|
})
|
|
var Js = b((h0, Uu) => {
|
|
'use strict'
|
|
var Bi = Ks()
|
|
Bi.Server = Du()
|
|
Bi.Receiver = Vs()
|
|
Bi.Sender = Gs()
|
|
Uu.exports = Bi
|
|
})
|
|
var Fu = b((d0, ju) => {
|
|
var xy = {}.toString
|
|
ju.exports =
|
|
Array.isArray ||
|
|
function (e) {
|
|
return xy.call(e) == '[object Array]'
|
|
}
|
|
})
|
|
var Xs = b((p0, Wu) => {
|
|
Wu.exports = require('stream')
|
|
})
|
|
var At = b((re) => {
|
|
function Cy(e) {
|
|
return Array.isArray ? Array.isArray(e) : Ai(e) === '[object Array]'
|
|
}
|
|
re.isArray = Cy
|
|
function Ty(e) {
|
|
return typeof e == 'boolean'
|
|
}
|
|
re.isBoolean = Ty
|
|
function Iy(e) {
|
|
return e === null
|
|
}
|
|
re.isNull = Iy
|
|
function Oy(e) {
|
|
return e == null
|
|
}
|
|
re.isNullOrUndefined = Oy
|
|
function ky(e) {
|
|
return typeof e == 'number'
|
|
}
|
|
re.isNumber = ky
|
|
function Ry(e) {
|
|
return typeof e == 'string'
|
|
}
|
|
re.isString = Ry
|
|
function Py(e) {
|
|
return typeof e == 'symbol'
|
|
}
|
|
re.isSymbol = Py
|
|
function By(e) {
|
|
return e === void 0
|
|
}
|
|
re.isUndefined = By
|
|
function Ay(e) {
|
|
return Ai(e) === '[object RegExp]'
|
|
}
|
|
re.isRegExp = Ay
|
|
function Ny(e) {
|
|
return typeof e == 'object' && e !== null
|
|
}
|
|
re.isObject = Ny
|
|
function My(e) {
|
|
return Ai(e) === '[object Date]'
|
|
}
|
|
re.isDate = My
|
|
function Ly(e) {
|
|
return Ai(e) === '[object Error]' || e instanceof Error
|
|
}
|
|
re.isError = Ly
|
|
function qy(e) {
|
|
return typeof e == 'function'
|
|
}
|
|
re.isFunction = qy
|
|
function Dy(e) {
|
|
return (
|
|
e === null ||
|
|
typeof e == 'boolean' ||
|
|
typeof e == 'number' ||
|
|
typeof e == 'string' ||
|
|
typeof e == 'symbol' ||
|
|
typeof e > 'u'
|
|
)
|
|
}
|
|
re.isPrimitive = Dy
|
|
re.isBuffer = Buffer.isBuffer
|
|
function Ai(e) {
|
|
return Object.prototype.toString.call(e)
|
|
}
|
|
})
|
|
var Hu = b((g0, Zs) => {
|
|
'use strict'
|
|
function Uy(e, t) {
|
|
if (!(e instanceof t))
|
|
throw new TypeError('Cannot call a class as a function')
|
|
}
|
|
var Vu = ve().Buffer,
|
|
yr = require('util')
|
|
function jy(e, t, r) {
|
|
e.copy(t, r)
|
|
}
|
|
Zs.exports = (function () {
|
|
function e() {
|
|
Uy(this, e), (this.head = null), (this.tail = null), (this.length = 0)
|
|
}
|
|
return (
|
|
(e.prototype.push = function (r) {
|
|
var i = { data: r, next: null }
|
|
this.length > 0 ? (this.tail.next = i) : (this.head = i),
|
|
(this.tail = i),
|
|
++this.length
|
|
}),
|
|
(e.prototype.unshift = function (r) {
|
|
var i = { data: r, next: this.head }
|
|
this.length === 0 && (this.tail = i), (this.head = i), ++this.length
|
|
}),
|
|
(e.prototype.shift = function () {
|
|
if (this.length !== 0) {
|
|
var r = this.head.data
|
|
return (
|
|
this.length === 1
|
|
? (this.head = this.tail = null)
|
|
: (this.head = this.head.next),
|
|
--this.length,
|
|
r
|
|
)
|
|
}
|
|
}),
|
|
(e.prototype.clear = function () {
|
|
;(this.head = this.tail = null), (this.length = 0)
|
|
}),
|
|
(e.prototype.join = function (r) {
|
|
if (this.length === 0) return ''
|
|
for (var i = this.head, n = '' + i.data; (i = i.next); ) n += r + i.data
|
|
return n
|
|
}),
|
|
(e.prototype.concat = function (r) {
|
|
if (this.length === 0) return Vu.alloc(0)
|
|
for (var i = Vu.allocUnsafe(r >>> 0), n = this.head, s = 0; n; )
|
|
jy(n.data, i, s), (s += n.data.length), (n = n.next)
|
|
return i
|
|
}),
|
|
e
|
|
)
|
|
})()
|
|
yr &&
|
|
yr.inspect &&
|
|
yr.inspect.custom &&
|
|
(Zs.exports.prototype[yr.inspect.custom] = function () {
|
|
var e = yr.inspect({ length: this.length })
|
|
return this.constructor.name + ' ' + e
|
|
})
|
|
})
|
|
var eo = b((b0, $u) => {
|
|
'use strict'
|
|
var Ni = Ot()
|
|
function Fy(e, t) {
|
|
var r = this,
|
|
i = this._readableState && this._readableState.destroyed,
|
|
n = this._writableState && this._writableState.destroyed
|
|
return i || n
|
|
? (t
|
|
? t(e)
|
|
: e &&
|
|
(this._writableState
|
|
? this._writableState.errorEmitted ||
|
|
((this._writableState.errorEmitted = !0),
|
|
Ni.nextTick(Mi, this, e))
|
|
: Ni.nextTick(Mi, this, e)),
|
|
this)
|
|
: (this._readableState && (this._readableState.destroyed = !0),
|
|
this._writableState && (this._writableState.destroyed = !0),
|
|
this._destroy(e || null, function (s) {
|
|
!t && s
|
|
? r._writableState
|
|
? r._writableState.errorEmitted ||
|
|
((r._writableState.errorEmitted = !0), Ni.nextTick(Mi, r, s))
|
|
: Ni.nextTick(Mi, r, s)
|
|
: t && t(s)
|
|
}),
|
|
this)
|
|
}
|
|
function Wy() {
|
|
this._readableState &&
|
|
((this._readableState.destroyed = !1),
|
|
(this._readableState.reading = !1),
|
|
(this._readableState.ended = !1),
|
|
(this._readableState.endEmitted = !1)),
|
|
this._writableState &&
|
|
((this._writableState.destroyed = !1),
|
|
(this._writableState.ended = !1),
|
|
(this._writableState.ending = !1),
|
|
(this._writableState.finalCalled = !1),
|
|
(this._writableState.prefinished = !1),
|
|
(this._writableState.finished = !1),
|
|
(this._writableState.errorEmitted = !1))
|
|
}
|
|
function Mi(e, t) {
|
|
e.emit('error', t)
|
|
}
|
|
$u.exports = { destroy: Fy, undestroy: Wy }
|
|
})
|
|
var ro = b((y0, Zu) => {
|
|
'use strict'
|
|
var bt = Ot()
|
|
Zu.exports = z
|
|
function zu(e) {
|
|
var t = this
|
|
;(this.next = null),
|
|
(this.entry = null),
|
|
(this.finish = function () {
|
|
ov(t, e)
|
|
})
|
|
}
|
|
var Vy =
|
|
!process.browser &&
|
|
['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1
|
|
? setImmediate
|
|
: bt.nextTick,
|
|
Nt
|
|
z.WritableState = mr
|
|
var Ku = Object.create(At())
|
|
Ku.inherits = ie()
|
|
var Hy = { deprecate: fn() },
|
|
Yu = Xs(),
|
|
qi = ve().Buffer,
|
|
$y =
|
|
(typeof global < 'u'
|
|
? global
|
|
: typeof window < 'u'
|
|
? window
|
|
: typeof self < 'u'
|
|
? self
|
|
: {}
|
|
).Uint8Array || function () {}
|
|
function Gy(e) {
|
|
return qi.from(e)
|
|
}
|
|
function zy(e) {
|
|
return qi.isBuffer(e) || e instanceof $y
|
|
}
|
|
var Qu = eo()
|
|
Ku.inherits(z, Yu)
|
|
function Ky() {}
|
|
function mr(e, t) {
|
|
;(Nt = Nt || yt()), (e = e || {})
|
|
var r = t instanceof Nt
|
|
;(this.objectMode = !!e.objectMode),
|
|
r && (this.objectMode = this.objectMode || !!e.writableObjectMode)
|
|
var i = e.highWaterMark,
|
|
n = e.writableHighWaterMark,
|
|
s = this.objectMode ? 16 : 16 * 1024
|
|
i || i === 0
|
|
? (this.highWaterMark = i)
|
|
: r && (n || n === 0)
|
|
? (this.highWaterMark = n)
|
|
: (this.highWaterMark = s),
|
|
(this.highWaterMark = Math.floor(this.highWaterMark)),
|
|
(this.finalCalled = !1),
|
|
(this.needDrain = !1),
|
|
(this.ending = !1),
|
|
(this.ended = !1),
|
|
(this.finished = !1),
|
|
(this.destroyed = !1)
|
|
var o = e.decodeStrings === !1
|
|
;(this.decodeStrings = !o),
|
|
(this.defaultEncoding = e.defaultEncoding || 'utf8'),
|
|
(this.length = 0),
|
|
(this.writing = !1),
|
|
(this.corked = 0),
|
|
(this.sync = !0),
|
|
(this.bufferProcessing = !1),
|
|
(this.onwrite = function (f) {
|
|
tv(t, f)
|
|
}),
|
|
(this.writecb = null),
|
|
(this.writelen = 0),
|
|
(this.bufferedRequest = null),
|
|
(this.lastBufferedRequest = null),
|
|
(this.pendingcb = 0),
|
|
(this.prefinished = !1),
|
|
(this.errorEmitted = !1),
|
|
(this.bufferedRequestCount = 0),
|
|
(this.corkedRequestsFree = new zu(this))
|
|
}
|
|
mr.prototype.getBuffer = function () {
|
|
for (var t = this.bufferedRequest, r = []; t; ) r.push(t), (t = t.next)
|
|
return r
|
|
}
|
|
;(function () {
|
|
try {
|
|
Object.defineProperty(mr.prototype, 'buffer', {
|
|
get: Hy.deprecate(
|
|
function () {
|
|
return this.getBuffer()
|
|
},
|
|
'_writableState.buffer is deprecated. Use _writableState.getBuffer instead.',
|
|
'DEP0003',
|
|
),
|
|
})
|
|
} catch {}
|
|
})()
|
|
var Li
|
|
typeof Symbol == 'function' &&
|
|
Symbol.hasInstance &&
|
|
typeof Function.prototype[Symbol.hasInstance] == 'function'
|
|
? ((Li = Function.prototype[Symbol.hasInstance]),
|
|
Object.defineProperty(z, Symbol.hasInstance, {
|
|
value: function (e) {
|
|
return Li.call(this, e)
|
|
? !0
|
|
: this !== z
|
|
? !1
|
|
: e && e._writableState instanceof mr
|
|
},
|
|
}))
|
|
: (Li = function (e) {
|
|
return e instanceof this
|
|
})
|
|
function z(e) {
|
|
if (((Nt = Nt || yt()), !Li.call(z, this) && !(this instanceof Nt)))
|
|
return new z(e)
|
|
;(this._writableState = new mr(e, this)),
|
|
(this.writable = !0),
|
|
e &&
|
|
(typeof e.write == 'function' && (this._write = e.write),
|
|
typeof e.writev == 'function' && (this._writev = e.writev),
|
|
typeof e.destroy == 'function' && (this._destroy = e.destroy),
|
|
typeof e.final == 'function' && (this._final = e.final)),
|
|
Yu.call(this)
|
|
}
|
|
z.prototype.pipe = function () {
|
|
this.emit('error', new Error('Cannot pipe, not readable'))
|
|
}
|
|
function Yy(e, t) {
|
|
var r = new Error('write after end')
|
|
e.emit('error', r), bt.nextTick(t, r)
|
|
}
|
|
function Qy(e, t, r, i) {
|
|
var n = !0,
|
|
s = !1
|
|
return (
|
|
r === null
|
|
? (s = new TypeError('May not write null values to stream'))
|
|
: typeof r != 'string' &&
|
|
r !== void 0 &&
|
|
!t.objectMode &&
|
|
(s = new TypeError('Invalid non-string/buffer chunk')),
|
|
s && (e.emit('error', s), bt.nextTick(i, s), (n = !1)),
|
|
n
|
|
)
|
|
}
|
|
z.prototype.write = function (e, t, r) {
|
|
var i = this._writableState,
|
|
n = !1,
|
|
s = !i.objectMode && zy(e)
|
|
return (
|
|
s && !qi.isBuffer(e) && (e = Gy(e)),
|
|
typeof t == 'function' && ((r = t), (t = null)),
|
|
s ? (t = 'buffer') : t || (t = i.defaultEncoding),
|
|
typeof r != 'function' && (r = Ky),
|
|
i.ended
|
|
? Yy(this, r)
|
|
: (s || Qy(this, i, e, r)) &&
|
|
(i.pendingcb++, (n = Xy(this, i, s, e, t, r))),
|
|
n
|
|
)
|
|
}
|
|
z.prototype.cork = function () {
|
|
var e = this._writableState
|
|
e.corked++
|
|
}
|
|
z.prototype.uncork = function () {
|
|
var e = this._writableState
|
|
e.corked &&
|
|
(e.corked--,
|
|
!e.writing &&
|
|
!e.corked &&
|
|
!e.bufferProcessing &&
|
|
e.bufferedRequest &&
|
|
Ju(this, e))
|
|
}
|
|
z.prototype.setDefaultEncoding = function (t) {
|
|
if (
|
|
(typeof t == 'string' && (t = t.toLowerCase()),
|
|
!(
|
|
[
|
|
'hex',
|
|
'utf8',
|
|
'utf-8',
|
|
'ascii',
|
|
'binary',
|
|
'base64',
|
|
'ucs2',
|
|
'ucs-2',
|
|
'utf16le',
|
|
'utf-16le',
|
|
'raw',
|
|
].indexOf((t + '').toLowerCase()) > -1
|
|
))
|
|
)
|
|
throw new TypeError('Unknown encoding: ' + t)
|
|
return (this._writableState.defaultEncoding = t), this
|
|
}
|
|
function Jy(e, t, r) {
|
|
return (
|
|
!e.objectMode &&
|
|
e.decodeStrings !== !1 &&
|
|
typeof t == 'string' &&
|
|
(t = qi.from(t, r)),
|
|
t
|
|
)
|
|
}
|
|
Object.defineProperty(z.prototype, 'writableHighWaterMark', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState.highWaterMark
|
|
},
|
|
})
|
|
function Xy(e, t, r, i, n, s) {
|
|
if (!r) {
|
|
var o = Jy(t, i, n)
|
|
i !== o && ((r = !0), (n = 'buffer'), (i = o))
|
|
}
|
|
var f = t.objectMode ? 1 : i.length
|
|
t.length += f
|
|
var a = t.length < t.highWaterMark
|
|
if ((a || (t.needDrain = !0), t.writing || t.corked)) {
|
|
var l = t.lastBufferedRequest
|
|
;(t.lastBufferedRequest = {
|
|
chunk: i,
|
|
encoding: n,
|
|
isBuf: r,
|
|
callback: s,
|
|
next: null,
|
|
}),
|
|
l
|
|
? (l.next = t.lastBufferedRequest)
|
|
: (t.bufferedRequest = t.lastBufferedRequest),
|
|
(t.bufferedRequestCount += 1)
|
|
} else to(e, t, !1, f, i, n, s)
|
|
return a
|
|
}
|
|
function to(e, t, r, i, n, s, o) {
|
|
;(t.writelen = i),
|
|
(t.writecb = o),
|
|
(t.writing = !0),
|
|
(t.sync = !0),
|
|
r ? e._writev(n, t.onwrite) : e._write(n, s, t.onwrite),
|
|
(t.sync = !1)
|
|
}
|
|
function Zy(e, t, r, i, n) {
|
|
--t.pendingcb,
|
|
r
|
|
? (bt.nextTick(n, i),
|
|
bt.nextTick(vr, e, t),
|
|
(e._writableState.errorEmitted = !0),
|
|
e.emit('error', i))
|
|
: (n(i),
|
|
(e._writableState.errorEmitted = !0),
|
|
e.emit('error', i),
|
|
vr(e, t))
|
|
}
|
|
function ev(e) {
|
|
;(e.writing = !1),
|
|
(e.writecb = null),
|
|
(e.length -= e.writelen),
|
|
(e.writelen = 0)
|
|
}
|
|
function tv(e, t) {
|
|
var r = e._writableState,
|
|
i = r.sync,
|
|
n = r.writecb
|
|
if ((ev(r), t)) Zy(e, r, i, t, n)
|
|
else {
|
|
var s = Xu(r)
|
|
!s && !r.corked && !r.bufferProcessing && r.bufferedRequest && Ju(e, r),
|
|
i ? Vy(Gu, e, r, s, n) : Gu(e, r, s, n)
|
|
}
|
|
}
|
|
function Gu(e, t, r, i) {
|
|
r || rv(e, t), t.pendingcb--, i(), vr(e, t)
|
|
}
|
|
function rv(e, t) {
|
|
t.length === 0 && t.needDrain && ((t.needDrain = !1), e.emit('drain'))
|
|
}
|
|
function Ju(e, t) {
|
|
t.bufferProcessing = !0
|
|
var r = t.bufferedRequest
|
|
if (e._writev && r && r.next) {
|
|
var i = t.bufferedRequestCount,
|
|
n = new Array(i),
|
|
s = t.corkedRequestsFree
|
|
s.entry = r
|
|
for (var o = 0, f = !0; r; )
|
|
(n[o] = r), r.isBuf || (f = !1), (r = r.next), (o += 1)
|
|
;(n.allBuffers = f),
|
|
to(e, t, !0, t.length, n, '', s.finish),
|
|
t.pendingcb++,
|
|
(t.lastBufferedRequest = null),
|
|
s.next
|
|
? ((t.corkedRequestsFree = s.next), (s.next = null))
|
|
: (t.corkedRequestsFree = new zu(t)),
|
|
(t.bufferedRequestCount = 0)
|
|
} else {
|
|
for (; r; ) {
|
|
var a = r.chunk,
|
|
l = r.encoding,
|
|
u = r.callback,
|
|
h = t.objectMode ? 1 : a.length
|
|
if (
|
|
(to(e, t, !1, h, a, l, u),
|
|
(r = r.next),
|
|
t.bufferedRequestCount--,
|
|
t.writing)
|
|
)
|
|
break
|
|
}
|
|
r === null && (t.lastBufferedRequest = null)
|
|
}
|
|
;(t.bufferedRequest = r), (t.bufferProcessing = !1)
|
|
}
|
|
z.prototype._write = function (e, t, r) {
|
|
r(new Error('_write() is not implemented'))
|
|
}
|
|
z.prototype._writev = null
|
|
z.prototype.end = function (e, t, r) {
|
|
var i = this._writableState
|
|
typeof e == 'function'
|
|
? ((r = e), (e = null), (t = null))
|
|
: typeof t == 'function' && ((r = t), (t = null)),
|
|
e != null && this.write(e, t),
|
|
i.corked && ((i.corked = 1), this.uncork()),
|
|
i.ending || sv(this, i, r)
|
|
}
|
|
function Xu(e) {
|
|
return (
|
|
e.ending &&
|
|
e.length === 0 &&
|
|
e.bufferedRequest === null &&
|
|
!e.finished &&
|
|
!e.writing
|
|
)
|
|
}
|
|
function iv(e, t) {
|
|
e._final(function (r) {
|
|
t.pendingcb--,
|
|
r && e.emit('error', r),
|
|
(t.prefinished = !0),
|
|
e.emit('prefinish'),
|
|
vr(e, t)
|
|
})
|
|
}
|
|
function nv(e, t) {
|
|
!t.prefinished &&
|
|
!t.finalCalled &&
|
|
(typeof e._final == 'function'
|
|
? (t.pendingcb++, (t.finalCalled = !0), bt.nextTick(iv, e, t))
|
|
: ((t.prefinished = !0), e.emit('prefinish')))
|
|
}
|
|
function vr(e, t) {
|
|
var r = Xu(t)
|
|
return (
|
|
r &&
|
|
(nv(e, t), t.pendingcb === 0 && ((t.finished = !0), e.emit('finish'))),
|
|
r
|
|
)
|
|
}
|
|
function sv(e, t, r) {
|
|
;(t.ending = !0),
|
|
vr(e, t),
|
|
r && (t.finished ? bt.nextTick(r) : e.once('finish', r)),
|
|
(t.ended = !0),
|
|
(e.writable = !1)
|
|
}
|
|
function ov(e, t, r) {
|
|
var i = e.entry
|
|
for (e.entry = null; i; ) {
|
|
var n = i.callback
|
|
t.pendingcb--, n(r), (i = i.next)
|
|
}
|
|
t.corkedRequestsFree.next = e
|
|
}
|
|
Object.defineProperty(z.prototype, 'destroyed', {
|
|
get: function () {
|
|
return this._writableState === void 0 ? !1 : this._writableState.destroyed
|
|
},
|
|
set: function (e) {
|
|
this._writableState && (this._writableState.destroyed = e)
|
|
},
|
|
})
|
|
z.prototype.destroy = Qu.destroy
|
|
z.prototype._undestroy = Qu.undestroy
|
|
z.prototype._destroy = function (e, t) {
|
|
this.end(), t(e)
|
|
}
|
|
})
|
|
var yt = b((v0, ic) => {
|
|
'use strict'
|
|
var ec = Ot(),
|
|
av =
|
|
Object.keys ||
|
|
function (e) {
|
|
var t = []
|
|
for (var r in e) t.push(r)
|
|
return t
|
|
}
|
|
ic.exports = qe
|
|
var tc = Object.create(At())
|
|
tc.inherits = ie()
|
|
var rc = so(),
|
|
no = ro()
|
|
tc.inherits(qe, rc)
|
|
for (io = av(no.prototype), Di = 0; Di < io.length; Di++)
|
|
(Ui = io[Di]), qe.prototype[Ui] || (qe.prototype[Ui] = no.prototype[Ui])
|
|
var io, Ui, Di
|
|
function qe(e) {
|
|
if (!(this instanceof qe)) return new qe(e)
|
|
rc.call(this, e),
|
|
no.call(this, e),
|
|
e && e.readable === !1 && (this.readable = !1),
|
|
e && e.writable === !1 && (this.writable = !1),
|
|
(this.allowHalfOpen = !0),
|
|
e && e.allowHalfOpen === !1 && (this.allowHalfOpen = !1),
|
|
this.once('end', fv)
|
|
}
|
|
Object.defineProperty(qe.prototype, 'writableHighWaterMark', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._writableState.highWaterMark
|
|
},
|
|
})
|
|
function fv() {
|
|
this.allowHalfOpen || this._writableState.ended || ec.nextTick(lv, this)
|
|
}
|
|
function lv(e) {
|
|
e.end()
|
|
}
|
|
Object.defineProperty(qe.prototype, 'destroyed', {
|
|
get: function () {
|
|
return this._readableState === void 0 || this._writableState === void 0
|
|
? !1
|
|
: this._readableState.destroyed && this._writableState.destroyed
|
|
},
|
|
set: function (e) {
|
|
this._readableState === void 0 ||
|
|
this._writableState === void 0 ||
|
|
((this._readableState.destroyed = e),
|
|
(this._writableState.destroyed = e))
|
|
},
|
|
})
|
|
qe.prototype._destroy = function (e, t) {
|
|
this.push(null), this.end(), ec.nextTick(t, e)
|
|
}
|
|
})
|
|
var fo = b((sc) => {
|
|
'use strict'
|
|
var ao = ve().Buffer,
|
|
nc =
|
|
ao.isEncoding ||
|
|
function (e) {
|
|
switch (((e = '' + e), e && e.toLowerCase())) {
|
|
case 'hex':
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
case 'ascii':
|
|
case 'binary':
|
|
case 'base64':
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
case 'raw':
|
|
return !0
|
|
default:
|
|
return !1
|
|
}
|
|
}
|
|
function uv(e) {
|
|
if (!e) return 'utf8'
|
|
for (var t; ; )
|
|
switch (e) {
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return 'utf8'
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return 'utf16le'
|
|
case 'latin1':
|
|
case 'binary':
|
|
return 'latin1'
|
|
case 'base64':
|
|
case 'ascii':
|
|
case 'hex':
|
|
return e
|
|
default:
|
|
if (t) return
|
|
;(e = ('' + e).toLowerCase()), (t = !0)
|
|
}
|
|
}
|
|
function cv(e) {
|
|
var t = uv(e)
|
|
if (typeof t != 'string' && (ao.isEncoding === nc || !nc(e)))
|
|
throw new Error('Unknown encoding: ' + e)
|
|
return t || e
|
|
}
|
|
sc.StringDecoder = wr
|
|
function wr(e) {
|
|
this.encoding = cv(e)
|
|
var t
|
|
switch (this.encoding) {
|
|
case 'utf16le':
|
|
;(this.text = bv), (this.end = yv), (t = 4)
|
|
break
|
|
case 'utf8':
|
|
;(this.fillLast = pv), (t = 4)
|
|
break
|
|
case 'base64':
|
|
;(this.text = vv), (this.end = mv), (t = 3)
|
|
break
|
|
default:
|
|
;(this.write = wv), (this.end = Sv)
|
|
return
|
|
}
|
|
;(this.lastNeed = 0),
|
|
(this.lastTotal = 0),
|
|
(this.lastChar = ao.allocUnsafe(t))
|
|
}
|
|
wr.prototype.write = function (e) {
|
|
if (e.length === 0) return ''
|
|
var t, r
|
|
if (this.lastNeed) {
|
|
if (((t = this.fillLast(e)), t === void 0)) return ''
|
|
;(r = this.lastNeed), (this.lastNeed = 0)
|
|
} else r = 0
|
|
return r < e.length ? (t ? t + this.text(e, r) : this.text(e, r)) : t || ''
|
|
}
|
|
wr.prototype.end = gv
|
|
wr.prototype.text = _v
|
|
wr.prototype.fillLast = function (e) {
|
|
if (this.lastNeed <= e.length)
|
|
return (
|
|
e.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed),
|
|
this.lastChar.toString(this.encoding, 0, this.lastTotal)
|
|
)
|
|
e.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, e.length),
|
|
(this.lastNeed -= e.length)
|
|
}
|
|
function oo(e) {
|
|
return e <= 127
|
|
? 0
|
|
: e >> 5 === 6
|
|
? 2
|
|
: e >> 4 === 14
|
|
? 3
|
|
: e >> 3 === 30
|
|
? 4
|
|
: e >> 6 === 2
|
|
? -1
|
|
: -2
|
|
}
|
|
function hv(e, t, r) {
|
|
var i = t.length - 1
|
|
if (i < r) return 0
|
|
var n = oo(t[i])
|
|
return n >= 0
|
|
? (n > 0 && (e.lastNeed = n - 1), n)
|
|
: --i < r || n === -2
|
|
? 0
|
|
: ((n = oo(t[i])),
|
|
n >= 0
|
|
? (n > 0 && (e.lastNeed = n - 2), n)
|
|
: --i < r || n === -2
|
|
? 0
|
|
: ((n = oo(t[i])),
|
|
n >= 0
|
|
? (n > 0 && (n === 2 ? (n = 0) : (e.lastNeed = n - 3)), n)
|
|
: 0))
|
|
}
|
|
function dv(e, t, r) {
|
|
if ((t[0] & 192) !== 128) return (e.lastNeed = 0), '\uFFFD'
|
|
if (e.lastNeed > 1 && t.length > 1) {
|
|
if ((t[1] & 192) !== 128) return (e.lastNeed = 1), '\uFFFD'
|
|
if (e.lastNeed > 2 && t.length > 2 && (t[2] & 192) !== 128)
|
|
return (e.lastNeed = 2), '\uFFFD'
|
|
}
|
|
}
|
|
function pv(e) {
|
|
var t = this.lastTotal - this.lastNeed,
|
|
r = dv(this, e, t)
|
|
if (r !== void 0) return r
|
|
if (this.lastNeed <= e.length)
|
|
return (
|
|
e.copy(this.lastChar, t, 0, this.lastNeed),
|
|
this.lastChar.toString(this.encoding, 0, this.lastTotal)
|
|
)
|
|
e.copy(this.lastChar, t, 0, e.length), (this.lastNeed -= e.length)
|
|
}
|
|
function _v(e, t) {
|
|
var r = hv(this, e, t)
|
|
if (!this.lastNeed) return e.toString('utf8', t)
|
|
this.lastTotal = r
|
|
var i = e.length - (r - this.lastNeed)
|
|
return e.copy(this.lastChar, 0, i), e.toString('utf8', t, i)
|
|
}
|
|
function gv(e) {
|
|
var t = e && e.length ? this.write(e) : ''
|
|
return this.lastNeed ? t + '\uFFFD' : t
|
|
}
|
|
function bv(e, t) {
|
|
if ((e.length - t) % 2 === 0) {
|
|
var r = e.toString('utf16le', t)
|
|
if (r) {
|
|
var i = r.charCodeAt(r.length - 1)
|
|
if (i >= 55296 && i <= 56319)
|
|
return (
|
|
(this.lastNeed = 2),
|
|
(this.lastTotal = 4),
|
|
(this.lastChar[0] = e[e.length - 2]),
|
|
(this.lastChar[1] = e[e.length - 1]),
|
|
r.slice(0, -1)
|
|
)
|
|
}
|
|
return r
|
|
}
|
|
return (
|
|
(this.lastNeed = 1),
|
|
(this.lastTotal = 2),
|
|
(this.lastChar[0] = e[e.length - 1]),
|
|
e.toString('utf16le', t, e.length - 1)
|
|
)
|
|
}
|
|
function yv(e) {
|
|
var t = e && e.length ? this.write(e) : ''
|
|
if (this.lastNeed) {
|
|
var r = this.lastTotal - this.lastNeed
|
|
return t + this.lastChar.toString('utf16le', 0, r)
|
|
}
|
|
return t
|
|
}
|
|
function vv(e, t) {
|
|
var r = (e.length - t) % 3
|
|
return r === 0
|
|
? e.toString('base64', t)
|
|
: ((this.lastNeed = 3 - r),
|
|
(this.lastTotal = 3),
|
|
r === 1
|
|
? (this.lastChar[0] = e[e.length - 1])
|
|
: ((this.lastChar[0] = e[e.length - 2]),
|
|
(this.lastChar[1] = e[e.length - 1])),
|
|
e.toString('base64', t, e.length - r))
|
|
}
|
|
function mv(e) {
|
|
var t = e && e.length ? this.write(e) : ''
|
|
return this.lastNeed
|
|
? t + this.lastChar.toString('base64', 0, 3 - this.lastNeed)
|
|
: t
|
|
}
|
|
function wv(e) {
|
|
return e.toString(this.encoding)
|
|
}
|
|
function Sv(e) {
|
|
return e && e.length ? this.write(e) : ''
|
|
}
|
|
})
|
|
var so = b((S0, bc) => {
|
|
'use strict'
|
|
var Lt = Ot()
|
|
bc.exports = V
|
|
var Ev = Fu(),
|
|
Sr
|
|
V.ReadableState = hc
|
|
var w0 = require('events').EventEmitter,
|
|
lc = function (e, t) {
|
|
return e.listeners(t).length
|
|
},
|
|
po = Xs(),
|
|
Er = ve().Buffer,
|
|
xv =
|
|
(typeof global < 'u'
|
|
? global
|
|
: typeof window < 'u'
|
|
? window
|
|
: typeof self < 'u'
|
|
? self
|
|
: {}
|
|
).Uint8Array || function () {}
|
|
function Cv(e) {
|
|
return Er.from(e)
|
|
}
|
|
function Tv(e) {
|
|
return Er.isBuffer(e) || e instanceof xv
|
|
}
|
|
var uc = Object.create(At())
|
|
uc.inherits = ie()
|
|
var lo = require('util'),
|
|
L = void 0
|
|
lo && lo.debuglog ? (L = lo.debuglog('stream')) : (L = function () {})
|
|
var Iv = Hu(),
|
|
cc = eo(),
|
|
Mt
|
|
uc.inherits(V, po)
|
|
var uo = ['error', 'close', 'destroy', 'pause', 'resume']
|
|
function Ov(e, t, r) {
|
|
if (typeof e.prependListener == 'function') return e.prependListener(t, r)
|
|
!e._events || !e._events[t]
|
|
? e.on(t, r)
|
|
: Ev(e._events[t])
|
|
? e._events[t].unshift(r)
|
|
: (e._events[t] = [r, e._events[t]])
|
|
}
|
|
function hc(e, t) {
|
|
;(Sr = Sr || yt()), (e = e || {})
|
|
var r = t instanceof Sr
|
|
;(this.objectMode = !!e.objectMode),
|
|
r && (this.objectMode = this.objectMode || !!e.readableObjectMode)
|
|
var i = e.highWaterMark,
|
|
n = e.readableHighWaterMark,
|
|
s = this.objectMode ? 16 : 16 * 1024
|
|
i || i === 0
|
|
? (this.highWaterMark = i)
|
|
: r && (n || n === 0)
|
|
? (this.highWaterMark = n)
|
|
: (this.highWaterMark = s),
|
|
(this.highWaterMark = Math.floor(this.highWaterMark)),
|
|
(this.buffer = new Iv()),
|
|
(this.length = 0),
|
|
(this.pipes = null),
|
|
(this.pipesCount = 0),
|
|
(this.flowing = null),
|
|
(this.ended = !1),
|
|
(this.endEmitted = !1),
|
|
(this.reading = !1),
|
|
(this.sync = !0),
|
|
(this.needReadable = !1),
|
|
(this.emittedReadable = !1),
|
|
(this.readableListening = !1),
|
|
(this.resumeScheduled = !1),
|
|
(this.destroyed = !1),
|
|
(this.defaultEncoding = e.defaultEncoding || 'utf8'),
|
|
(this.awaitDrain = 0),
|
|
(this.readingMore = !1),
|
|
(this.decoder = null),
|
|
(this.encoding = null),
|
|
e.encoding &&
|
|
(Mt || (Mt = fo().StringDecoder),
|
|
(this.decoder = new Mt(e.encoding)),
|
|
(this.encoding = e.encoding))
|
|
}
|
|
function V(e) {
|
|
if (((Sr = Sr || yt()), !(this instanceof V))) return new V(e)
|
|
;(this._readableState = new hc(e, this)),
|
|
(this.readable = !0),
|
|
e &&
|
|
(typeof e.read == 'function' && (this._read = e.read),
|
|
typeof e.destroy == 'function' && (this._destroy = e.destroy)),
|
|
po.call(this)
|
|
}
|
|
Object.defineProperty(V.prototype, 'destroyed', {
|
|
get: function () {
|
|
return this._readableState === void 0 ? !1 : this._readableState.destroyed
|
|
},
|
|
set: function (e) {
|
|
this._readableState && (this._readableState.destroyed = e)
|
|
},
|
|
})
|
|
V.prototype.destroy = cc.destroy
|
|
V.prototype._undestroy = cc.undestroy
|
|
V.prototype._destroy = function (e, t) {
|
|
this.push(null), t(e)
|
|
}
|
|
V.prototype.push = function (e, t) {
|
|
var r = this._readableState,
|
|
i
|
|
return (
|
|
r.objectMode
|
|
? (i = !0)
|
|
: typeof e == 'string' &&
|
|
((t = t || r.defaultEncoding),
|
|
t !== r.encoding && ((e = Er.from(e, t)), (t = '')),
|
|
(i = !0)),
|
|
dc(this, e, t, !1, i)
|
|
)
|
|
}
|
|
V.prototype.unshift = function (e) {
|
|
return dc(this, e, null, !0, !1)
|
|
}
|
|
function dc(e, t, r, i, n) {
|
|
var s = e._readableState
|
|
if (t === null) (s.reading = !1), Bv(e, s)
|
|
else {
|
|
var o
|
|
n || (o = kv(s, t)),
|
|
o
|
|
? e.emit('error', o)
|
|
: s.objectMode || (t && t.length > 0)
|
|
? (typeof t != 'string' &&
|
|
!s.objectMode &&
|
|
Object.getPrototypeOf(t) !== Er.prototype &&
|
|
(t = Cv(t)),
|
|
i
|
|
? s.endEmitted
|
|
? e.emit(
|
|
'error',
|
|
new Error('stream.unshift() after end event'),
|
|
)
|
|
: co(e, s, t, !0)
|
|
: s.ended
|
|
? e.emit('error', new Error('stream.push() after EOF'))
|
|
: ((s.reading = !1),
|
|
s.decoder && !r
|
|
? ((t = s.decoder.write(t)),
|
|
s.objectMode || t.length !== 0
|
|
? co(e, s, t, !1)
|
|
: pc(e, s))
|
|
: co(e, s, t, !1)))
|
|
: i || (s.reading = !1)
|
|
}
|
|
return Rv(s)
|
|
}
|
|
function co(e, t, r, i) {
|
|
t.flowing && t.length === 0 && !t.sync
|
|
? (e.emit('data', r), e.read(0))
|
|
: ((t.length += t.objectMode ? 1 : r.length),
|
|
i ? t.buffer.unshift(r) : t.buffer.push(r),
|
|
t.needReadable && ji(e)),
|
|
pc(e, t)
|
|
}
|
|
function kv(e, t) {
|
|
var r
|
|
return (
|
|
!Tv(t) &&
|
|
typeof t != 'string' &&
|
|
t !== void 0 &&
|
|
!e.objectMode &&
|
|
(r = new TypeError('Invalid non-string/buffer chunk')),
|
|
r
|
|
)
|
|
}
|
|
function Rv(e) {
|
|
return (
|
|
!e.ended &&
|
|
(e.needReadable || e.length < e.highWaterMark || e.length === 0)
|
|
)
|
|
}
|
|
V.prototype.isPaused = function () {
|
|
return this._readableState.flowing === !1
|
|
}
|
|
V.prototype.setEncoding = function (e) {
|
|
return (
|
|
Mt || (Mt = fo().StringDecoder),
|
|
(this._readableState.decoder = new Mt(e)),
|
|
(this._readableState.encoding = e),
|
|
this
|
|
)
|
|
}
|
|
var oc = 8388608
|
|
function Pv(e) {
|
|
return (
|
|
e >= oc
|
|
? (e = oc)
|
|
: (e--,
|
|
(e |= e >>> 1),
|
|
(e |= e >>> 2),
|
|
(e |= e >>> 4),
|
|
(e |= e >>> 8),
|
|
(e |= e >>> 16),
|
|
e++),
|
|
e
|
|
)
|
|
}
|
|
function ac(e, t) {
|
|
return e <= 0 || (t.length === 0 && t.ended)
|
|
? 0
|
|
: t.objectMode
|
|
? 1
|
|
: e !== e
|
|
? t.flowing && t.length
|
|
? t.buffer.head.data.length
|
|
: t.length
|
|
: (e > t.highWaterMark && (t.highWaterMark = Pv(e)),
|
|
e <= t.length ? e : t.ended ? t.length : ((t.needReadable = !0), 0))
|
|
}
|
|
V.prototype.read = function (e) {
|
|
L('read', e), (e = parseInt(e, 10))
|
|
var t = this._readableState,
|
|
r = e
|
|
if (
|
|
(e !== 0 && (t.emittedReadable = !1),
|
|
e === 0 && t.needReadable && (t.length >= t.highWaterMark || t.ended))
|
|
)
|
|
return (
|
|
L('read: emitReadable', t.length, t.ended),
|
|
t.length === 0 && t.ended ? ho(this) : ji(this),
|
|
null
|
|
)
|
|
if (((e = ac(e, t)), e === 0 && t.ended))
|
|
return t.length === 0 && ho(this), null
|
|
var i = t.needReadable
|
|
L('need readable', i),
|
|
(t.length === 0 || t.length - e < t.highWaterMark) &&
|
|
((i = !0), L('length less than watermark', i)),
|
|
t.ended || t.reading
|
|
? ((i = !1), L('reading or ended', i))
|
|
: i &&
|
|
(L('do read'),
|
|
(t.reading = !0),
|
|
(t.sync = !0),
|
|
t.length === 0 && (t.needReadable = !0),
|
|
this._read(t.highWaterMark),
|
|
(t.sync = !1),
|
|
t.reading || (e = ac(r, t)))
|
|
var n
|
|
return (
|
|
e > 0 ? (n = _c(e, t)) : (n = null),
|
|
n === null ? ((t.needReadable = !0), (e = 0)) : (t.length -= e),
|
|
t.length === 0 &&
|
|
(t.ended || (t.needReadable = !0), r !== e && t.ended && ho(this)),
|
|
n !== null && this.emit('data', n),
|
|
n
|
|
)
|
|
}
|
|
function Bv(e, t) {
|
|
if (!t.ended) {
|
|
if (t.decoder) {
|
|
var r = t.decoder.end()
|
|
r &&
|
|
r.length &&
|
|
(t.buffer.push(r), (t.length += t.objectMode ? 1 : r.length))
|
|
}
|
|
;(t.ended = !0), ji(e)
|
|
}
|
|
}
|
|
function ji(e) {
|
|
var t = e._readableState
|
|
;(t.needReadable = !1),
|
|
t.emittedReadable ||
|
|
(L('emitReadable', t.flowing),
|
|
(t.emittedReadable = !0),
|
|
t.sync ? Lt.nextTick(fc, e) : fc(e))
|
|
}
|
|
function fc(e) {
|
|
L('emit readable'), e.emit('readable'), _o(e)
|
|
}
|
|
function pc(e, t) {
|
|
t.readingMore || ((t.readingMore = !0), Lt.nextTick(Av, e, t))
|
|
}
|
|
function Av(e, t) {
|
|
for (
|
|
var r = t.length;
|
|
!t.reading &&
|
|
!t.flowing &&
|
|
!t.ended &&
|
|
t.length < t.highWaterMark &&
|
|
(L('maybeReadMore read 0'), e.read(0), r !== t.length);
|
|
|
|
)
|
|
r = t.length
|
|
t.readingMore = !1
|
|
}
|
|
V.prototype._read = function (e) {
|
|
this.emit('error', new Error('_read() is not implemented'))
|
|
}
|
|
V.prototype.pipe = function (e, t) {
|
|
var r = this,
|
|
i = this._readableState
|
|
switch (i.pipesCount) {
|
|
case 0:
|
|
i.pipes = e
|
|
break
|
|
case 1:
|
|
i.pipes = [i.pipes, e]
|
|
break
|
|
default:
|
|
i.pipes.push(e)
|
|
break
|
|
}
|
|
;(i.pipesCount += 1), L('pipe count=%d opts=%j', i.pipesCount, t)
|
|
var n =
|
|
(!t || t.end !== !1) && e !== process.stdout && e !== process.stderr,
|
|
s = n ? f : m
|
|
i.endEmitted ? Lt.nextTick(s) : r.once('end', s), e.on('unpipe', o)
|
|
function o(p, g) {
|
|
L('onunpipe'),
|
|
p === r && g && g.hasUnpiped === !1 && ((g.hasUnpiped = !0), u())
|
|
}
|
|
function f() {
|
|
L('onend'), e.end()
|
|
}
|
|
var a = Nv(r)
|
|
e.on('drain', a)
|
|
var l = !1
|
|
function u() {
|
|
L('cleanup'),
|
|
e.removeListener('close', _),
|
|
e.removeListener('finish', v),
|
|
e.removeListener('drain', a),
|
|
e.removeListener('error', d),
|
|
e.removeListener('unpipe', o),
|
|
r.removeListener('end', f),
|
|
r.removeListener('end', m),
|
|
r.removeListener('data', c),
|
|
(l = !0),
|
|
i.awaitDrain && (!e._writableState || e._writableState.needDrain) && a()
|
|
}
|
|
var h = !1
|
|
r.on('data', c)
|
|
function c(p) {
|
|
L('ondata'), (h = !1)
|
|
var g = e.write(p)
|
|
g === !1 &&
|
|
!h &&
|
|
(((i.pipesCount === 1 && i.pipes === e) ||
|
|
(i.pipesCount > 1 && gc(i.pipes, e) !== -1)) &&
|
|
!l &&
|
|
(L('false write response, pause', i.awaitDrain),
|
|
i.awaitDrain++,
|
|
(h = !0)),
|
|
r.pause())
|
|
}
|
|
function d(p) {
|
|
L('onerror', p),
|
|
m(),
|
|
e.removeListener('error', d),
|
|
lc(e, 'error') === 0 && e.emit('error', p)
|
|
}
|
|
Ov(e, 'error', d)
|
|
function _() {
|
|
e.removeListener('finish', v), m()
|
|
}
|
|
e.once('close', _)
|
|
function v() {
|
|
L('onfinish'), e.removeListener('close', _), m()
|
|
}
|
|
e.once('finish', v)
|
|
function m() {
|
|
L('unpipe'), r.unpipe(e)
|
|
}
|
|
return e.emit('pipe', r), i.flowing || (L('pipe resume'), r.resume()), e
|
|
}
|
|
function Nv(e) {
|
|
return function () {
|
|
var t = e._readableState
|
|
L('pipeOnDrain', t.awaitDrain),
|
|
t.awaitDrain && t.awaitDrain--,
|
|
t.awaitDrain === 0 && lc(e, 'data') && ((t.flowing = !0), _o(e))
|
|
}
|
|
}
|
|
V.prototype.unpipe = function (e) {
|
|
var t = this._readableState,
|
|
r = { hasUnpiped: !1 }
|
|
if (t.pipesCount === 0) return this
|
|
if (t.pipesCount === 1)
|
|
return e && e !== t.pipes
|
|
? this
|
|
: (e || (e = t.pipes),
|
|
(t.pipes = null),
|
|
(t.pipesCount = 0),
|
|
(t.flowing = !1),
|
|
e && e.emit('unpipe', this, r),
|
|
this)
|
|
if (!e) {
|
|
var i = t.pipes,
|
|
n = t.pipesCount
|
|
;(t.pipes = null), (t.pipesCount = 0), (t.flowing = !1)
|
|
for (var s = 0; s < n; s++) i[s].emit('unpipe', this, { hasUnpiped: !1 })
|
|
return this
|
|
}
|
|
var o = gc(t.pipes, e)
|
|
return o === -1
|
|
? this
|
|
: (t.pipes.splice(o, 1),
|
|
(t.pipesCount -= 1),
|
|
t.pipesCount === 1 && (t.pipes = t.pipes[0]),
|
|
e.emit('unpipe', this, r),
|
|
this)
|
|
}
|
|
V.prototype.on = function (e, t) {
|
|
var r = po.prototype.on.call(this, e, t)
|
|
if (e === 'data') this._readableState.flowing !== !1 && this.resume()
|
|
else if (e === 'readable') {
|
|
var i = this._readableState
|
|
!i.endEmitted &&
|
|
!i.readableListening &&
|
|
((i.readableListening = i.needReadable = !0),
|
|
(i.emittedReadable = !1),
|
|
i.reading ? i.length && ji(this) : Lt.nextTick(Mv, this))
|
|
}
|
|
return r
|
|
}
|
|
V.prototype.addListener = V.prototype.on
|
|
function Mv(e) {
|
|
L('readable nexttick read 0'), e.read(0)
|
|
}
|
|
V.prototype.resume = function () {
|
|
var e = this._readableState
|
|
return e.flowing || (L('resume'), (e.flowing = !0), Lv(this, e)), this
|
|
}
|
|
function Lv(e, t) {
|
|
t.resumeScheduled || ((t.resumeScheduled = !0), Lt.nextTick(qv, e, t))
|
|
}
|
|
function qv(e, t) {
|
|
t.reading || (L('resume read 0'), e.read(0)),
|
|
(t.resumeScheduled = !1),
|
|
(t.awaitDrain = 0),
|
|
e.emit('resume'),
|
|
_o(e),
|
|
t.flowing && !t.reading && e.read(0)
|
|
}
|
|
V.prototype.pause = function () {
|
|
return (
|
|
L('call pause flowing=%j', this._readableState.flowing),
|
|
this._readableState.flowing !== !1 &&
|
|
(L('pause'), (this._readableState.flowing = !1), this.emit('pause')),
|
|
this
|
|
)
|
|
}
|
|
function _o(e) {
|
|
var t = e._readableState
|
|
for (L('flow', t.flowing); t.flowing && e.read() !== null; );
|
|
}
|
|
V.prototype.wrap = function (e) {
|
|
var t = this,
|
|
r = this._readableState,
|
|
i = !1
|
|
e.on('end', function () {
|
|
if ((L('wrapped end'), r.decoder && !r.ended)) {
|
|
var o = r.decoder.end()
|
|
o && o.length && t.push(o)
|
|
}
|
|
t.push(null)
|
|
}),
|
|
e.on('data', function (o) {
|
|
if (
|
|
(L('wrapped data'),
|
|
r.decoder && (o = r.decoder.write(o)),
|
|
!(r.objectMode && o == null) && !(!r.objectMode && (!o || !o.length)))
|
|
) {
|
|
var f = t.push(o)
|
|
f || ((i = !0), e.pause())
|
|
}
|
|
})
|
|
for (var n in e)
|
|
this[n] === void 0 &&
|
|
typeof e[n] == 'function' &&
|
|
(this[n] = (function (o) {
|
|
return function () {
|
|
return e[o].apply(e, arguments)
|
|
}
|
|
})(n))
|
|
for (var s = 0; s < uo.length; s++) e.on(uo[s], this.emit.bind(this, uo[s]))
|
|
return (
|
|
(this._read = function (o) {
|
|
L('wrapped _read', o), i && ((i = !1), e.resume())
|
|
}),
|
|
this
|
|
)
|
|
}
|
|
Object.defineProperty(V.prototype, 'readableHighWaterMark', {
|
|
enumerable: !1,
|
|
get: function () {
|
|
return this._readableState.highWaterMark
|
|
},
|
|
})
|
|
V._fromList = _c
|
|
function _c(e, t) {
|
|
if (t.length === 0) return null
|
|
var r
|
|
return (
|
|
t.objectMode
|
|
? (r = t.buffer.shift())
|
|
: !e || e >= t.length
|
|
? (t.decoder
|
|
? (r = t.buffer.join(''))
|
|
: t.buffer.length === 1
|
|
? (r = t.buffer.head.data)
|
|
: (r = t.buffer.concat(t.length)),
|
|
t.buffer.clear())
|
|
: (r = Dv(e, t.buffer, t.decoder)),
|
|
r
|
|
)
|
|
}
|
|
function Dv(e, t, r) {
|
|
var i
|
|
return (
|
|
e < t.head.data.length
|
|
? ((i = t.head.data.slice(0, e)), (t.head.data = t.head.data.slice(e)))
|
|
: e === t.head.data.length
|
|
? (i = t.shift())
|
|
: (i = r ? Uv(e, t) : jv(e, t)),
|
|
i
|
|
)
|
|
}
|
|
function Uv(e, t) {
|
|
var r = t.head,
|
|
i = 1,
|
|
n = r.data
|
|
for (e -= n.length; (r = r.next); ) {
|
|
var s = r.data,
|
|
o = e > s.length ? s.length : e
|
|
if (
|
|
(o === s.length ? (n += s) : (n += s.slice(0, e)), (e -= o), e === 0)
|
|
) {
|
|
o === s.length
|
|
? (++i, r.next ? (t.head = r.next) : (t.head = t.tail = null))
|
|
: ((t.head = r), (r.data = s.slice(o)))
|
|
break
|
|
}
|
|
++i
|
|
}
|
|
return (t.length -= i), n
|
|
}
|
|
function jv(e, t) {
|
|
var r = Er.allocUnsafe(e),
|
|
i = t.head,
|
|
n = 1
|
|
for (i.data.copy(r), e -= i.data.length; (i = i.next); ) {
|
|
var s = i.data,
|
|
o = e > s.length ? s.length : e
|
|
if ((s.copy(r, r.length - e, 0, o), (e -= o), e === 0)) {
|
|
o === s.length
|
|
? (++n, i.next ? (t.head = i.next) : (t.head = t.tail = null))
|
|
: ((t.head = i), (i.data = s.slice(o)))
|
|
break
|
|
}
|
|
++n
|
|
}
|
|
return (t.length -= n), r
|
|
}
|
|
function ho(e) {
|
|
var t = e._readableState
|
|
if (t.length > 0)
|
|
throw new Error('"endReadable()" called on non-empty stream')
|
|
t.endEmitted || ((t.ended = !0), Lt.nextTick(Fv, t, e))
|
|
}
|
|
function Fv(e, t) {
|
|
!e.endEmitted &&
|
|
e.length === 0 &&
|
|
((e.endEmitted = !0), (t.readable = !1), t.emit('end'))
|
|
}
|
|
function gc(e, t) {
|
|
for (var r = 0, i = e.length; r < i; r++) if (e[r] === t) return r
|
|
return -1
|
|
}
|
|
})
|
|
var go = b((E0, mc) => {
|
|
'use strict'
|
|
mc.exports = De
|
|
var Fi = yt(),
|
|
vc = Object.create(At())
|
|
vc.inherits = ie()
|
|
vc.inherits(De, Fi)
|
|
function Wv(e, t) {
|
|
var r = this._transformState
|
|
r.transforming = !1
|
|
var i = r.writecb
|
|
if (!i)
|
|
return this.emit(
|
|
'error',
|
|
new Error('write callback called multiple times'),
|
|
)
|
|
;(r.writechunk = null), (r.writecb = null), t != null && this.push(t), i(e)
|
|
var n = this._readableState
|
|
;(n.reading = !1),
|
|
(n.needReadable || n.length < n.highWaterMark) &&
|
|
this._read(n.highWaterMark)
|
|
}
|
|
function De(e) {
|
|
if (!(this instanceof De)) return new De(e)
|
|
Fi.call(this, e),
|
|
(this._transformState = {
|
|
afterTransform: Wv.bind(this),
|
|
needTransform: !1,
|
|
transforming: !1,
|
|
writecb: null,
|
|
writechunk: null,
|
|
writeencoding: null,
|
|
}),
|
|
(this._readableState.needReadable = !0),
|
|
(this._readableState.sync = !1),
|
|
e &&
|
|
(typeof e.transform == 'function' && (this._transform = e.transform),
|
|
typeof e.flush == 'function' && (this._flush = e.flush)),
|
|
this.on('prefinish', Vv)
|
|
}
|
|
function Vv() {
|
|
var e = this
|
|
typeof this._flush == 'function'
|
|
? this._flush(function (t, r) {
|
|
yc(e, t, r)
|
|
})
|
|
: yc(this, null, null)
|
|
}
|
|
De.prototype.push = function (e, t) {
|
|
return (
|
|
(this._transformState.needTransform = !1),
|
|
Fi.prototype.push.call(this, e, t)
|
|
)
|
|
}
|
|
De.prototype._transform = function (e, t, r) {
|
|
throw new Error('_transform() is not implemented')
|
|
}
|
|
De.prototype._write = function (e, t, r) {
|
|
var i = this._transformState
|
|
if (
|
|
((i.writecb = r),
|
|
(i.writechunk = e),
|
|
(i.writeencoding = t),
|
|
!i.transforming)
|
|
) {
|
|
var n = this._readableState
|
|
;(i.needTransform || n.needReadable || n.length < n.highWaterMark) &&
|
|
this._read(n.highWaterMark)
|
|
}
|
|
}
|
|
De.prototype._read = function (e) {
|
|
var t = this._transformState
|
|
t.writechunk !== null && t.writecb && !t.transforming
|
|
? ((t.transforming = !0),
|
|
this._transform(t.writechunk, t.writeencoding, t.afterTransform))
|
|
: (t.needTransform = !0)
|
|
}
|
|
De.prototype._destroy = function (e, t) {
|
|
var r = this
|
|
Fi.prototype._destroy.call(this, e, function (i) {
|
|
t(i), r.emit('close')
|
|
})
|
|
}
|
|
function yc(e, t, r) {
|
|
if (t) return e.emit('error', t)
|
|
if ((r != null && e.push(r), e._writableState.length))
|
|
throw new Error('Calling transform done when ws.length != 0')
|
|
if (e._transformState.transforming)
|
|
throw new Error('Calling transform done when still transforming')
|
|
return e.push(null)
|
|
}
|
|
})
|
|
var xc = b((x0, Ec) => {
|
|
'use strict'
|
|
Ec.exports = xr
|
|
var wc = go(),
|
|
Sc = Object.create(At())
|
|
Sc.inherits = ie()
|
|
Sc.inherits(xr, wc)
|
|
function xr(e) {
|
|
if (!(this instanceof xr)) return new xr(e)
|
|
wc.call(this, e)
|
|
}
|
|
xr.prototype._transform = function (e, t, r) {
|
|
r(null, e)
|
|
}
|
|
})
|
|
var bo = b((X, Wi) => {
|
|
var Ie = require('stream')
|
|
process.env.READABLE_STREAM === 'disable' && Ie
|
|
? ((Wi.exports = Ie),
|
|
(X = Wi.exports = Ie.Readable),
|
|
(X.Readable = Ie.Readable),
|
|
(X.Writable = Ie.Writable),
|
|
(X.Duplex = Ie.Duplex),
|
|
(X.Transform = Ie.Transform),
|
|
(X.PassThrough = Ie.PassThrough),
|
|
(X.Stream = Ie))
|
|
: ((X = Wi.exports = so()),
|
|
(X.Stream = Ie || X),
|
|
(X.Readable = X),
|
|
(X.Writable = ro()),
|
|
(X.Duplex = yt()),
|
|
(X.Transform = go()),
|
|
(X.PassThrough = xc()))
|
|
})
|
|
var kc = b((C0, Oc) => {
|
|
var Vi = bo(),
|
|
Cc = Kn(),
|
|
Hv = ie(),
|
|
$v = Yn(),
|
|
Tc =
|
|
Buffer.from && Buffer.from !== Uint8Array.from
|
|
? Buffer.from([0])
|
|
: new Buffer([0]),
|
|
yo = function (e, t) {
|
|
e._corked ? e.once('uncork', t) : t()
|
|
},
|
|
Gv = function (e, t) {
|
|
e._autoDestroy && e.destroy(t)
|
|
},
|
|
Ic = function (e, t) {
|
|
return function (r) {
|
|
r
|
|
? Gv(e, r.message === 'premature close' ? null : r)
|
|
: t && !e._ended && e.end()
|
|
}
|
|
},
|
|
zv = function (e, t) {
|
|
if (!e || (e._writableState && e._writableState.finished)) return t()
|
|
if (e._writableState) return e.end(t)
|
|
e.end(), t()
|
|
},
|
|
Kv = function (e) {
|
|
return new Vi.Readable({ objectMode: !0, highWaterMark: 16 }).wrap(e)
|
|
},
|
|
Z = function (e, t, r) {
|
|
if (!(this instanceof Z)) return new Z(e, t, r)
|
|
Vi.Duplex.call(this, r),
|
|
(this._writable = null),
|
|
(this._readable = null),
|
|
(this._readable2 = null),
|
|
(this._autoDestroy = !r || r.autoDestroy !== !1),
|
|
(this._forwardDestroy = !r || r.destroy !== !1),
|
|
(this._forwardEnd = !r || r.end !== !1),
|
|
(this._corked = 1),
|
|
(this._ondrain = null),
|
|
(this._drained = !1),
|
|
(this._forwarding = !1),
|
|
(this._unwrite = null),
|
|
(this._unread = null),
|
|
(this._ended = !1),
|
|
(this.destroyed = !1),
|
|
e && this.setWritable(e),
|
|
t && this.setReadable(t)
|
|
}
|
|
Hv(Z, Vi.Duplex)
|
|
Z.obj = function (e, t, r) {
|
|
return (
|
|
r || (r = {}), (r.objectMode = !0), (r.highWaterMark = 16), new Z(e, t, r)
|
|
)
|
|
}
|
|
Z.prototype.cork = function () {
|
|
++this._corked === 1 && this.emit('cork')
|
|
}
|
|
Z.prototype.uncork = function () {
|
|
this._corked && --this._corked === 0 && this.emit('uncork')
|
|
}
|
|
Z.prototype.setWritable = function (e) {
|
|
if ((this._unwrite && this._unwrite(), this.destroyed)) {
|
|
e && e.destroy && e.destroy()
|
|
return
|
|
}
|
|
if (e === null || e === !1) {
|
|
this.end()
|
|
return
|
|
}
|
|
var t = this,
|
|
r = Cc(e, { writable: !0, readable: !1 }, Ic(this, this._forwardEnd)),
|
|
i = function () {
|
|
var s = t._ondrain
|
|
;(t._ondrain = null), s && s()
|
|
},
|
|
n = function () {
|
|
t._writable.removeListener('drain', i), r()
|
|
}
|
|
this._unwrite && process.nextTick(i),
|
|
(this._writable = e),
|
|
this._writable.on('drain', i),
|
|
(this._unwrite = n),
|
|
this.uncork()
|
|
}
|
|
Z.prototype.setReadable = function (e) {
|
|
if ((this._unread && this._unread(), this.destroyed)) {
|
|
e && e.destroy && e.destroy()
|
|
return
|
|
}
|
|
if (e === null || e === !1) {
|
|
this.push(null), this.resume()
|
|
return
|
|
}
|
|
var t = this,
|
|
r = Cc(e, { writable: !1, readable: !0 }, Ic(this)),
|
|
i = function () {
|
|
t._forward()
|
|
},
|
|
n = function () {
|
|
t.push(null)
|
|
},
|
|
s = function () {
|
|
t._readable2.removeListener('readable', i),
|
|
t._readable2.removeListener('end', n),
|
|
r()
|
|
}
|
|
;(this._drained = !0),
|
|
(this._readable = e),
|
|
(this._readable2 = e._readableState ? e : Kv(e)),
|
|
this._readable2.on('readable', i),
|
|
this._readable2.on('end', n),
|
|
(this._unread = s),
|
|
this._forward()
|
|
}
|
|
Z.prototype._read = function () {
|
|
;(this._drained = !0), this._forward()
|
|
}
|
|
Z.prototype._forward = function () {
|
|
if (!(this._forwarding || !this._readable2 || !this._drained)) {
|
|
this._forwarding = !0
|
|
for (var e; this._drained && (e = $v(this._readable2)) !== null; )
|
|
this.destroyed || (this._drained = this.push(e))
|
|
this._forwarding = !1
|
|
}
|
|
}
|
|
Z.prototype.destroy = function (e) {
|
|
if (!this.destroyed) {
|
|
this.destroyed = !0
|
|
var t = this
|
|
process.nextTick(function () {
|
|
t._destroy(e)
|
|
})
|
|
}
|
|
}
|
|
Z.prototype._destroy = function (e) {
|
|
if (e) {
|
|
var t = this._ondrain
|
|
;(this._ondrain = null), t ? t(e) : this.emit('error', e)
|
|
}
|
|
this._forwardDestroy &&
|
|
(this._readable && this._readable.destroy && this._readable.destroy(),
|
|
this._writable && this._writable.destroy && this._writable.destroy()),
|
|
this.emit('close')
|
|
}
|
|
Z.prototype._write = function (e, t, r) {
|
|
if (this.destroyed) return r()
|
|
if (this._corked) return yo(this, this._write.bind(this, e, t, r))
|
|
if (e === Tc) return this._finish(r)
|
|
if (!this._writable) return r()
|
|
this._writable.write(e) === !1 ? (this._ondrain = r) : r()
|
|
}
|
|
Z.prototype._finish = function (e) {
|
|
var t = this
|
|
this.emit('preend'),
|
|
yo(this, function () {
|
|
zv(t._forwardEnd && t._writable, function () {
|
|
t._writableState.prefinished === !1 &&
|
|
(t._writableState.prefinished = !0),
|
|
t.emit('prefinish'),
|
|
yo(t, e)
|
|
})
|
|
})
|
|
}
|
|
Z.prototype.end = function (e, t, r) {
|
|
return typeof e == 'function'
|
|
? this.end(null, null, e)
|
|
: typeof t == 'function'
|
|
? this.end(e, null, t)
|
|
: ((this._ended = !0),
|
|
e && this.write(e),
|
|
this._writableState.ending || this.write(Tc),
|
|
Vi.Writable.prototype.end.call(this, r))
|
|
}
|
|
Oc.exports = Z
|
|
})
|
|
var vo = b((T0, Pc) => {
|
|
'use strict'
|
|
var Yv = bo().Transform,
|
|
Qv = kc(),
|
|
Rc = Js(),
|
|
qt = ve().Buffer
|
|
Pc.exports = Xv
|
|
function Jv(e, t, r) {
|
|
var i = new Yv({ objectMode: e.objectMode })
|
|
return (i._write = t), (i._flush = r), i
|
|
}
|
|
function Xv(e, t, r) {
|
|
var i,
|
|
n,
|
|
s = process.title === 'browser',
|
|
o = !!global.WebSocket,
|
|
f = s ? _ : d
|
|
t &&
|
|
!Array.isArray(t) &&
|
|
typeof t == 'object' &&
|
|
((r = t),
|
|
(t = null),
|
|
(typeof r.protocol == 'string' || Array.isArray(r.protocol)) &&
|
|
(t = r.protocol)),
|
|
r || (r = {}),
|
|
r.objectMode === void 0 &&
|
|
(r.objectMode = !(r.binary === !0 || r.binary === void 0))
|
|
var a = Jv(r, f, v)
|
|
r.objectMode || (a._writev = C)
|
|
var l = r.browserBufferSize || 1024 * 512,
|
|
u = r.browserBufferTimeout || 1e3
|
|
typeof e == 'object'
|
|
? (n = e)
|
|
: (o && s ? (n = new Rc(e, t)) : (n = new Rc(e, t, r)),
|
|
(n.binaryType = 'arraybuffer'))
|
|
var h = typeof n.addEventListener > 'u'
|
|
n.readyState === n.OPEN
|
|
? (i = a)
|
|
: ((i = i = Qv(void 0, void 0, r)),
|
|
r.objectMode || (i._writev = C),
|
|
h ? n.addEventListener('open', m) : (n.onopen = m)),
|
|
(i.socket = n),
|
|
h
|
|
? (n.addEventListener('close', p),
|
|
n.addEventListener('error', g),
|
|
n.addEventListener('message', S))
|
|
: ((n.onclose = p), (n.onerror = g), (n.onmessage = S)),
|
|
a.on('close', x)
|
|
var c = !r.objectMode
|
|
function d(w, B, M) {
|
|
if (n.readyState !== n.OPEN) {
|
|
M()
|
|
return
|
|
}
|
|
c && typeof w == 'string' && (w = qt.from(w, 'utf8')), n.send(w, M)
|
|
}
|
|
function _(w, B, M) {
|
|
if (n.bufferedAmount > l) {
|
|
setTimeout(_, u, w, B, M)
|
|
return
|
|
}
|
|
c && typeof w == 'string' && (w = qt.from(w, 'utf8'))
|
|
try {
|
|
n.send(w)
|
|
} catch (H) {
|
|
return M(H)
|
|
}
|
|
M()
|
|
}
|
|
function v(w) {
|
|
n.close(), w()
|
|
}
|
|
function m() {
|
|
i.setReadable(a), i.setWritable(a), i.emit('connect')
|
|
}
|
|
function p() {
|
|
i.end(), i.destroy()
|
|
}
|
|
function g(w) {
|
|
i.destroy(w)
|
|
}
|
|
function S(w) {
|
|
var B = w.data
|
|
B instanceof ArrayBuffer ? (B = qt.from(B)) : (B = qt.from(B, 'utf8')),
|
|
a.push(B)
|
|
}
|
|
function x() {
|
|
n.close()
|
|
}
|
|
function C(w, B) {
|
|
for (var M = new Array(w.length), H = 0; H < w.length; H++)
|
|
typeof w[H].chunk == 'string'
|
|
? (M[H] = qt.from(w[H], 'utf8'))
|
|
: (M[H] = w[H].chunk)
|
|
this._write(qt.concat(M), 'binary', B)
|
|
}
|
|
return i
|
|
}
|
|
})
|
|
var Bc = b((I0, mo) => {
|
|
'use strict'
|
|
var Zv = Js().Server,
|
|
em = vo(),
|
|
Hi = class extends Zv {
|
|
constructor(t, r) {
|
|
super(t)
|
|
var i = !1
|
|
this.on('newListener', function (n) {
|
|
!i &&
|
|
n === 'stream' &&
|
|
((i = !0),
|
|
this.on('connection', function (s, o) {
|
|
this.emit('stream', em(s, t), o)
|
|
}))
|
|
}),
|
|
r && this.on('stream', r)
|
|
}
|
|
}
|
|
mo.exports.Server = Hi
|
|
mo.exports.createServer = function (e, t) {
|
|
return new Hi(e, t)
|
|
}
|
|
})
|
|
var Nc = b((O0, $i) => {
|
|
var Ac = Bc()
|
|
$i.exports = vo()
|
|
$i.exports.Server = Ac.Server
|
|
$i.exports.createServer = Ac.createServer
|
|
})
|
|
var Lc = b((k0, Mc) => {
|
|
var tm = Nc()
|
|
function rm(e, t) {
|
|
return tm(t.url, ['mqttv3.1'], t.websocketOptions)
|
|
}
|
|
Mc.exports = rm
|
|
})
|
|
var Gi = b((R0, Or) => {
|
|
var im = require('events'),
|
|
nm = require('util').inherits,
|
|
sm = Wl(),
|
|
Tr = Kl(),
|
|
qc = Is(),
|
|
Oe = Ql(),
|
|
R = cr(),
|
|
om = tu(),
|
|
am = require('path'),
|
|
fm = require('fs')
|
|
function Cr(e) {
|
|
return e > 9 ? e : '0' + e
|
|
}
|
|
function lm() {
|
|
var e = new Date()
|
|
return (
|
|
e.getUTCFullYear() +
|
|
'' +
|
|
Cr(e.getUTCMonth() + 1) +
|
|
Cr(e.getUTCDate()) +
|
|
'T' +
|
|
Cr(e.getUTCHours()) +
|
|
Cr(e.getUTCMinutes()) +
|
|
Cr(e.getUTCSeconds()) +
|
|
'Z'
|
|
)
|
|
}
|
|
function um(e) {
|
|
return e.substring(0, e.indexOf('T'))
|
|
}
|
|
function cm(e, t, r, i) {
|
|
var n = Tr(t, 'AWS4' + e, { asBytes: !0 }),
|
|
s = Tr(r, n, { asBytes: !0 }),
|
|
o = Tr(i, s, { asBytes: !0 }),
|
|
f = Tr('aws4_request', o, { asBytes: !0 })
|
|
return f
|
|
}
|
|
function hm(e, t, r, i, n, s, o, f, a, l, u, h, c, d) {
|
|
var _ = 'host',
|
|
v =
|
|
'host:' +
|
|
r.toLowerCase() +
|
|
`
|
|
`,
|
|
m =
|
|
e +
|
|
`
|
|
` +
|
|
i +
|
|
`
|
|
` +
|
|
n +
|
|
`
|
|
` +
|
|
v +
|
|
`
|
|
` +
|
|
_ +
|
|
`
|
|
` +
|
|
qc(l, { asBytes: !0 })
|
|
c === !0 &&
|
|
console.log(
|
|
'canonical request: ' +
|
|
m +
|
|
`
|
|
`,
|
|
)
|
|
var p = qc(m, { asBytes: !0 })
|
|
c === !0 &&
|
|
console.log(
|
|
'hashed canonical request: ' +
|
|
p +
|
|
`
|
|
`,
|
|
)
|
|
var g =
|
|
`AWS4-HMAC-SHA256
|
|
` +
|
|
h +
|
|
`
|
|
` +
|
|
u +
|
|
'/' +
|
|
f +
|
|
'/' +
|
|
a +
|
|
`/aws4_request
|
|
` +
|
|
p
|
|
c === !0 &&
|
|
console.log(
|
|
'string to sign: ' +
|
|
g +
|
|
`
|
|
`,
|
|
)
|
|
var S = cm(o, u, f, a)
|
|
c === !0 &&
|
|
console.log(
|
|
'signing key: ' +
|
|
S +
|
|
`
|
|
`,
|
|
)
|
|
var x = Tr(g, S, { asBytes: !0 })
|
|
c === !0 &&
|
|
console.log(
|
|
'signature: ' +
|
|
x +
|
|
`
|
|
`,
|
|
)
|
|
var C = n + '&X-Amz-Signature=' + x
|
|
R(d) || (C += '&X-Amz-Security-Token=' + encodeURIComponent(d))
|
|
var w = t + r + i + '?' + C
|
|
return (
|
|
c === !0 &&
|
|
console.log(
|
|
'url: ' +
|
|
w +
|
|
`
|
|
`,
|
|
),
|
|
w
|
|
)
|
|
}
|
|
function Dc(e, t, r, i) {
|
|
var n = lm(),
|
|
s = um(n),
|
|
o = '/mqtt',
|
|
f = 'iotdevicegateway',
|
|
a =
|
|
'X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=' +
|
|
t +
|
|
'%2F' +
|
|
s +
|
|
'%2F' +
|
|
e.region +
|
|
'%2F' +
|
|
f +
|
|
'%2Faws4_request&X-Amz-Date=' +
|
|
n +
|
|
'&X-Amz-SignedHeaders=host',
|
|
l = e.host
|
|
return (
|
|
!R(e.port) && e.port !== 443 && (l = e.host + ':' + e.port),
|
|
hm('GET', 'wss://', l, o, a, t, r, e.region, f, '', s, n, e.debug, i)
|
|
)
|
|
}
|
|
function Uc(e) {
|
|
var t = '/mqtt',
|
|
r = e.host
|
|
return (
|
|
!R(e.port) && e.port !== 443 && (r = e.host + ':' + e.port),
|
|
'wss://' + r + t + (e.customAuthQueryString || '')
|
|
)
|
|
}
|
|
function dm(e, t) {
|
|
for (var r in e)
|
|
Object.prototype.hasOwnProperty.call(e, r) &&
|
|
t.call(this, e[r], parseInt(r, 10))
|
|
}
|
|
function pm(e) {
|
|
var t = {},
|
|
r = {}
|
|
return (
|
|
dm(e.split(/\r?\n/), function (i) {
|
|
i = i.split(/(^|\s)[;#]/)[0]
|
|
var n = i.match(/^\s*\[([^\[\]]+)\]\s*$/)
|
|
if (n) r = n[1]
|
|
else if (r) {
|
|
var s = i.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/)
|
|
s && ((t[r] = t[r] || {}), (t[r][s[1]] = s[2]))
|
|
}
|
|
}),
|
|
t
|
|
)
|
|
}
|
|
function Ir(e) {
|
|
if (!(this instanceof Ir)) return new Ir(e)
|
|
var t = this,
|
|
r = [],
|
|
i = !0,
|
|
n = 0,
|
|
s = 'oldest'
|
|
r.length = 0
|
|
var o = [],
|
|
f = 50
|
|
o.length = 0
|
|
var a = [],
|
|
l = !0
|
|
a.length = 0
|
|
var u = []
|
|
u.length = 0
|
|
var h = 'inactive',
|
|
c = null,
|
|
d = 250,
|
|
_ = 300,
|
|
v = 1e3,
|
|
m = 2e4,
|
|
p = 128e3,
|
|
g,
|
|
S = null,
|
|
x,
|
|
C,
|
|
w,
|
|
B = '?SDK=JavaScript&Version=',
|
|
M = ru(),
|
|
H = M.version,
|
|
rt = B + H
|
|
if (R(e) || Object.keys(e).length === 0)
|
|
throw new Error(Oe.INVALID_CONNECT_OPTIONS)
|
|
if (
|
|
(R(e.keepalive) && (e.keepalive = _),
|
|
(R(e.enableMetrics) || e.enableMetrics === !0) &&
|
|
(R(e.username) ? (e.username = rt) : (e.username += rt)),
|
|
R(e.baseReconnectTimeMs) || (v = e.baseReconnectTimeMs),
|
|
R(e.minimumConnectionTimeMs) || (m = e.minimumConnectionTimeMs),
|
|
R(e.maximumReconnectTimeMs) || (p = e.maximumReconnectTimeMs),
|
|
R(e.drainTimeMs) || (d = e.drainTimeMs),
|
|
R(e.autoResubscribe) || (l = e.autoResubscribe),
|
|
R(e.offlineQueueing) || (i = e.offlineQueueing),
|
|
R(e.offlineQueueMaxSize) || (n = e.offlineQueueMaxSize),
|
|
R(e.offlineQueueDropBehavior) || (s = e.offlineQueueDropBehavior),
|
|
(g = v),
|
|
(e.reconnectPeriod = g),
|
|
(e.fastDisconnectDetection = !0),
|
|
(e.resubscribe = !1),
|
|
e.baseReconnectTimeMs <= 0)
|
|
)
|
|
throw new Error(Oe.INVALID_RECONNECT_TIMING)
|
|
if (p < v) throw new Error(Oe.INVALID_RECONNECT_TIMING)
|
|
if (m < v) throw new Error(Oe.INVALID_RECONNECT_TIMING)
|
|
if (s !== 'newest' && s !== 'oldest')
|
|
throw new Error(Oe.INVALID_OFFLINE_QUEUEING_PARAMETERS)
|
|
if (n < 0) throw new Error(Oe.INVALID_OFFLINE_QUEUEING_PARAMETERS)
|
|
if ((R(e.protocol) && (e.protocol = 'mqtts'), R(e.host)))
|
|
throw new Error(Oe.INVALID_CONNECT_OPTIONS)
|
|
if (
|
|
(R(e.servername) && (e.servername = e.host.split(':')[0]),
|
|
e.protocol === 'mqtts')
|
|
)
|
|
R(e.port) && (e.port = 8883), om(e)
|
|
else if (e.protocol === 'wss' || e.protocol === 'wss-custom-auth') {
|
|
if (e.protocol === 'wss') {
|
|
if (
|
|
(R(e.accessKeyId)
|
|
? (x = process.env.AWS_ACCESS_KEY_ID)
|
|
: (x = e.accessKeyId),
|
|
R(e.secretKey)
|
|
? (C = process.env.AWS_SECRET_ACCESS_KEY)
|
|
: (C = e.secretKey),
|
|
R(e.sessionToken)
|
|
? (w = process.env.AWS_SESSION_TOKEN)
|
|
: (w = e.sessionToken),
|
|
R(x) || R(C))
|
|
) {
|
|
var Se,
|
|
Rr = e.profile || process.env.AWS_PROFILE || 'default'
|
|
try {
|
|
R(e.filename) ? (Se = Qc()) : (Se = e.filename)
|
|
var Qi = pm(fm.readFileSync(Se, 'utf-8')),
|
|
Ut = Qi[Rr]
|
|
;(x = Ut.aws_access_key_id),
|
|
(C = Ut.aws_secret_access_key),
|
|
(w = Ut.aws_session_token)
|
|
} catch (T) {
|
|
console.log(T),
|
|
console.log(
|
|
'Failed to read credentials for AWS_PROFILE ' +
|
|
Rr +
|
|
' from ' +
|
|
Se,
|
|
)
|
|
}
|
|
}
|
|
if (R(x) || R(C))
|
|
throw (
|
|
(console.log(
|
|
'To connect via WebSocket/SigV4, AWS Access Key ID and AWS Secret Key must be passed either in options or as environment variables; see README.md',
|
|
),
|
|
new Error(Oe.INVALID_CONNECT_OPTIONS))
|
|
)
|
|
} else if (R(e.customAuthHeaders) && R(e.customAuthQueryString))
|
|
throw (
|
|
(console.log(
|
|
'To authenticate with a custom authorizer, you must provide the required HTTP headers or queryString; see README.md',
|
|
),
|
|
new Error(Oe.INVALID_CONNECT_OPTIONS))
|
|
)
|
|
if (!R(e.host) && R(e.region)) {
|
|
var Pr = /[a-zA-Z0-9]+\.iot\.([a-z]+-[a-z]+-[0-9]+)\.amazonaws\..+/,
|
|
Br = Pr.exec(e.host)
|
|
if (Br === null)
|
|
throw (
|
|
(console.log('Host endpoint is not valid'),
|
|
new Error(Oe.INVALID_CONNECT_OPTIONS))
|
|
)
|
|
e.region = Br[1]
|
|
}
|
|
R(e.port) && (e.port = 443),
|
|
R(e.websocketOptions)
|
|
? (e.websocketOptions = { protocol: 'mqttv3.1' })
|
|
: (e.websocketOptions.protocol = 'mqttv3.1'),
|
|
e.protocol === 'wss-custom-auth' &&
|
|
(e.websocketOptions.headers = e.customAuthHeaders)
|
|
}
|
|
!R(e) &&
|
|
e.debug === !0 &&
|
|
(console.log(e), console.log('attempting new mqtt connection...'))
|
|
var Ji = {}
|
|
;(Ji.mqtts = nu()), (Ji.wss = Lc())
|
|
function Qc() {
|
|
var T =
|
|
process.env.HOME ||
|
|
process.env.USERPROFILE ||
|
|
(process.env.HOMEPATH
|
|
? (process.env.HOMEDRIVE || 'C:/') + process.env.HOMEPATH
|
|
: null)
|
|
return am.join(T, '.aws', 'credentials')
|
|
}
|
|
function Jc(T, O) {
|
|
var U = a.filter(function (ce) {
|
|
return ce.topic === T
|
|
})
|
|
U.length === 0 && a.push({ topic: T, options: O })
|
|
}
|
|
function Xc(T, O) {
|
|
var U = a.filter(function (ce) {
|
|
return ce.topic !== T
|
|
})
|
|
a = U
|
|
}
|
|
function Xi(T, O, U) {
|
|
var ce = null
|
|
l !== !1 &&
|
|
(T === 'subscribe' ? (ce = Jc) : T === 'unsubscribe' && (ce = Xc),
|
|
Object.prototype.toString.call(O) === '[object Array]'
|
|
? O.forEach(function (ih, Om, km) {
|
|
ce(ih, U)
|
|
})
|
|
: ce(O, U))
|
|
}
|
|
function Ar() {
|
|
return h === 'inactive'
|
|
}
|
|
function Zc(T) {
|
|
var O = e.protocol
|
|
if (O === 'wss') {
|
|
var U
|
|
x === '' || C === ''
|
|
? (U = 'wss://no-credentials-available')
|
|
: (U = Dc(e, x, C, w)),
|
|
e.debug === !0 &&
|
|
console.log("using websockets, will connect to '" + U + "'..."),
|
|
(e.url = U)
|
|
} else
|
|
O === 'wss-custom-auth' &&
|
|
((e.url = Uc(e)),
|
|
e.debug === !0 &&
|
|
console.log(
|
|
"using websockets custom auth, will connect to '" +
|
|
e.url +
|
|
"'...",
|
|
),
|
|
(O = 'wss'))
|
|
return Ji[O](T, e)
|
|
}
|
|
var D = new sm.MqttClient(Zc, e)
|
|
function eh() {
|
|
;(g = v), (D.options.reconnectPeriod = g), (S = null), (h = 'stable')
|
|
}
|
|
function th() {
|
|
var T = !0
|
|
return (
|
|
n > 0 && r.length >= n && (s === 'oldest' ? r.shift() : (T = !1)), T
|
|
)
|
|
}
|
|
function rh() {
|
|
var T = u.shift()
|
|
if (!R(T))
|
|
R(T.callback)
|
|
? D.subscribe(T.topic, T.options)
|
|
: D.subscribe(T.topic, T.options, T.callback)
|
|
else {
|
|
var O = o.shift()
|
|
if (!R(O))
|
|
Xi(O.type, O.topics, O.options),
|
|
O.type === 'subscribe'
|
|
? R(O.callback)
|
|
? D.subscribe(O.topics, O.options)
|
|
: D.subscribe(O.topics, O.options, O.callback)
|
|
: O.type === 'unsubscribe' && D.unsubscribe(O.topics, O.callback)
|
|
else {
|
|
var U = r.shift()
|
|
R(U) || D.publish(U.topic, U.message, U.options, U.callback),
|
|
r.length === 0 && (clearInterval(c), (c = null))
|
|
}
|
|
}
|
|
}
|
|
D.on('connect', function (T) {
|
|
S === null && (S = setTimeout(eh, m)),
|
|
(h = 'established'),
|
|
c === null && ((u = a.slice(0)), (c = setInterval(rh, d))),
|
|
t.emit('connect', T)
|
|
}),
|
|
D.on('close', function (T) {
|
|
R(T) || t.emit('error', T),
|
|
!R(e) &&
|
|
e.debug === !0 &&
|
|
console.log(
|
|
'connection lost - will attempt reconnection in ' +
|
|
D.options.reconnectPeriod / 1e3 +
|
|
' seconds...',
|
|
),
|
|
clearTimeout(S),
|
|
(S = null),
|
|
clearInterval(c),
|
|
(c = null),
|
|
(h = 'inactive'),
|
|
t.emit('close')
|
|
}),
|
|
D.on('reconnect', function () {
|
|
;(g = g * 2),
|
|
(g = Math.min(p, g)),
|
|
(D.options.reconnectPeriod = g),
|
|
t.emit('reconnect')
|
|
}),
|
|
D.on('end', function () {
|
|
t.emit('end')
|
|
}),
|
|
D.on('offline', function () {
|
|
t.emit('offline')
|
|
}),
|
|
D.on('error', function (T) {
|
|
t.emit('error', T)
|
|
}),
|
|
D.on('packetsend', function (T) {
|
|
t.emit('packetsend', T)
|
|
}),
|
|
D.on('packetreceive', function (T) {
|
|
t.emit('packetreceive', T)
|
|
}),
|
|
D.on('message', function (T, O, U) {
|
|
t.emit('message', T, O, U)
|
|
}),
|
|
(this.publish = function (T, O, U, ce) {
|
|
i === !0 && (Ar() || c !== null)
|
|
? th() && r.push({ topic: T, message: O, options: U, callback: ce })
|
|
: (i === !0 || !Ar()) && D.publish(T, O, U, ce)
|
|
}),
|
|
(this.subscribe = function (T, O, U) {
|
|
!Ar() || l === !1
|
|
? (Xi('subscribe', T, O),
|
|
R(U) ? D.subscribe(T, O) : D.subscribe(T, O, U))
|
|
: o.length < f
|
|
? o.push({ type: 'subscribe', topics: T, options: O, callback: U })
|
|
: t.emit(
|
|
'error',
|
|
new Error('Maximum queued offline subscription reached'),
|
|
)
|
|
}),
|
|
(this.unsubscribe = function (T, O) {
|
|
!Ar() || l === !1
|
|
? (Xi('unsubscribe', T), D.unsubscribe(T, O))
|
|
: o.length < f &&
|
|
o.push({ type: 'unsubscribe', topics: T, options: e, callback: O })
|
|
}),
|
|
(this.end = function (T, O) {
|
|
D.end(T, O)
|
|
}),
|
|
(this.handleMessage = D.handleMessage.bind(D)),
|
|
(D.handleMessage = function (T, O) {
|
|
t.handleMessage(T, O)
|
|
}),
|
|
(this.updateWebSocketCredentials = function (T, O, U, ce) {
|
|
;(x = T), (C = O), (w = U)
|
|
}),
|
|
(this.getWebsocketHeaders = function () {
|
|
return e.websocketOptions.headers
|
|
}),
|
|
(this.updateCustomAuthHeaders = function (T) {
|
|
e.websocketOptions.headers = T
|
|
}),
|
|
(this.simulateNetworkFailure = function () {
|
|
D.stream.emit('error', new Error('simulated connection error')),
|
|
D.stream.end()
|
|
})
|
|
}
|
|
nm(Ir, im.EventEmitter)
|
|
Or.exports = Ir
|
|
Or.exports.DeviceClient = Ir
|
|
Or.exports.prepareWebSocketUrl = Dc
|
|
Or.exports.prepareWebSocketCustomAuthUrl = Uc
|
|
})
|
|
var Vc = b((P0, Wc) => {
|
|
var Fc = require('events'),
|
|
_m = require('util').inherits,
|
|
gm = Gi(),
|
|
q = cr()
|
|
function jc(e, t, r) {
|
|
return q(r)
|
|
? '$aws/things/' + e + '/shadow/' + t
|
|
: '$aws/things/' + e + '/shadow/' + t + '/' + r
|
|
}
|
|
function bm(e, t) {
|
|
var r = !1
|
|
return (
|
|
e[0] === '$aws' &&
|
|
e[1] === 'things' &&
|
|
e[3] === 'shadow' &&
|
|
(e[4] === 'update' || e[4] === 'get' || e[4] === 'delete') &&
|
|
(t === 'subscribe'
|
|
? (e[5] === 'accepted' || e[5] === 'rejected' || e[5] === 'delta') &&
|
|
e.length === 6 &&
|
|
(r = !0)
|
|
: e.length === 5 && (r = !0)),
|
|
r
|
|
)
|
|
}
|
|
function zi(e, t) {
|
|
if (!(this instanceof zi)) return new zi(e, t)
|
|
var r = this,
|
|
i = [{}],
|
|
n = 0,
|
|
s = 1e4,
|
|
o = !0,
|
|
f = gm.DeviceClient(e)
|
|
q(t) || q(t.operationTimeout) || (s = t.operationTimeout),
|
|
(this._handleSubscriptions = function (a, l, u, h) {
|
|
for (var c = [], d = 0, _ = l.length; d < _; d++)
|
|
for (var v = 0, m = l[d].operations.length; v < m; v++)
|
|
for (var p = 0, g = l[d].statii.length; p < g; p++)
|
|
c.push(jc(a, l[d].operations[v], l[d].statii[p]))
|
|
i[a].debug === !0 && console.log(u + ' on ' + c)
|
|
var S = []
|
|
S.push(c),
|
|
u === 'subscribe'
|
|
? (S.push({ qos: i[a].qos }),
|
|
S.push(function (x, C) {
|
|
if (!q(h)) {
|
|
if (x) {
|
|
h(x)
|
|
return
|
|
}
|
|
for (var w = [], B = 0, M = C.length; B < M; B++)
|
|
C[B].qos === 128 && w.push(C[B])
|
|
if (w.length > 0) {
|
|
h('Not all subscriptions were granted', w)
|
|
return
|
|
}
|
|
h()
|
|
}
|
|
}))
|
|
: q(h) || S.push(h),
|
|
f[u].apply(f, S)
|
|
}),
|
|
(this._handleMessages = function (a, l, u, h) {
|
|
var c = {}
|
|
try {
|
|
c = JSON.parse(h.toString())
|
|
} catch (v) {
|
|
e.debug === !0 &&
|
|
console.error("failed parsing JSON '" + h.toString() + "', " + v)
|
|
return
|
|
}
|
|
var d = c.clientToken,
|
|
_ = c.version
|
|
if ((delete c.clientToken, !q(_) && u !== 'rejected')) {
|
|
if (q(i[a].version) || _ >= i[a].version) i[a].version = _
|
|
else if (l !== 'delete' && i[a].discardStale === !0) {
|
|
e.debug === !0 &&
|
|
console.warn(
|
|
"out-of-date version '" +
|
|
_ +
|
|
"' on '" +
|
|
a +
|
|
"' (local version '" +
|
|
i[a].version +
|
|
"')",
|
|
)
|
|
return
|
|
}
|
|
}
|
|
if (u === 'delta') {
|
|
this.emit('delta', a, c)
|
|
return
|
|
}
|
|
if (q(i[a].clientToken) || i[a].clientToken !== d) {
|
|
u === 'accepted' &&
|
|
l !== 'get' &&
|
|
this.emit('foreignStateChange', a, l, c)
|
|
return
|
|
}
|
|
clearTimeout(i[a].timeout),
|
|
delete i[a].timeout,
|
|
delete i[a].clientToken,
|
|
(i[a].pending = !1),
|
|
i[a].persistentSubscribe === !1 &&
|
|
this._handleSubscriptions(
|
|
a,
|
|
[{ operations: [l], statii: ['accepted', 'rejected'] }],
|
|
'unsubscribe',
|
|
),
|
|
this.emit('status', a, u, d, c)
|
|
}),
|
|
f.on('connect', function () {
|
|
r.emit('connect')
|
|
}),
|
|
f.on('close', function () {
|
|
r.emit('close')
|
|
}),
|
|
f.on('reconnect', function () {
|
|
r.emit('reconnect')
|
|
}),
|
|
f.on('offline', function () {
|
|
r.emit('offline')
|
|
}),
|
|
f.on('error', function (a) {
|
|
r.emit('error', a)
|
|
}),
|
|
f.on('packetsend', function (a) {
|
|
r.emit('packetsend', a)
|
|
}),
|
|
f.on('packetreceive', function (a) {
|
|
r.emit('packetreceive', a)
|
|
}),
|
|
f.on('message', function (a, l) {
|
|
if (o === !0) {
|
|
var u = a.split('/')
|
|
bm(u, 'subscribe')
|
|
? i.hasOwnProperty(u[2]) && r._handleMessages(u[2], u[4], u[5], l)
|
|
: r.emit('message', a, l)
|
|
}
|
|
}),
|
|
(this._thingOperation = function (a, l, u) {
|
|
var h = null
|
|
if (i.hasOwnProperty(a))
|
|
if (i[a].pending === !1) {
|
|
i[a].pending = !0
|
|
var c
|
|
if (q(u.clientToken)) {
|
|
var d = e.clientId.length
|
|
d > 48
|
|
? (c = e.clientId.substr(d - 48) + '-' + n++)
|
|
: (c = e.clientId + '-' + n++)
|
|
} else c = u.clientToken
|
|
i[a].clientToken = c
|
|
var _ = jc(a, l)
|
|
;(i[a].timeout = setTimeout(
|
|
function (v, m) {
|
|
i[v].persistentSubscribe === !1 &&
|
|
r._handleSubscriptions(
|
|
v,
|
|
[{ operations: [l], statii: ['accepted', 'rejected'] }],
|
|
'unsubscribe',
|
|
),
|
|
(i[v].pending = !1),
|
|
delete i[v].timeout,
|
|
delete i[v].clientToken,
|
|
r.emit('timeout', v, m)
|
|
},
|
|
s,
|
|
a,
|
|
c,
|
|
)),
|
|
i[a].persistentSubscribe === !1
|
|
? this._handleSubscriptions(
|
|
a,
|
|
[{ operations: [l], statii: ['accepted', 'rejected'] }],
|
|
'subscribe',
|
|
function (v, m) {
|
|
if (!q(v) || !q(m)) {
|
|
console.warn(
|
|
'failed subscription to accepted/rejected topics',
|
|
)
|
|
return
|
|
}
|
|
q(u) ||
|
|
(!q(i[a].version) &&
|
|
i[a].enableVersioning &&
|
|
(u.version = i[a].version),
|
|
(u.clientToken = c),
|
|
f.publish(_, JSON.stringify(u), { qos: i[a].qos }),
|
|
!q(i[a]) &&
|
|
i[a].debug === !0 &&
|
|
console.log(
|
|
"publishing '" +
|
|
JSON.stringify(u) +
|
|
" on '" +
|
|
_ +
|
|
"'",
|
|
))
|
|
},
|
|
)
|
|
: (!q(i[a].version) &&
|
|
i[a].enableVersioning &&
|
|
(u.version = i[a].version),
|
|
(u.clientToken = c),
|
|
f.publish(_, JSON.stringify(u), { qos: i[a].qos }),
|
|
i[a].debug === !0 &&
|
|
console.log(
|
|
"publishing '" + JSON.stringify(u) + " on '" + _ + "'",
|
|
)),
|
|
(h = c)
|
|
} else
|
|
e.debug === !0 &&
|
|
console.error(l + ' still in progress on thing: ', a)
|
|
else
|
|
e.debug === !0 &&
|
|
console.error('attempting to ' + l + ' unknown thing: ', a)
|
|
return h
|
|
}),
|
|
(this.register = function (a, l, u) {
|
|
if (i.hasOwnProperty(a))
|
|
e.debug === !0 && console.error('thing already registered: ', a)
|
|
else {
|
|
var h = !1,
|
|
c = []
|
|
;(i[a] = {
|
|
persistentSubscribe: !0,
|
|
debug: !1,
|
|
discardStale: !0,
|
|
enableVersioning: !0,
|
|
qos: 0,
|
|
pending: !0,
|
|
}),
|
|
typeof l == 'function' && ((u = l), (l = null)),
|
|
q(l) ||
|
|
(q(l.ignoreDeltas) || (h = l.ignoreDeltas),
|
|
q(l.persistentSubscribe) ||
|
|
(i[a].persistentSubscribe = l.persistentSubscribe),
|
|
q(l.debug) || (i[a].debug = l.debug),
|
|
q(l.discardStale) || (i[a].discardStale = l.discardStale),
|
|
q(l.enableVersioning) ||
|
|
(i[a].enableVersioning = l.enableVersioning),
|
|
q(l.qos) || (i[a].qos = l.qos)),
|
|
h === !1 && c.push({ operations: ['update'], statii: ['delta'] }),
|
|
i[a].persistentSubscribe === !0 &&
|
|
c.push({
|
|
operations: ['update', 'get', 'delete'],
|
|
statii: ['accepted', 'rejected'],
|
|
}),
|
|
c.length > 0
|
|
? this._handleSubscriptions(a, c, 'subscribe', function (d, _) {
|
|
q(d) && q(_) && (i[a].pending = !1), q(u) || u(d, _)
|
|
})
|
|
: ((i[a].pending = !1), q(u) || u())
|
|
}
|
|
}),
|
|
(this.unregister = function (a) {
|
|
if (i.hasOwnProperty(a)) {
|
|
var l = []
|
|
l.push({ operations: ['update'], statii: ['delta'] }),
|
|
i[a].persistentSubscribe === !0 &&
|
|
l.push({
|
|
operations: ['update', 'get', 'delete'],
|
|
statii: ['accepted', 'rejected'],
|
|
}),
|
|
this._handleSubscriptions(a, l, 'unsubscribe'),
|
|
q(i[a].timeout) || clearTimeout(i[a].timeout),
|
|
delete i[a]
|
|
} else
|
|
e.debug === !0 &&
|
|
console.error('attempting to unregister unknown thing: ', a)
|
|
}),
|
|
(this.update = function (a, l) {
|
|
var u = null
|
|
return (
|
|
q(l.version)
|
|
? (u = r._thingOperation(a, 'update', l))
|
|
: console.error("message can't contain 'version' property"),
|
|
u
|
|
)
|
|
}),
|
|
(this.get = function (a, l) {
|
|
var u = {}
|
|
return q(l) || (u.clientToken = l), r._thingOperation(a, 'get', u)
|
|
}),
|
|
(this.delete = function (a, l) {
|
|
var u = {}
|
|
return q(l) || (u.clientToken = l), r._thingOperation(a, 'delete', u)
|
|
}),
|
|
(this.publish = function (a, l, u, h) {
|
|
f.publish(a, l, u, h)
|
|
}),
|
|
(this.subscribe = function (a, l, u) {
|
|
var h = []
|
|
typeof a == 'string'
|
|
? h.push(a)
|
|
: typeof a == 'object' && a.length && (h = a),
|
|
f.subscribe(h, l, u)
|
|
}),
|
|
(this.unsubscribe = function (a, l) {
|
|
var u = []
|
|
typeof a == 'string'
|
|
? u.push(a)
|
|
: typeof a == 'object' && a.length && (u = a),
|
|
f.unsubscribe(u, l)
|
|
}),
|
|
(this.end = function (a, l) {
|
|
f.end(a, l)
|
|
}),
|
|
(this.updateWebSocketCredentials = function (a, l, u, h) {
|
|
f.updateWebSocketCredentials(a, l, u, h)
|
|
}),
|
|
(this.updateCustomAuthHeaders = function (a) {
|
|
f.updateCustomAuthHeaders(a)
|
|
}),
|
|
(this.setConnectionStatus = function (a) {
|
|
o = a
|
|
}),
|
|
Fc.EventEmitter.call(this)
|
|
}
|
|
_m(zi, Fc.EventEmitter)
|
|
Wc.exports = zi
|
|
})
|
|
var $c = b((B0, Hc) => {
|
|
var ym = require('events'),
|
|
vm = require('util').inherits,
|
|
mm = Gi(),
|
|
F = cr()
|
|
function wm(e) {
|
|
return e[0] === '$aws' && e[1] === 'things' && e[3] === 'jobs'
|
|
}
|
|
function Dt(e, t, r) {
|
|
var i = '$aws/things/' + e + '/jobs/'
|
|
return F(r) ? (r = t) : (i += t.toString() + '/'), (i += r), i
|
|
}
|
|
function Ki(e) {
|
|
if (!(this instanceof Ki)) return new Ki(e)
|
|
var t = this,
|
|
r = [],
|
|
i = mm.DeviceClient(e)
|
|
;(this._updateJobStatus = function (n, s, o, f, a) {
|
|
typeof f == 'function' && ((a = f), (f = void 0)),
|
|
!F(e) &&
|
|
e.debug === !0 &&
|
|
console.log('updateJobStatus:', {
|
|
thingName: n,
|
|
jobId: s.id,
|
|
status: o,
|
|
statusDetails: f,
|
|
}),
|
|
i.publish(
|
|
Dt(n, s.id, 'update'),
|
|
JSON.stringify({ status: o, statusDetails: f }),
|
|
null,
|
|
function (l) {
|
|
F(l) && (s.status = { status: o, statusDetails: f }), F(a) || a(l)
|
|
},
|
|
)
|
|
}),
|
|
(this._buildJobObject = function (n, s) {
|
|
if (F(s) || F(s.jobId)) return null
|
|
var o = {}
|
|
return (
|
|
(o.id = s.jobId),
|
|
(o.document = s.jobDocument),
|
|
(o.operation = o.document.operation),
|
|
(o.status = { status: s.status, statusDetails: s.statusDetails }),
|
|
(o.inProgress = function (f, a) {
|
|
t._updateJobStatus(n, o, 'IN_PROGRESS', f, a)
|
|
}),
|
|
(o.failed = function (f, a) {
|
|
t._updateJobStatus(n, o, 'FAILED', f, a)
|
|
}),
|
|
(o.succeeded = function (f, a) {
|
|
t._updateJobStatus(n, o, 'SUCCEEDED', f, a)
|
|
}),
|
|
o
|
|
)
|
|
}),
|
|
(this._handleMessages = function (n, s) {
|
|
var o = n.split('/')
|
|
if (!wm(o)) {
|
|
t.emit('message', n, s)
|
|
return
|
|
}
|
|
var f = o[2],
|
|
a = r.find(function (c) {
|
|
return c.thingName === f
|
|
})
|
|
if (!F(a)) {
|
|
var l = {}
|
|
try {
|
|
l = JSON.parse(s.toString())
|
|
} catch (c) {
|
|
e.debug === !0 &&
|
|
console.error("failed parsing JSON '" + s.toString() + "', " + c)
|
|
return
|
|
}
|
|
if (
|
|
!(
|
|
F(l.execution) ||
|
|
F(l.execution.jobId) ||
|
|
F(l.execution.jobDocument)
|
|
)
|
|
) {
|
|
var u = l.execution.jobDocument.operation,
|
|
h = a.operations.find(function (c) {
|
|
return F(u) ? F(c.operationName) : u === c.operationName
|
|
})
|
|
;(F(h) &&
|
|
((h = a.operations.find(function (c) {
|
|
return F(c.operationName)
|
|
})),
|
|
F(h))) ||
|
|
h.callback(null, t._buildJobObject(f, l.execution))
|
|
}
|
|
}
|
|
}),
|
|
(this.subscribeToJobs = function (n, s, o) {
|
|
F(o) && ((o = s), (s = null)),
|
|
!F(e) &&
|
|
e.debug === !0 &&
|
|
console.log('subscribeToJobs:', { thingName: n, operationName: s })
|
|
var f = r.find(function (l) {
|
|
return l.thingName === n
|
|
})
|
|
F(f) &&
|
|
((f = { thingName: n, operations: [] }),
|
|
r.push(f),
|
|
i.subscribe(
|
|
[Dt(n, '$next/get/accepted'), Dt(n, 'notify-next')],
|
|
function (l, u) {
|
|
F(l) || o(l)
|
|
},
|
|
))
|
|
var a = f.operations.find(function (l) {
|
|
return F(s) ? F(l.operationName) : s === l.operationName
|
|
})
|
|
F(a)
|
|
? ((a = { operationName: s, callback: o }), f.operations.push(a))
|
|
: (a.callback = o)
|
|
}),
|
|
(this.unsubscribeFromJobs = function (n, s, o) {
|
|
F(o) && ((o = s), (s = null)),
|
|
!F(e) &&
|
|
e.debug === !0 &&
|
|
console.log('unsubscribeFromJobs:', {
|
|
thingName: n,
|
|
operationName: s,
|
|
})
|
|
var f = r.findIndex(function (u) {
|
|
return u.thingName === n
|
|
}),
|
|
a = new Error('subscription not found for given thing')
|
|
if (f < 0) {
|
|
o(a)
|
|
return
|
|
}
|
|
var l = r[f].operations.findIndex(function (u) {
|
|
return F(s) ? F(u.operationName) : s === u.operationName
|
|
})
|
|
if (l < 0) {
|
|
o(a)
|
|
return
|
|
}
|
|
if ((r[f].operations.splice(l, 1), r[f].operations.length === 0)) {
|
|
r.splice(f, 1),
|
|
i.unsubscribe(
|
|
[Dt(n, '$next/get/accepted'), Dt(n, 'notify-next')],
|
|
o,
|
|
)
|
|
return
|
|
}
|
|
o()
|
|
}),
|
|
(this.startJobNotifications = function (n, s) {
|
|
!F(e) &&
|
|
e.debug === !0 &&
|
|
console.log('startJobNotifications:', { thingName: n }),
|
|
i.publish(Dt(n, '$next', 'get'), '{}', s)
|
|
}),
|
|
i.on('connect', function () {
|
|
t.emit('connect')
|
|
}),
|
|
i.on('close', function () {
|
|
t.emit('close')
|
|
}),
|
|
i.on('reconnect', function () {
|
|
t.emit('reconnect')
|
|
}),
|
|
i.on('offline', function () {
|
|
t.emit('offline')
|
|
}),
|
|
i.on('error', function (n) {
|
|
t.emit('error', n)
|
|
}),
|
|
i.on('message', t._handleMessages),
|
|
(this.publish = i.publish),
|
|
(this.subscribe = i.subscribe),
|
|
(this.unsubscribe = i.unsubscribe),
|
|
(this.end = i.end),
|
|
(this.handleMessage = i.handleMessage),
|
|
(this.updateWebSocketCredentials = i.updateWebSocketCredentials),
|
|
(this.simulateNetworkFailure = i.simulateNetworkFailure)
|
|
}
|
|
vm(Ki, ym.EventEmitter)
|
|
Hc.exports = Ki
|
|
})
|
|
var Gc = b((A0, Yi) => {
|
|
Yi.exports.device = Gi()
|
|
Yi.exports.thingShadow = Vc()
|
|
Yi.exports.jobs = $c()
|
|
})
|
|
var Im = {}
|
|
lh(Im, { handler: () => Tm })
|
|
module.exports = ch(Im)
|
|
var zc = uh(Gc(), 1),
|
|
Sm = ['PATH', 'NODE_PATH', 'LD_LIBRARY_PATH', 'PWD', 'SHLVL'],
|
|
Em = Object.fromEntries(
|
|
Object.entries(process.env).filter(([e]) => !Sm.includes(e)),
|
|
),
|
|
wo = (e) => {
|
|
let t = process.env.AWS_REGION,
|
|
r = process.env.SLS_SERVICE,
|
|
i = process.env.SLS_STAGE,
|
|
n = `sls/${t}/${r}/${i}`
|
|
return e && (n += `/${e}`), n
|
|
},
|
|
vt = {
|
|
request: wo(`${process.env.SLS_FUNCTION}/request`),
|
|
response: wo(`${process.env.SLS_FUNCTION}/response`),
|
|
heartbeat: wo('_heartbeat'),
|
|
},
|
|
kr = new Map(),
|
|
mt = new zc.default.device({
|
|
protocol: 'wss',
|
|
host: process.env.SLS_IOT_ENDPOINT,
|
|
})
|
|
mt.on('connect', () => {
|
|
console.log('Successfully connected to AWS IoT')
|
|
})
|
|
mt.on('close', (...e) => {
|
|
console.log('AWS IoT connection closed'), console.log(e)
|
|
})
|
|
mt.on('error', (...e) => {
|
|
console.error('AWS IoT connection error occurred'), console.error(e)
|
|
})
|
|
mt.on('message', async (e, t) => {
|
|
let r = JSON.parse(t?.toString() || '{}')
|
|
console.log('Received message from AWS IoT:'),
|
|
console.log(e),
|
|
e === vt.heartbeat && kr.set(vt.heartbeat, !0),
|
|
e === vt.response && r.requestId && kr.set(r.requestId, r)
|
|
})
|
|
mt.subscribe(vt.heartbeat, { qos: 1 })
|
|
mt.subscribe(vt.response, { qos: 1 })
|
|
var So = (e = 1e3) =>
|
|
new Promise((t) => {
|
|
setTimeout(() => t(), e)
|
|
}),
|
|
Kc = async () =>
|
|
(await Promise.race([Yc(vt.heartbeat), So(2e3)]))
|
|
? (await So(2e3), await Kc())
|
|
: "Dev Mode Disconnected: This AWS Lambda function is instrumented with Serverless Framework's Dev Mode but the Dev Mode session is no longer active. Run `serverless dev` to reconnect, or `serverless deploy` to remove Dev Mode's instrumentation and restore the original code.",
|
|
xm = async (e) => {
|
|
let { response: t, error: r } = await Yc(e)
|
|
if (r) {
|
|
console.error(
|
|
'Error occurred during lambda invocation on the local machine:',
|
|
)
|
|
let i = new Error(r.message)
|
|
throw ((i.stack = r.stack), (i.name = r.name), i)
|
|
}
|
|
return t
|
|
},
|
|
Yc = async (e) => {
|
|
for (; !kr.get(e); ) await So(100)
|
|
let t = kr.get(e)
|
|
return kr.delete(e), t
|
|
},
|
|
Cm = async (e, t) =>
|
|
new Promise((r, i) => {
|
|
mt.publish(e, t ? JSON.stringify(t) : '{}', { qos: 1 }, (n) => {
|
|
n
|
|
? (console.error(
|
|
`Failed to publish message to AWS IoT: ${n.message}`,
|
|
),
|
|
i(n))
|
|
: (console.log('Message successfully published to AWS IoT topic:'),
|
|
console.log(e),
|
|
r(t))
|
|
})
|
|
}),
|
|
Tm = async (e, t) => {
|
|
let {
|
|
functionName: r,
|
|
functionVersion: i,
|
|
memoryLimitInMB: n,
|
|
logGroupName: s,
|
|
logStreamName: o,
|
|
clientContext: f,
|
|
identity: a,
|
|
invokedFunctionArn: l,
|
|
awsRequestId: u,
|
|
callbackWaitsForEmptyEventLoop: h,
|
|
} = t
|
|
return (
|
|
await Cm(vt.request, {
|
|
event: e,
|
|
environment: Em,
|
|
context: {
|
|
awsRequestId: u,
|
|
functionName: r,
|
|
functionVersion: i,
|
|
memoryLimitInMB: n,
|
|
logGroupName: s,
|
|
logStreamName: o,
|
|
clientContext: f,
|
|
identity: a,
|
|
invokedFunctionArn: l,
|
|
callbackWaitsForEmptyEventLoop: h,
|
|
},
|
|
}),
|
|
await Promise.race([xm(u), Kc()])
|
|
)
|
|
}
|
|
0 && (module.exports = { handler })
|
|
/*! Bundled license information:
|
|
|
|
safe-buffer/index.js:
|
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
|
|
ws/lib/BufferUtil.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
|
|
ws/lib/Validation.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
|
|
ws/lib/ErrorCodes.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
|
|
ws/lib/Receiver.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
|
|
ws/lib/Sender.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
|
|
ws/lib/WebSocket.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
|
|
ws/lib/WebSocketServer.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
|
|
ws/index.js:
|
|
(*!
|
|
* ws: a node.js websocket client
|
|
* Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
* MIT Licensed
|
|
*)
|
|
*/
|