stanza 12.17.0 → 12.17.3
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/Client.js +43 -25
- package/Constants.js +1 -1
- package/helpers/RSM.d.ts +8 -0
- package/helpers/RSM.js +25 -2
- package/index.d.ts +17 -6
- package/jxt/Definitions.d.ts +2 -2
- package/module.js +105 -42
- package/package.json +3 -3
- package/plugins/muc.js +1 -1
- package/protocol/xep0030.js +3 -1
- package/protocol/xep0084.js +6 -4
- package/protocol/xep0085.d.ts +1 -1
- package/protocol/xep0153.d.ts +1 -1
- package/protocol/xep0199.d.ts +1 -1
- package/protocol/xep0224.d.ts +1 -1
- package/protocol/xep0308.d.ts +1 -1
- package/protocol/xep0319.d.ts +1 -1
- package/protocol/xep0334.d.ts +1 -1
- package/transports/websocket.js +4 -0
package/Client.js
CHANGED
|
@@ -220,6 +220,7 @@ class Client extends events_1.EventEmitter {
|
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
222
|
updateConfig(opts = {}) {
|
|
223
|
+
var _a;
|
|
223
224
|
const currConfig = this.config || {};
|
|
224
225
|
this.config = {
|
|
225
226
|
allowResumption: true,
|
|
@@ -229,6 +230,7 @@ class Client extends events_1.EventEmitter {
|
|
|
229
230
|
websocket: true
|
|
230
231
|
},
|
|
231
232
|
useStreamManagement: true,
|
|
233
|
+
transportPreferenceOrder: ['websocket', 'bosh'],
|
|
232
234
|
...currConfig,
|
|
233
235
|
...opts
|
|
234
236
|
};
|
|
@@ -240,6 +242,9 @@ class Client extends events_1.EventEmitter {
|
|
|
240
242
|
this.config.credentials.password = this.config.password;
|
|
241
243
|
delete this.config.password;
|
|
242
244
|
}
|
|
245
|
+
if (!this.config.transportPreferenceOrder) {
|
|
246
|
+
this.config.transportPreferenceOrder = Object.keys((_a = this.config.transports) !== null && _a !== void 0 ? _a : {});
|
|
247
|
+
}
|
|
243
248
|
}
|
|
244
249
|
get stream() {
|
|
245
250
|
return this.transport ? this.transport.stream : undefined;
|
|
@@ -270,47 +275,60 @@ class Client extends events_1.EventEmitter {
|
|
|
270
275
|
return this._getConfiguredCredentials();
|
|
271
276
|
}
|
|
272
277
|
async connect() {
|
|
278
|
+
var _a, _b, _c;
|
|
273
279
|
this.sessionTerminating = false;
|
|
274
280
|
this.sessionStarting = true;
|
|
275
281
|
this.emit('--reset-stream-features');
|
|
276
282
|
if (this.transport) {
|
|
277
283
|
this.transport.disconnect(false);
|
|
278
284
|
}
|
|
279
|
-
const transportPref = [
|
|
285
|
+
const transportPref = (_a = this.config.transportPreferenceOrder) !== null && _a !== void 0 ? _a : [];
|
|
280
286
|
let endpoints;
|
|
281
287
|
for (const name of transportPref) {
|
|
282
|
-
|
|
283
|
-
if (!
|
|
288
|
+
const settings = this.config.transports[name];
|
|
289
|
+
if (!settings || !this.transports[name]) {
|
|
284
290
|
continue;
|
|
285
291
|
}
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
let config = {
|
|
293
|
+
acceptLanguages: this.config.acceptLanguages || [(_b = this.config.lang) !== null && _b !== void 0 ? _b : 'en'],
|
|
294
|
+
jid: this.config.jid,
|
|
295
|
+
lang: (_c = this.config.lang) !== null && _c !== void 0 ? _c : 'en',
|
|
296
|
+
server: this.config.server
|
|
297
|
+
};
|
|
298
|
+
const transport = new this.transports[name](this, this.sm, this.stanzas);
|
|
299
|
+
if (typeof settings === 'string') {
|
|
300
|
+
config.url = settings;
|
|
288
301
|
}
|
|
289
|
-
else if (
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
catch (err) {
|
|
295
|
-
console.error(err);
|
|
302
|
+
else if (settings == true) {
|
|
303
|
+
if (transport.discoverBindings) {
|
|
304
|
+
const discovered = await transport.discoverBindings(this.config.server);
|
|
305
|
+
if (!discovered) {
|
|
296
306
|
continue;
|
|
297
307
|
}
|
|
308
|
+
config = {
|
|
309
|
+
...config,
|
|
310
|
+
...discovered
|
|
311
|
+
};
|
|
298
312
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
313
|
+
else {
|
|
314
|
+
if (!endpoints) {
|
|
315
|
+
try {
|
|
316
|
+
endpoints = await this.discoverBindings(this.config.server);
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
console.error(err);
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
endpoints[name] = (endpoints[name] || []).filter(url => url.startsWith('wss:') || url.startsWith('https:'));
|
|
324
|
+
if (!endpoints[name] || !endpoints[name].length) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
config.url = endpoints[name][0];
|
|
302
328
|
}
|
|
303
|
-
conf = { url: endpoints[name][0] };
|
|
304
329
|
}
|
|
305
|
-
this.transport =
|
|
306
|
-
this.transport.connect(
|
|
307
|
-
acceptLanguages: this.config.acceptLanguages || ['en'],
|
|
308
|
-
jid: this.config.jid,
|
|
309
|
-
lang: this.config.lang || 'en',
|
|
310
|
-
server: this.config.server,
|
|
311
|
-
url: conf.url,
|
|
312
|
-
...conf
|
|
313
|
-
});
|
|
330
|
+
this.transport = transport;
|
|
331
|
+
this.transport.connect(config);
|
|
314
332
|
return;
|
|
315
333
|
}
|
|
316
334
|
console.error('No endpoints found for the requested transports.');
|
package/Constants.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.directionToSenders = exports.sendersToDirection = exports.JINGLE_INFO_RECEIVED_5 = exports.JINGLE_INFO_CHECKSUM_5 = exports.JINGLE_INFO_RINGING = exports.JINGLE_INFO_ACTIVE = exports.JINGLE_INFO_UNHOLD = exports.JINGLE_INFO_HOLD = exports.JINGLE_INFO_UNMUTE = exports.JINGLE_INFO_MUTE = exports.JINGLE_INFO = exports.USER_ACTIVITY_SPECIFIC = exports.USER_ACTIVITY_GENERAL = exports.USER_MOODS = exports.JingleReasonCondition = exports.JingleErrorCondition = exports.JingleAction = exports.JingleContentSenders = exports.JingleApplicationDirection = exports.JingleSessionRole = exports.ChatState = exports.PubsubErrorCondition = exports.MUCStatusCode = exports.MUCRole = exports.MUCAffiliation = exports.DataFormFieldType = exports.DataFormType = exports.RosterSubscription = exports.PresenceShow = exports.IQType = exports.PresenceType = exports.MessageType = exports.StanzaErrorCondition = exports.StreamErrorCondition = exports.SASLFailureCondition = exports.StreamType = exports.VERSION = void 0;
|
|
4
4
|
const Namespaces_1 = require("./Namespaces");
|
|
5
|
-
exports.VERSION = '12.17.
|
|
5
|
+
exports.VERSION = '12.17.3';
|
|
6
6
|
// ====================================================================
|
|
7
7
|
// Frequently Used Values
|
|
8
8
|
// ====================================================================
|
package/helpers/RSM.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare type RSMQuery<T> = (page: Paging) => Promise<{
|
|
|
6
6
|
interface RSMOptions<T> {
|
|
7
7
|
pageSize?: number;
|
|
8
8
|
direction?: 'forward' | 'backward';
|
|
9
|
+
reverse?: boolean;
|
|
9
10
|
before?: string;
|
|
10
11
|
after?: string;
|
|
11
12
|
max?: number;
|
|
@@ -15,10 +16,17 @@ export declare class ResultSetPager<T> {
|
|
|
15
16
|
private query;
|
|
16
17
|
private cursor;
|
|
17
18
|
private direction;
|
|
19
|
+
private reverse;
|
|
18
20
|
private pageSize;
|
|
21
|
+
private resultCount?;
|
|
22
|
+
private resultComplete;
|
|
23
|
+
private fetchedCount;
|
|
24
|
+
private yieldedCount;
|
|
19
25
|
constructor(opts: RSMOptions<T>);
|
|
20
26
|
[Symbol.asyncIterator](): AsyncGenerator<T>;
|
|
21
27
|
size(): Promise<number | undefined>;
|
|
28
|
+
queryCompleted(): boolean;
|
|
29
|
+
finished(): boolean;
|
|
22
30
|
private fetchPage;
|
|
23
31
|
}
|
|
24
32
|
export declare function createPager<T>(opts: RSMOptions<T>): ResultSetPager<T>;
|
package/helpers/RSM.js
CHANGED
|
@@ -3,25 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPager = exports.ResultSetPager = void 0;
|
|
4
4
|
class ResultSetPager {
|
|
5
5
|
constructor(opts) {
|
|
6
|
-
var _a, _b;
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
this.resultComplete = false;
|
|
8
|
+
this.fetchedCount = 0;
|
|
9
|
+
this.yieldedCount = 0;
|
|
7
10
|
this.cursor = { first: opts.before, last: opts.after };
|
|
8
11
|
this.query = opts.query;
|
|
9
12
|
this.direction = (_a = opts.direction) !== null && _a !== void 0 ? _a : 'forward';
|
|
10
|
-
this.
|
|
13
|
+
this.reverse = (_b = opts.reverse) !== null && _b !== void 0 ? _b : this.direction === 'backward';
|
|
14
|
+
this.pageSize = (_c = opts.pageSize) !== null && _c !== void 0 ? _c : 20;
|
|
11
15
|
}
|
|
12
16
|
async *[Symbol.asyncIterator]() {
|
|
13
17
|
let currentResults = [];
|
|
14
18
|
do {
|
|
15
19
|
currentResults = await this.fetchPage();
|
|
16
20
|
for (const item of currentResults) {
|
|
21
|
+
this.yieldedCount += 1;
|
|
17
22
|
yield item;
|
|
18
23
|
}
|
|
19
24
|
} while (currentResults.length > 0);
|
|
20
25
|
}
|
|
21
26
|
async size() {
|
|
27
|
+
if (this.resultCount !== undefined) {
|
|
28
|
+
return this.resultCount;
|
|
29
|
+
}
|
|
22
30
|
const { paging } = await this.query({ max: 0 });
|
|
31
|
+
this.resultCount = paging.count;
|
|
23
32
|
return paging.count;
|
|
24
33
|
}
|
|
34
|
+
queryCompleted() {
|
|
35
|
+
return this.resultComplete;
|
|
36
|
+
}
|
|
37
|
+
finished() {
|
|
38
|
+
return this.resultComplete && this.yieldedCount === this.fetchedCount;
|
|
39
|
+
}
|
|
25
40
|
async fetchPage() {
|
|
26
41
|
var _a;
|
|
27
42
|
const { results, paging } = await this.query({
|
|
@@ -30,6 +45,14 @@ class ResultSetPager {
|
|
|
30
45
|
max: this.pageSize
|
|
31
46
|
});
|
|
32
47
|
this.cursor = paging;
|
|
48
|
+
this.resultCount = paging.count;
|
|
49
|
+
this.fetchedCount += results.length;
|
|
50
|
+
if ((this.pageSize && results.length < this.pageSize) || (this.resultCount && this.fetchedCount === this.resultCount)) {
|
|
51
|
+
this.resultComplete = true;
|
|
52
|
+
}
|
|
53
|
+
if (this.reverse) {
|
|
54
|
+
results.reverse();
|
|
55
|
+
}
|
|
33
56
|
return results;
|
|
34
57
|
}
|
|
35
58
|
}
|
package/index.d.ts
CHANGED
|
@@ -105,6 +105,9 @@ export interface Agent extends StrictEventEmitter<EventEmitter, AgentEvents> {
|
|
|
105
105
|
sessionStarting: boolean;
|
|
106
106
|
sessionStarted: boolean;
|
|
107
107
|
sessionTerminating: boolean;
|
|
108
|
+
transports: {
|
|
109
|
+
[key: string]: new (client: Agent, sm: StreamManagement, registry: JXT.Registry) => Transport;
|
|
110
|
+
};
|
|
108
111
|
use(plugin: (agent: Agent, registry: JXT.Registry, config: AgentConfig) => void): void;
|
|
109
112
|
nextId(): string;
|
|
110
113
|
updateConfig(opts?: AgentConfig): void;
|
|
@@ -177,14 +180,21 @@ export interface AgentConfig {
|
|
|
177
180
|
*
|
|
178
181
|
* If a transport is set to a string, that will be used as the connection URL.
|
|
179
182
|
*
|
|
180
|
-
* If a transport is set to an object, it MUST include a <code>url</code> value for
|
|
181
|
-
* the connection URL.
|
|
182
|
-
*
|
|
183
183
|
* @default { websocket: true, bosh: true }
|
|
184
184
|
*/
|
|
185
185
|
transports?: {
|
|
186
186
|
[key: string]: boolean | string | Partial<TransportConfig>;
|
|
187
187
|
};
|
|
188
|
+
/**
|
|
189
|
+
* Transport Preference Order
|
|
190
|
+
*
|
|
191
|
+
* Specify the order in which transports should be tried when connecting.
|
|
192
|
+
*
|
|
193
|
+
* If a configured transport type is not listed, it will be skipped.
|
|
194
|
+
*
|
|
195
|
+
* @default ['websocket', 'bosh']
|
|
196
|
+
*/
|
|
197
|
+
transportPreferenceOrder?: string[];
|
|
188
198
|
/**
|
|
189
199
|
* Account Password
|
|
190
200
|
*
|
|
@@ -208,17 +218,18 @@ export interface Transport {
|
|
|
208
218
|
hasStream?: boolean;
|
|
209
219
|
stream?: Stream;
|
|
210
220
|
authenticated?: boolean;
|
|
221
|
+
discoverBindings?(host: string): Promise<Partial<TransportConfig> | null>;
|
|
211
222
|
connect(opts: TransportConfig): void;
|
|
212
223
|
disconnect(cleanly?: boolean): void;
|
|
213
224
|
restart(): void;
|
|
214
225
|
send(name: string, data?: JXT.JSONData): Promise<void>;
|
|
215
226
|
}
|
|
216
227
|
export interface TransportConfig {
|
|
217
|
-
lang?: string;
|
|
218
|
-
acceptLanguages?: string[];
|
|
219
228
|
server: string;
|
|
220
|
-
url: string;
|
|
221
229
|
jid: string;
|
|
230
|
+
lang?: string;
|
|
231
|
+
acceptLanguages?: string[];
|
|
232
|
+
url?: string;
|
|
222
233
|
sid?: string;
|
|
223
234
|
rid?: number;
|
|
224
235
|
maxRetries?: number;
|
package/jxt/Definitions.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export interface DefinitionUpdateOptions {
|
|
|
52
52
|
optionalNamespaces: Map<string, string>;
|
|
53
53
|
typeOrder?: number;
|
|
54
54
|
}
|
|
55
|
-
export interface DefinitionOptions {
|
|
55
|
+
export interface DefinitionOptions<DT extends object = any> {
|
|
56
56
|
namespace: string;
|
|
57
57
|
element: string;
|
|
58
58
|
typeField?: string;
|
|
@@ -63,7 +63,7 @@ export interface DefinitionOptions {
|
|
|
63
63
|
defaultVersion?: string;
|
|
64
64
|
versionField?: string;
|
|
65
65
|
fields?: {
|
|
66
|
-
[
|
|
66
|
+
[K in keyof DT]: FieldDefinition<Exclude<DT[K], undefined>>;
|
|
67
67
|
};
|
|
68
68
|
path?: string;
|
|
69
69
|
aliases?: Array<string | LinkPath>;
|
package/module.js
CHANGED
|
@@ -4012,7 +4012,8 @@ class Hash extends Transform {
|
|
|
4012
4012
|
let error = null;
|
|
4013
4013
|
try {
|
|
4014
4014
|
this.update(chunk, encoding);
|
|
4015
|
-
}
|
|
4015
|
+
}
|
|
4016
|
+
catch (err) {
|
|
4016
4017
|
error = err;
|
|
4017
4018
|
}
|
|
4018
4019
|
callback(error);
|
|
@@ -4021,7 +4022,8 @@ class Hash extends Transform {
|
|
|
4021
4022
|
let error = null;
|
|
4022
4023
|
try {
|
|
4023
4024
|
this.push(this.digest());
|
|
4024
|
-
}
|
|
4025
|
+
}
|
|
4026
|
+
catch (err) {
|
|
4025
4027
|
error = err;
|
|
4026
4028
|
}
|
|
4027
4029
|
callback(error);
|
|
@@ -4035,7 +4037,7 @@ class Hash extends Transform {
|
|
|
4035
4037
|
const blockSize = this._blockSize;
|
|
4036
4038
|
const length = data.length;
|
|
4037
4039
|
let accum = this._len;
|
|
4038
|
-
for (let offset = 0; offset < length;
|
|
4040
|
+
for (let offset = 0; offset < length;) {
|
|
4039
4041
|
const assigned = accum % blockSize;
|
|
4040
4042
|
const remainder = Math.min(length - offset, blockSize - assigned);
|
|
4041
4043
|
for (let i = 0; i < remainder; i++) {
|
|
@@ -4065,17 +4067,20 @@ class Hash extends Transform {
|
|
|
4065
4067
|
if (this._bigEndian) {
|
|
4066
4068
|
this._block.writeUInt32BE(0, this._blockSize - 8);
|
|
4067
4069
|
this._block.writeUInt32BE(bits, this._blockSize - 4);
|
|
4068
|
-
}
|
|
4070
|
+
}
|
|
4071
|
+
else {
|
|
4069
4072
|
this._block.writeUInt32LE(bits, this._blockSize - 8);
|
|
4070
4073
|
this._block.writeUInt32LE(0, this._blockSize - 4);
|
|
4071
4074
|
}
|
|
4072
|
-
}
|
|
4075
|
+
}
|
|
4076
|
+
else {
|
|
4073
4077
|
const lowBits = (bits & 0xffffffff) >>> 0;
|
|
4074
4078
|
const highBits = (bits - lowBits) / 0x100000000;
|
|
4075
4079
|
if (this._bigEndian) {
|
|
4076
4080
|
this._block.writeUInt32BE(highBits, this._blockSize - 8);
|
|
4077
4081
|
this._block.writeUInt32BE(lowBits, this._blockSize - 4);
|
|
4078
|
-
}
|
|
4082
|
+
}
|
|
4083
|
+
else {
|
|
4079
4084
|
this._block.writeUInt32LE(lowBits, this._blockSize - 8);
|
|
4080
4085
|
this._block.writeUInt32LE(highBits, this._blockSize - 4);
|
|
4081
4086
|
}
|
|
@@ -4811,7 +4816,8 @@ function createHash(alg) {
|
|
|
4811
4816
|
const HashImp = HASH_IMPLEMENTATIONS.get(alg);
|
|
4812
4817
|
if (HashImp) {
|
|
4813
4818
|
return new HashImp();
|
|
4814
|
-
}
|
|
4819
|
+
}
|
|
4820
|
+
else {
|
|
4815
4821
|
throw new Error('Unsupported hash algorithm: ' + alg);
|
|
4816
4822
|
}
|
|
4817
4823
|
}
|
|
@@ -4841,7 +4847,8 @@ class Hmac extends Transform {
|
|
|
4841
4847
|
key = createHash(alg)
|
|
4842
4848
|
.update(key)
|
|
4843
4849
|
.digest();
|
|
4844
|
-
}
|
|
4850
|
+
}
|
|
4851
|
+
else if (key.length < blocksize) {
|
|
4845
4852
|
key = Buffer.concat([key, ZEROS], blocksize);
|
|
4846
4853
|
}
|
|
4847
4854
|
this._ipad = Buffer.alloc(blocksize);
|
|
@@ -4856,9 +4863,11 @@ class Hmac extends Transform {
|
|
|
4856
4863
|
let err;
|
|
4857
4864
|
try {
|
|
4858
4865
|
this.update(data, enc);
|
|
4859
|
-
}
|
|
4866
|
+
}
|
|
4867
|
+
catch (e) {
|
|
4860
4868
|
err = e;
|
|
4861
|
-
}
|
|
4869
|
+
}
|
|
4870
|
+
finally {
|
|
4862
4871
|
next(err);
|
|
4863
4872
|
}
|
|
4864
4873
|
}
|
|
@@ -4866,7 +4875,8 @@ class Hmac extends Transform {
|
|
|
4866
4875
|
let err;
|
|
4867
4876
|
try {
|
|
4868
4877
|
this.push(this._final());
|
|
4869
|
-
}
|
|
4878
|
+
}
|
|
4879
|
+
catch (e) {
|
|
4870
4880
|
err = e;
|
|
4871
4881
|
}
|
|
4872
4882
|
done(err);
|
|
@@ -4894,7 +4904,8 @@ class Hmac extends Transform {
|
|
|
4894
4904
|
let root;
|
|
4895
4905
|
if (typeof window !== 'undefined') {
|
|
4896
4906
|
root = window;
|
|
4897
|
-
}
|
|
4907
|
+
}
|
|
4908
|
+
else if (typeof global !== 'undefined') {
|
|
4898
4909
|
root = global;
|
|
4899
4910
|
}
|
|
4900
4911
|
function randomBytes(size) {
|
|
@@ -4910,7 +4921,7 @@ function getHashes() {
|
|
|
4910
4921
|
function createHmac(alg, key) {
|
|
4911
4922
|
return new Hmac(alg.toLowerCase(), key);
|
|
4912
4923
|
}
|
|
4913
|
-
const nativeFetch = fetch;
|
|
4924
|
+
const nativeFetch = fetch.bind(window);
|
|
4914
4925
|
const nativeWS = WebSocket;
|
|
4915
4926
|
const nativeRTCPeerConnection = root.RTCPeerConnection;
|
|
4916
4927
|
|
|
@@ -6085,7 +6096,7 @@ function Disco (client) {
|
|
|
6085
6096
|
});
|
|
6086
6097
|
}
|
|
6087
6098
|
|
|
6088
|
-
const VERSION$1 = '12.17.
|
|
6099
|
+
const VERSION$1 = '12.17.3';
|
|
6089
6100
|
// ====================================================================
|
|
6090
6101
|
// Frequently Used Values
|
|
6091
6102
|
// ====================================================================
|
|
@@ -9276,7 +9287,7 @@ function MUC (client) {
|
|
|
9276
9287
|
}
|
|
9277
9288
|
client.on('session:started', rejoinRooms);
|
|
9278
9289
|
client.on('message', msg => {
|
|
9279
|
-
if (msg.type === 'groupchat' && msg.hasSubject) {
|
|
9290
|
+
if (msg.type === 'groupchat' && msg.hasSubject && !msg.body) {
|
|
9280
9291
|
client.emit('muc:topic', {
|
|
9281
9292
|
from: msg.from,
|
|
9282
9293
|
room: toBare(msg.from),
|
|
@@ -10980,7 +10991,9 @@ const Protocol$12 = [
|
|
|
10980
10991
|
{
|
|
10981
10992
|
aliases: ['iq.disco', 'message.disco', 'features.disco'],
|
|
10982
10993
|
childrenExportOrder: {
|
|
10983
|
-
identities:
|
|
10994
|
+
identities: 1,
|
|
10995
|
+
features: 2,
|
|
10996
|
+
extensions: 3
|
|
10984
10997
|
},
|
|
10985
10998
|
element: 'query',
|
|
10986
10999
|
fields: {
|
|
@@ -12141,12 +12154,15 @@ const Protocol$O = [
|
|
|
12141
12154
|
typeField: 'itemType'
|
|
12142
12155
|
},
|
|
12143
12156
|
{
|
|
12144
|
-
aliases: pubsubItemContentAliases(),
|
|
12157
|
+
aliases: [{ path: 'avatar', impliedType: true }, ...pubsubItemContentAliases()],
|
|
12145
12158
|
element: 'metadata',
|
|
12146
12159
|
namespace: NS_AVATAR_METADATA,
|
|
12147
|
-
path: 'avatar',
|
|
12148
12160
|
type: NS_AVATAR_METADATA,
|
|
12149
|
-
typeField: 'itemType'
|
|
12161
|
+
typeField: 'itemType',
|
|
12162
|
+
childrenExportOrder: {
|
|
12163
|
+
versions: 1,
|
|
12164
|
+
pointers: 2
|
|
12165
|
+
}
|
|
12150
12166
|
},
|
|
12151
12167
|
{
|
|
12152
12168
|
aliases: [
|
|
@@ -12181,7 +12197,6 @@ const Protocol$O = [
|
|
|
12181
12197
|
height: integerAttribute('height'),
|
|
12182
12198
|
id: attribute('id'),
|
|
12183
12199
|
mediaType: attribute('type'),
|
|
12184
|
-
uri: attribute('url'),
|
|
12185
12200
|
width: integerAttribute('width')
|
|
12186
12201
|
},
|
|
12187
12202
|
namespace: NS_AVATAR_METADATA
|
|
@@ -14471,6 +14486,10 @@ class WSConnection extends Duplex {
|
|
|
14471
14486
|
this.socket.onclose = () => {
|
|
14472
14487
|
this.push(null);
|
|
14473
14488
|
};
|
|
14489
|
+
this.socket.onerror = (err) => {
|
|
14490
|
+
console.error(err);
|
|
14491
|
+
this.push(null);
|
|
14492
|
+
};
|
|
14474
14493
|
}
|
|
14475
14494
|
disconnect(clean = true) {
|
|
14476
14495
|
if (this.socket && !this.closing && this.hasStream && clean) {
|
|
@@ -14734,11 +14753,12 @@ class Client extends EventEmitter {
|
|
|
14734
14753
|
});
|
|
14735
14754
|
}
|
|
14736
14755
|
updateConfig(opts = {}) {
|
|
14756
|
+
var _a;
|
|
14737
14757
|
const currConfig = this.config || {};
|
|
14738
14758
|
this.config = Object.assign(Object.assign({ allowResumption: true, jid: '', transports: {
|
|
14739
14759
|
bosh: true,
|
|
14740
14760
|
websocket: true
|
|
14741
|
-
}, useStreamManagement: true }, currConfig), opts);
|
|
14761
|
+
}, useStreamManagement: true, transportPreferenceOrder: ['websocket', 'bosh'] }, currConfig), opts);
|
|
14742
14762
|
if (!this.config.server) {
|
|
14743
14763
|
this.config.server = getDomain(this.config.jid);
|
|
14744
14764
|
}
|
|
@@ -14747,6 +14767,9 @@ class Client extends EventEmitter {
|
|
|
14747
14767
|
this.config.credentials.password = this.config.password;
|
|
14748
14768
|
delete this.config.password;
|
|
14749
14769
|
}
|
|
14770
|
+
if (!this.config.transportPreferenceOrder) {
|
|
14771
|
+
this.config.transportPreferenceOrder = Object.keys((_a = this.config.transports) !== null && _a !== void 0 ? _a : {});
|
|
14772
|
+
}
|
|
14750
14773
|
}
|
|
14751
14774
|
get stream() {
|
|
14752
14775
|
return this.transport ? this.transport.stream : undefined;
|
|
@@ -14779,6 +14802,7 @@ class Client extends EventEmitter {
|
|
|
14779
14802
|
});
|
|
14780
14803
|
}
|
|
14781
14804
|
connect() {
|
|
14805
|
+
var _a, _b, _c;
|
|
14782
14806
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14783
14807
|
this.sessionTerminating = false;
|
|
14784
14808
|
this.sessionStarting = true;
|
|
@@ -14786,34 +14810,50 @@ class Client extends EventEmitter {
|
|
|
14786
14810
|
if (this.transport) {
|
|
14787
14811
|
this.transport.disconnect(false);
|
|
14788
14812
|
}
|
|
14789
|
-
const transportPref = [
|
|
14813
|
+
const transportPref = (_a = this.config.transportPreferenceOrder) !== null && _a !== void 0 ? _a : [];
|
|
14790
14814
|
let endpoints;
|
|
14791
14815
|
for (const name of transportPref) {
|
|
14792
|
-
|
|
14793
|
-
if (!
|
|
14816
|
+
const settings = this.config.transports[name];
|
|
14817
|
+
if (!settings || !this.transports[name]) {
|
|
14794
14818
|
continue;
|
|
14795
14819
|
}
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14820
|
+
let config = {
|
|
14821
|
+
acceptLanguages: this.config.acceptLanguages || [(_b = this.config.lang) !== null && _b !== void 0 ? _b : 'en'],
|
|
14822
|
+
jid: this.config.jid,
|
|
14823
|
+
lang: (_c = this.config.lang) !== null && _c !== void 0 ? _c : 'en',
|
|
14824
|
+
server: this.config.server
|
|
14825
|
+
};
|
|
14826
|
+
const transport = new this.transports[name](this, this.sm, this.stanzas);
|
|
14827
|
+
if (typeof settings === 'string') {
|
|
14828
|
+
config.url = settings;
|
|
14829
|
+
}
|
|
14830
|
+
else if (settings == true) {
|
|
14831
|
+
if (transport.discoverBindings) {
|
|
14832
|
+
const discovered = yield transport.discoverBindings(this.config.server);
|
|
14833
|
+
if (!discovered) {
|
|
14806
14834
|
continue;
|
|
14807
14835
|
}
|
|
14836
|
+
config = Object.assign(Object.assign({}, config), discovered);
|
|
14808
14837
|
}
|
|
14809
|
-
|
|
14810
|
-
|
|
14811
|
-
|
|
14838
|
+
else {
|
|
14839
|
+
if (!endpoints) {
|
|
14840
|
+
try {
|
|
14841
|
+
endpoints = yield this.discoverBindings(this.config.server);
|
|
14842
|
+
}
|
|
14843
|
+
catch (err) {
|
|
14844
|
+
console.error(err);
|
|
14845
|
+
continue;
|
|
14846
|
+
}
|
|
14847
|
+
}
|
|
14848
|
+
endpoints[name] = (endpoints[name] || []).filter(url => url.startsWith('wss:') || url.startsWith('https:'));
|
|
14849
|
+
if (!endpoints[name] || !endpoints[name].length) {
|
|
14850
|
+
continue;
|
|
14851
|
+
}
|
|
14852
|
+
config.url = endpoints[name][0];
|
|
14812
14853
|
}
|
|
14813
|
-
conf = { url: endpoints[name][0] };
|
|
14814
14854
|
}
|
|
14815
|
-
this.transport =
|
|
14816
|
-
this.transport.connect(
|
|
14855
|
+
this.transport = transport;
|
|
14856
|
+
this.transport.connect(config);
|
|
14817
14857
|
return;
|
|
14818
14858
|
}
|
|
14819
14859
|
console.error('No endpoints found for the requested transports.');
|
|
@@ -15257,11 +15297,15 @@ var RTT = /*#__PURE__*/Object.freeze({
|
|
|
15257
15297
|
|
|
15258
15298
|
class ResultSetPager {
|
|
15259
15299
|
constructor(opts) {
|
|
15260
|
-
var _a, _b;
|
|
15300
|
+
var _a, _b, _c;
|
|
15301
|
+
this.resultComplete = false;
|
|
15302
|
+
this.fetchedCount = 0;
|
|
15303
|
+
this.yieldedCount = 0;
|
|
15261
15304
|
this.cursor = { first: opts.before, last: opts.after };
|
|
15262
15305
|
this.query = opts.query;
|
|
15263
15306
|
this.direction = (_a = opts.direction) !== null && _a !== void 0 ? _a : 'forward';
|
|
15264
|
-
this.
|
|
15307
|
+
this.reverse = (_b = opts.reverse) !== null && _b !== void 0 ? _b : this.direction === 'backward';
|
|
15308
|
+
this.pageSize = (_c = opts.pageSize) !== null && _c !== void 0 ? _c : 20;
|
|
15265
15309
|
}
|
|
15266
15310
|
[Symbol.asyncIterator]() {
|
|
15267
15311
|
return __asyncGenerator(this, arguments, function* _a() {
|
|
@@ -15269,6 +15313,7 @@ class ResultSetPager {
|
|
|
15269
15313
|
do {
|
|
15270
15314
|
currentResults = yield __await(this.fetchPage());
|
|
15271
15315
|
for (const item of currentResults) {
|
|
15316
|
+
this.yieldedCount += 1;
|
|
15272
15317
|
yield yield __await(item);
|
|
15273
15318
|
}
|
|
15274
15319
|
} while (currentResults.length > 0);
|
|
@@ -15276,10 +15321,20 @@ class ResultSetPager {
|
|
|
15276
15321
|
}
|
|
15277
15322
|
size() {
|
|
15278
15323
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15324
|
+
if (this.resultCount !== undefined) {
|
|
15325
|
+
return this.resultCount;
|
|
15326
|
+
}
|
|
15279
15327
|
const { paging } = yield this.query({ max: 0 });
|
|
15328
|
+
this.resultCount = paging.count;
|
|
15280
15329
|
return paging.count;
|
|
15281
15330
|
});
|
|
15282
15331
|
}
|
|
15332
|
+
queryCompleted() {
|
|
15333
|
+
return this.resultComplete;
|
|
15334
|
+
}
|
|
15335
|
+
finished() {
|
|
15336
|
+
return this.resultComplete && this.yieldedCount === this.fetchedCount;
|
|
15337
|
+
}
|
|
15283
15338
|
fetchPage() {
|
|
15284
15339
|
var _a;
|
|
15285
15340
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -15289,6 +15344,14 @@ class ResultSetPager {
|
|
|
15289
15344
|
max: this.pageSize
|
|
15290
15345
|
});
|
|
15291
15346
|
this.cursor = paging;
|
|
15347
|
+
this.resultCount = paging.count;
|
|
15348
|
+
this.fetchedCount += results.length;
|
|
15349
|
+
if ((this.pageSize && results.length < this.pageSize) || (this.resultCount && this.fetchedCount === this.resultCount)) {
|
|
15350
|
+
this.resultComplete = true;
|
|
15351
|
+
}
|
|
15352
|
+
if (this.reverse) {
|
|
15353
|
+
results.reverse();
|
|
15354
|
+
}
|
|
15292
15355
|
return results;
|
|
15293
15356
|
});
|
|
15294
15357
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stanza",
|
|
3
3
|
"description": "Modern XMPP in the browser, with a JSON API",
|
|
4
|
-
"version": "12.17.
|
|
4
|
+
"version": "12.17.3",
|
|
5
5
|
"author": "Lance Stout <lancestout@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/legastero/stanza/issues",
|
|
7
7
|
"contributors": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@types/punycode": "^2.1.0",
|
|
15
15
|
"@types/readable-stream": "^2.3.9",
|
|
16
16
|
"@types/ws": "^7.4.0",
|
|
17
|
-
"async": "^3.
|
|
17
|
+
"async": "^3.2.1",
|
|
18
18
|
"buffer": "^6.0.3",
|
|
19
19
|
"node-fetch": "^2.6.1",
|
|
20
20
|
"process": "^0.11.10",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"react-native-randombytes": "^3.6.0",
|
|
23
23
|
"readable-stream": "^2.3.6",
|
|
24
24
|
"sdp": "^3.0.2",
|
|
25
|
-
"stanza-shims": "^1.1.
|
|
25
|
+
"stanza-shims": "^1.1.2",
|
|
26
26
|
"tslib": "^2.2.0",
|
|
27
27
|
"ws": "^7.4.4"
|
|
28
28
|
},
|
package/plugins/muc.js
CHANGED
|
@@ -29,7 +29,7 @@ function default_1(client) {
|
|
|
29
29
|
}
|
|
30
30
|
client.on('session:started', rejoinRooms);
|
|
31
31
|
client.on('message', msg => {
|
|
32
|
-
if (msg.type === 'groupchat' && msg.hasSubject) {
|
|
32
|
+
if (msg.type === 'groupchat' && msg.hasSubject && !msg.body) {
|
|
33
33
|
client.emit('muc:topic', {
|
|
34
34
|
from: msg.from,
|
|
35
35
|
room: JID.toBare(msg.from),
|
package/protocol/xep0030.js
CHANGED
package/protocol/xep0084.js
CHANGED
|
@@ -21,12 +21,15 @@ const Protocol = [
|
|
|
21
21
|
typeField: 'itemType'
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
|
-
aliases: jxt_1.pubsubItemContentAliases(),
|
|
24
|
+
aliases: [{ path: 'avatar', impliedType: true }, ...jxt_1.pubsubItemContentAliases()],
|
|
25
25
|
element: 'metadata',
|
|
26
26
|
namespace: Namespaces_1.NS_AVATAR_METADATA,
|
|
27
|
-
path: 'avatar',
|
|
28
27
|
type: Namespaces_1.NS_AVATAR_METADATA,
|
|
29
|
-
typeField: 'itemType'
|
|
28
|
+
typeField: 'itemType',
|
|
29
|
+
childrenExportOrder: {
|
|
30
|
+
versions: 1,
|
|
31
|
+
pointers: 2
|
|
32
|
+
}
|
|
30
33
|
},
|
|
31
34
|
{
|
|
32
35
|
aliases: [
|
|
@@ -61,7 +64,6 @@ const Protocol = [
|
|
|
61
64
|
height: jxt_1.integerAttribute('height'),
|
|
62
65
|
id: jxt_1.attribute('id'),
|
|
63
66
|
mediaType: jxt_1.attribute('type'),
|
|
64
|
-
uri: jxt_1.attribute('url'),
|
|
65
67
|
width: jxt_1.integerAttribute('width')
|
|
66
68
|
},
|
|
67
69
|
namespace: Namespaces_1.NS_AVATAR_METADATA
|
package/protocol/xep0085.d.ts
CHANGED
package/protocol/xep0153.d.ts
CHANGED
package/protocol/xep0199.d.ts
CHANGED
package/protocol/xep0224.d.ts
CHANGED
package/protocol/xep0308.d.ts
CHANGED
package/protocol/xep0319.d.ts
CHANGED
package/protocol/xep0334.d.ts
CHANGED
package/transports/websocket.js
CHANGED
|
@@ -88,6 +88,10 @@ class WSConnection extends readable_stream_1.Duplex {
|
|
|
88
88
|
this.socket.onclose = () => {
|
|
89
89
|
this.push(null);
|
|
90
90
|
};
|
|
91
|
+
this.socket.onerror = (err) => {
|
|
92
|
+
console.error(err);
|
|
93
|
+
this.push(null);
|
|
94
|
+
};
|
|
91
95
|
}
|
|
92
96
|
disconnect(clean = true) {
|
|
93
97
|
if (this.socket && !this.closing && this.hasStream && clean) {
|