orgnote-api 0.7.13 → 0.7.14
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.
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
decryptViaKeys,
|
|
4
4
|
encryptViaPassword,
|
|
5
5
|
decryptViaPassword,
|
|
6
|
+
IncorrectOrMissingPrivateKeyPasswordError,
|
|
6
7
|
} from '../encryption';
|
|
7
8
|
import { test, expect } from 'vitest';
|
|
8
9
|
|
|
@@ -85,3 +86,43 @@ aGW80jwBXEQ7uTjT8akpOKiH7BIuhEUZIXh+vDveG0Uwf63s2dIklznAEo+E
|
|
|
85
86
|
'Hello world'
|
|
86
87
|
);
|
|
87
88
|
});
|
|
89
|
+
|
|
90
|
+
test('Should raise incorrect or missing private key error', async () => {
|
|
91
|
+
const encryptedMsg = `-----BEGIN PGP MESSAGE-----
|
|
92
|
+
|
|
93
|
+
wcFMA/vryg+TTn0rARAAhXuEjOHa856iCNVmdeIGHF+IEoeEwTc5tIcr6Lri
|
|
94
|
+
V6xs//3WnwVwUlyxYrum3yCpx8t5gyWTXFfTNH08VoVqPVP45fkk1H7jdC6Q
|
|
95
|
+
I+tHfn8nXZApdKQlMOku+XMXtRuqvOUQHutqHj4ka3qC+wGIPcOsy2TIoFsS
|
|
96
|
+
xauk13hMggmVHOdQkMzWA1QlxDcz6lFl86SvX18uc7H62s36gHxARmOLZfBd
|
|
97
|
+
nRFdnPgLKNOPGWb6QvYfvxiv03vGSsKlb0tIpwP1Ot0nyZax+yH9CJmIEni/
|
|
98
|
+
rW9Wu/Ph+PRcB2L9kp/X4Opol3RwJ0lI9ilTRw9+GGFipXhCmJcjPJC7WNIg
|
|
99
|
+
vg0/xVUjSmlxQQAZlC9/sefvoXjY0CP+h+djtoZsxLpN4P4iTO1reuoVD0iO
|
|
100
|
+
UwT9JCUR1uDEiNXvh6AmrLlH3ceBynJcBtHXAnx1vcgtY8oKKYBjsoTeEngg
|
|
101
|
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
116
|
+
sniNAsC/t/k6ErG8NKNQsNh1aeN6plXnxeVi1vv6SvO2mwZRVvDNT1hg9Cyc
|
|
117
|
+
UO1Pw43TRLO50HgR9+ERNXL491TJA0aCj14oXwsm0Dtg6EOltX0GUDwcPjv6
|
|
118
|
+
6QMreKTATPLytbhCdPO+JOzObsptU/IlsQQWlMz8yKXwqyuN8z8SOaddJIHR
|
|
119
|
+
YQ==
|
|
120
|
+
=f4F1
|
|
121
|
+
-----END PGP MESSAGE-----`;
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
await decryptViaPassword(encryptedMsg, 'password');
|
|
125
|
+
} catch (e) {
|
|
126
|
+
expect(e).toBeInstanceOf(IncorrectOrMissingPrivateKeyPasswordError);
|
|
127
|
+
}
|
|
128
|
+
});
|
package/encryption/encryption.ts
CHANGED
|
@@ -25,6 +25,9 @@ const decriptionFailedErrorMsg =
|
|
|
25
25
|
const incorrectEncryptionPasswordErrorMsg =
|
|
26
26
|
'Error decrypting message: Modification detected.';
|
|
27
27
|
|
|
28
|
+
const noSymmetricallyEncryptedSessionKey =
|
|
29
|
+
'Error decrypting message: No symmetrically encrypted session key packet found.';
|
|
30
|
+
|
|
28
31
|
export const encryptViaKeys = withCustomErrors(_encryptViaKeys);
|
|
29
32
|
export const encryptViaPassword = withCustomErrors(_encryptViaPassword);
|
|
30
33
|
export const decryptViaPassword = withCustomErrors(_decryptViaPassword);
|
|
@@ -136,6 +139,7 @@ function withCustomErrors<P extends unknown[], T>(
|
|
|
136
139
|
incorrectPrivateKeyPassphraseErrorMsg,
|
|
137
140
|
corruptedPrivateKeyErrorMsg,
|
|
138
141
|
decryptionKeyIsNotDecryptedErrorMsg,
|
|
142
|
+
noSymmetricallyEncryptedSessionKey,
|
|
139
143
|
].includes(e.message)
|
|
140
144
|
) {
|
|
141
145
|
throw new IncorrectOrMissingPrivateKeyPasswordError(e.message);
|