orgnote-api 0.7.15 → 0.7.16
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,8 +3,8 @@ import {
|
|
|
3
3
|
decryptViaKeys,
|
|
4
4
|
encryptViaPassword,
|
|
5
5
|
decryptViaPassword,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
NoKeysProvidedError,
|
|
7
|
+
NoPasswordProvidedError,
|
|
8
8
|
IncorrectOrMissingPrivateKeyPasswordError,
|
|
9
9
|
} from '../encryption';
|
|
10
10
|
import { test, expect } from 'vitest';
|
|
@@ -125,7 +125,7 @@ YQ==
|
|
|
125
125
|
try {
|
|
126
126
|
await decryptViaPassword(encryptedMsg, 'password');
|
|
127
127
|
} catch (e) {
|
|
128
|
-
expect(e).toBeInstanceOf(
|
|
128
|
+
expect(e).toBeInstanceOf(NoKeysProvidedError);
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -147,7 +147,7 @@ aGW80jwBXEQ7uTjT8akpOKiH7BIuhEUZIXh+vDveG0Uwf63s2dIklznAEo+E
|
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
test('Should raise
|
|
150
|
+
test('Should raise NoPasswordProvidedError error when try to use keys instead of password', async () => {
|
|
151
151
|
const encryptedMsg = `-----BEGIN PGP MESSAGE-----
|
|
152
152
|
|
|
153
153
|
wy4ECQMI6KFWGqyVV+DgYl0qUEeTe1kAdjkoR4FxFJxx+6QiOP+sZ6h7bn//
|
|
@@ -160,6 +160,6 @@ aGW80jwBXEQ7uTjT8akpOKiH7BIuhEUZIXh+vDveG0Uwf63s2dIklznAEo+E
|
|
|
160
160
|
try {
|
|
161
161
|
await decryptViaKeys(encryptedMsg, armoredPrivateKey, privateKeyPassphrase);
|
|
162
162
|
} catch (e) {
|
|
163
|
-
expect(e).toBeInstanceOf(
|
|
163
|
+
expect(e).toBeInstanceOf(NoPasswordProvidedError);
|
|
164
164
|
}
|
|
165
165
|
});
|
package/encryption/encryption.ts
CHANGED
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
export class IncorrectOrMissingPrivateKeyPasswordError extends Error {}
|
|
12
12
|
export class ImpossibleToDecryptWithProvidedKeysError extends Error {}
|
|
13
13
|
export class IncorrectEncryptionPasswordError extends Error {}
|
|
14
|
-
export class
|
|
15
|
-
export class
|
|
14
|
+
export class NoKeysProvidedError extends Error {}
|
|
15
|
+
export class NoPasswordProvidedError extends Error {}
|
|
16
16
|
|
|
17
17
|
const noPrivateKeyPassphraseProvidedErrorMsg =
|
|
18
18
|
'Error: Signing key is not decrypted.';
|
|
@@ -159,11 +159,11 @@ function withCustomErrors<P extends unknown[], T>(
|
|
|
159
159
|
throw new IncorrectEncryptionPasswordError();
|
|
160
160
|
}
|
|
161
161
|
if (e.message === noSymmetricallyEncryptedSessionKeyErrorMsg) {
|
|
162
|
-
throw new
|
|
162
|
+
throw new NoKeysProvidedError();
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
if (e.message === notPrivateKeyErrprMsg) {
|
|
166
|
-
throw new
|
|
166
|
+
throw new NoPasswordProvidedError();
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
throw e;
|