internxt-crypto 0.0.10-alpha → 0.0.11

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.
Files changed (148) hide show
  1. package/README.md +3 -4
  2. package/dist/asymmetric-crypto-BORmLhnx.js +143 -0
  3. package/dist/asymmetric-crypto-BORmLhnx.js.map +1 -0
  4. package/dist/asymmetric-crypto-CyXsV4XT.mjs +102 -0
  5. package/dist/asymmetric-crypto-CyXsV4XT.mjs.map +1 -0
  6. package/dist/asymmetric-crypto.d.mts +9 -3
  7. package/dist/asymmetric-crypto.d.ts +9 -3
  8. package/dist/asymmetric-crypto.js +8 -92
  9. package/dist/asymmetric-crypto.mjs +2 -84
  10. package/dist/chunk-DWirmd9C.mjs +18 -0
  11. package/dist/chunk-Dt-PWiN7.js +60 -0
  12. package/dist/constants-Ccp21E03.js +208 -0
  13. package/dist/constants-Ccp21E03.js.map +1 -0
  14. package/dist/constants-kTeX-2T0.mjs +34 -0
  15. package/dist/constants-kTeX-2T0.mjs.map +1 -0
  16. package/dist/constants.d.mts +5 -11
  17. package/dist/constants.d.ts +5 -11
  18. package/dist/constants.js +30 -79
  19. package/dist/constants.mjs +2 -41
  20. package/dist/derive-key-Be7hS-cN.mjs +751 -0
  21. package/dist/derive-key-Be7hS-cN.mjs.map +1 -0
  22. package/dist/derive-key-CBf2WxJd.js +2513 -0
  23. package/dist/derive-key-CBf2WxJd.js.map +1 -0
  24. package/dist/derive-key.d.mts +14 -8
  25. package/dist/derive-key.d.ts +14 -8
  26. package/dist/derive-key.js +15 -795
  27. package/dist/derive-key.mjs +5 -783
  28. package/dist/email-crypto-BrT98taw.js +617 -0
  29. package/dist/email-crypto-BrT98taw.js.map +1 -0
  30. package/dist/email-crypto-DJUEjTxA.mjs +534 -0
  31. package/dist/email-crypto-DJUEjTxA.mjs.map +1 -0
  32. package/dist/email-crypto.d.mts +58 -78
  33. package/dist/email-crypto.d.ts +58 -78
  34. package/dist/email-crypto.js +17 -1409
  35. package/dist/email-crypto.mjs +8 -1381
  36. package/dist/email-search.d.mts +39 -32
  37. package/dist/email-search.d.ts +39 -32
  38. package/dist/email-search.js +572 -540
  39. package/dist/email-search.js.map +1 -1
  40. package/dist/email-search.mjs +567 -539
  41. package/dist/email-search.mjs.map +1 -1
  42. package/dist/hash-BoqwNkcd.js +190 -0
  43. package/dist/hash-BoqwNkcd.js.map +1 -0
  44. package/dist/hash-CXeGAwai.mjs +131 -0
  45. package/dist/hash-CXeGAwai.mjs.map +1 -0
  46. package/dist/hash.d.mts +21 -15
  47. package/dist/hash.d.ts +21 -15
  48. package/dist/hash.js +11 -95
  49. package/dist/hash.mjs +2 -84
  50. package/dist/index-CQqgKsbX.d.ts +50 -0
  51. package/dist/index-CintVUbp.d.ts +97 -0
  52. package/dist/index-D5pBU_A5.d.mts +50 -0
  53. package/dist/index-MaOov-ag.d.mts +97 -0
  54. package/dist/index.d.mts +35 -18
  55. package/dist/index.d.ts +35 -18
  56. package/dist/index.js +103 -2685
  57. package/dist/index.mjs +15 -2538
  58. package/dist/keystore-crypto-B4yCVo9l.js +182 -0
  59. package/dist/keystore-crypto-B4yCVo9l.js.map +1 -0
  60. package/dist/keystore-crypto-Bjgriq9h.mjs +159 -0
  61. package/dist/keystore-crypto-Bjgriq9h.mjs.map +1 -0
  62. package/dist/keystore-crypto.d.mts +20 -46
  63. package/dist/keystore-crypto.d.ts +20 -46
  64. package/dist/keystore-crypto.js +11 -530
  65. package/dist/keystore-crypto.mjs +9 -501
  66. package/dist/keystore-service.d.mts +44 -78
  67. package/dist/keystore-service.d.ts +44 -78
  68. package/dist/keystore-service.js +113 -340
  69. package/dist/keystore-service.js.map +1 -1
  70. package/dist/keystore-service.mjs +107 -335
  71. package/dist/keystore-service.mjs.map +1 -1
  72. package/dist/post-quantum-crypto-CAi-cEkV.js +189 -0
  73. package/dist/post-quantum-crypto-CAi-cEkV.js.map +1 -0
  74. package/dist/post-quantum-crypto-Vv34t6gX.mjs +154 -0
  75. package/dist/post-quantum-crypto-Vv34t6gX.mjs.map +1 -0
  76. package/dist/post-quantum-crypto.d.mts +2 -72
  77. package/dist/post-quantum-crypto.d.ts +2 -72
  78. package/dist/post-quantum-crypto.js +13 -92
  79. package/dist/post-quantum-crypto.mjs +2 -89
  80. package/dist/storage-service-BgIK2aYZ.js +82 -0
  81. package/dist/storage-service-BgIK2aYZ.js.map +1 -0
  82. package/dist/storage-service-CubCbhY2.mjs +65 -0
  83. package/dist/storage-service-CubCbhY2.mjs.map +1 -0
  84. package/dist/storage-service.d.mts +2 -53
  85. package/dist/storage-service.d.ts +2 -53
  86. package/dist/storage-service.js +12 -68
  87. package/dist/storage-service.mjs +2 -66
  88. package/dist/symmetric-crypto-CrdS1Che.mjs +197 -0
  89. package/dist/symmetric-crypto-CrdS1Che.mjs.map +1 -0
  90. package/dist/symmetric-crypto-D65zB396.js +244 -0
  91. package/dist/symmetric-crypto-D65zB396.js.map +1 -0
  92. package/dist/symmetric-crypto.d.mts +12 -8
  93. package/dist/symmetric-crypto.d.ts +12 -8
  94. package/dist/symmetric-crypto.js +10 -142
  95. package/dist/symmetric-crypto.mjs +3 -133
  96. package/dist/types-52g887Zi.js +16 -0
  97. package/dist/types-52g887Zi.js.map +1 -0
  98. package/dist/types-BiEoleqw.mjs +10 -0
  99. package/dist/types-BiEoleqw.mjs.map +1 -0
  100. package/dist/types-Ds3ivE9W.d.ts +104 -0
  101. package/dist/types-DwQJtrTx.d.mts +104 -0
  102. package/dist/types.d.mts +2 -102
  103. package/dist/types.d.ts +2 -102
  104. package/dist/types.js +2 -13
  105. package/dist/types.mjs +2 -11
  106. package/dist/utils-CNs3cyDj.js +263 -0
  107. package/dist/utils-CNs3cyDj.js.map +1 -0
  108. package/dist/utils-DS04iUcX.mjs +173 -0
  109. package/dist/utils-DS04iUcX.mjs.map +1 -0
  110. package/dist/utils.d.mts +37 -78
  111. package/dist/utils.d.ts +37 -78
  112. package/dist/utils.js +16 -313
  113. package/dist/utils.mjs +2 -272
  114. package/package.json +15 -90
  115. package/dist/asymmetric-crypto.js.map +0 -1
  116. package/dist/asymmetric-crypto.mjs.map +0 -1
  117. package/dist/constants.js.map +0 -1
  118. package/dist/constants.mjs.map +0 -1
  119. package/dist/derive-key.js.map +0 -1
  120. package/dist/derive-key.mjs.map +0 -1
  121. package/dist/email-crypto.js.map +0 -1
  122. package/dist/email-crypto.mjs.map +0 -1
  123. package/dist/email-service.d.mts +0 -38
  124. package/dist/email-service.d.ts +0 -38
  125. package/dist/email-service.js +0 -154
  126. package/dist/email-service.js.map +0 -1
  127. package/dist/email-service.mjs +0 -147
  128. package/dist/email-service.mjs.map +0 -1
  129. package/dist/hash.js.map +0 -1
  130. package/dist/hash.mjs.map +0 -1
  131. package/dist/index.js.map +0 -1
  132. package/dist/index.mjs.map +0 -1
  133. package/dist/keystore-crypto.js.map +0 -1
  134. package/dist/keystore-crypto.mjs.map +0 -1
  135. package/dist/kyber768-B87rMQ7u.d.mts +0 -30
  136. package/dist/kyber768-B87rMQ7u.d.ts +0 -30
  137. package/dist/post-quantum-crypto.js.map +0 -1
  138. package/dist/post-quantum-crypto.mjs.map +0 -1
  139. package/dist/storage-service.js.map +0 -1
  140. package/dist/storage-service.mjs.map +0 -1
  141. package/dist/symmetric-crypto.js.map +0 -1
  142. package/dist/symmetric-crypto.mjs.map +0 -1
  143. package/dist/types.js.map +0 -1
  144. package/dist/types.mjs.map +0 -1
  145. package/dist/utils-BDaK_d6T.d.ts +0 -114
  146. package/dist/utils-v34IRTIx.d.mts +0 -114
  147. package/dist/utils.js.map +0 -1
  148. package/dist/utils.mjs.map +0 -1
@@ -1,114 +0,0 @@
1
- import { Email, UserWithPublicKeys, PrivateKeys, HybridEncryptedEmail, PublicKeys, PwdProtectedEmail, EmailPublicParameters } from './types.js';
2
-
3
- /**
4
- * Encrypts the email using hybrid encryption.
5
- *
6
- * @param email - The email to encrypt.
7
- * @param recipientPublicKeys - The public keys of the recipient.
8
- * @param senderPrivateKey - The private key of the sender.
9
- * @returns The encrypted email
10
- */
11
- declare function encryptEmailHybrid(email: Email, recipient: UserWithPublicKeys, senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail>;
12
- /**
13
- * Encrypts the email using hybrid encryption for multiple recipients.
14
- *
15
- * @param email - The email to encrypt.
16
- * @param recipients - The recipients with corresponding public keys.
17
- * @param senderPrivateKey - The private key of the sender.
18
- * @returns The set of encrypted email
19
- */
20
- declare function encryptEmailHybridForMultipleRecipients(email: Email, recipients: UserWithPublicKeys[], senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail[]>;
21
- /**
22
- * Decrypts the email using hybrid encryption.
23
- *
24
- * @param encryptedEmail - The encrypted email.
25
- * @param senderPublicKeys - The public key of the sender.
26
- * @param recipientPrivateKeys - The private key of the recipient.
27
- * @returns The decrypted email
28
- */
29
- declare function decryptEmailHybrid(encryptedEmail: HybridEncryptedEmail, senderPublicKeys: PublicKeys, recipientPrivateKeys: PrivateKeys): Promise<Email>;
30
-
31
- /**
32
- * Encrypts the email and its subject using hybrid encryption.
33
- *
34
- * @param email - The email to encrypt.
35
- * @param recipientPublicKeys - The public keys of the recipient.
36
- * @param senderPrivateKey - The private key of the sender.
37
- * @returns The encrypted email
38
- */
39
- declare function encryptEmailAndSubjectHybrid(email: Email, recipient: UserWithPublicKeys, senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail>;
40
- /**
41
- * Encrypts the email using hybrid encryption for multiple recipients.
42
- *
43
- * @param email - The email to encrypt.
44
- * @param recipients - The recipients with corresponding public keys.
45
- * @param senderPrivateKey - The private key of the sender.
46
- * @returns The set of encrypted email
47
- */
48
- declare function encryptEmailAndSubjectHybridForMultipleRecipients(email: Email, recipients: UserWithPublicKeys[], senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail[]>;
49
- /**
50
- * Decrypts the email using hybrid encryption.
51
- *
52
- * @param encryptedEmail - The encrypted email.
53
- * @param senderPublicKeys - The public key of the sender.
54
- * @param recipientPrivateKeys - The private key of the recipient.
55
- * @returns The decrypted email
56
- */
57
- declare function decryptEmailAndSubjectHybrid(encryptedEmail: HybridEncryptedEmail, senderPublicKeys: PublicKeys, recipientPrivateKeys: PrivateKeys): Promise<Email>;
58
-
59
- /**
60
- * Creates a password-protected email.
61
- *
62
- * @param email - The email to password-protect
63
- * @param password - The secret password shared among recipients.
64
- * @returns The password-protected email
65
- */
66
- declare function createPwdProtectedEmail(email: Email, password: string): Promise<PwdProtectedEmail>;
67
- /**
68
- * Opens a password-protected email.
69
- *
70
- * @param encryptedEmail - The encrypted email
71
- * @param password - The secret password shared among recipients.
72
- * @returns The decrypted email
73
- */
74
- declare function decryptPwdProtectedEmail(encryptedEmail: PwdProtectedEmail, password: string): Promise<Email>;
75
-
76
- /**
77
- * Creates a password-protected email and its subject.
78
- *
79
- * @param email - The email to password-protect
80
- * @param password - The secret password shared among recipients.
81
- * @returns The password-protected email with encrypted email subject
82
- */
83
- declare function createPwdProtectedEmailAndSubject(email: Email, password: string): Promise<PwdProtectedEmail>;
84
- /**
85
- * Opens a password-protected email.
86
- *
87
- * @param encryptedEmail - The encrypted email with encrypted email subject.
88
- * @param password - The secret password shared among recipients.
89
- * @returns The decrypted email and email subject
90
- */
91
- declare function decryptPwdProtectedEmailAndSubject(encryptedEmail: PwdProtectedEmail, password: string): Promise<Email>;
92
-
93
- /**
94
- * Creates an auxilary string from public fields of the email.
95
- *
96
- * @param params - The email public parameters.
97
- * @returns The resulting auxilary string
98
- */
99
- declare function getAux(params: EmailPublicParameters): string;
100
- /**
101
- * Creates an auxilary string from public fields of the email (except for subject field).
102
- *
103
- * @param params - The email public parameters.
104
- * @returns The resulting auxilary string
105
- */
106
- declare function getAuxWithoutSubject(params: EmailPublicParameters): string;
107
- /**
108
- * Creates a random email ID.
109
- *
110
- * @returns The resulting auxilary string
111
- */
112
- declare function generateEmailID(): string;
113
-
114
- export { encryptEmailHybridForMultipleRecipients as a, encryptEmailAndSubjectHybrid as b, encryptEmailAndSubjectHybridForMultipleRecipients as c, decryptEmailHybrid as d, encryptEmailHybrid as e, decryptEmailAndSubjectHybrid as f, createPwdProtectedEmail as g, decryptPwdProtectedEmail as h, createPwdProtectedEmailAndSubject as i, decryptPwdProtectedEmailAndSubject as j, getAux as k, getAuxWithoutSubject as l, generateEmailID as m };
@@ -1,114 +0,0 @@
1
- import { Email, UserWithPublicKeys, PrivateKeys, HybridEncryptedEmail, PublicKeys, PwdProtectedEmail, EmailPublicParameters } from './types.mjs';
2
-
3
- /**
4
- * Encrypts the email using hybrid encryption.
5
- *
6
- * @param email - The email to encrypt.
7
- * @param recipientPublicKeys - The public keys of the recipient.
8
- * @param senderPrivateKey - The private key of the sender.
9
- * @returns The encrypted email
10
- */
11
- declare function encryptEmailHybrid(email: Email, recipient: UserWithPublicKeys, senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail>;
12
- /**
13
- * Encrypts the email using hybrid encryption for multiple recipients.
14
- *
15
- * @param email - The email to encrypt.
16
- * @param recipients - The recipients with corresponding public keys.
17
- * @param senderPrivateKey - The private key of the sender.
18
- * @returns The set of encrypted email
19
- */
20
- declare function encryptEmailHybridForMultipleRecipients(email: Email, recipients: UserWithPublicKeys[], senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail[]>;
21
- /**
22
- * Decrypts the email using hybrid encryption.
23
- *
24
- * @param encryptedEmail - The encrypted email.
25
- * @param senderPublicKeys - The public key of the sender.
26
- * @param recipientPrivateKeys - The private key of the recipient.
27
- * @returns The decrypted email
28
- */
29
- declare function decryptEmailHybrid(encryptedEmail: HybridEncryptedEmail, senderPublicKeys: PublicKeys, recipientPrivateKeys: PrivateKeys): Promise<Email>;
30
-
31
- /**
32
- * Encrypts the email and its subject using hybrid encryption.
33
- *
34
- * @param email - The email to encrypt.
35
- * @param recipientPublicKeys - The public keys of the recipient.
36
- * @param senderPrivateKey - The private key of the sender.
37
- * @returns The encrypted email
38
- */
39
- declare function encryptEmailAndSubjectHybrid(email: Email, recipient: UserWithPublicKeys, senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail>;
40
- /**
41
- * Encrypts the email using hybrid encryption for multiple recipients.
42
- *
43
- * @param email - The email to encrypt.
44
- * @param recipients - The recipients with corresponding public keys.
45
- * @param senderPrivateKey - The private key of the sender.
46
- * @returns The set of encrypted email
47
- */
48
- declare function encryptEmailAndSubjectHybridForMultipleRecipients(email: Email, recipients: UserWithPublicKeys[], senderPrivateKey: PrivateKeys): Promise<HybridEncryptedEmail[]>;
49
- /**
50
- * Decrypts the email using hybrid encryption.
51
- *
52
- * @param encryptedEmail - The encrypted email.
53
- * @param senderPublicKeys - The public key of the sender.
54
- * @param recipientPrivateKeys - The private key of the recipient.
55
- * @returns The decrypted email
56
- */
57
- declare function decryptEmailAndSubjectHybrid(encryptedEmail: HybridEncryptedEmail, senderPublicKeys: PublicKeys, recipientPrivateKeys: PrivateKeys): Promise<Email>;
58
-
59
- /**
60
- * Creates a password-protected email.
61
- *
62
- * @param email - The email to password-protect
63
- * @param password - The secret password shared among recipients.
64
- * @returns The password-protected email
65
- */
66
- declare function createPwdProtectedEmail(email: Email, password: string): Promise<PwdProtectedEmail>;
67
- /**
68
- * Opens a password-protected email.
69
- *
70
- * @param encryptedEmail - The encrypted email
71
- * @param password - The secret password shared among recipients.
72
- * @returns The decrypted email
73
- */
74
- declare function decryptPwdProtectedEmail(encryptedEmail: PwdProtectedEmail, password: string): Promise<Email>;
75
-
76
- /**
77
- * Creates a password-protected email and its subject.
78
- *
79
- * @param email - The email to password-protect
80
- * @param password - The secret password shared among recipients.
81
- * @returns The password-protected email with encrypted email subject
82
- */
83
- declare function createPwdProtectedEmailAndSubject(email: Email, password: string): Promise<PwdProtectedEmail>;
84
- /**
85
- * Opens a password-protected email.
86
- *
87
- * @param encryptedEmail - The encrypted email with encrypted email subject.
88
- * @param password - The secret password shared among recipients.
89
- * @returns The decrypted email and email subject
90
- */
91
- declare function decryptPwdProtectedEmailAndSubject(encryptedEmail: PwdProtectedEmail, password: string): Promise<Email>;
92
-
93
- /**
94
- * Creates an auxilary string from public fields of the email.
95
- *
96
- * @param params - The email public parameters.
97
- * @returns The resulting auxilary string
98
- */
99
- declare function getAux(params: EmailPublicParameters): string;
100
- /**
101
- * Creates an auxilary string from public fields of the email (except for subject field).
102
- *
103
- * @param params - The email public parameters.
104
- * @returns The resulting auxilary string
105
- */
106
- declare function getAuxWithoutSubject(params: EmailPublicParameters): string;
107
- /**
108
- * Creates a random email ID.
109
- *
110
- * @returns The resulting auxilary string
111
- */
112
- declare function generateEmailID(): string;
113
-
114
- export { encryptEmailHybridForMultipleRecipients as a, encryptEmailAndSubjectHybrid as b, encryptEmailAndSubjectHybridForMultipleRecipients as c, decryptEmailHybrid as d, encryptEmailHybrid as e, decryptEmailAndSubjectHybrid as f, createPwdProtectedEmail as g, decryptPwdProtectedEmail as h, createPwdProtectedEmailAndSubject as i, decryptPwdProtectedEmailAndSubject as j, getAux as k, getAuxWithoutSubject as l, generateEmailID as m };
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/converters.ts","../src/constants.ts","../src/asymmetric-crypto/keys.ts","../src/utils/aesConverters.ts","../src/utils/keyConverters.ts","../src/utils/genMnemonic.ts"],"names":["bytesToHex","hexToBytes","bip39","wordlist"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,SAAS,gBAAgB,KAAA,EAA2B;AACzD,EAAA,OAAOA,oBAAW,KAAK,CAAA;AACzB;AAQO,SAAS,YAAY,GAAA,EAAyB;AACnD,EAAA,OAAO,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,GAAG,CAAA;AACrC;AAQO,SAAS,YAAY,KAAA,EAA2B;AACrD,EAAA,OAAO,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,KAAK,CAAA;AACvC;AAQO,SAAS,gBAAgB,GAAA,EAAyB;AACvD,EAAA,OAAOC,oBAAW,GAAG,CAAA;AACvB;AAQO,SAAS,mBAAmB,MAAA,EAA4B;AAC7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AChE,IAAA,MAAM,IAAA,GAAO,KAAK,SAAA,CAAU;AAAA,MAC1B,YAAA,EAAc,mBAAmB,iBAAiB,CAAA;AAAA,MAClD,cAAA,EAAgB,kBAAA,CAAmB,GAAA,CAAI,cAAc;AAAA,KACtD,CAAA;AACD,IAAA,MAAM,MAAA,GAAS,KAAK,IAAI,CAAA;AACxB,IAAA,OAAO,MAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,wDAAA,EAA0D,EAAE,KAAA,EAAO,OAAO,CAAA;AAAA,EAC5F;AACF;AC3NO,SAAS,YAAY,IAAA,EAAsB;AAChD,EAAA,OAAaC,gBAAA,CAAA,gBAAA,CAAiBC,kBAAU,IAAI,CAAA;AAC9C","file":"utils.js","sourcesContent":["import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\n/**\n * Converts a Uint8Array into a hexadecimal string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The hexadecimal string representation of the array.\n */\nexport function uint8ArrayToHex(array: Uint8Array): string {\n return bytesToHex(array);\n}\n\n/**\n * Converts a UTF-8 string into a Uint8Array.\n *\n * @param str - The UTF-8 string to convert.\n * @returns A Uint8Array created from the UTF-8 string.\n */\nexport function UTF8ToUint8(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n/**\n * Converts an Uint8Array into a UTF-8 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The UTF-8 string representation of the array.\n */\nexport function uint8ToUTF8(array: Uint8Array): string {\n return new TextDecoder().decode(array);\n}\n\n/**\n * Converts a hexadecimal string into a Uint8Array.\n *\n * @param hex - The hexadecimal string to convert.\n * @returns A Uint8Array created from the hex string.\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n return hexToBytes(hex);\n}\n\n/**\n * Converts a Uint8Array into a base64 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The base64 string representation of the array.\n */\nexport function uint8ArrayToBase64(buffer: Uint8Array): string {\n const array = Uint16Array.from(buffer);\n const binaryString = new TextDecoder('UTF-16').decode(array);\n return btoa(binaryString);\n}\n\n/**\n * Converts a base64 string into a Uint8Array.\n *\n * @param str - The base64 string to convert.\n * @returns A Uint8Array created from the base64 string.\n */\nexport function base64ToUint8Array(str: string): Uint8Array {\n const binaryString = atob(str);\n const len = binaryString.length;\n const array = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n array[i] = binaryString.charCodeAt(i);\n }\n return new Uint8Array(array.buffer);\n}\n","export const AES_ALGORITHM = 'AES-GCM';\nexport const AES_KEY_BIT_LENGTH = 256;\nexport const AUX_LEN = 128;\nexport const IV_LEN_BYTES = 16;\n\nexport const KEY_WRAPPING_ALGORITHM = 'AES-KW';\nexport const KEY_FORMAT = 'raw';\nexport const CONTEXT_WRAPPING = 'CRYPTO library 2025-08-22 18:10:00 key derived from ecc and kyber secrets';\n\nexport const ECC_ALGORITHM = 'X25519';\n\nexport const CONTEXT_LOGIN = 'CRYPTO library 2025-07-26 16:18:03 key for opening identity keystore';\nexport const CONTEXT_ENC_KEYSTORE = 'CRYPTO library 2025-07-30 16:18:03 key for opening encryption keys keystore';\nexport const CONTEXT_RECOVERY = 'CRYPTO library 2025-07-30 16:20:00 key for account recovery';\nexport const CONTEXT_INDEX = 'CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices';\nexport const CONTEXT_DERIVE = 'CRYPTO library 2025-08-27 17:08:00 derive one key from two keys';\n\nexport const PREFIX_MEDIA_KEY_COMMITMENT = 'CRYPTO library 2025-08-26 18:29:00 prefix for commitment to media keys';\nexport const PREFIX_PUBLIC_KEY_COMMITMENT = 'CRYPTO library 2025-08-26 18:30:00 prefix for commitment to public keys';\nexport const PREFIX_IDENTITY_KEY_COMMITMENT =\n 'CRYPTO library 2025-08-26 18:45:00 prefix for commitment to identity keys';\n\n// Second recommended parameter set from RFC 9106\nexport const ARGON2ID_PARALLELISM = 3;\nexport const ARGON2ID_ITERATIONS = 4;\nexport const ARGON2ID_MEMORY_SIZE = 65536;\nexport const ARGON2ID_SALT_BYTE_LENGTH = 16;\nexport const ARGON2ID_OUTPUT_BYTE_LENGTH = 32;\n\nexport const IDENTITY_KEYSTORE_TAG = 'Identity keystore';\nexport const ENCRYPTION_KEYSTORE_TAG = 'Encryption keystore';\nexport const RECOVERY_KEYSTORE_TAG = 'Key recovery keystroe';\nexport const INDEX_KEYSTORE_TAG = 'Current encrypted indices';\n\nexport const KYBER512_PUBLIC_KEY_LENGTH = 800;\nexport const KYBER512_SECRET_KEY_LENGTH = 1632;\n\nexport const KYBER768_PUBLIC_KEY_LENGTH = 1184;\nexport const KYBER768_SECRET_KEY_LENGTH = 2400;\n\nexport const KYBER1024_PUBLIC_KEY_LENGTH = 1568;\nexport const KYBER1024_SECRET_KEY_LENGTH = 3168;\n\nexport const KYBER_SEED_LENGTH = 64;\n\nexport const HASH_BIT_LEN = 256;\n\nexport const MAX_CACHE_SIZE = 600000000; // 600 MB\nexport const MAX_EMAIL_PER_BATCH = 100;\nexport const DB_LABEL = 'email';\nexport const DB_VERSION = 1;\n","import { ECC_ALGORITHM } from '../constants';\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<CryptoKeyPair> {\n try {\n return (await crypto.subtle.generateKey(\n {\n name: ECC_ALGORITHM,\n },\n true,\n ['deriveBits'],\n )) as CryptoKeyPair;\n } catch (error) {\n throw new Error('Failed to generate elliptic curve key pair', { cause: error });\n }\n}\n\n/**\n * Converts public CryptoKey into Uint8Array using SubjectPublicKeyInfo format (RFC 5280)\n *\n * @returns The Uint8Array representation of the public key\n */\nexport async function exportPublicKey(key: CryptoKey): Promise<Uint8Array> {\n try {\n const result = await crypto.subtle.exportKey('spki', key);\n return new Uint8Array(result);\n } catch (error) {\n throw new Error('Failed to export public key', { cause: error });\n }\n}\n\n/**\n * Converts public key in SubjectPublicKeyInfo format (RFC 5280) to CryptoKey\n *\n * @returns The CryptoKey representation of the public key\n */\nexport async function importPublicKey(spkiKeyData: Uint8Array): Promise<CryptoKey> {\n try {\n return await crypto.subtle.importKey(\n 'spki',\n spkiKeyData as BufferSource,\n {\n name: ECC_ALGORITHM,\n },\n true,\n [],\n );\n } catch (error) {\n throw new Error('Failed to import public key', { cause: error });\n }\n}\n\n/**\n * Converts private key in CryptoKey to PKCS #8 format (RFC 5208)\n *\n * @returns The Uint8Array representation of the private key\n */\nexport async function exportPrivateKey(key: CryptoKey): Promise<Uint8Array> {\n try {\n const result = await crypto.subtle.exportKey('pkcs8', key);\n return new Uint8Array(result);\n } catch (error) {\n throw new Error('Failed to export private key', { cause: error });\n }\n}\n\n/**\n * Converts private key in PKCS #8 format (RFC 5208) to CryptoKey\n *\n * @returns The CryptoKey representation of the private key\n */\nexport async function importPrivateKey(pkcs8KeyData: Uint8Array): Promise<CryptoKey> {\n try {\n return await crypto.subtle.importKey(\n 'pkcs8',\n pkcs8KeyData as BufferSource,\n {\n name: ECC_ALGORITHM,\n },\n true,\n ['deriveBits'],\n );\n } catch (error) {\n throw new Error('Failed to import private key', { cause: error });\n }\n}\n","import { uint8ArrayToBase64, base64ToUint8Array } from './converters';\nimport { SymmetricCiphertext } from '../types';\n\n/**\n * Converts encrypted message to base64 string\n *\n * @param encryptedMessage - The encrypted message\n * @returns The resulting base64 string.\n */\nexport function ciphertextToBase64(encryptedMessage: SymmetricCiphertext): string {\n try {\n const ivBase64 = uint8ArrayToBase64(encryptedMessage.iv);\n const ciphertextBase64 = uint8ArrayToBase64(encryptedMessage.ciphertext);\n const json = JSON.stringify({ ciphertext: ciphertextBase64, iv: ivBase64 });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert ciphertext to base64', { cause: error });\n }\n}\n\n/**\n * Converts base64 string to encrypted message\n *\n * @param base64 - The base64 representation of the encrypted message\n * @returns The resulting encrypted message.\n */\nexport function base64ToCiphertext(base64: string): SymmetricCiphertext {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const iv = base64ToUint8Array(obj.iv);\n const ciphertext = base64ToUint8Array(obj.ciphertext);\n const result: SymmetricCiphertext = {\n ciphertext,\n iv,\n };\n return result;\n } catch (error) {\n throw new Error('Failed to convert base64 to ciphertext', { cause: error });\n }\n}\n","import { uint8ArrayToBase64, base64ToUint8Array } from '.';\nimport { IdentityKeys, EncryptionKeys, EncryptedKeystore, MediaKeys, PublicKeys } from '../types';\nimport { exportPublicKey, exportPrivateKey, importPublicKey, importPrivateKey } from '../asymmetric-crypto';\nimport { base64ToCiphertext, ciphertextToBase64 } from './aesConverters';\n\n/**\n * Converts identity keys to base64\n *\n * @param keys - The identity keys\n * @returns The resulting base64 string\n */\nexport async function identityKeysToBase64(keys: IdentityKeys): Promise<string> {\n try {\n const pkArray = await exportPublicKey(keys.userPublicKey);\n const skArray = await exportPrivateKey(keys.userPrivateKey);\n const json = JSON.stringify({\n userPublicKey: uint8ArrayToBase64(pkArray),\n userPrivateKey: uint8ArrayToBase64(skArray),\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert identity keys to base64', { cause: error });\n }\n}\n\n/**\n * Converts encryption keys to base64\n *\n * @param keys - The encryption keys\n * @returns The resulting base64 string\n */\nexport async function encryptionKeysToBase64(keys: EncryptionKeys): Promise<string> {\n try {\n const pkArray = await exportPublicKey(keys.userPublicKey);\n const skArray = await exportPrivateKey(keys.userPrivateKey);\n const json = JSON.stringify({\n userPublicKey: uint8ArrayToBase64(pkArray),\n userPrivateKey: uint8ArrayToBase64(skArray),\n userPublicKyberKey: uint8ArrayToBase64(keys.userPublicKyberKey),\n userPrivateKyberKey: uint8ArrayToBase64(keys.userPrivateKyberKey),\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert identity keys to base64', { cause: error });\n }\n}\n\n/**\n * Converts encrypted keystore to base64\n *\n * @param keystore - The encrypted keystore\n * @returns The resulting base64 string\n */\nexport function encryptedKeystoreToBase64(keystore: EncryptedKeystore): string {\n try {\n const ciphertext = ciphertextToBase64(keystore.encryptedKeys);\n const json = JSON.stringify({\n userID: keystore.userID,\n type: keystore.type.toString(),\n encryptedKeys: ciphertext,\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert encrypted keystore to base64', { cause: error });\n }\n}\n\n/**\n * Converts base64 to identity keys\n *\n * @param base64 - The base64 input\n * @returns The resulting idenity keys\n */\nexport async function base64ToIdentityKeys(base64: string): Promise<IdentityKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const pkArray = base64ToUint8Array(obj.userPublicKey);\n const skArray = base64ToUint8Array(obj.userPrivateKey);\n const pkCryptoKey = await importPublicKey(pkArray);\n const skCryptoKey = await importPrivateKey(skArray);\n const result: IdentityKeys = {\n userPublicKey: pkCryptoKey,\n userPrivateKey: skCryptoKey,\n };\n return result;\n } catch (error) {\n throw new Error('Failed convert base64 to idenity key', { cause: error });\n }\n}\n\n/**\n * Converts base64 to encryption keys\n *\n * @param base64 - The base64 input\n * @returns The resulting encryption keys\n */\nexport async function base64ToEncryptionKeys(base64: string): Promise<EncryptionKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const pkArray = base64ToUint8Array(obj.userPublicKey);\n const skArray = base64ToUint8Array(obj.userPrivateKey);\n const pkCryptoKey = await importPublicKey(pkArray);\n const skCryptoKey = await importPrivateKey(skArray);\n const pkKyber = base64ToUint8Array(obj.userPublicKyberKey);\n const skKyber = base64ToUint8Array(obj.userPrivateKyberKey);\n const result: EncryptionKeys = {\n userPublicKey: pkCryptoKey,\n userPrivateKey: skCryptoKey,\n userPublicKyberKey: pkKyber,\n userPrivateKyberKey: skKyber,\n };\n return result;\n } catch (error) {\n throw new Error('Failed to convert base64 to encryption key', { cause: error });\n }\n}\n\n/**\n * Converts base64 to encrypted keystore\n *\n * @param base64 - The base64 input\n * @returns The resulting encrypted keystore\n */\nexport function base64ToEncryptedKeystore(base64: string): EncryptedKeystore {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const ciphertext = base64ToCiphertext(obj.encryptedKeys);\n const result: EncryptedKeystore = {\n userID: obj.userID,\n type: obj.type,\n encryptedKeys: ciphertext,\n };\n return result;\n } catch (error) {\n throw new Error('Failed to convert base64 to encrypted keystore', { cause: error });\n }\n}\n\n/**\n * Converts media keys to base64\n *\n * @param keys - The media keys\n * @returns The resulting base64 string\n */\nexport function mediaKeysToBase64(keys: MediaKeys): string {\n try {\n const json = JSON.stringify({\n olmKey: uint8ArrayToBase64(keys.olmKey),\n pqKey: uint8ArrayToBase64(keys.pqKey),\n index: keys.index.toString(),\n userID: keys.userID,\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert media keys to base64', { cause: error });\n }\n}\n\n/**\n * Converts base64 to media keys\n *\n * @param base64 - The base64 input\n * @returns The resulting media keys\n */\nexport async function base64ToMediaKeys(base64: string): Promise<MediaKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n\n const result: MediaKeys = {\n olmKey: base64ToUint8Array(obj.olmKey),\n pqKey: base64ToUint8Array(obj.pqKey),\n index: Number(obj.index),\n userID: obj.userID,\n };\n return result;\n } catch (error) {\n throw new Error('Failed convert base64 to media keys', { cause: error });\n }\n}\n\n/**\n * Converts a base64 string into PublicKeys type.\n *\n * @param base64 - The base64 representation of the public key.\n * @returns The resulting PublicKeys.\n */\nexport async function base64ToPublicKey(base64: string): Promise<PublicKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const eccPublicKeyBytes = base64ToUint8Array(obj.eccPublicKey);\n const eccPublicKey = await importPublicKey(eccPublicKeyBytes);\n const kyberPublicKey = base64ToUint8Array(obj.kyberPublicKey);\n return {\n eccPublicKey: eccPublicKey,\n kyberPublicKey: kyberPublicKey,\n };\n } catch (error) {\n throw new Error('Failed to convert base64 to PublicKeys', { cause: error });\n }\n}\n\n/**\n * Converts a PublicKeys type into base64 string.\n *\n * @param key - The PublicKeys key.\n * @returns The resulting base64 string.\n */\nexport async function publicKeyToBase64(key: PublicKeys): Promise<string> {\n try {\n const eccPublicKeyArray = await exportPublicKey(key.eccPublicKey);\n const json = JSON.stringify({\n eccPublicKey: uint8ArrayToBase64(eccPublicKeyArray),\n kyberPublicKey: uint8ArrayToBase64(key.kyberPublicKey),\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert key of the type PublicKeys to base64', { cause: error });\n }\n}\n","import * as bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n\n/**\n * Generates a mnemonic of required bit strength\n *\n * @param bits - The bit strength.\n * @returns The generated mnemonic.\n */\nexport function genMnemonic(bits: number): string {\n return bip39.generateMnemonic(wordlist, bits);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/converters.ts","../src/constants.ts","../src/asymmetric-crypto/keys.ts","../src/utils/aesConverters.ts","../src/utils/keyConverters.ts","../src/utils/genMnemonic.ts"],"names":[],"mappings":";;;;;AAQO,SAAS,gBAAgB,KAAA,EAA2B;AACzD,EAAA,OAAO,WAAW,KAAK,CAAA;AACzB;AAQO,SAAS,YAAY,GAAA,EAAyB;AACnD,EAAA,OAAO,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,GAAG,CAAA;AACrC;AAQO,SAAS,YAAY,KAAA,EAA2B;AACrD,EAAA,OAAO,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,KAAK,CAAA;AACvC;AAQO,SAAS,gBAAgB,GAAA,EAAyB;AACvD,EAAA,OAAO,WAAW,GAAG,CAAA;AACvB;AAQO,SAAS,mBAAmB,MAAA,EAA4B;AAC7D,EAAA,MAAM,KAAA,GAAQ,WAAA,CAAY,IAAA,CAAK,MAAM,CAAA;AACrC,EAAA,MAAM,eAAe,IAAI,WAAA,CAAY,QAAQ,CAAA,CAAE,OAAO,KAAK,CAAA;AAC3D,EAAA,OAAO,KAAK,YAAY,CAAA;AAC1B;AAQO,SAAS,mBAAmB,GAAA,EAAyB;AAC1D,EAAA,MAAM,YAA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AA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,wDAAA,EAA0D,EAAE,KAAA,EAAO,OAAO,CAAA;AAAA,EAC5F;AACF;AC3NO,SAAS,YAAY,IAAA,EAAsB;AAChD,EAAA,OAAa,KAAA,CAAA,gBAAA,CAAiB,UAAU,IAAI,CAAA;AAC9C","file":"utils.mjs","sourcesContent":["import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\n/**\n * Converts a Uint8Array into a hexadecimal string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The hexadecimal string representation of the array.\n */\nexport function uint8ArrayToHex(array: Uint8Array): string {\n return bytesToHex(array);\n}\n\n/**\n * Converts a UTF-8 string into a Uint8Array.\n *\n * @param str - The UTF-8 string to convert.\n * @returns A Uint8Array created from the UTF-8 string.\n */\nexport function UTF8ToUint8(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n/**\n * Converts an Uint8Array into a UTF-8 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The UTF-8 string representation of the array.\n */\nexport function uint8ToUTF8(array: Uint8Array): string {\n return new TextDecoder().decode(array);\n}\n\n/**\n * Converts a hexadecimal string into a Uint8Array.\n *\n * @param hex - The hexadecimal string to convert.\n * @returns A Uint8Array created from the hex string.\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n return hexToBytes(hex);\n}\n\n/**\n * Converts a Uint8Array into a base64 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The base64 string representation of the array.\n */\nexport function uint8ArrayToBase64(buffer: Uint8Array): string {\n const array = Uint16Array.from(buffer);\n const binaryString = new TextDecoder('UTF-16').decode(array);\n return btoa(binaryString);\n}\n\n/**\n * Converts a base64 string into a Uint8Array.\n *\n * @param str - The base64 string to convert.\n * @returns A Uint8Array created from the base64 string.\n */\nexport function base64ToUint8Array(str: string): Uint8Array {\n const binaryString = atob(str);\n const len = binaryString.length;\n const array = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n array[i] = binaryString.charCodeAt(i);\n }\n return new Uint8Array(array.buffer);\n}\n","export const AES_ALGORITHM = 'AES-GCM';\nexport const AES_KEY_BIT_LENGTH = 256;\nexport const AUX_LEN = 128;\nexport const IV_LEN_BYTES = 16;\n\nexport const KEY_WRAPPING_ALGORITHM = 'AES-KW';\nexport const KEY_FORMAT = 'raw';\nexport const CONTEXT_WRAPPING = 'CRYPTO library 2025-08-22 18:10:00 key derived from ecc and kyber secrets';\n\nexport const ECC_ALGORITHM = 'X25519';\n\nexport const CONTEXT_LOGIN = 'CRYPTO library 2025-07-26 16:18:03 key for opening identity keystore';\nexport const CONTEXT_ENC_KEYSTORE = 'CRYPTO library 2025-07-30 16:18:03 key for opening encryption keys keystore';\nexport const CONTEXT_RECOVERY = 'CRYPTO library 2025-07-30 16:20:00 key for account recovery';\nexport const CONTEXT_INDEX = 'CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices';\nexport const CONTEXT_DERIVE = 'CRYPTO library 2025-08-27 17:08:00 derive one key from two keys';\n\nexport const PREFIX_MEDIA_KEY_COMMITMENT = 'CRYPTO library 2025-08-26 18:29:00 prefix for commitment to media keys';\nexport const PREFIX_PUBLIC_KEY_COMMITMENT = 'CRYPTO library 2025-08-26 18:30:00 prefix for commitment to public keys';\nexport const PREFIX_IDENTITY_KEY_COMMITMENT =\n 'CRYPTO library 2025-08-26 18:45:00 prefix for commitment to identity keys';\n\n// Second recommended parameter set from RFC 9106\nexport const ARGON2ID_PARALLELISM = 3;\nexport const ARGON2ID_ITERATIONS = 4;\nexport const ARGON2ID_MEMORY_SIZE = 65536;\nexport const ARGON2ID_SALT_BYTE_LENGTH = 16;\nexport const ARGON2ID_OUTPUT_BYTE_LENGTH = 32;\n\nexport const IDENTITY_KEYSTORE_TAG = 'Identity keystore';\nexport const ENCRYPTION_KEYSTORE_TAG = 'Encryption keystore';\nexport const RECOVERY_KEYSTORE_TAG = 'Key recovery keystroe';\nexport const INDEX_KEYSTORE_TAG = 'Current encrypted indices';\n\nexport const KYBER512_PUBLIC_KEY_LENGTH = 800;\nexport const KYBER512_SECRET_KEY_LENGTH = 1632;\n\nexport const KYBER768_PUBLIC_KEY_LENGTH = 1184;\nexport const KYBER768_SECRET_KEY_LENGTH = 2400;\n\nexport const KYBER1024_PUBLIC_KEY_LENGTH = 1568;\nexport const KYBER1024_SECRET_KEY_LENGTH = 3168;\n\nexport const KYBER_SEED_LENGTH = 64;\n\nexport const HASH_BIT_LEN = 256;\n\nexport const MAX_CACHE_SIZE = 600000000; // 600 MB\nexport const MAX_EMAIL_PER_BATCH = 100;\nexport const DB_LABEL = 'email';\nexport const DB_VERSION = 1;\n","import { ECC_ALGORITHM } from '../constants';\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<CryptoKeyPair> {\n try {\n return (await crypto.subtle.generateKey(\n {\n name: ECC_ALGORITHM,\n },\n true,\n ['deriveBits'],\n )) as CryptoKeyPair;\n } catch (error) {\n throw new Error('Failed to generate elliptic curve key pair', { cause: error });\n }\n}\n\n/**\n * Converts public CryptoKey into Uint8Array using SubjectPublicKeyInfo format (RFC 5280)\n *\n * @returns The Uint8Array representation of the public key\n */\nexport async function exportPublicKey(key: CryptoKey): Promise<Uint8Array> {\n try {\n const result = await crypto.subtle.exportKey('spki', key);\n return new Uint8Array(result);\n } catch (error) {\n throw new Error('Failed to export public key', { cause: error });\n }\n}\n\n/**\n * Converts public key in SubjectPublicKeyInfo format (RFC 5280) to CryptoKey\n *\n * @returns The CryptoKey representation of the public key\n */\nexport async function importPublicKey(spkiKeyData: Uint8Array): Promise<CryptoKey> {\n try {\n return await crypto.subtle.importKey(\n 'spki',\n spkiKeyData as BufferSource,\n {\n name: ECC_ALGORITHM,\n },\n true,\n [],\n );\n } catch (error) {\n throw new Error('Failed to import public key', { cause: error });\n }\n}\n\n/**\n * Converts private key in CryptoKey to PKCS #8 format (RFC 5208)\n *\n * @returns The Uint8Array representation of the private key\n */\nexport async function exportPrivateKey(key: CryptoKey): Promise<Uint8Array> {\n try {\n const result = await crypto.subtle.exportKey('pkcs8', key);\n return new Uint8Array(result);\n } catch (error) {\n throw new Error('Failed to export private key', { cause: error });\n }\n}\n\n/**\n * Converts private key in PKCS #8 format (RFC 5208) to CryptoKey\n *\n * @returns The CryptoKey representation of the private key\n */\nexport async function importPrivateKey(pkcs8KeyData: Uint8Array): Promise<CryptoKey> {\n try {\n return await crypto.subtle.importKey(\n 'pkcs8',\n pkcs8KeyData as BufferSource,\n {\n name: ECC_ALGORITHM,\n },\n true,\n ['deriveBits'],\n );\n } catch (error) {\n throw new Error('Failed to import private key', { cause: error });\n }\n}\n","import { uint8ArrayToBase64, base64ToUint8Array } from './converters';\nimport { SymmetricCiphertext } from '../types';\n\n/**\n * Converts encrypted message to base64 string\n *\n * @param encryptedMessage - The encrypted message\n * @returns The resulting base64 string.\n */\nexport function ciphertextToBase64(encryptedMessage: SymmetricCiphertext): string {\n try {\n const ivBase64 = uint8ArrayToBase64(encryptedMessage.iv);\n const ciphertextBase64 = uint8ArrayToBase64(encryptedMessage.ciphertext);\n const json = JSON.stringify({ ciphertext: ciphertextBase64, iv: ivBase64 });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert ciphertext to base64', { cause: error });\n }\n}\n\n/**\n * Converts base64 string to encrypted message\n *\n * @param base64 - The base64 representation of the encrypted message\n * @returns The resulting encrypted message.\n */\nexport function base64ToCiphertext(base64: string): SymmetricCiphertext {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const iv = base64ToUint8Array(obj.iv);\n const ciphertext = base64ToUint8Array(obj.ciphertext);\n const result: SymmetricCiphertext = {\n ciphertext,\n iv,\n };\n return result;\n } catch (error) {\n throw new Error('Failed to convert base64 to ciphertext', { cause: error });\n }\n}\n","import { uint8ArrayToBase64, base64ToUint8Array } from '.';\nimport { IdentityKeys, EncryptionKeys, EncryptedKeystore, MediaKeys, PublicKeys } from '../types';\nimport { exportPublicKey, exportPrivateKey, importPublicKey, importPrivateKey } from '../asymmetric-crypto';\nimport { base64ToCiphertext, ciphertextToBase64 } from './aesConverters';\n\n/**\n * Converts identity keys to base64\n *\n * @param keys - The identity keys\n * @returns The resulting base64 string\n */\nexport async function identityKeysToBase64(keys: IdentityKeys): Promise<string> {\n try {\n const pkArray = await exportPublicKey(keys.userPublicKey);\n const skArray = await exportPrivateKey(keys.userPrivateKey);\n const json = JSON.stringify({\n userPublicKey: uint8ArrayToBase64(pkArray),\n userPrivateKey: uint8ArrayToBase64(skArray),\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert identity keys to base64', { cause: error });\n }\n}\n\n/**\n * Converts encryption keys to base64\n *\n * @param keys - The encryption keys\n * @returns The resulting base64 string\n */\nexport async function encryptionKeysToBase64(keys: EncryptionKeys): Promise<string> {\n try {\n const pkArray = await exportPublicKey(keys.userPublicKey);\n const skArray = await exportPrivateKey(keys.userPrivateKey);\n const json = JSON.stringify({\n userPublicKey: uint8ArrayToBase64(pkArray),\n userPrivateKey: uint8ArrayToBase64(skArray),\n userPublicKyberKey: uint8ArrayToBase64(keys.userPublicKyberKey),\n userPrivateKyberKey: uint8ArrayToBase64(keys.userPrivateKyberKey),\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert identity keys to base64', { cause: error });\n }\n}\n\n/**\n * Converts encrypted keystore to base64\n *\n * @param keystore - The encrypted keystore\n * @returns The resulting base64 string\n */\nexport function encryptedKeystoreToBase64(keystore: EncryptedKeystore): string {\n try {\n const ciphertext = ciphertextToBase64(keystore.encryptedKeys);\n const json = JSON.stringify({\n userID: keystore.userID,\n type: keystore.type.toString(),\n encryptedKeys: ciphertext,\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert encrypted keystore to base64', { cause: error });\n }\n}\n\n/**\n * Converts base64 to identity keys\n *\n * @param base64 - The base64 input\n * @returns The resulting idenity keys\n */\nexport async function base64ToIdentityKeys(base64: string): Promise<IdentityKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const pkArray = base64ToUint8Array(obj.userPublicKey);\n const skArray = base64ToUint8Array(obj.userPrivateKey);\n const pkCryptoKey = await importPublicKey(pkArray);\n const skCryptoKey = await importPrivateKey(skArray);\n const result: IdentityKeys = {\n userPublicKey: pkCryptoKey,\n userPrivateKey: skCryptoKey,\n };\n return result;\n } catch (error) {\n throw new Error('Failed convert base64 to idenity key', { cause: error });\n }\n}\n\n/**\n * Converts base64 to encryption keys\n *\n * @param base64 - The base64 input\n * @returns The resulting encryption keys\n */\nexport async function base64ToEncryptionKeys(base64: string): Promise<EncryptionKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const pkArray = base64ToUint8Array(obj.userPublicKey);\n const skArray = base64ToUint8Array(obj.userPrivateKey);\n const pkCryptoKey = await importPublicKey(pkArray);\n const skCryptoKey = await importPrivateKey(skArray);\n const pkKyber = base64ToUint8Array(obj.userPublicKyberKey);\n const skKyber = base64ToUint8Array(obj.userPrivateKyberKey);\n const result: EncryptionKeys = {\n userPublicKey: pkCryptoKey,\n userPrivateKey: skCryptoKey,\n userPublicKyberKey: pkKyber,\n userPrivateKyberKey: skKyber,\n };\n return result;\n } catch (error) {\n throw new Error('Failed to convert base64 to encryption key', { cause: error });\n }\n}\n\n/**\n * Converts base64 to encrypted keystore\n *\n * @param base64 - The base64 input\n * @returns The resulting encrypted keystore\n */\nexport function base64ToEncryptedKeystore(base64: string): EncryptedKeystore {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const ciphertext = base64ToCiphertext(obj.encryptedKeys);\n const result: EncryptedKeystore = {\n userID: obj.userID,\n type: obj.type,\n encryptedKeys: ciphertext,\n };\n return result;\n } catch (error) {\n throw new Error('Failed to convert base64 to encrypted keystore', { cause: error });\n }\n}\n\n/**\n * Converts media keys to base64\n *\n * @param keys - The media keys\n * @returns The resulting base64 string\n */\nexport function mediaKeysToBase64(keys: MediaKeys): string {\n try {\n const json = JSON.stringify({\n olmKey: uint8ArrayToBase64(keys.olmKey),\n pqKey: uint8ArrayToBase64(keys.pqKey),\n index: keys.index.toString(),\n userID: keys.userID,\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert media keys to base64', { cause: error });\n }\n}\n\n/**\n * Converts base64 to media keys\n *\n * @param base64 - The base64 input\n * @returns The resulting media keys\n */\nexport async function base64ToMediaKeys(base64: string): Promise<MediaKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n\n const result: MediaKeys = {\n olmKey: base64ToUint8Array(obj.olmKey),\n pqKey: base64ToUint8Array(obj.pqKey),\n index: Number(obj.index),\n userID: obj.userID,\n };\n return result;\n } catch (error) {\n throw new Error('Failed convert base64 to media keys', { cause: error });\n }\n}\n\n/**\n * Converts a base64 string into PublicKeys type.\n *\n * @param base64 - The base64 representation of the public key.\n * @returns The resulting PublicKeys.\n */\nexport async function base64ToPublicKey(base64: string): Promise<PublicKeys> {\n try {\n const json = atob(base64);\n const obj = JSON.parse(json);\n const eccPublicKeyBytes = base64ToUint8Array(obj.eccPublicKey);\n const eccPublicKey = await importPublicKey(eccPublicKeyBytes);\n const kyberPublicKey = base64ToUint8Array(obj.kyberPublicKey);\n return {\n eccPublicKey: eccPublicKey,\n kyberPublicKey: kyberPublicKey,\n };\n } catch (error) {\n throw new Error('Failed to convert base64 to PublicKeys', { cause: error });\n }\n}\n\n/**\n * Converts a PublicKeys type into base64 string.\n *\n * @param key - The PublicKeys key.\n * @returns The resulting base64 string.\n */\nexport async function publicKeyToBase64(key: PublicKeys): Promise<string> {\n try {\n const eccPublicKeyArray = await exportPublicKey(key.eccPublicKey);\n const json = JSON.stringify({\n eccPublicKey: uint8ArrayToBase64(eccPublicKeyArray),\n kyberPublicKey: uint8ArrayToBase64(key.kyberPublicKey),\n });\n const base64 = btoa(json);\n return base64;\n } catch (error) {\n throw new Error('Failed to convert key of the type PublicKeys to base64', { cause: error });\n }\n}\n","import * as bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n\n/**\n * Generates a mnemonic of required bit strength\n *\n * @param bits - The bit strength.\n * @returns The generated mnemonic.\n */\nexport function genMnemonic(bits: number): string {\n return bip39.generateMnemonic(wordlist, bits);\n}\n"]}