-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use TS in tests and fix type definitions of decryptMessageLegacy
, decryptMIMEMessage
#127
Conversation
decryptMessageLegacy
and decryptMIMEMessage
decryptMessageLegacy
, decryptMIMEMessage
decryptMessageLegacy
, decryptMIMEMessage
decryptMessageLegacy
, decryptMIMEMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpicks below. Alternatively, I'm also fine with merging this PR as-is and then changing the below in a separate PR.
@@ -4,6 +4,11 @@ const protonmailCryptoTailMessage = '---END ENCRYPTED MESSAGE---'; | |||
const protonmailCryptoHeaderRandomKey = '---BEGIN ENCRYPTED RANDOM KEY---'; | |||
const protonmailCryptoTailRandomKey = '---END ENCRYPTED RANDOM KEY---'; | |||
|
|||
/** | |||
* Extract armored encrypted message from email | |||
* @param {String|Object} EmailPM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the function kinda sort accepts it, but do we ever pass an object here? If not I don't really think we should start explicitly allowing it now. Maybe we can even get rid of the checks at some point
* @param {String|Object} EmailPM | |
* @param {String} EmailPM |
@@ -14,6 +19,11 @@ export function getEncMessageFromEmailPM(EmailPM) { | |||
return ''; | |||
} | |||
|
|||
/** | |||
* Extract (legacy, custom) armored encrypted random key from email | |||
* @param {String|Object} EmailPM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem
* @param {String|Object} EmailPM | |
* @param {String} EmailPM |
@@ -50,7 +50,7 @@ export async function decryptMessage(options) { | |||
} | |||
|
|||
// Backwards-compatible decrypt message function | |||
// 'message' option must be a string! | |||
// `options.message` must be a string, to properly handle legacy messages (and avoid misusing this function) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As written, it kind of sounds like it only needs to be a string if you care about legacy messages, which is true - but I would rather change that and remove the checks, so that this function always throws for other types, so that we enforce this rather than write a comment about it.
// `options.message` must be a string, to properly handle legacy messages (and avoid misusing this function) | |
// `options.message` must be a string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the behaviour in a separate PR, to keep this one about TS fixes only 👍
decryptMessageLegacy
,decryptMIMEMessage
to accept a string input message (used to accept aMessage
instead).ava
to v3 to support its typescript integration.