@wireapp/api-client 22.17.0 → 23.0.0
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/APIClient.js +1 -1
- package/lib/broadcast/BroadcastAPI.d.ts +2 -28
- package/lib/broadcast/BroadcastAPI.d.ts.map +1 -1
- package/lib/broadcast/BroadcastAPI.js +1 -71
- package/lib/connection/ConnectionAPI.d.ts +4 -20
- package/lib/connection/ConnectionAPI.d.ts.map +1 -1
- package/lib/connection/ConnectionAPI.js +4 -68
- package/lib/conversation/ConversationAPI/ConversationAPI.d.ts +3 -36
- package/lib/conversation/ConversationAPI/ConversationAPI.d.ts.map +1 -1
- package/lib/conversation/ConversationAPI/ConversationAPI.js +2 -133
- package/lib/demo/http401.js +1 -1
- package/lib/user/UserAPI.d.ts +6 -15
- package/lib/user/UserAPI.d.ts.map +1 -1
- package/lib/user/UserAPI.js +4 -54
- package/lib/user/UserPreKeyBundleMap.d.ts +1 -3
- package/lib/user/UserPreKeyBundleMap.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/APIClient.js
CHANGED
|
@@ -99,7 +99,7 @@ class APIClient extends events_1.EventEmitter {
|
|
|
99
99
|
services: new services_1.ServicesAPI(this.transport.http, assetAPI),
|
|
100
100
|
broadcast: new broadcast_1.BroadcastAPI(this.transport.http),
|
|
101
101
|
client: new client_1.ClientAPI(this.transport.http),
|
|
102
|
-
connection: new connection_1.ConnectionAPI(this.transport.http
|
|
102
|
+
connection: new connection_1.ConnectionAPI(this.transport.http),
|
|
103
103
|
conversation: new conversation_1.ConversationAPI(this.transport.http, backendFeatures),
|
|
104
104
|
giphy: new giphy_1.GiphyAPI(this.transport.http),
|
|
105
105
|
notification: new notification_1.NotificationAPI(this.transport.http),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proteus as ProtobufOTR } from '@wireapp/protocol-messaging/web/otr';
|
|
2
|
-
import {
|
|
2
|
+
import { MessageSendingStatus } from '../conversation/';
|
|
3
3
|
import { HttpClient } from '../http/';
|
|
4
4
|
export declare class BroadcastAPI {
|
|
5
5
|
private readonly client;
|
|
@@ -8,38 +8,12 @@ export declare class BroadcastAPI {
|
|
|
8
8
|
BROADCAST: string;
|
|
9
9
|
BROADCAST_FEDERATED: string;
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Broadcast an encrypted message to all team members and all contacts (accepts Protobuf).
|
|
13
|
-
* @param sendingClientId The sender's client ID
|
|
14
|
-
* @param messageData The message content
|
|
15
|
-
* @param ignoreMissing Whether to report missing clients or not:
|
|
16
|
-
* `false`: Report about all missing clients
|
|
17
|
-
* `true`: Ignore all missing clients and force sending
|
|
18
|
-
* Array: User IDs specifying which user IDs are allowed to have
|
|
19
|
-
* missing clients
|
|
20
|
-
* `undefined`: Default to setting of `report_missing` in `NewOTRMessage`
|
|
21
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/tab.html#!/postOtrBroadcast
|
|
22
|
-
*/
|
|
23
|
-
postBroadcastMessage(sendingClientId: string, messageData: NewOTRMessage<string>, ignoreMissing?: boolean | string[]): Promise<ClientMismatch>;
|
|
24
|
-
/**
|
|
25
|
-
* Broadcast an encrypted message to all team members and all contacts (accepts Protobuf).
|
|
26
|
-
* @param sendingClientId The sender's client ID
|
|
27
|
-
* @param messageData The message content
|
|
28
|
-
* @param ignoreMissing Whether to report missing clients or not:
|
|
29
|
-
* `false`: Report about all missing clients
|
|
30
|
-
* `true`: Ignore all missing clients and force sending
|
|
31
|
-
* Array: User IDs specifying which user IDs are allowed to have
|
|
32
|
-
* missing clients
|
|
33
|
-
* `undefined`: Default to setting of `report_missing` in `NewOTRMessage`
|
|
34
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/tab.html#!/postOtrBroadcast
|
|
35
|
-
*/
|
|
36
|
-
postBroadcastProtobufMessage(sendingClientId: string, messageData: ProtobufOTR.NewOtrMessage, ignoreMissing?: boolean | string[]): Promise<ClientMismatch>;
|
|
37
11
|
/**
|
|
38
12
|
* Broadcast an encrypted message to all team members and all contacts in federated environments
|
|
39
13
|
* @param sendingClientId The sender's client ID
|
|
40
14
|
* @param messageData The message content
|
|
41
15
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/tab.html#!/postOtrBroadcast
|
|
42
16
|
*/
|
|
43
|
-
|
|
17
|
+
postBroadcastMessage(sendingClientId: string, messageData: ProtobufOTR.QualifiedNewOtrMessage): Promise<MessageSendingStatus>;
|
|
44
18
|
}
|
|
45
19
|
//# sourceMappingURL=BroadcastAPI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BroadcastAPI.d.ts","sourceRoot":"","sources":["../../src/broadcast/BroadcastAPI.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"BroadcastAPI.d.ts","sourceRoot":"","sources":["../../src/broadcast/BroadcastAPI.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,qCAAqC,CAAC;AAG3E,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C,gBAAuB,GAAG;;;MAGxB;IAEF;;;;;OAKG;IACU,oBAAoB,CAC/B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,WAAW,CAAC,sBAAsB,GAC9C,OAAO,CAAC,oBAAoB,CAAC;CAcjC"}
|
|
@@ -25,83 +25,13 @@ class BroadcastAPI {
|
|
|
25
25
|
constructor(client) {
|
|
26
26
|
this.client = client;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Broadcast an encrypted message to all team members and all contacts (accepts Protobuf).
|
|
30
|
-
* @param sendingClientId The sender's client ID
|
|
31
|
-
* @param messageData The message content
|
|
32
|
-
* @param ignoreMissing Whether to report missing clients or not:
|
|
33
|
-
* `false`: Report about all missing clients
|
|
34
|
-
* `true`: Ignore all missing clients and force sending
|
|
35
|
-
* Array: User IDs specifying which user IDs are allowed to have
|
|
36
|
-
* missing clients
|
|
37
|
-
* `undefined`: Default to setting of `report_missing` in `NewOTRMessage`
|
|
38
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/tab.html#!/postOtrBroadcast
|
|
39
|
-
*/
|
|
40
|
-
async postBroadcastMessage(sendingClientId, messageData, ignoreMissing) {
|
|
41
|
-
if (!sendingClientId) {
|
|
42
|
-
throw new validation_1.ValidationError('Unable to send OTR message without client ID.');
|
|
43
|
-
}
|
|
44
|
-
const config = {
|
|
45
|
-
data: messageData,
|
|
46
|
-
method: 'post',
|
|
47
|
-
url: BroadcastAPI.URL.BROADCAST,
|
|
48
|
-
};
|
|
49
|
-
if (typeof ignoreMissing !== 'undefined') {
|
|
50
|
-
const ignore_missing = Array.isArray(ignoreMissing) ? ignoreMissing.join(',') : ignoreMissing;
|
|
51
|
-
config.params = { ignore_missing };
|
|
52
|
-
// `ignore_missing` takes precedence on the server so we can remove
|
|
53
|
-
// `report_missing` to save some bandwidth.
|
|
54
|
-
delete messageData.report_missing;
|
|
55
|
-
}
|
|
56
|
-
else if (typeof messageData.report_missing === 'undefined') {
|
|
57
|
-
// both `ignore_missing` and `report_missing` are undefined
|
|
58
|
-
config.params = { ignore_missing: !!messageData.data };
|
|
59
|
-
}
|
|
60
|
-
const response = await this.client.sendJSON(config);
|
|
61
|
-
return response.data;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Broadcast an encrypted message to all team members and all contacts (accepts Protobuf).
|
|
65
|
-
* @param sendingClientId The sender's client ID
|
|
66
|
-
* @param messageData The message content
|
|
67
|
-
* @param ignoreMissing Whether to report missing clients or not:
|
|
68
|
-
* `false`: Report about all missing clients
|
|
69
|
-
* `true`: Ignore all missing clients and force sending
|
|
70
|
-
* Array: User IDs specifying which user IDs are allowed to have
|
|
71
|
-
* missing clients
|
|
72
|
-
* `undefined`: Default to setting of `report_missing` in `NewOTRMessage`
|
|
73
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/tab.html#!/postOtrBroadcast
|
|
74
|
-
*/
|
|
75
|
-
async postBroadcastProtobufMessage(sendingClientId, messageData, ignoreMissing) {
|
|
76
|
-
if (!sendingClientId) {
|
|
77
|
-
throw new validation_1.ValidationError('Unable to send OTR message without client ID.');
|
|
78
|
-
}
|
|
79
|
-
const config = {
|
|
80
|
-
data: otr_1.proteus.NewOtrMessage.encode(messageData).finish(),
|
|
81
|
-
method: 'post',
|
|
82
|
-
url: BroadcastAPI.URL.BROADCAST,
|
|
83
|
-
};
|
|
84
|
-
if (typeof ignoreMissing !== 'undefined') {
|
|
85
|
-
const ignore_missing = Array.isArray(ignoreMissing) ? ignoreMissing.join(',') : ignoreMissing;
|
|
86
|
-
config.params = { ignore_missing };
|
|
87
|
-
// `ignore_missing` takes precedence on the server so we can remove
|
|
88
|
-
// `report_missing` to save some bandwidth.
|
|
89
|
-
messageData.reportMissing = [];
|
|
90
|
-
}
|
|
91
|
-
else if (typeof messageData.reportMissing === 'undefined' || !messageData.reportMissing.length) {
|
|
92
|
-
// both `ignore_missing` and `report_missing` are undefined
|
|
93
|
-
config.params = { ignore_missing: !!messageData.blob };
|
|
94
|
-
}
|
|
95
|
-
const response = await this.client.sendProtocolBuffer(config);
|
|
96
|
-
return response.data;
|
|
97
|
-
}
|
|
98
28
|
/**
|
|
99
29
|
* Broadcast an encrypted message to all team members and all contacts in federated environments
|
|
100
30
|
* @param sendingClientId The sender's client ID
|
|
101
31
|
* @param messageData The message content
|
|
102
32
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/tab.html#!/postOtrBroadcast
|
|
103
33
|
*/
|
|
104
|
-
async
|
|
34
|
+
async postBroadcastMessage(sendingClientId, messageData) {
|
|
105
35
|
if (!sendingClientId) {
|
|
106
36
|
throw new validation_1.ValidationError('Unable to send OTR message without client ID.');
|
|
107
37
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { BackendFeatures } from '../APIClient';
|
|
2
1
|
import { Connection, ConnectionUpdate, UserConnectionList } from '../connection/';
|
|
3
2
|
import { HttpClient } from '../http/';
|
|
4
3
|
import { QualifiedId } from '../user';
|
|
5
4
|
export declare class ConnectionAPI {
|
|
6
5
|
private readonly client;
|
|
7
|
-
|
|
8
|
-
constructor(client: HttpClient, backendFeatures: BackendFeatures);
|
|
6
|
+
constructor(client: HttpClient);
|
|
9
7
|
static readonly URL: {
|
|
10
8
|
CONNECTIONS: string;
|
|
11
9
|
};
|
|
@@ -14,7 +12,7 @@ export declare class ConnectionAPI {
|
|
|
14
12
|
* @param userId The ID of the other user
|
|
15
13
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/connection
|
|
16
14
|
*/
|
|
17
|
-
getConnection(userId:
|
|
15
|
+
getConnection(userId: QualifiedId): Promise<Connection>;
|
|
18
16
|
/**
|
|
19
17
|
* List the connections to other users.
|
|
20
18
|
* @param limit Number of results to return (default 100, max 500)
|
|
@@ -28,27 +26,13 @@ export declare class ConnectionAPI {
|
|
|
28
26
|
* @see https://nginz-https.anta.wire.link/api/swagger-ui/#/default/post_list_connections
|
|
29
27
|
*/
|
|
30
28
|
getConnectionList(): Promise<Connection[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Get all connections to other users.
|
|
33
|
-
* @deprecated use `getConnectionList` instead
|
|
34
|
-
*/
|
|
35
|
-
getAllConnections(): Promise<Connection[]>;
|
|
36
|
-
postConnection(userId: QualifiedId, name?: string): Promise<Connection>;
|
|
37
|
-
/**
|
|
38
|
-
* Create a connection to another user.
|
|
39
|
-
* Note: You can have no more than 1000 connections in accepted or sent state.
|
|
40
|
-
* @deprecated use createConnection instead
|
|
41
|
-
* @param connectionRequestData: The connection request
|
|
42
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/createConnection
|
|
43
|
-
*/
|
|
44
|
-
private postConnection_v1;
|
|
45
29
|
/**
|
|
46
30
|
* Create a connection to another user.
|
|
47
31
|
* Note: You can have no more than 1000 connections in accepted or sent state.
|
|
48
32
|
* @param qualifiedUserId: The qualified id of the user we want to connect to
|
|
49
33
|
* @see https://nginz-https.anta.wire.link/api/swagger-ui/#/default/post_connections__uid_domain___uid
|
|
50
34
|
*/
|
|
51
|
-
|
|
35
|
+
postConnection({ id, domain }: QualifiedId): Promise<Connection>;
|
|
52
36
|
/**
|
|
53
37
|
* Update a connection.
|
|
54
38
|
* Note: You can have no more than 1000 connections in accepted or sent state.
|
|
@@ -56,6 +40,6 @@ export declare class ConnectionAPI {
|
|
|
56
40
|
* @param updatedConnection: The updated connection
|
|
57
41
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/updateConnection
|
|
58
42
|
*/
|
|
59
|
-
putConnection(userId:
|
|
43
|
+
putConnection(userId: QualifiedId, updatedConnection: ConnectionUpdate): Promise<Connection>;
|
|
60
44
|
}
|
|
61
45
|
//# sourceMappingURL=ConnectionAPI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionAPI.d.ts","sourceRoot":"","sources":["../../src/connection/ConnectionAPI.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"ConnectionAPI.d.ts","sourceRoot":"","sources":["../../src/connection/ConnectionAPI.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAkC,UAAU,EAAC,MAAM,UAAU,CAAC;AACrE,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEpC,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C,gBAAuB,GAAG;;MAExB;IAEF;;;;OAIG;IACU,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAWpE;;;;;OAKG;IACU,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,SAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAc5F;;;;OAIG;IACI,iBAAiB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAoCjD;;;;;OAKG;IACU,cAAc,CAAC,EAAC,EAAE,EAAE,MAAM,EAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB3E;;;;;;OAMG;IACU,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;CAY1G"}
|
|
@@ -22,9 +22,8 @@ exports.ConnectionAPI = void 0;
|
|
|
22
22
|
const ConnectionError_1 = require("./ConnectionError");
|
|
23
23
|
const http_1 = require("../http/");
|
|
24
24
|
class ConnectionAPI {
|
|
25
|
-
constructor(client
|
|
25
|
+
constructor(client) {
|
|
26
26
|
this.client = client;
|
|
27
|
-
this.backendFeatures = backendFeatures;
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* Get an existing connection to another user.
|
|
@@ -32,10 +31,7 @@ class ConnectionAPI {
|
|
|
32
31
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/connection
|
|
33
32
|
*/
|
|
34
33
|
async getConnection(userId) {
|
|
35
|
-
const
|
|
36
|
-
const url = typeof userId !== 'string' && this.backendFeatures.federationEndpoints
|
|
37
|
-
? `${ConnectionAPI.URL.CONNECTIONS}/${userId.domain}/${userId}`
|
|
38
|
-
: `${ConnectionAPI.URL.CONNECTIONS}/${strUserId}`;
|
|
34
|
+
const url = `${ConnectionAPI.URL.CONNECTIONS}/${userId.domain}/${userId}`;
|
|
39
35
|
const config = {
|
|
40
36
|
method: 'get',
|
|
41
37
|
url,
|
|
@@ -67,9 +63,6 @@ class ConnectionAPI {
|
|
|
67
63
|
* @see https://nginz-https.anta.wire.link/api/swagger-ui/#/default/post_list_connections
|
|
68
64
|
*/
|
|
69
65
|
getConnectionList() {
|
|
70
|
-
if (!this.backendFeatures.federationEndpoints) {
|
|
71
|
-
return this.getAllConnections();
|
|
72
|
-
}
|
|
73
66
|
let allConnections = [];
|
|
74
67
|
const getConnectionChunks = async (pagingState) => {
|
|
75
68
|
const connectionsPerRequest = 500;
|
|
@@ -93,67 +86,13 @@ class ConnectionAPI {
|
|
|
93
86
|
};
|
|
94
87
|
return getConnectionChunks();
|
|
95
88
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Get all connections to other users.
|
|
98
|
-
* @deprecated use `getConnectionList` instead
|
|
99
|
-
*/
|
|
100
|
-
getAllConnections() {
|
|
101
|
-
let allConnections = [];
|
|
102
|
-
const getConnectionChunks = async (connectionId) => {
|
|
103
|
-
const connectionsPerRequest = 500;
|
|
104
|
-
const { connections, has_more } = await this.getConnections(connectionId, connectionsPerRequest);
|
|
105
|
-
if (connections.length) {
|
|
106
|
-
allConnections = allConnections.concat(connections);
|
|
107
|
-
}
|
|
108
|
-
if (has_more) {
|
|
109
|
-
const lastConnection = connections.pop();
|
|
110
|
-
if (lastConnection) {
|
|
111
|
-
return getConnectionChunks(lastConnection.to);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return allConnections;
|
|
115
|
-
};
|
|
116
|
-
return getConnectionChunks();
|
|
117
|
-
}
|
|
118
|
-
async postConnection(userId, name) {
|
|
119
|
-
if (this.backendFeatures.federationEndpoints) {
|
|
120
|
-
return this.postConnection_v2(userId);
|
|
121
|
-
}
|
|
122
|
-
return this.postConnection_v1({ user: userId.id, name });
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Create a connection to another user.
|
|
126
|
-
* Note: You can have no more than 1000 connections in accepted or sent state.
|
|
127
|
-
* @deprecated use createConnection instead
|
|
128
|
-
* @param connectionRequestData: The connection request
|
|
129
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/createConnection
|
|
130
|
-
*/
|
|
131
|
-
async postConnection_v1(connectionRequestData) {
|
|
132
|
-
const config = {
|
|
133
|
-
data: connectionRequestData,
|
|
134
|
-
method: 'post',
|
|
135
|
-
url: ConnectionAPI.URL.CONNECTIONS,
|
|
136
|
-
};
|
|
137
|
-
try {
|
|
138
|
-
const response = await this.client.sendJSON(config);
|
|
139
|
-
return response.data;
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
switch (error.label) {
|
|
143
|
-
case http_1.BackendErrorLabel.LEGAL_HOLD_MISSING_CONSENT: {
|
|
144
|
-
throw new ConnectionError_1.ConnectionLegalholdMissingConsentError(error.message);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
throw error;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
89
|
/**
|
|
151
90
|
* Create a connection to another user.
|
|
152
91
|
* Note: You can have no more than 1000 connections in accepted or sent state.
|
|
153
92
|
* @param qualifiedUserId: The qualified id of the user we want to connect to
|
|
154
93
|
* @see https://nginz-https.anta.wire.link/api/swagger-ui/#/default/post_connections__uid_domain___uid
|
|
155
94
|
*/
|
|
156
|
-
async
|
|
95
|
+
async postConnection({ id, domain }) {
|
|
157
96
|
const config = {
|
|
158
97
|
method: 'post',
|
|
159
98
|
url: `${ConnectionAPI.URL.CONNECTIONS}/${domain}/${id}`,
|
|
@@ -179,10 +118,7 @@ class ConnectionAPI {
|
|
|
179
118
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/updateConnection
|
|
180
119
|
*/
|
|
181
120
|
async putConnection(userId, updatedConnection) {
|
|
182
|
-
const
|
|
183
|
-
const url = this.backendFeatures.federationEndpoints && typeof userId !== 'string'
|
|
184
|
-
? `${ConnectionAPI.URL.CONNECTIONS}/${userId.domain}/${userId.id}`
|
|
185
|
-
: `${ConnectionAPI.URL.CONNECTIONS}/${strUserId}`;
|
|
121
|
+
const url = `${ConnectionAPI.URL.CONNECTIONS}/${userId.domain}/${userId.id}`;
|
|
186
122
|
const config = {
|
|
187
123
|
data: updatedConnection,
|
|
188
124
|
method: 'put',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proteus as ProtobufOTR } from '@wireapp/protocol-messaging/web/otr';
|
|
2
|
-
import { ClientMismatch, Conversation, ConversationCode, ConversationRolesList, Conversations, Invite, Member, MessageSendingStatus, NewConversation,
|
|
2
|
+
import { ClientMismatch, Conversation, ConversationCode, ConversationRolesList, Conversations, Invite, Member, MessageSendingStatus, NewConversation, RemoteConversations } from '..';
|
|
3
3
|
import { BackendFeatures } from '../../APIClient';
|
|
4
4
|
import { ConversationAccessUpdateEvent, ConversationCodeDeleteEvent, ConversationCodeUpdateEvent, ConversationEvent, ConversationMemberJoinEvent, ConversationMemberLeaveEvent, ConversationMessageTimerUpdateEvent, ConversationReceiptModeUpdateEvent, ConversationRenameEvent } from '../../event';
|
|
5
5
|
import { HttpClient } from '../../http';
|
|
@@ -67,11 +67,6 @@ export declare class ConversationAPI {
|
|
|
67
67
|
* @see https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/delete_conversations__cnv_domain___cnv__members__usr_domain___usr_
|
|
68
68
|
*/
|
|
69
69
|
deleteMember(conversationId: QualifiedId, userId: QualifiedId): Promise<ConversationMemberLeaveEvent>;
|
|
70
|
-
/**
|
|
71
|
-
* Get all conversations.
|
|
72
|
-
* @deprecated - use getConversationList instead
|
|
73
|
-
*/
|
|
74
|
-
getAllConversations(): Promise<Conversation[]>;
|
|
75
70
|
/**
|
|
76
71
|
* Get a conversation code.
|
|
77
72
|
* @param conversationId ID of conversation to get the code for
|
|
@@ -83,14 +78,7 @@ export declare class ConversationAPI {
|
|
|
83
78
|
* @deprecated use feature.getAllFeatures instead
|
|
84
79
|
*/
|
|
85
80
|
getConversationGuestLinkFeature(conversationId: string): Promise<ConversationGuestLinkStatus>;
|
|
86
|
-
getConversation(conversationId:
|
|
87
|
-
/**
|
|
88
|
-
* Get a conversation by ID.
|
|
89
|
-
* @param conversationId The conversation ID
|
|
90
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/conversation
|
|
91
|
-
*/
|
|
92
|
-
private getConversation_v1;
|
|
93
|
-
private getConversation_v2;
|
|
81
|
+
getConversation(conversationId: QualifiedId): Promise<Conversation>;
|
|
94
82
|
getSubconversation(conversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID): Promise<Subconversation>;
|
|
95
83
|
deleteSubconversation(conversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID, { groupId, epoch }: {
|
|
96
84
|
groupId: string;
|
|
@@ -212,20 +200,6 @@ export declare class ConversationAPI {
|
|
|
212
200
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/joinConversation
|
|
213
201
|
*/
|
|
214
202
|
postJoin(conversationId: string): Promise<ConversationEvent>;
|
|
215
|
-
/**
|
|
216
|
-
* Post an encrypted message to a conversation.
|
|
217
|
-
* @param sendingClientId The sender's client ID
|
|
218
|
-
* @param conversationId The conversation ID
|
|
219
|
-
* @param messageData The message content
|
|
220
|
-
* @param ignoreMissing Whether to report missing clients or not:
|
|
221
|
-
* `false`: Report about all missing clients
|
|
222
|
-
* `true`: Ignore all missing clients and force sending.
|
|
223
|
-
* Array: User IDs specifying which user IDs are allowed to have
|
|
224
|
-
* missing clients
|
|
225
|
-
* `undefined`: Default to setting of `report_missing` in `NewOTRMessage`
|
|
226
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/postOtrMessage
|
|
227
|
-
*/
|
|
228
|
-
postOTRMessage(sendingClientId: string, conversationId: string, messageData?: NewOTRMessage<string>, ignoreMissing?: boolean | string[]): Promise<ClientMismatch>;
|
|
229
203
|
/**
|
|
230
204
|
* This endpoint ensures that the list of clients is correct and only sends the message if the list is correct.
|
|
231
205
|
* To override this, the endpoint accepts `client_mismatch_strategy` in the body. It can have these values:
|
|
@@ -248,7 +222,7 @@ export declare class ConversationAPI {
|
|
|
248
222
|
*
|
|
249
223
|
* @see https://nginz-https.anta.wire.link/api/swagger-ui/#/default/post_conversations__cnv_domain___cnv__proteus_messages
|
|
250
224
|
*/
|
|
251
|
-
|
|
225
|
+
postOTRMessage(conversationId: string, domain: string, messageData: ProtobufOTR.QualifiedNewOtrMessage): Promise<MessageSendingStatus>;
|
|
252
226
|
/**
|
|
253
227
|
* Post an encrypted message to a conversation.
|
|
254
228
|
* @param sendingClientId The sender's client ID
|
|
@@ -277,7 +251,6 @@ export declare class ConversationAPI {
|
|
|
277
251
|
* @see https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_mls_welcome
|
|
278
252
|
*/
|
|
279
253
|
postMlsCommitBundle(messageData: Uint8Array): Promise<PostMlsMessageResponse>;
|
|
280
|
-
postForClients(clientId: string, conversationId: string): Promise<void>;
|
|
281
254
|
/**
|
|
282
255
|
* Create a self-conversation.
|
|
283
256
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/createSelfConversation
|
|
@@ -318,12 +291,6 @@ export declare class ConversationAPI {
|
|
|
318
291
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/updateConversationReceiptMode
|
|
319
292
|
*/
|
|
320
293
|
putConversationReceiptMode(conversationId: string, receiptModeData: ConversationReceiptModeUpdateData): Promise<ConversationReceiptModeUpdateEvent>;
|
|
321
|
-
/**
|
|
322
|
-
* Add users to an existing conversation.
|
|
323
|
-
* @param conversationId The conversation ID to add the users to
|
|
324
|
-
* @param users List of users to add to a conversation
|
|
325
|
-
*/
|
|
326
|
-
private postMembersV0;
|
|
327
294
|
/**
|
|
328
295
|
* Add qualified members to an existing Proteus conversation.
|
|
329
296
|
* @param conversationId The conversation ID to add the users to
|
|
@@ -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,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EAEb,MAAM,EACN,MAAM,EACN,oBAAoB,EACpB,eAAe,
|
|
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,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EAEb,MAAM,EACN,MAAM,EACN,oBAAoB,EACpB,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,kCAAkC,EAClC,uBAAuB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAkC,UAAU,EAAC,MAAM,YAAY,CAAC;AACvE,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAOvC,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,4BAA4B,EAC5B,kCAAkC,EAClC,0BAA0B,EAC1B,iCAAiC,EACjC,iCAAiC,EACjC,sBAAsB,EACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAEvE,MAAM,MAAM,sBAAsB,GAAG;IACnC,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;AA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,IAAI,OAAO,CAAC,YAAY,CAAC;IAU9C;;;;;OAKG;IACU,UAAU,CAAC,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvG;;;;;OAKG;IACU,SAAS,CACpB,cAAc,EAAE,WAAW,EAC3B,UAAU,EAAE,4BAA4B,GACvC,OAAO,CAAC,6BAA6B,CAAC;IAUzC;;;;;OAKG;IACU,eAAe,CAC1B,cAAc,EAAE,MAAM,EACtB,oBAAoB,EAAE,0BAA0B,GAC/C,OAAO,CAAC,uBAAuB,CAAC;IAWnC;;;;;OAKG;IACU,2BAA2B,CACtC,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,kCAAkC,GACnD,OAAO,CAAC,mCAAmC,CAAC;IAW/C;;;;;OAKG;IACU,0BAA0B,CACrC,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,iCAAiC,GACjD,OAAO,CAAC,kCAAkC,CAAC;IAW9C;;;;OAIG;IACU,WAAW,CAAC,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;IA2B1E;;;;;;OAMG;IACU,cAAc,CACzB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,gBAAgB,EAAE,iCAAiC,GAClD,OAAO,CAAC,IAAI,CAAC;IAUhB;;;;;OAKG;IACU,uBAAuB,CAClC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC;CASjB"}
|
|
@@ -17,14 +17,10 @@
|
|
|
17
17
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
-
};
|
|
23
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
21
|
exports.ConversationAPI = void 0;
|
|
25
22
|
const ArrayUtil_1 = require("@wireapp/commons/lib/util/ArrayUtil");
|
|
26
23
|
const otr_1 = require("@wireapp/protocol-messaging/web/otr");
|
|
27
|
-
const axios_1 = __importDefault(require("axios"));
|
|
28
24
|
const __1 = require("..");
|
|
29
25
|
const http_1 = require("../../http");
|
|
30
26
|
const validation_1 = require("../../validation");
|
|
@@ -35,7 +31,7 @@ class ConversationAPI {
|
|
|
35
31
|
this.backendFeatures = backendFeatures;
|
|
36
32
|
}
|
|
37
33
|
generateBaseConversationUrl(conversationId, supportsQualifiedEndpoint = true) {
|
|
38
|
-
return
|
|
34
|
+
return supportsQualifiedEndpoint && conversationId.domain
|
|
39
35
|
? `${ConversationAPI.URL.CONVERSATIONS}/${conversationId.domain}/${conversationId.id}`
|
|
40
36
|
: `${ConversationAPI.URL.CONVERSATIONS}/${conversationId.id}`;
|
|
41
37
|
}
|
|
@@ -84,27 +80,6 @@ class ConversationAPI {
|
|
|
84
80
|
});
|
|
85
81
|
return response.data;
|
|
86
82
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Get all conversations.
|
|
89
|
-
* @deprecated - use getConversationList instead
|
|
90
|
-
*/
|
|
91
|
-
getAllConversations() {
|
|
92
|
-
let allConversations = [];
|
|
93
|
-
const getConversationChunks = async (conversationId) => {
|
|
94
|
-
const { conversations, has_more } = await this.getConversations(conversationId, ConversationAPI.MAX_CHUNK_SIZE);
|
|
95
|
-
if (conversations.length) {
|
|
96
|
-
allConversations = allConversations.concat(conversations);
|
|
97
|
-
}
|
|
98
|
-
if (has_more) {
|
|
99
|
-
const lastConversation = conversations.pop();
|
|
100
|
-
if (lastConversation) {
|
|
101
|
-
return getConversationChunks(lastConversation.id);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return allConversations;
|
|
105
|
-
};
|
|
106
|
-
return getConversationChunks();
|
|
107
|
-
}
|
|
108
83
|
/**
|
|
109
84
|
* Get a conversation code.
|
|
110
85
|
* @param conversationId ID of conversation to get the code for
|
|
@@ -131,25 +106,6 @@ class ConversationAPI {
|
|
|
131
106
|
return response.data;
|
|
132
107
|
}
|
|
133
108
|
async getConversation(conversationId) {
|
|
134
|
-
return this.backendFeatures.federationEndpoints && typeof conversationId !== 'string'
|
|
135
|
-
? this.getConversation_v2(conversationId)
|
|
136
|
-
: this.getConversation_v1(typeof conversationId === 'string' ? conversationId : conversationId.id);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Get a conversation by ID.
|
|
140
|
-
* @param conversationId The conversation ID
|
|
141
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/conversation
|
|
142
|
-
*/
|
|
143
|
-
async getConversation_v1(conversationId) {
|
|
144
|
-
const url = `${ConversationAPI.URL.CONVERSATIONS}/${conversationId}`;
|
|
145
|
-
const config = {
|
|
146
|
-
method: 'get',
|
|
147
|
-
url,
|
|
148
|
-
};
|
|
149
|
-
const response = await this.client.sendJSON(config);
|
|
150
|
-
return response.data;
|
|
151
|
-
}
|
|
152
|
-
async getConversation_v2(conversationId) {
|
|
153
109
|
const { id, domain } = conversationId;
|
|
154
110
|
const url = `${ConversationAPI.URL.CONVERSATIONS}/${domain}/${id}`;
|
|
155
111
|
const config = {
|
|
@@ -266,9 +222,6 @@ class ConversationAPI {
|
|
|
266
222
|
* Get all local & remote conversations from a federated backend.
|
|
267
223
|
*/
|
|
268
224
|
async getConversationList() {
|
|
269
|
-
if (!this.backendFeatures.federationEndpoints) {
|
|
270
|
-
return { found: await this.getAllConversations() };
|
|
271
|
-
}
|
|
272
225
|
const allConversationIds = await this.getQualifiedConversationIds();
|
|
273
226
|
const conversations = await this.getConversationsByQualifiedIds(allConversationIds);
|
|
274
227
|
return conversations;
|
|
@@ -547,46 +500,6 @@ class ConversationAPI {
|
|
|
547
500
|
const response = await this.client.sendJSON(config);
|
|
548
501
|
return response.data;
|
|
549
502
|
}
|
|
550
|
-
/**
|
|
551
|
-
* Post an encrypted message to a conversation.
|
|
552
|
-
* @param sendingClientId The sender's client ID
|
|
553
|
-
* @param conversationId The conversation ID
|
|
554
|
-
* @param messageData The message content
|
|
555
|
-
* @param ignoreMissing Whether to report missing clients or not:
|
|
556
|
-
* `false`: Report about all missing clients
|
|
557
|
-
* `true`: Ignore all missing clients and force sending.
|
|
558
|
-
* Array: User IDs specifying which user IDs are allowed to have
|
|
559
|
-
* missing clients
|
|
560
|
-
* `undefined`: Default to setting of `report_missing` in `NewOTRMessage`
|
|
561
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/postOtrMessage
|
|
562
|
-
*/
|
|
563
|
-
async postOTRMessage(sendingClientId, conversationId, messageData, ignoreMissing) {
|
|
564
|
-
if (!sendingClientId) {
|
|
565
|
-
throw new validation_1.ValidationError('Unable to send OTR message without client ID.');
|
|
566
|
-
}
|
|
567
|
-
messageData || (messageData = {
|
|
568
|
-
recipients: {},
|
|
569
|
-
sender: sendingClientId,
|
|
570
|
-
});
|
|
571
|
-
const config = {
|
|
572
|
-
data: messageData,
|
|
573
|
-
method: 'post',
|
|
574
|
-
url: `${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.OTR}/${ConversationAPI.URL.MESSAGES}`,
|
|
575
|
-
};
|
|
576
|
-
if (typeof ignoreMissing !== 'undefined') {
|
|
577
|
-
const ignore_missing = Array.isArray(ignoreMissing) ? ignoreMissing.join(',') : ignoreMissing;
|
|
578
|
-
config.params = { ignore_missing };
|
|
579
|
-
// `ignore_missing` takes precedence on the server so we can remove
|
|
580
|
-
// `report_missing` to save some bandwidth.
|
|
581
|
-
delete messageData.report_missing;
|
|
582
|
-
}
|
|
583
|
-
else if (typeof messageData.report_missing === 'undefined' || !messageData.report_missing.length) {
|
|
584
|
-
// both `ignore_missing` and `report_missing` are undefined
|
|
585
|
-
config.params = { ignore_missing: !!messageData.data };
|
|
586
|
-
}
|
|
587
|
-
const response = await this.client.sendJSON(config, true);
|
|
588
|
-
return response.data;
|
|
589
|
-
}
|
|
590
503
|
/**
|
|
591
504
|
* This endpoint ensures that the list of clients is correct and only sends the message if the list is correct.
|
|
592
505
|
* To override this, the endpoint accepts `client_mismatch_strategy` in the body. It can have these values:
|
|
@@ -609,7 +522,7 @@ class ConversationAPI {
|
|
|
609
522
|
*
|
|
610
523
|
* @see https://nginz-https.anta.wire.link/api/swagger-ui/#/default/post_conversations__cnv_domain___cnv__proteus_messages
|
|
611
524
|
*/
|
|
612
|
-
async
|
|
525
|
+
async postOTRMessage(conversationId, domain, messageData) {
|
|
613
526
|
const config = {
|
|
614
527
|
/*
|
|
615
528
|
* We need to slice the content of what protobuf has generated in order for Axios to send the correct data (see https://github.com/axios/axios/issues/4068)
|
|
@@ -692,19 +605,6 @@ class ConversationAPI {
|
|
|
692
605
|
const response = await this.client.sendProtocolBuffer(config, true);
|
|
693
606
|
return response.data;
|
|
694
607
|
}
|
|
695
|
-
async postForClients(clientId, conversationId) {
|
|
696
|
-
var _a;
|
|
697
|
-
try {
|
|
698
|
-
await this.postOTRMessage(clientId, conversationId);
|
|
699
|
-
throw new Error(`Expected backend to throw error.`);
|
|
700
|
-
}
|
|
701
|
-
catch (error) {
|
|
702
|
-
if (axios_1.default.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
703
|
-
return error.response.data;
|
|
704
|
-
}
|
|
705
|
-
throw error;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
608
|
/**
|
|
709
609
|
* Create a self-conversation.
|
|
710
610
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/createSelfConversation
|
|
@@ -791,43 +691,12 @@ class ConversationAPI {
|
|
|
791
691
|
const response = await this.client.sendJSON(config);
|
|
792
692
|
return response.data;
|
|
793
693
|
}
|
|
794
|
-
/**
|
|
795
|
-
* Add users to an existing conversation.
|
|
796
|
-
* @param conversationId The conversation ID to add the users to
|
|
797
|
-
* @param users List of users to add to a conversation
|
|
798
|
-
*/
|
|
799
|
-
async postMembersV0(conversationId, userIds) {
|
|
800
|
-
const config = {
|
|
801
|
-
data: {
|
|
802
|
-
conversation_role: __1.DefaultConversationRoleName.WIRE_MEMBER,
|
|
803
|
-
users: userIds,
|
|
804
|
-
},
|
|
805
|
-
method: 'post',
|
|
806
|
-
url: `${ConversationAPI.URL.CONVERSATIONS}/${conversationId}/${ConversationAPI.URL.MEMBERS}`,
|
|
807
|
-
};
|
|
808
|
-
try {
|
|
809
|
-
const response = await this.client.sendJSON(config);
|
|
810
|
-
return response.data;
|
|
811
|
-
}
|
|
812
|
-
catch (error) {
|
|
813
|
-
const backendError = error;
|
|
814
|
-
switch (backendError.label) {
|
|
815
|
-
case http_1.BackendErrorLabel.LEGAL_HOLD_MISSING_CONSENT: {
|
|
816
|
-
throw new ConversationError_1.ConversationLegalholdMissingConsentError(backendError.message);
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
throw error;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
694
|
/**
|
|
823
695
|
* Add qualified members to an existing Proteus conversation.
|
|
824
696
|
* @param conversationId The conversation ID to add the users to
|
|
825
697
|
* @param users List of users to add to a conversation
|
|
826
698
|
*/
|
|
827
699
|
async postMembers(conversationId, users) {
|
|
828
|
-
if (!this.backendFeatures.federationEndpoints) {
|
|
829
|
-
return this.postMembersV0(conversationId.id, users.map(user => user.id));
|
|
830
|
-
}
|
|
831
700
|
const config = {
|
|
832
701
|
data: {
|
|
833
702
|
conversation_role: __1.DefaultConversationRoleName.WIRE_MEMBER,
|
package/lib/demo/http401.js
CHANGED
|
@@ -22,7 +22,7 @@ const initClient_1 = require("./initClient");
|
|
|
22
22
|
(async () => {
|
|
23
23
|
const apiClient = await (0, initClient_1.initClient)();
|
|
24
24
|
apiClient['accessTokenStore'].accessToken.access_token = 'invalid';
|
|
25
|
-
await apiClient.api.conversation.
|
|
25
|
+
await apiClient.api.conversation.getConversations();
|
|
26
26
|
})().catch(error => {
|
|
27
27
|
console.error(error);
|
|
28
28
|
process.exit(1);
|
package/lib/user/UserAPI.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { BackendFeatures } from '../APIClient';
|
|
|
4
4
|
import { ClientPreKey, PreKeyBundle } from '../auth/';
|
|
5
5
|
import { VerificationActionType } from '../auth/VerificationActionType';
|
|
6
6
|
import { PublicClient, QualifiedPublicClients } from '../client/';
|
|
7
|
-
import {
|
|
7
|
+
import { QualifiedUserClients } from '../conversation/';
|
|
8
8
|
import { HttpClient, RequestCancelable } from '../http/';
|
|
9
|
-
import { Activate, ActivationResponse, CheckHandles, CompletePasswordReset, HandleInfo, LimitedQualifiedUserIdList, NewPasswordReset, QualifiedHandle, QualifiedId, SearchResult, SendActivationCode, User,
|
|
9
|
+
import { Activate, ActivationResponse, CheckHandles, CompletePasswordReset, HandleInfo, LimitedQualifiedUserIdList, NewPasswordReset, QualifiedHandle, QualifiedId, SearchResult, SendActivationCode, User, VerifyDelete } from '../user/';
|
|
10
10
|
export declare class UserAPI {
|
|
11
11
|
private readonly client;
|
|
12
12
|
private readonly backendFeatures;
|
|
@@ -65,22 +65,20 @@ export declare class UserAPI {
|
|
|
65
65
|
* @param clientId The client ID
|
|
66
66
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getUserClient
|
|
67
67
|
*/
|
|
68
|
-
getClient(userId:
|
|
68
|
+
getClient(userId: QualifiedId, clientId: string): Promise<PublicClient>;
|
|
69
69
|
/**
|
|
70
70
|
* Get a prekey for a specific client of a user.
|
|
71
71
|
* @param userId The user ID
|
|
72
72
|
* @param clientId The client ID
|
|
73
73
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getPrekey
|
|
74
74
|
*/
|
|
75
|
-
getClientPreKey(userId:
|
|
76
|
-
private getClientPreKey_v1;
|
|
77
|
-
private getClientPreKey_v2;
|
|
75
|
+
getClientPreKey(userId: QualifiedId, clientId: string): Promise<ClientPreKey>;
|
|
78
76
|
/**
|
|
79
77
|
* Get all of a user's clients.
|
|
80
78
|
* @param userId The user ID
|
|
81
79
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getUserClients
|
|
82
80
|
*/
|
|
83
|
-
getClients(userId:
|
|
81
|
+
getClients(userId: QualifiedId): Promise<PublicClient[]>;
|
|
84
82
|
/**
|
|
85
83
|
* @deprecated use getSearchContacts instead
|
|
86
84
|
* Get information on a user handle.
|
|
@@ -181,7 +179,6 @@ export declare class UserAPI {
|
|
|
181
179
|
*/
|
|
182
180
|
getUserByHandle(handle: QualifiedHandle): Promise<User>;
|
|
183
181
|
private postMultiPreKeyBundlesChunk;
|
|
184
|
-
private postMultiQualifiedPreKeyBundlesChunk;
|
|
185
182
|
/**
|
|
186
183
|
* List users.
|
|
187
184
|
* Note: The 'qualified_ids' and 'qualified_handles' parameters are mutually exclusive.
|
|
@@ -195,17 +192,11 @@ export declare class UserAPI {
|
|
|
195
192
|
* Get client infos from a list of users.
|
|
196
193
|
*/
|
|
197
194
|
postListClients(userIdList: LimitedQualifiedUserIdList): Promise<QualifiedPublicClients>;
|
|
198
|
-
/**
|
|
199
|
-
* Given a map of user IDs to client IDs return a prekey for each one.
|
|
200
|
-
* @param userClientMap A map of the user's clients
|
|
201
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getMultiPrekeyBundles
|
|
202
|
-
*/
|
|
203
|
-
postMultiPreKeyBundles(userClientMap: UserClients, limit?: number): Promise<UserPreKeyBundleMap>;
|
|
204
195
|
/**
|
|
205
196
|
* Given a map of qualified user IDs to client IDs return a prekey for each one.
|
|
206
197
|
* @param userClientMap A map of the qualified user's clients
|
|
207
198
|
*/
|
|
208
|
-
|
|
199
|
+
postMultiPreKeyBundles(userClientMap: QualifiedUserClients, limit?: number): Promise<QualifiedUserPreKeyBundleMap>;
|
|
209
200
|
/**
|
|
210
201
|
* Initiate or complete a password reset.
|
|
211
202
|
* @param resetData The data needed to initiate or complete the reset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAPI.d.ts","sourceRoot":"","sources":["../../src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AE,eAAe,EAAE,CAAA;KAAC,GAC7E,OAAO,CAAC,IAAI,EAAE,CAAC;IAWlB;;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,4BAA4B,CAAC;IAiCxC;;;;;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
|
@@ -91,10 +91,7 @@ class UserAPI {
|
|
|
91
91
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getUserClient
|
|
92
92
|
*/
|
|
93
93
|
async getClient(userId, clientId) {
|
|
94
|
-
const
|
|
95
|
-
const url = this.backendFeatures.federationEndpoints && typeof userId !== 'string'
|
|
96
|
-
? `${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.CLIENTS}/${clientId}`
|
|
97
|
-
: `${UserAPI.URL.USERS}/${strUserId}/${UserAPI.URL.CLIENTS}/${clientId}`;
|
|
94
|
+
const url = `${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.CLIENTS}/${clientId}`;
|
|
98
95
|
const config = {
|
|
99
96
|
method: 'get',
|
|
100
97
|
url,
|
|
@@ -109,22 +106,6 @@ class UserAPI {
|
|
|
109
106
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getPrekey
|
|
110
107
|
*/
|
|
111
108
|
async getClientPreKey(userId, clientId) {
|
|
112
|
-
if (this.backendFeatures.federationEndpoints && typeof userId !== 'string') {
|
|
113
|
-
return this.getClientPreKey_v2(userId, clientId);
|
|
114
|
-
}
|
|
115
|
-
const strUserId = typeof userId === 'string' ? userId : userId.id;
|
|
116
|
-
return this.getClientPreKey_v1(strUserId, clientId);
|
|
117
|
-
}
|
|
118
|
-
async getClientPreKey_v1(userId, clientId) {
|
|
119
|
-
const url = `${UserAPI.URL.USERS}/${userId}/${UserAPI.URL.PRE_KEYS}/${clientId}`;
|
|
120
|
-
const config = {
|
|
121
|
-
method: 'get',
|
|
122
|
-
url,
|
|
123
|
-
};
|
|
124
|
-
const response = await this.client.sendJSON(config);
|
|
125
|
-
return response.data;
|
|
126
|
-
}
|
|
127
|
-
async getClientPreKey_v2(userId, clientId) {
|
|
128
109
|
const { id, domain } = userId;
|
|
129
110
|
const url = `${UserAPI.URL.USERS}/${domain}/${id}/${UserAPI.URL.PRE_KEYS}/${clientId}`;
|
|
130
111
|
const config = {
|
|
@@ -140,10 +121,7 @@ class UserAPI {
|
|
|
140
121
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getUserClients
|
|
141
122
|
*/
|
|
142
123
|
async getClients(userId) {
|
|
143
|
-
const
|
|
144
|
-
const url = this.backendFeatures.federationEndpoints && typeof userId !== 'string'
|
|
145
|
-
? `${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.CLIENTS}`
|
|
146
|
-
: `${UserAPI.URL.USERS}/${strUserId}/${UserAPI.URL.CLIENTS}`;
|
|
124
|
+
const url = `${UserAPI.URL.USERS}/${userId.domain}/${userId.id}/${UserAPI.URL.CLIENTS}`;
|
|
147
125
|
const config = {
|
|
148
126
|
method: 'get',
|
|
149
127
|
url,
|
|
@@ -411,15 +389,6 @@ class UserAPI {
|
|
|
411
389
|
return response.data;
|
|
412
390
|
}
|
|
413
391
|
async postMultiPreKeyBundlesChunk(userClientMap) {
|
|
414
|
-
const config = {
|
|
415
|
-
data: userClientMap,
|
|
416
|
-
method: 'post',
|
|
417
|
-
url: `${UserAPI.URL.USERS}/${UserAPI.URL.PRE_KEYS}`,
|
|
418
|
-
};
|
|
419
|
-
const response = await this.client.sendJSON(config, true);
|
|
420
|
-
return response.data;
|
|
421
|
-
}
|
|
422
|
-
async postMultiQualifiedPreKeyBundlesChunk(userClientMap) {
|
|
423
392
|
const config = {
|
|
424
393
|
data: userClientMap,
|
|
425
394
|
method: 'post',
|
|
@@ -455,30 +424,11 @@ class UserAPI {
|
|
|
455
424
|
const response = await this.client.sendJSON(config);
|
|
456
425
|
return response.data;
|
|
457
426
|
}
|
|
458
|
-
/**
|
|
459
|
-
* Given a map of user IDs to client IDs return a prekey for each one.
|
|
460
|
-
* @param userClientMap A map of the user's clients
|
|
461
|
-
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/users/getMultiPrekeyBundles
|
|
462
|
-
*/
|
|
463
|
-
async postMultiPreKeyBundles(userClientMap, limit = UserAPI.DEFAULT_USERS_PREKEY_BUNDLE_CHUNK_SIZE) {
|
|
464
|
-
const userIdChunks = commons_1.ArrayUtil.chunk(Object.keys(userClientMap), limit);
|
|
465
|
-
const chunksPromises = userIdChunks.map(userIdChunk => {
|
|
466
|
-
const rebuiltMap = userIdChunk.reduce((chunkedUserClientMap, userId) => {
|
|
467
|
-
chunkedUserClientMap[userId] = userClientMap[userId];
|
|
468
|
-
return chunkedUserClientMap;
|
|
469
|
-
}, {});
|
|
470
|
-
return this.postMultiPreKeyBundlesChunk(rebuiltMap);
|
|
471
|
-
});
|
|
472
|
-
const userPreKeyBundleMapChunks = await Promise.all(chunksPromises);
|
|
473
|
-
return userPreKeyBundleMapChunks.reduce((userPreKeyBundleMap, userPreKeyBundleMapChunk) => {
|
|
474
|
-
return Object.assign(Object.assign({}, userPreKeyBundleMap), userPreKeyBundleMapChunk);
|
|
475
|
-
}, {});
|
|
476
|
-
}
|
|
477
427
|
/**
|
|
478
428
|
* Given a map of qualified user IDs to client IDs return a prekey for each one.
|
|
479
429
|
* @param userClientMap A map of the qualified user's clients
|
|
480
430
|
*/
|
|
481
|
-
async
|
|
431
|
+
async postMultiPreKeyBundles(userClientMap, limit = UserAPI.DEFAULT_USERS_PREKEY_BUNDLE_CHUNK_SIZE) {
|
|
482
432
|
const flattenUsers = Object.entries(userClientMap).reduce((users, [domain, domainUsersClients]) => {
|
|
483
433
|
const domainUsers = Object.entries(domainUsersClients).map(([userId, clients]) => ({
|
|
484
434
|
userId: { id: userId, domain },
|
|
@@ -492,7 +442,7 @@ class UserAPI {
|
|
|
492
442
|
return Object.assign(Object.assign({}, chunkedMap), { [userId.domain]: Object.assign(Object.assign({}, chunkedMap[userId.domain]), { [userId.id]: clients }) });
|
|
493
443
|
}, {});
|
|
494
444
|
})
|
|
495
|
-
.map(chunkedMap => this.
|
|
445
|
+
.map(chunkedMap => this.postMultiPreKeyBundlesChunk(chunkedMap));
|
|
496
446
|
const userPreKeyBundleMapChunks = await Promise.all(chunksPromises);
|
|
497
447
|
return userPreKeyBundleMapChunks.reduce((userPreKeyBundleMap, userPreKeyBundleMapChunk) => {
|
|
498
448
|
Object.entries(userPreKeyBundleMapChunk).forEach(([domain, userClientMap]) => {
|
|
@@ -4,7 +4,5 @@ export interface UserPreKeyBundleMap {
|
|
|
4
4
|
[clientId: string]: PreKey | null;
|
|
5
5
|
};
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
[domain: string]: UserPreKeyBundleMap;
|
|
9
|
-
}
|
|
7
|
+
export type QualifiedUserPreKeyBundleMap = Record<string, UserPreKeyBundleMap>;
|
|
10
8
|
//# sourceMappingURL=UserPreKeyBundleMap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserPreKeyBundleMap.d.ts","sourceRoot":"","sources":["../../src/user/UserPreKeyBundleMap.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAE/B,MAAM,WAAW,mBAAmB;IAClC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;KACnC,CAAC;CACH;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"UserPreKeyBundleMap.d.ts","sourceRoot":"","sources":["../../src/user/UserPreKeyBundleMap.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAE/B,MAAM,WAAW,mBAAmB;IAClC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;KACnC,CAAC;CACH;AAED,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@wireapp/commons": "^5.0.4",
|
|
17
17
|
"@wireapp/priority-queue": "^2.0.3",
|
|
18
18
|
"@wireapp/protocol-messaging": "1.44.0",
|
|
19
|
-
"axios": "1.3.
|
|
19
|
+
"axios": "1.3.4",
|
|
20
20
|
"axios-retry": "3.4.0",
|
|
21
21
|
"http-status-codes": "2.2.0",
|
|
22
22
|
"logdown": "3.3.1",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/ws": "8.5.3",
|
|
37
37
|
"@wireapp/store-engine": "^5.0.3",
|
|
38
38
|
"@wireapp/store-engine-fs": "^3.0.4",
|
|
39
|
-
"browser-sync": "2.27.
|
|
39
|
+
"browser-sync": "2.27.12",
|
|
40
40
|
"concurrently": "7.6.0",
|
|
41
41
|
"cross-env": "7.0.3",
|
|
42
42
|
"dotenv": "16.0.3",
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"watch": "webpack serve --config webpack.browser.js",
|
|
64
64
|
"prepare": "yarn dist"
|
|
65
65
|
},
|
|
66
|
-
"version": "
|
|
67
|
-
"gitHead": "
|
|
66
|
+
"version": "23.0.0",
|
|
67
|
+
"gitHead": "5e86fc700f348bd1f6d477b5eae88bb6d8bb5fb0"
|
|
68
68
|
}
|