@wireapp/core 43.14.1 → 43.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +10 -7
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +27 -23
- package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.d.ts +1 -5
- package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.js +0 -19
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +17 -3
- package/lib/testUtils/index.d.ts +0 -1
- package/lib/testUtils/index.d.ts.map +1 -1
- package/lib/testUtils/index.js +1 -9
- package/lib/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.test.js +1 -1
- package/lib/util/RecurringTaskScheduler/RecurringTaskScheduler.test.js +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AcmeService } from './Connection/AcmeServer';
|
|
2
2
|
import { InitParams, RotateBundle } from './E2EIService.types';
|
|
3
|
+
import { InitialData } from './Storage/E2EIStorage.schema';
|
|
3
4
|
export declare class E2EIServiceInternal {
|
|
4
5
|
private readonly coreCryptoClient;
|
|
5
6
|
private readonly apiClient;
|
|
@@ -11,9 +12,11 @@ export declare class E2EIServiceInternal {
|
|
|
11
12
|
private static instance;
|
|
12
13
|
private readonly logger;
|
|
13
14
|
private _acmeService?;
|
|
15
|
+
private _initialData?;
|
|
14
16
|
private constructor();
|
|
15
17
|
static getInstance(params?: InitParams): Promise<E2EIServiceInternal>;
|
|
16
18
|
get acmeService(): AcmeService;
|
|
19
|
+
get initialData(): InitialData;
|
|
17
20
|
startCertificateProcess(hasActiveCertificate: boolean): Promise<{
|
|
18
21
|
challenge: {
|
|
19
22
|
url: string;
|
|
@@ -23,6 +26,13 @@ export declare class E2EIServiceInternal {
|
|
|
23
26
|
keyAuth: string;
|
|
24
27
|
}>;
|
|
25
28
|
continueCertificateProcess(oAuthIdToken: string): Promise<RotateBundle | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* This function starts a ACME refresh flow for an existing client with a valid refresh token
|
|
31
|
+
*
|
|
32
|
+
* @param oAuthIdToken
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
renewCertificate(oAuthIdToken: string, hasActiveCertificate: boolean): Promise<RotateBundle>;
|
|
26
36
|
private initIdentity;
|
|
27
37
|
private init;
|
|
28
38
|
private getDirectory;
|
|
@@ -56,12 +66,5 @@ export declare class E2EIServiceInternal {
|
|
|
56
66
|
* @returns RotateBundle | undefined
|
|
57
67
|
*/
|
|
58
68
|
private continueOAuthFlow;
|
|
59
|
-
/**
|
|
60
|
-
* This function starts a ACME refresh flow for an existing client with a valid refresh token
|
|
61
|
-
*
|
|
62
|
-
* @param oAuthIdToken
|
|
63
|
-
* @returns
|
|
64
|
-
*/
|
|
65
|
-
startRefreshCertficateFlow(oAuthIdToken: string, hasActiveCertificate: boolean): Promise<RotateBundle>;
|
|
66
69
|
}
|
|
67
70
|
//# sourceMappingURL=E2EIServiceInternal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceInternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAyD,UAAU,EAAE,YAAY,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"E2EIServiceInternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceIn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
|
|
|
59
59
|
if (!discoveryUrl || !user || !clientId) {
|
|
60
60
|
throw new Error('discoveryUrl, user and clientId are required to initialize E2EIServiceInternal');
|
|
61
61
|
}
|
|
62
|
-
E2EIStorage_1.E2EIStorage.store.initialData({ discoveryUrl, user, clientId });
|
|
63
62
|
await E2EIServiceInternal.instance.init({ clientId, discoveryUrl, user });
|
|
64
63
|
}
|
|
65
64
|
}
|
|
@@ -71,6 +70,12 @@ class E2EIServiceInternal {
|
|
|
71
70
|
}
|
|
72
71
|
return this._acmeService;
|
|
73
72
|
}
|
|
73
|
+
get initialData() {
|
|
74
|
+
if (!this._initialData) {
|
|
75
|
+
throw new Error('Error while trying to get InitialData. E2EIServiceInternal has not been initialized');
|
|
76
|
+
}
|
|
77
|
+
return this._initialData;
|
|
78
|
+
}
|
|
74
79
|
async startCertificateProcess(hasActiveCertificate) {
|
|
75
80
|
// Step 0: Check if we have a handle in local storage
|
|
76
81
|
// If we don't have a handle, we need to start a new OAuth flow
|
|
@@ -84,9 +89,20 @@ class E2EIServiceInternal {
|
|
|
84
89
|
}
|
|
85
90
|
throw new Error('Error while trying to continue OAuth flow. No enrollment in progress found');
|
|
86
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* This function starts a ACME refresh flow for an existing client with a valid refresh token
|
|
94
|
+
*
|
|
95
|
+
* @param oAuthIdToken
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
async renewCertificate(oAuthIdToken, hasActiveCertificate) {
|
|
99
|
+
const identity = await this.initIdentity(hasActiveCertificate);
|
|
100
|
+
const authData = await this.getEnrollmentChallenges(identity);
|
|
101
|
+
return this.getRotateBundleAndStoreCertificateData(identity, oAuthIdToken, authData.authChallenges);
|
|
102
|
+
}
|
|
87
103
|
// ############ Internal Functions ############
|
|
88
104
|
async initIdentity(hasActiveCertificate) {
|
|
89
|
-
const { user } =
|
|
105
|
+
const { user } = this.initialData;
|
|
90
106
|
// How long the issued certificate should be maximal valid
|
|
91
107
|
const ciphersuite = E2EIService_types_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519;
|
|
92
108
|
return hasActiveCertificate
|
|
@@ -96,9 +112,9 @@ class E2EIServiceInternal {
|
|
|
96
112
|
async init(params) {
|
|
97
113
|
const { user, clientId, discoveryUrl } = params;
|
|
98
114
|
if (!user || !clientId) {
|
|
99
|
-
|
|
100
|
-
throw new Error();
|
|
115
|
+
throw new Error('user and clientId are required to initialize E2eIdentityService');
|
|
101
116
|
}
|
|
117
|
+
this._initialData = { user, clientId, discoveryUrl };
|
|
102
118
|
this._acmeService = new AcmeServer_1.AcmeService(discoveryUrl);
|
|
103
119
|
}
|
|
104
120
|
async getDirectory(identity, connection) {
|
|
@@ -155,10 +171,7 @@ class E2EIServiceInternal {
|
|
|
155
171
|
authzUrls: orderData.authzUrls,
|
|
156
172
|
nonce: orderData.nonce,
|
|
157
173
|
});
|
|
158
|
-
|
|
159
|
-
E2EIStorage_1.E2EIStorage.store.authData(authChallenges);
|
|
160
|
-
E2EIStorage_1.E2EIStorage.store.orderData({ orderUrl: orderData.orderUrl });
|
|
161
|
-
return authChallenges;
|
|
174
|
+
return { authChallenges, orderUrl: orderData.orderUrl };
|
|
162
175
|
}
|
|
163
176
|
/**
|
|
164
177
|
* Continuation of the ACME enrollment flow
|
|
@@ -181,7 +194,7 @@ class E2EIServiceInternal {
|
|
|
181
194
|
if (!oidcData.data.validated) {
|
|
182
195
|
throw new Error('Error while trying to continue OAuth flow. OIDC challenge not validated');
|
|
183
196
|
}
|
|
184
|
-
const { user: wireUser, clientId } =
|
|
197
|
+
const { user: wireUser, clientId } = this.initialData;
|
|
185
198
|
//Step 8: Do DPOP Challenge
|
|
186
199
|
const dpopData = await (0, DpopChallenge_1.doWireDpopChallenge)({
|
|
187
200
|
authData,
|
|
@@ -231,14 +244,17 @@ class E2EIServiceInternal {
|
|
|
231
244
|
if (this.e2eiServiceExternal.isEnrollmentInProgress()) {
|
|
232
245
|
throw new Error('Error while trying to start OAuth flow. There is already a flow in progress');
|
|
233
246
|
}
|
|
234
|
-
const {
|
|
247
|
+
const { authChallenges, orderUrl } = await this.getEnrollmentChallenges(identity);
|
|
248
|
+
const { authorization: { oidcChallenge: wireOidcChallenge, keyauth }, } = authChallenges;
|
|
235
249
|
if (!wireOidcChallenge || !keyauth) {
|
|
236
250
|
throw new Error('missing wireOidcChallenge or keyauth');
|
|
237
251
|
}
|
|
238
252
|
// stash the identity for later use
|
|
239
253
|
const handle = await this.coreCryptoClient.e2eiEnrollmentStash(identity);
|
|
240
|
-
//
|
|
254
|
+
// Store the values in local storage for later use (e.g. in the continue flow)
|
|
241
255
|
E2EIStorage_1.E2EIStorage.store.handle(bazinga64_1.Encoder.toBase64(handle).asString);
|
|
256
|
+
E2EIStorage_1.E2EIStorage.store.authData(authChallenges);
|
|
257
|
+
E2EIStorage_1.E2EIStorage.store.orderData({ orderUrl });
|
|
242
258
|
// we need to pass back the aquired wireOidcChallenge to the UI
|
|
243
259
|
return { challenge: wireOidcChallenge, keyAuth: keyauth };
|
|
244
260
|
}
|
|
@@ -256,17 +272,5 @@ class E2EIServiceInternal {
|
|
|
256
272
|
this.logger.log('retrieved identity from stash');
|
|
257
273
|
return this.getRotateBundleAndStoreCertificateData(identity, oAuthIdToken, authData);
|
|
258
274
|
}
|
|
259
|
-
/**
|
|
260
|
-
* This function starts a ACME refresh flow for an existing client with a valid refresh token
|
|
261
|
-
*
|
|
262
|
-
* @param oAuthIdToken
|
|
263
|
-
* @returns
|
|
264
|
-
*/
|
|
265
|
-
async startRefreshCertficateFlow(oAuthIdToken, hasActiveCertificate) {
|
|
266
|
-
// We need to initialize the identity
|
|
267
|
-
const identity = await this.initIdentity(hasActiveCertificate);
|
|
268
|
-
const authData = await this.getEnrollmentChallenges(identity);
|
|
269
|
-
return this.getRotateBundleAndStoreCertificateData(identity, oAuthIdToken, authData);
|
|
270
|
-
}
|
|
271
275
|
}
|
|
272
276
|
exports.E2EIServiceInternal = E2EIServiceInternal;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import { AuthData,
|
|
1
|
+
import { AuthData, OrderData } from './E2EIStorage.schema';
|
|
2
2
|
export declare const E2EIStorage: {
|
|
3
3
|
store: {
|
|
4
4
|
handle: (handle: string) => void;
|
|
5
5
|
authData: (data: AuthData) => void;
|
|
6
6
|
orderData: (data: OrderData) => void;
|
|
7
|
-
initialData: (data: InitialData) => void;
|
|
8
7
|
};
|
|
9
8
|
get: {
|
|
10
|
-
initialData: () => InitialData;
|
|
11
9
|
handle: () => string;
|
|
12
10
|
authData: () => AuthData;
|
|
13
11
|
orderData: () => OrderData;
|
|
14
12
|
};
|
|
15
13
|
has: {
|
|
16
14
|
handle: () => boolean;
|
|
17
|
-
initialData: () => boolean;
|
|
18
15
|
};
|
|
19
16
|
remove: {
|
|
20
|
-
initialData: () => void;
|
|
21
17
|
temporaryData: () => void;
|
|
22
18
|
all: () => void;
|
|
23
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIStorage.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,QAAQ,EAAkB,
|
|
1
|
+
{"version":3,"file":"E2EIStorage.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,QAAQ,EAAkB,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAqDzE,eAAO,MAAM,WAAW;;yBA3CK,MAAM;yBAEN,QAAQ;0BADP,SAAS;;;;wBAcN,QAAQ;yBASP,SAAS;;;;;;;;;CAqC1C,CAAC"}
|
|
@@ -25,14 +25,11 @@ const LocalStorageStore_1 = require("../../../../util/LocalStorageStore");
|
|
|
25
25
|
const HandleKey = 'Handle';
|
|
26
26
|
const AuthDataKey = 'AuthData';
|
|
27
27
|
const OderDataKey = 'OrderData';
|
|
28
|
-
const InitialDataKey = 'InitialData';
|
|
29
28
|
const storage = (0, LocalStorageStore_1.LocalStorageStore)('E2EIStorage');
|
|
30
29
|
const storeHandle = (handle) => storage.add(HandleKey, bazinga64_1.Encoder.toBase64(handle).asString);
|
|
31
30
|
const storeOrderData = (data) => storage.add(OderDataKey, bazinga64_1.Encoder.toBase64(JSON.stringify(data)).asString);
|
|
32
31
|
const storeAuthData = (data) => storage.add(AuthDataKey, bazinga64_1.Encoder.toBase64(JSON.stringify(data)).asString);
|
|
33
|
-
const storeInitialData = (data) => storage.add(InitialDataKey, bazinga64_1.Encoder.toBase64(JSON.stringify(data)).asString);
|
|
34
32
|
const hasHandle = () => storage.has(HandleKey);
|
|
35
|
-
const hasInitialData = () => storage.has(InitialDataKey);
|
|
36
33
|
const getAndVerifyHandle = () => {
|
|
37
34
|
const handle = storage.get(HandleKey);
|
|
38
35
|
if (!handle) {
|
|
@@ -48,14 +45,6 @@ const getAndVerifyAuthData = () => {
|
|
|
48
45
|
const decodedData = bazinga64_1.Decoder.fromBase64(data).asString;
|
|
49
46
|
return E2EIStorage_schema_1.AuthDataSchema.parse(JSON.parse(decodedData));
|
|
50
47
|
};
|
|
51
|
-
const getInitialData = () => {
|
|
52
|
-
const data = storage.get(InitialDataKey);
|
|
53
|
-
if (!data) {
|
|
54
|
-
throw new Error('ACME: InitialData not found');
|
|
55
|
-
}
|
|
56
|
-
const decodedData = bazinga64_1.Decoder.fromBase64(data).asString;
|
|
57
|
-
return E2EIStorage_schema_1.InitialDataSchema.parse(JSON.parse(decodedData));
|
|
58
|
-
};
|
|
59
48
|
const getAndVerifyOrderData = () => {
|
|
60
49
|
const data = storage.get(OderDataKey);
|
|
61
50
|
if (!data) {
|
|
@@ -64,9 +53,6 @@ const getAndVerifyOrderData = () => {
|
|
|
64
53
|
const decodedData = bazinga64_1.Decoder.fromBase64(data).asString;
|
|
65
54
|
return JSON.parse(decodedData);
|
|
66
55
|
};
|
|
67
|
-
const removeInitialData = () => {
|
|
68
|
-
storage.remove(InitialDataKey);
|
|
69
|
-
};
|
|
70
56
|
const removeTemporaryData = () => {
|
|
71
57
|
storage.remove(HandleKey);
|
|
72
58
|
storage.remove(AuthDataKey);
|
|
@@ -74,27 +60,22 @@ const removeTemporaryData = () => {
|
|
|
74
60
|
};
|
|
75
61
|
const removeAll = () => {
|
|
76
62
|
removeTemporaryData();
|
|
77
|
-
removeInitialData();
|
|
78
63
|
};
|
|
79
64
|
exports.E2EIStorage = {
|
|
80
65
|
store: {
|
|
81
66
|
handle: storeHandle,
|
|
82
67
|
authData: storeAuthData,
|
|
83
68
|
orderData: storeOrderData,
|
|
84
|
-
initialData: storeInitialData,
|
|
85
69
|
},
|
|
86
70
|
get: {
|
|
87
|
-
initialData: getInitialData,
|
|
88
71
|
handle: getAndVerifyHandle,
|
|
89
72
|
authData: getAndVerifyAuthData,
|
|
90
73
|
orderData: getAndVerifyOrderData,
|
|
91
74
|
},
|
|
92
75
|
has: {
|
|
93
76
|
handle: hasHandle,
|
|
94
|
-
initialData: hasInitialData,
|
|
95
77
|
},
|
|
96
78
|
remove: {
|
|
97
|
-
initialData: removeInitialData,
|
|
98
79
|
temporaryData: removeTemporaryData,
|
|
99
80
|
all: removeAll,
|
|
100
81
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,8BAA8B,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/M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,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE;IASjF;;;;;;;;OAQG;IACU,UAAU,CACrB,YAAY,EAAE,MAAM,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,sBAAsB,CAAC;CA6DnC"}
|
|
@@ -34,6 +34,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.MLSService = exports.optionalToUint8Array = void 0;
|
|
36
36
|
const http_1 = require("@wireapp/api-client/lib/http");
|
|
37
|
+
const ExponentialBackoff_1 = require("@wireapp/commons/lib/util/ExponentialBackoff");
|
|
38
|
+
const TimeUtil_1 = require("@wireapp/commons/lib/util/TimeUtil");
|
|
37
39
|
const bazinga64_1 = require("bazinga64");
|
|
38
40
|
const logdown_1 = __importDefault(require("logdown"));
|
|
39
41
|
const commons_1 = require("@wireapp/commons");
|
|
@@ -70,6 +72,11 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
70
72
|
this.textDecoder = new TextDecoder();
|
|
71
73
|
this.uploadCommitBundle = async (groupId, commitBundle, { regenerateCommitBundle, isExternalCommit } = {}) => {
|
|
72
74
|
const groupIdStr = bazinga64_1.Encoder.toBase64(groupId).asString;
|
|
75
|
+
const backoffKey = `upload-commit-bundle-409-${groupIdStr}`;
|
|
76
|
+
const { backOff, resetBackOff } = (0, ExponentialBackoff_1.exponentialBackoff)(backoffKey, {
|
|
77
|
+
maxDelay: TimeUtil_1.TimeInMillis.SECOND * 32,
|
|
78
|
+
minDelay: TimeUtil_1.TimeInMillis.SECOND / 2,
|
|
79
|
+
});
|
|
73
80
|
// We need to lock the incoming mls messages queue while we are uploading the commit bundle
|
|
74
81
|
// it's possible that we will be sent some mls messages before we receive the response from backend and accept a commit locally.
|
|
75
82
|
return (0, messageAdd_1.withLockedMLSMessagesQueue)(groupIdStr, async () => {
|
|
@@ -85,6 +92,8 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
85
92
|
}
|
|
86
93
|
const newEpoch = await this.getEpoch(groupId);
|
|
87
94
|
this.emit('newEpoch', { epoch: newEpoch, groupId: groupIdStr });
|
|
95
|
+
// We need to reset the backoff after a successful request
|
|
96
|
+
resetBackOff();
|
|
88
97
|
return response;
|
|
89
98
|
}
|
|
90
99
|
catch (error) {
|
|
@@ -100,8 +109,13 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
100
109
|
// could be that we are trying to upload a commit to a conversation that has a different epoch on backend
|
|
101
110
|
// in this case we will most likely receive a commit from backend that will increase our local epoch
|
|
102
111
|
this.logger.warn(`Uploading commitBundle failed. Will retry generating a new bundle`);
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
return backOff(async () => {
|
|
113
|
+
const updatedCommitBundle = await regenerateCommitBundle();
|
|
114
|
+
return this.uploadCommitBundle(groupId, updatedCommitBundle, { regenerateCommitBundle, isExternalCommit });
|
|
115
|
+
}, () => {
|
|
116
|
+
this.logger.error('Uploading commit bundle retry limit reached', error);
|
|
117
|
+
throw error;
|
|
118
|
+
});
|
|
105
119
|
}
|
|
106
120
|
throw error;
|
|
107
121
|
}
|
|
@@ -662,7 +676,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
662
676
|
? // If we are not refreshing the active certificate, we need to continue the certificate process with Oauth
|
|
663
677
|
await instance.continueCertificateProcess(oAuthIdToken)
|
|
664
678
|
: // If we are refreshing the active certificate, can start the refresh process
|
|
665
|
-
await instance.
|
|
679
|
+
await instance.renewCertificate(oAuthIdToken, hasActiveCertificate);
|
|
666
680
|
if (rotateBundle === undefined) {
|
|
667
681
|
throw new Error('Could not get the rotate bundle');
|
|
668
682
|
}
|
package/lib/testUtils/index.d.ts
CHANGED
|
@@ -4,5 +4,4 @@ export declare function generateQualifiedId(domain: string): {
|
|
|
4
4
|
domain: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function generateQualifiedIds(nbUsers: number, domain: string): QualifiedId[];
|
|
7
|
-
export declare const advanceJestTimersWithPromise: (time: number) => Promise<unknown>;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testUtils/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM;;;EAEjD;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAMnE
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testUtils/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM;;;EAEjD;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAMnE"}
|
package/lib/testUtils/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
21
|
+
exports.generateQualifiedIds = exports.generateQualifiedId = void 0;
|
|
22
22
|
const crypto_1 = require("crypto");
|
|
23
23
|
function generateQualifiedId(domain) {
|
|
24
24
|
return { id: (0, crypto_1.randomUUID)(), domain };
|
|
@@ -32,11 +32,3 @@ function generateQualifiedIds(nbUsers, domain) {
|
|
|
32
32
|
return users;
|
|
33
33
|
}
|
|
34
34
|
exports.generateQualifiedIds = generateQualifiedIds;
|
|
35
|
-
/*
|
|
36
|
-
* Jest fake timers do not play well with promises, so we need to advance the timers and wait for all the promises to resolve.
|
|
37
|
-
*/
|
|
38
|
-
const advanceJestTimersWithPromise = async (time) => {
|
|
39
|
-
jest.advanceTimersByTime(time);
|
|
40
|
-
return new Promise(jest.requireActual('timers').setImmediate);
|
|
41
|
-
};
|
|
42
|
-
exports.advanceJestTimersWithPromise = advanceJestTimersWithPromise;
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const testUtils_1 = require("@wireapp/commons/lib/util/testUtils");
|
|
21
22
|
const LowPrecisionTaskScheduler_1 = require("./LowPrecisionTaskScheduler");
|
|
22
|
-
const testUtils_1 = require("../../testUtils");
|
|
23
23
|
describe('LowPrecisionTaskScheduler', () => {
|
|
24
24
|
beforeEach(() => {
|
|
25
25
|
jest.useFakeTimers();
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const testUtils_1 = require("@wireapp/commons/lib/util/testUtils");
|
|
21
22
|
const commons_1 = require("@wireapp/commons");
|
|
22
23
|
const RecurringTaskScheduler_1 = require("./RecurringTaskScheduler");
|
|
23
|
-
const testUtils_1 = require("../../testUtils");
|
|
24
24
|
const mockedStore = {
|
|
25
25
|
storage: new Map(),
|
|
26
26
|
set: async (key, timestamp) => {
|
package/package.json
CHANGED
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^26.10.
|
|
15
|
-
"@wireapp/commons": "^5.2.
|
|
14
|
+
"@wireapp/api-client": "^26.10.6",
|
|
15
|
+
"@wireapp/commons": "^5.2.5",
|
|
16
16
|
"@wireapp/core-crypto": "1.0.0-rc.36",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
18
|
-
"@wireapp/promise-queue": "^2.2.
|
|
18
|
+
"@wireapp/promise-queue": "^2.2.10",
|
|
19
19
|
"@wireapp/protocol-messaging": "1.44.0",
|
|
20
20
|
"@wireapp/store-engine": "5.1.5",
|
|
21
21
|
"@wireapp/store-engine-dexie": "^2.1.7",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"test:coverage": "jest --coverage",
|
|
62
62
|
"watch": "tsc --watch"
|
|
63
63
|
},
|
|
64
|
-
"version": "43.14.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "43.14.3",
|
|
65
|
+
"gitHead": "82a565bd0b61a6ebd29a7afa67a2f4a63e0dfca4"
|
|
66
66
|
}
|