-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): Quit on decryption failure (#381)
- Loading branch information
1 parent
4cf3838
commit 1349d15
Showing
9 changed files
with
1,323 additions
and
1,272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
pnpm lint && pnpm format && pnpm test:api && pnpm test:api-client | ||
pnpm lint && pnpm format && pnpm test:api && pnpm test:api-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as eccrypto from 'eccrypto' | ||
|
||
export const decrypt = async ( | ||
privateKey: string, | ||
data: string | ||
): Promise<string> => { | ||
const parsed = JSON.parse(data) | ||
|
||
const eicesData = { | ||
iv: Buffer.from(parsed.iv), | ||
ephemPublicKey: Buffer.from(parsed.ephemPublicKey), | ||
ciphertext: Buffer.from(parsed.ciphertext), | ||
mac: Buffer.from(parsed.mac) | ||
} | ||
|
||
const decrypted = await eccrypto.decrypt( | ||
Buffer.from(privateKey, 'hex'), | ||
eicesData | ||
) | ||
|
||
return decrypted.toString() | ||
} |
Oops, something went wrong.