internxt-crypto 0.0.14 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -72
- package/dist/aes-B8TA-JKq.mjs +49 -0
- package/dist/aes-B8TA-JKq.mjs.map +1 -0
- package/dist/aes-CuW_SPl-.js +67 -0
- package/dist/aes-CuW_SPl-.js.map +1 -0
- package/dist/asymmetric-crypto.d.mts +8 -31
- package/dist/asymmetric-crypto.d.mts.map +1 -1
- package/dist/asymmetric-crypto.d.ts +8 -31
- package/dist/asymmetric-crypto.d.ts.map +1 -1
- package/dist/asymmetric-crypto.js +30 -7
- package/dist/asymmetric-crypto.js.map +1 -0
- package/dist/asymmetric-crypto.mjs +28 -2
- package/dist/asymmetric-crypto.mjs.map +1 -0
- package/dist/constants.d.mts +3 -10
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.d.ts +3 -10
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -17
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +3 -10
- package/dist/constants.mjs.map +1 -1
- package/dist/core-Bj26rNdA.js +227 -0
- package/dist/core-Bj26rNdA.js.map +1 -0
- package/dist/core-pEGygy6S.mjs +173 -0
- package/dist/core-pEGygy6S.mjs.map +1 -0
- package/dist/derive-key.d.mts +1 -74
- package/dist/derive-key.d.mts.map +1 -1
- package/dist/derive-key.d.ts +1 -74
- package/dist/derive-key.d.ts.map +1 -1
- package/dist/derive-key.js +3 -11
- package/dist/derive-key.mjs +2 -2
- package/dist/derive-password.d.mts +22 -0
- package/dist/derive-password.d.mts.map +1 -0
- package/dist/derive-password.d.ts +22 -0
- package/dist/derive-password.d.ts.map +1 -0
- package/dist/derive-password.js +5 -0
- package/dist/derive-password.mjs +3 -0
- package/dist/deriveKeysFromKey-C4McqO6_.js +47 -0
- package/dist/deriveKeysFromKey-C4McqO6_.js.map +1 -0
- package/dist/deriveKeysFromKey-DPU_h7wr.mjs +35 -0
- package/dist/deriveKeysFromKey-DPU_h7wr.mjs.map +1 -0
- package/dist/{deriveKeysFromPassword-BYaiSGKL.js → deriveKeysFromPassword-C7xAGGsh.js} +5 -172
- package/dist/deriveKeysFromPassword-C7xAGGsh.js.map +1 -0
- package/dist/{deriveKeysFromPassword-XIwzErlL.mjs → deriveKeysFromPassword-DXgSvTNC.mjs} +6 -125
- package/dist/deriveKeysFromPassword-DXgSvTNC.mjs.map +1 -0
- package/dist/email-crypto.d.mts +24 -46
- package/dist/email-crypto.d.mts.map +1 -1
- package/dist/email-crypto.d.ts +24 -46
- package/dist/email-crypto.d.ts.map +1 -1
- package/dist/email-crypto.js +121 -12
- package/dist/email-crypto.js.map +1 -0
- package/dist/email-crypto.mjs +115 -2
- package/dist/email-crypto.mjs.map +1 -0
- package/dist/email-search.d.mts.map +1 -1
- package/dist/email-search.d.ts.map +1 -1
- package/dist/email-search.js +25 -597
- package/dist/email-search.mjs +2 -573
- package/dist/{emailEncryptionKey-B9xHw1h_.mjs → emailEncryptionKey-BtSPYd9M.mjs} +22 -45
- package/dist/emailEncryptionKey-BtSPYd9M.mjs.map +1 -0
- package/dist/{emailEncryptionKey-CQNe5W_T.js → emailEncryptionKey-C4X1Bwy4.js} +22 -45
- package/dist/emailEncryptionKey-C4X1Bwy4.js.map +1 -0
- package/dist/{genID-3Er5IowC.mjs → genID-D08K7JPr.mjs} +4 -40
- package/dist/genID-D08K7JPr.mjs.map +1 -0
- package/dist/{genID-YJSl3YhL.js → genID-cWOPmspk.js} +2 -50
- package/dist/genID-cWOPmspk.js.map +1 -0
- package/dist/hash.d.mts +24 -36
- package/dist/hash.d.mts.map +1 -1
- package/dist/hash.d.ts +24 -36
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +88 -10
- package/dist/hash.js.map +1 -0
- package/dist/hash.mjs +82 -2
- package/dist/hash.mjs.map +1 -0
- package/dist/index.d.mts +9 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -79
- package/dist/index.mjs +13 -11
- package/dist/keystore-crypto.d.mts +6 -6
- package/dist/keystore-crypto.d.mts.map +1 -1
- package/dist/keystore-crypto.d.ts +6 -6
- package/dist/keystore-crypto.d.ts.map +1 -1
- package/dist/keystore-crypto.js +1 -1
- package/dist/keystore-crypto.mjs +1 -1
- package/dist/post-quantum-crypto.js +49 -4
- package/dist/post-quantum-crypto.js.map +1 -0
- package/dist/post-quantum-crypto.mjs +46 -2
- package/dist/post-quantum-crypto.mjs.map +1 -0
- package/dist/search-B9YM3XAA.mjs +587 -0
- package/dist/search-B9YM3XAA.mjs.map +1 -0
- package/dist/search-DUTm4-rN.js +731 -0
- package/dist/search-DUTm4-rN.js.map +1 -0
- package/dist/symmetric-crypto.d.mts +11 -40
- package/dist/symmetric-crypto.d.mts.map +1 -1
- package/dist/symmetric-crypto.d.ts +11 -40
- package/dist/symmetric-crypto.d.ts.map +1 -1
- package/dist/symmetric-crypto.js +2 -6
- package/dist/symmetric-crypto.mjs +2 -2
- package/dist/types.d.mts +13 -40
- package/dist/types.d.mts.map +1 -1
- package/dist/types.d.ts +13 -40
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.d.mts +1 -19
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.d.ts +1 -19
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -3
- package/dist/utils.mjs +2 -2
- package/dist/xwing-CQmQX6hn.mjs +16 -0
- package/dist/xwing-CQmQX6hn.mjs.map +1 -0
- package/dist/xwing-iRWVRtNE.js +34 -0
- package/dist/xwing-iRWVRtNE.js.map +1 -0
- package/package.json +3 -2
- package/dist/aes-DCb9dJqb.mjs +0 -161
- package/dist/aes-DCb9dJqb.mjs.map +0 -1
- package/dist/aes-DQo1MyCz.js +0 -203
- package/dist/aes-DQo1MyCz.js.map +0 -1
- package/dist/deriveKeysFromPassword-BYaiSGKL.js.map +0 -1
- package/dist/deriveKeysFromPassword-XIwzErlL.mjs.map +0 -1
- package/dist/email-search.js.map +0 -1
- package/dist/email-search.mjs.map +0 -1
- package/dist/emailEncryptionKey-B9xHw1h_.mjs.map +0 -1
- package/dist/emailEncryptionKey-CQNe5W_T.js.map +0 -1
- package/dist/emailKeys-C0KhtfNP.js +0 -572
- package/dist/emailKeys-C0KhtfNP.js.map +0 -1
- package/dist/emailKeys-D4lp9NRv.mjs +0 -488
- package/dist/emailKeys-D4lp9NRv.mjs.map +0 -1
- package/dist/genID-3Er5IowC.mjs.map +0 -1
- package/dist/genID-YJSl3YhL.js.map +0 -1
- package/dist/keys-BfcaiAOv.mjs +0 -90
- package/dist/keys-BfcaiAOv.mjs.map +0 -1
- package/dist/keys-CinT7kEY.js +0 -125
- package/dist/keys-CinT7kEY.js.map +0 -1
- package/dist/kyber768-SXnIo-Nw.mjs +0 -47
- package/dist/kyber768-SXnIo-Nw.mjs.map +0 -1
- package/dist/kyber768-WUVc2fIR.js +0 -65
- package/dist/kyber768-WUVc2fIR.js.map +0 -1
- package/dist/mac-BMb1F0dN.js +0 -170
- package/dist/mac-BMb1F0dN.js.map +0 -1
- package/dist/mac-ZpRlx8Fs.mjs +0 -116
- package/dist/mac-ZpRlx8Fs.mjs.map +0 -1
package/dist/email-crypto.d.mts
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmailBody, HybridEncryptedEmail, HybridKeyPair, PwdProtectedEmail, RecipientWithPublicKey } from "./types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/email-crypto/hybridEncyptedEmail.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Encrypts the email using hybrid encryption.
|
|
5
|
+
* Encrypts the email body using hybrid encryption.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param body - The email body to encrypt.
|
|
8
8
|
* @param recipientPublicKeys - The public keys of the recipient.
|
|
9
|
-
* @param
|
|
10
|
-
* @
|
|
11
|
-
* @returns The encrypted email
|
|
9
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
10
|
+
* @returns The encrypted email body
|
|
12
11
|
*/
|
|
13
|
-
declare function encryptEmailHybrid(
|
|
12
|
+
declare function encryptEmailHybrid(body: EmailBody, recipient: RecipientWithPublicKey, aux?: Uint8Array): Promise<HybridEncryptedEmail>;
|
|
14
13
|
/**
|
|
15
|
-
* Encrypts the email using hybrid encryption for multiple recipients.
|
|
14
|
+
* Encrypts the email body using hybrid encryption for multiple recipients.
|
|
16
15
|
*
|
|
17
|
-
* @param
|
|
16
|
+
* @param body - The email body to encrypt for multiple recipients.
|
|
18
17
|
* @param recipients - The recipients with corresponding public keys.
|
|
19
|
-
* @param
|
|
20
|
-
* @
|
|
21
|
-
* @returns The set of encrypted email
|
|
18
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
19
|
+
* @returns The set of encrypted email bodies
|
|
22
20
|
*/
|
|
23
|
-
declare function encryptEmailHybridForMultipleRecipients(
|
|
21
|
+
declare function encryptEmailHybridForMultipleRecipients(body: EmailBody, recipients: RecipientWithPublicKey[], aux?: Uint8Array): Promise<HybridEncryptedEmail[]>;
|
|
24
22
|
/**
|
|
25
23
|
* Decrypts the email using hybrid encryption.
|
|
26
24
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @returns The decrypted email
|
|
25
|
+
* @param encEmailBody - The encrypted email.
|
|
26
|
+
* @param recipientPrivateHybridKeys - The private key of the recipient.
|
|
27
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
28
|
+
* @returns The decrypted email body
|
|
31
29
|
*/
|
|
32
|
-
declare function decryptEmailHybrid(
|
|
30
|
+
declare function decryptEmailHybrid(encEmailBody: HybridEncryptedEmail, recipientPrivateHybridKeys: Uint8Array, aux?: Uint8Array): Promise<EmailBody>;
|
|
33
31
|
//#endregion
|
|
34
32
|
//#region src/email-crypto/pwdProtectedEmail.d.ts
|
|
35
33
|
/**
|
|
@@ -37,47 +35,27 @@ declare function decryptEmailHybrid(encryptedEmail: HybridEncryptedEmail, sender
|
|
|
37
35
|
*
|
|
38
36
|
* @param email - The email to password-protect
|
|
39
37
|
* @param password - The secret password shared among recipients
|
|
40
|
-
* @param
|
|
38
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
41
39
|
* @returns The password-protected email
|
|
42
40
|
*/
|
|
43
|
-
declare function createPwdProtectedEmail(
|
|
41
|
+
declare function createPwdProtectedEmail(emailBody: EmailBody, password: string, aux?: Uint8Array): Promise<PwdProtectedEmail>;
|
|
44
42
|
/**
|
|
45
43
|
* Opens a password-protected email.
|
|
46
44
|
*
|
|
47
45
|
* @param encryptedEmail - The encrypted email
|
|
48
46
|
* @param password - The secret password shared among recipients.
|
|
49
|
-
* @
|
|
47
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
48
|
+
* @returns The decrypted email body
|
|
50
49
|
*/
|
|
51
|
-
declare function decryptPwdProtectedEmail(encryptedEmail: PwdProtectedEmail, password: string): Promise<
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/email-crypto/converters.d.ts
|
|
54
|
-
declare function userToBytes(user: User): Uint8Array;
|
|
55
|
-
declare function recipientsToBytes(recipients: User[]): Uint8Array;
|
|
56
|
-
/**
|
|
57
|
-
* Converts an Email type into a Uint8Array array.
|
|
58
|
-
*
|
|
59
|
-
* @param email - The email.
|
|
60
|
-
* @returns The Uint8Array array representation of the Email type.
|
|
61
|
-
*/
|
|
62
|
-
declare function emailToBinary(email: Email): Uint8Array;
|
|
50
|
+
declare function decryptPwdProtectedEmail(encryptedEmail: PwdProtectedEmail, password: string, aux?: Uint8Array): Promise<EmailBody>;
|
|
63
51
|
//#endregion
|
|
64
52
|
//#region src/email-crypto/emailKeys.d.ts
|
|
65
53
|
/**
|
|
66
|
-
* Generates public and private keys for email
|
|
54
|
+
* Generates public and private keys for email encryption.
|
|
67
55
|
*
|
|
68
56
|
* @returns The user's private and public keys
|
|
69
57
|
*/
|
|
70
|
-
declare function generateEmailKeys(): Promise<
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/email-crypto/utils.d.ts
|
|
73
|
-
/**
|
|
74
|
-
* Creates an auxiliary string from public fields of the email.
|
|
75
|
-
*
|
|
76
|
-
* @param params - The email public parameters.
|
|
77
|
-
* @param isSubjectEncrypted - Indicates if the email subject field should be encrypted
|
|
78
|
-
* @returns The resulting auxiliary string
|
|
79
|
-
*/
|
|
80
|
-
declare function getAux(params: EmailPublicParameters, isSubjectEncrypted: boolean): Uint8Array;
|
|
58
|
+
declare function generateEmailKeys(): Promise<HybridKeyPair>;
|
|
81
59
|
//#endregion
|
|
82
|
-
export { createPwdProtectedEmail, decryptEmailHybrid, decryptPwdProtectedEmail,
|
|
60
|
+
export { createPwdProtectedEmail, decryptEmailHybrid, decryptPwdProtectedEmail, encryptEmailHybrid, encryptEmailHybridForMultipleRecipients, generateEmailKeys };
|
|
83
61
|
//# sourceMappingURL=email-crypto.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-crypto.d.mts","names":[],"sources":["../src/email-crypto/hybridEncyptedEmail.ts","../src/email-crypto/pwdProtectedEmail.ts","../src/email-crypto/
|
|
1
|
+
{"version":3,"file":"email-crypto.d.mts","names":[],"sources":["../src/email-crypto/hybridEncyptedEmail.ts","../src/email-crypto/pwdProtectedEmail.ts","../src/email-crypto/emailKeys.ts"],"mappings":";;;;;AAWA;;;;;;iBAAsB,kBAAA,CACpB,IAAA,EAAM,SAAA,EACN,SAAA,EAAW,sBAAA,EACX,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,oBAAA;;;;;;;;;iBAkBW,uCAAA,CACpB,IAAA,EAAM,SAAA,EACN,UAAA,EAAY,sBAAA,IACZ,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,oBAAA;;;;;AAJX;;;;iBA8BsB,kBAAA,CACpB,YAAA,EAAc,oBAAA,EACd,0BAAA,EAA4B,UAAA,EAC5B,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,SAAA;;;;;AAxDX;;;;;;iBCAsB,uBAAA,CACpB,SAAA,EAAW,SAAA,EACX,QAAA,UACA,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,iBAAA;;;;;;;;;iBAmBW,wBAAA,CACpB,cAAA,EAAgB,iBAAA,EAChB,QAAA,UACA,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,SAAA;;;;;AD3BX;;;iBEHsB,iBAAA,CAAA,GAAqB,OAAA,CAAQ,aAAA"}
|
package/dist/email-crypto.d.ts
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmailBody, HybridEncryptedEmail, HybridKeyPair, PwdProtectedEmail, RecipientWithPublicKey } from "./types.js";
|
|
2
2
|
|
|
3
3
|
//#region src/email-crypto/hybridEncyptedEmail.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Encrypts the email using hybrid encryption.
|
|
5
|
+
* Encrypts the email body using hybrid encryption.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param body - The email body to encrypt.
|
|
8
8
|
* @param recipientPublicKeys - The public keys of the recipient.
|
|
9
|
-
* @param
|
|
10
|
-
* @
|
|
11
|
-
* @returns The encrypted email
|
|
9
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
10
|
+
* @returns The encrypted email body
|
|
12
11
|
*/
|
|
13
|
-
declare function encryptEmailHybrid(
|
|
12
|
+
declare function encryptEmailHybrid(body: EmailBody, recipient: RecipientWithPublicKey, aux?: Uint8Array): Promise<HybridEncryptedEmail>;
|
|
14
13
|
/**
|
|
15
|
-
* Encrypts the email using hybrid encryption for multiple recipients.
|
|
14
|
+
* Encrypts the email body using hybrid encryption for multiple recipients.
|
|
16
15
|
*
|
|
17
|
-
* @param
|
|
16
|
+
* @param body - The email body to encrypt for multiple recipients.
|
|
18
17
|
* @param recipients - The recipients with corresponding public keys.
|
|
19
|
-
* @param
|
|
20
|
-
* @
|
|
21
|
-
* @returns The set of encrypted email
|
|
18
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
19
|
+
* @returns The set of encrypted email bodies
|
|
22
20
|
*/
|
|
23
|
-
declare function encryptEmailHybridForMultipleRecipients(
|
|
21
|
+
declare function encryptEmailHybridForMultipleRecipients(body: EmailBody, recipients: RecipientWithPublicKey[], aux?: Uint8Array): Promise<HybridEncryptedEmail[]>;
|
|
24
22
|
/**
|
|
25
23
|
* Decrypts the email using hybrid encryption.
|
|
26
24
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @returns The decrypted email
|
|
25
|
+
* @param encEmailBody - The encrypted email.
|
|
26
|
+
* @param recipientPrivateHybridKeys - The private key of the recipient.
|
|
27
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
28
|
+
* @returns The decrypted email body
|
|
31
29
|
*/
|
|
32
|
-
declare function decryptEmailHybrid(
|
|
30
|
+
declare function decryptEmailHybrid(encEmailBody: HybridEncryptedEmail, recipientPrivateHybridKeys: Uint8Array, aux?: Uint8Array): Promise<EmailBody>;
|
|
33
31
|
//#endregion
|
|
34
32
|
//#region src/email-crypto/pwdProtectedEmail.d.ts
|
|
35
33
|
/**
|
|
@@ -37,47 +35,27 @@ declare function decryptEmailHybrid(encryptedEmail: HybridEncryptedEmail, sender
|
|
|
37
35
|
*
|
|
38
36
|
* @param email - The email to password-protect
|
|
39
37
|
* @param password - The secret password shared among recipients
|
|
40
|
-
* @param
|
|
38
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
41
39
|
* @returns The password-protected email
|
|
42
40
|
*/
|
|
43
|
-
declare function createPwdProtectedEmail(
|
|
41
|
+
declare function createPwdProtectedEmail(emailBody: EmailBody, password: string, aux?: Uint8Array): Promise<PwdProtectedEmail>;
|
|
44
42
|
/**
|
|
45
43
|
* Opens a password-protected email.
|
|
46
44
|
*
|
|
47
45
|
* @param encryptedEmail - The encrypted email
|
|
48
46
|
* @param password - The secret password shared among recipients.
|
|
49
|
-
* @
|
|
47
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
48
|
+
* @returns The decrypted email body
|
|
50
49
|
*/
|
|
51
|
-
declare function decryptPwdProtectedEmail(encryptedEmail: PwdProtectedEmail, password: string): Promise<
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/email-crypto/converters.d.ts
|
|
54
|
-
declare function userToBytes(user: User): Uint8Array;
|
|
55
|
-
declare function recipientsToBytes(recipients: User[]): Uint8Array;
|
|
56
|
-
/**
|
|
57
|
-
* Converts an Email type into a Uint8Array array.
|
|
58
|
-
*
|
|
59
|
-
* @param email - The email.
|
|
60
|
-
* @returns The Uint8Array array representation of the Email type.
|
|
61
|
-
*/
|
|
62
|
-
declare function emailToBinary(email: Email): Uint8Array;
|
|
50
|
+
declare function decryptPwdProtectedEmail(encryptedEmail: PwdProtectedEmail, password: string, aux?: Uint8Array): Promise<EmailBody>;
|
|
63
51
|
//#endregion
|
|
64
52
|
//#region src/email-crypto/emailKeys.d.ts
|
|
65
53
|
/**
|
|
66
|
-
* Generates public and private keys for email
|
|
54
|
+
* Generates public and private keys for email encryption.
|
|
67
55
|
*
|
|
68
56
|
* @returns The user's private and public keys
|
|
69
57
|
*/
|
|
70
|
-
declare function generateEmailKeys(): Promise<
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/email-crypto/utils.d.ts
|
|
73
|
-
/**
|
|
74
|
-
* Creates an auxiliary string from public fields of the email.
|
|
75
|
-
*
|
|
76
|
-
* @param params - The email public parameters.
|
|
77
|
-
* @param isSubjectEncrypted - Indicates if the email subject field should be encrypted
|
|
78
|
-
* @returns The resulting auxiliary string
|
|
79
|
-
*/
|
|
80
|
-
declare function getAux(params: EmailPublicParameters, isSubjectEncrypted: boolean): Uint8Array;
|
|
58
|
+
declare function generateEmailKeys(): Promise<HybridKeyPair>;
|
|
81
59
|
//#endregion
|
|
82
|
-
export { createPwdProtectedEmail, decryptEmailHybrid, decryptPwdProtectedEmail,
|
|
60
|
+
export { createPwdProtectedEmail, decryptEmailHybrid, decryptPwdProtectedEmail, encryptEmailHybrid, encryptEmailHybridForMultipleRecipients, generateEmailKeys };
|
|
83
61
|
//# sourceMappingURL=email-crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-crypto.d.ts","names":[],"sources":["../src/email-crypto/hybridEncyptedEmail.ts","../src/email-crypto/pwdProtectedEmail.ts","../src/email-crypto/
|
|
1
|
+
{"version":3,"file":"email-crypto.d.ts","names":[],"sources":["../src/email-crypto/hybridEncyptedEmail.ts","../src/email-crypto/pwdProtectedEmail.ts","../src/email-crypto/emailKeys.ts"],"mappings":";;;;;AAWA;;;;;;iBAAsB,kBAAA,CACpB,IAAA,EAAM,SAAA,EACN,SAAA,EAAW,sBAAA,EACX,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,oBAAA;;;;;;;;;iBAkBW,uCAAA,CACpB,IAAA,EAAM,SAAA,EACN,UAAA,EAAY,sBAAA,IACZ,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,oBAAA;;;;;AAJX;;;;iBA8BsB,kBAAA,CACpB,YAAA,EAAc,oBAAA,EACd,0BAAA,EAA4B,UAAA,EAC5B,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,SAAA;;;;;AAxDX;;;;;;iBCAsB,uBAAA,CACpB,SAAA,EAAW,SAAA,EACX,QAAA,UACA,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,iBAAA;;;;;;;;;iBAmBW,wBAAA,CACpB,cAAA,EAAgB,iBAAA,EAChB,QAAA,UACA,GAAA,GAAM,UAAA,GACL,OAAA,CAAQ,SAAA;;;;;AD3BX;;;iBEHsB,iBAAA,CAAA,GAAqB,OAAA,CAAQ,aAAA"}
|
package/dist/email-crypto.js
CHANGED
|
@@ -1,13 +1,122 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
const require_xwing = require('./xwing-iRWVRtNE.js');
|
|
3
|
+
const require_core = require('./core-Bj26rNdA.js');
|
|
4
|
+
|
|
5
|
+
//#region src/email-crypto/hybridEncyptedEmail.ts
|
|
6
|
+
/**
|
|
7
|
+
* Encrypts the email body using hybrid encryption.
|
|
8
|
+
*
|
|
9
|
+
* @param body - The email body to encrypt.
|
|
10
|
+
* @param recipientPublicKeys - The public keys of the recipient.
|
|
11
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
12
|
+
* @returns The encrypted email body
|
|
13
|
+
*/
|
|
14
|
+
async function encryptEmailHybrid(body, recipient, aux) {
|
|
15
|
+
try {
|
|
16
|
+
const { encryptionKey, encEmailBody } = await require_core.encryptEmailBody(body, aux);
|
|
17
|
+
return {
|
|
18
|
+
encEmailBody,
|
|
19
|
+
encryptedKey: await require_core.encryptKeysHybrid(encryptionKey, recipient)
|
|
20
|
+
};
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new Error("Failed to encrypt email body with hybrid encryption", { cause: error });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Encrypts the email body using hybrid encryption for multiple recipients.
|
|
27
|
+
*
|
|
28
|
+
* @param body - The email body to encrypt for multiple recipients.
|
|
29
|
+
* @param recipients - The recipients with corresponding public keys.
|
|
30
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
31
|
+
* @returns The set of encrypted email bodies
|
|
32
|
+
*/
|
|
33
|
+
async function encryptEmailHybridForMultipleRecipients(body, recipients, aux) {
|
|
34
|
+
try {
|
|
35
|
+
const { encryptionKey, encEmailBody } = await require_core.encryptEmailBody(body, aux);
|
|
36
|
+
const encryptedEmails = [];
|
|
37
|
+
for (const recipient of recipients) {
|
|
38
|
+
const encryptedKey = await require_core.encryptKeysHybrid(encryptionKey, recipient);
|
|
39
|
+
encryptedEmails.push({
|
|
40
|
+
encEmailBody,
|
|
41
|
+
encryptedKey
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return encryptedEmails;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new Error("Failed to encrypt email to multiple recipients with hybrid encryption", { cause: error });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Decrypts the email using hybrid encryption.
|
|
51
|
+
*
|
|
52
|
+
* @param encEmailBody - The encrypted email.
|
|
53
|
+
* @param recipientPrivateHybridKeys - The private key of the recipient.
|
|
54
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
55
|
+
* @returns The decrypted email body
|
|
56
|
+
*/
|
|
57
|
+
async function decryptEmailHybrid(encEmailBody, recipientPrivateHybridKeys, aux) {
|
|
58
|
+
try {
|
|
59
|
+
const encryptionKey = await require_core.decryptKeysHybrid(encEmailBody.encryptedKey, recipientPrivateHybridKeys);
|
|
60
|
+
return await require_core.decryptEmailBody(encEmailBody.encEmailBody, encryptionKey, aux);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw new Error("Failed to decrypt email with hybrid encryption", { cause: error });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/email-crypto/pwdProtectedEmail.ts
|
|
68
|
+
/**
|
|
69
|
+
* Creates a password-protected email.
|
|
70
|
+
*
|
|
71
|
+
* @param email - The email to password-protect
|
|
72
|
+
* @param password - The secret password shared among recipients
|
|
73
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
74
|
+
* @returns The password-protected email
|
|
75
|
+
*/
|
|
76
|
+
async function createPwdProtectedEmail(emailBody, password, aux) {
|
|
77
|
+
try {
|
|
78
|
+
const { encryptionKey, encEmailBody } = await require_core.encryptEmailBody(emailBody, aux);
|
|
79
|
+
return {
|
|
80
|
+
encEmailBody,
|
|
81
|
+
encryptedKey: await require_core.passwordProtectKey(encryptionKey, password)
|
|
82
|
+
};
|
|
83
|
+
} catch (error) {
|
|
84
|
+
throw new Error("Failed to password-protect email", { cause: error });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Opens a password-protected email.
|
|
89
|
+
*
|
|
90
|
+
* @param encryptedEmail - The encrypted email
|
|
91
|
+
* @param password - The secret password shared among recipients.
|
|
92
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
93
|
+
* @returns The decrypted email body
|
|
94
|
+
*/
|
|
95
|
+
async function decryptPwdProtectedEmail(encryptedEmail, password, aux) {
|
|
96
|
+
try {
|
|
97
|
+
const encryptionKey = await require_core.removePasswordProtection(encryptedEmail.encryptedKey, password);
|
|
98
|
+
return await require_core.decryptEmailBody(encryptedEmail.encEmailBody, encryptionKey, aux);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
throw new Error("Failed to decrypt password-protect email", { cause: error });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/email-crypto/emailKeys.ts
|
|
106
|
+
/**
|
|
107
|
+
* Generates public and private keys for email encryption.
|
|
108
|
+
*
|
|
109
|
+
* @returns The user's private and public keys
|
|
110
|
+
*/
|
|
111
|
+
async function generateEmailKeys() {
|
|
112
|
+
return require_xwing.genHybridKeys();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
exports.createPwdProtectedEmail = createPwdProtectedEmail;
|
|
117
|
+
exports.decryptEmailHybrid = decryptEmailHybrid;
|
|
118
|
+
exports.decryptPwdProtectedEmail = decryptPwdProtectedEmail;
|
|
119
|
+
exports.encryptEmailHybrid = encryptEmailHybrid;
|
|
120
|
+
exports.encryptEmailHybridForMultipleRecipients = encryptEmailHybridForMultipleRecipients;
|
|
121
|
+
exports.generateEmailKeys = generateEmailKeys;
|
|
122
|
+
//# sourceMappingURL=email-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-crypto.js","names":["encryptEmailBody","encryptKeysHybrid","decryptKeysHybrid","decryptEmailBody","encryptEmailBody","passwordProtectKey","removePasswordProtection","decryptEmailBody","genHybridKeys"],"sources":["../src/email-crypto/hybridEncyptedEmail.ts","../src/email-crypto/pwdProtectedEmail.ts","../src/email-crypto/emailKeys.ts"],"sourcesContent":["import { HybridEncryptedEmail, EmailBody, RecipientWithPublicKey } from '../types';\nimport { decryptEmailBody, encryptKeysHybrid, decryptKeysHybrid, encryptEmailBody } from './core';\n\n/**\n * Encrypts the email body using hybrid encryption.\n *\n * @param body - The email body to encrypt.\n * @param recipientPublicKeys - The public keys of the recipient.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The encrypted email body\n */\nexport async function encryptEmailHybrid(\n body: EmailBody,\n recipient: RecipientWithPublicKey,\n aux?: Uint8Array,\n): Promise<HybridEncryptedEmail> {\n try {\n const { encryptionKey, encEmailBody } = await encryptEmailBody(body, aux);\n const encryptedKey = await encryptKeysHybrid(encryptionKey, recipient);\n return { encEmailBody, encryptedKey };\n } catch (error) {\n throw new Error('Failed to encrypt email body with hybrid encryption', { cause: error });\n }\n}\n\n/**\n * Encrypts the email body using hybrid encryption for multiple recipients.\n *\n * @param body - The email body to encrypt for multiple recipients.\n * @param recipients - The recipients with corresponding public keys.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The set of encrypted email bodies\n */\nexport async function encryptEmailHybridForMultipleRecipients(\n body: EmailBody,\n recipients: RecipientWithPublicKey[],\n aux?: Uint8Array,\n): Promise<HybridEncryptedEmail[]> {\n try {\n const { encryptionKey, encEmailBody } = await encryptEmailBody(body, aux);\n\n const encryptedEmails: HybridEncryptedEmail[] = [];\n for (const recipient of recipients) {\n const encryptedKey = await encryptKeysHybrid(encryptionKey, recipient);\n encryptedEmails.push({\n encEmailBody: encEmailBody,\n encryptedKey,\n });\n }\n return encryptedEmails;\n } catch (error) {\n throw new Error('Failed to encrypt email to multiple recipients with hybrid encryption', { cause: error });\n }\n}\n\n/**\n * Decrypts the email using hybrid encryption.\n *\n * @param encEmailBody - The encrypted email.\n * @param recipientPrivateHybridKeys - The private key of the recipient.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The decrypted email body\n */\nexport async function decryptEmailHybrid(\n encEmailBody: HybridEncryptedEmail,\n recipientPrivateHybridKeys: Uint8Array,\n aux?: Uint8Array,\n): Promise<EmailBody> {\n try {\n const encryptionKey = await decryptKeysHybrid(encEmailBody.encryptedKey, recipientPrivateHybridKeys);\n const body = await decryptEmailBody(encEmailBody.encEmailBody, encryptionKey, aux);\n return body;\n } catch (error) {\n throw new Error('Failed to decrypt email with hybrid encryption', { cause: error });\n }\n}\n","import { PwdProtectedEmail, EmailBody } from '../types';\nimport { decryptEmailBody, passwordProtectKey, removePasswordProtection, encryptEmailBody } from './core';\n\n/**\n * Creates a password-protected email.\n *\n * @param email - The email to password-protect\n * @param password - The secret password shared among recipients\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The password-protected email\n */\nexport async function createPwdProtectedEmail(\n emailBody: EmailBody,\n password: string,\n aux?: Uint8Array,\n): Promise<PwdProtectedEmail> {\n try {\n const { encryptionKey, encEmailBody } = await encryptEmailBody(emailBody, aux);\n const encryptedKey = await passwordProtectKey(encryptionKey, password);\n\n return { encEmailBody, encryptedKey };\n } catch (error) {\n throw new Error('Failed to password-protect email', { cause: error });\n }\n}\n\n/**\n * Opens a password-protected email.\n *\n * @param encryptedEmail - The encrypted email\n * @param password - The secret password shared among recipients.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The decrypted email body\n */\nexport async function decryptPwdProtectedEmail(\n encryptedEmail: PwdProtectedEmail,\n password: string,\n aux?: Uint8Array,\n): Promise<EmailBody> {\n try {\n const encryptionKey = await removePasswordProtection(encryptedEmail.encryptedKey, password);\n const body = await decryptEmailBody(encryptedEmail.encEmailBody, encryptionKey, aux);\n return body;\n } catch (error) {\n throw new Error('Failed to decrypt password-protect email', { cause: error });\n }\n}\n","import { genHybridKeys } from '../hybrid-crypto';\nimport { HybridKeyPair } from '../types';\n\n/**\n * Generates public and private keys for email encryption.\n *\n * @returns The user's private and public keys\n */\nexport async function generateEmailKeys(): Promise<HybridKeyPair> {\n return genHybridKeys();\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,eAAsB,mBACpB,MACA,WACA,KAC+B;AAC/B,KAAI;EACF,MAAM,EAAE,eAAe,iBAAiB,MAAMA,8BAAiB,MAAM,IAAI;AAEzE,SAAO;GAAE;GAAc,cADF,MAAMC,+BAAkB,eAAe,UAAU;GACjC;UAC9B,OAAO;AACd,QAAM,IAAI,MAAM,uDAAuD,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAY5F,eAAsB,wCACpB,MACA,YACA,KACiC;AACjC,KAAI;EACF,MAAM,EAAE,eAAe,iBAAiB,MAAMD,8BAAiB,MAAM,IAAI;EAEzE,MAAM,kBAA0C,EAAE;AAClD,OAAK,MAAM,aAAa,YAAY;GAClC,MAAM,eAAe,MAAMC,+BAAkB,eAAe,UAAU;AACtE,mBAAgB,KAAK;IACL;IACd;IACD,CAAC;;AAEJ,SAAO;UACA,OAAO;AACd,QAAM,IAAI,MAAM,yEAAyE,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAY9G,eAAsB,mBACpB,cACA,4BACA,KACoB;AACpB,KAAI;EACF,MAAM,gBAAgB,MAAMC,+BAAkB,aAAa,cAAc,2BAA2B;AAEpG,SADa,MAAMC,8BAAiB,aAAa,cAAc,eAAe,IAAI;UAE3E,OAAO;AACd,QAAM,IAAI,MAAM,kDAAkD,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;;;;AC9DvF,eAAsB,wBACpB,WACA,UACA,KAC4B;AAC5B,KAAI;EACF,MAAM,EAAE,eAAe,iBAAiB,MAAMC,8BAAiB,WAAW,IAAI;AAG9E,SAAO;GAAE;GAAc,cAFF,MAAMC,gCAAmB,eAAe,SAAS;GAEjC;UAC9B,OAAO;AACd,QAAM,IAAI,MAAM,oCAAoC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYzE,eAAsB,yBACpB,gBACA,UACA,KACoB;AACpB,KAAI;EACF,MAAM,gBAAgB,MAAMC,sCAAyB,eAAe,cAAc,SAAS;AAE3F,SADa,MAAMC,8BAAiB,eAAe,cAAc,eAAe,IAAI;UAE7E,OAAO;AACd,QAAM,IAAI,MAAM,4CAA4C,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;ACpCjF,eAAsB,oBAA4C;AAChE,QAAOC,6BAAe"}
|
package/dist/email-crypto.mjs
CHANGED
|
@@ -1,3 +1,116 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as genHybridKeys } from "./xwing-CQmQX6hn.mjs";
|
|
2
|
+
import { a as encryptKeysHybrid, n as decryptKeysHybrid, o as passwordProtectKey, r as encryptEmailBody, s as removePasswordProtection, t as decryptEmailBody } from "./core-pEGygy6S.mjs";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
//#region src/email-crypto/hybridEncyptedEmail.ts
|
|
5
|
+
/**
|
|
6
|
+
* Encrypts the email body using hybrid encryption.
|
|
7
|
+
*
|
|
8
|
+
* @param body - The email body to encrypt.
|
|
9
|
+
* @param recipientPublicKeys - The public keys of the recipient.
|
|
10
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
11
|
+
* @returns The encrypted email body
|
|
12
|
+
*/
|
|
13
|
+
async function encryptEmailHybrid(body, recipient, aux) {
|
|
14
|
+
try {
|
|
15
|
+
const { encryptionKey, encEmailBody } = await encryptEmailBody(body, aux);
|
|
16
|
+
return {
|
|
17
|
+
encEmailBody,
|
|
18
|
+
encryptedKey: await encryptKeysHybrid(encryptionKey, recipient)
|
|
19
|
+
};
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new Error("Failed to encrypt email body with hybrid encryption", { cause: error });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Encrypts the email body using hybrid encryption for multiple recipients.
|
|
26
|
+
*
|
|
27
|
+
* @param body - The email body to encrypt for multiple recipients.
|
|
28
|
+
* @param recipients - The recipients with corresponding public keys.
|
|
29
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
30
|
+
* @returns The set of encrypted email bodies
|
|
31
|
+
*/
|
|
32
|
+
async function encryptEmailHybridForMultipleRecipients(body, recipients, aux) {
|
|
33
|
+
try {
|
|
34
|
+
const { encryptionKey, encEmailBody } = await encryptEmailBody(body, aux);
|
|
35
|
+
const encryptedEmails = [];
|
|
36
|
+
for (const recipient of recipients) {
|
|
37
|
+
const encryptedKey = await encryptKeysHybrid(encryptionKey, recipient);
|
|
38
|
+
encryptedEmails.push({
|
|
39
|
+
encEmailBody,
|
|
40
|
+
encryptedKey
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return encryptedEmails;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new Error("Failed to encrypt email to multiple recipients with hybrid encryption", { cause: error });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Decrypts the email using hybrid encryption.
|
|
50
|
+
*
|
|
51
|
+
* @param encEmailBody - The encrypted email.
|
|
52
|
+
* @param recipientPrivateHybridKeys - The private key of the recipient.
|
|
53
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
54
|
+
* @returns The decrypted email body
|
|
55
|
+
*/
|
|
56
|
+
async function decryptEmailHybrid(encEmailBody, recipientPrivateHybridKeys, aux) {
|
|
57
|
+
try {
|
|
58
|
+
const encryptionKey = await decryptKeysHybrid(encEmailBody.encryptedKey, recipientPrivateHybridKeys);
|
|
59
|
+
return await decryptEmailBody(encEmailBody.encEmailBody, encryptionKey, aux);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw new Error("Failed to decrypt email with hybrid encryption", { cause: error });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/email-crypto/pwdProtectedEmail.ts
|
|
67
|
+
/**
|
|
68
|
+
* Creates a password-protected email.
|
|
69
|
+
*
|
|
70
|
+
* @param email - The email to password-protect
|
|
71
|
+
* @param password - The secret password shared among recipients
|
|
72
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
73
|
+
* @returns The password-protected email
|
|
74
|
+
*/
|
|
75
|
+
async function createPwdProtectedEmail(emailBody, password, aux) {
|
|
76
|
+
try {
|
|
77
|
+
const { encryptionKey, encEmailBody } = await encryptEmailBody(emailBody, aux);
|
|
78
|
+
return {
|
|
79
|
+
encEmailBody,
|
|
80
|
+
encryptedKey: await passwordProtectKey(encryptionKey, password)
|
|
81
|
+
};
|
|
82
|
+
} catch (error) {
|
|
83
|
+
throw new Error("Failed to password-protect email", { cause: error });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Opens a password-protected email.
|
|
88
|
+
*
|
|
89
|
+
* @param encryptedEmail - The encrypted email
|
|
90
|
+
* @param password - The secret password shared among recipients.
|
|
91
|
+
* @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).
|
|
92
|
+
* @returns The decrypted email body
|
|
93
|
+
*/
|
|
94
|
+
async function decryptPwdProtectedEmail(encryptedEmail, password, aux) {
|
|
95
|
+
try {
|
|
96
|
+
const encryptionKey = await removePasswordProtection(encryptedEmail.encryptedKey, password);
|
|
97
|
+
return await decryptEmailBody(encryptedEmail.encEmailBody, encryptionKey, aux);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
throw new Error("Failed to decrypt password-protect email", { cause: error });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/email-crypto/emailKeys.ts
|
|
105
|
+
/**
|
|
106
|
+
* Generates public and private keys for email encryption.
|
|
107
|
+
*
|
|
108
|
+
* @returns The user's private and public keys
|
|
109
|
+
*/
|
|
110
|
+
async function generateEmailKeys() {
|
|
111
|
+
return genHybridKeys();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { createPwdProtectedEmail, decryptEmailHybrid, decryptPwdProtectedEmail, encryptEmailHybrid, encryptEmailHybridForMultipleRecipients, generateEmailKeys };
|
|
116
|
+
//# sourceMappingURL=email-crypto.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-crypto.mjs","names":[],"sources":["../src/email-crypto/hybridEncyptedEmail.ts","../src/email-crypto/pwdProtectedEmail.ts","../src/email-crypto/emailKeys.ts"],"sourcesContent":["import { HybridEncryptedEmail, EmailBody, RecipientWithPublicKey } from '../types';\nimport { decryptEmailBody, encryptKeysHybrid, decryptKeysHybrid, encryptEmailBody } from './core';\n\n/**\n * Encrypts the email body using hybrid encryption.\n *\n * @param body - The email body to encrypt.\n * @param recipientPublicKeys - The public keys of the recipient.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The encrypted email body\n */\nexport async function encryptEmailHybrid(\n body: EmailBody,\n recipient: RecipientWithPublicKey,\n aux?: Uint8Array,\n): Promise<HybridEncryptedEmail> {\n try {\n const { encryptionKey, encEmailBody } = await encryptEmailBody(body, aux);\n const encryptedKey = await encryptKeysHybrid(encryptionKey, recipient);\n return { encEmailBody, encryptedKey };\n } catch (error) {\n throw new Error('Failed to encrypt email body with hybrid encryption', { cause: error });\n }\n}\n\n/**\n * Encrypts the email body using hybrid encryption for multiple recipients.\n *\n * @param body - The email body to encrypt for multiple recipients.\n * @param recipients - The recipients with corresponding public keys.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The set of encrypted email bodies\n */\nexport async function encryptEmailHybridForMultipleRecipients(\n body: EmailBody,\n recipients: RecipientWithPublicKey[],\n aux?: Uint8Array,\n): Promise<HybridEncryptedEmail[]> {\n try {\n const { encryptionKey, encEmailBody } = await encryptEmailBody(body, aux);\n\n const encryptedEmails: HybridEncryptedEmail[] = [];\n for (const recipient of recipients) {\n const encryptedKey = await encryptKeysHybrid(encryptionKey, recipient);\n encryptedEmails.push({\n encEmailBody: encEmailBody,\n encryptedKey,\n });\n }\n return encryptedEmails;\n } catch (error) {\n throw new Error('Failed to encrypt email to multiple recipients with hybrid encryption', { cause: error });\n }\n}\n\n/**\n * Decrypts the email using hybrid encryption.\n *\n * @param encEmailBody - The encrypted email.\n * @param recipientPrivateHybridKeys - The private key of the recipient.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The decrypted email body\n */\nexport async function decryptEmailHybrid(\n encEmailBody: HybridEncryptedEmail,\n recipientPrivateHybridKeys: Uint8Array,\n aux?: Uint8Array,\n): Promise<EmailBody> {\n try {\n const encryptionKey = await decryptKeysHybrid(encEmailBody.encryptedKey, recipientPrivateHybridKeys);\n const body = await decryptEmailBody(encEmailBody.encEmailBody, encryptionKey, aux);\n return body;\n } catch (error) {\n throw new Error('Failed to decrypt email with hybrid encryption', { cause: error });\n }\n}\n","import { PwdProtectedEmail, EmailBody } from '../types';\nimport { decryptEmailBody, passwordProtectKey, removePasswordProtection, encryptEmailBody } from './core';\n\n/**\n * Creates a password-protected email.\n *\n * @param email - The email to password-protect\n * @param password - The secret password shared among recipients\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The password-protected email\n */\nexport async function createPwdProtectedEmail(\n emailBody: EmailBody,\n password: string,\n aux?: Uint8Array,\n): Promise<PwdProtectedEmail> {\n try {\n const { encryptionKey, encEmailBody } = await encryptEmailBody(emailBody, aux);\n const encryptedKey = await passwordProtectKey(encryptionKey, password);\n\n return { encEmailBody, encryptedKey };\n } catch (error) {\n throw new Error('Failed to password-protect email', { cause: error });\n }\n}\n\n/**\n * Opens a password-protected email.\n *\n * @param encryptedEmail - The encrypted email\n * @param password - The secret password shared among recipients.\n * @param aux - An optional auxilary sting for AEAD (e.g., email ID or timestamp).\n * @returns The decrypted email body\n */\nexport async function decryptPwdProtectedEmail(\n encryptedEmail: PwdProtectedEmail,\n password: string,\n aux?: Uint8Array,\n): Promise<EmailBody> {\n try {\n const encryptionKey = await removePasswordProtection(encryptedEmail.encryptedKey, password);\n const body = await decryptEmailBody(encryptedEmail.encEmailBody, encryptionKey, aux);\n return body;\n } catch (error) {\n throw new Error('Failed to decrypt password-protect email', { cause: error });\n }\n}\n","import { genHybridKeys } from '../hybrid-crypto';\nimport { HybridKeyPair } from '../types';\n\n/**\n * Generates public and private keys for email encryption.\n *\n * @returns The user's private and public keys\n */\nexport async function generateEmailKeys(): Promise<HybridKeyPair> {\n return genHybridKeys();\n}\n"],"mappings":";;;;;;;;;;;;AAWA,eAAsB,mBACpB,MACA,WACA,KAC+B;AAC/B,KAAI;EACF,MAAM,EAAE,eAAe,iBAAiB,MAAM,iBAAiB,MAAM,IAAI;AAEzE,SAAO;GAAE;GAAc,cADF,MAAM,kBAAkB,eAAe,UAAU;GACjC;UAC9B,OAAO;AACd,QAAM,IAAI,MAAM,uDAAuD,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAY5F,eAAsB,wCACpB,MACA,YACA,KACiC;AACjC,KAAI;EACF,MAAM,EAAE,eAAe,iBAAiB,MAAM,iBAAiB,MAAM,IAAI;EAEzE,MAAM,kBAA0C,EAAE;AAClD,OAAK,MAAM,aAAa,YAAY;GAClC,MAAM,eAAe,MAAM,kBAAkB,eAAe,UAAU;AACtE,mBAAgB,KAAK;IACL;IACd;IACD,CAAC;;AAEJ,SAAO;UACA,OAAO;AACd,QAAM,IAAI,MAAM,yEAAyE,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAY9G,eAAsB,mBACpB,cACA,4BACA,KACoB;AACpB,KAAI;EACF,MAAM,gBAAgB,MAAM,kBAAkB,aAAa,cAAc,2BAA2B;AAEpG,SADa,MAAM,iBAAiB,aAAa,cAAc,eAAe,IAAI;UAE3E,OAAO;AACd,QAAM,IAAI,MAAM,kDAAkD,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;;;;AC9DvF,eAAsB,wBACpB,WACA,UACA,KAC4B;AAC5B,KAAI;EACF,MAAM,EAAE,eAAe,iBAAiB,MAAM,iBAAiB,WAAW,IAAI;AAG9E,SAAO;GAAE;GAAc,cAFF,MAAM,mBAAmB,eAAe,SAAS;GAEjC;UAC9B,OAAO;AACd,QAAM,IAAI,MAAM,oCAAoC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYzE,eAAsB,yBACpB,gBACA,UACA,KACoB;AACpB,KAAI;EACF,MAAM,gBAAgB,MAAM,yBAAyB,eAAe,cAAc,SAAS;AAE3F,SADa,MAAM,iBAAiB,eAAe,cAAc,eAAe,IAAI;UAE7E,OAAO;AACd,QAAM,IAAI,MAAM,4CAA4C,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;ACpCjF,eAAsB,oBAA4C;AAChE,QAAO,eAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-search.d.mts","names":[],"sources":["../src/email-search/indexedDB.ts","../src/email-search/mailCache.ts","../src/email-search/search.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"email-search.d.mts","names":[],"sources":["../src/email-search/indexedDB.ts","../src/email-search/mailCache.ts","../src/email-search/search.ts"],"mappings":";;;;;KAMY,MAAA,GAAS,YAAA,CAAa,iBAAA;AAAA,UAEjB,iBAAA,SAA0B,QAAA;EACzC,KAAA;IACE,GAAA;IACA,KAAA,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,KAAA,UACA,OAAA,EAAS,SAAA,CAAU,KAAA,GACnB,WAAA,EAAa,gBAAA,EACb,OAAA,GAAS,aAAA,KACR,OAAA,CAAQ,iBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-search.d.ts","names":[],"sources":["../src/email-search/indexedDB.ts","../src/email-search/mailCache.ts","../src/email-search/search.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"email-search.d.ts","names":[],"sources":["../src/email-search/indexedDB.ts","../src/email-search/mailCache.ts","../src/email-search/search.ts"],"mappings":";;;;;KAMY,MAAA,GAAS,YAAA,CAAa,iBAAA;AAAA,UAEjB,iBAAA,SAA0B,QAAA;EACzC,KAAA;IACE,GAAA;IACA,KAAA,EAAO,WAAA;IACP,OAAA;MAAW,MAAA;IAAA;EAAA;AAAA;;;;;;;cAoBF,YAAA,GAAsB,MAAA,aAAiB,OAAA,CAAQ,MAAA;;;;;AAA5D;cAqBa,aAAA,GAAiB,IAAA,EAAM,MAAA;;;;;;;cAUvB,cAAA,GAAwB,MAAA,aAAiB,OAAA;AAVtD;;;;;AAUA;AAVA,cAqBa,cAAA,GAAwB,OAAA,EAAS,UAAA,KAAa,OAAA,CAAQ,UAAA;;;;AAAnE;;;;cAWa,oBAAA,GACX,eAAA,EAAiB,KAAA,EACjB,QAAA,EAAU,UAAA,EACV,IAAA,EAAM,MAAA,KACL,OAAA;;;;;;;;cAiBU,wBAAA,GACX,gBAAA,EAAkB,KAAA,IAClB,QAAA,EAAU,UAAA,EACV,IAAA,EAAM,MAAA,KACL,OAAA;;AAzBH;;;;;;;cAkEa,kBAAA,GAA4B,OAAA,UAAiB,QAAA,EAAU,UAAA,EAAY,IAAA,EAAM,MAAA,KAAS,OAAA,CAAQ,KAAA;;;;;;;;cAmB1F,sBAAA,GAAgC,QAAA,EAAU,UAAA,EAAY,IAAA,EAAM,MAAA,KAAS,OAAA,CAAQ,KAAA;;;AAhE1F;;;;cAuFa,WAAA,GAAqB,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