[FIX] Adjust error message (#646)

I ran into a case where the secret value provided had trailing
whitespace, and when the code ran, it logged that secret value as part
of the stack trace.

This change will make it harder for users to accidentally leak key
material.
This commit is contained in:
Brad Larson
2020-07-31 15:48:31 +02:00
committed by GitHub
parent 9696badcd1
commit a0251ff650
2 changed files with 2 additions and 2 deletions
@@ -8,7 +8,7 @@ describe('keyExtractSuri', (): void => {
it('does not extract from invalid suri', (): void => {
expect(
(): ExtractResult => keyExtractSuri('//2')
).toThrow(/to a secret URI/);
).toThrow('Unable to match provided value to a secret URI');
});
it('derives on "hello world"', (): void => {
+1 -1
View File
@@ -22,7 +22,7 @@ export default function keyExtract (suri: string): ExtractResult {
// eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
const matches = suri.match(RE_CAPTURE);
assert(!isNull(matches), `Unable to match '${suri}' to a secret URI`);
assert(!isNull(matches), 'Unable to match provided value to a secret URI');
const [, phrase, , derivePath, , , password] = matches as string[];
const { path } = keyExtractPath(derivePath);