@wireapp/api-client 27.66.0 → 27.67.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/APIClient.d.ts +17 -10
- package/lib/APIClient.d.ts.map +1 -1
- package/lib/APIClient.js +37 -27
- package/lib/Config.d.ts +1 -0
- package/lib/Config.d.ts.map +1 -1
- package/lib/Config.js +2 -0
- package/lib/cells/CellsAPI.d.ts +1 -0
- package/lib/cells/CellsAPI.d.ts.map +1 -1
- package/lib/cells/CellsAPI.js +5 -2
- package/lib/client/RegisteredClient.d.ts +2 -1
- package/lib/client/RegisteredClient.d.ts.map +1 -1
- package/lib/notification/ConsumableNotification.d.ts +202 -0
- package/lib/notification/ConsumableNotification.d.ts.map +1 -0
- package/lib/notification/ConsumableNotification.js +57 -0
- package/lib/notification/NotificationAPI/NotificationAPI.d.ts +2 -2
- package/lib/notification/NotificationAPI/NotificationAPI.d.ts.map +1 -1
- package/lib/notification/NotificationAPI/NotificationAPI.js +4 -4
- package/lib/tcp/AcknowledgeEvent.types.d.ts +14 -0
- package/lib/tcp/AcknowledgeEvent.types.d.ts.map +1 -0
- package/lib/tcp/AcknowledgeEvent.types.js +27 -0
- package/lib/tcp/ReconnectingWebsocket.d.ts +1 -13
- package/lib/tcp/ReconnectingWebsocket.d.ts.map +1 -1
- package/lib/tcp/ReconnectingWebsocket.js +5 -49
- package/lib/tcp/WebSocketClient.d.ts +8 -3
- package/lib/tcp/WebSocketClient.d.ts.map +1 -1
- package/lib/tcp/WebSocketClient.js +41 -2
- package/package.json +2 -2
package/lib/APIClient.d.ts
CHANGED
|
@@ -113,18 +113,25 @@ export declare class APIClient extends EventEmitter {
|
|
|
113
113
|
*/
|
|
114
114
|
private computeBackendFeatures;
|
|
115
115
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* - useVersion(0, 1, true) > version 1 is used
|
|
125
|
-
* @return The highest version that is both supported by client and backend
|
|
116
|
+
* Sets the API client to use the highest supported version within a given range,
|
|
117
|
+
* with a hard minimum of version 8 enforced.
|
|
118
|
+
*
|
|
119
|
+
* @param min - Minimum acceptable version (must be ≥ 8)
|
|
120
|
+
* @param max - Maximum acceptable version
|
|
121
|
+
* @param allowDev - If true, allows using development versions from the backend
|
|
122
|
+
* @returns Backend feature configuration for the selected version
|
|
123
|
+
* @throws Error if no compatible version is found
|
|
126
124
|
*/
|
|
127
125
|
useVersion(min: number, max: number, allowDev?: boolean): Promise<BackendFeatures>;
|
|
126
|
+
/**
|
|
127
|
+
* Returns the highest version from the list that falls within the specified range.
|
|
128
|
+
*
|
|
129
|
+
* @param versions - List of available versions
|
|
130
|
+
* @param min - Minimum required version
|
|
131
|
+
* @param max - Maximum allowed version
|
|
132
|
+
* @returns The highest version in the allowed range, or undefined if none are compatible
|
|
133
|
+
*/
|
|
134
|
+
private findHighestCompatibleVersion;
|
|
128
135
|
init(clientType?: ClientType, cookie?: Cookie): Promise<Context>;
|
|
129
136
|
login(loginData: LoginData): Promise<Context>;
|
|
130
137
|
loginWithToken(accessTokenString: string, clientType?: ClientType): Promise<Context>;
|
package/lib/APIClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIClient.d.ts","sourceRoot":"","sources":["../src/APIClient.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAIpC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,eAAe,EAEf,OAAO,EACP,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,SAAS,EAET,YAAY,EACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1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GAAG,SAAS,CAExC;IAED,IAAW,MAAM,IAAI,MAAM,GAAG,SAAS,CAEtC;IAED,IAAW,MAAM,IAAI,MAAM,GAAG,SAAS,CAEtC;IAED,8DAA8D;IAC9D,IAAW,eAAe,IAAI,MAAM,CAKnC;IAED,gEAAgE;IAChE,IAAW,iBAAiB,IAAI,MAAM,CAKrC;IAED;;OAEG;IACU,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAc7C"}
|
package/lib/APIClient.js
CHANGED
|
@@ -29,6 +29,7 @@ const parseAccessToken_1 = require("./auth/parseAccessToken");
|
|
|
29
29
|
const broadcast_1 = require("./broadcast/");
|
|
30
30
|
const CellsAPI_1 = require("./cells/CellsAPI");
|
|
31
31
|
const client_1 = require("./client/");
|
|
32
|
+
const Config_1 = require("./Config");
|
|
32
33
|
const connection_1 = require("./connection/");
|
|
33
34
|
const conversation_1 = require("./conversation/");
|
|
34
35
|
const env_1 = require("./env/");
|
|
@@ -96,7 +97,7 @@ class APIClient extends events_1.EventEmitter {
|
|
|
96
97
|
http: httpClient,
|
|
97
98
|
ws: webSocket,
|
|
98
99
|
};
|
|
99
|
-
this.backendFeatures = this.computeBackendFeatures(
|
|
100
|
+
this.backendFeatures = this.computeBackendFeatures(Config_1.MINIMUM_API_VERSION);
|
|
100
101
|
this.api = this.configureApis(this.backendFeatures);
|
|
101
102
|
}
|
|
102
103
|
configureApis(backendFeatures) {
|
|
@@ -159,38 +160,47 @@ class APIClient extends events_1.EventEmitter {
|
|
|
159
160
|
};
|
|
160
161
|
}
|
|
161
162
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* @param
|
|
166
|
-
* @param
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* - useVersion(0, 1, true) > version 1 is used
|
|
171
|
-
* @return The highest version that is both supported by client and backend
|
|
163
|
+
* Sets the API client to use the highest supported version within a given range,
|
|
164
|
+
* with a hard minimum of version 8 enforced.
|
|
165
|
+
*
|
|
166
|
+
* @param min - Minimum acceptable version (must be ≥ 8)
|
|
167
|
+
* @param max - Maximum acceptable version
|
|
168
|
+
* @param allowDev - If true, allows using development versions from the backend
|
|
169
|
+
* @returns Backend feature configuration for the selected version
|
|
170
|
+
* @throws Error if no compatible version is found
|
|
172
171
|
*/
|
|
173
|
-
async useVersion(min, max, allowDev) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
backendVersions = (await this.transport.http.sendRequest({ url: '/api-version' })).data;
|
|
172
|
+
async useVersion(min, max, allowDev = false) {
|
|
173
|
+
if (min < Config_1.MINIMUM_API_VERSION) {
|
|
174
|
+
throw new Error(`Minimum supported API version is ${Config_1.MINIMUM_API_VERSION}. Received: ${min}`);
|
|
177
175
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const supportedStr = backendVersions.supported.join(', ');
|
|
187
|
-
throw new Error(`Backend does not support requested versions [${min}-${max}] (supported versions ${supportedStr})`);
|
|
176
|
+
const response = await this.transport.http.sendRequest({
|
|
177
|
+
url: '/api-version',
|
|
178
|
+
});
|
|
179
|
+
const { supported, development = [], domain, federation } = response.data;
|
|
180
|
+
const availableVersions = allowDev ? [...supported, ...development] : supported;
|
|
181
|
+
const compatibleVersion = this.findHighestCompatibleVersion(availableVersions, min, max);
|
|
182
|
+
if (compatibleVersion === undefined) {
|
|
183
|
+
throw new Error(`No compatible API version in range [${min}-${max}]. ` + `Backend supports: [${supported.join(', ')}]`);
|
|
188
184
|
}
|
|
189
|
-
this.backendFeatures = this.computeBackendFeatures(
|
|
190
|
-
this.transport.http.useVersion(
|
|
185
|
+
this.backendFeatures = this.computeBackendFeatures(compatibleVersion, { federation, supported, development, domain });
|
|
186
|
+
this.transport.http.useVersion(compatibleVersion);
|
|
187
|
+
this.transport.ws.useVersion(compatibleVersion);
|
|
191
188
|
this.api = this.configureApis(this.backendFeatures);
|
|
192
189
|
return this.backendFeatures;
|
|
193
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns the highest version from the list that falls within the specified range.
|
|
193
|
+
*
|
|
194
|
+
* @param versions - List of available versions
|
|
195
|
+
* @param min - Minimum required version
|
|
196
|
+
* @param max - Maximum allowed version
|
|
197
|
+
* @returns The highest version in the allowed range, or undefined if none are compatible
|
|
198
|
+
*/
|
|
199
|
+
findHighestCompatibleVersion(versions, min, max) {
|
|
200
|
+
const inRangeVersions = versions.filter(version => version >= min && version <= max);
|
|
201
|
+
const [highestVersion] = inRangeVersions.sort((a, b) => b - a);
|
|
202
|
+
return highestVersion;
|
|
203
|
+
}
|
|
194
204
|
async init(clientType = client_1.ClientType.NONE, cookie) {
|
|
195
205
|
CookieStore_1.CookieStore.setCookie(cookie);
|
|
196
206
|
const initialAccessToken = await this.transport.http.refreshAccessToken();
|
package/lib/Config.d.ts
CHANGED
package/lib/Config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAC;AAEnC,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC"}
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAC;AAEnC,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,eAAO,MAAM,mBAAmB,IAAI,CAAC"}
|
package/lib/Config.js
CHANGED
package/lib/cells/CellsAPI.d.ts
CHANGED
|
@@ -1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M,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAe3F,iBAAiB,CAAC,EAAC,IAAI,EAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAUjE,UAAU,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAUlD,WAAW,CAAC,EAAC,IAAI,EAAE,IAAI,EAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBlF,OAAO,CAAC,mBAAmB;CAG5B"}
|
package/lib/cells/CellsAPI.js
CHANGED
|
@@ -199,7 +199,7 @@ class CellsAPI {
|
|
|
199
199
|
Status: {
|
|
200
200
|
Deleted: deleted ? 'Only' : 'Not',
|
|
201
201
|
},
|
|
202
|
-
Metadata: tags?.length ? [{ Namespace: USER_META_TAGS_NAMESPACE, Term:
|
|
202
|
+
Metadata: tags?.length ? [{ Namespace: USER_META_TAGS_NAMESPACE, Term: this.transformTagsToJson(tags) }] : [],
|
|
203
203
|
},
|
|
204
204
|
Flags: ['WithPreSignedURLs'],
|
|
205
205
|
Limit: `${limit}`,
|
|
@@ -282,11 +282,14 @@ class CellsAPI {
|
|
|
282
282
|
MetaUpdates: [
|
|
283
283
|
{
|
|
284
284
|
Operation: tags.length > 0 ? 'PUT' : 'DELETE',
|
|
285
|
-
UserMeta: { Namespace: USER_META_TAGS_NAMESPACE, JsonValue:
|
|
285
|
+
UserMeta: { Namespace: USER_META_TAGS_NAMESPACE, JsonValue: this.transformTagsToJson(tags) },
|
|
286
286
|
},
|
|
287
287
|
],
|
|
288
288
|
});
|
|
289
289
|
return result.data;
|
|
290
290
|
}
|
|
291
|
+
transformTagsToJson(tags) {
|
|
292
|
+
return JSON.stringify(tags.join(','));
|
|
293
|
+
}
|
|
291
294
|
}
|
|
292
295
|
exports.CellsAPI = CellsAPI;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientType, Location, MLSPublicKeyRecord, PublicClient } from './';
|
|
1
|
+
import { ClientCapability, ClientType, Location, MLSPublicKeyRecord, PublicClient } from './';
|
|
2
2
|
export interface AddedClient extends PublicClient {
|
|
3
3
|
/** The IP address from which the client was registered */
|
|
4
4
|
address?: string;
|
|
@@ -13,6 +13,7 @@ export interface AddedClient extends PublicClient {
|
|
|
13
13
|
}
|
|
14
14
|
export interface RegisteredClient extends AddedClient {
|
|
15
15
|
/** The cookie label */
|
|
16
|
+
capabilities: ClientCapability[];
|
|
16
17
|
cookie: string;
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=RegisteredClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredClient.d.ts","sourceRoot":"","sources":["../../src/client/RegisteredClient.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,kBAAkB,EAAE,YAAY,EAAC,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"RegisteredClient.d.ts","sourceRoot":"","sources":["../../src/client/RegisteredClient.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,kBAAkB,EAAE,YAAY,EAAC,MAAM,IAAI,CAAC;AAE5F,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC;IAClD,eAAe,EAAE,kBAAkB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,uBAAuB;IACvB,YAAY,EAAE,gBAAgB,EAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BackendEvent } from '../event';
|
|
3
|
+
/**
|
|
4
|
+
* Enum of all possible consumable notification types received via WebSocket.
|
|
5
|
+
* Now fully aligned with backend naming conventions.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ConsumableEvent {
|
|
8
|
+
EVENT = "event",
|
|
9
|
+
MISSED = "notifications_missed",
|
|
10
|
+
MESSAGE_COUNT = "message_count"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Notification type received when the client has missed messages due to being offline too long.
|
|
14
|
+
* Requires a full re-sync before consuming more notifications.
|
|
15
|
+
* TODO: when BackendEvent is typed in zod use:
|
|
16
|
+
* export type ConsumableNotificationMissed = z.infer<typeof ConsumableNotificationMissedSchema>;
|
|
17
|
+
*/
|
|
18
|
+
export interface ConsumableNotificationMissed {
|
|
19
|
+
type: ConsumableEvent.MISSED;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Notification type for actual backend events, contains one or more event payloads.
|
|
23
|
+
* Includes a delivery tag for acknowledgment.
|
|
24
|
+
* TODO: when BackendEvent is typed in zod use:
|
|
25
|
+
* export type ConsumableNotificationEvent = z.infer<typeof ConsumableNotificationEventSchema>;
|
|
26
|
+
*/
|
|
27
|
+
export interface ConsumableNotificationEvent {
|
|
28
|
+
type: ConsumableEvent.EVENT;
|
|
29
|
+
data: {
|
|
30
|
+
delivery_tag: number;
|
|
31
|
+
event: {
|
|
32
|
+
id: string;
|
|
33
|
+
payload: BackendEvent[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Notification sent after connecting to indicate current number of messages queued.
|
|
39
|
+
* TODO: when BackendEvent is typed in zod use:
|
|
40
|
+
* export type ConsumableNotificationMessageCount = z.infer<typeof ConsumableNotificationMessageCountSchema>;
|
|
41
|
+
*/
|
|
42
|
+
export interface ConsumableNotificationMessageCount {
|
|
43
|
+
type: ConsumableEvent.MESSAGE_COUNT;
|
|
44
|
+
data: {
|
|
45
|
+
count: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Union of all valid notification types supported by the WebSocket backend.
|
|
50
|
+
* TODO: when BackendEvent is typed in zod use:
|
|
51
|
+
* export const ConsumableNotificationSchema = z.discriminatedUnion('type', [
|
|
52
|
+
ConsumableNotificationMissedSchema,
|
|
53
|
+
ConsumableNotificationEventSchema,
|
|
54
|
+
ConsumableNotificationMessageCountSchema,
|
|
55
|
+
]);
|
|
56
|
+
*/
|
|
57
|
+
export type ConsumableNotification = ConsumableNotificationMissed | ConsumableNotificationEvent | ConsumableNotificationMessageCount;
|
|
58
|
+
export declare const ConsumableNotificationMissedSchema: z.ZodObject<{
|
|
59
|
+
type: z.ZodLiteral<ConsumableEvent.MISSED>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
type: ConsumableEvent.MISSED;
|
|
62
|
+
}, {
|
|
63
|
+
type: ConsumableEvent.MISSED;
|
|
64
|
+
}>;
|
|
65
|
+
export declare const ConsumableNotificationEventSchema: z.ZodObject<{
|
|
66
|
+
type: z.ZodLiteral<ConsumableEvent.EVENT>;
|
|
67
|
+
data: z.ZodObject<{
|
|
68
|
+
delivery_tag: z.ZodNumber;
|
|
69
|
+
event: z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
payload: z.ZodArray<z.ZodUnknown, "many">;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
id: string;
|
|
74
|
+
payload: unknown[];
|
|
75
|
+
}, {
|
|
76
|
+
id: string;
|
|
77
|
+
payload: unknown[];
|
|
78
|
+
}>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
event: {
|
|
81
|
+
id: string;
|
|
82
|
+
payload: unknown[];
|
|
83
|
+
};
|
|
84
|
+
delivery_tag: number;
|
|
85
|
+
}, {
|
|
86
|
+
event: {
|
|
87
|
+
id: string;
|
|
88
|
+
payload: unknown[];
|
|
89
|
+
};
|
|
90
|
+
delivery_tag: number;
|
|
91
|
+
}>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
type: ConsumableEvent.EVENT;
|
|
94
|
+
data: {
|
|
95
|
+
event: {
|
|
96
|
+
id: string;
|
|
97
|
+
payload: unknown[];
|
|
98
|
+
};
|
|
99
|
+
delivery_tag: number;
|
|
100
|
+
};
|
|
101
|
+
}, {
|
|
102
|
+
type: ConsumableEvent.EVENT;
|
|
103
|
+
data: {
|
|
104
|
+
event: {
|
|
105
|
+
id: string;
|
|
106
|
+
payload: unknown[];
|
|
107
|
+
};
|
|
108
|
+
delivery_tag: number;
|
|
109
|
+
};
|
|
110
|
+
}>;
|
|
111
|
+
export declare const ConsumableNotificationMessageCountSchema: z.ZodObject<{
|
|
112
|
+
type: z.ZodLiteral<ConsumableEvent.MESSAGE_COUNT>;
|
|
113
|
+
data: z.ZodObject<{
|
|
114
|
+
count: z.ZodNumber;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
count: number;
|
|
117
|
+
}, {
|
|
118
|
+
count: number;
|
|
119
|
+
}>;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
type: ConsumableEvent.MESSAGE_COUNT;
|
|
122
|
+
data: {
|
|
123
|
+
count: number;
|
|
124
|
+
};
|
|
125
|
+
}, {
|
|
126
|
+
type: ConsumableEvent.MESSAGE_COUNT;
|
|
127
|
+
data: {
|
|
128
|
+
count: number;
|
|
129
|
+
};
|
|
130
|
+
}>;
|
|
131
|
+
export declare const ConsumableNotificationSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
132
|
+
type: z.ZodLiteral<ConsumableEvent.MISSED>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
type: ConsumableEvent.MISSED;
|
|
135
|
+
}, {
|
|
136
|
+
type: ConsumableEvent.MISSED;
|
|
137
|
+
}>, z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<ConsumableEvent.EVENT>;
|
|
139
|
+
data: z.ZodObject<{
|
|
140
|
+
delivery_tag: z.ZodNumber;
|
|
141
|
+
event: z.ZodObject<{
|
|
142
|
+
id: z.ZodString;
|
|
143
|
+
payload: z.ZodArray<z.ZodUnknown, "many">;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
id: string;
|
|
146
|
+
payload: unknown[];
|
|
147
|
+
}, {
|
|
148
|
+
id: string;
|
|
149
|
+
payload: unknown[];
|
|
150
|
+
}>;
|
|
151
|
+
}, "strip", z.ZodTypeAny, {
|
|
152
|
+
event: {
|
|
153
|
+
id: string;
|
|
154
|
+
payload: unknown[];
|
|
155
|
+
};
|
|
156
|
+
delivery_tag: number;
|
|
157
|
+
}, {
|
|
158
|
+
event: {
|
|
159
|
+
id: string;
|
|
160
|
+
payload: unknown[];
|
|
161
|
+
};
|
|
162
|
+
delivery_tag: number;
|
|
163
|
+
}>;
|
|
164
|
+
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
type: ConsumableEvent.EVENT;
|
|
166
|
+
data: {
|
|
167
|
+
event: {
|
|
168
|
+
id: string;
|
|
169
|
+
payload: unknown[];
|
|
170
|
+
};
|
|
171
|
+
delivery_tag: number;
|
|
172
|
+
};
|
|
173
|
+
}, {
|
|
174
|
+
type: ConsumableEvent.EVENT;
|
|
175
|
+
data: {
|
|
176
|
+
event: {
|
|
177
|
+
id: string;
|
|
178
|
+
payload: unknown[];
|
|
179
|
+
};
|
|
180
|
+
delivery_tag: number;
|
|
181
|
+
};
|
|
182
|
+
}>, z.ZodObject<{
|
|
183
|
+
type: z.ZodLiteral<ConsumableEvent.MESSAGE_COUNT>;
|
|
184
|
+
data: z.ZodObject<{
|
|
185
|
+
count: z.ZodNumber;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
count: number;
|
|
188
|
+
}, {
|
|
189
|
+
count: number;
|
|
190
|
+
}>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
type: ConsumableEvent.MESSAGE_COUNT;
|
|
193
|
+
data: {
|
|
194
|
+
count: number;
|
|
195
|
+
};
|
|
196
|
+
}, {
|
|
197
|
+
type: ConsumableEvent.MESSAGE_COUNT;
|
|
198
|
+
data: {
|
|
199
|
+
count: number;
|
|
200
|
+
};
|
|
201
|
+
}>]>;
|
|
202
|
+
//# sourceMappingURL=ConsumableNotification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsumableNotification.d.ts","sourceRoot":"","sources":["../../src/notification/ConsumableNotification.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAEtC;;;GAGG;AACH,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,MAAM,yBAAyB;IAC/B,aAAa,kBAAkB;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC;IAC5B,IAAI,EAAE;QACJ,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE;YACL,EAAE,EAAE,MAAM,CAAC;YACX,OAAO,EAAE,YAAY,EAAE,CAAC;SACzB,CAAC;KACH,CAAC;CACH;AAED;;;;GAIG;AACH,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,eAAe,CAAC,aAAa,CAAC;IACpC,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAC9B,4BAA4B,GAC5B,2BAA2B,GAC3B,kCAAkC,CAAC;AAOvC,eAAO,MAAM,kCAAkC;;;;;;EAE7C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM5C,CAAC;AAEH,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;;;;;;;EAKnD,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIvC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2025 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.ConsumableNotificationSchema = exports.ConsumableNotificationMessageCountSchema = exports.ConsumableNotificationEventSchema = exports.ConsumableNotificationMissedSchema = exports.ConsumableEvent = void 0;
|
|
22
|
+
const zod_1 = require("zod");
|
|
23
|
+
/**
|
|
24
|
+
* Enum of all possible consumable notification types received via WebSocket.
|
|
25
|
+
* Now fully aligned with backend naming conventions.
|
|
26
|
+
*/
|
|
27
|
+
var ConsumableEvent;
|
|
28
|
+
(function (ConsumableEvent) {
|
|
29
|
+
ConsumableEvent["EVENT"] = "event";
|
|
30
|
+
ConsumableEvent["MISSED"] = "notifications_missed";
|
|
31
|
+
ConsumableEvent["MESSAGE_COUNT"] = "message_count";
|
|
32
|
+
})(ConsumableEvent || (exports.ConsumableEvent = ConsumableEvent = {}));
|
|
33
|
+
const BackendEventSchema = zod_1.z.object({
|
|
34
|
+
id: zod_1.z.string(),
|
|
35
|
+
payload: zod_1.z.array(zod_1.z.unknown()), // TODO: Replace `z.any()` with BackendEvent schema when available
|
|
36
|
+
});
|
|
37
|
+
exports.ConsumableNotificationMissedSchema = zod_1.z.object({
|
|
38
|
+
type: zod_1.z.literal(ConsumableEvent.MISSED),
|
|
39
|
+
});
|
|
40
|
+
exports.ConsumableNotificationEventSchema = zod_1.z.object({
|
|
41
|
+
type: zod_1.z.literal(ConsumableEvent.EVENT),
|
|
42
|
+
data: zod_1.z.object({
|
|
43
|
+
delivery_tag: zod_1.z.number(),
|
|
44
|
+
event: BackendEventSchema,
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
exports.ConsumableNotificationMessageCountSchema = zod_1.z.object({
|
|
48
|
+
type: zod_1.z.literal(ConsumableEvent.MESSAGE_COUNT),
|
|
49
|
+
data: zod_1.z.object({
|
|
50
|
+
count: zod_1.z.number(),
|
|
51
|
+
}),
|
|
52
|
+
});
|
|
53
|
+
exports.ConsumableNotificationSchema = zod_1.z.discriminatedUnion('type', [
|
|
54
|
+
exports.ConsumableNotificationMissedSchema,
|
|
55
|
+
exports.ConsumableNotificationEventSchema,
|
|
56
|
+
exports.ConsumableNotificationMessageCountSchema,
|
|
57
|
+
]);
|
|
@@ -24,14 +24,14 @@ export declare class NotificationAPI {
|
|
|
24
24
|
* @param since Only return notifications more recent than this.
|
|
25
25
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/push/fetchNotifications
|
|
26
26
|
*/
|
|
27
|
-
getNotifications(clientId?: string, size?: number, since?: string
|
|
27
|
+
getNotifications(clientId?: string, size?: number, since?: string): Promise<NotificationList>;
|
|
28
28
|
/**
|
|
29
29
|
* Fetch all notifications.
|
|
30
30
|
* @param clientId Only return notifications targeted at the given client
|
|
31
31
|
* @param lastNotificationId Only return notifications more recent than this
|
|
32
32
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/push/fetchNotifications
|
|
33
33
|
*/
|
|
34
|
-
getAllNotifications(clientId?: string, lastNotificationId?: string
|
|
34
|
+
getAllNotifications(clientId?: string, lastNotificationId?: string): Promise<NotificationsReponse>;
|
|
35
35
|
/**
|
|
36
36
|
* Fetch a notification by ID.
|
|
37
37
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/push/getNotification
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationAPI.d.ts","sourceRoot":"","sources":["../../../src/notification/NotificationAPI/NotificationAPI.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAClD,OAAO,EAAkC,UAAU,EAAa,MAAM,YAAY,CAAC;AAEnF,eAAO,MAAM,yBAAyB,QAAQ,CAAC;AAE/C,KAAK,oBAAoB,GAAG;IAC1B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C,gBAAuB,GAAG;;;MAGxB;IAEF;;;OAGG;IACU,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAa1E;;;;;;OAMG;IACU,gBAAgB,CAC3B,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,GAAE,MAAkC,EACxC,KAAK,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"NotificationAPI.d.ts","sourceRoot":"","sources":["../../../src/notification/NotificationAPI/NotificationAPI.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAClD,OAAO,EAAkC,UAAU,EAAa,MAAM,YAAY,CAAC;AAEnF,eAAO,MAAM,yBAAyB,QAAQ,CAAC;AAE/C,KAAK,oBAAoB,GAAG;IAC1B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C,gBAAuB,GAAG;;;MAGxB;IAEF;;;OAGG;IACU,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAa1E;;;;;;OAMG;IACU,gBAAgB,CAC3B,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,GAAE,MAAkC,EACxC,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC;IAe5B;;;;;OAKG;IACU,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqE/G;;;OAGG;IACU,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAY/F"}
|
|
@@ -56,7 +56,7 @@ class NotificationAPI {
|
|
|
56
56
|
* @param since Only return notifications more recent than this.
|
|
57
57
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/push/fetchNotifications
|
|
58
58
|
*/
|
|
59
|
-
async getNotifications(clientId, size = exports.NOTIFICATION_SIZE_MAXIMUM, since
|
|
59
|
+
async getNotifications(clientId, size = exports.NOTIFICATION_SIZE_MAXIMUM, since) {
|
|
60
60
|
const config = {
|
|
61
61
|
method: 'get',
|
|
62
62
|
params: {
|
|
@@ -66,7 +66,7 @@ class NotificationAPI {
|
|
|
66
66
|
},
|
|
67
67
|
url: NotificationAPI.URL.NOTIFICATION,
|
|
68
68
|
};
|
|
69
|
-
const response = await this.client.sendJSON(config, false
|
|
69
|
+
const response = await this.client.sendJSON(config, false);
|
|
70
70
|
return response.data;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
@@ -75,7 +75,7 @@ class NotificationAPI {
|
|
|
75
75
|
* @param lastNotificationId Only return notifications more recent than this
|
|
76
76
|
* @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/push/fetchNotifications
|
|
77
77
|
*/
|
|
78
|
-
async getAllNotifications(clientId, lastNotificationId
|
|
78
|
+
async getAllNotifications(clientId, lastNotificationId) {
|
|
79
79
|
const getNotificationChunks = async (notificationList, currentClientId, currentNotificationId) => {
|
|
80
80
|
const defaultPayload = {
|
|
81
81
|
notifications: [],
|
|
@@ -85,7 +85,7 @@ class NotificationAPI {
|
|
|
85
85
|
let payload = { ...defaultPayload };
|
|
86
86
|
let hasMissedNotifications = false;
|
|
87
87
|
try {
|
|
88
|
-
payload = await this.getNotifications(currentClientId, exports.NOTIFICATION_SIZE_MAXIMUM, currentNotificationId
|
|
88
|
+
payload = await this.getNotifications(currentClientId, exports.NOTIFICATION_SIZE_MAXIMUM, currentNotificationId);
|
|
89
89
|
}
|
|
90
90
|
catch (error) {
|
|
91
91
|
const isAxiosError = axios_1.default.isAxiosError(error);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AcknowledgeEvent {
|
|
2
|
+
type: AcknowledgeType;
|
|
3
|
+
data?: AcknowledgeData;
|
|
4
|
+
}
|
|
5
|
+
export interface AcknowledgeData {
|
|
6
|
+
delivery_tag: number;
|
|
7
|
+
multiple: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare enum AcknowledgeType {
|
|
10
|
+
ACK = "ack",
|
|
11
|
+
ACK_MESSAGE_COUNT = "ack_message_count",
|
|
12
|
+
ACK_FULL_SYNC = "ack_full_sync"
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=AcknowledgeEvent.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcknowledgeEvent.types.d.ts","sourceRoot":"","sources":["../../src/tcp/AcknowledgeEvent.types.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,oBAAY,eAAe;IACzB,GAAG,QAAQ;IACX,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;CAChC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2025 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.AcknowledgeType = void 0;
|
|
22
|
+
var AcknowledgeType;
|
|
23
|
+
(function (AcknowledgeType) {
|
|
24
|
+
AcknowledgeType["ACK"] = "ack";
|
|
25
|
+
AcknowledgeType["ACK_MESSAGE_COUNT"] = "ack_message_count";
|
|
26
|
+
AcknowledgeType["ACK_FULL_SYNC"] = "ack_full_sync";
|
|
27
|
+
})(AcknowledgeType || (exports.AcknowledgeType = AcknowledgeType = {}));
|
|
@@ -11,25 +11,16 @@ export declare enum WEBSOCKET_STATE {
|
|
|
11
11
|
CLOSING = 2,
|
|
12
12
|
CLOSED = 3
|
|
13
13
|
}
|
|
14
|
-
export declare enum PingMessage {
|
|
15
|
-
PING = "ping",
|
|
16
|
-
PONG = "pong"
|
|
17
|
-
}
|
|
18
14
|
export declare class ReconnectingWebsocket {
|
|
19
15
|
private readonly onReconnect;
|
|
20
16
|
private static readonly RECONNECTING_OPTIONS;
|
|
21
17
|
private readonly logger;
|
|
22
18
|
private socket?;
|
|
23
|
-
private pingerId?;
|
|
24
|
-
private readonly PING_INTERVAL;
|
|
25
|
-
private hasUnansweredPing;
|
|
26
19
|
private onOpen?;
|
|
27
20
|
private onMessage?;
|
|
28
21
|
private onError?;
|
|
29
22
|
private onClose?;
|
|
30
|
-
constructor(onReconnect: () => Promise<string
|
|
31
|
-
pingInterval?: number;
|
|
32
|
-
});
|
|
23
|
+
constructor(onReconnect: () => Promise<string>);
|
|
33
24
|
private readonly internalOnError;
|
|
34
25
|
private readonly internalOnMessage;
|
|
35
26
|
private readonly internalOnOpen;
|
|
@@ -37,9 +28,6 @@ export declare class ReconnectingWebsocket {
|
|
|
37
28
|
private readonly internalOnClose;
|
|
38
29
|
connect(): void;
|
|
39
30
|
send(message: any): void;
|
|
40
|
-
private startPinging;
|
|
41
|
-
private stopPinging;
|
|
42
|
-
private readonly sendPing;
|
|
43
31
|
getState(): WEBSOCKET_STATE;
|
|
44
32
|
disconnect(reason?: string): void;
|
|
45
33
|
private getReconnectingWebsocket;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReconnectingWebsocket.d.ts","sourceRoot":"","sources":["../../src/tcp/ReconnectingWebsocket.ts"],"names":[],"mappings":"AAoBA,OAAY,EAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAU,MAAM,wBAAwB,CAAC;AAQnF,oBAAY,cAAc;IACxB,cAAc,OAAO;IACrB,UAAU,OAAO;IACjB,cAAc,OAAO;IACrB,gBAAgB,OAAO;CACxB;AAED,oBAAY,eAAe;IACzB,UAAU,IAAI;IACd,IAAI,IAAI;IACR,OAAO,IAAI;IACX,MAAM,IAAI;CACX;AAED,
|
|
1
|
+
{"version":3,"file":"ReconnectingWebsocket.d.ts","sourceRoot":"","sources":["../../src/tcp/ReconnectingWebsocket.ts"],"names":[],"mappings":"AAoBA,OAAY,EAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAU,MAAM,wBAAwB,CAAC;AAQnF,oBAAY,cAAc;IACxB,cAAc,OAAO;IACrB,UAAU,OAAO;IACjB,cAAc,OAAO;IACrB,gBAAgB,OAAO;CACxB;AAED,oBAAY,eAAe;IACzB,UAAU,IAAI;IACd,IAAI,IAAI;IACR,OAAO,IAAI;IACX,MAAM,IAAI;CACX;AAED,qBAAa,qBAAqB;IAmBpB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAlBxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAQ1C;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,MAAM,CAAC,CAAM;IAErB,OAAO,CAAC,MAAM,CAAC,CAAyB;IACxC,OAAO,CAAC,SAAS,CAAC,CAAyB;IAC3C,OAAO,CAAC,OAAO,CAAC,CAA8B;IAC9C,OAAO,CAAC,OAAO,CAAC,CAA8B;gBAEjB,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;IAmB/D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAK9B;IAEF,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAQhC;IAEF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAQ7B;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAGlC;IAEF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAK9B;IAEK,OAAO,IAAI,IAAI;IAQf,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAIxB,QAAQ,IAAI,eAAe;IAI3B,UAAU,CAAC,MAAM,SAAqB,GAAG,IAAI;IAOpD,OAAO,CAAC,wBAAwB;IAIzB,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;IAI/C,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAIrD,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI;IAItD,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI;CAG9D"}
|
|
@@ -44,7 +44,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
44
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
45
|
};
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.ReconnectingWebsocket = exports.
|
|
47
|
+
exports.ReconnectingWebsocket = exports.WEBSOCKET_STATE = exports.CloseEventCode = void 0;
|
|
48
48
|
const reconnecting_websocket_1 = __importDefault(require("reconnecting-websocket"));
|
|
49
49
|
const commons_1 = require("@wireapp/commons");
|
|
50
50
|
const buffer = __importStar(require("../shims/node/buffer"));
|
|
@@ -64,11 +64,6 @@ var WEBSOCKET_STATE;
|
|
|
64
64
|
WEBSOCKET_STATE[WEBSOCKET_STATE["CLOSING"] = 2] = "CLOSING";
|
|
65
65
|
WEBSOCKET_STATE[WEBSOCKET_STATE["CLOSED"] = 3] = "CLOSED";
|
|
66
66
|
})(WEBSOCKET_STATE || (exports.WEBSOCKET_STATE = WEBSOCKET_STATE = {}));
|
|
67
|
-
var PingMessage;
|
|
68
|
-
(function (PingMessage) {
|
|
69
|
-
PingMessage["PING"] = "ping";
|
|
70
|
-
PingMessage["PONG"] = "pong";
|
|
71
|
-
})(PingMessage || (exports.PingMessage = PingMessage = {}));
|
|
72
67
|
class ReconnectingWebsocket {
|
|
73
68
|
onReconnect;
|
|
74
69
|
static RECONNECTING_OPTIONS = {
|
|
@@ -82,20 +77,13 @@ class ReconnectingWebsocket {
|
|
|
82
77
|
};
|
|
83
78
|
logger;
|
|
84
79
|
socket;
|
|
85
|
-
pingerId;
|
|
86
|
-
PING_INTERVAL = commons_1.TimeUtil.TimeInMillis.SECOND * 20;
|
|
87
|
-
hasUnansweredPing;
|
|
88
80
|
onOpen;
|
|
89
81
|
onMessage;
|
|
90
82
|
onError;
|
|
91
83
|
onClose;
|
|
92
|
-
constructor(onReconnect
|
|
84
|
+
constructor(onReconnect) {
|
|
93
85
|
this.onReconnect = onReconnect;
|
|
94
86
|
this.logger = commons_1.LogFactory.getLogger('@wireapp/api-client/tcp/ReconnectingWebsocket');
|
|
95
|
-
if (options.pingInterval) {
|
|
96
|
-
this.PING_INTERVAL = options.pingInterval;
|
|
97
|
-
}
|
|
98
|
-
this.hasUnansweredPing = false;
|
|
99
87
|
/**
|
|
100
88
|
* According to https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine, navigator.onLine attribute and 'online' and 'offline' events are not reliable enough (especially when it's truthy).
|
|
101
89
|
* We won't receive the 'offline' event when the system goes to sleep (e.g. closing the lid of a laptop).
|
|
@@ -121,11 +109,7 @@ class ReconnectingWebsocket {
|
|
|
121
109
|
internalOnMessage = (event) => {
|
|
122
110
|
this.logger.debug('Incoming message');
|
|
123
111
|
const data = buffer.bufferToString(event.data);
|
|
124
|
-
if (
|
|
125
|
-
this.logger.debug('Received pong from WebSocket');
|
|
126
|
-
this.hasUnansweredPing = false;
|
|
127
|
-
}
|
|
128
|
-
else if (this.onMessage) {
|
|
112
|
+
if (this.onMessage) {
|
|
129
113
|
this.onMessage(data);
|
|
130
114
|
}
|
|
131
115
|
};
|
|
@@ -140,14 +124,10 @@ class ReconnectingWebsocket {
|
|
|
140
124
|
};
|
|
141
125
|
internalOnReconnect = async () => {
|
|
142
126
|
this.logger.debug('Connecting to WebSocket');
|
|
143
|
-
// The ping is needed to keep the connection alive as long as possible.
|
|
144
|
-
// Otherwise the connection would be closed after 1 min of inactivity and re-established.
|
|
145
|
-
this.startPinging();
|
|
146
127
|
return this.onReconnect();
|
|
147
128
|
};
|
|
148
129
|
internalOnClose = (event) => {
|
|
149
|
-
this.logger.debug(
|
|
150
|
-
this.stopPinging();
|
|
130
|
+
this.logger.debug(`WebSocket closed with code: ${event?.code}${event?.reason ? `Reason: ${event?.reason}` : ''}`);
|
|
151
131
|
if (this.onClose) {
|
|
152
132
|
this.onClose(event);
|
|
153
133
|
}
|
|
@@ -160,32 +140,8 @@ class ReconnectingWebsocket {
|
|
|
160
140
|
this.socket.onclose = this.internalOnClose;
|
|
161
141
|
}
|
|
162
142
|
send(message) {
|
|
163
|
-
|
|
164
|
-
this.socket.send(message);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
startPinging() {
|
|
168
|
-
this.stopPinging();
|
|
169
|
-
this.hasUnansweredPing = false;
|
|
170
|
-
this.pingerId = setInterval(this.sendPing, this.PING_INTERVAL);
|
|
143
|
+
this.socket?.send(message);
|
|
171
144
|
}
|
|
172
|
-
stopPinging() {
|
|
173
|
-
if (this.pingerId) {
|
|
174
|
-
clearInterval(this.pingerId);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
sendPing = () => {
|
|
178
|
-
if (this.socket) {
|
|
179
|
-
if (this.hasUnansweredPing) {
|
|
180
|
-
this.logger.warn('Ping interval check failed');
|
|
181
|
-
this.stopPinging();
|
|
182
|
-
this.socket.reconnect();
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
this.hasUnansweredPing = true;
|
|
186
|
-
this.send(PingMessage.PING);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
145
|
getState() {
|
|
190
146
|
return this.socket ? this.socket.readyState : WEBSOCKET_STATE.CLOSED;
|
|
191
147
|
}
|
|
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
|
|
|
3
3
|
import { WEBSOCKET_STATE } from './ReconnectingWebsocket';
|
|
4
4
|
import { InvalidTokenError, MissingCookieError } from '../auth/';
|
|
5
5
|
import { HttpClient } from '../http/';
|
|
6
|
-
import {
|
|
6
|
+
import { ConsumableNotification, ConsumableNotificationEvent } from '../notification/ConsumableNotification';
|
|
7
7
|
declare enum TOPIC {
|
|
8
8
|
ON_ERROR = "WebSocketClient.TOPIC.ON_ERROR",
|
|
9
9
|
ON_INVALID_TOKEN = "WebSocketClient.TOPIC.ON_INVALID_TOKEN",
|
|
@@ -13,10 +13,10 @@ declare enum TOPIC {
|
|
|
13
13
|
export interface WebSocketClient {
|
|
14
14
|
on(event: TOPIC.ON_ERROR, listener: (error: Error | ErrorEvent) => void): this;
|
|
15
15
|
on(event: TOPIC.ON_INVALID_TOKEN, listener: (error: InvalidTokenError | MissingCookieError) => void): this;
|
|
16
|
-
on(event: TOPIC.ON_MESSAGE, listener: (notification:
|
|
16
|
+
on(event: TOPIC.ON_MESSAGE, listener: (notification: ConsumableNotification) => void): this;
|
|
17
17
|
on(event: TOPIC.ON_STATE_CHANGE, listener: (state: WEBSOCKET_STATE) => void): this;
|
|
18
18
|
}
|
|
19
|
-
export type OnConnect = (abortHandler: AbortController) =>
|
|
19
|
+
export type OnConnect = (abortHandler: AbortController) => void;
|
|
20
20
|
export declare class WebSocketClient extends EventEmitter {
|
|
21
21
|
private clientId?;
|
|
22
22
|
private isRefreshingAccessToken;
|
|
@@ -28,8 +28,10 @@ export declare class WebSocketClient extends EventEmitter {
|
|
|
28
28
|
private isSocketLocked;
|
|
29
29
|
private bufferedMessages;
|
|
30
30
|
private abortHandler?;
|
|
31
|
+
private versionPrefix;
|
|
31
32
|
static readonly TOPIC: typeof TOPIC;
|
|
32
33
|
constructor(baseUrl: string, client: HttpClient);
|
|
34
|
+
useVersion(version: number): void;
|
|
33
35
|
private onStateChange;
|
|
34
36
|
private readonly onMessage;
|
|
35
37
|
private readonly onError;
|
|
@@ -66,6 +68,9 @@ export declare class WebSocketClient extends EventEmitter {
|
|
|
66
68
|
readonly lock: () => void;
|
|
67
69
|
isLocked(): boolean;
|
|
68
70
|
private buildWebSocketUrl;
|
|
71
|
+
acknowledgeMissedNotification(): void;
|
|
72
|
+
acknowledgeMessageCountNotification(): void;
|
|
73
|
+
acknowledgeNotification(notification: ConsumableNotificationEvent): void;
|
|
69
74
|
}
|
|
70
75
|
export {};
|
|
71
76
|
//# sourceMappingURL=WebSocketClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebSocketClient.d.ts","sourceRoot":"","sources":["../../src/tcp/WebSocketClient.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"WebSocketClient.d.ts","sourceRoot":"","sources":["../../src/tcp/WebSocketClient.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAKpC,OAAO,EAAwB,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EAAC,iBAAiB,EAA8B,kBAAkB,EAAC,MAAM,UAAU,CAAC;AAE3F,OAAO,EAAC,UAAU,EAAe,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAE5B,MAAM,wCAAwC,CAAC;AAEhD,aAAK,KAAK;IACR,QAAQ,mCAAmC;IAC3C,gBAAgB,2CAA2C;IAC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;IAOxC,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAOxB;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAItB;IAEF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAM1B;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAErB;IAEF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAItB;IAEF;;;;;;;;;;;OAWG;IACI,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,eAAe;YAmB3D,kBAAkB;IA8BzB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAMxC;;;;OAIG;IACH,SAAgB,MAAM,aAOpB;IAEF;;;;;OAKG;IACH,SAAgB,IAAI,aAGlB;IAEK,QAAQ,IAAI,OAAO;IAI1B,OAAO,CAAC,iBAAiB;IAoBlB,6BAA6B;IAQ7B,mCAAmC;IAQnC,uBAAuB,CAAC,YAAY,EAAE,2BAA2B;CAgBzE"}
|
|
@@ -21,9 +21,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.WebSocketClient = void 0;
|
|
22
22
|
const events_1 = require("events");
|
|
23
23
|
const commons_1 = require("@wireapp/commons");
|
|
24
|
+
const AcknowledgeEvent_types_1 = require("./AcknowledgeEvent.types");
|
|
24
25
|
const ReconnectingWebsocket_1 = require("./ReconnectingWebsocket");
|
|
25
26
|
const auth_1 = require("../auth/");
|
|
27
|
+
const Config_1 = require("../Config");
|
|
26
28
|
const http_1 = require("../http/");
|
|
29
|
+
const ConsumableNotification_1 = require("../notification/ConsumableNotification");
|
|
27
30
|
var TOPIC;
|
|
28
31
|
(function (TOPIC) {
|
|
29
32
|
TOPIC["ON_ERROR"] = "WebSocketClient.TOPIC.ON_ERROR";
|
|
@@ -42,6 +45,7 @@ class WebSocketClient extends events_1.EventEmitter {
|
|
|
42
45
|
isSocketLocked;
|
|
43
46
|
bufferedMessages;
|
|
44
47
|
abortHandler;
|
|
48
|
+
versionPrefix = '';
|
|
45
49
|
static TOPIC = TOPIC;
|
|
46
50
|
constructor(baseUrl, client) {
|
|
47
51
|
super();
|
|
@@ -54,6 +58,12 @@ class WebSocketClient extends events_1.EventEmitter {
|
|
|
54
58
|
this.websocketState = this.socket.getState();
|
|
55
59
|
this.logger = commons_1.LogFactory.getLogger('@wireapp/api-client/tcp/WebSocketClient');
|
|
56
60
|
}
|
|
61
|
+
useVersion(version) {
|
|
62
|
+
if (version < Config_1.MINIMUM_API_VERSION) {
|
|
63
|
+
throw new Error('Minium supported api version is 8 in order to connect to /events web socket endpoint');
|
|
64
|
+
}
|
|
65
|
+
this.versionPrefix = version > 0 ? `/v${version}` : '';
|
|
66
|
+
}
|
|
57
67
|
onStateChange(newState) {
|
|
58
68
|
if (newState !== this.websocketState) {
|
|
59
69
|
this.websocketState = newState;
|
|
@@ -65,7 +75,7 @@ class WebSocketClient extends events_1.EventEmitter {
|
|
|
65
75
|
this.bufferedMessages.push(data);
|
|
66
76
|
}
|
|
67
77
|
else {
|
|
68
|
-
const notification = JSON.parse(data);
|
|
78
|
+
const notification = ConsumableNotification_1.ConsumableNotificationSchema.parse(JSON.parse(data));
|
|
69
79
|
this.emit(WebSocketClient.TOPIC.ON_MESSAGE, notification);
|
|
70
80
|
}
|
|
71
81
|
};
|
|
@@ -181,7 +191,10 @@ class WebSocketClient extends events_1.EventEmitter {
|
|
|
181
191
|
if (!token) {
|
|
182
192
|
this.logger.warn('Reconnecting WebSocket with unset token');
|
|
183
193
|
}
|
|
184
|
-
|
|
194
|
+
if (!this.versionPrefix) {
|
|
195
|
+
throw new Error('Backend api version is not set to connect to web socket');
|
|
196
|
+
}
|
|
197
|
+
let url = `${this.baseUrl}${this.versionPrefix}/events?access_token=${token}`;
|
|
185
198
|
if (this.clientId) {
|
|
186
199
|
// Note: If no client ID is given, then the WebSocket connection will receive all notifications for all clients
|
|
187
200
|
// of the connected user
|
|
@@ -189,5 +202,31 @@ class WebSocketClient extends events_1.EventEmitter {
|
|
|
189
202
|
}
|
|
190
203
|
return url;
|
|
191
204
|
}
|
|
205
|
+
acknowledgeMissedNotification() {
|
|
206
|
+
const jsonEvent = JSON.stringify({
|
|
207
|
+
type: AcknowledgeEvent_types_1.AcknowledgeType.ACK_FULL_SYNC,
|
|
208
|
+
});
|
|
209
|
+
this.socket.send(jsonEvent);
|
|
210
|
+
}
|
|
211
|
+
acknowledgeMessageCountNotification() {
|
|
212
|
+
const jsonEvent = JSON.stringify({
|
|
213
|
+
type: AcknowledgeEvent_types_1.AcknowledgeType.ACK_MESSAGE_COUNT,
|
|
214
|
+
});
|
|
215
|
+
this.socket.send(jsonEvent);
|
|
216
|
+
}
|
|
217
|
+
acknowledgeNotification(notification) {
|
|
218
|
+
if (this.socket?.getState() !== WebSocket.OPEN) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const jsonEvent = JSON.stringify({
|
|
222
|
+
type: AcknowledgeEvent_types_1.AcknowledgeType.ACK,
|
|
223
|
+
data: {
|
|
224
|
+
delivery_tag: notification.data.delivery_tag,
|
|
225
|
+
// Note: this can be used when implementing batch proccessing
|
|
226
|
+
multiple: false,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
this.socket.send(jsonEvent);
|
|
230
|
+
}
|
|
192
231
|
}
|
|
193
232
|
exports.WebSocketClient = WebSocketClient;
|
package/package.json
CHANGED