internxt-crypto 0.0.9-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 (120) 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 +47 -0
  7. package/dist/asymmetric-crypto.d.ts +47 -0
  8. package/dist/asymmetric-crypto.js +8 -0
  9. package/dist/asymmetric-crypto.mjs +3 -0
  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 +33 -0
  17. package/dist/constants.d.ts +33 -0
  18. package/dist/constants.js +31 -0
  19. package/dist/constants.mjs +3 -0
  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 +97 -0
  25. package/dist/derive-key.d.ts +97 -0
  26. package/dist/derive-key.js +15 -0
  27. package/dist/derive-key.mjs +6 -0
  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 +86 -0
  33. package/dist/email-crypto.d.ts +86 -0
  34. package/dist/email-crypto.js +17 -0
  35. package/dist/email-crypto.mjs +8 -0
  36. package/dist/email-search.d.mts +235 -0
  37. package/dist/email-search.d.ts +235 -0
  38. package/dist/email-search.js +637 -0
  39. package/dist/email-search.js.map +1 -0
  40. package/dist/email-search.mjs +608 -0
  41. package/dist/email-search.mjs.map +1 -0
  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 +65 -0
  47. package/dist/hash.d.ts +65 -0
  48. package/dist/hash.js +11 -0
  49. package/dist/hash.mjs +3 -0
  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 +52 -0
  55. package/dist/index.d.ts +52 -0
  56. package/dist/index.js +116 -2055
  57. package/dist/index.mjs +15 -8712
  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 +40 -0
  63. package/dist/keystore-crypto.d.ts +40 -0
  64. package/dist/keystore-crypto.js +11 -0
  65. package/dist/keystore-crypto.mjs +9 -0
  66. package/dist/keystore-service.d.mts +48 -0
  67. package/dist/keystore-service.d.ts +48 -0
  68. package/dist/keystore-service.js +122 -0
  69. package/dist/keystore-service.js.map +1 -0
  70. package/dist/keystore-service.mjs +114 -0
  71. package/dist/keystore-service.mjs.map +1 -0
  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 -0
  77. package/dist/post-quantum-crypto.d.ts +2 -0
  78. package/dist/post-quantum-crypto.js +17 -0
  79. package/dist/post-quantum-crypto.mjs +3 -0
  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 -0
  85. package/dist/storage-service.d.ts +2 -0
  86. package/dist/storage-service.js +14 -0
  87. package/dist/storage-service.mjs +3 -0
  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 +60 -0
  93. package/dist/symmetric-crypto.d.ts +60 -0
  94. package/dist/symmetric-crypto.js +10 -0
  95. package/dist/symmetric-crypto.mjs +4 -0
  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 -0
  103. package/dist/types.d.ts +2 -0
  104. package/dist/types.js +3 -0
  105. package/dist/types.mjs +3 -0
  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 +99 -0
  111. package/dist/utils.d.ts +99 -0
  112. package/dist/utils.js +16 -0
  113. package/dist/utils.mjs +3 -0
  114. package/package.json +12 -11
  115. package/dist/__vite-browser-external-Dyvby5gX.js +0 -2
  116. package/dist/__vite-browser-external-Dyvby5gX.js.map +0 -1
  117. package/dist/__vite-browser-external-l0sNRNKZ.mjs +0 -2
  118. package/dist/__vite-browser-external-l0sNRNKZ.mjs.map +0 -1
  119. package/dist/index.js.map +0 -1
  120. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,60 @@
1
+ //#region src/symmetric-crypto/keys.d.ts
2
+ /**
3
+ * Converts Uint8Array into CryptoKey
4
+ *
5
+ * @param keyData - The Uint8Array representation of the symmetric key
6
+ * @returns The resulting symmetric CryptoKey.
7
+ */
8
+ declare function importSymmetricCryptoKey(keyData: Uint8Array | ArrayBuffer): Promise<CryptoKey>;
9
+ /**
10
+ * Converts CryptoKey into Uint8Array
11
+ *
12
+ * @param key - The symmetric CryptoKey
13
+ * @returns The resulting Uint8Array.
14
+ */
15
+ declare function exportSymmetricCryptoKey(key: CryptoKey): Promise<Uint8Array>;
16
+ /**
17
+ * Generates symmetric CryptoKey
18
+ *
19
+ * @returns The generated CryptoKey.
20
+ */
21
+ declare function genSymmetricCryptoKey(): Promise<CryptoKey>;
22
+ /**
23
+ * Generates symmetric key as Uint8Array
24
+ *
25
+ * @returns The generated Uint8Array.
26
+ */
27
+ declare function genSymmetricKey(): Uint8Array;
28
+ /**
29
+ * Derives CryptoKey from the given key material
30
+ *
31
+ * @returns The derived CryptoKey.
32
+ */
33
+ declare function deriveSymmetricCryptoKey(keyMaterial: Uint8Array): Promise<CryptoKey>;
34
+ //#endregion
35
+ //#region src/symmetric-crypto/aes.d.ts
36
+ /**
37
+ * Symmetrically encrypts the message
38
+ *
39
+ * @param encryptionKey - The symmetric CryptoKey used for message encryption
40
+ * @param message - The message to encrypt
41
+ * @param freeField - The context of the message (required for IV generation)
42
+ * @param aux - The auxilary string
43
+ * @returns The resulting ciphertext.
44
+ */
45
+ declare function encryptSymmetrically(encryptionKey: CryptoKey, message: Uint8Array, aux: Uint8Array, freeField?: Uint8Array): Promise<Uint8Array>;
46
+ /**
47
+ * Decryps symmetrically encrypted message
48
+ *
49
+ * @param encryptionKey - The symmetric CryptoKey used for message encryption
50
+ * @param encryptedMessage - The ciphertext
51
+ * @param aux - The auxilary string
52
+ * @returns The resulting ciphertext.
53
+ */
54
+ declare function decryptSymmetrically(encryptionKey: CryptoKey, encryptedMessage: Uint8Array, aux: Uint8Array): Promise<Uint8Array>;
55
+ declare namespace index_d_exports {
56
+ export { decryptSymmetrically, deriveSymmetricCryptoKey, encryptSymmetrically, exportSymmetricCryptoKey, genSymmetricCryptoKey, genSymmetricKey, importSymmetricCryptoKey };
57
+ }
58
+ //#endregion
59
+ export { decryptSymmetrically, deriveSymmetricCryptoKey, encryptSymmetrically, exportSymmetricCryptoKey, genSymmetricCryptoKey, genSymmetricKey, importSymmetricCryptoKey, index_d_exports as t };
60
+ //# sourceMappingURL=symmetric-crypto.d.mts.map
@@ -0,0 +1,60 @@
1
+ //#region src/symmetric-crypto/keys.d.ts
2
+ /**
3
+ * Converts Uint8Array into CryptoKey
4
+ *
5
+ * @param keyData - The Uint8Array representation of the symmetric key
6
+ * @returns The resulting symmetric CryptoKey.
7
+ */
8
+ declare function importSymmetricCryptoKey(keyData: Uint8Array | ArrayBuffer): Promise<CryptoKey>;
9
+ /**
10
+ * Converts CryptoKey into Uint8Array
11
+ *
12
+ * @param key - The symmetric CryptoKey
13
+ * @returns The resulting Uint8Array.
14
+ */
15
+ declare function exportSymmetricCryptoKey(key: CryptoKey): Promise<Uint8Array>;
16
+ /**
17
+ * Generates symmetric CryptoKey
18
+ *
19
+ * @returns The generated CryptoKey.
20
+ */
21
+ declare function genSymmetricCryptoKey(): Promise<CryptoKey>;
22
+ /**
23
+ * Generates symmetric key as Uint8Array
24
+ *
25
+ * @returns The generated Uint8Array.
26
+ */
27
+ declare function genSymmetricKey(): Uint8Array;
28
+ /**
29
+ * Derives CryptoKey from the given key material
30
+ *
31
+ * @returns The derived CryptoKey.
32
+ */
33
+ declare function deriveSymmetricCryptoKey(keyMaterial: Uint8Array): Promise<CryptoKey>;
34
+ //#endregion
35
+ //#region src/symmetric-crypto/aes.d.ts
36
+ /**
37
+ * Symmetrically encrypts the message
38
+ *
39
+ * @param encryptionKey - The symmetric CryptoKey used for message encryption
40
+ * @param message - The message to encrypt
41
+ * @param freeField - The context of the message (required for IV generation)
42
+ * @param aux - The auxilary string
43
+ * @returns The resulting ciphertext.
44
+ */
45
+ declare function encryptSymmetrically(encryptionKey: CryptoKey, message: Uint8Array, aux: Uint8Array, freeField?: Uint8Array): Promise<Uint8Array>;
46
+ /**
47
+ * Decryps symmetrically encrypted message
48
+ *
49
+ * @param encryptionKey - The symmetric CryptoKey used for message encryption
50
+ * @param encryptedMessage - The ciphertext
51
+ * @param aux - The auxilary string
52
+ * @returns The resulting ciphertext.
53
+ */
54
+ declare function decryptSymmetrically(encryptionKey: CryptoKey, encryptedMessage: Uint8Array, aux: Uint8Array): Promise<Uint8Array>;
55
+ declare namespace index_d_exports {
56
+ export { decryptSymmetrically, deriveSymmetricCryptoKey, encryptSymmetrically, exportSymmetricCryptoKey, genSymmetricCryptoKey, genSymmetricKey, importSymmetricCryptoKey };
57
+ }
58
+ //#endregion
59
+ export { decryptSymmetrically, deriveSymmetricCryptoKey, encryptSymmetrically, exportSymmetricCryptoKey, genSymmetricCryptoKey, genSymmetricKey, importSymmetricCryptoKey, index_d_exports as t };
60
+ //# sourceMappingURL=symmetric-crypto.d.ts.map
@@ -0,0 +1,10 @@
1
+ require('./hash-BoqwNkcd.js');
2
+ const require_symmetric_crypto = require('./symmetric-crypto-D65zB396.js');
3
+
4
+ exports.decryptSymmetrically = require_symmetric_crypto.decryptSymmetrically;
5
+ exports.deriveSymmetricCryptoKey = require_symmetric_crypto.deriveSymmetricCryptoKey;
6
+ exports.encryptSymmetrically = require_symmetric_crypto.encryptSymmetrically;
7
+ exports.exportSymmetricCryptoKey = require_symmetric_crypto.exportSymmetricCryptoKey;
8
+ exports.genSymmetricCryptoKey = require_symmetric_crypto.genSymmetricCryptoKey;
9
+ exports.genSymmetricKey = require_symmetric_crypto.genSymmetricKey;
10
+ exports.importSymmetricCryptoKey = require_symmetric_crypto.importSymmetricCryptoKey;
@@ -0,0 +1,4 @@
1
+ import "./hash-CXeGAwai.mjs";
2
+ import { a as exportSymmetricCryptoKey, c as importSymmetricCryptoKey, i as deriveSymmetricCryptoKey, n as decryptSymmetrically, o as genSymmetricCryptoKey, r as encryptSymmetrically, s as genSymmetricKey } from "./symmetric-crypto-CrdS1Che.mjs";
3
+
4
+ export { decryptSymmetrically, deriveSymmetricCryptoKey, encryptSymmetrically, exportSymmetricCryptoKey, genSymmetricCryptoKey, genSymmetricKey, importSymmetricCryptoKey };
@@ -0,0 +1,16 @@
1
+
2
+ //#region src/types.ts
3
+ let KeystoreType = /* @__PURE__ */ function(KeystoreType) {
4
+ KeystoreType["ENCRYPTION"] = "Encryption";
5
+ KeystoreType["RECOVERY"] = "Recovery";
6
+ return KeystoreType;
7
+ }({});
8
+
9
+ //#endregion
10
+ Object.defineProperty(exports, 'KeystoreType', {
11
+ enumerable: true,
12
+ get: function () {
13
+ return KeystoreType;
14
+ }
15
+ });
16
+ //# sourceMappingURL=types-52g887Zi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-52g887Zi.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type EncryptedKeystore = {\n userEmail: string;\n type: KeystoreType;\n encryptedKeys: EmailKeysEncrypted;\n};\n\nexport type User = {\n email: string;\n name: string;\n};\n\nexport type UserWithPublicKeys = User & {\n publicKeys: PublicKeys;\n};\n\nexport type PublicKeys = {\n eccPublicKey: CryptoKey;\n kyberPublicKey: Uint8Array;\n};\n\nexport type PublicKeysBase64 = {\n eccPublicKeyBase64: string;\n kyberPublicKeyBase64: string;\n};\n\nexport type PrivateKeys = {\n eccPrivateKey: CryptoKey;\n kyberPrivateKey: Uint8Array;\n};\n\nexport type PrivateKeysEncrypted = {\n eccPrivateKeyBase64: string;\n kyberPrivateKeyBase64: string;\n};\n\nexport type EmailKeys = {\n publicKeys: PublicKeys;\n privateKeys: PrivateKeys;\n};\n\nexport type EmailKeysEncrypted = {\n publicKeys: PublicKeysBase64;\n privateKeys: PrivateKeysEncrypted;\n};\n\nexport type HybridEncryptedEmail = {\n encryptedKey: HybridEncKey;\n enc: EmailBodyEncrypted;\n recipientEmail: string;\n params: EmailPublicParameters;\n id: string;\n isSubjectEncrypted: boolean;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n enc: EmailBodyEncrypted;\n params: EmailPublicParameters;\n id: string;\n isSubjectEncrypted: boolean;\n};\n\nexport type StoredEmail = {\n params: EmailPublicParameters;\n enc: EmailBodyEncrypted;\n id: string;\n};\n\nexport type HybridEncKey = {\n kyberCiphertext: string;\n encryptedKey: string;\n};\n\nexport type PwdProtectedKey = {\n encryptedKey: string;\n salt: string;\n};\n\nexport type EmailBodyEncrypted = {\n encText: string;\n encAttachments?: string[];\n};\n\nexport type EmailBody = {\n text: string;\n attachments?: string[];\n};\n\nexport type EmailPublicParameters = {\n subject: string;\n createdAt: string;\n sender: User;\n recipient: User;\n recipients?: User[];\n replyToEmailID?: string;\n labels?: string[];\n};\n\nexport type Email = {\n id: string;\n body: EmailBody;\n params: EmailPublicParameters;\n};\n\nexport interface MailCache<Email> {\n esCache: Map<string, Email>;\n cacheSize: number;\n isCacheLimited: boolean;\n isCacheReady: boolean;\n}\nexport interface EmailSearchResult {\n email: Email;\n score?: number;\n}\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":";;AAmHA,IAAY,sDAAL;AACL;AACA"}
@@ -0,0 +1,10 @@
1
+ //#region src/types.ts
2
+ let KeystoreType = /* @__PURE__ */ function(KeystoreType) {
3
+ KeystoreType["ENCRYPTION"] = "Encryption";
4
+ KeystoreType["RECOVERY"] = "Recovery";
5
+ return KeystoreType;
6
+ }({});
7
+
8
+ //#endregion
9
+ export { KeystoreType as t };
10
+ //# sourceMappingURL=types-BiEoleqw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BiEoleqw.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type EncryptedKeystore = {\n userEmail: string;\n type: KeystoreType;\n encryptedKeys: EmailKeysEncrypted;\n};\n\nexport type User = {\n email: string;\n name: string;\n};\n\nexport type UserWithPublicKeys = User & {\n publicKeys: PublicKeys;\n};\n\nexport type PublicKeys = {\n eccPublicKey: CryptoKey;\n kyberPublicKey: Uint8Array;\n};\n\nexport type PublicKeysBase64 = {\n eccPublicKeyBase64: string;\n kyberPublicKeyBase64: string;\n};\n\nexport type PrivateKeys = {\n eccPrivateKey: CryptoKey;\n kyberPrivateKey: Uint8Array;\n};\n\nexport type PrivateKeysEncrypted = {\n eccPrivateKeyBase64: string;\n kyberPrivateKeyBase64: string;\n};\n\nexport type EmailKeys = {\n publicKeys: PublicKeys;\n privateKeys: PrivateKeys;\n};\n\nexport type EmailKeysEncrypted = {\n publicKeys: PublicKeysBase64;\n privateKeys: PrivateKeysEncrypted;\n};\n\nexport type HybridEncryptedEmail = {\n encryptedKey: HybridEncKey;\n enc: EmailBodyEncrypted;\n recipientEmail: string;\n params: EmailPublicParameters;\n id: string;\n isSubjectEncrypted: boolean;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n enc: EmailBodyEncrypted;\n params: EmailPublicParameters;\n id: string;\n isSubjectEncrypted: boolean;\n};\n\nexport type StoredEmail = {\n params: EmailPublicParameters;\n enc: EmailBodyEncrypted;\n id: string;\n};\n\nexport type HybridEncKey = {\n kyberCiphertext: string;\n encryptedKey: string;\n};\n\nexport type PwdProtectedKey = {\n encryptedKey: string;\n salt: string;\n};\n\nexport type EmailBodyEncrypted = {\n encText: string;\n encAttachments?: string[];\n};\n\nexport type EmailBody = {\n text: string;\n attachments?: string[];\n};\n\nexport type EmailPublicParameters = {\n subject: string;\n createdAt: string;\n sender: User;\n recipient: User;\n recipients?: User[];\n replyToEmailID?: string;\n labels?: string[];\n};\n\nexport type Email = {\n id: string;\n body: EmailBody;\n params: EmailPublicParameters;\n};\n\nexport interface MailCache<Email> {\n esCache: Map<string, Email>;\n cacheSize: number;\n isCacheLimited: boolean;\n isCacheReady: boolean;\n}\nexport interface EmailSearchResult {\n email: Email;\n score?: number;\n}\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":";AAmHA,IAAY,sDAAL;AACL;AACA"}
@@ -0,0 +1,104 @@
1
+ //#region src/types.d.ts
2
+ type EncryptedKeystore = {
3
+ userEmail: string;
4
+ type: KeystoreType;
5
+ encryptedKeys: EmailKeysEncrypted;
6
+ };
7
+ type User = {
8
+ email: string;
9
+ name: string;
10
+ };
11
+ type UserWithPublicKeys = User & {
12
+ publicKeys: PublicKeys;
13
+ };
14
+ type PublicKeys = {
15
+ eccPublicKey: CryptoKey;
16
+ kyberPublicKey: Uint8Array;
17
+ };
18
+ type PublicKeysBase64 = {
19
+ eccPublicKeyBase64: string;
20
+ kyberPublicKeyBase64: string;
21
+ };
22
+ type PrivateKeys = {
23
+ eccPrivateKey: CryptoKey;
24
+ kyberPrivateKey: Uint8Array;
25
+ };
26
+ type PrivateKeysEncrypted = {
27
+ eccPrivateKeyBase64: string;
28
+ kyberPrivateKeyBase64: string;
29
+ };
30
+ type EmailKeys = {
31
+ publicKeys: PublicKeys;
32
+ privateKeys: PrivateKeys;
33
+ };
34
+ type EmailKeysEncrypted = {
35
+ publicKeys: PublicKeysBase64;
36
+ privateKeys: PrivateKeysEncrypted;
37
+ };
38
+ type HybridEncryptedEmail = {
39
+ encryptedKey: HybridEncKey;
40
+ enc: EmailBodyEncrypted;
41
+ recipientEmail: string;
42
+ params: EmailPublicParameters;
43
+ id: string;
44
+ isSubjectEncrypted: boolean;
45
+ };
46
+ type PwdProtectedEmail = {
47
+ encryptedKey: PwdProtectedKey;
48
+ enc: EmailBodyEncrypted;
49
+ params: EmailPublicParameters;
50
+ id: string;
51
+ isSubjectEncrypted: boolean;
52
+ };
53
+ type StoredEmail = {
54
+ params: EmailPublicParameters;
55
+ enc: EmailBodyEncrypted;
56
+ id: string;
57
+ };
58
+ type HybridEncKey = {
59
+ kyberCiphertext: string;
60
+ encryptedKey: string;
61
+ };
62
+ type PwdProtectedKey = {
63
+ encryptedKey: string;
64
+ salt: string;
65
+ };
66
+ type EmailBodyEncrypted = {
67
+ encText: string;
68
+ encAttachments?: string[];
69
+ };
70
+ type EmailBody = {
71
+ text: string;
72
+ attachments?: string[];
73
+ };
74
+ type EmailPublicParameters = {
75
+ subject: string;
76
+ createdAt: string;
77
+ sender: User;
78
+ recipient: User;
79
+ recipients?: User[];
80
+ replyToEmailID?: string;
81
+ labels?: string[];
82
+ };
83
+ type Email = {
84
+ id: string;
85
+ body: EmailBody;
86
+ params: EmailPublicParameters;
87
+ };
88
+ interface MailCache<Email> {
89
+ esCache: Map<string, Email>;
90
+ cacheSize: number;
91
+ isCacheLimited: boolean;
92
+ isCacheReady: boolean;
93
+ }
94
+ interface EmailSearchResult {
95
+ email: Email;
96
+ score?: number;
97
+ }
98
+ declare enum KeystoreType {
99
+ ENCRYPTION = "Encryption",
100
+ RECOVERY = "Recovery"
101
+ }
102
+ //#endregion
103
+ export { PwdProtectedEmail as _, EmailKeysEncrypted as a, User as b, EncryptedKeystore as c, KeystoreType as d, MailCache as f, PublicKeysBase64 as g, PublicKeys as h, EmailKeys as i, HybridEncKey as l, PrivateKeysEncrypted as m, EmailBody as n, EmailPublicParameters as o, PrivateKeys as p, EmailBodyEncrypted as r, EmailSearchResult as s, Email as t, HybridEncryptedEmail as u, PwdProtectedKey as v, UserWithPublicKeys as x, StoredEmail as y };
104
+ //# sourceMappingURL=types-Ds3ivE9W.d.ts.map
@@ -0,0 +1,104 @@
1
+ //#region src/types.d.ts
2
+ type EncryptedKeystore = {
3
+ userEmail: string;
4
+ type: KeystoreType;
5
+ encryptedKeys: EmailKeysEncrypted;
6
+ };
7
+ type User = {
8
+ email: string;
9
+ name: string;
10
+ };
11
+ type UserWithPublicKeys = User & {
12
+ publicKeys: PublicKeys;
13
+ };
14
+ type PublicKeys = {
15
+ eccPublicKey: CryptoKey;
16
+ kyberPublicKey: Uint8Array;
17
+ };
18
+ type PublicKeysBase64 = {
19
+ eccPublicKeyBase64: string;
20
+ kyberPublicKeyBase64: string;
21
+ };
22
+ type PrivateKeys = {
23
+ eccPrivateKey: CryptoKey;
24
+ kyberPrivateKey: Uint8Array;
25
+ };
26
+ type PrivateKeysEncrypted = {
27
+ eccPrivateKeyBase64: string;
28
+ kyberPrivateKeyBase64: string;
29
+ };
30
+ type EmailKeys = {
31
+ publicKeys: PublicKeys;
32
+ privateKeys: PrivateKeys;
33
+ };
34
+ type EmailKeysEncrypted = {
35
+ publicKeys: PublicKeysBase64;
36
+ privateKeys: PrivateKeysEncrypted;
37
+ };
38
+ type HybridEncryptedEmail = {
39
+ encryptedKey: HybridEncKey;
40
+ enc: EmailBodyEncrypted;
41
+ recipientEmail: string;
42
+ params: EmailPublicParameters;
43
+ id: string;
44
+ isSubjectEncrypted: boolean;
45
+ };
46
+ type PwdProtectedEmail = {
47
+ encryptedKey: PwdProtectedKey;
48
+ enc: EmailBodyEncrypted;
49
+ params: EmailPublicParameters;
50
+ id: string;
51
+ isSubjectEncrypted: boolean;
52
+ };
53
+ type StoredEmail = {
54
+ params: EmailPublicParameters;
55
+ enc: EmailBodyEncrypted;
56
+ id: string;
57
+ };
58
+ type HybridEncKey = {
59
+ kyberCiphertext: string;
60
+ encryptedKey: string;
61
+ };
62
+ type PwdProtectedKey = {
63
+ encryptedKey: string;
64
+ salt: string;
65
+ };
66
+ type EmailBodyEncrypted = {
67
+ encText: string;
68
+ encAttachments?: string[];
69
+ };
70
+ type EmailBody = {
71
+ text: string;
72
+ attachments?: string[];
73
+ };
74
+ type EmailPublicParameters = {
75
+ subject: string;
76
+ createdAt: string;
77
+ sender: User;
78
+ recipient: User;
79
+ recipients?: User[];
80
+ replyToEmailID?: string;
81
+ labels?: string[];
82
+ };
83
+ type Email = {
84
+ id: string;
85
+ body: EmailBody;
86
+ params: EmailPublicParameters;
87
+ };
88
+ interface MailCache<Email> {
89
+ esCache: Map<string, Email>;
90
+ cacheSize: number;
91
+ isCacheLimited: boolean;
92
+ isCacheReady: boolean;
93
+ }
94
+ interface EmailSearchResult {
95
+ email: Email;
96
+ score?: number;
97
+ }
98
+ declare enum KeystoreType {
99
+ ENCRYPTION = "Encryption",
100
+ RECOVERY = "Recovery"
101
+ }
102
+ //#endregion
103
+ export { PwdProtectedEmail as _, EmailKeysEncrypted as a, User as b, EncryptedKeystore as c, KeystoreType as d, MailCache as f, PublicKeysBase64 as g, PublicKeys as h, EmailKeys as i, HybridEncKey as l, PrivateKeysEncrypted as m, EmailBody as n, EmailPublicParameters as o, PrivateKeys as p, EmailBodyEncrypted as r, EmailSearchResult as s, Email as t, HybridEncryptedEmail as u, PwdProtectedKey as v, UserWithPublicKeys as x, StoredEmail as y };
104
+ //# sourceMappingURL=types-DwQJtrTx.d.mts.map
@@ -0,0 +1,2 @@
1
+ import { _ as PwdProtectedEmail, a as EmailKeysEncrypted, b as User, c as EncryptedKeystore, d as KeystoreType, f as MailCache, g as PublicKeysBase64, h as PublicKeys, i as EmailKeys, l as HybridEncKey, m as PrivateKeysEncrypted, n as EmailBody, o as EmailPublicParameters, p as PrivateKeys, r as EmailBodyEncrypted, s as EmailSearchResult, t as Email, u as HybridEncryptedEmail, v as PwdProtectedKey, x as UserWithPublicKeys, y as StoredEmail } from "./types-DwQJtrTx.mjs";
2
+ export { Email, EmailBody, EmailBodyEncrypted, EmailKeys, EmailKeysEncrypted, EmailPublicParameters, EmailSearchResult, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, KeystoreType, MailCache, PrivateKeys, PrivateKeysEncrypted, PublicKeys, PublicKeysBase64, PwdProtectedEmail, PwdProtectedKey, StoredEmail, User, UserWithPublicKeys };
@@ -0,0 +1,2 @@
1
+ import { _ as PwdProtectedEmail, a as EmailKeysEncrypted, b as User, c as EncryptedKeystore, d as KeystoreType, f as MailCache, g as PublicKeysBase64, h as PublicKeys, i as EmailKeys, l as HybridEncKey, m as PrivateKeysEncrypted, n as EmailBody, o as EmailPublicParameters, p as PrivateKeys, r as EmailBodyEncrypted, s as EmailSearchResult, t as Email, u as HybridEncryptedEmail, v as PwdProtectedKey, x as UserWithPublicKeys, y as StoredEmail } from "./types-Ds3ivE9W.js";
2
+ export { Email, EmailBody, EmailBodyEncrypted, EmailKeys, EmailKeysEncrypted, EmailPublicParameters, EmailSearchResult, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, KeystoreType, MailCache, PrivateKeys, PrivateKeysEncrypted, PublicKeys, PublicKeysBase64, PwdProtectedEmail, PwdProtectedKey, StoredEmail, User, UserWithPublicKeys };
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ const require_types = require('./types-52g887Zi.js');
2
+
3
+ exports.KeystoreType = require_types.KeystoreType;
package/dist/types.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { t as KeystoreType } from "./types-BiEoleqw.mjs";
2
+
3
+ export { KeystoreType };
@@ -0,0 +1,263 @@
1
+ const require_chunk = require('./chunk-Dt-PWiN7.js');
2
+ const require_constants = require('./constants-Ccp21E03.js');
3
+ const require_asymmetric_crypto = require('./asymmetric-crypto-BORmLhnx.js');
4
+ let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
5
+ let _scure_bip39 = require("@scure/bip39");
6
+ _scure_bip39 = require_chunk.__toESM(_scure_bip39);
7
+ let _scure_bip39_wordlists_english_js = require("@scure/bip39/wordlists/english.js");
8
+ let uuid = require("uuid");
9
+
10
+ //#region src/utils/converters.ts
11
+ /**
12
+ * Converts a Uint8Array into a hexadecimal string.
13
+ *
14
+ * @param array - The Uint8Array to convert.
15
+ * @returns The hexadecimal string representation of the array.
16
+ */
17
+ function uint8ArrayToHex(array) {
18
+ return (0, _noble_hashes_utils_js.bytesToHex)(array);
19
+ }
20
+ /**
21
+ * Converts a UTF-8 string into a Uint8Array.
22
+ *
23
+ * @param str - The UTF-8 string to convert.
24
+ * @returns A Uint8Array created from the UTF-8 string.
25
+ */
26
+ function UTF8ToUint8(str) {
27
+ return new TextEncoder().encode(str);
28
+ }
29
+ /**
30
+ * Converts an Uint8Array into a UTF-8 string.
31
+ *
32
+ * @param array - The Uint8Array to convert.
33
+ * @returns The UTF-8 string representation of the array.
34
+ */
35
+ function uint8ToUTF8(array) {
36
+ return new TextDecoder().decode(array);
37
+ }
38
+ /**
39
+ * Converts a hexadecimal string into a Uint8Array.
40
+ *
41
+ * @param hex - The hexadecimal string to convert.
42
+ * @returns A Uint8Array created from the hex string.
43
+ */
44
+ function hexToUint8Array(hex) {
45
+ return (0, _noble_hashes_utils_js.hexToBytes)(hex);
46
+ }
47
+ /**
48
+ * Converts a Uint8Array into a base64 string.
49
+ *
50
+ * @param array - The Uint8Array to convert.
51
+ * @returns The base64 string representation of the array.
52
+ */
53
+ function uint8ArrayToBase64(buffer) {
54
+ const array = Uint16Array.from(buffer);
55
+ const binaryString = new TextDecoder("UTF-16").decode(array);
56
+ return btoa(binaryString);
57
+ }
58
+ /**
59
+ * Converts a base64 string into a Uint8Array.
60
+ *
61
+ * @param str - The base64 string to convert.
62
+ * @returns A Uint8Array created from the base64 string.
63
+ */
64
+ function base64ToUint8Array(str) {
65
+ const binaryString = atob(str);
66
+ const len = binaryString.length;
67
+ const array = new Uint8Array(len);
68
+ for (let i = 0; i < len; i++) array[i] = binaryString.codePointAt(i);
69
+ return new Uint8Array(array.buffer);
70
+ }
71
+
72
+ //#endregion
73
+ //#region src/utils/keyConverters.ts
74
+ /**
75
+ * Converts a base64 string into PublicKeys type.
76
+ *
77
+ * @param base64 - The base64 representation of the public key.
78
+ * @returns The resulting PublicKeys.
79
+ */
80
+ async function base64ToPublicKey(base64) {
81
+ try {
82
+ return {
83
+ eccPublicKey: await require_asymmetric_crypto.importPublicKey(base64ToUint8Array(base64.eccPublicKeyBase64)),
84
+ kyberPublicKey: base64ToUint8Array(base64.kyberPublicKeyBase64)
85
+ };
86
+ } catch (error) {
87
+ throw new Error("Failed to convert base64 to PublicKeys", { cause: error });
88
+ }
89
+ }
90
+ /**
91
+ * Converts a PublicKeys type into PublicKeysBase64.
92
+ *
93
+ * @param key - The PublicKeys key.
94
+ * @returns The resulting PublicKeysBase64.
95
+ */
96
+ async function publicKeyToBase64(key) {
97
+ try {
98
+ return {
99
+ eccPublicKeyBase64: uint8ArrayToBase64(await require_asymmetric_crypto.exportPublicKey(key.eccPublicKey)),
100
+ kyberPublicKeyBase64: uint8ArrayToBase64(key.kyberPublicKey)
101
+ };
102
+ } catch (error) {
103
+ throw new Error("Failed to convert key of the type PublicKeys to PublicKeysBase64", { cause: error });
104
+ }
105
+ }
106
+
107
+ //#endregion
108
+ //#region src/utils/genMnemonic.ts
109
+ /**
110
+ * Generates a mnemonic
111
+ *
112
+ * @returns The generated mnemonic.
113
+ */
114
+ function genMnemonic() {
115
+ return _scure_bip39.generateMnemonic(_scure_bip39_wordlists_english_js.wordlist, require_constants.AES_KEY_BIT_LENGTH);
116
+ }
117
+ /**
118
+ * Converts a mnemonic to Uint8Array
119
+ *
120
+ * @param mnemonic - The mnemonic to convert
121
+ * @returns The mnemonic as Uint8Array
122
+ */
123
+ function mnemonicToBytes(mnemonic) {
124
+ return _scure_bip39.mnemonicToEntropy(mnemonic, _scure_bip39_wordlists_english_js.wordlist);
125
+ }
126
+ /**
127
+ * Converts a Uint8Array to a mnemonic
128
+ *
129
+ * @param bytes - The bytes to convert
130
+ * @returns The mnemonic string
131
+ */
132
+ function bytesToMnemonic(bytes) {
133
+ return _scure_bip39.entropyToMnemonic(bytes, _scure_bip39_wordlists_english_js.wordlist);
134
+ }
135
+
136
+ //#endregion
137
+ //#region src/utils/genID.ts
138
+ /**
139
+ * Creates a random identifier.
140
+ *
141
+ * @returns The resulting auxilary string
142
+ */
143
+ function generateUuid() {
144
+ return (0, uuid.v4)();
145
+ }
146
+ function uuidToBytes(uuid$1) {
147
+ return (0, uuid.parse)(uuid$1);
148
+ }
149
+ function bytesToUuid(bytes) {
150
+ return (0, uuid.stringify)(bytes);
151
+ }
152
+
153
+ //#endregion
154
+ //#region src/utils/index.ts
155
+ var utils_exports = /* @__PURE__ */ require_chunk.__exportAll({
156
+ UTF8ToUint8: () => UTF8ToUint8,
157
+ base64ToPublicKey: () => base64ToPublicKey,
158
+ base64ToUint8Array: () => base64ToUint8Array,
159
+ bytesToMnemonic: () => bytesToMnemonic,
160
+ bytesToUuid: () => bytesToUuid,
161
+ genMnemonic: () => genMnemonic,
162
+ generateUuid: () => generateUuid,
163
+ hexToUint8Array: () => hexToUint8Array,
164
+ mnemonicToBytes: () => mnemonicToBytes,
165
+ publicKeyToBase64: () => publicKeyToBase64,
166
+ uint8ArrayToBase64: () => uint8ArrayToBase64,
167
+ uint8ArrayToHex: () => uint8ArrayToHex,
168
+ uint8ToUTF8: () => uint8ToUTF8,
169
+ uuidToBytes: () => uuidToBytes
170
+ });
171
+
172
+ //#endregion
173
+ Object.defineProperty(exports, 'UTF8ToUint8', {
174
+ enumerable: true,
175
+ get: function () {
176
+ return UTF8ToUint8;
177
+ }
178
+ });
179
+ Object.defineProperty(exports, 'base64ToPublicKey', {
180
+ enumerable: true,
181
+ get: function () {
182
+ return base64ToPublicKey;
183
+ }
184
+ });
185
+ Object.defineProperty(exports, 'base64ToUint8Array', {
186
+ enumerable: true,
187
+ get: function () {
188
+ return base64ToUint8Array;
189
+ }
190
+ });
191
+ Object.defineProperty(exports, 'bytesToMnemonic', {
192
+ enumerable: true,
193
+ get: function () {
194
+ return bytesToMnemonic;
195
+ }
196
+ });
197
+ Object.defineProperty(exports, 'bytesToUuid', {
198
+ enumerable: true,
199
+ get: function () {
200
+ return bytesToUuid;
201
+ }
202
+ });
203
+ Object.defineProperty(exports, 'genMnemonic', {
204
+ enumerable: true,
205
+ get: function () {
206
+ return genMnemonic;
207
+ }
208
+ });
209
+ Object.defineProperty(exports, 'generateUuid', {
210
+ enumerable: true,
211
+ get: function () {
212
+ return generateUuid;
213
+ }
214
+ });
215
+ Object.defineProperty(exports, 'hexToUint8Array', {
216
+ enumerable: true,
217
+ get: function () {
218
+ return hexToUint8Array;
219
+ }
220
+ });
221
+ Object.defineProperty(exports, 'mnemonicToBytes', {
222
+ enumerable: true,
223
+ get: function () {
224
+ return mnemonicToBytes;
225
+ }
226
+ });
227
+ Object.defineProperty(exports, 'publicKeyToBase64', {
228
+ enumerable: true,
229
+ get: function () {
230
+ return publicKeyToBase64;
231
+ }
232
+ });
233
+ Object.defineProperty(exports, 'uint8ArrayToBase64', {
234
+ enumerable: true,
235
+ get: function () {
236
+ return uint8ArrayToBase64;
237
+ }
238
+ });
239
+ Object.defineProperty(exports, 'uint8ArrayToHex', {
240
+ enumerable: true,
241
+ get: function () {
242
+ return uint8ArrayToHex;
243
+ }
244
+ });
245
+ Object.defineProperty(exports, 'uint8ToUTF8', {
246
+ enumerable: true,
247
+ get: function () {
248
+ return uint8ToUTF8;
249
+ }
250
+ });
251
+ Object.defineProperty(exports, 'utils_exports', {
252
+ enumerable: true,
253
+ get: function () {
254
+ return utils_exports;
255
+ }
256
+ });
257
+ Object.defineProperty(exports, 'uuidToBytes', {
258
+ enumerable: true,
259
+ get: function () {
260
+ return uuidToBytes;
261
+ }
262
+ });
263
+ //# sourceMappingURL=utils-CNs3cyDj.js.map