@wireapp/core 41.2.4 → 41.2.5
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.
|
@@ -34,11 +34,12 @@ const isCryptoboxError = (error) => {
|
|
|
34
34
|
return 'code' in error;
|
|
35
35
|
};
|
|
36
36
|
const generateDecryptionError = (senderInfo, error) => {
|
|
37
|
+
var _a;
|
|
37
38
|
const { clientId, userId } = senderInfo;
|
|
38
39
|
const sender = `${userId.id} (${clientId})`;
|
|
39
|
-
const coreCryptoCode = isCoreCryptoError(error)
|
|
40
|
-
const cryptoboxCode = isCryptoboxError(error)
|
|
41
|
-
const code = coreCryptoCode
|
|
40
|
+
const coreCryptoCode = isCoreCryptoError(error) ? error.proteusErrorCode : null;
|
|
41
|
+
const cryptoboxCode = isCryptoboxError(error) ? error.code : null;
|
|
42
|
+
const code = (_a = coreCryptoCode !== null && coreCryptoCode !== void 0 ? coreCryptoCode : cryptoboxCode) !== null && _a !== void 0 ? _a : exports.ProteusErrors.Unknown;
|
|
42
43
|
const message = `Decryption error from ${sender} (${error.message})`;
|
|
43
44
|
return new DecryptionError_1.DecryptionError(message, code);
|
|
44
45
|
};
|
|
@@ -22,15 +22,15 @@ const DecryptionErrorGenerator_1 = require("./DecryptionErrorGenerator");
|
|
|
22
22
|
const DecryptionError_1 = require("../../../../errors/DecryptionError");
|
|
23
23
|
const basePayload = { userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' };
|
|
24
24
|
describe('generateDecryptionError', () => {
|
|
25
|
-
it('handles coreCrypto error',
|
|
26
|
-
const coreCryptoError = { proteusErrorCode
|
|
25
|
+
it.each([Math.floor(Math.random() * 100), 0])('handles coreCrypto error', proteusErrorCode => {
|
|
26
|
+
const coreCryptoError = { proteusErrorCode, message: 'decryption error' };
|
|
27
27
|
const error = (0, DecryptionErrorGenerator_1.generateDecryptionError)(basePayload, coreCryptoError);
|
|
28
28
|
expect(error).toBeInstanceOf(DecryptionError_1.DecryptionError);
|
|
29
29
|
expect(error.message).toBe(`Decryption error from user1 (client1) (${coreCryptoError.message})`);
|
|
30
30
|
expect(error.code).toBe(coreCryptoError.proteusErrorCode);
|
|
31
31
|
});
|
|
32
|
-
it('handles cryptobox error',
|
|
33
|
-
const coreCryptoError = { code
|
|
32
|
+
it.each([Math.floor(Math.random() * 100), 0])('handles cryptobox error', code => {
|
|
33
|
+
const coreCryptoError = { code, message: 'decryption error' };
|
|
34
34
|
const error = (0, DecryptionErrorGenerator_1.generateDecryptionError)(basePayload, coreCryptoError);
|
|
35
35
|
expect(error).toBeInstanceOf(DecryptionError_1.DecryptionError);
|
|
36
36
|
expect(error.message).toBe(`Decryption error from user1 (client1) (${coreCryptoError.message})`);
|
package/package.json
CHANGED