@wireapp/api-client 27.11.0 → 27.12.1
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/lib/conversation/ConversationAPI/ConversationAPI.d.ts +1 -0
- package/lib/conversation/ConversationAPI/ConversationAPI.d.ts.map +1 -1
- package/lib/conversation/ConversationAPI/ConversationAPI.js +49 -35
- package/lib/user/UserAPI.d.ts.map +1 -1
- package/lib/user/UserAPI.js +52 -43
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationAPI.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationAPI/ConversationAPI.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EAErB,MAAM,EACN,6BAA6B,EAC7B,MAAM,EACN,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,eAAe,EAEf,mBAAmB,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,mCAAmC,EACnC,+BAA+B,EAC/B,kCAAkC,EAClC,uBAAuB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAkC,UAAU,EAAC,MAAM,YAAY,CAAC;AACvE,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAMvC,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,4BAA4B,EAC5B,kCAAkC,EAClC,0BAA0B,EAC1B,iCAAiC,EACjC,iCAAiC,EACjC,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAEvE,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,CAAC,EAAE,WAAW,EAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,2BAA2B,GAAG;IAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAA;CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationAPI.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationAPI/ConversationAPI.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EAErB,MAAM,EACN,6BAA6B,EAC7B,MAAM,EACN,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,eAAe,EAEf,mBAAmB,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,2BAA2B,EAC3B,iBAAiB,EACjB,2BAA2B,EAC3B,4BAA4B,EAC5B,mCAAmC,EACnC,+BAA+B,EAC/B,kCAAkC,EAClC,uBAAuB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAkC,UAAU,EAAC,MAAM,YAAY,CAAC;AACvE,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAMvC,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,4BAA4B,EAC5B,kCAAkC,EAClC,0BAA0B,EAC1B,iCAAiC,EACjC,iCAAiC,EACjC,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAEvE,MAAM,MA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|
@@ -26,21 +26,27 @@ const __1 = require("..");
|
|
|
26
26
|
const http_1 = require("../../http");
|
|
27
27
|
const ConversationError_1 = require("../ConversationError");
|
|
28
28
|
const FederatedBackendsError_1 = require("../FederatedBackendsError");
|
|
29
|
+
const apiBreakpoint = {
|
|
30
|
+
version2: 2,
|
|
31
|
+
// API V7 introduces new endpoints to conversations and users
|
|
32
|
+
version7: 7,
|
|
33
|
+
};
|
|
29
34
|
class ConversationAPI {
|
|
30
35
|
client;
|
|
31
36
|
backendFeatures;
|
|
32
37
|
static MAX_CHUNK_SIZE = 500;
|
|
33
38
|
static URL = {
|
|
34
39
|
ACCESS: 'access',
|
|
40
|
+
BOT: 'bot',
|
|
35
41
|
BOTS: 'bots',
|
|
36
|
-
CLIENTS: '
|
|
42
|
+
CLIENTS: 'clients',
|
|
37
43
|
CODE: 'code',
|
|
38
|
-
CODE_CHECK: '
|
|
39
|
-
CONVERSATIONS: '
|
|
44
|
+
CODE_CHECK: 'code-check',
|
|
45
|
+
CONVERSATIONS: 'conversations',
|
|
40
46
|
SUBCONVERSATIONS: 'subconversations',
|
|
41
47
|
GROUP_INFO: 'groupinfo',
|
|
42
|
-
MLS: '
|
|
43
|
-
JOIN: '
|
|
48
|
+
MLS: 'mls',
|
|
49
|
+
JOIN: 'join',
|
|
44
50
|
LIST: 'list',
|
|
45
51
|
LIST_IDS: 'list-ids',
|
|
46
52
|
MEMBERS: 'members',
|
|
@@ -64,8 +70,8 @@ class ConversationAPI {
|
|
|
64
70
|
}
|
|
65
71
|
generateBaseConversationUrl(conversationId, supportsQualifiedEndpoint = true) {
|
|
66
72
|
return supportsQualifiedEndpoint && conversationId.domain
|
|
67
|
-
?
|
|
68
|
-
:
|
|
73
|
+
? `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId.domain}/${conversationId.id}`
|
|
74
|
+
: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId.id}`;
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
71
77
|
* Delete a conversation code.
|
|
@@ -75,7 +81,7 @@ class ConversationAPI {
|
|
|
75
81
|
async deleteConversationCode(conversationId) {
|
|
76
82
|
const config = {
|
|
77
83
|
method: 'delete',
|
|
78
|
-
url:
|
|
84
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.CODE}`,
|
|
79
85
|
};
|
|
80
86
|
const response = await this.client.sendJSON(config);
|
|
81
87
|
return response.data;
|
|
@@ -94,7 +100,9 @@ class ConversationAPI {
|
|
|
94
100
|
async deleteService(conversationId, serviceId) {
|
|
95
101
|
const config = {
|
|
96
102
|
method: 'delete',
|
|
97
|
-
url:
|
|
103
|
+
url: this.backendFeatures.version >= apiBreakpoint.version7
|
|
104
|
+
? `/${ConversationAPI.URL.BOT}/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${serviceId}`
|
|
105
|
+
: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.BOTS}/${serviceId}`,
|
|
98
106
|
};
|
|
99
107
|
await this.client.sendJSON(config);
|
|
100
108
|
}
|
|
@@ -105,7 +113,7 @@ class ConversationAPI {
|
|
|
105
113
|
* @see https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/delete_conversations__cnv_domain___cnv__members__usr_domain___usr_
|
|
106
114
|
*/
|
|
107
115
|
async deleteMember(conversationId, userId) {
|
|
108
|
-
const url =
|
|
116
|
+
const url = `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId.domain}/${conversationId.id}/${ConversationAPI.URL.MEMBERS}/${userId.domain}/${userId.id}`;
|
|
109
117
|
const response = await this.client.sendJSON({
|
|
110
118
|
method: 'delete',
|
|
111
119
|
url,
|
|
@@ -120,7 +128,7 @@ class ConversationAPI {
|
|
|
120
128
|
async getConversationCode(conversationId) {
|
|
121
129
|
const config = {
|
|
122
130
|
method: 'GET',
|
|
123
|
-
url:
|
|
131
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.CODE}`,
|
|
124
132
|
};
|
|
125
133
|
const response = await this.client.sendJSON(config);
|
|
126
134
|
return response.data;
|
|
@@ -132,7 +140,7 @@ class ConversationAPI {
|
|
|
132
140
|
async getConversationGuestLinkFeature(conversationId) {
|
|
133
141
|
const config = {
|
|
134
142
|
method: 'get',
|
|
135
|
-
url:
|
|
143
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/features/conversationGuestLinks`,
|
|
136
144
|
};
|
|
137
145
|
const response = await this.client.sendJSON(config);
|
|
138
146
|
return response.data;
|
|
@@ -149,7 +157,7 @@ class ConversationAPI {
|
|
|
149
157
|
async getMLSSelfConversation() {
|
|
150
158
|
const config = {
|
|
151
159
|
method: 'get',
|
|
152
|
-
url:
|
|
160
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.MLS_SELF}`,
|
|
153
161
|
};
|
|
154
162
|
const response = await this.client.sendJSON(config);
|
|
155
163
|
return response.data;
|
|
@@ -202,7 +210,7 @@ class ConversationAPI {
|
|
|
202
210
|
const config = {
|
|
203
211
|
data: {},
|
|
204
212
|
method: 'post',
|
|
205
|
-
url:
|
|
213
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.LIST_IDS}`,
|
|
206
214
|
};
|
|
207
215
|
if (limit > 0) {
|
|
208
216
|
config.data.size = limit;
|
|
@@ -233,9 +241,9 @@ class ConversationAPI {
|
|
|
233
241
|
const config = {
|
|
234
242
|
data: { qualified_ids: chunk },
|
|
235
243
|
method: 'post',
|
|
236
|
-
url: this.backendFeatures.version >=
|
|
237
|
-
?
|
|
238
|
-
:
|
|
244
|
+
url: this.backendFeatures.version >= apiBreakpoint.version2
|
|
245
|
+
? `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.LIST}`
|
|
246
|
+
: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.LIST}/${ConversationAPI.URL.V2}`,
|
|
239
247
|
};
|
|
240
248
|
const { data } = await this.client.sendJSON(config);
|
|
241
249
|
results = {
|
|
@@ -276,7 +284,7 @@ class ConversationAPI {
|
|
|
276
284
|
async getRoles(conversationId) {
|
|
277
285
|
const config = {
|
|
278
286
|
method: 'get',
|
|
279
|
-
url:
|
|
287
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.ROLES}`,
|
|
280
288
|
};
|
|
281
289
|
const response = await this.client.sendJSON(config);
|
|
282
290
|
return response.data;
|
|
@@ -303,7 +311,9 @@ class ConversationAPI {
|
|
|
303
311
|
const config = {
|
|
304
312
|
data: conversationData,
|
|
305
313
|
method: 'post',
|
|
306
|
-
url:
|
|
314
|
+
url: this.backendFeatures.version >= apiBreakpoint.version7
|
|
315
|
+
? `${ConversationAPI.URL.ONE_2_ONE}-${ConversationAPI.URL.CONVERSATIONS}`
|
|
316
|
+
: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.ONE_2_ONE}`,
|
|
307
317
|
};
|
|
308
318
|
await this.client.sendJSON(config);
|
|
309
319
|
}
|
|
@@ -314,7 +324,9 @@ class ConversationAPI {
|
|
|
314
324
|
async getMLS1to1Conversation({ domain, id }) {
|
|
315
325
|
const config = {
|
|
316
326
|
method: 'get',
|
|
317
|
-
url:
|
|
327
|
+
url: this.backendFeatures.version >= apiBreakpoint.version7
|
|
328
|
+
? `${ConversationAPI.URL.ONE_2_ONE}-${ConversationAPI.URL.CONVERSATIONS}/${domain}/${id}`
|
|
329
|
+
: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.ONE_2_ONE}/${domain}/${id}`,
|
|
318
330
|
};
|
|
319
331
|
const response = await this.client.sendJSON(config);
|
|
320
332
|
return response.data;
|
|
@@ -329,7 +341,7 @@ class ConversationAPI {
|
|
|
329
341
|
const config = {
|
|
330
342
|
data: invitationData,
|
|
331
343
|
method: 'post',
|
|
332
|
-
url:
|
|
344
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.MEMBERS}`,
|
|
333
345
|
};
|
|
334
346
|
try {
|
|
335
347
|
const response = await this.client.sendJSON(config);
|
|
@@ -364,7 +376,9 @@ class ConversationAPI {
|
|
|
364
376
|
service: serviceId,
|
|
365
377
|
},
|
|
366
378
|
method: 'post',
|
|
367
|
-
url:
|
|
379
|
+
url: this.backendFeatures.version >= apiBreakpoint.version7
|
|
380
|
+
? `/${ConversationAPI.URL.BOT}/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}`
|
|
381
|
+
: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.BOTS}}`,
|
|
368
382
|
};
|
|
369
383
|
const response = await this.client.sendJSON(config);
|
|
370
384
|
return response.data;
|
|
@@ -405,7 +419,7 @@ class ConversationAPI {
|
|
|
405
419
|
async postConversationCodeRequest(conversationId, password) {
|
|
406
420
|
const config = {
|
|
407
421
|
method: 'post',
|
|
408
|
-
url:
|
|
422
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.CODE}`,
|
|
409
423
|
data: {},
|
|
410
424
|
};
|
|
411
425
|
if (password) {
|
|
@@ -423,7 +437,7 @@ class ConversationAPI {
|
|
|
423
437
|
const config = {
|
|
424
438
|
data: conversationCode,
|
|
425
439
|
method: 'post',
|
|
426
|
-
url:
|
|
440
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.CODE_CHECK}`,
|
|
427
441
|
};
|
|
428
442
|
try {
|
|
429
443
|
await this.client.sendJSON(config);
|
|
@@ -447,7 +461,7 @@ class ConversationAPI {
|
|
|
447
461
|
const config = {
|
|
448
462
|
data: conversationCode,
|
|
449
463
|
method: 'post',
|
|
450
|
-
url:
|
|
464
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.JOIN}`,
|
|
451
465
|
};
|
|
452
466
|
try {
|
|
453
467
|
const response = await this.client.sendJSON(config);
|
|
@@ -475,7 +489,7 @@ class ConversationAPI {
|
|
|
475
489
|
const config = {
|
|
476
490
|
params: conversationCode,
|
|
477
491
|
method: 'get',
|
|
478
|
-
url:
|
|
492
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.JOIN}`,
|
|
479
493
|
};
|
|
480
494
|
try {
|
|
481
495
|
const response = await this.client.sendJSON(config);
|
|
@@ -499,7 +513,7 @@ class ConversationAPI {
|
|
|
499
513
|
async postJoin(conversationId) {
|
|
500
514
|
const config = {
|
|
501
515
|
method: 'post',
|
|
502
|
-
url:
|
|
516
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}`,
|
|
503
517
|
};
|
|
504
518
|
const response = await this.client.sendJSON(config);
|
|
505
519
|
return response.data;
|
|
@@ -534,7 +548,7 @@ class ConversationAPI {
|
|
|
534
548
|
*/
|
|
535
549
|
data: otr_1.proteus.QualifiedNewOtrMessage.encode(messageData).finish().slice(),
|
|
536
550
|
method: 'post',
|
|
537
|
-
url:
|
|
551
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${domain}/${conversationId}/${ConversationAPI.URL.PROTEUS}/${ConversationAPI.URL.MESSAGES}`,
|
|
538
552
|
};
|
|
539
553
|
const response = await this.client.sendProtocolBuffer(config, true);
|
|
540
554
|
return response.data;
|
|
@@ -549,7 +563,7 @@ class ConversationAPI {
|
|
|
549
563
|
const config = {
|
|
550
564
|
data: messageData,
|
|
551
565
|
method: 'post',
|
|
552
|
-
url:
|
|
566
|
+
url: `/${ConversationAPI.URL.MLS}/${ConversationAPI.URL.MESSAGES}`,
|
|
553
567
|
};
|
|
554
568
|
const response = await this.client.sendProtocolMls(config, true);
|
|
555
569
|
return response.data;
|
|
@@ -564,7 +578,7 @@ class ConversationAPI {
|
|
|
564
578
|
const config = {
|
|
565
579
|
data: messageData,
|
|
566
580
|
method: 'post',
|
|
567
|
-
url:
|
|
581
|
+
url: `/${ConversationAPI.URL.MLS}/commit-bundles`,
|
|
568
582
|
};
|
|
569
583
|
const response = await this.client.sendProtocolMls(config, true);
|
|
570
584
|
return response.data;
|
|
@@ -576,7 +590,7 @@ class ConversationAPI {
|
|
|
576
590
|
async postSelf() {
|
|
577
591
|
const config = {
|
|
578
592
|
method: 'post',
|
|
579
|
-
url:
|
|
593
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.SELF}`,
|
|
580
594
|
};
|
|
581
595
|
const response = await this.client.sendJSON(config);
|
|
582
596
|
return response.data;
|
|
@@ -620,7 +634,7 @@ class ConversationAPI {
|
|
|
620
634
|
const config = {
|
|
621
635
|
data: conversationNameData,
|
|
622
636
|
method: 'put',
|
|
623
|
-
url:
|
|
637
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.NAME}`,
|
|
624
638
|
};
|
|
625
639
|
const response = await this.client.sendJSON(config);
|
|
626
640
|
return response.data;
|
|
@@ -635,7 +649,7 @@ class ConversationAPI {
|
|
|
635
649
|
const config = {
|
|
636
650
|
data: messageTimerData,
|
|
637
651
|
method: 'put',
|
|
638
|
-
url:
|
|
652
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId.id}/${ConversationAPI.URL.MESSAGE_TIMER}`,
|
|
639
653
|
};
|
|
640
654
|
const response = await this.client.sendJSON(config);
|
|
641
655
|
return response.data;
|
|
@@ -669,7 +683,7 @@ class ConversationAPI {
|
|
|
669
683
|
method: 'post',
|
|
670
684
|
url: this.backendFeatures.version >= 2
|
|
671
685
|
? `${this.generateBaseConversationUrl(conversationId)}/${ConversationAPI.URL.MEMBERS}`
|
|
672
|
-
:
|
|
686
|
+
: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId.id}/${ConversationAPI.URL.MEMBERS}/${ConversationAPI.URL.V2}`,
|
|
673
687
|
};
|
|
674
688
|
try {
|
|
675
689
|
const response = await this.client.sendJSON(config);
|
|
@@ -699,7 +713,7 @@ class ConversationAPI {
|
|
|
699
713
|
const config = {
|
|
700
714
|
data: memberUpdateData,
|
|
701
715
|
method: 'put',
|
|
702
|
-
url:
|
|
716
|
+
url: `/${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.MEMBERS}/${userId}`,
|
|
703
717
|
};
|
|
704
718
|
await this.client.sendJSON(config);
|
|
705
719
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAPI.d.ts","sourceRoot":"","sources":["../../src/user/UserAPI.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,4BAA4B,EAAC,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAC,YAAY,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAC;AAChE,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAkC,UAAU,EAAE,iBAAiB,EAAsB,MAAM,UAAU,CAAC;AAC7G,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,UAAU,EACV,0BAA0B,EAC1B,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,IAAI,EACJ,YAAY,EACb,MAAM,UAAU,CAAC;AAElB,KAAK,eAAe,GAAG;IACrB,6BAA6B,EAAE,4BAA4B,CAAC;IAC5D,cAAc,CAAC,EAAE,WAAW,EAAE,CAAC;CAChC,CAAC;AAKF,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC;C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e,EAAE,CAAA;KAAC,GAC7E,OAAO,CAAC,YAAY,CAAC;IA6CxB;;OAEG;IACU,eAAe,CAAC,UAAU,EAAE,0BAA0B,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAcrG;;;OAGG;IACU,sBAAsB,CACjC,aAAa,EAAE,oBAAoB,EACnC,KAAK,GAAE,MAAuD,GAC7D,OAAO,CAAC,eAAe,CAAC;IA2C3B;;;;;OAKG;IACU,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,GAAG,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAUlG;;;;;OAKG;IACU,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAUhF;;;;OAIG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU3D;;;;OAIG;IACU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ9E"}
|
package/lib/user/UserAPI.js
CHANGED
|
@@ -32,33 +32,38 @@ function isPrekeysResponse(object) {
|
|
|
32
32
|
function isUsersResponse(object) {
|
|
33
33
|
return object.found || object.failed || object.not_found;
|
|
34
34
|
}
|
|
35
|
+
const apiBreakpoint = {
|
|
36
|
+
version2: 2,
|
|
37
|
+
// API V7 introduces new endpoints to conversations and users
|
|
38
|
+
version7: 7,
|
|
39
|
+
};
|
|
35
40
|
class UserAPI {
|
|
36
41
|
client;
|
|
37
42
|
backendFeatures;
|
|
38
43
|
static DEFAULT_USERS_CHUNK_SIZE = 50;
|
|
39
44
|
static DEFAULT_USERS_PREKEY_BUNDLE_CHUNK_SIZE = 128;
|
|
40
45
|
static URL = {
|
|
41
|
-
ACTIVATE: '
|
|
46
|
+
ACTIVATE: 'activate',
|
|
42
47
|
BY_HANDLE: 'by-handle',
|
|
43
|
-
CALLS: '
|
|
48
|
+
CALLS: 'calls',
|
|
44
49
|
CLIENTS: 'clients',
|
|
45
50
|
CONFIG: 'config',
|
|
46
51
|
CONTACTS: 'contacts',
|
|
47
|
-
DELETE: '
|
|
52
|
+
DELETE: 'delete',
|
|
48
53
|
EMAIL: 'email',
|
|
49
54
|
HANDLES: 'handles',
|
|
50
55
|
LIST_CLIENTS: 'list-clients',
|
|
51
56
|
LIST_PREKEYS: 'list-prekeys',
|
|
52
|
-
LIST_USERS: '
|
|
53
|
-
PASSWORD_RESET: '
|
|
57
|
+
LIST_USERS: 'list-users',
|
|
58
|
+
PASSWORD_RESET: 'password-reset',
|
|
54
59
|
PRE_KEYS: 'prekeys',
|
|
55
|
-
PROPERTIES: '
|
|
60
|
+
PROPERTIES: 'properties',
|
|
56
61
|
RICH_INFO: 'rich-info',
|
|
57
|
-
SEARCH: '
|
|
62
|
+
SEARCH: 'search',
|
|
58
63
|
SEND: 'send',
|
|
59
|
-
USERS: '
|
|
64
|
+
USERS: 'users',
|
|
60
65
|
V2: 'v2',
|
|
61
|
-
VERIFICATION: '
|
|
66
|
+
VERIFICATION: 'verification-code',
|
|
62
67
|
SUPPORTED_PROTOCOLS: 'supported-protocols',
|
|
63
68
|
};
|
|
64
69
|
constructor(client, backendFeatures) {
|
|
@@ -72,7 +77,7 @@ class UserAPI {
|
|
|
72
77
|
async deleteProperties() {
|
|
73
78
|
const config = {
|
|
74
79
|
method: 'delete',
|
|
75
|
-
url: UserAPI.URL.PROPERTIES
|
|
80
|
+
url: `/${UserAPI.URL.PROPERTIES}`,
|
|
76
81
|
};
|
|
77
82
|
await this.client.sendJSON(config);
|
|
78
83
|
}
|
|
@@ -84,7 +89,7 @@ class UserAPI {
|
|
|
84
89
|
async deleteProperty(propertyKey) {
|
|
85
90
|
const config = {
|
|
86
91
|
method: 'delete',
|
|
87
|
-
url:
|
|
92
|
+
url: `/${UserAPI.URL.PROPERTIES}/${propertyKey}`,
|
|
88
93
|
};
|
|
89
94
|
await this.client.sendJSON(config);
|
|
90
95
|
}
|
|
@@ -101,7 +106,7 @@ class UserAPI {
|
|
|
101
106
|
code: activationCode,
|
|
102
107
|
key: activationKey,
|
|
103
108
|
},
|
|
104
|
-
url: UserAPI.URL.ACTIVATE
|
|
109
|
+
url: `/${UserAPI.URL.ACTIVATE}`,
|
|
105
110
|
};
|
|
106
111
|
const response = await this.client.sendJSON(config);
|
|
107
112
|
return response.data;
|
|
@@ -113,7 +118,7 @@ class UserAPI {
|
|
|
113
118
|
async getCallsConfiguration() {
|
|
114
119
|
const config = {
|
|
115
120
|
method: 'get',
|
|
116
|
-
url:
|
|
121
|
+
url: `/${UserAPI.URL.CALLS}/${UserAPI.URL.CONFIG}`,
|
|
117
122
|
};
|
|
118
123
|
const response = await this.client.sendJSON(config);
|
|
119
124
|
return response.data;
|
|
@@ -125,7 +130,7 @@ class UserAPI {
|
|
|
125
130
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getUserClient
|
|
126
131
|
*/
|
|
127
132
|
async getClient(userId, clientId) {
|
|
128
|
-
const url =
|
|
133
|
+
const url = `/${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.CLIENTS}/${clientId}`;
|
|
129
134
|
const config = {
|
|
130
135
|
method: 'get',
|
|
131
136
|
url,
|
|
@@ -141,7 +146,7 @@ class UserAPI {
|
|
|
141
146
|
*/
|
|
142
147
|
async getClientPreKey(userId, clientId) {
|
|
143
148
|
const { id, domain } = userId;
|
|
144
|
-
const url =
|
|
149
|
+
const url = `/${UserAPI.URL.USERS}/${domain}/${id}/${UserAPI.URL.PRE_KEYS}/${clientId}`;
|
|
145
150
|
const config = {
|
|
146
151
|
method: 'get',
|
|
147
152
|
url,
|
|
@@ -155,7 +160,7 @@ class UserAPI {
|
|
|
155
160
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getUserClients
|
|
156
161
|
*/
|
|
157
162
|
async getClients(userId) {
|
|
158
|
-
const url =
|
|
163
|
+
const url = `/${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.CLIENTS}`;
|
|
159
164
|
const config = {
|
|
160
165
|
method: 'get',
|
|
161
166
|
url,
|
|
@@ -172,7 +177,7 @@ class UserAPI {
|
|
|
172
177
|
async getHandle(handle) {
|
|
173
178
|
const config = {
|
|
174
179
|
method: 'get',
|
|
175
|
-
url:
|
|
180
|
+
url: `/${UserAPI.URL.USERS}/${UserAPI.URL.HANDLES}/${handle}`,
|
|
176
181
|
};
|
|
177
182
|
const response = await this.client.sendJSON(config);
|
|
178
183
|
return response.data;
|
|
@@ -184,7 +189,7 @@ class UserAPI {
|
|
|
184
189
|
async getProperties() {
|
|
185
190
|
const config = {
|
|
186
191
|
method: 'get',
|
|
187
|
-
url: UserAPI.URL.PROPERTIES
|
|
192
|
+
url: `/${UserAPI.URL.PROPERTIES}`,
|
|
188
193
|
};
|
|
189
194
|
const response = await this.client.sendJSON(config);
|
|
190
195
|
return response.data;
|
|
@@ -197,7 +202,7 @@ class UserAPI {
|
|
|
197
202
|
async getProperty(propertyKey) {
|
|
198
203
|
const config = {
|
|
199
204
|
method: 'get',
|
|
200
|
-
url:
|
|
205
|
+
url: `/${UserAPI.URL.PROPERTIES}/${propertyKey}`,
|
|
201
206
|
};
|
|
202
207
|
const response = await this.client.sendJSON(config);
|
|
203
208
|
return response.data;
|
|
@@ -217,7 +222,7 @@ class UserAPI {
|
|
|
217
222
|
params: {
|
|
218
223
|
q: query,
|
|
219
224
|
},
|
|
220
|
-
url:
|
|
225
|
+
url: `/${UserAPI.URL.SEARCH}/${UserAPI.URL.CONTACTS}`,
|
|
221
226
|
};
|
|
222
227
|
if (domain) {
|
|
223
228
|
config.params.domain = domain;
|
|
@@ -250,8 +255,8 @@ class UserAPI {
|
|
|
250
255
|
*/
|
|
251
256
|
async getUser(userId) {
|
|
252
257
|
const url = typeof userId === 'string'
|
|
253
|
-
?
|
|
254
|
-
:
|
|
258
|
+
? `/${UserAPI.URL.USERS}/${userId}`
|
|
259
|
+
: `/${UserAPI.URL.USERS}/${userId.domain}/${userId.id}`;
|
|
255
260
|
const config = {
|
|
256
261
|
method: 'get',
|
|
257
262
|
url,
|
|
@@ -260,7 +265,7 @@ class UserAPI {
|
|
|
260
265
|
return response.data;
|
|
261
266
|
}
|
|
262
267
|
async getUserPreKeys(userId) {
|
|
263
|
-
const url =
|
|
268
|
+
const url = `/${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.PRE_KEYS}`;
|
|
264
269
|
const config = {
|
|
265
270
|
method: 'get',
|
|
266
271
|
url,
|
|
@@ -269,7 +274,7 @@ class UserAPI {
|
|
|
269
274
|
return response.data;
|
|
270
275
|
}
|
|
271
276
|
async getUserSupportedProtocols(userId) {
|
|
272
|
-
const url =
|
|
277
|
+
const url = `/${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.SUPPORTED_PROTOCOLS}`;
|
|
273
278
|
const config = {
|
|
274
279
|
method: 'get',
|
|
275
280
|
url,
|
|
@@ -328,8 +333,8 @@ class UserAPI {
|
|
|
328
333
|
*/
|
|
329
334
|
async headUsers(userId) {
|
|
330
335
|
const url = typeof userId === 'string'
|
|
331
|
-
?
|
|
332
|
-
:
|
|
336
|
+
? `/${UserAPI.URL.USERS}/${userId}`
|
|
337
|
+
: `/${UserAPI.URL.USERS}/${userId.domain}/${userId.id}`;
|
|
333
338
|
const config = {
|
|
334
339
|
method: 'head',
|
|
335
340
|
url,
|
|
@@ -346,7 +351,7 @@ class UserAPI {
|
|
|
346
351
|
const config = {
|
|
347
352
|
data: activationData,
|
|
348
353
|
method: 'post',
|
|
349
|
-
url: UserAPI.URL.ACTIVATE
|
|
354
|
+
url: `/${UserAPI.URL.ACTIVATE}`,
|
|
350
355
|
};
|
|
351
356
|
const response = await this.client.sendJSON(config);
|
|
352
357
|
return response.data;
|
|
@@ -360,7 +365,7 @@ class UserAPI {
|
|
|
360
365
|
const config = {
|
|
361
366
|
data: activationCodeData,
|
|
362
367
|
method: 'post',
|
|
363
|
-
url:
|
|
368
|
+
url: `/${UserAPI.URL.ACTIVATE}/${UserAPI.URL.SEND}`,
|
|
364
369
|
};
|
|
365
370
|
await this.client.sendJSON(config);
|
|
366
371
|
}
|
|
@@ -373,7 +378,7 @@ class UserAPI {
|
|
|
373
378
|
const config = {
|
|
374
379
|
data: { email, action },
|
|
375
380
|
method: 'post',
|
|
376
|
-
url:
|
|
381
|
+
url: `/${UserAPI.URL.VERIFICATION}/${UserAPI.URL.SEND}`,
|
|
377
382
|
};
|
|
378
383
|
await this.client.sendJSON(config);
|
|
379
384
|
}
|
|
@@ -386,7 +391,7 @@ class UserAPI {
|
|
|
386
391
|
const config = {
|
|
387
392
|
data: verificationData,
|
|
388
393
|
method: 'post',
|
|
389
|
-
url: UserAPI.URL.DELETE
|
|
394
|
+
url: `/${UserAPI.URL.DELETE}`,
|
|
390
395
|
};
|
|
391
396
|
await this.client.sendJSON(config);
|
|
392
397
|
}
|
|
@@ -399,7 +404,9 @@ class UserAPI {
|
|
|
399
404
|
const config = {
|
|
400
405
|
data: handles,
|
|
401
406
|
method: 'post',
|
|
402
|
-
url:
|
|
407
|
+
url: this.backendFeatures.version >= apiBreakpoint.version7
|
|
408
|
+
? `/${UserAPI.URL.HANDLES}`
|
|
409
|
+
: `/${UserAPI.URL.USERS}/${UserAPI.URL.HANDLES}`,
|
|
403
410
|
};
|
|
404
411
|
const response = await this.client.sendJSON(config);
|
|
405
412
|
return response.data;
|
|
@@ -412,7 +419,9 @@ class UserAPI {
|
|
|
412
419
|
async headHandle(handle) {
|
|
413
420
|
const config = {
|
|
414
421
|
method: 'head',
|
|
415
|
-
url:
|
|
422
|
+
url: this.backendFeatures.version >= apiBreakpoint.version7
|
|
423
|
+
? `/${UserAPI.URL.HANDLES}/${handle}`
|
|
424
|
+
: `/${UserAPI.URL.USERS}/${UserAPI.URL.HANDLES}/${handle}`,
|
|
416
425
|
};
|
|
417
426
|
await this.client.sendJSON(config);
|
|
418
427
|
}
|
|
@@ -424,7 +433,7 @@ class UserAPI {
|
|
|
424
433
|
async getUserByHandle(handle) {
|
|
425
434
|
const config = {
|
|
426
435
|
method: 'get',
|
|
427
|
-
url:
|
|
436
|
+
url: `/${UserAPI.URL.USERS}/${UserAPI.URL.BY_HANDLE}/${handle.domain}/${handle.handle}`,
|
|
428
437
|
};
|
|
429
438
|
const response = await this.client.sendJSON(config);
|
|
430
439
|
return response.data;
|
|
@@ -433,7 +442,7 @@ class UserAPI {
|
|
|
433
442
|
const config = {
|
|
434
443
|
data: userClientMap,
|
|
435
444
|
method: 'post',
|
|
436
|
-
url:
|
|
445
|
+
url: `/${UserAPI.URL.USERS}/${UserAPI.URL.LIST_PREKEYS}`,
|
|
437
446
|
};
|
|
438
447
|
const response = await this.client.sendJSON(config, true);
|
|
439
448
|
return isPrekeysResponse(response.data) ? response.data : { qualified_user_client_prekeys: response.data };
|
|
@@ -446,7 +455,7 @@ class UserAPI {
|
|
|
446
455
|
const config = {
|
|
447
456
|
data: users,
|
|
448
457
|
method: 'post',
|
|
449
|
-
url: UserAPI.URL.LIST_USERS
|
|
458
|
+
url: `/${UserAPI.URL.LIST_USERS}`,
|
|
450
459
|
};
|
|
451
460
|
try {
|
|
452
461
|
/**
|
|
@@ -477,7 +486,7 @@ class UserAPI {
|
|
|
477
486
|
const { data: sameBackendUserData } = await this.client.sendJSON({
|
|
478
487
|
data: { qualified_ids: sameBackendUsers },
|
|
479
488
|
method: 'post',
|
|
480
|
-
url: UserAPI.URL.LIST_USERS
|
|
489
|
+
url: `/${UserAPI.URL.LIST_USERS}`,
|
|
481
490
|
});
|
|
482
491
|
return { found: sameBackendUserData, failed: federatedUsers };
|
|
483
492
|
}
|
|
@@ -491,9 +500,9 @@ class UserAPI {
|
|
|
491
500
|
const config = {
|
|
492
501
|
data: userIdList,
|
|
493
502
|
method: 'post',
|
|
494
|
-
url: this.backendFeatures.version >=
|
|
495
|
-
?
|
|
496
|
-
:
|
|
503
|
+
url: this.backendFeatures.version >= apiBreakpoint.version2
|
|
504
|
+
? `/${UserAPI.URL.USERS}/${UserAPI.URL.LIST_CLIENTS}`
|
|
505
|
+
: `/${UserAPI.URL.USERS}/${UserAPI.URL.LIST_CLIENTS}/${UserAPI.URL.V2}`,
|
|
497
506
|
};
|
|
498
507
|
const response = await this.client.sendJSON(config);
|
|
499
508
|
return response.data;
|
|
@@ -545,7 +554,7 @@ class UserAPI {
|
|
|
545
554
|
const config = {
|
|
546
555
|
data: resetData,
|
|
547
556
|
method: 'post',
|
|
548
|
-
url: UserAPI.URL.PASSWORD_RESET
|
|
557
|
+
url: `/${UserAPI.URL.PASSWORD_RESET}`,
|
|
549
558
|
};
|
|
550
559
|
await this.client.sendJSON(config);
|
|
551
560
|
}
|
|
@@ -559,7 +568,7 @@ class UserAPI {
|
|
|
559
568
|
const config = {
|
|
560
569
|
data: propertyData,
|
|
561
570
|
method: 'put',
|
|
562
|
-
url:
|
|
571
|
+
url: `/${UserAPI.URL.PROPERTIES}/${propertyKey}`,
|
|
563
572
|
};
|
|
564
573
|
await this.client.sendJSON(config);
|
|
565
574
|
}
|
|
@@ -571,7 +580,7 @@ class UserAPI {
|
|
|
571
580
|
async getRichInfo(userId) {
|
|
572
581
|
const config = {
|
|
573
582
|
method: 'get',
|
|
574
|
-
url:
|
|
583
|
+
url: `/${UserAPI.URL.USERS}/${userId}/${UserAPI.URL.RICH_INFO}`,
|
|
575
584
|
};
|
|
576
585
|
const response = await this.client.sendJSON(config);
|
|
577
586
|
return response.data;
|
|
@@ -585,7 +594,7 @@ class UserAPI {
|
|
|
585
594
|
const config = {
|
|
586
595
|
data: { email },
|
|
587
596
|
method: 'put',
|
|
588
|
-
url:
|
|
597
|
+
url: `/${UserAPI.URL.USERS}/${userId}/${UserAPI.URL.EMAIL}`,
|
|
589
598
|
};
|
|
590
599
|
await this.client.sendJSON(config);
|
|
591
600
|
}
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"browser-sync": "3.0.3",
|
|
43
43
|
"concurrently": "9.1.0",
|
|
44
44
|
"cross-env": "7.0.3",
|
|
45
|
-
"dotenv": "16.4.
|
|
45
|
+
"dotenv": "16.4.6",
|
|
46
46
|
"jest": "^29.2.1",
|
|
47
47
|
"nock": "13.5.6",
|
|
48
48
|
"react": "18.3.1",
|
|
@@ -66,6 +66,6 @@
|
|
|
66
66
|
"watch": "webpack serve --config webpack.browser.js",
|
|
67
67
|
"prepare": "yarn dist"
|
|
68
68
|
},
|
|
69
|
-
"version": "27.
|
|
70
|
-
"gitHead": "
|
|
69
|
+
"version": "27.12.1",
|
|
70
|
+
"gitHead": "80f7e3f3405a1489ffa348f1e1111c36a0158017"
|
|
71
71
|
}
|