-
Notifications
You must be signed in to change notification settings - Fork 3
[PB-5714] Add mail API to the sdk #358
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
base: master
Are you sure you want to change the base?
Conversation
src/mail/index.ts
Outdated
| clientName: this.appDetails.clientName, | ||
| clientVersion: this.appDetails.clientVersion, | ||
| token: this.apiSecurity.token, | ||
| workspaceToken: this.apiSecurity.workspaceToken, |
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.
Is the workspaceToken or the desktopToken going to be needed for the meet server api?
If not, maybe its better to remove them from here 🤔
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.
You are right, I took this part from drive I think
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.
nope, copied headersWithToken from meet
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.
maybe they should be removed from there too haha
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.
@larryrider Fixed
|
If you are going to do a new release, remember to update the package.json version |
src/mail/index.ts
Outdated
| */ | ||
| async decryptEmail(email: HybridEncryptedEmail, keys: EmailKeys): Promise<Email> { | ||
| const senderEmail = email.params.sender.email; | ||
| const pk = await this.getUserPublicKeys(senderEmail); |
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.
What is pk and why it contains the publicKeys while other object (keys) contains the private ones? I feel this confusing unless the pk name is clearer
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.
pk is the public key of the sender. To decrypt the email, we need both the public key of the person who sent the email and the private key of the receiver. I can rename pk to senderPublicKeys
src/mail/index.ts
Outdated
| */ | ||
| async getPublicKeysOfSeveralUsers(emails: string[]): Promise<UserWithPublicKeys[]> { | ||
| const response = await this.client.getWithParams<{ publicKeys: PublicKeysBase64; user: User }[]>( | ||
| `${this.apiUrl}/getPublicKeysOfSeveralUsers`, |
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.
This path is not following REST. Something like /users/keys with a body would be better
src/mail/index.ts
Outdated
| */ | ||
| async getUserPublicKeys(userEmail: string): Promise<UserWithPublicKeys> { | ||
| const response = await this.client.getWithParams<{ publicKeys: PublicKeysBase64; user: User }>( | ||
| `${this.apiUrl}/getUserPublicKeys`, |
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.
Same here
src/mail/index.ts
Outdated
| * @returns Server response | ||
| */ | ||
| async uploadKeystoreToServer(encryptedKeystore: EncryptedKeystore): Promise<void> { | ||
| return this.client.post(`${this.apiUrl}/uploadKeystore`, { encryptedKeystore }, this.headers()); |
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.
And here:
POST /keys
Would be better
src/mail/index.ts
Outdated
| * @returns Server response | ||
| */ | ||
| async sendEncryptedEmail(email: HybridEncryptedEmail): Promise<void> { | ||
| return this.client.post(`${this.apiUrl}/sendEncryptedEmail`, { email }, this.headers()); |
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.
Same here
POST /mails
Would be more correct
src/mail/index.ts
Outdated
| * @returns Server response | ||
| */ | ||
| async sendEncryptedEmailToMultipleRecipients(emails: HybridEncryptedEmail[]): Promise<void> { | ||
| return this.client.post(`${this.apiUrl}/sendEncryptedEmailToMultipleRecipients`, { emails }, this.headers()); |
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.
Same here
src/mail/index.ts
Outdated
| * @returns Server response | ||
| */ | ||
| async sendPwdProtectedEmail(email: PwdProtectedEmail): Promise<void> { | ||
| return this.client.post(`${this.apiUrl}/sendPwdProtectedEmail`, { email }, this.headers()); |
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.
Same here
src/mail/index.ts
Outdated
| * @returns The encrypted keystore | ||
| */ | ||
| async downloadKeystoreFromServer(userEmail: string, keystoreType: KeystoreType): Promise<EncryptedKeystore> { | ||
| return this.client.getWithParams(`${this.apiUrl}/getKeystore`, { userEmail, keystoreType }, this.headers()); |
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.
Same here
GET /keys
|
@sg-gs I've changed the paths, now they are:
|
@TamaraFinogina
Idea: Same action but additional params → same route (generally) |
yeah agreed, only the get keys requests seem like a POST to me, so we avoid sending the emails in query params as I know there is a max url limit (though I have no clue how big or small this limit is) or avoid possiby exposing recipients in a server request log |
|
@sg-gs @jzunigax2, functions now are the following:
All of them are currently POST because P.S. I'm not sure if |
This PR adds functions needed for implementing Mail