-
Notifications
You must be signed in to change notification settings - Fork 0
[PB-6629] Adopt lib for mobile use #67
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1ee11bc
add function for preview decryption only
TamaraFinogina a50e79d
add function for preview decryption to exports
TamaraFinogina a940725
remive not needed try/catch
TamaraFinogina 96faa6c
add this.name for preview decrypt error
TamaraFinogina 86c451f
remove webcrypto dependency
TamaraFinogina 27140bb
make converters mobile compatible
TamaraFinogina 570b622
fix style
TamaraFinogina 8edc62b
revert not needed changes
TamaraFinogina 1d4a947
add native versions
TamaraFinogina 8e02a9b
add compatibility tests
TamaraFinogina b27b4a7
apply style changes
TamaraFinogina 80c3190
add names to all errors, remove unused try for hybrid email with subject
TamaraFinogina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,25 @@ | ||
| import { x25519 } from '@noble/curves/ed25519.js'; | ||
|
|
||
| /** | ||
| * Derives secret key from the other user's public key and own private key | ||
| * | ||
| * @param aliceSecretKey - The secret key of the user deriving the shared secret key | ||
| * @param bobPublicKey - The public key of the other user | ||
| * @returns The derived secret key bits | ||
| */ | ||
| export async function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array> { | ||
| try { | ||
| return x25519.getSharedSecret(aliceSecretKey, bobPublicKey); | ||
| } catch (error) { | ||
| throw new Error('Failed to derive elliptic curve secret key', { cause: error }); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Generates elliptic curve key pair | ||
| * | ||
| * @returns The generated key pair | ||
| */ | ||
| export async function generateEccKeys(): Promise<{ secretKey: Uint8Array; publicKey: Uint8Array }> { | ||
| return x25519.keygen(); | ||
| } |
This file contains hidden or 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 hidden or 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,34 @@ | ||
| import { argon2id } from '@noble/hashes/argon2.js'; | ||
| import { | ||
| ARGON2ID_ITERATIONS, | ||
| ARGON2ID_MEMORY_SIZE, | ||
| ARGON2ID_PARALLELISM, | ||
| ARGON2ID_OUTPUT_BYTE_LENGTH, | ||
| } from '../constants'; | ||
|
|
||
| /** | ||
| * Calculates hash using the argon2id password-hashing function | ||
| * | ||
| * @param password - The user's password | ||
| * @param salt - The given salt | ||
| * @param parallelism - The degree of parallelism | ||
| * @param iterations - The number of iterations | ||
| * @param memorySize - The memory size in KB | ||
| * @param hashLength - The desired hash byte length | ||
| * @returns The resulting hash | ||
| */ | ||
| export async function argon2( | ||
| password: string, | ||
| salt: Uint8Array, | ||
| parallelism: number = ARGON2ID_PARALLELISM, | ||
| iterations: number = ARGON2ID_ITERATIONS, | ||
| memorySize: number = ARGON2ID_MEMORY_SIZE, | ||
| hashLength: number = ARGON2ID_OUTPUT_BYTE_LENGTH, | ||
| ): Promise<Uint8Array> { | ||
| return argon2id(password, salt, { | ||
| p: parallelism, | ||
| t: iterations, | ||
| m: memorySize, | ||
| dkLen: hashLength, | ||
| }); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Also, add the name of the error here:
this.name = 'EmailPreviewSymmetrictDecryptionError'so we can use it in the client if we need to filter errors. Better using the name rather than status codes, messages or whatever.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.
Done