chat4app-client-angular 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -24
- package/bundles/chat4app-client-angular.umd.js +2533 -2508
- package/bundles/chat4app-client-angular.umd.js.map +1 -1
- package/bundles/chat4app-client-angular.umd.min.js +1 -1
- package/bundles/chat4app-client-angular.umd.min.js.map +1 -1
- package/chat4app-client-angular.d.ts +4 -4
- package/chat4app-client-angular.metadata.json +1 -1
- package/esm2015/chat4app-client-angular.js +4 -4
- package/esm2015/lib/chat4app-client-angular.component.js +18 -18
- package/esm2015/lib/chat4app-client-angular.module.js +12 -12
- package/esm2015/lib/chat4app-client-angular.service.js +704 -679
- package/esm2015/lib/nats.min.js +695 -695
- package/esm2015/public-api.js +7 -7
- package/fesm2015/chat4app-client-angular.js +1416 -1391
- package/fesm2015/chat4app-client-angular.js.map +1 -1
- package/lib/chat4app-client-angular.component.d.ts +5 -5
- package/lib/chat4app-client-angular.module.d.ts +2 -2
- package/lib/chat4app-client-angular.service.d.ts +192 -197
- package/lib/chat4app-client-angular.service.d.ts.map +1 -1
- package/lib/nats.min.d.ts +3 -3
- package/package.json +1 -1
- package/public-api.d.ts +3 -3
|
@@ -42,1413 +42,1438 @@ function commonjsRequire (target) {
|
|
|
42
42
|
throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
/**
|
|
46
|
-
* Skipped minification because the original files appears to be already minified.
|
|
47
|
-
* Original file: /npm/@provide/nats.ws@1.0.6/dist/umd/index.js
|
|
48
|
-
*
|
|
49
|
-
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
45
|
+
/**
|
|
46
|
+
* Skipped minification because the original files appears to be already minified.
|
|
47
|
+
* Original file: /npm/@provide/nats.ws@1.0.6/dist/umd/index.js
|
|
48
|
+
*
|
|
49
|
+
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
52
|
var nats_min = createCommonjsModule(function (module, exports) {
|
|
53
|
-
!function (t, e) { "object" == 'object' && "object" == 'object' ? module.exports = e() : "function" == typeof undefined && undefined.amd ? undefined([], e) : "object" == 'object' ? exports.nats = e() : t.nats = e(); }(commonjsGlobal, (function () {
|
|
54
|
-
return function (t) { var e = {}; function r(n) { if (e[n])
|
|
55
|
-
return e[n].exports; var i = e[n] = { i: n, l: !1, exports: {} }; return t[n].call(i.exports, i, i.exports, r), i.l = !0, i.exports; } return r.m = t, r.c = e, r.d = function (t, e, n) { r.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: n }); }, r.r = function (t) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t, "__esModule", { value: !0 }); }, r.t = function (t, e) { if (1 & e && (t = r(t)), 8 & e)
|
|
56
|
-
return t; if (4 & e && "object" == typeof t && t && t.__esModule)
|
|
57
|
-
return t; var n = Object.create(null); if (r.r(n), Object.defineProperty(n, "default", { enumerable: !0, value: t }), 2 & e && "string" != typeof t)
|
|
58
|
-
for (var i in t)
|
|
59
|
-
r.d(n, i, function (e) { return t[e]; }.bind(null, i)); return n; }, r.n = function (t) { var e = t && t.__esModule ? function () { return t.default; } : function () { return t; }; return r.d(e, "a", e), e; }, r.o = function (t, e) { return Object.prototype.hasOwnProperty.call(t, e); }, r.p = "", r(r.s = 12); }([function (t, e, r) {
|
|
60
|
-
"use strict";
|
|
61
|
-
var n;
|
|
62
|
-
r.d(e, "a", (function () { return n; })), r.d(e, "b", (function () { return i; })), r.d(e, "c", (function () { return s; })), function (t) { t.BAD_AUTHENTICATION = "BAD_AUTHENTICATION", t.BAD_SUBJECT = "BAD_SUBJECT", t.CONNECTION_CLOSED = "CONNECTION_CLOSED", t.CONNECTION_DRAINING = "CONNECTION_DRAINING", t.CONNECTION_REFUSED = "CONNECTION_REFUSED", t.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", t.INVALID_PAYLOAD_TYPE = "INVALID_PAYLOAD", t.UNKNOWN = "UNKNOWN_ERROR", t.WSS_REQUIRED = "WSS_REQUIRED", t.SUB_CLOSED = "SUB_CLOSED", t.SUB_DRAINING = "SUB_DRAINING", t.PERMISSIONS_VIOLATION = "PERMISSIONS_VIOLATION", t.AUTHORIZATION_VIOLATION = "AUTHORIZATION_VIOLATION", t.NATS_PROTOCOL_ERR = "NATS_PROTOCOL_ERR"; }(n || (n = {}));
|
|
63
|
-
class i {
|
|
64
|
-
constructor() { this.messages = {}, this.messages[n.BAD_AUTHENTICATION] = "User and Token can not both be provided", this.messages[n.BAD_SUBJECT] = "Subject must be supplied", this.messages[n.CONNECTION_CLOSED] = "Connection closed", this.messages[n.CONNECTION_CLOSED] = "Connection closed", this.messages[n.CONNECTION_REFUSED] = "Connection refused", this.messages[n.CONNECTION_TIMEOUT] = "Connection timeout", this.messages[n.CONNECTION_DRAINING] = "Connection draining", this.messages[n.INVALID_PAYLOAD_TYPE] = "Invalid payload type - payloads can be 'binary', 'string', or 'json'", this.messages[n.SUB_CLOSED] = "Subscription closed", this.messages[n.SUB_DRAINING] = "Subscription draining", this.messages[n.WSS_REQUIRED] = "TLS is required, therefore a secure websocket connection is also required"; }
|
|
65
|
-
static getMessage(t) { return i.messages.getMessage(t); }
|
|
66
|
-
getMessage(t) { let e = this.messages[t]; return e || (e = t), e; }
|
|
67
|
-
}
|
|
68
|
-
i.messages = new i;
|
|
69
|
-
class s extends Error {
|
|
70
|
-
constructor(t, e, r) { super(t), this.name = "NatsError", this.message = t, this.code = e, this.chainedError = r; }
|
|
71
|
-
static errorForCode(t, e) { let r = i.getMessage(t); return new s(r, t, e); }
|
|
72
|
-
}
|
|
73
|
-
}, function (t, e, r) {
|
|
74
|
-
"use strict";
|
|
75
|
-
r.d(e, "d", (function () { return u; })), r.d(e, "b", (function () { return a; })), r.d(e, "c", (function () { return h; })), r.d(e, "a", (function () { return c; })), r.d(e, "e", (function () { return f; })), r.d(e, "f", (function () { return l; }));
|
|
76
|
-
var n = r(2);
|
|
77
|
-
let i = n.a.fromAscii("\r\n"), s = new Uint8Array(i)[0], o = new Uint8Array(i)[1];
|
|
78
|
-
function u(t) { return t instanceof ArrayBuffer; }
|
|
79
|
-
function a(t, ...e) { for (let r = 0; r < e.length; r++) {
|
|
80
|
-
let n = e[r];
|
|
81
|
-
Object.keys(n).forEach((function (e) { t[e] = n[e]; }));
|
|
82
|
-
} return t; }
|
|
83
|
-
function h(t) { let e = function (t) { let e = new Uint8Array(t); for (let t = 0; t < e.byteLength; t++) {
|
|
84
|
-
let r = t + 1;
|
|
85
|
-
if (e.byteLength > r && e[t] === s && e[r] === o)
|
|
86
|
-
return r + 1;
|
|
87
|
-
} return -1; }(t); if (e) {
|
|
88
|
-
let r = new Uint8Array(t).slice(0, e);
|
|
89
|
-
return String.fromCharCode.apply(null, r);
|
|
90
|
-
} return ""; }
|
|
91
|
-
function c(t, e) { let r = n.a.fromAscii(t); return e && (r = n.a.concat(r, e, i)), r; }
|
|
92
|
-
function f(t) { return Array.isArray(t) ? Promise.resolve(t).then(d) : Promise.reject(new TypeError("argument requires an array of promises")); }
|
|
93
|
-
function l(t) { const e = t.split(""), r = []; for (var n = 0; n < e.length; n++)
|
|
94
|
-
r.push(e[n].charCodeAt(0)); return new Uint8Array(r); }
|
|
95
|
-
function d(t) { return Promise.all(t.map(t => Promise.resolve(t).then(p, p))); }
|
|
96
|
-
function p(t) { return t; }
|
|
97
|
-
}, function (t, e, r) {
|
|
98
|
-
"use strict";
|
|
99
|
-
r.d(e, "a", (function () { return n; }));
|
|
100
|
-
class n {
|
|
101
|
-
constructor() { this.buffers = [], this.byteLength = 0; }
|
|
102
|
-
static concat(...t) { let e = 0; for (let r = 0; r < t.length; r++)
|
|
103
|
-
e += t[r].byteLength; let r = new Uint8Array(e), n = 0; for (let e = 0; e < t.length; e++)
|
|
104
|
-
r.set(new Uint8Array(t[e]), n), n += t[e].byteLength; return r.buffer; }
|
|
105
|
-
static fromAscii(t) { t || (t = ""); let e = new ArrayBuffer(t.length), r = new Uint8Array(e); for (let e = 0; e < t.length; e++)
|
|
106
|
-
r[e] = t.charCodeAt(e); return e; }
|
|
107
|
-
static toAscii(t) { return String.fromCharCode.apply(null, new Uint8Array(t)); }
|
|
108
|
-
pack() { if (this.buffers.length > 1) {
|
|
109
|
-
let t = this.buffers.splice(0, this.buffers.length);
|
|
110
|
-
this.buffers.push(n.concat(...t));
|
|
111
|
-
} }
|
|
112
|
-
drain(t) { if (this.buffers.length) {
|
|
113
|
-
this.pack();
|
|
114
|
-
let e = this.buffers.pop();
|
|
115
|
-
if (e) {
|
|
116
|
-
let r = this.byteLength;
|
|
117
|
-
(void 0 === t || t > r) && (t = r);
|
|
118
|
-
let n = e.slice(0, t);
|
|
119
|
-
return r > t && this.buffers.push(e.slice(t)), this.byteLength = r - t, n;
|
|
120
|
-
}
|
|
121
|
-
} return new Uint8Array(0).buffer; }
|
|
122
|
-
fill(t) { t && (this.buffers.push(t), this.byteLength += t.byteLength); }
|
|
123
|
-
peek() { return this.buffers.length ? (this.pack(), this.buffers[0]) : new Uint8Array(0).buffer; }
|
|
124
|
-
size() { return this.byteLength; }
|
|
125
|
-
length() { return this.buffers.length; }
|
|
126
|
-
}
|
|
127
|
-
}, function (t, e, r) {
|
|
128
|
-
"use strict";
|
|
129
|
-
var n;
|
|
130
|
-
r.d(e, "a", (function () { return n; })), function (t) { t.STRING = "string", t.JSON = "json", t.BINARY = "binary"; }(n || (n = {}));
|
|
131
|
-
}, function (t, e, r) {
|
|
132
|
-
"use strict";
|
|
133
|
-
(function (t) { r.d(e, "d", (function () { return c; })), r.d(e, "i", (function () { return m; })), r.d(e, "a", (function () { return w; })), r.d(e, "k", (function () { return A; })), r.d(e, "j", (function () { return E; })), r.d(e, "f", (function () { return O; })), r.d(e, "g", (function () { return N; })), r.d(e, "c", (function () { return C; })), r.d(e, "h", (function () { return T; })), r.d(e, "b", (function () { return S; })), r.d(e, "e", (function () { return I; })); var n = r(3), i = r(5), s = r(0), o = r(1), u = r(6), a = r(2); let h; var c; !function (t) { t[t.CLOSED = -1] = "CLOSED", t[t.AWAITING_CONTROL = 0] = "AWAITING_CONTROL", t[t.AWAITING_MSG_PAYLOAD = 1] = "AWAITING_MSG_PAYLOAD"; }(c || (c = {})); const f = /^MSG\s+([^\s\r\n]+)\s+([^\s\r\n]+)\s+(([^\s\r\n]+)[^\S\r\n]+)?(\d+)\r\n/i, l = /^\+OK\s*\r\n/i, d = /^-ERR\s+('.+')?\r\n/i, p = /^PING\r\n/i, g = /^PONG\r\n/i, b = /^INFO\s+([^\r\n]+)\r\n/i, y = "\r\n".length; function m() { return h || (h = new u.a), `_INBOX.${h.next()}`; } class w {
|
|
134
|
-
constructor(t) { this.lang = "javascript", this.pedantic = !1, this.protocol = 1, this.verbose = !1, (t = t || {}).token && (this.auth_token = t.token), t.noEcho && (this.echo = !1), t.userJWT && ("function" == typeof t.userJWT ? this.jwt = t.userJWT() : this.jwt = t.userJWT), Object(o.b)(this, t); }
|
|
135
|
-
} function A() { return { sid: 0, subject: "", received: 0 }; } function E() { return { token: "", subject: "", received: 0, max: 1 }; } class O {
|
|
136
|
-
constructor(t, e) { this.token = t.token, this.protocol = e; }
|
|
137
|
-
cancel() { this.protocol.cancelRequest(this.token, 0); }
|
|
138
|
-
} class N {
|
|
139
|
-
constructor(t, e) { this.sid = t.sid, this.protocol = e; }
|
|
140
|
-
unsubscribe(t) { this.protocol.unsubscribe(this.sid, t); }
|
|
141
|
-
hasTimeout() { let t = this.protocol.subscriptions.get(this.sid); return null !== t && null !== t.timeout; }
|
|
142
|
-
cancelTimeout() { let t = this.protocol.subscriptions.get(this.sid); null !== t && null !== t.timeout && (clearTimeout(t.timeout), t.timeout = null); }
|
|
143
|
-
setTimeout(t, e) { let r = this.protocol.subscriptions.get(this.sid); return null !== r && (r.timeout && (clearTimeout(r.timeout), r.timeout = null), r.timeout = setTimeout(e, t), !0); }
|
|
144
|
-
getReceived() { let t = this.protocol.subscriptions.get(this.sid); return t ? t.received : 0; }
|
|
145
|
-
drain() { return this.protocol.drainSubscription(this.sid); }
|
|
146
|
-
isDraining() { let t = this.protocol.subscriptions.get(this.sid); return !!t && t.draining; }
|
|
147
|
-
isCancelled() { return null === this.protocol.subscriptions.get(this.sid); }
|
|
148
|
-
} class C {
|
|
149
|
-
constructor() { this.reqs = {}, this.length = 0; }
|
|
150
|
-
init() { return this.baseInbox = `${m()}.`, this.baseInbox; }
|
|
151
|
-
add(t) { isNaN(t.received) || (t.received = 0), this.length++, this.reqs[t.token] = t; }
|
|
152
|
-
get(t) { return t in this.reqs ? this.reqs[t] : null; }
|
|
153
|
-
cancel(t) { t && t.timeout && (clearTimeout(t.timeout), t.timeout = null), t.token in this.reqs && (delete this.reqs[t.token], this.length--); }
|
|
154
|
-
getToken(t) { let e = t.subject || ""; return 0 === e.indexOf(this.baseInbox) ? e.substring(this.baseInbox.length) : null; }
|
|
155
|
-
dispatcher() { let t = this; return function (e) { let r = t.getToken(e); if (r) {
|
|
156
|
-
let n = t.get(r);
|
|
157
|
-
n && (n.received++, n.callback(e), n.max && n.received >= n.max && t.cancel(n));
|
|
158
|
-
} }; }
|
|
159
|
-
} class T {
|
|
160
|
-
constructor() { this.subs = {}, this.sidCounter = 0, this.length = 0; }
|
|
161
|
-
add(t) { return this.sidCounter++, this.length++, t.sid = this.sidCounter, this.subs[t.sid] = t, t; }
|
|
162
|
-
setMux(t) { return this.mux = t, t; }
|
|
163
|
-
getMux() { return this.mux; }
|
|
164
|
-
get(t) { return t in this.subs ? this.subs[t] : null; }
|
|
165
|
-
all() { let t = []; for (let e in this.subs) {
|
|
166
|
-
let r = this.subs[e];
|
|
167
|
-
t.push(r);
|
|
168
|
-
} return t; }
|
|
169
|
-
cancel(t) { t && t.timeout && (clearTimeout(t.timeout), t.timeout = null), t.sid in this.subs && (delete this.subs[t.sid], this.length--); }
|
|
170
|
-
} class S {
|
|
171
|
-
constructor(t, e = "string") { this.msg = {}, this.msg.subject = t[1], this.msg.sid = parseInt(t[2], 10), this.msg.reply = t[4], this.msg.size = parseInt(t[5], 10), this.length = this.msg.size + y, this.payload = e; }
|
|
172
|
-
fill(e) { if (this.buf ? this.buf = a.a.concat(this.buf, e) : this.buf = e, this.length -= e.byteLength, 0 === this.length) {
|
|
173
|
-
switch (this.msg.data = this.buf.slice(0, this.buf.byteLength - 2), this.payload) {
|
|
174
|
-
case n.a.JSON:
|
|
175
|
-
this.msg.data = t.from(this.msg.data).toString("utf8"), this.msg.data = JSON.parse(this.msg.data);
|
|
176
|
-
break;
|
|
177
|
-
case n.a.STRING:
|
|
178
|
-
this.msg.data = t.from(this.msg.data).toString("utf8");
|
|
179
|
-
break;
|
|
180
|
-
case n.a.BINARY:
|
|
181
|
-
}
|
|
182
|
-
this.buf = null;
|
|
183
|
-
} }
|
|
184
|
-
} class I {
|
|
185
|
-
constructor(t, e) { this.infoReceived = !1, this.payload = null, this.pongs = [], this.pout = 0, this.state = c.AWAITING_CONTROL, this.noMorePublishing = !1, this.options = t, this.clientHandlers = e, this.subscriptions = new T, this.muxSubscriptions = new C, this.inbound = new a.a, this.outbound = new a.a; }
|
|
186
|
-
static connect(t, e) { return new Promise((r, n) => { let o = new I(t, e); o.connectError = n; let u = t.connectTimeout || 1e4, a = new Promise((t, e) => { let r = setTimeout(() => { e(s.c.errorForCode(s.a.CONNECTION_TIMEOUT)); }, u); o.pongs.push(() => { clearTimeout(r), t(!0); }); }); i.a.connect(t, o, t.debug).then(t => { o.transport = t; }).catch(t => { o.connectError = null, n(t); }), a.then(() => { o.connectError = null, r(o); }).catch(t => { o.connectError = null, n(t); }); }); }
|
|
187
|
-
static toError(t) { let e = t ? t.toLowerCase() : ""; return -1 !== e.indexOf("permissions violation") ? new s.c(t, s.a.PERMISSIONS_VIOLATION) : -1 !== e.indexOf("authorization violation") ? new s.c(t, s.a.AUTHORIZATION_VIOLATION) : new s.c(t, s.a.NATS_PROTOCOL_ERR); }
|
|
188
|
-
processInbound() { let t = null; for (; this.inbound.size();) {
|
|
189
|
-
switch (this.state) {
|
|
190
|
-
case c.CLOSED: return;
|
|
191
|
-
case c.AWAITING_CONTROL:
|
|
192
|
-
let e = this.inbound.peek(), r = Object(o.c)(e);
|
|
193
|
-
if (t = f.exec(r))
|
|
194
|
-
this.payload = new S(t, this.options.payload), this.state = c.AWAITING_MSG_PAYLOAD;
|
|
195
|
-
else if (t = l.exec(r))
|
|
196
|
-
;
|
|
197
|
-
else {
|
|
198
|
-
if (t = d.exec(r))
|
|
199
|
-
return void this.processError(t[1]);
|
|
200
|
-
if (t = g.exec(r)) {
|
|
201
|
-
this.pout = 0;
|
|
202
|
-
let t = this.pongs.shift();
|
|
203
|
-
t && t();
|
|
204
|
-
}
|
|
205
|
-
else if (t = p.exec(r))
|
|
206
|
-
this.transport.write(Object(o.a)("PONG \r\n"));
|
|
207
|
-
else {
|
|
208
|
-
if (!(t = b.exec(r)))
|
|
209
|
-
return;
|
|
210
|
-
if (!this.infoReceived) {
|
|
211
|
-
if (JSON.parse(t[1]).tls_required && !this.transport.isSecure())
|
|
212
|
-
return void this.handleError(s.c.errorForCode(s.a.WSS_REQUIRED));
|
|
213
|
-
let e = JSON.stringify(new w(this.options));
|
|
214
|
-
this.transport.write(Object(o.a)(`CONNECT ${e}\r\n`)), this.sendSubscriptions(), this.transport.write(Object(o.a)("PING \r\n")), this.infoReceived = !0, this.flushPending();
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
break;
|
|
219
|
-
case c.AWAITING_MSG_PAYLOAD:
|
|
220
|
-
if (!this.payload)
|
|
221
|
-
break;
|
|
222
|
-
if (this.inbound.size() < this.payload.length) {
|
|
223
|
-
let t = this.inbound.drain();
|
|
224
|
-
return void this.payload.fill(t);
|
|
225
|
-
}
|
|
226
|
-
let n = this.inbound.drain(this.payload.length);
|
|
227
|
-
this.payload.fill(n);
|
|
228
|
-
try {
|
|
229
|
-
this.processMsg();
|
|
230
|
-
}
|
|
231
|
-
catch (t) { }
|
|
232
|
-
this.state = c.AWAITING_CONTROL, this.payload = null;
|
|
233
|
-
}
|
|
234
|
-
if (t) {
|
|
235
|
-
let e = t[0].length;
|
|
236
|
-
e >= this.inbound.size() ? this.inbound.drain() : this.inbound.drain(e), t = null;
|
|
237
|
-
}
|
|
238
|
-
} }
|
|
239
|
-
processMsg() { if (!this.payload || !this.subscriptions.sidCounter)
|
|
240
|
-
return; let t = this.payload, e = this.subscriptions.get(t.msg.sid); e && (e.received += 1, e.timeout && void 0 === e.max && (clearTimeout(e.timeout), e.timeout = null), e.callback && e.callback(t.msg), void 0 !== e.max && e.received >= e.max && this.unsubscribe(e.sid)); }
|
|
241
|
-
sendCommand(t) { let e; e = "string" == typeof t ? Object(o.f)(t) : t, t && this.outbound.fill(e), 1 === this.outbound.length() ? setTimeout(() => { this.flushPending(); }) : this.outbound.size() > 8192 && this.flushPending(); }
|
|
242
|
-
publish(e, r, n) { if (this.isClosed())
|
|
243
|
-
throw s.c.errorForCode(s.a.CONNECTION_CLOSED); if (this.noMorePublishing)
|
|
244
|
-
throw s.c.errorForCode(s.a.CONNECTION_DRAINING); let i, u = t.byteLength(r); i = (n = n || "") ? `PUB ${e} ${n} ${u}\r\n` : `PUB ${e} ${u}\r\n`, this.sendCommand(Object(o.a)(i, r)); }
|
|
245
|
-
request(t) { return this.initMux(), this.muxSubscriptions.add(t), new O(t, this); }
|
|
246
|
-
subscribe(t) { let e = this.subscriptions.add(t); return e.queue ? this.sendCommand(`SUB ${e.subject} ${e.queue} ${e.sid}\r\n`) : this.sendCommand(`SUB ${e.subject} ${e.sid}\r\n`), new N(e, this); }
|
|
247
|
-
unsubscribe(t, e) { if (!t || this.isClosed())
|
|
248
|
-
return; let r = this.subscriptions.get(t); r && (e ? this.sendCommand(`UNSUB ${t} ${e}\r\n`) : this.sendCommand(`UNSUB ${t}\r\n`), r.max = e, (void 0 === r.max || r.received >= r.max) && this.subscriptions.cancel(r)); }
|
|
249
|
-
cancelRequest(t, e) { if (!t || this.isClosed())
|
|
250
|
-
return; let r = this.muxSubscriptions.get(t); r && (r.max = e, (void 0 === r.max || r.received >= r.max) && this.muxSubscriptions.cancel(r)); }
|
|
251
|
-
flush(t) { this.pongs.push(t), this.sendCommand("PING \r\n"); }
|
|
252
|
-
processError(t) { let e = { error: I.toError(t) }; this.errorHandler(e); }
|
|
253
|
-
sendSubscriptions() { let t = []; this.subscriptions.all().forEach(e => { e.queue ? t.push(`SUB ${e.subject} ${e.queue} ${e.sid} \r\n`) : t.push(`SUB ${e.subject} ${e.sid} \r\n`); }), t.length && this.transport.write(Object(o.a)(t.join(""))); }
|
|
254
|
-
openHandler(t) { }
|
|
255
|
-
closeHandler(t) { this.close(), this.clientHandlers.closeHandler(); }
|
|
256
|
-
errorHandler(t) { let e; t && (e = t.error), this.handleError(e); }
|
|
257
|
-
messageHandler(t) { this.inbound.fill(t.data), this.processInbound(); }
|
|
258
|
-
close() { this.transport.close(), this.state = c.CLOSED; }
|
|
259
|
-
isClosed() { return this.transport.isClosed(); }
|
|
260
|
-
drain() { let t = this.subscriptions.all(), e = []; return t.forEach(t => { let r = this.drainSubscription(t.sid); e.push(r); }), new Promise(t => { Object(o.e)(e).then(e => { this.noMorePublishing = !0, setTimeout(() => { this.close(), t(e); }); }).catch(() => { }); }); }
|
|
261
|
-
drainSubscription(t) { if (this.isClosed())
|
|
262
|
-
return Promise.reject(s.c.errorForCode(s.a.CONNECTION_CLOSED)); if (!t)
|
|
263
|
-
return Promise.reject(s.c.errorForCode(s.a.SUB_CLOSED)); let e = this.subscriptions.get(t); if (!e)
|
|
264
|
-
return Promise.reject(s.c.errorForCode(s.a.SUB_CLOSED)); if (e.draining)
|
|
265
|
-
return Promise.reject(s.c.errorForCode(s.a.SUB_DRAINING)); let r = e; return new Promise(t => { r.draining = !0, this.sendCommand(`UNSUB ${r.sid}\r\n`), this.flush(() => { this.subscriptions.cancel(r), t(r); }); }); }
|
|
266
|
-
flushPending() { if (this.infoReceived && this.outbound.size()) {
|
|
267
|
-
let t = this.outbound.drain();
|
|
268
|
-
this.transport.write(t);
|
|
269
|
-
} }
|
|
270
|
-
initMux() { if (!this.subscriptions.getMux()) {
|
|
271
|
-
let t = this.muxSubscriptions.init(), e = { sid: 0, subject: "", received: 0 };
|
|
272
|
-
e.subject = `${t}*`, e.callback = this.muxSubscriptions.dispatcher(), this.subscriptions.setMux(e), this.subscribe(e);
|
|
273
|
-
} }
|
|
274
|
-
handleError(t) { this.connectError && (this.connectError(t), this.connectError = null), this.close(), this.clientHandlers.errorHandler(t); }
|
|
275
|
-
} }).call(this, r(7).Buffer);
|
|
276
|
-
}, function (t, e, r) {
|
|
277
|
-
"use strict";
|
|
278
|
-
r.d(e, "a", (function () { return i; }));
|
|
279
|
-
var n = r(0);
|
|
280
|
-
class i {
|
|
281
|
-
constructor(t) { this.stream = null, this.closed = !1, this.debug = !1, this.listeners = {}, this.handlers = t; }
|
|
282
|
-
static connect(t, e, r = !1) { return new Promise((s, o) => { let u, a = new i(e); a.debug = r, a.stream = new WebSocket(t.url), a.stream.binaryType = "arraybuffer", a.listeners = {}, a.stream.onclose = function (t) { a.trace("ws closed", t), a.closed || (u ? (a.handlers.closeHandler(t), a.close()) : (clearTimeout(void 0), o(n.c.errorForCode(n.a.CONNECTION_CLOSED)))); }, a.stream.onerror = function (t) { let e; if (t && (e = t.error, !e)) {
|
|
283
|
-
let r = t.message;
|
|
284
|
-
e = r ? new n.c(r, n.a.UNKNOWN) : u ? n.c.errorForCode(n.a.UNKNOWN) : n.c.errorForCode(n.a.CONNECTION_REFUSED);
|
|
285
|
-
} a.trace("ws error", e), a.closed || (a && a.close(), u ? a.handlers.errorHandler(t) : o(e)); }, a.stream.onopen = function () { a.trace("ws open"); }, a.stream.onmessage = function (t) { a.trace(">", [t.data]), u ? a.handlers.messageHandler(t) : (u = !0, s(a), setTimeout((function () { a.handlers.messageHandler(t); }), 100)); }; }); }
|
|
286
|
-
isClosed() { return this.closed; }
|
|
287
|
-
isConnected() { return null !== this.stream && this.stream.readyState === WebSocket.OPEN; }
|
|
288
|
-
write(t) { this.stream && this.isConnected() && (this.trace("<", [t]), this.stream.send(t)); }
|
|
289
|
-
destroy() { this.stream && (this.closed && (this.stream.onclose = null, this.stream.onerror = null, this.stream.onopen = null, this.stream.onmessage = null), this.stream.readyState !== WebSocket.CLOSED && this.stream.readyState !== WebSocket.CLOSING && this.stream.close(1e3), this.stream = null); }
|
|
290
|
-
close() { this.closed = !0, this.stream && this.stream.bufferedAmount > 0 ? setTimeout(this.close.bind(this), 100) : this.destroy(); }
|
|
291
|
-
trace(...t) { this.debug && console.log(t); }
|
|
292
|
-
isSecure() { if (this.stream) {
|
|
293
|
-
return "wss:" === new URL(this.stream.url).protocol.toLowerCase();
|
|
294
|
-
} return !1; }
|
|
295
|
-
}
|
|
296
|
-
}, function (t, e, r) {
|
|
297
|
-
"use strict";
|
|
298
|
-
r.d(e, "a", (function () { return s; }));
|
|
299
|
-
const n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
300
|
-
let i;
|
|
301
|
-
class s {
|
|
302
|
-
constructor() { this.buf = new Uint8Array(22), this.init(); }
|
|
303
|
-
init() { "crypto" in Object({}) && Object({}).crypto.getRandomValues ? i = Object({}).crypto : "msCrypto" in Object({}) && Object({}).msCrypto.getRandomValues && (i = Object({}).msCrypto), i || (i = { getRandomValues: function (t) { for (let e = 0; e < t.length; e++)
|
|
304
|
-
t[e] = Math.floor(255 * Math.random()); } }), this.setPre(), this.initSeqAndInc(), this.fillSeq(); }
|
|
305
|
-
initSeqAndInc() { this.seq = Math.floor(0xcfd41b9100000 * Math.random()), this.inc = Math.floor(300 * Math.random() + 33); }
|
|
306
|
-
setPre() { let t = new Uint8Array(12); i.getRandomValues(t); for (let e = 0; e < 12; e++) {
|
|
307
|
-
let r = t[e] % 36;
|
|
308
|
-
this.buf[e] = n.charCodeAt(r);
|
|
309
|
-
} }
|
|
310
|
-
fillSeq() { let t = this.seq; for (let e = 21; e >= 12; e--)
|
|
311
|
-
this.buf[e] = n.charCodeAt(t % 36), t = Math.floor(t / 36); }
|
|
312
|
-
next() { return this.seq += this.inc, this.seq > 0xcfd41b9100000 && (this.setPre(), this.initSeqAndInc()), this.fillSeq(), String.fromCharCode.apply(String, this.buf); }
|
|
313
|
-
reset() { this.init(); }
|
|
314
|
-
}
|
|
315
|
-
}, function (t, e, r) {
|
|
316
|
-
"use strict";
|
|
317
|
-
(function (t) {
|
|
318
|
-
/*!
|
|
319
|
-
* The buffer module from node.js, for the browser.
|
|
320
|
-
*
|
|
321
|
-
* @author Feross Aboukhadijeh <http://feross.org>
|
|
322
|
-
* @license MIT
|
|
323
|
-
*/
|
|
324
|
-
var n = r(9), i = r(10), s = r(11);
|
|
325
|
-
function o() { return a.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823; }
|
|
326
|
-
function u(t, e) { if (o() < e)
|
|
327
|
-
throw new RangeError("Invalid typed array length"); return a.TYPED_ARRAY_SUPPORT ? (t = new Uint8Array(e)).__proto__ = a.prototype : (null === t && (t = new a(e)), t.length = e), t; }
|
|
328
|
-
function a(t, e, r) { if (!(a.TYPED_ARRAY_SUPPORT || this instanceof a))
|
|
329
|
-
return new a(t, e, r); if ("number" == typeof t) {
|
|
330
|
-
if ("string" == typeof e)
|
|
331
|
-
throw new Error("If encoding is specified then the first argument must be a string");
|
|
332
|
-
return f(this, t);
|
|
333
|
-
} return h(this, t, e, r); }
|
|
334
|
-
function h(t, e, r, n) { if ("number" == typeof e)
|
|
335
|
-
throw new TypeError('"value" argument must not be a number'); return "undefined" != typeof ArrayBuffer && e instanceof ArrayBuffer ? function (t, e, r, n) { if (e.byteLength, r < 0 || e.byteLength < r)
|
|
336
|
-
throw new RangeError("'offset' is out of bounds"); if (e.byteLength < r + (n || 0))
|
|
337
|
-
throw new RangeError("'length' is out of bounds"); e = void 0 === r && void 0 === n ? new Uint8Array(e) : void 0 === n ? new Uint8Array(e, r) : new Uint8Array(e, r, n); a.TYPED_ARRAY_SUPPORT ? (t = e).__proto__ = a.prototype : t = l(t, e); return t; }(t, e, r, n) : "string" == typeof e ? function (t, e, r) { "string" == typeof r && "" !== r || (r = "utf8"); if (!a.isEncoding(r))
|
|
338
|
-
throw new TypeError('"encoding" must be a valid string encoding'); var n = 0 | p(e, r), i = (t = u(t, n)).write(e, r); i !== n && (t = t.slice(0, i)); return t; }(t, e, r) : function (t, e) { if (a.isBuffer(e)) {
|
|
339
|
-
var r = 0 | d(e.length);
|
|
340
|
-
return 0 === (t = u(t, r)).length ? t : (e.copy(t, 0, 0, r), t);
|
|
341
|
-
} if (e) {
|
|
342
|
-
if ("undefined" != typeof ArrayBuffer && e.buffer instanceof ArrayBuffer || "length" in e)
|
|
343
|
-
return "number" != typeof e.length || (n = e.length) != n ? u(t, 0) : l(t, e);
|
|
344
|
-
if ("Buffer" === e.type && s(e.data))
|
|
345
|
-
return l(t, e.data);
|
|
346
|
-
} var n; throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object."); }(t, e); }
|
|
347
|
-
function c(t) { if ("number" != typeof t)
|
|
348
|
-
throw new TypeError('"size" argument must be a number'); if (t < 0)
|
|
349
|
-
throw new RangeError('"size" argument must not be negative'); }
|
|
350
|
-
function f(t, e) { if (c(e), t = u(t, e < 0 ? 0 : 0 | d(e)), !a.TYPED_ARRAY_SUPPORT)
|
|
351
|
-
for (var r = 0; r < e; ++r)
|
|
352
|
-
t[r] = 0; return t; }
|
|
353
|
-
function l(t, e) { var r = e.length < 0 ? 0 : 0 | d(e.length); t = u(t, r); for (var n = 0; n < r; n += 1)
|
|
354
|
-
t[n] = 255 & e[n]; return t; }
|
|
355
|
-
function d(t) { if (t >= o())
|
|
356
|
-
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + o().toString(16) + " bytes"); return 0 | t; }
|
|
357
|
-
function p(t, e) { if (a.isBuffer(t))
|
|
358
|
-
return t.length; if ("undefined" != typeof ArrayBuffer && "function" == typeof ArrayBuffer.isView && (ArrayBuffer.isView(t) || t instanceof ArrayBuffer))
|
|
359
|
-
return t.byteLength; "string" != typeof t && (t = "" + t); var r = t.length; if (0 === r)
|
|
360
|
-
return 0; for (var n = !1;;)
|
|
361
|
-
switch (e) {
|
|
362
|
-
case "ascii":
|
|
363
|
-
case "latin1":
|
|
364
|
-
case "binary": return r;
|
|
365
|
-
case "utf8":
|
|
366
|
-
case "utf-8":
|
|
367
|
-
case void 0: return k(t).length;
|
|
368
|
-
case "ucs2":
|
|
369
|
-
case "ucs-2":
|
|
370
|
-
case "utf16le":
|
|
371
|
-
case "utf-16le": return 2 * r;
|
|
372
|
-
case "hex": return r >>> 1;
|
|
373
|
-
case "base64": return F(t).length;
|
|
374
|
-
default:
|
|
375
|
-
if (n)
|
|
376
|
-
return k(t).length;
|
|
377
|
-
e = ("" + e).toLowerCase(), n = !0;
|
|
378
|
-
} }
|
|
379
|
-
function g(t, e, r) { var n = !1; if ((void 0 === e || e < 0) && (e = 0), e > this.length)
|
|
380
|
-
return ""; if ((void 0 === r || r > this.length) && (r = this.length), r <= 0)
|
|
381
|
-
return ""; if ((r >>>= 0) <= (e >>>= 0))
|
|
382
|
-
return ""; for (t || (t = "utf8");;)
|
|
383
|
-
switch (t) {
|
|
384
|
-
case "hex": return v(this, e, r);
|
|
385
|
-
case "utf8":
|
|
386
|
-
case "utf-8": return S(this, e, r);
|
|
387
|
-
case "ascii": return I(this, e, r);
|
|
388
|
-
case "latin1":
|
|
389
|
-
case "binary": return _(this, e, r);
|
|
390
|
-
case "base64": return T(this, e, r);
|
|
391
|
-
case "ucs2":
|
|
392
|
-
case "ucs-2":
|
|
393
|
-
case "utf16le":
|
|
394
|
-
case "utf-16le": return R(this, e, r);
|
|
395
|
-
default:
|
|
396
|
-
if (n)
|
|
397
|
-
throw new TypeError("Unknown encoding: " + t);
|
|
398
|
-
t = (t + "").toLowerCase(), n = !0;
|
|
399
|
-
} }
|
|
400
|
-
function b(t, e, r) { var n = t[e]; t[e] = t[r], t[r] = n; }
|
|
401
|
-
function y(t, e, r, n, i) { if (0 === t.length)
|
|
402
|
-
return -1; if ("string" == typeof r ? (n = r, r = 0) : r > 2147483647 ? r = 2147483647 : r < -2147483648 && (r = -2147483648), r = +r, isNaN(r) && (r = i ? 0 : t.length - 1), r < 0 && (r = t.length + r), r >= t.length) {
|
|
403
|
-
if (i)
|
|
404
|
-
return -1;
|
|
405
|
-
r = t.length - 1;
|
|
406
|
-
}
|
|
407
|
-
else if (r < 0) {
|
|
408
|
-
if (!i)
|
|
409
|
-
return -1;
|
|
410
|
-
r = 0;
|
|
411
|
-
} if ("string" == typeof e && (e = a.from(e, n)), a.isBuffer(e))
|
|
412
|
-
return 0 === e.length ? -1 : m(t, e, r, n, i); if ("number" == typeof e)
|
|
413
|
-
return e &= 255, a.TYPED_ARRAY_SUPPORT && "function" == typeof Uint8Array.prototype.indexOf ? i ? Uint8Array.prototype.indexOf.call(t, e, r) : Uint8Array.prototype.lastIndexOf.call(t, e, r) : m(t, [e], r, n, i); throw new TypeError("val must be string, number or Buffer"); }
|
|
414
|
-
function m(t, e, r, n, i) { var s, o = 1, u = t.length, a = e.length; if (void 0 !== n && ("ucs2" === (n = String(n).toLowerCase()) || "ucs-2" === n || "utf16le" === n || "utf-16le" === n)) {
|
|
415
|
-
if (t.length < 2 || e.length < 2)
|
|
416
|
-
return -1;
|
|
417
|
-
o = 2, u /= 2, a /= 2, r /= 2;
|
|
418
|
-
} function h(t, e) { return 1 === o ? t[e] : t.readUInt16BE(e * o); } if (i) {
|
|
419
|
-
var c = -1;
|
|
420
|
-
for (s = r; s < u; s++)
|
|
421
|
-
if (h(t, s) === h(e, -1 === c ? 0 : s - c)) {
|
|
422
|
-
if (-1 === c && (c = s), s - c + 1 === a)
|
|
423
|
-
return c * o;
|
|
424
|
-
}
|
|
425
|
-
else
|
|
426
|
-
-1 !== c && (s -= s - c), c = -1;
|
|
427
|
-
}
|
|
428
|
-
else
|
|
429
|
-
for (r + a > u && (r = u - a), s = r; s >= 0; s--) {
|
|
430
|
-
for (var f = !0, l = 0; l < a; l++)
|
|
431
|
-
if (h(t, s + l) !== h(e, l)) {
|
|
432
|
-
f = !1;
|
|
433
|
-
break;
|
|
434
|
-
}
|
|
435
|
-
if (f)
|
|
436
|
-
return s;
|
|
437
|
-
} return -1; }
|
|
438
|
-
function w(t, e, r, n) { r = Number(r) || 0; var i = t.length - r; n ? (n = Number(n)) > i && (n = i) : n = i; var s = e.length; if (s % 2 != 0)
|
|
439
|
-
throw new TypeError("Invalid hex string"); n > s / 2 && (n = s / 2); for (var o = 0; o < n; ++o) {
|
|
440
|
-
var u = parseInt(e.substr(2 * o, 2), 16);
|
|
441
|
-
if (isNaN(u))
|
|
442
|
-
return o;
|
|
443
|
-
t[r + o] = u;
|
|
444
|
-
} return o; }
|
|
445
|
-
function A(t, e, r, n) { return G(k(e, t.length - r), t, r, n); }
|
|
446
|
-
function E(t, e, r, n) { return G(function (t) { for (var e = [], r = 0; r < t.length; ++r)
|
|
447
|
-
e.push(255 & t.charCodeAt(r)); return e; }(e), t, r, n); }
|
|
448
|
-
function O(t, e, r, n) { return E(t, e, r, n); }
|
|
449
|
-
function N(t, e, r, n) { return G(F(e), t, r, n); }
|
|
450
|
-
function C(t, e, r, n) { return G(function (t, e) { for (var r, n, i, s = [], o = 0; o < t.length && !((e -= 2) < 0); ++o)
|
|
451
|
-
r = t.charCodeAt(o), n = r >> 8, i = r % 256, s.push(i), s.push(n); return s; }(e, t.length - r), t, r, n); }
|
|
452
|
-
function T(t, e, r) { return 0 === e && r === t.length ? n.fromByteArray(t) : n.fromByteArray(t.slice(e, r)); }
|
|
453
|
-
function S(t, e, r) { r = Math.min(t.length, r); for (var n = [], i = e; i < r;) {
|
|
454
|
-
var s, o, u, a, h = t[i], c = null, f = h > 239 ? 4 : h > 223 ? 3 : h > 191 ? 2 : 1;
|
|
455
|
-
if (i + f <= r)
|
|
456
|
-
switch (f) {
|
|
457
|
-
case 1:
|
|
458
|
-
h < 128 && (c = h);
|
|
459
|
-
break;
|
|
460
|
-
case 2:
|
|
461
|
-
128 == (192 & (s = t[i + 1])) && (a = (31 & h) << 6 | 63 & s) > 127 && (c = a);
|
|
462
|
-
break;
|
|
463
|
-
case 3:
|
|
464
|
-
s = t[i + 1], o = t[i + 2], 128 == (192 & s) && 128 == (192 & o) && (a = (15 & h) << 12 | (63 & s) << 6 | 63 & o) > 2047 && (a < 55296 || a > 57343) && (c = a);
|
|
465
|
-
break;
|
|
466
|
-
case 4: s = t[i + 1], o = t[i + 2], u = t[i + 3], 128 == (192 & s) && 128 == (192 & o) && 128 == (192 & u) && (a = (15 & h) << 18 | (63 & s) << 12 | (63 & o) << 6 | 63 & u) > 65535 && a < 1114112 && (c = a);
|
|
467
|
-
}
|
|
468
|
-
null === c ? (c = 65533, f = 1) : c > 65535 && (c -= 65536, n.push(c >>> 10 & 1023 | 55296), c = 56320 | 1023 & c), n.push(c), i += f;
|
|
469
|
-
} return function (t) { var e = t.length; if (e <= 4096)
|
|
470
|
-
return String.fromCharCode.apply(String, t); var r = "", n = 0; for (; n < e;)
|
|
471
|
-
r += String.fromCharCode.apply(String, t.slice(n, n += 4096)); return r; }(n); }
|
|
472
|
-
e.Buffer = a, e.SlowBuffer = function (t) { +t != t && (t = 0); return a.alloc(+t); }, e.INSPECT_MAX_BYTES = 50, a.TYPED_ARRAY_SUPPORT = void 0 !== t.TYPED_ARRAY_SUPPORT ? t.TYPED_ARRAY_SUPPORT : function () { try {
|
|
473
|
-
var t = new Uint8Array(1);
|
|
474
|
-
return t.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42; } }, 42 === t.foo() && "function" == typeof t.subarray && 0 === t.subarray(1, 1).byteLength;
|
|
475
|
-
}
|
|
476
|
-
catch (t) {
|
|
477
|
-
return !1;
|
|
478
|
-
} }(), e.kMaxLength = o(), a.poolSize = 8192, a._augment = function (t) { return t.__proto__ = a.prototype, t; }, a.from = function (t, e, r) { return h(null, t, e, r); }, a.TYPED_ARRAY_SUPPORT && (a.prototype.__proto__ = Uint8Array.prototype, a.__proto__ = Uint8Array, "undefined" != typeof Symbol && Symbol.species && a[Symbol.species] === a && Object.defineProperty(a, Symbol.species, { value: null, configurable: !0 })), a.alloc = function (t, e, r) { return function (t, e, r, n) { return c(e), e <= 0 ? u(t, e) : void 0 !== r ? "string" == typeof n ? u(t, e).fill(r, n) : u(t, e).fill(r) : u(t, e); }(null, t, e, r); }, a.allocUnsafe = function (t) { return f(null, t); }, a.allocUnsafeSlow = function (t) { return f(null, t); }, a.isBuffer = function (t) { return !(null == t || !t._isBuffer); }, a.compare = function (t, e) { if (!a.isBuffer(t) || !a.isBuffer(e))
|
|
479
|
-
throw new TypeError("Arguments must be Buffers"); if (t === e)
|
|
480
|
-
return 0; for (var r = t.length, n = e.length, i = 0, s = Math.min(r, n); i < s; ++i)
|
|
481
|
-
if (t[i] !== e[i]) {
|
|
482
|
-
r = t[i], n = e[i];
|
|
483
|
-
break;
|
|
484
|
-
} return r < n ? -1 : n < r ? 1 : 0; }, a.isEncoding = function (t) { switch (String(t).toLowerCase()) {
|
|
485
|
-
case "hex":
|
|
486
|
-
case "utf8":
|
|
487
|
-
case "utf-8":
|
|
488
|
-
case "ascii":
|
|
489
|
-
case "latin1":
|
|
490
|
-
case "binary":
|
|
491
|
-
case "base64":
|
|
492
|
-
case "ucs2":
|
|
493
|
-
case "ucs-2":
|
|
494
|
-
case "utf16le":
|
|
495
|
-
case "utf-16le": return !0;
|
|
496
|
-
default: return !1;
|
|
497
|
-
} }, a.concat = function (t, e) { if (!s(t))
|
|
498
|
-
throw new TypeError('"list" argument must be an Array of Buffers'); if (0 === t.length)
|
|
499
|
-
return a.alloc(0); var r; if (void 0 === e)
|
|
500
|
-
for (e = 0, r = 0; r < t.length; ++r)
|
|
501
|
-
e += t[r].length; var n = a.allocUnsafe(e), i = 0; for (r = 0; r < t.length; ++r) {
|
|
502
|
-
var o = t[r];
|
|
503
|
-
if (!a.isBuffer(o))
|
|
504
|
-
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
505
|
-
o.copy(n, i), i += o.length;
|
|
506
|
-
} return n; }, a.byteLength = p, a.prototype._isBuffer = !0, a.prototype.swap16 = function () { var t = this.length; if (t % 2 != 0)
|
|
507
|
-
throw new RangeError("Buffer size must be a multiple of 16-bits"); for (var e = 0; e < t; e += 2)
|
|
508
|
-
b(this, e, e + 1); return this; }, a.prototype.swap32 = function () { var t = this.length; if (t % 4 != 0)
|
|
509
|
-
throw new RangeError("Buffer size must be a multiple of 32-bits"); for (var e = 0; e < t; e += 4)
|
|
510
|
-
b(this, e, e + 3), b(this, e + 1, e + 2); return this; }, a.prototype.swap64 = function () { var t = this.length; if (t % 8 != 0)
|
|
511
|
-
throw new RangeError("Buffer size must be a multiple of 64-bits"); for (var e = 0; e < t; e += 8)
|
|
512
|
-
b(this, e, e + 7), b(this, e + 1, e + 6), b(this, e + 2, e + 5), b(this, e + 3, e + 4); return this; }, a.prototype.toString = function () { var t = 0 | this.length; return 0 === t ? "" : 0 === arguments.length ? S(this, 0, t) : g.apply(this, arguments); }, a.prototype.equals = function (t) { if (!a.isBuffer(t))
|
|
513
|
-
throw new TypeError("Argument must be a Buffer"); return this === t || 0 === a.compare(this, t); }, a.prototype.inspect = function () { var t = "", r = e.INSPECT_MAX_BYTES; return this.length > 0 && (t = this.toString("hex", 0, r).match(/.{2}/g).join(" "), this.length > r && (t += " ... ")), "<Buffer " + t + ">"; }, a.prototype.compare = function (t, e, r, n, i) { if (!a.isBuffer(t))
|
|
514
|
-
throw new TypeError("Argument must be a Buffer"); if (void 0 === e && (e = 0), void 0 === r && (r = t ? t.length : 0), void 0 === n && (n = 0), void 0 === i && (i = this.length), e < 0 || r > t.length || n < 0 || i > this.length)
|
|
515
|
-
throw new RangeError("out of range index"); if (n >= i && e >= r)
|
|
516
|
-
return 0; if (n >= i)
|
|
517
|
-
return -1; if (e >= r)
|
|
518
|
-
return 1; if (this === t)
|
|
519
|
-
return 0; for (var s = (i >>>= 0) - (n >>>= 0), o = (r >>>= 0) - (e >>>= 0), u = Math.min(s, o), h = this.slice(n, i), c = t.slice(e, r), f = 0; f < u; ++f)
|
|
520
|
-
if (h[f] !== c[f]) {
|
|
521
|
-
s = h[f], o = c[f];
|
|
522
|
-
break;
|
|
523
|
-
} return s < o ? -1 : o < s ? 1 : 0; }, a.prototype.includes = function (t, e, r) { return -1 !== this.indexOf(t, e, r); }, a.prototype.indexOf = function (t, e, r) { return y(this, t, e, r, !0); }, a.prototype.lastIndexOf = function (t, e, r) { return y(this, t, e, r, !1); }, a.prototype.write = function (t, e, r, n) { if (void 0 === e)
|
|
524
|
-
n = "utf8", r = this.length, e = 0;
|
|
525
|
-
else if (void 0 === r && "string" == typeof e)
|
|
526
|
-
n = e, r = this.length, e = 0;
|
|
527
|
-
else {
|
|
528
|
-
if (!isFinite(e))
|
|
529
|
-
throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
|
|
530
|
-
e |= 0, isFinite(r) ? (r |= 0, void 0 === n && (n = "utf8")) : (n = r, r = void 0);
|
|
531
|
-
} var i = this.length - e; if ((void 0 === r || r > i) && (r = i), t.length > 0 && (r < 0 || e < 0) || e > this.length)
|
|
532
|
-
throw new RangeError("Attempt to write outside buffer bounds"); n || (n = "utf8"); for (var s = !1;;)
|
|
533
|
-
switch (n) {
|
|
534
|
-
case "hex": return w(this, t, e, r);
|
|
535
|
-
case "utf8":
|
|
536
|
-
case "utf-8": return A(this, t, e, r);
|
|
537
|
-
case "ascii": return E(this, t, e, r);
|
|
538
|
-
case "latin1":
|
|
539
|
-
case "binary": return O(this, t, e, r);
|
|
540
|
-
case "base64": return N(this, t, e, r);
|
|
541
|
-
case "ucs2":
|
|
542
|
-
case "ucs-2":
|
|
543
|
-
case "utf16le":
|
|
544
|
-
case "utf-16le": return C(this, t, e, r);
|
|
545
|
-
default:
|
|
546
|
-
if (s)
|
|
547
|
-
throw new TypeError("Unknown encoding: " + n);
|
|
548
|
-
n = ("" + n).toLowerCase(), s = !0;
|
|
549
|
-
} }, a.prototype.toJSON = function () { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; };
|
|
550
|
-
function I(t, e, r) { var n = ""; r = Math.min(t.length, r); for (var i = e; i < r; ++i)
|
|
551
|
-
n += String.fromCharCode(127 & t[i]); return n; }
|
|
552
|
-
function _(t, e, r) { var n = ""; r = Math.min(t.length, r); for (var i = e; i < r; ++i)
|
|
553
|
-
n += String.fromCharCode(t[i]); return n; }
|
|
554
|
-
function v(t, e, r) { var n = t.length; (!e || e < 0) && (e = 0), (!r || r < 0 || r > n) && (r = n); for (var i = "", s = e; s < r; ++s)
|
|
555
|
-
i += Y(t[s]); return i; }
|
|
556
|
-
function R(t, e, r) { for (var n = t.slice(e, r), i = "", s = 0; s < n.length; s += 2)
|
|
557
|
-
i += String.fromCharCode(n[s] + 256 * n[s + 1]); return i; }
|
|
558
|
-
function P(t, e, r) { if (t % 1 != 0 || t < 0)
|
|
559
|
-
throw new RangeError("offset is not uint"); if (t + e > r)
|
|
560
|
-
throw new RangeError("Trying to access beyond buffer length"); }
|
|
561
|
-
function U(t, e, r, n, i, s) { if (!a.isBuffer(t))
|
|
562
|
-
throw new TypeError('"buffer" argument must be a Buffer instance'); if (e > i || e < s)
|
|
563
|
-
throw new RangeError('"value" argument is out of bounds'); if (r + n > t.length)
|
|
564
|
-
throw new RangeError("Index out of range"); }
|
|
565
|
-
function B(t, e, r, n) { e < 0 && (e = 65535 + e + 1); for (var i = 0, s = Math.min(t.length - r, 2); i < s; ++i)
|
|
566
|
-
t[r + i] = (e & 255 << 8 * (n ? i : 1 - i)) >>> 8 * (n ? i : 1 - i); }
|
|
567
|
-
function L(t, e, r, n) { e < 0 && (e = 4294967295 + e + 1); for (var i = 0, s = Math.min(t.length - r, 4); i < s; ++i)
|
|
568
|
-
t[r + i] = e >>> 8 * (n ? i : 3 - i) & 255; }
|
|
569
|
-
function D(t, e, r, n, i, s) { if (r + n > t.length)
|
|
570
|
-
throw new RangeError("Index out of range"); if (r < 0)
|
|
571
|
-
throw new RangeError("Index out of range"); }
|
|
572
|
-
function x(t, e, r, n, s) { return s || D(t, 0, r, 4), i.write(t, e, r, n, 23, 4), r + 4; }
|
|
573
|
-
function M(t, e, r, n, s) { return s || D(t, 0, r, 8), i.write(t, e, r, n, 52, 8), r + 8; }
|
|
574
|
-
a.prototype.slice = function (t, e) { var r, n = this.length; if ((t = ~~t) < 0 ? (t += n) < 0 && (t = 0) : t > n && (t = n), (e = void 0 === e ? n : ~~e) < 0 ? (e += n) < 0 && (e = 0) : e > n && (e = n), e < t && (e = t), a.TYPED_ARRAY_SUPPORT)
|
|
575
|
-
(r = this.subarray(t, e)).__proto__ = a.prototype;
|
|
576
|
-
else {
|
|
577
|
-
var i = e - t;
|
|
578
|
-
r = new a(i, void 0);
|
|
579
|
-
for (var s = 0; s < i; ++s)
|
|
580
|
-
r[s] = this[s + t];
|
|
581
|
-
} return r; }, a.prototype.readUIntLE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = this[t], i = 1, s = 0; ++s < e && (i *= 256);)
|
|
582
|
-
n += this[t + s] * i; return n; }, a.prototype.readUIntBE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = this[t + --e], i = 1; e > 0 && (i *= 256);)
|
|
583
|
-
n += this[t + --e] * i; return n; }, a.prototype.readUInt8 = function (t, e) { return e || P(t, 1, this.length), this[t]; }, a.prototype.readUInt16LE = function (t, e) { return e || P(t, 2, this.length), this[t] | this[t + 1] << 8; }, a.prototype.readUInt16BE = function (t, e) { return e || P(t, 2, this.length), this[t] << 8 | this[t + 1]; }, a.prototype.readUInt32LE = function (t, e) { return e || P(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + 16777216 * this[t + 3]; }, a.prototype.readUInt32BE = function (t, e) { return e || P(t, 4, this.length), 16777216 * this[t] + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]); }, a.prototype.readIntLE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = this[t], i = 1, s = 0; ++s < e && (i *= 256);)
|
|
584
|
-
n += this[t + s] * i; return n >= (i *= 128) && (n -= Math.pow(2, 8 * e)), n; }, a.prototype.readIntBE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = e, i = 1, s = this[t + --n]; n > 0 && (i *= 256);)
|
|
585
|
-
s += this[t + --n] * i; return s >= (i *= 128) && (s -= Math.pow(2, 8 * e)), s; }, a.prototype.readInt8 = function (t, e) { return e || P(t, 1, this.length), 128 & this[t] ? -1 * (255 - this[t] + 1) : this[t]; }, a.prototype.readInt16LE = function (t, e) { e || P(t, 2, this.length); var r = this[t] | this[t + 1] << 8; return 32768 & r ? 4294901760 | r : r; }, a.prototype.readInt16BE = function (t, e) { e || P(t, 2, this.length); var r = this[t + 1] | this[t] << 8; return 32768 & r ? 4294901760 | r : r; }, a.prototype.readInt32LE = function (t, e) { return e || P(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24; }, a.prototype.readInt32BE = function (t, e) { return e || P(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]; }, a.prototype.readFloatLE = function (t, e) { return e || P(t, 4, this.length), i.read(this, t, !0, 23, 4); }, a.prototype.readFloatBE = function (t, e) { return e || P(t, 4, this.length), i.read(this, t, !1, 23, 4); }, a.prototype.readDoubleLE = function (t, e) { return e || P(t, 8, this.length), i.read(this, t, !0, 52, 8); }, a.prototype.readDoubleBE = function (t, e) { return e || P(t, 8, this.length), i.read(this, t, !1, 52, 8); }, a.prototype.writeUIntLE = function (t, e, r, n) { (t = +t, e |= 0, r |= 0, n) || U(this, t, e, r, Math.pow(2, 8 * r) - 1, 0); var i = 1, s = 0; for (this[e] = 255 & t; ++s < r && (i *= 256);)
|
|
586
|
-
this[e + s] = t / i & 255; return e + r; }, a.prototype.writeUIntBE = function (t, e, r, n) { (t = +t, e |= 0, r |= 0, n) || U(this, t, e, r, Math.pow(2, 8 * r) - 1, 0); var i = r - 1, s = 1; for (this[e + i] = 255 & t; --i >= 0 && (s *= 256);)
|
|
587
|
-
this[e + i] = t / s & 255; return e + r; }, a.prototype.writeUInt8 = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 1, 255, 0), a.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), this[e] = 255 & t, e + 1; }, a.prototype.writeUInt16LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 65535, 0), a.TYPED_ARRAY_SUPPORT ? (this[e] = 255 & t, this[e + 1] = t >>> 8) : B(this, t, e, !0), e + 2; }, a.prototype.writeUInt16BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 65535, 0), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 8, this[e + 1] = 255 & t) : B(this, t, e, !1), e + 2; }, a.prototype.writeUInt32LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 4294967295, 0), a.TYPED_ARRAY_SUPPORT ? (this[e + 3] = t >>> 24, this[e + 2] = t >>> 16, this[e + 1] = t >>> 8, this[e] = 255 & t) : L(this, t, e, !0), e + 4; }, a.prototype.writeUInt32BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 4294967295, 0), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = 255 & t) : L(this, t, e, !1), e + 4; }, a.prototype.writeIntLE = function (t, e, r, n) { if (t = +t, e |= 0, !n) {
|
|
588
|
-
var i = Math.pow(2, 8 * r - 1);
|
|
589
|
-
U(this, t, e, r, i - 1, -i);
|
|
590
|
-
} var s = 0, o = 1, u = 0; for (this[e] = 255 & t; ++s < r && (o *= 256);)
|
|
591
|
-
t < 0 && 0 === u && 0 !== this[e + s - 1] && (u = 1), this[e + s] = (t / o >> 0) - u & 255; return e + r; }, a.prototype.writeIntBE = function (t, e, r, n) { if (t = +t, e |= 0, !n) {
|
|
592
|
-
var i = Math.pow(2, 8 * r - 1);
|
|
593
|
-
U(this, t, e, r, i - 1, -i);
|
|
594
|
-
} var s = r - 1, o = 1, u = 0; for (this[e + s] = 255 & t; --s >= 0 && (o *= 256);)
|
|
595
|
-
t < 0 && 0 === u && 0 !== this[e + s + 1] && (u = 1), this[e + s] = (t / o >> 0) - u & 255; return e + r; }, a.prototype.writeInt8 = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 1, 127, -128), a.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), t < 0 && (t = 255 + t + 1), this[e] = 255 & t, e + 1; }, a.prototype.writeInt16LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 32767, -32768), a.TYPED_ARRAY_SUPPORT ? (this[e] = 255 & t, this[e + 1] = t >>> 8) : B(this, t, e, !0), e + 2; }, a.prototype.writeInt16BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 32767, -32768), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 8, this[e + 1] = 255 & t) : B(this, t, e, !1), e + 2; }, a.prototype.writeInt32LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 2147483647, -2147483648), a.TYPED_ARRAY_SUPPORT ? (this[e] = 255 & t, this[e + 1] = t >>> 8, this[e + 2] = t >>> 16, this[e + 3] = t >>> 24) : L(this, t, e, !0), e + 4; }, a.prototype.writeInt32BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 2147483647, -2147483648), t < 0 && (t = 4294967295 + t + 1), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = 255 & t) : L(this, t, e, !1), e + 4; }, a.prototype.writeFloatLE = function (t, e, r) { return x(this, t, e, !0, r); }, a.prototype.writeFloatBE = function (t, e, r) { return x(this, t, e, !1, r); }, a.prototype.writeDoubleLE = function (t, e, r) { return M(this, t, e, !0, r); }, a.prototype.writeDoubleBE = function (t, e, r) { return M(this, t, e, !1, r); }, a.prototype.copy = function (t, e, r, n) { if (r || (r = 0), n || 0 === n || (n = this.length), e >= t.length && (e = t.length), e || (e = 0), n > 0 && n < r && (n = r), n === r)
|
|
596
|
-
return 0; if (0 === t.length || 0 === this.length)
|
|
597
|
-
return 0; if (e < 0)
|
|
598
|
-
throw new RangeError("targetStart out of bounds"); if (r < 0 || r >= this.length)
|
|
599
|
-
throw new RangeError("sourceStart out of bounds"); if (n < 0)
|
|
600
|
-
throw new RangeError("sourceEnd out of bounds"); n > this.length && (n = this.length), t.length - e < n - r && (n = t.length - e + r); var i, s = n - r; if (this === t && r < e && e < n)
|
|
601
|
-
for (i = s - 1; i >= 0; --i)
|
|
602
|
-
t[i + e] = this[i + r];
|
|
603
|
-
else if (s < 1e3 || !a.TYPED_ARRAY_SUPPORT)
|
|
604
|
-
for (i = 0; i < s; ++i)
|
|
605
|
-
t[i + e] = this[i + r];
|
|
606
|
-
else
|
|
607
|
-
Uint8Array.prototype.set.call(t, this.subarray(r, r + s), e); return s; }, a.prototype.fill = function (t, e, r, n) { if ("string" == typeof t) {
|
|
608
|
-
if ("string" == typeof e ? (n = e, e = 0, r = this.length) : "string" == typeof r && (n = r, r = this.length), 1 === t.length) {
|
|
609
|
-
var i = t.charCodeAt(0);
|
|
610
|
-
i < 256 && (t = i);
|
|
611
|
-
}
|
|
612
|
-
if (void 0 !== n && "string" != typeof n)
|
|
613
|
-
throw new TypeError("encoding must be a string");
|
|
614
|
-
if ("string" == typeof n && !a.isEncoding(n))
|
|
615
|
-
throw new TypeError("Unknown encoding: " + n);
|
|
616
|
-
}
|
|
617
|
-
else
|
|
618
|
-
"number" == typeof t && (t &= 255); if (e < 0 || this.length < e || this.length < r)
|
|
619
|
-
throw new RangeError("Out of range index"); if (r <= e)
|
|
620
|
-
return this; var s; if (e >>>= 0, r = void 0 === r ? this.length : r >>> 0, t || (t = 0), "number" == typeof t)
|
|
621
|
-
for (s = e; s < r; ++s)
|
|
622
|
-
this[s] = t;
|
|
623
|
-
else {
|
|
624
|
-
var o = a.isBuffer(t) ? t : k(new a(t, n).toString()), u = o.length;
|
|
625
|
-
for (s = 0; s < r - e; ++s)
|
|
626
|
-
this[s + e] = o[s % u];
|
|
627
|
-
} return this; };
|
|
628
|
-
var j = /[^+\/0-9A-Za-z-_]/g;
|
|
629
|
-
function Y(t) { return t < 16 ? "0" + t.toString(16) : t.toString(16); }
|
|
630
|
-
function k(t, e) { var r; e = e || 1 / 0; for (var n = t.length, i = null, s = [], o = 0; o < n; ++o) {
|
|
631
|
-
if ((r = t.charCodeAt(o)) > 55295 && r < 57344) {
|
|
632
|
-
if (!i) {
|
|
633
|
-
if (r > 56319) {
|
|
634
|
-
(e -= 3) > -1 && s.push(239, 191, 189);
|
|
635
|
-
continue;
|
|
636
|
-
}
|
|
637
|
-
if (o + 1 === n) {
|
|
638
|
-
(e -= 3) > -1 && s.push(239, 191, 189);
|
|
639
|
-
continue;
|
|
640
|
-
}
|
|
641
|
-
i = r;
|
|
642
|
-
continue;
|
|
643
|
-
}
|
|
644
|
-
if (r < 56320) {
|
|
645
|
-
(e -= 3) > -1 && s.push(239, 191, 189), i = r;
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
r = 65536 + (i - 55296 << 10 | r - 56320);
|
|
649
|
-
}
|
|
650
|
-
else
|
|
651
|
-
i && (e -= 3) > -1 && s.push(239, 191, 189);
|
|
652
|
-
if (i = null, r < 128) {
|
|
653
|
-
if ((e -= 1) < 0)
|
|
654
|
-
break;
|
|
655
|
-
s.push(r);
|
|
656
|
-
}
|
|
657
|
-
else if (r < 2048) {
|
|
658
|
-
if ((e -= 2) < 0)
|
|
659
|
-
break;
|
|
660
|
-
s.push(r >> 6 | 192, 63 & r | 128);
|
|
661
|
-
}
|
|
662
|
-
else if (r < 65536) {
|
|
663
|
-
if ((e -= 3) < 0)
|
|
664
|
-
break;
|
|
665
|
-
s.push(r >> 12 | 224, r >> 6 & 63 | 128, 63 & r | 128);
|
|
666
|
-
}
|
|
667
|
-
else {
|
|
668
|
-
if (!(r < 1114112))
|
|
669
|
-
throw new Error("Invalid code point");
|
|
670
|
-
if ((e -= 4) < 0)
|
|
671
|
-
break;
|
|
672
|
-
s.push(r >> 18 | 240, r >> 12 & 63 | 128, r >> 6 & 63 | 128, 63 & r | 128);
|
|
673
|
-
}
|
|
674
|
-
} return s; }
|
|
675
|
-
function F(t) { return n.toByteArray(function (t) { if ((t = function (t) { return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, ""); }(t).replace(j, "")).length < 2)
|
|
676
|
-
return ""; for (; t.length % 4 != 0;)
|
|
677
|
-
t += "="; return t; }(t)); }
|
|
678
|
-
function G(t, e, r, n) { for (var i = 0; i < n && !(i + r >= e.length || i >= t.length); ++i)
|
|
679
|
-
e[i + r] = t[i]; return i; }
|
|
680
|
-
}).call(this, r(8));
|
|
681
|
-
}, function (t, e, r) { var n; n = function () { return this; }(); try {
|
|
682
|
-
n = n || new Function("return this")();
|
|
683
|
-
}
|
|
684
|
-
catch (t) {
|
|
685
|
-
n = Object({});
|
|
686
|
-
} t.exports = n; }, function (t, e, r) {
|
|
687
|
-
"use strict";
|
|
688
|
-
e.byteLength = function (t) { var e = h(t), r = e[0], n = e[1]; return 3 * (r + n) / 4 - n; }, e.toByteArray = function (t) { var e, r, n = h(t), o = n[0], u = n[1], a = new s(function (t, e, r) { return 3 * (e + r) / 4 - r; }(0, o, u)), c = 0, f = u > 0 ? o - 4 : o; for (r = 0; r < f; r += 4)
|
|
689
|
-
e = i[t.charCodeAt(r)] << 18 | i[t.charCodeAt(r + 1)] << 12 | i[t.charCodeAt(r + 2)] << 6 | i[t.charCodeAt(r + 3)], a[c++] = e >> 16 & 255, a[c++] = e >> 8 & 255, a[c++] = 255 & e; 2 === u && (e = i[t.charCodeAt(r)] << 2 | i[t.charCodeAt(r + 1)] >> 4, a[c++] = 255 & e); 1 === u && (e = i[t.charCodeAt(r)] << 10 | i[t.charCodeAt(r + 1)] << 4 | i[t.charCodeAt(r + 2)] >> 2, a[c++] = e >> 8 & 255, a[c++] = 255 & e); return a; }, e.fromByteArray = function (t) { for (var e, r = t.length, i = r % 3, s = [], o = 0, u = r - i; o < u; o += 16383)
|
|
690
|
-
s.push(c(t, o, o + 16383 > u ? u : o + 16383)); 1 === i ? (e = t[r - 1], s.push(n[e >> 2] + n[e << 4 & 63] + "==")) : 2 === i && (e = (t[r - 2] << 8) + t[r - 1], s.push(n[e >> 10] + n[e >> 4 & 63] + n[e << 2 & 63] + "=")); return s.join(""); };
|
|
691
|
-
for (var n = [], i = [], s = "undefined" != typeof Uint8Array ? Uint8Array : Array, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", u = 0, a = o.length; u < a; ++u)
|
|
692
|
-
n[u] = o[u], i[o.charCodeAt(u)] = u;
|
|
693
|
-
function h(t) { var e = t.length; if (e % 4 > 0)
|
|
694
|
-
throw new Error("Invalid string. Length must be a multiple of 4"); var r = t.indexOf("="); return -1 === r && (r = e), [r, r === e ? 0 : 4 - r % 4]; }
|
|
695
|
-
function c(t, e, r) { for (var i, s, o = [], u = e; u < r; u += 3)
|
|
696
|
-
i = (t[u] << 16 & 16711680) + (t[u + 1] << 8 & 65280) + (255 & t[u + 2]), o.push(n[(s = i) >> 18 & 63] + n[s >> 12 & 63] + n[s >> 6 & 63] + n[63 & s]); return o.join(""); }
|
|
697
|
-
i["-".charCodeAt(0)] = 62, i["_".charCodeAt(0)] = 63;
|
|
698
|
-
}, function (t, e) { e.read = function (t, e, r, n, i) { var s, o, u = 8 * i - n - 1, a = (1 << u) - 1, h = a >> 1, c = -7, f = r ? i - 1 : 0, l = r ? -1 : 1, d = t[e + f]; for (f += l, s = d & (1 << -c) - 1, d >>= -c, c += u; c > 0; s = 256 * s + t[e + f], f += l, c -= 8)
|
|
699
|
-
; for (o = s & (1 << -c) - 1, s >>= -c, c += n; c > 0; o = 256 * o + t[e + f], f += l, c -= 8)
|
|
700
|
-
; if (0 === s)
|
|
701
|
-
s = 1 - h;
|
|
702
|
-
else {
|
|
703
|
-
if (s === a)
|
|
704
|
-
return o ? NaN : 1 / 0 * (d ? -1 : 1);
|
|
705
|
-
o += Math.pow(2, n), s -= h;
|
|
706
|
-
} return (d ? -1 : 1) * o * Math.pow(2, s - n); }, e.write = function (t, e, r, n, i, s) { var o, u, a, h = 8 * s - i - 1, c = (1 << h) - 1, f = c >> 1, l = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0, d = n ? 0 : s - 1, p = n ? 1 : -1, g = e < 0 || 0 === e && 1 / e < 0 ? 1 : 0; for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (u = isNaN(e) ? 1 : 0, o = c) : (o = Math.floor(Math.log(e) / Math.LN2), e * (a = Math.pow(2, -o)) < 1 && (o--, a *= 2), (e += o + f >= 1 ? l / a : l * Math.pow(2, 1 - f)) * a >= 2 && (o++, a /= 2), o + f >= c ? (u = 0, o = c) : o + f >= 1 ? (u = (e * a - 1) * Math.pow(2, i), o += f) : (u = e * Math.pow(2, f - 1) * Math.pow(2, i), o = 0)); i >= 8; t[r + d] = 255 & u, d += p, u /= 256, i -= 8)
|
|
707
|
-
; for (o = o << i | u, h += i; h > 0; t[r + d] = 255 & o, d += p, o /= 256, h -= 8)
|
|
708
|
-
; t[r + d - p] |= 128 * g; }; }, function (t, e) { var r = {}.toString; t.exports = Array.isArray || function (t) { return "[object Array]" == r.call(t); }; }, function (t, e, r) {
|
|
709
|
-
"use strict";
|
|
710
|
-
r.r(e);
|
|
711
|
-
var n = r(2), i = r(0), s = r(3), o = r(1), u = r(4), a = r(6);
|
|
712
|
-
function h(t) { return c.connect(t); }
|
|
713
|
-
class c {
|
|
714
|
-
constructor(t) { this.closeListeners = [], this.errorListeners = [], this.draining = !1, this.nuid = new a.a, this.options = { url: "ws://localhost:4222" }, void 0 === t.payload && (t.payload = s.a.STRING); if (!["json", "string", "binary"].includes(t.payload))
|
|
715
|
-
throw i.c.errorForCode(i.a.INVALID_PAYLOAD_TYPE); if (t.user && t.token)
|
|
716
|
-
throw i.c.errorForCode(i.a.BAD_AUTHENTICATION); Object(o.b)(this.options, t); }
|
|
717
|
-
static connect(t) { return new Promise((e, r) => { let n = new c(t); u.e.connect(t, n).then(t => { n.protocol = t, e(n); }).catch(t => { r(t); }); }); }
|
|
718
|
-
close() { this.protocol.close(); }
|
|
719
|
-
publish(t, e, r = "") { return 0 === (t = t || "").length ? (this.errorHandler(i.c.errorForCode(i.a.BAD_SUBJECT)), this) : (Object(o.d)(e) || (this.options.payload !== s.a.JSON ? e = e || "" : (e = void 0 === e ? null : e, e = JSON.stringify(e)), e = Object(o.f)(e)), this.protocol.publish(t, e, r), this); }
|
|
720
|
-
subscribe(t, e, r = {}) { return new Promise((n, s) => { this.isClosed() && s(i.c.errorForCode(i.a.CONNECTION_CLOSED)), this.isDraining() && s(i.c.errorForCode(i.a.CONNECTION_DRAINING)); let a = Object(u.k)(); Object(o.b)(a, r), a.subject = t, a.callback = e, n(this.protocol.subscribe(a)); }); }
|
|
721
|
-
request(t, e = 1e3, r) { return new Promise((n, s) => { this.isClosed() && s(i.c.errorForCode(i.a.CONNECTION_CLOSED)), this.isDraining() && s(i.c.errorForCode(i.a.CONNECTION_DRAINING)); let a = Object(u.j)(); Object(o.b)(a, { max: 1 }), a.token = this.nuid.next(), a.timeout = setTimeout(() => { h.cancel(), s("timeout"); }, e), a.callback = t => { n(t); }; let h = this.protocol.request(a); this.publish(t, r, `${this.protocol.muxSubscriptions.baseInbox}${a.token}`); }); }
|
|
722
|
-
flush(t) { if (void 0 === t)
|
|
723
|
-
return new Promise(t => { this.protocol.flush(() => { t(); }); }); this.protocol.flush(t); }
|
|
724
|
-
drain() { return this.isClosed() ? Promise.reject(i.c.errorForCode(i.a.CONNECTION_CLOSED)) : this.isDraining() ? Promise.reject(i.c.errorForCode(i.a.CONNECTION_DRAINING)) : (this.draining = !0, this.protocol.drain()); }
|
|
725
|
-
errorHandler(t) { this.errorListeners.forEach(e => { try {
|
|
726
|
-
e(t);
|
|
727
|
-
}
|
|
728
|
-
catch (t) { } }); }
|
|
729
|
-
closeHandler() { this.closeListeners.forEach(t => { try {
|
|
730
|
-
t();
|
|
731
|
-
}
|
|
732
|
-
catch (t) { } }); }
|
|
733
|
-
addEventListener(t, e) { "close" === t ? this.closeListeners.push(e) : "error" === t && this.errorListeners.push(e); }
|
|
734
|
-
isClosed() { return this.protocol.isClosed(); }
|
|
735
|
-
isDraining() { return this.draining; }
|
|
736
|
-
}
|
|
737
|
-
var f = r(5);
|
|
738
|
-
r.d(e, "DataBuffer", (function () { return n.a; })), r.d(e, "ErrorCode", (function () { return i.a; })), r.d(e, "Messages", (function () { return i.b; })), r.d(e, "NatsError", (function () { return i.c; })), r.d(e, "connect", (function () { return h; })), r.d(e, "Connection", (function () { return c; })), r.d(e, "ParserState", (function () { return u.d; })), r.d(e, "createInbox", (function () { return u.i; })), r.d(e, "Connect", (function () { return u.a; })), r.d(e, "defaultSub", (function () { return u.k; })), r.d(e, "defaultReq", (function () { return u.j; })), r.d(e, "Request", (function () { return u.f; })), r.d(e, "Subscription", (function () { return u.g; })), r.d(e, "MuxSubscription", (function () { return u.c; })), r.d(e, "Subscriptions", (function () { return u.h; })), r.d(e, "MsgBuffer", (function () { return u.b; })), r.d(e, "ProtocolHandler", (function () { return u.e; })), r.d(e, "WSTransport", (function () { return f.a; })), r.d(e, "isArrayBuffer", (function () { return o.d; })), r.d(e, "extend", (function () { return o.b; })), r.d(e, "extractProtocolMessage", (function () { return o.c; })), r.d(e, "buildWSMessage", (function () { return o.a; })), r.d(e, "settle", (function () { return o.e; })), r.d(e, "stringToUint8Array", (function () { return o.f; }));
|
|
739
|
-
}]);
|
|
740
|
-
}));
|
|
53
|
+
!function (t, e) { "object" == 'object' && "object" == 'object' ? module.exports = e() : "function" == typeof undefined && undefined.amd ? undefined([], e) : "object" == 'object' ? exports.nats = e() : t.nats = e(); }(commonjsGlobal, (function () {
|
|
54
|
+
return function (t) { var e = {}; function r(n) { if (e[n])
|
|
55
|
+
return e[n].exports; var i = e[n] = { i: n, l: !1, exports: {} }; return t[n].call(i.exports, i, i.exports, r), i.l = !0, i.exports; } return r.m = t, r.c = e, r.d = function (t, e, n) { r.o(t, e) || Object.defineProperty(t, e, { enumerable: !0, get: n }); }, r.r = function (t) { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(t, "__esModule", { value: !0 }); }, r.t = function (t, e) { if (1 & e && (t = r(t)), 8 & e)
|
|
56
|
+
return t; if (4 & e && "object" == typeof t && t && t.__esModule)
|
|
57
|
+
return t; var n = Object.create(null); if (r.r(n), Object.defineProperty(n, "default", { enumerable: !0, value: t }), 2 & e && "string" != typeof t)
|
|
58
|
+
for (var i in t)
|
|
59
|
+
r.d(n, i, function (e) { return t[e]; }.bind(null, i)); return n; }, r.n = function (t) { var e = t && t.__esModule ? function () { return t.default; } : function () { return t; }; return r.d(e, "a", e), e; }, r.o = function (t, e) { return Object.prototype.hasOwnProperty.call(t, e); }, r.p = "", r(r.s = 12); }([function (t, e, r) {
|
|
60
|
+
"use strict";
|
|
61
|
+
var n;
|
|
62
|
+
r.d(e, "a", (function () { return n; })), r.d(e, "b", (function () { return i; })), r.d(e, "c", (function () { return s; })), function (t) { t.BAD_AUTHENTICATION = "BAD_AUTHENTICATION", t.BAD_SUBJECT = "BAD_SUBJECT", t.CONNECTION_CLOSED = "CONNECTION_CLOSED", t.CONNECTION_DRAINING = "CONNECTION_DRAINING", t.CONNECTION_REFUSED = "CONNECTION_REFUSED", t.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", t.INVALID_PAYLOAD_TYPE = "INVALID_PAYLOAD", t.UNKNOWN = "UNKNOWN_ERROR", t.WSS_REQUIRED = "WSS_REQUIRED", t.SUB_CLOSED = "SUB_CLOSED", t.SUB_DRAINING = "SUB_DRAINING", t.PERMISSIONS_VIOLATION = "PERMISSIONS_VIOLATION", t.AUTHORIZATION_VIOLATION = "AUTHORIZATION_VIOLATION", t.NATS_PROTOCOL_ERR = "NATS_PROTOCOL_ERR"; }(n || (n = {}));
|
|
63
|
+
class i {
|
|
64
|
+
constructor() { this.messages = {}, this.messages[n.BAD_AUTHENTICATION] = "User and Token can not both be provided", this.messages[n.BAD_SUBJECT] = "Subject must be supplied", this.messages[n.CONNECTION_CLOSED] = "Connection closed", this.messages[n.CONNECTION_CLOSED] = "Connection closed", this.messages[n.CONNECTION_REFUSED] = "Connection refused", this.messages[n.CONNECTION_TIMEOUT] = "Connection timeout", this.messages[n.CONNECTION_DRAINING] = "Connection draining", this.messages[n.INVALID_PAYLOAD_TYPE] = "Invalid payload type - payloads can be 'binary', 'string', or 'json'", this.messages[n.SUB_CLOSED] = "Subscription closed", this.messages[n.SUB_DRAINING] = "Subscription draining", this.messages[n.WSS_REQUIRED] = "TLS is required, therefore a secure websocket connection is also required"; }
|
|
65
|
+
static getMessage(t) { return i.messages.getMessage(t); }
|
|
66
|
+
getMessage(t) { let e = this.messages[t]; return e || (e = t), e; }
|
|
67
|
+
}
|
|
68
|
+
i.messages = new i;
|
|
69
|
+
class s extends Error {
|
|
70
|
+
constructor(t, e, r) { super(t), this.name = "NatsError", this.message = t, this.code = e, this.chainedError = r; }
|
|
71
|
+
static errorForCode(t, e) { let r = i.getMessage(t); return new s(r, t, e); }
|
|
72
|
+
}
|
|
73
|
+
}, function (t, e, r) {
|
|
74
|
+
"use strict";
|
|
75
|
+
r.d(e, "d", (function () { return u; })), r.d(e, "b", (function () { return a; })), r.d(e, "c", (function () { return h; })), r.d(e, "a", (function () { return c; })), r.d(e, "e", (function () { return f; })), r.d(e, "f", (function () { return l; }));
|
|
76
|
+
var n = r(2);
|
|
77
|
+
let i = n.a.fromAscii("\r\n"), s = new Uint8Array(i)[0], o = new Uint8Array(i)[1];
|
|
78
|
+
function u(t) { return t instanceof ArrayBuffer; }
|
|
79
|
+
function a(t, ...e) { for (let r = 0; r < e.length; r++) {
|
|
80
|
+
let n = e[r];
|
|
81
|
+
Object.keys(n).forEach((function (e) { t[e] = n[e]; }));
|
|
82
|
+
} return t; }
|
|
83
|
+
function h(t) { let e = function (t) { let e = new Uint8Array(t); for (let t = 0; t < e.byteLength; t++) {
|
|
84
|
+
let r = t + 1;
|
|
85
|
+
if (e.byteLength > r && e[t] === s && e[r] === o)
|
|
86
|
+
return r + 1;
|
|
87
|
+
} return -1; }(t); if (e) {
|
|
88
|
+
let r = new Uint8Array(t).slice(0, e);
|
|
89
|
+
return String.fromCharCode.apply(null, r);
|
|
90
|
+
} return ""; }
|
|
91
|
+
function c(t, e) { let r = n.a.fromAscii(t); return e && (r = n.a.concat(r, e, i)), r; }
|
|
92
|
+
function f(t) { return Array.isArray(t) ? Promise.resolve(t).then(d) : Promise.reject(new TypeError("argument requires an array of promises")); }
|
|
93
|
+
function l(t) { const e = t.split(""), r = []; for (var n = 0; n < e.length; n++)
|
|
94
|
+
r.push(e[n].charCodeAt(0)); return new Uint8Array(r); }
|
|
95
|
+
function d(t) { return Promise.all(t.map(t => Promise.resolve(t).then(p, p))); }
|
|
96
|
+
function p(t) { return t; }
|
|
97
|
+
}, function (t, e, r) {
|
|
98
|
+
"use strict";
|
|
99
|
+
r.d(e, "a", (function () { return n; }));
|
|
100
|
+
class n {
|
|
101
|
+
constructor() { this.buffers = [], this.byteLength = 0; }
|
|
102
|
+
static concat(...t) { let e = 0; for (let r = 0; r < t.length; r++)
|
|
103
|
+
e += t[r].byteLength; let r = new Uint8Array(e), n = 0; for (let e = 0; e < t.length; e++)
|
|
104
|
+
r.set(new Uint8Array(t[e]), n), n += t[e].byteLength; return r.buffer; }
|
|
105
|
+
static fromAscii(t) { t || (t = ""); let e = new ArrayBuffer(t.length), r = new Uint8Array(e); for (let e = 0; e < t.length; e++)
|
|
106
|
+
r[e] = t.charCodeAt(e); return e; }
|
|
107
|
+
static toAscii(t) { return String.fromCharCode.apply(null, new Uint8Array(t)); }
|
|
108
|
+
pack() { if (this.buffers.length > 1) {
|
|
109
|
+
let t = this.buffers.splice(0, this.buffers.length);
|
|
110
|
+
this.buffers.push(n.concat(...t));
|
|
111
|
+
} }
|
|
112
|
+
drain(t) { if (this.buffers.length) {
|
|
113
|
+
this.pack();
|
|
114
|
+
let e = this.buffers.pop();
|
|
115
|
+
if (e) {
|
|
116
|
+
let r = this.byteLength;
|
|
117
|
+
(void 0 === t || t > r) && (t = r);
|
|
118
|
+
let n = e.slice(0, t);
|
|
119
|
+
return r > t && this.buffers.push(e.slice(t)), this.byteLength = r - t, n;
|
|
120
|
+
}
|
|
121
|
+
} return new Uint8Array(0).buffer; }
|
|
122
|
+
fill(t) { t && (this.buffers.push(t), this.byteLength += t.byteLength); }
|
|
123
|
+
peek() { return this.buffers.length ? (this.pack(), this.buffers[0]) : new Uint8Array(0).buffer; }
|
|
124
|
+
size() { return this.byteLength; }
|
|
125
|
+
length() { return this.buffers.length; }
|
|
126
|
+
}
|
|
127
|
+
}, function (t, e, r) {
|
|
128
|
+
"use strict";
|
|
129
|
+
var n;
|
|
130
|
+
r.d(e, "a", (function () { return n; })), function (t) { t.STRING = "string", t.JSON = "json", t.BINARY = "binary"; }(n || (n = {}));
|
|
131
|
+
}, function (t, e, r) {
|
|
132
|
+
"use strict";
|
|
133
|
+
(function (t) { r.d(e, "d", (function () { return c; })), r.d(e, "i", (function () { return m; })), r.d(e, "a", (function () { return w; })), r.d(e, "k", (function () { return A; })), r.d(e, "j", (function () { return E; })), r.d(e, "f", (function () { return O; })), r.d(e, "g", (function () { return N; })), r.d(e, "c", (function () { return C; })), r.d(e, "h", (function () { return T; })), r.d(e, "b", (function () { return S; })), r.d(e, "e", (function () { return I; })); var n = r(3), i = r(5), s = r(0), o = r(1), u = r(6), a = r(2); let h; var c; !function (t) { t[t.CLOSED = -1] = "CLOSED", t[t.AWAITING_CONTROL = 0] = "AWAITING_CONTROL", t[t.AWAITING_MSG_PAYLOAD = 1] = "AWAITING_MSG_PAYLOAD"; }(c || (c = {})); const f = /^MSG\s+([^\s\r\n]+)\s+([^\s\r\n]+)\s+(([^\s\r\n]+)[^\S\r\n]+)?(\d+)\r\n/i, l = /^\+OK\s*\r\n/i, d = /^-ERR\s+('.+')?\r\n/i, p = /^PING\r\n/i, g = /^PONG\r\n/i, b = /^INFO\s+([^\r\n]+)\r\n/i, y = "\r\n".length; function m() { return h || (h = new u.a), `_INBOX.${h.next()}`; } class w {
|
|
134
|
+
constructor(t) { this.lang = "javascript", this.pedantic = !1, this.protocol = 1, this.verbose = !1, (t = t || {}).token && (this.auth_token = t.token), t.noEcho && (this.echo = !1), t.userJWT && ("function" == typeof t.userJWT ? this.jwt = t.userJWT() : this.jwt = t.userJWT), Object(o.b)(this, t); }
|
|
135
|
+
} function A() { return { sid: 0, subject: "", received: 0 }; } function E() { return { token: "", subject: "", received: 0, max: 1 }; } class O {
|
|
136
|
+
constructor(t, e) { this.token = t.token, this.protocol = e; }
|
|
137
|
+
cancel() { this.protocol.cancelRequest(this.token, 0); }
|
|
138
|
+
} class N {
|
|
139
|
+
constructor(t, e) { this.sid = t.sid, this.protocol = e; }
|
|
140
|
+
unsubscribe(t) { this.protocol.unsubscribe(this.sid, t); }
|
|
141
|
+
hasTimeout() { let t = this.protocol.subscriptions.get(this.sid); return null !== t && null !== t.timeout; }
|
|
142
|
+
cancelTimeout() { let t = this.protocol.subscriptions.get(this.sid); null !== t && null !== t.timeout && (clearTimeout(t.timeout), t.timeout = null); }
|
|
143
|
+
setTimeout(t, e) { let r = this.protocol.subscriptions.get(this.sid); return null !== r && (r.timeout && (clearTimeout(r.timeout), r.timeout = null), r.timeout = setTimeout(e, t), !0); }
|
|
144
|
+
getReceived() { let t = this.protocol.subscriptions.get(this.sid); return t ? t.received : 0; }
|
|
145
|
+
drain() { return this.protocol.drainSubscription(this.sid); }
|
|
146
|
+
isDraining() { let t = this.protocol.subscriptions.get(this.sid); return !!t && t.draining; }
|
|
147
|
+
isCancelled() { return null === this.protocol.subscriptions.get(this.sid); }
|
|
148
|
+
} class C {
|
|
149
|
+
constructor() { this.reqs = {}, this.length = 0; }
|
|
150
|
+
init() { return this.baseInbox = `${m()}.`, this.baseInbox; }
|
|
151
|
+
add(t) { isNaN(t.received) || (t.received = 0), this.length++, this.reqs[t.token] = t; }
|
|
152
|
+
get(t) { return t in this.reqs ? this.reqs[t] : null; }
|
|
153
|
+
cancel(t) { t && t.timeout && (clearTimeout(t.timeout), t.timeout = null), t.token in this.reqs && (delete this.reqs[t.token], this.length--); }
|
|
154
|
+
getToken(t) { let e = t.subject || ""; return 0 === e.indexOf(this.baseInbox) ? e.substring(this.baseInbox.length) : null; }
|
|
155
|
+
dispatcher() { let t = this; return function (e) { let r = t.getToken(e); if (r) {
|
|
156
|
+
let n = t.get(r);
|
|
157
|
+
n && (n.received++, n.callback(e), n.max && n.received >= n.max && t.cancel(n));
|
|
158
|
+
} }; }
|
|
159
|
+
} class T {
|
|
160
|
+
constructor() { this.subs = {}, this.sidCounter = 0, this.length = 0; }
|
|
161
|
+
add(t) { return this.sidCounter++, this.length++, t.sid = this.sidCounter, this.subs[t.sid] = t, t; }
|
|
162
|
+
setMux(t) { return this.mux = t, t; }
|
|
163
|
+
getMux() { return this.mux; }
|
|
164
|
+
get(t) { return t in this.subs ? this.subs[t] : null; }
|
|
165
|
+
all() { let t = []; for (let e in this.subs) {
|
|
166
|
+
let r = this.subs[e];
|
|
167
|
+
t.push(r);
|
|
168
|
+
} return t; }
|
|
169
|
+
cancel(t) { t && t.timeout && (clearTimeout(t.timeout), t.timeout = null), t.sid in this.subs && (delete this.subs[t.sid], this.length--); }
|
|
170
|
+
} class S {
|
|
171
|
+
constructor(t, e = "string") { this.msg = {}, this.msg.subject = t[1], this.msg.sid = parseInt(t[2], 10), this.msg.reply = t[4], this.msg.size = parseInt(t[5], 10), this.length = this.msg.size + y, this.payload = e; }
|
|
172
|
+
fill(e) { if (this.buf ? this.buf = a.a.concat(this.buf, e) : this.buf = e, this.length -= e.byteLength, 0 === this.length) {
|
|
173
|
+
switch (this.msg.data = this.buf.slice(0, this.buf.byteLength - 2), this.payload) {
|
|
174
|
+
case n.a.JSON:
|
|
175
|
+
this.msg.data = t.from(this.msg.data).toString("utf8"), this.msg.data = JSON.parse(this.msg.data);
|
|
176
|
+
break;
|
|
177
|
+
case n.a.STRING:
|
|
178
|
+
this.msg.data = t.from(this.msg.data).toString("utf8");
|
|
179
|
+
break;
|
|
180
|
+
case n.a.BINARY:
|
|
181
|
+
}
|
|
182
|
+
this.buf = null;
|
|
183
|
+
} }
|
|
184
|
+
} class I {
|
|
185
|
+
constructor(t, e) { this.infoReceived = !1, this.payload = null, this.pongs = [], this.pout = 0, this.state = c.AWAITING_CONTROL, this.noMorePublishing = !1, this.options = t, this.clientHandlers = e, this.subscriptions = new T, this.muxSubscriptions = new C, this.inbound = new a.a, this.outbound = new a.a; }
|
|
186
|
+
static connect(t, e) { return new Promise((r, n) => { let o = new I(t, e); o.connectError = n; let u = t.connectTimeout || 1e4, a = new Promise((t, e) => { let r = setTimeout(() => { e(s.c.errorForCode(s.a.CONNECTION_TIMEOUT)); }, u); o.pongs.push(() => { clearTimeout(r), t(!0); }); }); i.a.connect(t, o, t.debug).then(t => { o.transport = t; }).catch(t => { o.connectError = null, n(t); }), a.then(() => { o.connectError = null, r(o); }).catch(t => { o.connectError = null, n(t); }); }); }
|
|
187
|
+
static toError(t) { let e = t ? t.toLowerCase() : ""; return -1 !== e.indexOf("permissions violation") ? new s.c(t, s.a.PERMISSIONS_VIOLATION) : -1 !== e.indexOf("authorization violation") ? new s.c(t, s.a.AUTHORIZATION_VIOLATION) : new s.c(t, s.a.NATS_PROTOCOL_ERR); }
|
|
188
|
+
processInbound() { let t = null; for (; this.inbound.size();) {
|
|
189
|
+
switch (this.state) {
|
|
190
|
+
case c.CLOSED: return;
|
|
191
|
+
case c.AWAITING_CONTROL:
|
|
192
|
+
let e = this.inbound.peek(), r = Object(o.c)(e);
|
|
193
|
+
if (t = f.exec(r))
|
|
194
|
+
this.payload = new S(t, this.options.payload), this.state = c.AWAITING_MSG_PAYLOAD;
|
|
195
|
+
else if (t = l.exec(r))
|
|
196
|
+
;
|
|
197
|
+
else {
|
|
198
|
+
if (t = d.exec(r))
|
|
199
|
+
return void this.processError(t[1]);
|
|
200
|
+
if (t = g.exec(r)) {
|
|
201
|
+
this.pout = 0;
|
|
202
|
+
let t = this.pongs.shift();
|
|
203
|
+
t && t();
|
|
204
|
+
}
|
|
205
|
+
else if (t = p.exec(r))
|
|
206
|
+
this.transport.write(Object(o.a)("PONG \r\n"));
|
|
207
|
+
else {
|
|
208
|
+
if (!(t = b.exec(r)))
|
|
209
|
+
return;
|
|
210
|
+
if (!this.infoReceived) {
|
|
211
|
+
if (JSON.parse(t[1]).tls_required && !this.transport.isSecure())
|
|
212
|
+
return void this.handleError(s.c.errorForCode(s.a.WSS_REQUIRED));
|
|
213
|
+
let e = JSON.stringify(new w(this.options));
|
|
214
|
+
this.transport.write(Object(o.a)(`CONNECT ${e}\r\n`)), this.sendSubscriptions(), this.transport.write(Object(o.a)("PING \r\n")), this.infoReceived = !0, this.flushPending();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
case c.AWAITING_MSG_PAYLOAD:
|
|
220
|
+
if (!this.payload)
|
|
221
|
+
break;
|
|
222
|
+
if (this.inbound.size() < this.payload.length) {
|
|
223
|
+
let t = this.inbound.drain();
|
|
224
|
+
return void this.payload.fill(t);
|
|
225
|
+
}
|
|
226
|
+
let n = this.inbound.drain(this.payload.length);
|
|
227
|
+
this.payload.fill(n);
|
|
228
|
+
try {
|
|
229
|
+
this.processMsg();
|
|
230
|
+
}
|
|
231
|
+
catch (t) { }
|
|
232
|
+
this.state = c.AWAITING_CONTROL, this.payload = null;
|
|
233
|
+
}
|
|
234
|
+
if (t) {
|
|
235
|
+
let e = t[0].length;
|
|
236
|
+
e >= this.inbound.size() ? this.inbound.drain() : this.inbound.drain(e), t = null;
|
|
237
|
+
}
|
|
238
|
+
} }
|
|
239
|
+
processMsg() { if (!this.payload || !this.subscriptions.sidCounter)
|
|
240
|
+
return; let t = this.payload, e = this.subscriptions.get(t.msg.sid); e && (e.received += 1, e.timeout && void 0 === e.max && (clearTimeout(e.timeout), e.timeout = null), e.callback && e.callback(t.msg), void 0 !== e.max && e.received >= e.max && this.unsubscribe(e.sid)); }
|
|
241
|
+
sendCommand(t) { let e; e = "string" == typeof t ? Object(o.f)(t) : t, t && this.outbound.fill(e), 1 === this.outbound.length() ? setTimeout(() => { this.flushPending(); }) : this.outbound.size() > 8192 && this.flushPending(); }
|
|
242
|
+
publish(e, r, n) { if (this.isClosed())
|
|
243
|
+
throw s.c.errorForCode(s.a.CONNECTION_CLOSED); if (this.noMorePublishing)
|
|
244
|
+
throw s.c.errorForCode(s.a.CONNECTION_DRAINING); let i, u = t.byteLength(r); i = (n = n || "") ? `PUB ${e} ${n} ${u}\r\n` : `PUB ${e} ${u}\r\n`, this.sendCommand(Object(o.a)(i, r)); }
|
|
245
|
+
request(t) { return this.initMux(), this.muxSubscriptions.add(t), new O(t, this); }
|
|
246
|
+
subscribe(t) { let e = this.subscriptions.add(t); return e.queue ? this.sendCommand(`SUB ${e.subject} ${e.queue} ${e.sid}\r\n`) : this.sendCommand(`SUB ${e.subject} ${e.sid}\r\n`), new N(e, this); }
|
|
247
|
+
unsubscribe(t, e) { if (!t || this.isClosed())
|
|
248
|
+
return; let r = this.subscriptions.get(t); r && (e ? this.sendCommand(`UNSUB ${t} ${e}\r\n`) : this.sendCommand(`UNSUB ${t}\r\n`), r.max = e, (void 0 === r.max || r.received >= r.max) && this.subscriptions.cancel(r)); }
|
|
249
|
+
cancelRequest(t, e) { if (!t || this.isClosed())
|
|
250
|
+
return; let r = this.muxSubscriptions.get(t); r && (r.max = e, (void 0 === r.max || r.received >= r.max) && this.muxSubscriptions.cancel(r)); }
|
|
251
|
+
flush(t) { this.pongs.push(t), this.sendCommand("PING \r\n"); }
|
|
252
|
+
processError(t) { let e = { error: I.toError(t) }; this.errorHandler(e); }
|
|
253
|
+
sendSubscriptions() { let t = []; this.subscriptions.all().forEach(e => { e.queue ? t.push(`SUB ${e.subject} ${e.queue} ${e.sid} \r\n`) : t.push(`SUB ${e.subject} ${e.sid} \r\n`); }), t.length && this.transport.write(Object(o.a)(t.join(""))); }
|
|
254
|
+
openHandler(t) { }
|
|
255
|
+
closeHandler(t) { this.close(), this.clientHandlers.closeHandler(); }
|
|
256
|
+
errorHandler(t) { let e; t && (e = t.error), this.handleError(e); }
|
|
257
|
+
messageHandler(t) { this.inbound.fill(t.data), this.processInbound(); }
|
|
258
|
+
close() { this.transport.close(), this.state = c.CLOSED; }
|
|
259
|
+
isClosed() { return this.transport.isClosed(); }
|
|
260
|
+
drain() { let t = this.subscriptions.all(), e = []; return t.forEach(t => { let r = this.drainSubscription(t.sid); e.push(r); }), new Promise(t => { Object(o.e)(e).then(e => { this.noMorePublishing = !0, setTimeout(() => { this.close(), t(e); }); }).catch(() => { }); }); }
|
|
261
|
+
drainSubscription(t) { if (this.isClosed())
|
|
262
|
+
return Promise.reject(s.c.errorForCode(s.a.CONNECTION_CLOSED)); if (!t)
|
|
263
|
+
return Promise.reject(s.c.errorForCode(s.a.SUB_CLOSED)); let e = this.subscriptions.get(t); if (!e)
|
|
264
|
+
return Promise.reject(s.c.errorForCode(s.a.SUB_CLOSED)); if (e.draining)
|
|
265
|
+
return Promise.reject(s.c.errorForCode(s.a.SUB_DRAINING)); let r = e; return new Promise(t => { r.draining = !0, this.sendCommand(`UNSUB ${r.sid}\r\n`), this.flush(() => { this.subscriptions.cancel(r), t(r); }); }); }
|
|
266
|
+
flushPending() { if (this.infoReceived && this.outbound.size()) {
|
|
267
|
+
let t = this.outbound.drain();
|
|
268
|
+
this.transport.write(t);
|
|
269
|
+
} }
|
|
270
|
+
initMux() { if (!this.subscriptions.getMux()) {
|
|
271
|
+
let t = this.muxSubscriptions.init(), e = { sid: 0, subject: "", received: 0 };
|
|
272
|
+
e.subject = `${t}*`, e.callback = this.muxSubscriptions.dispatcher(), this.subscriptions.setMux(e), this.subscribe(e);
|
|
273
|
+
} }
|
|
274
|
+
handleError(t) { this.connectError && (this.connectError(t), this.connectError = null), this.close(), this.clientHandlers.errorHandler(t); }
|
|
275
|
+
} }).call(this, r(7).Buffer);
|
|
276
|
+
}, function (t, e, r) {
|
|
277
|
+
"use strict";
|
|
278
|
+
r.d(e, "a", (function () { return i; }));
|
|
279
|
+
var n = r(0);
|
|
280
|
+
class i {
|
|
281
|
+
constructor(t) { this.stream = null, this.closed = !1, this.debug = !1, this.listeners = {}, this.handlers = t; }
|
|
282
|
+
static connect(t, e, r = !1) { return new Promise((s, o) => { let u, a = new i(e); a.debug = r, a.stream = new WebSocket(t.url), a.stream.binaryType = "arraybuffer", a.listeners = {}, a.stream.onclose = function (t) { a.trace("ws closed", t), a.closed || (u ? (a.handlers.closeHandler(t), a.close()) : (clearTimeout(void 0), o(n.c.errorForCode(n.a.CONNECTION_CLOSED)))); }, a.stream.onerror = function (t) { let e; if (t && (e = t.error, !e)) {
|
|
283
|
+
let r = t.message;
|
|
284
|
+
e = r ? new n.c(r, n.a.UNKNOWN) : u ? n.c.errorForCode(n.a.UNKNOWN) : n.c.errorForCode(n.a.CONNECTION_REFUSED);
|
|
285
|
+
} a.trace("ws error", e), a.closed || (a && a.close(), u ? a.handlers.errorHandler(t) : o(e)); }, a.stream.onopen = function () { a.trace("ws open"); }, a.stream.onmessage = function (t) { a.trace(">", [t.data]), u ? a.handlers.messageHandler(t) : (u = !0, s(a), setTimeout((function () { a.handlers.messageHandler(t); }), 100)); }; }); }
|
|
286
|
+
isClosed() { return this.closed; }
|
|
287
|
+
isConnected() { return null !== this.stream && this.stream.readyState === WebSocket.OPEN; }
|
|
288
|
+
write(t) { this.stream && this.isConnected() && (this.trace("<", [t]), this.stream.send(t)); }
|
|
289
|
+
destroy() { this.stream && (this.closed && (this.stream.onclose = null, this.stream.onerror = null, this.stream.onopen = null, this.stream.onmessage = null), this.stream.readyState !== WebSocket.CLOSED && this.stream.readyState !== WebSocket.CLOSING && this.stream.close(1e3), this.stream = null); }
|
|
290
|
+
close() { this.closed = !0, this.stream && this.stream.bufferedAmount > 0 ? setTimeout(this.close.bind(this), 100) : this.destroy(); }
|
|
291
|
+
trace(...t) { this.debug && console.log(t); }
|
|
292
|
+
isSecure() { if (this.stream) {
|
|
293
|
+
return "wss:" === new URL(this.stream.url).protocol.toLowerCase();
|
|
294
|
+
} return !1; }
|
|
295
|
+
}
|
|
296
|
+
}, function (t, e, r) {
|
|
297
|
+
"use strict";
|
|
298
|
+
r.d(e, "a", (function () { return s; }));
|
|
299
|
+
const n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
300
|
+
let i;
|
|
301
|
+
class s {
|
|
302
|
+
constructor() { this.buf = new Uint8Array(22), this.init(); }
|
|
303
|
+
init() { "crypto" in Object({}) && Object({}).crypto.getRandomValues ? i = Object({}).crypto : "msCrypto" in Object({}) && Object({}).msCrypto.getRandomValues && (i = Object({}).msCrypto), i || (i = { getRandomValues: function (t) { for (let e = 0; e < t.length; e++)
|
|
304
|
+
t[e] = Math.floor(255 * Math.random()); } }), this.setPre(), this.initSeqAndInc(), this.fillSeq(); }
|
|
305
|
+
initSeqAndInc() { this.seq = Math.floor(0xcfd41b9100000 * Math.random()), this.inc = Math.floor(300 * Math.random() + 33); }
|
|
306
|
+
setPre() { let t = new Uint8Array(12); i.getRandomValues(t); for (let e = 0; e < 12; e++) {
|
|
307
|
+
let r = t[e] % 36;
|
|
308
|
+
this.buf[e] = n.charCodeAt(r);
|
|
309
|
+
} }
|
|
310
|
+
fillSeq() { let t = this.seq; for (let e = 21; e >= 12; e--)
|
|
311
|
+
this.buf[e] = n.charCodeAt(t % 36), t = Math.floor(t / 36); }
|
|
312
|
+
next() { return this.seq += this.inc, this.seq > 0xcfd41b9100000 && (this.setPre(), this.initSeqAndInc()), this.fillSeq(), String.fromCharCode.apply(String, this.buf); }
|
|
313
|
+
reset() { this.init(); }
|
|
314
|
+
}
|
|
315
|
+
}, function (t, e, r) {
|
|
316
|
+
"use strict";
|
|
317
|
+
(function (t) {
|
|
318
|
+
/*!
|
|
319
|
+
* The buffer module from node.js, for the browser.
|
|
320
|
+
*
|
|
321
|
+
* @author Feross Aboukhadijeh <http://feross.org>
|
|
322
|
+
* @license MIT
|
|
323
|
+
*/
|
|
324
|
+
var n = r(9), i = r(10), s = r(11);
|
|
325
|
+
function o() { return a.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823; }
|
|
326
|
+
function u(t, e) { if (o() < e)
|
|
327
|
+
throw new RangeError("Invalid typed array length"); return a.TYPED_ARRAY_SUPPORT ? (t = new Uint8Array(e)).__proto__ = a.prototype : (null === t && (t = new a(e)), t.length = e), t; }
|
|
328
|
+
function a(t, e, r) { if (!(a.TYPED_ARRAY_SUPPORT || this instanceof a))
|
|
329
|
+
return new a(t, e, r); if ("number" == typeof t) {
|
|
330
|
+
if ("string" == typeof e)
|
|
331
|
+
throw new Error("If encoding is specified then the first argument must be a string");
|
|
332
|
+
return f(this, t);
|
|
333
|
+
} return h(this, t, e, r); }
|
|
334
|
+
function h(t, e, r, n) { if ("number" == typeof e)
|
|
335
|
+
throw new TypeError('"value" argument must not be a number'); return "undefined" != typeof ArrayBuffer && e instanceof ArrayBuffer ? function (t, e, r, n) { if (e.byteLength, r < 0 || e.byteLength < r)
|
|
336
|
+
throw new RangeError("'offset' is out of bounds"); if (e.byteLength < r + (n || 0))
|
|
337
|
+
throw new RangeError("'length' is out of bounds"); e = void 0 === r && void 0 === n ? new Uint8Array(e) : void 0 === n ? new Uint8Array(e, r) : new Uint8Array(e, r, n); a.TYPED_ARRAY_SUPPORT ? (t = e).__proto__ = a.prototype : t = l(t, e); return t; }(t, e, r, n) : "string" == typeof e ? function (t, e, r) { "string" == typeof r && "" !== r || (r = "utf8"); if (!a.isEncoding(r))
|
|
338
|
+
throw new TypeError('"encoding" must be a valid string encoding'); var n = 0 | p(e, r), i = (t = u(t, n)).write(e, r); i !== n && (t = t.slice(0, i)); return t; }(t, e, r) : function (t, e) { if (a.isBuffer(e)) {
|
|
339
|
+
var r = 0 | d(e.length);
|
|
340
|
+
return 0 === (t = u(t, r)).length ? t : (e.copy(t, 0, 0, r), t);
|
|
341
|
+
} if (e) {
|
|
342
|
+
if ("undefined" != typeof ArrayBuffer && e.buffer instanceof ArrayBuffer || "length" in e)
|
|
343
|
+
return "number" != typeof e.length || (n = e.length) != n ? u(t, 0) : l(t, e);
|
|
344
|
+
if ("Buffer" === e.type && s(e.data))
|
|
345
|
+
return l(t, e.data);
|
|
346
|
+
} var n; throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object."); }(t, e); }
|
|
347
|
+
function c(t) { if ("number" != typeof t)
|
|
348
|
+
throw new TypeError('"size" argument must be a number'); if (t < 0)
|
|
349
|
+
throw new RangeError('"size" argument must not be negative'); }
|
|
350
|
+
function f(t, e) { if (c(e), t = u(t, e < 0 ? 0 : 0 | d(e)), !a.TYPED_ARRAY_SUPPORT)
|
|
351
|
+
for (var r = 0; r < e; ++r)
|
|
352
|
+
t[r] = 0; return t; }
|
|
353
|
+
function l(t, e) { var r = e.length < 0 ? 0 : 0 | d(e.length); t = u(t, r); for (var n = 0; n < r; n += 1)
|
|
354
|
+
t[n] = 255 & e[n]; return t; }
|
|
355
|
+
function d(t) { if (t >= o())
|
|
356
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + o().toString(16) + " bytes"); return 0 | t; }
|
|
357
|
+
function p(t, e) { if (a.isBuffer(t))
|
|
358
|
+
return t.length; if ("undefined" != typeof ArrayBuffer && "function" == typeof ArrayBuffer.isView && (ArrayBuffer.isView(t) || t instanceof ArrayBuffer))
|
|
359
|
+
return t.byteLength; "string" != typeof t && (t = "" + t); var r = t.length; if (0 === r)
|
|
360
|
+
return 0; for (var n = !1;;)
|
|
361
|
+
switch (e) {
|
|
362
|
+
case "ascii":
|
|
363
|
+
case "latin1":
|
|
364
|
+
case "binary": return r;
|
|
365
|
+
case "utf8":
|
|
366
|
+
case "utf-8":
|
|
367
|
+
case void 0: return k(t).length;
|
|
368
|
+
case "ucs2":
|
|
369
|
+
case "ucs-2":
|
|
370
|
+
case "utf16le":
|
|
371
|
+
case "utf-16le": return 2 * r;
|
|
372
|
+
case "hex": return r >>> 1;
|
|
373
|
+
case "base64": return F(t).length;
|
|
374
|
+
default:
|
|
375
|
+
if (n)
|
|
376
|
+
return k(t).length;
|
|
377
|
+
e = ("" + e).toLowerCase(), n = !0;
|
|
378
|
+
} }
|
|
379
|
+
function g(t, e, r) { var n = !1; if ((void 0 === e || e < 0) && (e = 0), e > this.length)
|
|
380
|
+
return ""; if ((void 0 === r || r > this.length) && (r = this.length), r <= 0)
|
|
381
|
+
return ""; if ((r >>>= 0) <= (e >>>= 0))
|
|
382
|
+
return ""; for (t || (t = "utf8");;)
|
|
383
|
+
switch (t) {
|
|
384
|
+
case "hex": return v(this, e, r);
|
|
385
|
+
case "utf8":
|
|
386
|
+
case "utf-8": return S(this, e, r);
|
|
387
|
+
case "ascii": return I(this, e, r);
|
|
388
|
+
case "latin1":
|
|
389
|
+
case "binary": return _(this, e, r);
|
|
390
|
+
case "base64": return T(this, e, r);
|
|
391
|
+
case "ucs2":
|
|
392
|
+
case "ucs-2":
|
|
393
|
+
case "utf16le":
|
|
394
|
+
case "utf-16le": return R(this, e, r);
|
|
395
|
+
default:
|
|
396
|
+
if (n)
|
|
397
|
+
throw new TypeError("Unknown encoding: " + t);
|
|
398
|
+
t = (t + "").toLowerCase(), n = !0;
|
|
399
|
+
} }
|
|
400
|
+
function b(t, e, r) { var n = t[e]; t[e] = t[r], t[r] = n; }
|
|
401
|
+
function y(t, e, r, n, i) { if (0 === t.length)
|
|
402
|
+
return -1; if ("string" == typeof r ? (n = r, r = 0) : r > 2147483647 ? r = 2147483647 : r < -2147483648 && (r = -2147483648), r = +r, isNaN(r) && (r = i ? 0 : t.length - 1), r < 0 && (r = t.length + r), r >= t.length) {
|
|
403
|
+
if (i)
|
|
404
|
+
return -1;
|
|
405
|
+
r = t.length - 1;
|
|
406
|
+
}
|
|
407
|
+
else if (r < 0) {
|
|
408
|
+
if (!i)
|
|
409
|
+
return -1;
|
|
410
|
+
r = 0;
|
|
411
|
+
} if ("string" == typeof e && (e = a.from(e, n)), a.isBuffer(e))
|
|
412
|
+
return 0 === e.length ? -1 : m(t, e, r, n, i); if ("number" == typeof e)
|
|
413
|
+
return e &= 255, a.TYPED_ARRAY_SUPPORT && "function" == typeof Uint8Array.prototype.indexOf ? i ? Uint8Array.prototype.indexOf.call(t, e, r) : Uint8Array.prototype.lastIndexOf.call(t, e, r) : m(t, [e], r, n, i); throw new TypeError("val must be string, number or Buffer"); }
|
|
414
|
+
function m(t, e, r, n, i) { var s, o = 1, u = t.length, a = e.length; if (void 0 !== n && ("ucs2" === (n = String(n).toLowerCase()) || "ucs-2" === n || "utf16le" === n || "utf-16le" === n)) {
|
|
415
|
+
if (t.length < 2 || e.length < 2)
|
|
416
|
+
return -1;
|
|
417
|
+
o = 2, u /= 2, a /= 2, r /= 2;
|
|
418
|
+
} function h(t, e) { return 1 === o ? t[e] : t.readUInt16BE(e * o); } if (i) {
|
|
419
|
+
var c = -1;
|
|
420
|
+
for (s = r; s < u; s++)
|
|
421
|
+
if (h(t, s) === h(e, -1 === c ? 0 : s - c)) {
|
|
422
|
+
if (-1 === c && (c = s), s - c + 1 === a)
|
|
423
|
+
return c * o;
|
|
424
|
+
}
|
|
425
|
+
else
|
|
426
|
+
-1 !== c && (s -= s - c), c = -1;
|
|
427
|
+
}
|
|
428
|
+
else
|
|
429
|
+
for (r + a > u && (r = u - a), s = r; s >= 0; s--) {
|
|
430
|
+
for (var f = !0, l = 0; l < a; l++)
|
|
431
|
+
if (h(t, s + l) !== h(e, l)) {
|
|
432
|
+
f = !1;
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
if (f)
|
|
436
|
+
return s;
|
|
437
|
+
} return -1; }
|
|
438
|
+
function w(t, e, r, n) { r = Number(r) || 0; var i = t.length - r; n ? (n = Number(n)) > i && (n = i) : n = i; var s = e.length; if (s % 2 != 0)
|
|
439
|
+
throw new TypeError("Invalid hex string"); n > s / 2 && (n = s / 2); for (var o = 0; o < n; ++o) {
|
|
440
|
+
var u = parseInt(e.substr(2 * o, 2), 16);
|
|
441
|
+
if (isNaN(u))
|
|
442
|
+
return o;
|
|
443
|
+
t[r + o] = u;
|
|
444
|
+
} return o; }
|
|
445
|
+
function A(t, e, r, n) { return G(k(e, t.length - r), t, r, n); }
|
|
446
|
+
function E(t, e, r, n) { return G(function (t) { for (var e = [], r = 0; r < t.length; ++r)
|
|
447
|
+
e.push(255 & t.charCodeAt(r)); return e; }(e), t, r, n); }
|
|
448
|
+
function O(t, e, r, n) { return E(t, e, r, n); }
|
|
449
|
+
function N(t, e, r, n) { return G(F(e), t, r, n); }
|
|
450
|
+
function C(t, e, r, n) { return G(function (t, e) { for (var r, n, i, s = [], o = 0; o < t.length && !((e -= 2) < 0); ++o)
|
|
451
|
+
r = t.charCodeAt(o), n = r >> 8, i = r % 256, s.push(i), s.push(n); return s; }(e, t.length - r), t, r, n); }
|
|
452
|
+
function T(t, e, r) { return 0 === e && r === t.length ? n.fromByteArray(t) : n.fromByteArray(t.slice(e, r)); }
|
|
453
|
+
function S(t, e, r) { r = Math.min(t.length, r); for (var n = [], i = e; i < r;) {
|
|
454
|
+
var s, o, u, a, h = t[i], c = null, f = h > 239 ? 4 : h > 223 ? 3 : h > 191 ? 2 : 1;
|
|
455
|
+
if (i + f <= r)
|
|
456
|
+
switch (f) {
|
|
457
|
+
case 1:
|
|
458
|
+
h < 128 && (c = h);
|
|
459
|
+
break;
|
|
460
|
+
case 2:
|
|
461
|
+
128 == (192 & (s = t[i + 1])) && (a = (31 & h) << 6 | 63 & s) > 127 && (c = a);
|
|
462
|
+
break;
|
|
463
|
+
case 3:
|
|
464
|
+
s = t[i + 1], o = t[i + 2], 128 == (192 & s) && 128 == (192 & o) && (a = (15 & h) << 12 | (63 & s) << 6 | 63 & o) > 2047 && (a < 55296 || a > 57343) && (c = a);
|
|
465
|
+
break;
|
|
466
|
+
case 4: s = t[i + 1], o = t[i + 2], u = t[i + 3], 128 == (192 & s) && 128 == (192 & o) && 128 == (192 & u) && (a = (15 & h) << 18 | (63 & s) << 12 | (63 & o) << 6 | 63 & u) > 65535 && a < 1114112 && (c = a);
|
|
467
|
+
}
|
|
468
|
+
null === c ? (c = 65533, f = 1) : c > 65535 && (c -= 65536, n.push(c >>> 10 & 1023 | 55296), c = 56320 | 1023 & c), n.push(c), i += f;
|
|
469
|
+
} return function (t) { var e = t.length; if (e <= 4096)
|
|
470
|
+
return String.fromCharCode.apply(String, t); var r = "", n = 0; for (; n < e;)
|
|
471
|
+
r += String.fromCharCode.apply(String, t.slice(n, n += 4096)); return r; }(n); }
|
|
472
|
+
e.Buffer = a, e.SlowBuffer = function (t) { +t != t && (t = 0); return a.alloc(+t); }, e.INSPECT_MAX_BYTES = 50, a.TYPED_ARRAY_SUPPORT = void 0 !== t.TYPED_ARRAY_SUPPORT ? t.TYPED_ARRAY_SUPPORT : function () { try {
|
|
473
|
+
var t = new Uint8Array(1);
|
|
474
|
+
return t.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42; } }, 42 === t.foo() && "function" == typeof t.subarray && 0 === t.subarray(1, 1).byteLength;
|
|
475
|
+
}
|
|
476
|
+
catch (t) {
|
|
477
|
+
return !1;
|
|
478
|
+
} }(), e.kMaxLength = o(), a.poolSize = 8192, a._augment = function (t) { return t.__proto__ = a.prototype, t; }, a.from = function (t, e, r) { return h(null, t, e, r); }, a.TYPED_ARRAY_SUPPORT && (a.prototype.__proto__ = Uint8Array.prototype, a.__proto__ = Uint8Array, "undefined" != typeof Symbol && Symbol.species && a[Symbol.species] === a && Object.defineProperty(a, Symbol.species, { value: null, configurable: !0 })), a.alloc = function (t, e, r) { return function (t, e, r, n) { return c(e), e <= 0 ? u(t, e) : void 0 !== r ? "string" == typeof n ? u(t, e).fill(r, n) : u(t, e).fill(r) : u(t, e); }(null, t, e, r); }, a.allocUnsafe = function (t) { return f(null, t); }, a.allocUnsafeSlow = function (t) { return f(null, t); }, a.isBuffer = function (t) { return !(null == t || !t._isBuffer); }, a.compare = function (t, e) { if (!a.isBuffer(t) || !a.isBuffer(e))
|
|
479
|
+
throw new TypeError("Arguments must be Buffers"); if (t === e)
|
|
480
|
+
return 0; for (var r = t.length, n = e.length, i = 0, s = Math.min(r, n); i < s; ++i)
|
|
481
|
+
if (t[i] !== e[i]) {
|
|
482
|
+
r = t[i], n = e[i];
|
|
483
|
+
break;
|
|
484
|
+
} return r < n ? -1 : n < r ? 1 : 0; }, a.isEncoding = function (t) { switch (String(t).toLowerCase()) {
|
|
485
|
+
case "hex":
|
|
486
|
+
case "utf8":
|
|
487
|
+
case "utf-8":
|
|
488
|
+
case "ascii":
|
|
489
|
+
case "latin1":
|
|
490
|
+
case "binary":
|
|
491
|
+
case "base64":
|
|
492
|
+
case "ucs2":
|
|
493
|
+
case "ucs-2":
|
|
494
|
+
case "utf16le":
|
|
495
|
+
case "utf-16le": return !0;
|
|
496
|
+
default: return !1;
|
|
497
|
+
} }, a.concat = function (t, e) { if (!s(t))
|
|
498
|
+
throw new TypeError('"list" argument must be an Array of Buffers'); if (0 === t.length)
|
|
499
|
+
return a.alloc(0); var r; if (void 0 === e)
|
|
500
|
+
for (e = 0, r = 0; r < t.length; ++r)
|
|
501
|
+
e += t[r].length; var n = a.allocUnsafe(e), i = 0; for (r = 0; r < t.length; ++r) {
|
|
502
|
+
var o = t[r];
|
|
503
|
+
if (!a.isBuffer(o))
|
|
504
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
505
|
+
o.copy(n, i), i += o.length;
|
|
506
|
+
} return n; }, a.byteLength = p, a.prototype._isBuffer = !0, a.prototype.swap16 = function () { var t = this.length; if (t % 2 != 0)
|
|
507
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits"); for (var e = 0; e < t; e += 2)
|
|
508
|
+
b(this, e, e + 1); return this; }, a.prototype.swap32 = function () { var t = this.length; if (t % 4 != 0)
|
|
509
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits"); for (var e = 0; e < t; e += 4)
|
|
510
|
+
b(this, e, e + 3), b(this, e + 1, e + 2); return this; }, a.prototype.swap64 = function () { var t = this.length; if (t % 8 != 0)
|
|
511
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits"); for (var e = 0; e < t; e += 8)
|
|
512
|
+
b(this, e, e + 7), b(this, e + 1, e + 6), b(this, e + 2, e + 5), b(this, e + 3, e + 4); return this; }, a.prototype.toString = function () { var t = 0 | this.length; return 0 === t ? "" : 0 === arguments.length ? S(this, 0, t) : g.apply(this, arguments); }, a.prototype.equals = function (t) { if (!a.isBuffer(t))
|
|
513
|
+
throw new TypeError("Argument must be a Buffer"); return this === t || 0 === a.compare(this, t); }, a.prototype.inspect = function () { var t = "", r = e.INSPECT_MAX_BYTES; return this.length > 0 && (t = this.toString("hex", 0, r).match(/.{2}/g).join(" "), this.length > r && (t += " ... ")), "<Buffer " + t + ">"; }, a.prototype.compare = function (t, e, r, n, i) { if (!a.isBuffer(t))
|
|
514
|
+
throw new TypeError("Argument must be a Buffer"); if (void 0 === e && (e = 0), void 0 === r && (r = t ? t.length : 0), void 0 === n && (n = 0), void 0 === i && (i = this.length), e < 0 || r > t.length || n < 0 || i > this.length)
|
|
515
|
+
throw new RangeError("out of range index"); if (n >= i && e >= r)
|
|
516
|
+
return 0; if (n >= i)
|
|
517
|
+
return -1; if (e >= r)
|
|
518
|
+
return 1; if (this === t)
|
|
519
|
+
return 0; for (var s = (i >>>= 0) - (n >>>= 0), o = (r >>>= 0) - (e >>>= 0), u = Math.min(s, o), h = this.slice(n, i), c = t.slice(e, r), f = 0; f < u; ++f)
|
|
520
|
+
if (h[f] !== c[f]) {
|
|
521
|
+
s = h[f], o = c[f];
|
|
522
|
+
break;
|
|
523
|
+
} return s < o ? -1 : o < s ? 1 : 0; }, a.prototype.includes = function (t, e, r) { return -1 !== this.indexOf(t, e, r); }, a.prototype.indexOf = function (t, e, r) { return y(this, t, e, r, !0); }, a.prototype.lastIndexOf = function (t, e, r) { return y(this, t, e, r, !1); }, a.prototype.write = function (t, e, r, n) { if (void 0 === e)
|
|
524
|
+
n = "utf8", r = this.length, e = 0;
|
|
525
|
+
else if (void 0 === r && "string" == typeof e)
|
|
526
|
+
n = e, r = this.length, e = 0;
|
|
527
|
+
else {
|
|
528
|
+
if (!isFinite(e))
|
|
529
|
+
throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
|
|
530
|
+
e |= 0, isFinite(r) ? (r |= 0, void 0 === n && (n = "utf8")) : (n = r, r = void 0);
|
|
531
|
+
} var i = this.length - e; if ((void 0 === r || r > i) && (r = i), t.length > 0 && (r < 0 || e < 0) || e > this.length)
|
|
532
|
+
throw new RangeError("Attempt to write outside buffer bounds"); n || (n = "utf8"); for (var s = !1;;)
|
|
533
|
+
switch (n) {
|
|
534
|
+
case "hex": return w(this, t, e, r);
|
|
535
|
+
case "utf8":
|
|
536
|
+
case "utf-8": return A(this, t, e, r);
|
|
537
|
+
case "ascii": return E(this, t, e, r);
|
|
538
|
+
case "latin1":
|
|
539
|
+
case "binary": return O(this, t, e, r);
|
|
540
|
+
case "base64": return N(this, t, e, r);
|
|
541
|
+
case "ucs2":
|
|
542
|
+
case "ucs-2":
|
|
543
|
+
case "utf16le":
|
|
544
|
+
case "utf-16le": return C(this, t, e, r);
|
|
545
|
+
default:
|
|
546
|
+
if (s)
|
|
547
|
+
throw new TypeError("Unknown encoding: " + n);
|
|
548
|
+
n = ("" + n).toLowerCase(), s = !0;
|
|
549
|
+
} }, a.prototype.toJSON = function () { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; };
|
|
550
|
+
function I(t, e, r) { var n = ""; r = Math.min(t.length, r); for (var i = e; i < r; ++i)
|
|
551
|
+
n += String.fromCharCode(127 & t[i]); return n; }
|
|
552
|
+
function _(t, e, r) { var n = ""; r = Math.min(t.length, r); for (var i = e; i < r; ++i)
|
|
553
|
+
n += String.fromCharCode(t[i]); return n; }
|
|
554
|
+
function v(t, e, r) { var n = t.length; (!e || e < 0) && (e = 0), (!r || r < 0 || r > n) && (r = n); for (var i = "", s = e; s < r; ++s)
|
|
555
|
+
i += Y(t[s]); return i; }
|
|
556
|
+
function R(t, e, r) { for (var n = t.slice(e, r), i = "", s = 0; s < n.length; s += 2)
|
|
557
|
+
i += String.fromCharCode(n[s] + 256 * n[s + 1]); return i; }
|
|
558
|
+
function P(t, e, r) { if (t % 1 != 0 || t < 0)
|
|
559
|
+
throw new RangeError("offset is not uint"); if (t + e > r)
|
|
560
|
+
throw new RangeError("Trying to access beyond buffer length"); }
|
|
561
|
+
function U(t, e, r, n, i, s) { if (!a.isBuffer(t))
|
|
562
|
+
throw new TypeError('"buffer" argument must be a Buffer instance'); if (e > i || e < s)
|
|
563
|
+
throw new RangeError('"value" argument is out of bounds'); if (r + n > t.length)
|
|
564
|
+
throw new RangeError("Index out of range"); }
|
|
565
|
+
function B(t, e, r, n) { e < 0 && (e = 65535 + e + 1); for (var i = 0, s = Math.min(t.length - r, 2); i < s; ++i)
|
|
566
|
+
t[r + i] = (e & 255 << 8 * (n ? i : 1 - i)) >>> 8 * (n ? i : 1 - i); }
|
|
567
|
+
function L(t, e, r, n) { e < 0 && (e = 4294967295 + e + 1); for (var i = 0, s = Math.min(t.length - r, 4); i < s; ++i)
|
|
568
|
+
t[r + i] = e >>> 8 * (n ? i : 3 - i) & 255; }
|
|
569
|
+
function D(t, e, r, n, i, s) { if (r + n > t.length)
|
|
570
|
+
throw new RangeError("Index out of range"); if (r < 0)
|
|
571
|
+
throw new RangeError("Index out of range"); }
|
|
572
|
+
function x(t, e, r, n, s) { return s || D(t, 0, r, 4), i.write(t, e, r, n, 23, 4), r + 4; }
|
|
573
|
+
function M(t, e, r, n, s) { return s || D(t, 0, r, 8), i.write(t, e, r, n, 52, 8), r + 8; }
|
|
574
|
+
a.prototype.slice = function (t, e) { var r, n = this.length; if ((t = ~~t) < 0 ? (t += n) < 0 && (t = 0) : t > n && (t = n), (e = void 0 === e ? n : ~~e) < 0 ? (e += n) < 0 && (e = 0) : e > n && (e = n), e < t && (e = t), a.TYPED_ARRAY_SUPPORT)
|
|
575
|
+
(r = this.subarray(t, e)).__proto__ = a.prototype;
|
|
576
|
+
else {
|
|
577
|
+
var i = e - t;
|
|
578
|
+
r = new a(i, void 0);
|
|
579
|
+
for (var s = 0; s < i; ++s)
|
|
580
|
+
r[s] = this[s + t];
|
|
581
|
+
} return r; }, a.prototype.readUIntLE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = this[t], i = 1, s = 0; ++s < e && (i *= 256);)
|
|
582
|
+
n += this[t + s] * i; return n; }, a.prototype.readUIntBE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = this[t + --e], i = 1; e > 0 && (i *= 256);)
|
|
583
|
+
n += this[t + --e] * i; return n; }, a.prototype.readUInt8 = function (t, e) { return e || P(t, 1, this.length), this[t]; }, a.prototype.readUInt16LE = function (t, e) { return e || P(t, 2, this.length), this[t] | this[t + 1] << 8; }, a.prototype.readUInt16BE = function (t, e) { return e || P(t, 2, this.length), this[t] << 8 | this[t + 1]; }, a.prototype.readUInt32LE = function (t, e) { return e || P(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + 16777216 * this[t + 3]; }, a.prototype.readUInt32BE = function (t, e) { return e || P(t, 4, this.length), 16777216 * this[t] + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]); }, a.prototype.readIntLE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = this[t], i = 1, s = 0; ++s < e && (i *= 256);)
|
|
584
|
+
n += this[t + s] * i; return n >= (i *= 128) && (n -= Math.pow(2, 8 * e)), n; }, a.prototype.readIntBE = function (t, e, r) { t |= 0, e |= 0, r || P(t, e, this.length); for (var n = e, i = 1, s = this[t + --n]; n > 0 && (i *= 256);)
|
|
585
|
+
s += this[t + --n] * i; return s >= (i *= 128) && (s -= Math.pow(2, 8 * e)), s; }, a.prototype.readInt8 = function (t, e) { return e || P(t, 1, this.length), 128 & this[t] ? -1 * (255 - this[t] + 1) : this[t]; }, a.prototype.readInt16LE = function (t, e) { e || P(t, 2, this.length); var r = this[t] | this[t + 1] << 8; return 32768 & r ? 4294901760 | r : r; }, a.prototype.readInt16BE = function (t, e) { e || P(t, 2, this.length); var r = this[t + 1] | this[t] << 8; return 32768 & r ? 4294901760 | r : r; }, a.prototype.readInt32LE = function (t, e) { return e || P(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24; }, a.prototype.readInt32BE = function (t, e) { return e || P(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]; }, a.prototype.readFloatLE = function (t, e) { return e || P(t, 4, this.length), i.read(this, t, !0, 23, 4); }, a.prototype.readFloatBE = function (t, e) { return e || P(t, 4, this.length), i.read(this, t, !1, 23, 4); }, a.prototype.readDoubleLE = function (t, e) { return e || P(t, 8, this.length), i.read(this, t, !0, 52, 8); }, a.prototype.readDoubleBE = function (t, e) { return e || P(t, 8, this.length), i.read(this, t, !1, 52, 8); }, a.prototype.writeUIntLE = function (t, e, r, n) { (t = +t, e |= 0, r |= 0, n) || U(this, t, e, r, Math.pow(2, 8 * r) - 1, 0); var i = 1, s = 0; for (this[e] = 255 & t; ++s < r && (i *= 256);)
|
|
586
|
+
this[e + s] = t / i & 255; return e + r; }, a.prototype.writeUIntBE = function (t, e, r, n) { (t = +t, e |= 0, r |= 0, n) || U(this, t, e, r, Math.pow(2, 8 * r) - 1, 0); var i = r - 1, s = 1; for (this[e + i] = 255 & t; --i >= 0 && (s *= 256);)
|
|
587
|
+
this[e + i] = t / s & 255; return e + r; }, a.prototype.writeUInt8 = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 1, 255, 0), a.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), this[e] = 255 & t, e + 1; }, a.prototype.writeUInt16LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 65535, 0), a.TYPED_ARRAY_SUPPORT ? (this[e] = 255 & t, this[e + 1] = t >>> 8) : B(this, t, e, !0), e + 2; }, a.prototype.writeUInt16BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 65535, 0), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 8, this[e + 1] = 255 & t) : B(this, t, e, !1), e + 2; }, a.prototype.writeUInt32LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 4294967295, 0), a.TYPED_ARRAY_SUPPORT ? (this[e + 3] = t >>> 24, this[e + 2] = t >>> 16, this[e + 1] = t >>> 8, this[e] = 255 & t) : L(this, t, e, !0), e + 4; }, a.prototype.writeUInt32BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 4294967295, 0), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = 255 & t) : L(this, t, e, !1), e + 4; }, a.prototype.writeIntLE = function (t, e, r, n) { if (t = +t, e |= 0, !n) {
|
|
588
|
+
var i = Math.pow(2, 8 * r - 1);
|
|
589
|
+
U(this, t, e, r, i - 1, -i);
|
|
590
|
+
} var s = 0, o = 1, u = 0; for (this[e] = 255 & t; ++s < r && (o *= 256);)
|
|
591
|
+
t < 0 && 0 === u && 0 !== this[e + s - 1] && (u = 1), this[e + s] = (t / o >> 0) - u & 255; return e + r; }, a.prototype.writeIntBE = function (t, e, r, n) { if (t = +t, e |= 0, !n) {
|
|
592
|
+
var i = Math.pow(2, 8 * r - 1);
|
|
593
|
+
U(this, t, e, r, i - 1, -i);
|
|
594
|
+
} var s = r - 1, o = 1, u = 0; for (this[e + s] = 255 & t; --s >= 0 && (o *= 256);)
|
|
595
|
+
t < 0 && 0 === u && 0 !== this[e + s + 1] && (u = 1), this[e + s] = (t / o >> 0) - u & 255; return e + r; }, a.prototype.writeInt8 = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 1, 127, -128), a.TYPED_ARRAY_SUPPORT || (t = Math.floor(t)), t < 0 && (t = 255 + t + 1), this[e] = 255 & t, e + 1; }, a.prototype.writeInt16LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 32767, -32768), a.TYPED_ARRAY_SUPPORT ? (this[e] = 255 & t, this[e + 1] = t >>> 8) : B(this, t, e, !0), e + 2; }, a.prototype.writeInt16BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 2, 32767, -32768), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 8, this[e + 1] = 255 & t) : B(this, t, e, !1), e + 2; }, a.prototype.writeInt32LE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 2147483647, -2147483648), a.TYPED_ARRAY_SUPPORT ? (this[e] = 255 & t, this[e + 1] = t >>> 8, this[e + 2] = t >>> 16, this[e + 3] = t >>> 24) : L(this, t, e, !0), e + 4; }, a.prototype.writeInt32BE = function (t, e, r) { return t = +t, e |= 0, r || U(this, t, e, 4, 2147483647, -2147483648), t < 0 && (t = 4294967295 + t + 1), a.TYPED_ARRAY_SUPPORT ? (this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = 255 & t) : L(this, t, e, !1), e + 4; }, a.prototype.writeFloatLE = function (t, e, r) { return x(this, t, e, !0, r); }, a.prototype.writeFloatBE = function (t, e, r) { return x(this, t, e, !1, r); }, a.prototype.writeDoubleLE = function (t, e, r) { return M(this, t, e, !0, r); }, a.prototype.writeDoubleBE = function (t, e, r) { return M(this, t, e, !1, r); }, a.prototype.copy = function (t, e, r, n) { if (r || (r = 0), n || 0 === n || (n = this.length), e >= t.length && (e = t.length), e || (e = 0), n > 0 && n < r && (n = r), n === r)
|
|
596
|
+
return 0; if (0 === t.length || 0 === this.length)
|
|
597
|
+
return 0; if (e < 0)
|
|
598
|
+
throw new RangeError("targetStart out of bounds"); if (r < 0 || r >= this.length)
|
|
599
|
+
throw new RangeError("sourceStart out of bounds"); if (n < 0)
|
|
600
|
+
throw new RangeError("sourceEnd out of bounds"); n > this.length && (n = this.length), t.length - e < n - r && (n = t.length - e + r); var i, s = n - r; if (this === t && r < e && e < n)
|
|
601
|
+
for (i = s - 1; i >= 0; --i)
|
|
602
|
+
t[i + e] = this[i + r];
|
|
603
|
+
else if (s < 1e3 || !a.TYPED_ARRAY_SUPPORT)
|
|
604
|
+
for (i = 0; i < s; ++i)
|
|
605
|
+
t[i + e] = this[i + r];
|
|
606
|
+
else
|
|
607
|
+
Uint8Array.prototype.set.call(t, this.subarray(r, r + s), e); return s; }, a.prototype.fill = function (t, e, r, n) { if ("string" == typeof t) {
|
|
608
|
+
if ("string" == typeof e ? (n = e, e = 0, r = this.length) : "string" == typeof r && (n = r, r = this.length), 1 === t.length) {
|
|
609
|
+
var i = t.charCodeAt(0);
|
|
610
|
+
i < 256 && (t = i);
|
|
611
|
+
}
|
|
612
|
+
if (void 0 !== n && "string" != typeof n)
|
|
613
|
+
throw new TypeError("encoding must be a string");
|
|
614
|
+
if ("string" == typeof n && !a.isEncoding(n))
|
|
615
|
+
throw new TypeError("Unknown encoding: " + n);
|
|
616
|
+
}
|
|
617
|
+
else
|
|
618
|
+
"number" == typeof t && (t &= 255); if (e < 0 || this.length < e || this.length < r)
|
|
619
|
+
throw new RangeError("Out of range index"); if (r <= e)
|
|
620
|
+
return this; var s; if (e >>>= 0, r = void 0 === r ? this.length : r >>> 0, t || (t = 0), "number" == typeof t)
|
|
621
|
+
for (s = e; s < r; ++s)
|
|
622
|
+
this[s] = t;
|
|
623
|
+
else {
|
|
624
|
+
var o = a.isBuffer(t) ? t : k(new a(t, n).toString()), u = o.length;
|
|
625
|
+
for (s = 0; s < r - e; ++s)
|
|
626
|
+
this[s + e] = o[s % u];
|
|
627
|
+
} return this; };
|
|
628
|
+
var j = /[^+\/0-9A-Za-z-_]/g;
|
|
629
|
+
function Y(t) { return t < 16 ? "0" + t.toString(16) : t.toString(16); }
|
|
630
|
+
function k(t, e) { var r; e = e || 1 / 0; for (var n = t.length, i = null, s = [], o = 0; o < n; ++o) {
|
|
631
|
+
if ((r = t.charCodeAt(o)) > 55295 && r < 57344) {
|
|
632
|
+
if (!i) {
|
|
633
|
+
if (r > 56319) {
|
|
634
|
+
(e -= 3) > -1 && s.push(239, 191, 189);
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
if (o + 1 === n) {
|
|
638
|
+
(e -= 3) > -1 && s.push(239, 191, 189);
|
|
639
|
+
continue;
|
|
640
|
+
}
|
|
641
|
+
i = r;
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (r < 56320) {
|
|
645
|
+
(e -= 3) > -1 && s.push(239, 191, 189), i = r;
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
r = 65536 + (i - 55296 << 10 | r - 56320);
|
|
649
|
+
}
|
|
650
|
+
else
|
|
651
|
+
i && (e -= 3) > -1 && s.push(239, 191, 189);
|
|
652
|
+
if (i = null, r < 128) {
|
|
653
|
+
if ((e -= 1) < 0)
|
|
654
|
+
break;
|
|
655
|
+
s.push(r);
|
|
656
|
+
}
|
|
657
|
+
else if (r < 2048) {
|
|
658
|
+
if ((e -= 2) < 0)
|
|
659
|
+
break;
|
|
660
|
+
s.push(r >> 6 | 192, 63 & r | 128);
|
|
661
|
+
}
|
|
662
|
+
else if (r < 65536) {
|
|
663
|
+
if ((e -= 3) < 0)
|
|
664
|
+
break;
|
|
665
|
+
s.push(r >> 12 | 224, r >> 6 & 63 | 128, 63 & r | 128);
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
if (!(r < 1114112))
|
|
669
|
+
throw new Error("Invalid code point");
|
|
670
|
+
if ((e -= 4) < 0)
|
|
671
|
+
break;
|
|
672
|
+
s.push(r >> 18 | 240, r >> 12 & 63 | 128, r >> 6 & 63 | 128, 63 & r | 128);
|
|
673
|
+
}
|
|
674
|
+
} return s; }
|
|
675
|
+
function F(t) { return n.toByteArray(function (t) { if ((t = function (t) { return t.trim ? t.trim() : t.replace(/^\s+|\s+$/g, ""); }(t).replace(j, "")).length < 2)
|
|
676
|
+
return ""; for (; t.length % 4 != 0;)
|
|
677
|
+
t += "="; return t; }(t)); }
|
|
678
|
+
function G(t, e, r, n) { for (var i = 0; i < n && !(i + r >= e.length || i >= t.length); ++i)
|
|
679
|
+
e[i + r] = t[i]; return i; }
|
|
680
|
+
}).call(this, r(8));
|
|
681
|
+
}, function (t, e, r) { var n; n = function () { return this; }(); try {
|
|
682
|
+
n = n || new Function("return this")();
|
|
683
|
+
}
|
|
684
|
+
catch (t) {
|
|
685
|
+
n = Object({});
|
|
686
|
+
} t.exports = n; }, function (t, e, r) {
|
|
687
|
+
"use strict";
|
|
688
|
+
e.byteLength = function (t) { var e = h(t), r = e[0], n = e[1]; return 3 * (r + n) / 4 - n; }, e.toByteArray = function (t) { var e, r, n = h(t), o = n[0], u = n[1], a = new s(function (t, e, r) { return 3 * (e + r) / 4 - r; }(0, o, u)), c = 0, f = u > 0 ? o - 4 : o; for (r = 0; r < f; r += 4)
|
|
689
|
+
e = i[t.charCodeAt(r)] << 18 | i[t.charCodeAt(r + 1)] << 12 | i[t.charCodeAt(r + 2)] << 6 | i[t.charCodeAt(r + 3)], a[c++] = e >> 16 & 255, a[c++] = e >> 8 & 255, a[c++] = 255 & e; 2 === u && (e = i[t.charCodeAt(r)] << 2 | i[t.charCodeAt(r + 1)] >> 4, a[c++] = 255 & e); 1 === u && (e = i[t.charCodeAt(r)] << 10 | i[t.charCodeAt(r + 1)] << 4 | i[t.charCodeAt(r + 2)] >> 2, a[c++] = e >> 8 & 255, a[c++] = 255 & e); return a; }, e.fromByteArray = function (t) { for (var e, r = t.length, i = r % 3, s = [], o = 0, u = r - i; o < u; o += 16383)
|
|
690
|
+
s.push(c(t, o, o + 16383 > u ? u : o + 16383)); 1 === i ? (e = t[r - 1], s.push(n[e >> 2] + n[e << 4 & 63] + "==")) : 2 === i && (e = (t[r - 2] << 8) + t[r - 1], s.push(n[e >> 10] + n[e >> 4 & 63] + n[e << 2 & 63] + "=")); return s.join(""); };
|
|
691
|
+
for (var n = [], i = [], s = "undefined" != typeof Uint8Array ? Uint8Array : Array, o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", u = 0, a = o.length; u < a; ++u)
|
|
692
|
+
n[u] = o[u], i[o.charCodeAt(u)] = u;
|
|
693
|
+
function h(t) { var e = t.length; if (e % 4 > 0)
|
|
694
|
+
throw new Error("Invalid string. Length must be a multiple of 4"); var r = t.indexOf("="); return -1 === r && (r = e), [r, r === e ? 0 : 4 - r % 4]; }
|
|
695
|
+
function c(t, e, r) { for (var i, s, o = [], u = e; u < r; u += 3)
|
|
696
|
+
i = (t[u] << 16 & 16711680) + (t[u + 1] << 8 & 65280) + (255 & t[u + 2]), o.push(n[(s = i) >> 18 & 63] + n[s >> 12 & 63] + n[s >> 6 & 63] + n[63 & s]); return o.join(""); }
|
|
697
|
+
i["-".charCodeAt(0)] = 62, i["_".charCodeAt(0)] = 63;
|
|
698
|
+
}, function (t, e) { e.read = function (t, e, r, n, i) { var s, o, u = 8 * i - n - 1, a = (1 << u) - 1, h = a >> 1, c = -7, f = r ? i - 1 : 0, l = r ? -1 : 1, d = t[e + f]; for (f += l, s = d & (1 << -c) - 1, d >>= -c, c += u; c > 0; s = 256 * s + t[e + f], f += l, c -= 8)
|
|
699
|
+
; for (o = s & (1 << -c) - 1, s >>= -c, c += n; c > 0; o = 256 * o + t[e + f], f += l, c -= 8)
|
|
700
|
+
; if (0 === s)
|
|
701
|
+
s = 1 - h;
|
|
702
|
+
else {
|
|
703
|
+
if (s === a)
|
|
704
|
+
return o ? NaN : 1 / 0 * (d ? -1 : 1);
|
|
705
|
+
o += Math.pow(2, n), s -= h;
|
|
706
|
+
} return (d ? -1 : 1) * o * Math.pow(2, s - n); }, e.write = function (t, e, r, n, i, s) { var o, u, a, h = 8 * s - i - 1, c = (1 << h) - 1, f = c >> 1, l = 23 === i ? Math.pow(2, -24) - Math.pow(2, -77) : 0, d = n ? 0 : s - 1, p = n ? 1 : -1, g = e < 0 || 0 === e && 1 / e < 0 ? 1 : 0; for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (u = isNaN(e) ? 1 : 0, o = c) : (o = Math.floor(Math.log(e) / Math.LN2), e * (a = Math.pow(2, -o)) < 1 && (o--, a *= 2), (e += o + f >= 1 ? l / a : l * Math.pow(2, 1 - f)) * a >= 2 && (o++, a /= 2), o + f >= c ? (u = 0, o = c) : o + f >= 1 ? (u = (e * a - 1) * Math.pow(2, i), o += f) : (u = e * Math.pow(2, f - 1) * Math.pow(2, i), o = 0)); i >= 8; t[r + d] = 255 & u, d += p, u /= 256, i -= 8)
|
|
707
|
+
; for (o = o << i | u, h += i; h > 0; t[r + d] = 255 & o, d += p, o /= 256, h -= 8)
|
|
708
|
+
; t[r + d - p] |= 128 * g; }; }, function (t, e) { var r = {}.toString; t.exports = Array.isArray || function (t) { return "[object Array]" == r.call(t); }; }, function (t, e, r) {
|
|
709
|
+
"use strict";
|
|
710
|
+
r.r(e);
|
|
711
|
+
var n = r(2), i = r(0), s = r(3), o = r(1), u = r(4), a = r(6);
|
|
712
|
+
function h(t) { return c.connect(t); }
|
|
713
|
+
class c {
|
|
714
|
+
constructor(t) { this.closeListeners = [], this.errorListeners = [], this.draining = !1, this.nuid = new a.a, this.options = { url: "ws://localhost:4222" }, void 0 === t.payload && (t.payload = s.a.STRING); if (!["json", "string", "binary"].includes(t.payload))
|
|
715
|
+
throw i.c.errorForCode(i.a.INVALID_PAYLOAD_TYPE); if (t.user && t.token)
|
|
716
|
+
throw i.c.errorForCode(i.a.BAD_AUTHENTICATION); Object(o.b)(this.options, t); }
|
|
717
|
+
static connect(t) { return new Promise((e, r) => { let n = new c(t); u.e.connect(t, n).then(t => { n.protocol = t, e(n); }).catch(t => { r(t); }); }); }
|
|
718
|
+
close() { this.protocol.close(); }
|
|
719
|
+
publish(t, e, r = "") { return 0 === (t = t || "").length ? (this.errorHandler(i.c.errorForCode(i.a.BAD_SUBJECT)), this) : (Object(o.d)(e) || (this.options.payload !== s.a.JSON ? e = e || "" : (e = void 0 === e ? null : e, e = JSON.stringify(e)), e = Object(o.f)(e)), this.protocol.publish(t, e, r), this); }
|
|
720
|
+
subscribe(t, e, r = {}) { return new Promise((n, s) => { this.isClosed() && s(i.c.errorForCode(i.a.CONNECTION_CLOSED)), this.isDraining() && s(i.c.errorForCode(i.a.CONNECTION_DRAINING)); let a = Object(u.k)(); Object(o.b)(a, r), a.subject = t, a.callback = e, n(this.protocol.subscribe(a)); }); }
|
|
721
|
+
request(t, e = 1e3, r) { return new Promise((n, s) => { this.isClosed() && s(i.c.errorForCode(i.a.CONNECTION_CLOSED)), this.isDraining() && s(i.c.errorForCode(i.a.CONNECTION_DRAINING)); let a = Object(u.j)(); Object(o.b)(a, { max: 1 }), a.token = this.nuid.next(), a.timeout = setTimeout(() => { h.cancel(), s("timeout"); }, e), a.callback = t => { n(t); }; let h = this.protocol.request(a); this.publish(t, r, `${this.protocol.muxSubscriptions.baseInbox}${a.token}`); }); }
|
|
722
|
+
flush(t) { if (void 0 === t)
|
|
723
|
+
return new Promise(t => { this.protocol.flush(() => { t(); }); }); this.protocol.flush(t); }
|
|
724
|
+
drain() { return this.isClosed() ? Promise.reject(i.c.errorForCode(i.a.CONNECTION_CLOSED)) : this.isDraining() ? Promise.reject(i.c.errorForCode(i.a.CONNECTION_DRAINING)) : (this.draining = !0, this.protocol.drain()); }
|
|
725
|
+
errorHandler(t) { this.errorListeners.forEach(e => { try {
|
|
726
|
+
e(t);
|
|
727
|
+
}
|
|
728
|
+
catch (t) { } }); }
|
|
729
|
+
closeHandler() { this.closeListeners.forEach(t => { try {
|
|
730
|
+
t();
|
|
731
|
+
}
|
|
732
|
+
catch (t) { } }); }
|
|
733
|
+
addEventListener(t, e) { "close" === t ? this.closeListeners.push(e) : "error" === t && this.errorListeners.push(e); }
|
|
734
|
+
isClosed() { return this.protocol.isClosed(); }
|
|
735
|
+
isDraining() { return this.draining; }
|
|
736
|
+
}
|
|
737
|
+
var f = r(5);
|
|
738
|
+
r.d(e, "DataBuffer", (function () { return n.a; })), r.d(e, "ErrorCode", (function () { return i.a; })), r.d(e, "Messages", (function () { return i.b; })), r.d(e, "NatsError", (function () { return i.c; })), r.d(e, "connect", (function () { return h; })), r.d(e, "Connection", (function () { return c; })), r.d(e, "ParserState", (function () { return u.d; })), r.d(e, "createInbox", (function () { return u.i; })), r.d(e, "Connect", (function () { return u.a; })), r.d(e, "defaultSub", (function () { return u.k; })), r.d(e, "defaultReq", (function () { return u.j; })), r.d(e, "Request", (function () { return u.f; })), r.d(e, "Subscription", (function () { return u.g; })), r.d(e, "MuxSubscription", (function () { return u.c; })), r.d(e, "Subscriptions", (function () { return u.h; })), r.d(e, "MsgBuffer", (function () { return u.b; })), r.d(e, "ProtocolHandler", (function () { return u.e; })), r.d(e, "WSTransport", (function () { return f.a; })), r.d(e, "isArrayBuffer", (function () { return o.d; })), r.d(e, "extend", (function () { return o.b; })), r.d(e, "extractProtocolMessage", (function () { return o.c; })), r.d(e, "buildWSMessage", (function () { return o.a; })), r.d(e, "settle", (function () { return o.e; })), r.d(e, "stringToUint8Array", (function () { return o.f; }));
|
|
739
|
+
}]);
|
|
740
|
+
}));
|
|
741
741
|
|
|
742
742
|
});
|
|
743
743
|
|
|
744
744
|
var nats_min$1 = /*@__PURE__*/getDefaultExportFromCjs(nats_min);
|
|
745
745
|
|
|
746
|
-
//declare let nats_min: any;
|
|
747
|
-
class Chat4appClientAngularService {
|
|
748
|
-
constructor(http) {
|
|
749
|
-
this.http = http;
|
|
750
|
-
this.chatServer = "";
|
|
751
|
-
this.chatUrl = "";
|
|
752
|
-
this.debug = false;
|
|
753
|
-
this.chatUserExternalId = "";
|
|
754
|
-
this.timeoutReconnect = 500;
|
|
755
|
-
}
|
|
756
|
-
ngOnInit() {
|
|
757
|
-
}
|
|
758
|
-
config(chat4AppConfig) {
|
|
759
|
-
this.chatServer = chat4AppConfig.endpoint;
|
|
760
|
-
this.chatUrl = chat4AppConfig.endpoint + "/api/v1/";
|
|
761
|
-
this.debug = chat4AppConfig.debug;
|
|
762
|
-
}
|
|
763
|
-
init(securityChatToken, callback, chatCallback, connectionClientId) {
|
|
764
|
-
if (!this.chatServer || this.chatServer.trim().length == 0) {
|
|
765
|
-
throw new Error("Endpoint is empty");
|
|
766
|
-
}
|
|
767
|
-
if (!securityChatToken || securityChatToken.trim().length == 0) {
|
|
768
|
-
throw new Error("SecurityChatToken is empty");
|
|
769
|
-
}
|
|
770
|
-
this.setTokenChat4app(securityChatToken);
|
|
771
|
-
if (chatCallback && connectionClientId) {
|
|
772
|
-
this.connectWebsocket(chatCallback, connectionClientId);
|
|
773
|
-
}
|
|
774
|
-
callback(securityChatToken);
|
|
775
|
-
}
|
|
776
|
-
getChatUrlDownload(messageFileId) {
|
|
777
|
-
return this.chatUrl + "chatmessage/getFile?messageFileId=" + messageFileId + "&token=" + this.getBearerToken();
|
|
778
|
-
}
|
|
779
|
-
getMessageChat(chatId, fromId, toId) {
|
|
780
|
-
let url = this.chatUrl + "chatmessage/" + chatId + "/" + fromId + "/" + toId;
|
|
781
|
-
return this.http.get(url, {
|
|
782
|
-
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
getMessageChatByGrop(chatId, groupId, fromId) {
|
|
786
|
-
let url = this.chatUrl + "chatmessage/byGroup/" + chatId + "/" + groupId + "/" + fromId;
|
|
787
|
-
return this.http.get(url, {
|
|
788
|
-
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
addMessageChat(chatMessage4App) {
|
|
792
|
-
let url = this.chatUrl + "chatmessage/" + chatMessage4App.chatId;
|
|
793
|
-
return this.http.post(url, chatMessage4App, {
|
|
794
|
-
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
params.push("
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
let url = this.chatUrl;
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
return this.http.
|
|
919
|
-
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
let url = this.chatUrl + "
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
return this.http
|
|
948
|
-
.
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
})
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
chat4appMessage
|
|
1062
|
-
chat4appMessage.data.
|
|
1063
|
-
chat4appMessage.data.
|
|
1064
|
-
chat4appMessage.data.
|
|
1065
|
-
chat4appMessage.data.
|
|
1066
|
-
chat4appMessage.data.
|
|
1067
|
-
chat4appMessage.data.
|
|
1068
|
-
chat4appMessage.data.
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
let
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
chat4appMessage.data.
|
|
1082
|
-
chat4appMessage
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
chat4appMessage
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
chat4appMessage.data.
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
let
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
chat4appMessage.data.
|
|
1099
|
-
chat4appMessage
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
chat4appMessage
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
chat4appMessage.data.
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
let
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
chat4appMessage.data.
|
|
1116
|
-
chat4appMessage
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
chat4appMessage
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
chat4appMessage.data.
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
let
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
chat4appMessage.data.
|
|
1133
|
-
chat4appMessage
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
chat4appMessage
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
chat4appMessage.data.
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
let
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
chat4appMessage.data.
|
|
1150
|
-
chat4appMessage
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
chat4appMessage
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
chat4appMessage.data.
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
let
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
chat4appMessage.data.
|
|
1167
|
-
chat4appMessage
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
chat4appMessage
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
chat4appMessage.data.
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
let
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
if (this.
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
if (
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
746
|
+
//declare let nats_min: any;
|
|
747
|
+
class Chat4appClientAngularService {
|
|
748
|
+
constructor(http) {
|
|
749
|
+
this.http = http;
|
|
750
|
+
this.chatServer = "";
|
|
751
|
+
this.chatUrl = "";
|
|
752
|
+
this.debug = false;
|
|
753
|
+
this.chatUserExternalId = "";
|
|
754
|
+
this.timeoutReconnect = 500;
|
|
755
|
+
}
|
|
756
|
+
ngOnInit() {
|
|
757
|
+
}
|
|
758
|
+
config(chat4AppConfig) {
|
|
759
|
+
this.chatServer = chat4AppConfig.endpoint;
|
|
760
|
+
this.chatUrl = chat4AppConfig.endpoint + "/api/v1/";
|
|
761
|
+
this.debug = chat4AppConfig.debug;
|
|
762
|
+
}
|
|
763
|
+
init(securityChatToken, callback, chatCallback, connectionClientId) {
|
|
764
|
+
if (!this.chatServer || this.chatServer.trim().length == 0) {
|
|
765
|
+
throw new Error("Endpoint is empty");
|
|
766
|
+
}
|
|
767
|
+
if (!securityChatToken || securityChatToken.trim().length == 0) {
|
|
768
|
+
throw new Error("SecurityChatToken is empty");
|
|
769
|
+
}
|
|
770
|
+
this.setTokenChat4app(securityChatToken);
|
|
771
|
+
if (chatCallback && connectionClientId) {
|
|
772
|
+
this.connectWebsocket(chatCallback, connectionClientId);
|
|
773
|
+
}
|
|
774
|
+
callback(securityChatToken);
|
|
775
|
+
}
|
|
776
|
+
getChatUrlDownload(messageFileId) {
|
|
777
|
+
return this.chatUrl + "chatmessage/getFile?messageFileId=" + messageFileId + "&token=" + this.getBearerToken();
|
|
778
|
+
}
|
|
779
|
+
getMessageChat(chatId, fromId, toId) {
|
|
780
|
+
let url = this.chatUrl + "chatmessage/" + chatId + "/" + fromId + "/" + toId;
|
|
781
|
+
return this.http.get(url, {
|
|
782
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
getMessageChatByGrop(chatId, groupId, fromId) {
|
|
786
|
+
let url = this.chatUrl + "chatmessage/byGroup/" + chatId + "/" + groupId + "/" + fromId;
|
|
787
|
+
return this.http.get(url, {
|
|
788
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
addMessageChat(chatMessage4App) {
|
|
792
|
+
let url = this.chatUrl + "chatmessage/" + chatMessage4App.chatId;
|
|
793
|
+
return this.http.post(url, chatMessage4App, {
|
|
794
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
/*
|
|
798
|
+
props(chatFilterRequest4App: Array<ChatFilterRequest4App>): Observable<ChatUserResponse4App[]> {
|
|
799
|
+
let url = this.chatUrl + "chatmessage/props";
|
|
800
|
+
|
|
801
|
+
return this.http.post<ChatUserResponse4App[]>(url, chatFilterRequest4App,
|
|
802
|
+
{
|
|
803
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
804
|
+
})
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
*/
|
|
808
|
+
removeUsersChat(chatId, chatUsersId, chatUsersExternalId) {
|
|
809
|
+
let params = new Array();
|
|
810
|
+
if (chatUsersId && chatUsersId.length > 0) {
|
|
811
|
+
chatUsersId.forEach(cui => {
|
|
812
|
+
params.push("chatUserId=" + cui);
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
else if (chatUsersExternalId && chatUsersExternalId.length > 0) {
|
|
816
|
+
chatUsersExternalId.forEach(cuei => {
|
|
817
|
+
params.push("chatUserExternalId=" + cuei);
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
let url = this.chatUrl + "chatuser/" + chatId + "?" + params.join("&");
|
|
821
|
+
return this.http.delete(url, {
|
|
822
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
removeUserChat(chatId, chatUserId, chatUserExternalId) {
|
|
826
|
+
let param = "";
|
|
827
|
+
if (chatUserId) {
|
|
828
|
+
param = "chatUserId=" + chatUserId;
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
param = "chatUserExternalId=" + chatUserExternalId;
|
|
832
|
+
}
|
|
833
|
+
let url = this.chatUrl + "chatuser/" + chatId + "?" + param;
|
|
834
|
+
return this.http.delete(url, {
|
|
835
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
updateUserChat(chatId, charUser4AppUpdate) {
|
|
839
|
+
let url = this.chatUrl + "chatuser/" + chatId;
|
|
840
|
+
return this.http.put(url, charUser4AppUpdate, {
|
|
841
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
createUserChat(chatId, chatUser4App) {
|
|
845
|
+
let url = this.chatUrl + "chatuser/" + chatId;
|
|
846
|
+
return this.http.post(url, chatUser4App, {
|
|
847
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
createUsersChat(chatId, chatUser4App) {
|
|
851
|
+
let url = this.chatUrl + "chatuser/users/" + chatId;
|
|
852
|
+
return this.http.post(url, chatUser4App, {
|
|
853
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
createChat(chat4app) {
|
|
857
|
+
let url = this.chatUrl + "chat";
|
|
858
|
+
return this.http.post(url, chat4app, {
|
|
859
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
createUpdateChat(chat4app) {
|
|
863
|
+
let url = this.chatUrl + "chat";
|
|
864
|
+
return this.http.put(url, chat4app, {
|
|
865
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
/*
|
|
869
|
+
getLastMessageGroup(chatExternalId: string, groupId: string): Observable<ChatUserResponse4App> {
|
|
870
|
+
|
|
871
|
+
let url = this.chatUrl + "chatmessage/lastMessageGroup?chatExternalId=" + chatExternalId + "&groupId=" + groupId;
|
|
872
|
+
|
|
873
|
+
return this.http.get<ChatUserResponse4App>(url,
|
|
874
|
+
{
|
|
875
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
876
|
+
})
|
|
877
|
+
}
|
|
878
|
+
getLastMessage(chatExternalId: string, chatUserExternalId: string): Observable<ChatUserResponse4App> {
|
|
879
|
+
|
|
880
|
+
let url = this.chatUrl + "chatmessage/lastMessage?chatExternalId=" + chatExternalId + "&chatUserExternalId=" + chatUserExternalId;
|
|
881
|
+
|
|
882
|
+
return this.http.get<ChatUserResponse4App>(url,
|
|
883
|
+
{
|
|
884
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
885
|
+
})
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
countNotReadMessages(chatUserExternalId: string, chatExternalId?: string, groupId?: string, fromId?:string): Observable<ChatUserResponse4App> {
|
|
889
|
+
|
|
890
|
+
let url = this.chatUrl + "chatmessage/countNotReadMessages?chatUserExternalId=" + chatUserExternalId;
|
|
891
|
+
|
|
892
|
+
if (chatExternalId && chatExternalId.length > 0) {
|
|
893
|
+
url += "&chatExternalId=" + chatExternalId;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
if (groupId && groupId.length > 0) {
|
|
897
|
+
url += "&groupId=" + groupId;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
if (fromId && fromId.length > 0) {
|
|
901
|
+
url += "&fromId=" + groupId;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
return this.http.get<ChatUserResponse4App>(url,
|
|
905
|
+
{
|
|
906
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
907
|
+
})
|
|
908
|
+
}
|
|
909
|
+
*/
|
|
910
|
+
getChatByExternalId(externalId) {
|
|
911
|
+
let url = this.chatUrl + "chat?externalId=" + externalId;
|
|
912
|
+
return this.http.get(url, {
|
|
913
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
getChatById(id) {
|
|
917
|
+
let url = this.chatUrl + "chat?chatId=" + id;
|
|
918
|
+
return this.http.get(url, {
|
|
919
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
listChatByUser(externalUserId, userId, chatStatus) {
|
|
923
|
+
let url = this.chatUrl + "chat/listChatByUser/?externalUserId=" + externalUserId
|
|
924
|
+
+ "&userId=" + userId
|
|
925
|
+
+ "&chatStatus=" + chatStatus;
|
|
926
|
+
return this.http.get(url, {
|
|
927
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
closeChat(chatId, chatExternalId) {
|
|
931
|
+
let url = this.chatUrl;
|
|
932
|
+
if (chatId && chatId.length > 0) {
|
|
933
|
+
url += "chat?chatId=" + chatId;
|
|
934
|
+
}
|
|
935
|
+
if (chatExternalId && chatExternalId.length > 0) {
|
|
936
|
+
url += "chat?externalId=" + chatExternalId;
|
|
937
|
+
}
|
|
938
|
+
return this.http.delete(url, {
|
|
939
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
readMessage(chatMessageId, toId) {
|
|
943
|
+
let url = this.chatUrl + "chatmessage/read/" + chatMessageId;
|
|
944
|
+
if (toId && toId.length > 0) {
|
|
945
|
+
url += "/" + toId;
|
|
946
|
+
}
|
|
947
|
+
return this.http.put(url, null, {
|
|
948
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
online(chatId) {
|
|
952
|
+
let url = this.chatUrl + "chatmessage/online/" + chatId;
|
|
953
|
+
return this.http.get(url, {
|
|
954
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
setOffLine(chatUserExternalIdId) {
|
|
958
|
+
let url = this.chatUrl + "chatmessage/set-offline/" + chatUserExternalIdId;
|
|
959
|
+
return this.http.put(url, null, {
|
|
960
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
sendFile(chatId, fromId, toId, fileToUpload) {
|
|
964
|
+
const endpoint = this.chatUrl + "chatmessage/sendFile/" + chatId + "/" + fromId + "/" + toId;
|
|
965
|
+
const formData = new FormData();
|
|
966
|
+
formData.append('file', fileToUpload);
|
|
967
|
+
return this.http
|
|
968
|
+
.post(endpoint, formData, {
|
|
969
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
sendFileGroup(chatId, fromId, groupId, fileToUpload) {
|
|
973
|
+
const endpoint = this.chatUrl + "chatmessage/sendFileGroup/" + chatId + "/" + fromId + "/" + groupId;
|
|
974
|
+
const formData = new FormData();
|
|
975
|
+
formData.append('file', fileToUpload);
|
|
976
|
+
return this.http
|
|
977
|
+
.post(endpoint, formData, {
|
|
978
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
/*
|
|
982
|
+
translateMessage(chatMessageId: string, languageTarget: string): Observable<Chat4AppTranslate> {
|
|
983
|
+
|
|
984
|
+
let url = this.chatUrl + "chatmessage/translate/" + chatMessageId + "/" + languageTarget;
|
|
985
|
+
|
|
986
|
+
return this.http.get<Chat4AppTranslate>(url,
|
|
987
|
+
{
|
|
988
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
989
|
+
})
|
|
990
|
+
}
|
|
991
|
+
*/
|
|
992
|
+
startTyping(chatId, fromId, toId) {
|
|
993
|
+
let url = this.chatUrl + "chatmessage/startTyping/" + chatId + "/" + fromId + "/" + toId;
|
|
994
|
+
return this.http.put(url, null, {
|
|
995
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
startTypingGroup(chatId, fromId, groupId) {
|
|
999
|
+
let url = this.chatUrl + "chatmessage/startTypingGroup/" + chatId + "/" + fromId + "/" + groupId;
|
|
1000
|
+
return this.http.put(url, null, {
|
|
1001
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
stopTyping(chatId, fromId, toId) {
|
|
1005
|
+
let url = this.chatUrl + "chatmessage/stopTyping/" + chatId + "/" + fromId + "/" + toId;
|
|
1006
|
+
return this.http.put(url, null, {
|
|
1007
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
stopTypingGroup(chatId, fromId, groupId) {
|
|
1011
|
+
let url = this.chatUrl + "chatmessage/stopTypingGroup/" + chatId + "/" + fromId + "/" + groupId;
|
|
1012
|
+
return this.http.put(url, null, {
|
|
1013
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
createGroup(group) {
|
|
1017
|
+
let url = this.chatUrl + "/group";
|
|
1018
|
+
return this.http.post(url, group, {
|
|
1019
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
getGroup(chatId, groupId) {
|
|
1023
|
+
let url = this.chatUrl + "/group/" + groupId + "/" + chatId;
|
|
1024
|
+
return this.http.get(url, {
|
|
1025
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
listGroups(chatId, externalId) {
|
|
1029
|
+
let url = this.chatUrl + "/group/";
|
|
1030
|
+
if (chatId && chatId.length > 0) {
|
|
1031
|
+
url += "&chatId=" + chatId;
|
|
1032
|
+
}
|
|
1033
|
+
if (externalId && externalId.length > 0) {
|
|
1034
|
+
url += "&externalId=" + externalId;
|
|
1035
|
+
}
|
|
1036
|
+
return this.http.get(url, {
|
|
1037
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
listFilesGroup(chatId, groupId) {
|
|
1041
|
+
let url = this.chatUrl + "/group/" + chatId;
|
|
1042
|
+
if (groupId && groupId.length > 0) {
|
|
1043
|
+
url += "&groupId=" + chatId;
|
|
1044
|
+
}
|
|
1045
|
+
return this.http.get(url, {
|
|
1046
|
+
headers: new HttpHeaders().set('Authorization', this.getBearerToken())
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
/* Token */
|
|
1050
|
+
getBearerToken() {
|
|
1051
|
+
let ret = "Bearer " + window.sessionStorage.getItem("chat4AppSessionToken");
|
|
1052
|
+
return ret;
|
|
1053
|
+
}
|
|
1054
|
+
setTokenChat4app(chat4AppSessionToken) {
|
|
1055
|
+
window.sessionStorage.setItem("chat4AppSessionToken", chat4AppSessionToken);
|
|
1056
|
+
}
|
|
1057
|
+
/* Connection */
|
|
1058
|
+
onMessageFirebaseReceived(data, chatCallback) {
|
|
1059
|
+
//alert("onMessageReceived connectFirebase");
|
|
1060
|
+
if (data.type == "msg") {
|
|
1061
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1062
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1063
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1064
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1065
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1066
|
+
chat4appMessage.data.toId = data.toId;
|
|
1067
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1068
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1069
|
+
chat4appMessage.data.type = data.type;
|
|
1070
|
+
chat4appMessage.notification.body = data.body;
|
|
1071
|
+
if (data.fileId && data.fileId.length > 0) {
|
|
1072
|
+
chat4appMessage.data.fileId = data.fileId;
|
|
1073
|
+
chat4appMessage.data.fileName = data.fileName;
|
|
1074
|
+
chat4appMessage.data.fileSize = data.fileSize;
|
|
1075
|
+
chat4appMessage.data.fileType = data.fileType;
|
|
1076
|
+
}
|
|
1077
|
+
let datTmp = new Map();
|
|
1078
|
+
for (let key in data) {
|
|
1079
|
+
datTmp.set(key, data[key]);
|
|
1080
|
+
}
|
|
1081
|
+
chat4appMessage.data.all = datTmp;
|
|
1082
|
+
chatCallback.onMessage(chat4appMessage);
|
|
1083
|
+
}
|
|
1084
|
+
else if ((data.type == "on" || data.type == "off")) {
|
|
1085
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1086
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1087
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1088
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1089
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1090
|
+
chat4appMessage.data.toId = data.toId;
|
|
1091
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1092
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1093
|
+
chat4appMessage.data.type = data.type;
|
|
1094
|
+
let datTmp = new Map();
|
|
1095
|
+
for (let key in data) {
|
|
1096
|
+
datTmp.set(key, data[key]);
|
|
1097
|
+
}
|
|
1098
|
+
chat4appMessage.data.all = datTmp;
|
|
1099
|
+
chatCallback.onOffline(chat4appMessage);
|
|
1100
|
+
}
|
|
1101
|
+
else if (data.type == "read") {
|
|
1102
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1103
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1104
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1105
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1106
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1107
|
+
chat4appMessage.data.toId = data.toId;
|
|
1108
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1109
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1110
|
+
chat4appMessage.data.type = data.type;
|
|
1111
|
+
let datTmp = new Map();
|
|
1112
|
+
for (let key in data) {
|
|
1113
|
+
datTmp.set(key, data[key]);
|
|
1114
|
+
}
|
|
1115
|
+
chat4appMessage.data.all = datTmp;
|
|
1116
|
+
chatCallback.onRead(chat4appMessage);
|
|
1117
|
+
}
|
|
1118
|
+
else if (data.type == "startTyping" || data.type == "stopTyping") {
|
|
1119
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1120
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1121
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1122
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1123
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1124
|
+
chat4appMessage.data.toId = data.toId;
|
|
1125
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1126
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1127
|
+
chat4appMessage.data.type = data.type;
|
|
1128
|
+
let datTmp = new Map();
|
|
1129
|
+
for (let key in data) {
|
|
1130
|
+
datTmp.set(key, data[key]);
|
|
1131
|
+
}
|
|
1132
|
+
chat4appMessage.data.all = datTmp;
|
|
1133
|
+
chatCallback.onStartStopTyping(chat4appMessage);
|
|
1134
|
+
}
|
|
1135
|
+
else if (data.type == "new_user") {
|
|
1136
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1137
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1138
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1139
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1140
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1141
|
+
chat4appMessage.data.toId = data.toId;
|
|
1142
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1143
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1144
|
+
chat4appMessage.data.type = data.type;
|
|
1145
|
+
let datTmp = new Map();
|
|
1146
|
+
for (let key in data) {
|
|
1147
|
+
datTmp.set(key, data[key]);
|
|
1148
|
+
}
|
|
1149
|
+
chat4appMessage.data.all = datTmp;
|
|
1150
|
+
chatCallback.onNewUser(chat4appMessage);
|
|
1151
|
+
}
|
|
1152
|
+
else if (data.type == "remove_user") {
|
|
1153
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1154
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1155
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1156
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1157
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1158
|
+
chat4appMessage.data.toId = data.toId;
|
|
1159
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1160
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1161
|
+
chat4appMessage.data.type = data.type;
|
|
1162
|
+
let datTmp = new Map();
|
|
1163
|
+
for (let key in data) {
|
|
1164
|
+
datTmp.set(key, data[key]);
|
|
1165
|
+
}
|
|
1166
|
+
chat4appMessage.data.all = datTmp;
|
|
1167
|
+
chatCallback.onRemoveUser(chat4appMessage);
|
|
1168
|
+
}
|
|
1169
|
+
else if (data.type == "chat_closed") {
|
|
1170
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1171
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1172
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1173
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1174
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1175
|
+
chat4appMessage.data.toId = data.toId;
|
|
1176
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1177
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1178
|
+
chat4appMessage.data.type = data.type;
|
|
1179
|
+
let datTmp = new Map();
|
|
1180
|
+
for (let key in data) {
|
|
1181
|
+
datTmp.set(key, data[key]);
|
|
1182
|
+
}
|
|
1183
|
+
chat4appMessage.data.all = datTmp;
|
|
1184
|
+
chatCallback.onChatClosed(chat4appMessage);
|
|
1185
|
+
}
|
|
1186
|
+
else if (data.type == "count_notread") {
|
|
1187
|
+
let chat4appMessage = new Chat4AppMessageReceive();
|
|
1188
|
+
chat4appMessage.data.chatId = data.chatId;
|
|
1189
|
+
chat4appMessage.data.chatMessageId = data.chatMessageId;
|
|
1190
|
+
chat4appMessage.data.externalId = data.externalId;
|
|
1191
|
+
chat4appMessage.data.fromId = data.fromId;
|
|
1192
|
+
chat4appMessage.data.toId = data.toId;
|
|
1193
|
+
chat4appMessage.data.groupId = data.groupId;
|
|
1194
|
+
chat4appMessage.data.dateHour = data.dateHour;
|
|
1195
|
+
chat4appMessage.data.type = data.type;
|
|
1196
|
+
let datTmp = new Map();
|
|
1197
|
+
for (let key in data) {
|
|
1198
|
+
datTmp.set(key, data[key]);
|
|
1199
|
+
}
|
|
1200
|
+
chat4appMessage.data.all = datTmp;
|
|
1201
|
+
chatCallback.onCountNotRead(chat4appMessage);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
ensureConn(chatUserExternalId) {
|
|
1205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1206
|
+
if (this.debug) {
|
|
1207
|
+
console.log(`chatServer: ${this.chatServer}`);
|
|
1208
|
+
console.log(`userId: ${chatUserExternalId}`);
|
|
1209
|
+
console.log(`getBearerToken: ${this.getBearerToken()}`);
|
|
1210
|
+
}
|
|
1211
|
+
const that = this;
|
|
1212
|
+
let uriStep1 = this.chatServer.replace(/^https/, 'wss');
|
|
1213
|
+
let server = uriStep1.replace(/(\/\/.*?)\//, '$1\/ws/');
|
|
1214
|
+
if (this.debug) {
|
|
1215
|
+
console.log(`ws server: ${server}`);
|
|
1216
|
+
}
|
|
1217
|
+
if (!this.nc || (this.nc.isClose && this.nc.isClose())) {
|
|
1218
|
+
that.nc = yield nats_min.connect({ url: server, user: chatUserExternalId, pass: this.getBearerToken(), reconnect: true });
|
|
1219
|
+
}
|
|
1220
|
+
this.chatUserExternalId = chatUserExternalId;
|
|
1221
|
+
return that.nc;
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
disconnect() {
|
|
1225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1226
|
+
// Check how we can disconnect
|
|
1227
|
+
if (this.interval) {
|
|
1228
|
+
try {
|
|
1229
|
+
clearInterval(this.interval);
|
|
1230
|
+
}
|
|
1231
|
+
catch (e) {
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
if (this.nc && this.chatUserExternalId && this.chatUserExternalId.length > 0 && this.getBearerToken() && this.getBearerToken().length > 0) {
|
|
1235
|
+
this.setOffLine(this.chatUserExternalId).subscribe(() => {
|
|
1236
|
+
if (this.debug) {
|
|
1237
|
+
console.log("had set offline");
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
if (this.nc) {
|
|
1242
|
+
try {
|
|
1243
|
+
yield this.nc.close();
|
|
1244
|
+
}
|
|
1245
|
+
catch (e) {
|
|
1246
|
+
if (this.debug) {
|
|
1247
|
+
console.error(e);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
this.nc = undefined;
|
|
1251
|
+
}
|
|
1252
|
+
if (this.debug) {
|
|
1253
|
+
console.log("disconect");
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
processAndCallback(msgObj, chatCallback) {
|
|
1258
|
+
if (this.debug && msgObj) {
|
|
1259
|
+
console.log("Msg Received: " + JSON.stringify(msgObj));
|
|
1260
|
+
}
|
|
1261
|
+
//if (!chatCallback.isTokenFirebaseActive()) {
|
|
1262
|
+
let datTmp = new Map();
|
|
1263
|
+
for (let key in msgObj.data) {
|
|
1264
|
+
datTmp.set(key, msgObj.data[key]);
|
|
1265
|
+
}
|
|
1266
|
+
msgObj.data.all = datTmp;
|
|
1267
|
+
if (msgObj.data.type == "msg") {
|
|
1268
|
+
chatCallback.onMessage(msgObj);
|
|
1269
|
+
}
|
|
1270
|
+
else if ((msgObj.data.type == "on" || msgObj.data.type == "off")) {
|
|
1271
|
+
chatCallback.onOffline(msgObj);
|
|
1272
|
+
}
|
|
1273
|
+
else if (msgObj.data.type == "read") {
|
|
1274
|
+
chatCallback.onRead(msgObj);
|
|
1275
|
+
}
|
|
1276
|
+
else if (msgObj.data.type == "startTyping" || msgObj.data.type == "stopTyping") {
|
|
1277
|
+
chatCallback.onStartStopTyping(msgObj);
|
|
1278
|
+
}
|
|
1279
|
+
else if (msgObj.data.type == "new_user") {
|
|
1280
|
+
chatCallback.onNewUser(msgObj);
|
|
1281
|
+
}
|
|
1282
|
+
else if (msgObj.data.type == "remove_user") {
|
|
1283
|
+
chatCallback.onRemoveUser(msgObj);
|
|
1284
|
+
}
|
|
1285
|
+
else if (msgObj.data.type == "chat_closed") {
|
|
1286
|
+
chatCallback.onChatClosed(msgObj);
|
|
1287
|
+
}
|
|
1288
|
+
else if (msgObj.data.type == "count_notread") {
|
|
1289
|
+
chatCallback.onCountNotRead(msgObj);
|
|
1290
|
+
}
|
|
1291
|
+
//}
|
|
1292
|
+
}
|
|
1293
|
+
connectWebsocket(chatCallback, userId) {
|
|
1294
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1295
|
+
const that = this;
|
|
1296
|
+
this.disconnect();
|
|
1297
|
+
let securityToken = this.getBearerToken();
|
|
1298
|
+
let tokenAuth = "";
|
|
1299
|
+
if (securityToken && securityToken.startsWith("Bearer ")) {
|
|
1300
|
+
tokenAuth = securityToken;
|
|
1301
|
+
}
|
|
1302
|
+
else {
|
|
1303
|
+
tokenAuth = "Bearer " + securityToken;
|
|
1304
|
+
}
|
|
1305
|
+
const configId = this.chatServer.split("/")[3];
|
|
1306
|
+
const nc = yield this.ensureConn(userId);
|
|
1307
|
+
//TODO Get the user id from jwt
|
|
1308
|
+
const subject = `chat4app.config.${configId}.user.${userId}`;
|
|
1309
|
+
const sub = nc.subscribe(subject, (msg) => {
|
|
1310
|
+
if (this.debug) {
|
|
1311
|
+
console.log(msg);
|
|
1312
|
+
}
|
|
1313
|
+
this.processAndCallback(JSON.parse(msg.data), chatCallback);
|
|
1314
|
+
});
|
|
1315
|
+
if (this.interval) {
|
|
1316
|
+
try {
|
|
1317
|
+
clearInterval(this.interval);
|
|
1318
|
+
}
|
|
1319
|
+
catch (e) {
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
that.interval = setInterval(() => {
|
|
1323
|
+
if (that.debug) {
|
|
1324
|
+
console.log(`publish chat4app.user.online ${userId} `);
|
|
1325
|
+
}
|
|
1326
|
+
that.nc.publish(`chat4app.user.online`, userId);
|
|
1327
|
+
}, 1000);
|
|
1328
|
+
if (this.debug) {
|
|
1329
|
+
console.log(`Subscribe online chat4app.user.${userId}.online`);
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
/*
|
|
1334
|
+
disconnect() {
|
|
1335
|
+
// console.log("disconnect")
|
|
1336
|
+
try {
|
|
1337
|
+
if (this.stompClient) {
|
|
1338
|
+
this.stompClient.disconnect();
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
} catch (e) {
|
|
1342
|
+
console.log(e);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
*/
|
|
1346
|
+
convertChat4AppMessageReceiveToChatMessage4App(msg) {
|
|
1347
|
+
var _a;
|
|
1348
|
+
let message = new ChatMessage4App();
|
|
1349
|
+
message.body = (_a = msg === null || msg === void 0 ? void 0 : msg.notification) === null || _a === void 0 ? void 0 : _a.body;
|
|
1350
|
+
message.chatId = msg.data.chatId;
|
|
1351
|
+
message.fromId = msg.data.fromId;
|
|
1352
|
+
message.toId = msg.data.toId;
|
|
1353
|
+
message.groupId = msg.data.groupId;
|
|
1354
|
+
message.replyFrom = msg.data.replyFrom;
|
|
1355
|
+
if (msg.data.dateHour && msg.data.dateHour.length > 0) {
|
|
1356
|
+
message.dateHourIncluded = msg.data.dateHour.substring(6, 10) + "-"
|
|
1357
|
+
+ msg.data.dateHour.substring(3, 5) + "-"
|
|
1358
|
+
+ msg.data.dateHour.substring(0, 2)
|
|
1359
|
+
+ msg.data.dateHour.substring(10);
|
|
1360
|
+
}
|
|
1361
|
+
message.id = msg.data.chatMessageId;
|
|
1362
|
+
if (msg.data.fileId && msg.data.fileId.length > 0) {
|
|
1363
|
+
let messageFile = new ChatMessageFile4App();
|
|
1364
|
+
messageFile.id = msg.data.fileId;
|
|
1365
|
+
messageFile.name = msg.data.fileName;
|
|
1366
|
+
messageFile.size = msg.data.fileSize;
|
|
1367
|
+
messageFile.type = msg.data.fileType;
|
|
1368
|
+
message.chatMessageFile = messageFile;
|
|
1369
|
+
}
|
|
1370
|
+
if (msg.data.vFileId && msg.data.vFileId.length > 0) {
|
|
1371
|
+
let messageFile = new ChatMessageFile4App();
|
|
1372
|
+
messageFile.id = msg.data.vFileId;
|
|
1373
|
+
messageFile.name = msg.data.vFileName;
|
|
1374
|
+
messageFile.size = msg.data.vFileSize;
|
|
1375
|
+
messageFile.type = msg.data.vFileType;
|
|
1376
|
+
message.chatVoiceFile = messageFile;
|
|
1377
|
+
}
|
|
1378
|
+
return message;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
Chat4appClientAngularService.ɵprov = i0.ɵɵdefineInjectable({ factory: function Chat4appClientAngularService_Factory() { return new Chat4appClientAngularService(i0.ɵɵinject(i1.HttpClient)); }, token: Chat4appClientAngularService, providedIn: "root" });
|
|
1382
|
+
Chat4appClientAngularService.decorators = [
|
|
1383
|
+
{ type: Injectable, args: [{
|
|
1384
|
+
providedIn: 'root'
|
|
1385
|
+
},] }
|
|
1386
|
+
];
|
|
1387
|
+
Chat4appClientAngularService.ctorParameters = () => [
|
|
1388
|
+
{ type: HttpClient }
|
|
1389
|
+
];
|
|
1390
|
+
class Chat4App {
|
|
1391
|
+
}
|
|
1392
|
+
class ChatUser4App {
|
|
1393
|
+
}
|
|
1394
|
+
class ChatMessage4App {
|
|
1395
|
+
}
|
|
1396
|
+
class ChatMessageFile4App {
|
|
1397
|
+
}
|
|
1398
|
+
class ChatMessageMeta4App {
|
|
1399
|
+
}
|
|
1400
|
+
class Chat4AppMessageReceive {
|
|
1401
|
+
constructor() {
|
|
1402
|
+
this.data = new Chat4AppMessageReceiveData();
|
|
1403
|
+
this.notification = new Chat4AppMessageReceiveNotification();
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
class Chat4AppMessageReceiveData {
|
|
1407
|
+
}
|
|
1408
|
+
class Chat4AppMessageReceiveNotification {
|
|
1409
|
+
}
|
|
1410
|
+
class ChatUserResponse4App {
|
|
1411
|
+
}
|
|
1412
|
+
class ChatFilterRequest4App {
|
|
1413
|
+
}
|
|
1414
|
+
class Chat4AppConfig {
|
|
1415
|
+
constructor(endpoint, debug) {
|
|
1416
|
+
this.endpoint = endpoint;
|
|
1417
|
+
this.debug = debug;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
class Chat4AppTranslate {
|
|
1421
|
+
}
|
|
1422
|
+
class ChatGroupApp {
|
|
1423
|
+
}
|
|
1424
|
+
var ChatStatus4App;
|
|
1425
|
+
(function (ChatStatus4App) {
|
|
1426
|
+
ChatStatus4App["CREATED"] = "CREATED";
|
|
1427
|
+
ChatStatus4App["CLOSED"] = "CLOSED";
|
|
1428
|
+
})(ChatStatus4App || (ChatStatus4App = {}));
|
|
1429
|
+
var ChatUserStatus4App;
|
|
1430
|
+
(function (ChatUserStatus4App) {
|
|
1431
|
+
ChatUserStatus4App["REMOVED"] = "REMOVED";
|
|
1432
|
+
})(ChatUserStatus4App || (ChatUserStatus4App = {}));
|
|
1433
|
+
var ChatFilterType;
|
|
1434
|
+
(function (ChatFilterType) {
|
|
1435
|
+
ChatFilterType[ChatFilterType["COUNT_NOT_READ"] = 1] = "COUNT_NOT_READ";
|
|
1436
|
+
ChatFilterType[ChatFilterType["LAST_MESSAGE"] = 2] = "LAST_MESSAGE";
|
|
1437
|
+
})(ChatFilterType || (ChatFilterType = {}));
|
|
1438
|
+
var GroupStatus4App;
|
|
1439
|
+
(function (GroupStatus4App) {
|
|
1440
|
+
GroupStatus4App["CREATED"] = "CREATED";
|
|
1441
|
+
GroupStatus4App["CLOSED"] = "REMOVED";
|
|
1417
1442
|
})(GroupStatus4App || (GroupStatus4App = {}));
|
|
1418
1443
|
|
|
1419
|
-
class Chat4appClientAngularComponent {
|
|
1420
|
-
constructor() { }
|
|
1421
|
-
ngOnInit() {
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
Chat4appClientAngularComponent.decorators = [
|
|
1425
|
-
{ type: Component, args: [{
|
|
1426
|
-
selector: 'lib-chat4app-client-angular',
|
|
1427
|
-
template: `
|
|
1428
|
-
<p>
|
|
1429
|
-
chat4app-client-angular works!
|
|
1430
|
-
</p>
|
|
1431
|
-
`
|
|
1432
|
-
},] }
|
|
1433
|
-
];
|
|
1444
|
+
class Chat4appClientAngularComponent {
|
|
1445
|
+
constructor() { }
|
|
1446
|
+
ngOnInit() {
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
Chat4appClientAngularComponent.decorators = [
|
|
1450
|
+
{ type: Component, args: [{
|
|
1451
|
+
selector: 'lib-chat4app-client-angular',
|
|
1452
|
+
template: `
|
|
1453
|
+
<p>
|
|
1454
|
+
chat4app-client-angular works!
|
|
1455
|
+
</p>
|
|
1456
|
+
`
|
|
1457
|
+
},] }
|
|
1458
|
+
];
|
|
1434
1459
|
Chat4appClientAngularComponent.ctorParameters = () => [];
|
|
1435
1460
|
|
|
1436
|
-
class Chat4appClientAngularModule {
|
|
1437
|
-
}
|
|
1438
|
-
Chat4appClientAngularModule.decorators = [
|
|
1439
|
-
{ type: NgModule, args: [{
|
|
1440
|
-
declarations: [Chat4appClientAngularComponent],
|
|
1441
|
-
imports: [],
|
|
1442
|
-
exports: [Chat4appClientAngularComponent]
|
|
1443
|
-
},] }
|
|
1461
|
+
class Chat4appClientAngularModule {
|
|
1462
|
+
}
|
|
1463
|
+
Chat4appClientAngularModule.decorators = [
|
|
1464
|
+
{ type: NgModule, args: [{
|
|
1465
|
+
declarations: [Chat4appClientAngularComponent],
|
|
1466
|
+
imports: [],
|
|
1467
|
+
exports: [Chat4appClientAngularComponent]
|
|
1468
|
+
},] }
|
|
1444
1469
|
];
|
|
1445
1470
|
|
|
1446
|
-
/*
|
|
1447
|
-
* Public API Surface of chat4app-client-angular
|
|
1471
|
+
/*
|
|
1472
|
+
* Public API Surface of chat4app-client-angular
|
|
1448
1473
|
*/
|
|
1449
1474
|
|
|
1450
|
-
/**
|
|
1451
|
-
* Generated bundle index. Do not edit.
|
|
1475
|
+
/**
|
|
1476
|
+
* Generated bundle index. Do not edit.
|
|
1452
1477
|
*/
|
|
1453
1478
|
|
|
1454
1479
|
export { Chat4App, Chat4AppConfig, Chat4AppMessageReceive, Chat4AppMessageReceiveData, Chat4AppMessageReceiveNotification, Chat4AppTranslate, Chat4appClientAngularComponent, Chat4appClientAngularModule, Chat4appClientAngularService, ChatFilterRequest4App, ChatFilterType, ChatGroupApp, ChatMessage4App, ChatMessageFile4App, ChatMessageMeta4App, ChatStatus4App, ChatUser4App, ChatUserResponse4App, ChatUserStatus4App, GroupStatus4App };
|