-
Notifications
You must be signed in to change notification settings - Fork 10
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
send password-protected message through FES and update email format #1254
Comments
I'd like to clarify some things. Honestly, it's a little difficult to understand code for the browser, when you are not familiar with TS :) Anyway, let's aks some questions:
where
As I understand
Could you share an example of the text, that we should encrypt? Like
|
correct
It's hard when reading snippets of code on github, but it's not hard in an IDE. When you open the codebase using vscode, and run |
You can see this above in
Continuing the above example, now you need to encode the updated plaintext and attachments into a mime message, which you'll later encrypt. Use mime encoding library for this. Assuming there was also one png attachment, you'll get something similar to this (the actual png data below is gibberish, don't try to parse my example):
This plain, formatted mime message is what you'll be password-encrypting - whole. |
Excellent 👍. That's what I needed. Thank you! |
* #1254 add pwd param to composeEmail * #1254 add encryptMsgWithPwd * #1254 update password message structure * update msg password encryption * encrypt attachments for password message * fix attachments password encryption * refactor password encryption * fix message password * add core test for password encryption * add message upload progress * improve password message progress calculation * code cleaning * update core methods naming * refactor password message upload * code improvements * add test_sendable_msg_copy test * update pwd message encryption
When sending password protected message, we must upload it to FES & format the Gmail message differently. You can study
EncryptedMsgMailFormatter
on browser extension for details not mentioned here.The steps are (when sending a password-protected message through FES:
replyInfo = Str.base64urlUtfEncode(JSON.stringify({sender: "...", recipient: ["..."], subject: "...", token: "..."}))
infoDiv = '<div style="display: none" class="cryptup_reply" cryptup-data="REPLY INFO STRING"></div>'
bodyWithReplyToken = newMsgData.plaintext + '\n\n' + infoDiv
pgpMimeWithAttachments = Mime.encode(bodyWithReplyToken, { Subject: newMsg.subject }, attachments);
pwdEncryptedWithAttachments = encryptDataArmor(pgpMimeWithAttachments, newMsg.pwd, []); // encrypted only for pwd, not signed
. This message will be uploaded, therefore it's only encrypted for message password.msgUrl = this.view.acctServer.messageUpload(idToken, pwdEncryptedWithAttachments, replyToken, from, recipients, { renderUploadProgress(p, PercentageAccounting.FIRST_HALF) } )
. Notice that the upload progress will be divided by two, so that instead of rendering 0-100%, we render 0-50% at this stage.encryptedTextFile = Core.encryptFile(newMsgData.plaintext, publicKeys) // no attachments, no infoDiv, no mime. Use public keys to encrypt as usual, as available. No password
encryptedAttachments = plainAttachments.map { Core.encryptFile($0, publicKeys) }
// add.pgp
to name if not done automaticallyencryptedAttachmentsAndBodyAsFiles = [Attachment(data=encryptedTextFile, name=message.asc, mimeType=application/pgp-encrypted)] + encryptedAttachments
formatPwdEncryptedMsgBodyLink
.emailAndLinkBody = await this.formatPwdEncryptedMsgBodyLink(msgUrl);
- NOTE: skip theintro
part from the linked code, we are not implementing this on mobile yetemailAndLinkBody
. Attachments were encrypted separately. Compose it all into a plain message together:sendableMessageMime = Core.composeEmail(format=plain, emailAndLinkBody, encryptedAttachmentsAndBodyAsFiles)
PercentageAccounting.SECOND_HALF
, eg on browser extension (simplified):You can start implementation with approximately this method:
Rendering upload progress:
Formatting plain part of Gmail message
Formatting final Gmail message:
The text was updated successfully, but these errors were encountered: