@wireapp/core 38.14.1 → 38.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.
|
@@ -154,9 +154,9 @@ describe('ProteusService', () => {
|
|
|
154
154
|
it('create a session from given prekey if session does not exists', async () => {
|
|
155
155
|
const [proteusService, { apiClient, cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
156
156
|
const expectedFingerprint = 'fingerprint-client1';
|
|
157
|
-
const
|
|
157
|
+
const getPrekeysSpy = jest.spyOn(apiClient.api.user, 'postQualifiedMultiPreKeyBundles');
|
|
158
158
|
jest.spyOn(cryptoClient, 'getRemoteFingerprint').mockResolvedValue(expectedFingerprint);
|
|
159
|
-
jest.spyOn(cryptoClient, 'sessionFromPrekey').mockResolvedValue(undefined);
|
|
159
|
+
const saveSessionSpy = jest.spyOn(cryptoClient, 'sessionFromPrekey').mockResolvedValue(undefined);
|
|
160
160
|
jest.spyOn(cryptoClient, 'saveSession').mockResolvedValue(undefined);
|
|
161
161
|
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(false);
|
|
162
162
|
const userId = { id: 'user1', domain: 'domain.com' };
|
|
@@ -165,7 +165,8 @@ describe('ProteusService', () => {
|
|
|
165
165
|
key: 'pQABARhIAqEAWCCaJpFa9c626ORmjj1aV6OnOYgmTjfoiE3ynOfNfGAOmgOhAKEAWCD60VMzRrLfO+1GSjgyhnVp2N7L58DM+eeJhZJi1tBLfQT2',
|
|
166
166
|
id: 123,
|
|
167
167
|
});
|
|
168
|
-
expect(
|
|
168
|
+
expect(saveSessionSpy).toHaveBeenCalled();
|
|
169
|
+
expect(getPrekeysSpy).not.toHaveBeenCalled();
|
|
169
170
|
expect(result).toBe(expectedFingerprint);
|
|
170
171
|
});
|
|
171
172
|
it('returns the fingerprint from existing session', async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionHandler.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAK9C,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE/D,UAAU,wBAAwB;IAChC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,kBAAkB,kDAAiD,wBAAwB,KAAG,MAKnG,CAAC;AAuFF;;;GAGG;AACH,QAAA,MAAM,WAAW;YAC6B,WAAW;cAAY,MAAM;;;eAClC,SAAS;kBAAgB,YAAY;MAC3E,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"SessionHandler.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAK9C,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE/D,UAAU,wBAAwB;IAChC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,kBAAkB,kDAAiD,wBAAwB,KAAG,MAKnG,CAAC;AAuFF;;;GAGG;AACH,QAAA,MAAM,WAAW;YAC6B,WAAW;cAAY,MAAM;;;eAClC,SAAS;kBAAgB,YAAY;MAC3E,QAAQ,MAAM,CAShB,CAAC;AAyBF,UAAU,wCAAwC;IAChD,UAAU,EAAE,WAAW,GAAG,mBAAmB,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,QAAA,MAAM,YAAY,6DAMf,wCAAwC,KAAG,QAAQ,MAAM,EAAE,CA+C7D,CAAC;AAEF,UAAU,mBAAmB;IAC3B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC1B;AACD,iBAAe,aAAa,CAAC,MAAM,EAAE,mBAAmB,iBAGvD;AA+CD,KAAK,iBAAiB,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9D;;GAEG;AACH,QAAA,MAAM,sBAAsB,uDAO3B,CAAC;AAEF,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAC,CAAC"}
|
|
@@ -78,19 +78,9 @@ const createQualifiedSessions = async ({ userClientMap, domain, apiClient, crypt
|
|
|
78
78
|
* @param sessionId the session to init
|
|
79
79
|
*/
|
|
80
80
|
const initSession = async ({ userId, clientId, initialPrekey }, { cryptoClient, apiClient }) => {
|
|
81
|
-
const
|
|
82
|
-
const sessionExists = await cryptoClient.sessionExists(sessionId);
|
|
83
|
-
if (sessionExists) {
|
|
84
|
-
return sessionId;
|
|
85
|
-
}
|
|
86
|
-
if (initialPrekey) {
|
|
87
|
-
const prekeyBuffer = bazinga64_1.Decoder.fromBase64(initialPrekey.key).asBytes;
|
|
88
|
-
await cryptoClient.sessionFromPrekey(sessionId, prekeyBuffer);
|
|
89
|
-
await cryptoClient.saveSession(sessionId);
|
|
90
|
-
return sessionId;
|
|
91
|
-
}
|
|
81
|
+
const recipients = initialPrekey ? { [userId.id]: { [clientId]: initialPrekey } } : { [userId.id]: [clientId] };
|
|
92
82
|
const sessions = await initSessions({
|
|
93
|
-
recipients
|
|
83
|
+
recipients,
|
|
94
84
|
domain: userId.domain,
|
|
95
85
|
apiClient,
|
|
96
86
|
cryptoClient,
|
|
@@ -118,7 +108,8 @@ const createSessions = async ({ userClientMap, domain, apiClient, cryptoClient,
|
|
|
118
108
|
* Will make sure all the sessions need to encrypt for those user/clients pair are set
|
|
119
109
|
*/
|
|
120
110
|
const initSessions = async ({ recipients, domain = '', apiClient, cryptoClient, logger, }) => {
|
|
121
|
-
const
|
|
111
|
+
const missingClients = {};
|
|
112
|
+
const missingClientsWithPrekeys = {};
|
|
122
113
|
const existingSessions = [];
|
|
123
114
|
const users = (0, UserClientsUtil_1.flattenUserClients)(recipients, domain);
|
|
124
115
|
for (const user of users) {
|
|
@@ -130,21 +121,33 @@ const initSessions = async ({ recipients, domain = '', apiClient, cryptoClient,
|
|
|
130
121
|
existingSessions.push(sessionId);
|
|
131
122
|
continue;
|
|
132
123
|
}
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
if (!Array.isArray(data)) {
|
|
125
|
+
missingClientsWithPrekeys[userId.id] = missingClientsWithPrekeys[userId.id] || {};
|
|
126
|
+
missingClientsWithPrekeys[userId.id][clientId] = data[clientId];
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
missingClients[userId.id] = missingClients[userId.id] || [];
|
|
130
|
+
missingClients[userId.id].push(clientId);
|
|
135
131
|
}
|
|
136
132
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
133
|
+
const newPrekeySessions = Object.keys(missingClientsWithPrekeys).length > 0
|
|
134
|
+
? await createSessionsFromPreKeys({
|
|
135
|
+
preKeyBundleMap: missingClientsWithPrekeys,
|
|
136
|
+
domain,
|
|
137
|
+
useQualifiedIds: !!domain,
|
|
138
|
+
cryptoClient,
|
|
139
|
+
})
|
|
140
|
+
: [];
|
|
141
|
+
const newSessions = Object.keys(missingClients).length > 0
|
|
142
|
+
? await createSessions({
|
|
143
|
+
userClientMap: missingClients,
|
|
144
|
+
domain,
|
|
145
|
+
apiClient,
|
|
146
|
+
cryptoClient,
|
|
147
|
+
logger,
|
|
148
|
+
})
|
|
149
|
+
: [];
|
|
150
|
+
return [...existingSessions, ...newPrekeySessions, ...newSessions];
|
|
148
151
|
};
|
|
149
152
|
exports.initSessions = initSessions;
|
|
150
153
|
async function deleteSession(params) {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^22.
|
|
14
|
+
"@wireapp/api-client": "^22.16.0",
|
|
15
15
|
"@wireapp/commons": "^5.0.4",
|
|
16
16
|
"@wireapp/core-crypto": "0.6.2",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"test:coverage": "jest --coverage",
|
|
61
61
|
"watch": "tsc --watch"
|
|
62
62
|
},
|
|
63
|
-
"version": "38.14.
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"version": "38.14.3",
|
|
64
|
+
"gitHead": "abc28cc952a2154ede6ba475b7ccc780b7f3b20d"
|
|
65
65
|
}
|