internxt-crypto 1.0.2 → 1.1.1

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 (56) hide show
  1. package/README.md +1 -1
  2. package/dist/derive-key.d.mts +8 -1
  3. package/dist/derive-key.d.mts.map +1 -1
  4. package/dist/derive-key.d.ts +8 -1
  5. package/dist/derive-key.d.ts.map +1 -1
  6. package/dist/derive-key.js +2 -1
  7. package/dist/derive-key.mjs +2 -2
  8. package/dist/{deriveKeysFromKey-DPU_h7wr.mjs → deriveKeysFromKey-CseBjg0n.mjs} +12 -3
  9. package/dist/deriveKeysFromKey-CseBjg0n.mjs.map +1 -0
  10. package/dist/{deriveKeysFromKey-C4McqO6_.js → deriveKeysFromKey-GTRMuxDj.js} +16 -1
  11. package/dist/deriveKeysFromKey-GTRMuxDj.js.map +1 -0
  12. package/dist/email-crypto.d.mts +65 -2
  13. package/dist/email-crypto.d.mts.map +1 -1
  14. package/dist/email-crypto.d.ts +65 -2
  15. package/dist/email-crypto.d.ts.map +1 -1
  16. package/dist/email-crypto.js +14 -120
  17. package/dist/email-crypto.mjs +2 -115
  18. package/dist/{emailEncryptionKey-C4X1Bwy4.js → emailEncryptionKey-F_YuJu1H.js} +2 -2
  19. package/dist/{emailEncryptionKey-C4X1Bwy4.js.map → emailEncryptionKey-F_YuJu1H.js.map} +1 -1
  20. package/dist/{emailEncryptionKey-BtSPYd9M.mjs → emailEncryptionKey-kIsseFo6.mjs} +2 -2
  21. package/dist/{emailEncryptionKey-BtSPYd9M.mjs.map → emailEncryptionKey-kIsseFo6.mjs.map} +1 -1
  22. package/dist/{core-Bj26rNdA.js → emailKeys-DWvKANTZ.js} +148 -1
  23. package/dist/emailKeys-DWvKANTZ.js.map +1 -0
  24. package/dist/{core-pEGygy6S.mjs → emailKeys-nzn7U7HQ.mjs} +114 -3
  25. package/dist/emailKeys-nzn7U7HQ.mjs.map +1 -0
  26. package/dist/index.d.mts +4 -5
  27. package/dist/index.d.mts.map +1 -1
  28. package/dist/index.d.ts +4 -5
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +15 -36
  31. package/dist/index.mjs +4 -6
  32. package/dist/keystore-crypto.js +1 -1
  33. package/dist/keystore-crypto.mjs +1 -1
  34. package/dist/types.d.mts +1 -34
  35. package/dist/types.d.mts.map +1 -1
  36. package/dist/types.d.ts +1 -34
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js.map +1 -1
  39. package/dist/types.mjs.map +1 -1
  40. package/package.json +1 -3
  41. package/dist/core-Bj26rNdA.js.map +0 -1
  42. package/dist/core-pEGygy6S.mjs.map +0 -1
  43. package/dist/deriveKeysFromKey-C4McqO6_.js.map +0 -1
  44. package/dist/deriveKeysFromKey-DPU_h7wr.mjs.map +0 -1
  45. package/dist/email-crypto.js.map +0 -1
  46. package/dist/email-crypto.mjs.map +0 -1
  47. package/dist/email-search.d.mts +0 -232
  48. package/dist/email-search.d.mts.map +0 -1
  49. package/dist/email-search.d.ts +0 -232
  50. package/dist/email-search.d.ts.map +0 -1
  51. package/dist/email-search.js +0 -27
  52. package/dist/email-search.mjs +0 -3
  53. package/dist/search-B9YM3XAA.mjs +0 -587
  54. package/dist/search-B9YM3XAA.mjs.map +0 -1
  55. package/dist/search-DUTm4-rN.js +0 -731
  56. package/dist/search-DUTm4-rN.js.map +0 -1
@@ -1,232 +0,0 @@
1
- import { Email, EmailSearchResult, MailCache, StoredEmail } from "./types.js";
2
- import { DBSchema, IDBPDatabase } from "idb";
3
- import { Index } from "flexsearch";
4
-
5
- //#region src/email-search/indexedDB.d.ts
6
- type MailDB = IDBPDatabase<EncryptedSearchDB>;
7
- interface EncryptedSearchDB extends DBSchema {
8
- email: {
9
- key: string;
10
- value: StoredEmail;
11
- indexes: {
12
- byTime: number[];
13
- };
14
- };
15
- }
16
- /**
17
- * Opens IndexedDB database for the given user
18
- *
19
- * @param userID - The user ID
20
- * @returns The database
21
- */
22
- declare const openDatabase: (userID: string) => Promise<MailDB>;
23
- /**
24
- * Closes the IndexedDB database
25
- *
26
- * @param esDB - The database
27
- */
28
- declare const closeDatabase: (esDB: MailDB) => void;
29
- /**
30
- * Deletes IndexedDB database for the given user
31
- *
32
- * @param userID - The user ID
33
- * @returns The database
34
- */
35
- declare const deleteDatabase: (userID: string) => Promise<void>;
36
- /**
37
- * Derives database encryption key for the given user
38
- *
39
- * @param userID - The user ID
40
- * @returns The symmetric key for protecting database
41
- */
42
- declare const deriveIndexKey: (baseKey: Uint8Array) => Promise<Uint8Array>;
43
- /**
44
- * Encrypts the given email and stores it in the IndexedDB database
45
- *
46
- * @param newEmailToStore - The email for storing
47
- * @param indexKey - The symmetric key for protecting database
48
- * @param esDB - The database
49
- */
50
- declare const encryptAndStoreEmail: (newEmailToStore: Email, indexKey: Uint8Array, esDB: MailDB) => Promise<void>;
51
- /**
52
- * Encrypts the given set of emails and stores it in the IndexedDB database
53
- *
54
- * @param newEmailsToStore - The set of emails for storing
55
- * @param indexKey - The symmetric key key for protecting database
56
- * @param esDB - The database
57
- */
58
- declare const encryptAndStoreManyEmail: (newEmailsToStore: Email[], indexKey: Uint8Array, esDB: MailDB) => Promise<void>;
59
- /**
60
- * Fetches the email from the database and decrypts it
61
- *
62
- * @param emailID - The email identifier
63
- * @param indexKey - The symmetric key key for protecting database
64
- * @param encryptedEmail - The encrypted email
65
- * @returns The decrypted email
66
- */
67
- declare const getAndDecryptEmail: (emailID: string, indexKey: Uint8Array, esDB: MailDB) => Promise<Email>;
68
- /**
69
- * Fetches all email from the database and decrypts them
70
- *
71
- * @param indexKey - The symmetric key key for protecting database
72
- * @param esDB - The database
73
- * @returns The decrypted emails
74
- */
75
- declare const getAndDecryptAllEmails: (indexKey: Uint8Array, esDB: MailDB) => Promise<Email[]>;
76
- /**
77
- * Deletes the email from the database
78
- *
79
- * @param emailID - The email identifier
80
- * @param esDB - The database
81
- */
82
- declare const deleteEmail: (emailID: string, esDB: MailDB) => Promise<void>;
83
- /**
84
- * Returns the number of stored email
85
- *
86
- * @param esDB - The database
87
- * @returns The number of stored emails
88
- */
89
- declare const getEmailCount: (esDB: MailDB) => Promise<number>;
90
- /**
91
- * Removes the given number of oldests emails from the database
92
- *
93
- * @param emailsToDelete - The number of emails to delete
94
- * @param esDB - The database
95
- */
96
- declare const deleteOldestEmails: (emailsToDelete: number, esDB: MailDB) => Promise<void>;
97
- /**
98
- * Enforces the maximum email number in the database
99
- *
100
- * @param esDB - The database
101
- * @param max - The maximum allowed number of emails
102
- */
103
- declare const enforceMaxEmailNumber: (esDB: MailDB, max: number) => Promise<void>;
104
- /**
105
- * Fetches all emails from the database, decrypts them and sortes the results based on the creation time (newest first)
106
- *
107
- * @param esDB - The database
108
- * @param indexKey - The symmetric Uint8Array key for protecting database
109
- * @returns The number of stored emails
110
- */
111
- declare const getAllEmailsSortedNewestFirst: (esDB: MailDB, indexKey: Uint8Array) => Promise<Email[]>;
112
- /**
113
- * Fetches all emails from the database, decrypts them and sortes the results based on the creation time (oldest first)
114
- *
115
- * @param esDB - The database
116
- * @param indexKey - The symmetric key for protecting database
117
- * @returns The number of stored emails
118
- */
119
- declare const getAllEmailsSortedOldestFirst: (esDB: MailDB, indexKey: Uint8Array) => Promise<Email[]>;
120
- /**
121
- * Fetches a batch of emails from the database, decrypts them and sortes the results based on the creation time (newest first)
122
- *
123
- * @param esDB - The database
124
- * @param indexKey - The symmetric key for protecting database
125
- * @param batchSize - The size of the batch
126
- * @param startCursor - The starting point (optional). If not given, starts from the beginning
127
- * @returns The number of stored emails
128
- */
129
- declare const getEmailBatch: (esDB: MailDB, indexKey: Uint8Array, batchSize: number, startCursor?: IDBValidKey) => Promise<{
130
- emails: Email[];
131
- nextCursor?: IDBValidKey;
132
- }>;
133
- //#endregion
134
- //#region src/email-search/mailCache.d.ts
135
- /**
136
- * Fetches all emails from the database in batches and cahces them
137
- *
138
- * @param indexKey - The symmetric key for protecting database
139
- * @param esCache - The cache to add emails too
140
- * @param esDB - The database
141
- */
142
- declare const createCacheFromDB: (indexKey: Uint8Array, esDB: MailDB) => Promise<MailCache<Email>>;
143
- /**
144
- * Gets an email from the cache
145
- *
146
- * @param emailID - The email identifier
147
- * @param esCache - The email cache
148
- * @returns The found email or throws an error
149
- */
150
- declare const getEmailFromCache: (emailID: string, esCache: MailCache<Email>) => Promise<Email>;
151
- /**
152
- * Removes the email from cache
153
- *
154
- * @param emailID - The email identifier
155
- * @param esCache - The email cache
156
- */
157
- declare const deleteEmailFromCache: (emailID: string, esCache: MailCache<Email>) => Promise<void>;
158
- /**
159
- * Adds emails to the cache
160
- *
161
- * @param emails - The emails to add
162
- * @param esCache - The email cache
163
- * @returns TRUE if all emails were added sucessfully, or FALSE and error reason.
164
- */
165
- declare function addEmailsToCache(emails: Email[], esCache: MailCache<Email>): {
166
- success: boolean;
167
- reason?: string;
168
- };
169
- /**
170
- * Adds email to the cache
171
- *
172
- * @param email - The email to add
173
- * @param esCache - The email cache
174
- * @returns TRUE if the email was added sucessfully, or FALSE and error reason.
175
- */
176
- declare const addEmailToCache: (email: Email, esCache: MailCache<Email>) => {
177
- success: boolean;
178
- reason?: string;
179
- };
180
- //#endregion
181
- //#region src/email-search/search.d.ts
182
- interface EmailSearchIndex {
183
- subjectIndex: Index;
184
- bodyIndex: Index;
185
- fromIndex: Index;
186
- toIndex: Index;
187
- isReady: boolean;
188
- }
189
- /**
190
- * Adds the given email to the email search index
191
- *
192
- * @param email - The email to add
193
- * @param searchIndex - The email search index
194
- */
195
- declare const addEmailToSearchIndex: (email: Email, searchIndex: EmailSearchIndex) => void;
196
- /**
197
- * Removes the email from the email search index
198
- *
199
- * @param emailID - The email identifier
200
- * @param searchIndex - The email search index
201
- */
202
- declare const removeEmailFromSearchIndex: (emailID: string, searchIndex: EmailSearchIndex) => void;
203
- /**
204
- * Buils the email search index from the email cache
205
- *
206
- * @param esCache - The email cache
207
- * @returns The email search index
208
- */
209
- declare const buildSearchIndexFromCache: (esCache: MailCache<Email>) => Promise<EmailSearchIndex>;
210
- interface SearchOptions {
211
- fields?: ('subject' | 'body' | 'from' | 'to')[];
212
- limit?: number;
213
- boost?: {
214
- subject?: number;
215
- body?: number;
216
- from?: number;
217
- to?: number;
218
- };
219
- }
220
- /**
221
- * Searches in teh
222
- *
223
- * @param query - The string to search for
224
- * @param esCache - The email cache
225
- * @param searchIndex - The email search index
226
- * @param opetions - The optional search limitations
227
- * @returns The result of the email search (emails ans their corresponding result weights)
228
- */
229
- declare const searchEmails: (query: string, esCache: MailCache<Email>, searchIndex: EmailSearchIndex, options?: SearchOptions) => Promise<EmailSearchResult[]>;
230
- //#endregion
231
- export { EmailSearchIndex, EncryptedSearchDB, MailDB, SearchOptions, addEmailToCache, addEmailToSearchIndex, addEmailsToCache, buildSearchIndexFromCache, closeDatabase, createCacheFromDB, deleteDatabase, deleteEmail, deleteEmailFromCache, deleteOldestEmails, deriveIndexKey, encryptAndStoreEmail, encryptAndStoreManyEmail, enforceMaxEmailNumber, getAllEmailsSortedNewestFirst, getAllEmailsSortedOldestFirst, getAndDecryptAllEmails, getAndDecryptEmail, getEmailBatch, getEmailCount, getEmailFromCache, openDatabase, removeEmailFromSearchIndex, searchEmails };
232
- //# sourceMappingURL=email-search.d.ts.map
@@ -1 +0,0 @@
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,OAA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A,CAAU,KAAA;AD5B/F;;;;;;;AAAA,cCwEa,iBAAA,GAA2B,OAAA,UAAiB,OAAA,EAAS,SAAA,CAAU,KAAA,MAAS,OAAA,CAAQ,KAAA;;;;;;ADhD7F;cC8Da,oBAAA,GAA8B,OAAA,UAAiB,OAAA,EAAS,SAAA,CAAU,KAAA,MAAS,OAAA;;;;;;;;iBAkBxE,gBAAA,CAAiB,MAAA,EAAQ,KAAA,IAAS,OAAA,EAAS,SAAA,CAAU,KAAA;EAAW,OAAA;EAAkB,MAAA;AAAA;;ADjDlG;;;;;AAWA;cCyDa,eAAA,GAAmB,KAAA,EAAO,KAAA,EAAO,OAAA,EAAS,SAAA,CAAU,KAAA;EAAW,OAAA;EAAkB,MAAA;AAAA;;;UC5F7E,gBAAA;EACf,YAAA,EAAc,KAAA;EACd,SAAA,EAAW,KAAA;EACX,SAAA,EAAW,KAAA;EACX,OAAA,EAAS,KAAA;EACT,OAAA;AAAA;;AFpCF;;;;;cE0Da,qBAAA,GAAyB,KAAA,EAAO,KAAA,EAAO,WAAA,EAAa,gBAAA;;;;;;;cAyBpD,0BAAA,GAA8B,OAAA,UAAiB,WAAA,EAAa,gBAAA;AF3DzE;;;;;;AAAA,cE4Ea,yBAAA,GAAmC,OAAA,EAAS,SAAA,CAAU,KAAA,MAAS,OAAA,CAAQ,gBAAA;AAAA,UAgBnE,aAAA;EACf,MAAA;EACA,KAAA;EACA,KAAA;IACE,OAAA;IACA,IAAA;IACA,IAAA;IACA,EAAA;EAAA;AAAA;;;AFzDJ;;;;;;;cEsEa,YAAA,GACX,KAAA,UACA,OAAA,EAAS,SAAA,CAAU,KAAA,GACnB,WAAA,EAAa,gBAAA,EACb,OAAA,GAAS,aAAA,KACR,OAAA,CAAQ,iBAAA"}
@@ -1,27 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_search = require('./search-DUTm4-rN.js');
3
-
4
- exports.addEmailToCache = require_search.addEmailToCache;
5
- exports.addEmailToSearchIndex = require_search.addEmailToSearchIndex;
6
- exports.addEmailsToCache = require_search.addEmailsToCache;
7
- exports.buildSearchIndexFromCache = require_search.buildSearchIndexFromCache;
8
- exports.closeDatabase = require_search.closeDatabase;
9
- exports.createCacheFromDB = require_search.createCacheFromDB;
10
- exports.deleteDatabase = require_search.deleteDatabase;
11
- exports.deleteEmail = require_search.deleteEmail;
12
- exports.deleteEmailFromCache = require_search.deleteEmailFromCache;
13
- exports.deleteOldestEmails = require_search.deleteOldestEmails;
14
- exports.deriveIndexKey = require_search.deriveIndexKey;
15
- exports.encryptAndStoreEmail = require_search.encryptAndStoreEmail;
16
- exports.encryptAndStoreManyEmail = require_search.encryptAndStoreManyEmail;
17
- exports.enforceMaxEmailNumber = require_search.enforceMaxEmailNumber;
18
- exports.getAllEmailsSortedNewestFirst = require_search.getAllEmailsSortedNewestFirst;
19
- exports.getAllEmailsSortedOldestFirst = require_search.getAllEmailsSortedOldestFirst;
20
- exports.getAndDecryptAllEmails = require_search.getAndDecryptAllEmails;
21
- exports.getAndDecryptEmail = require_search.getAndDecryptEmail;
22
- exports.getEmailBatch = require_search.getEmailBatch;
23
- exports.getEmailCount = require_search.getEmailCount;
24
- exports.getEmailFromCache = require_search.getEmailFromCache;
25
- exports.openDatabase = require_search.openDatabase;
26
- exports.removeEmailFromSearchIndex = require_search.removeEmailFromSearchIndex;
27
- exports.searchEmails = require_search.searchEmails;
@@ -1,3 +0,0 @@
1
- import { C as getEmailCount, S as getEmailBatch, _ as enforceMaxEmailNumber, a as addEmailToCache, b as getAndDecryptAllEmails, c as deleteEmailFromCache, d as deleteDatabase, f as deleteEmail, g as encryptAndStoreManyEmail, h as encryptAndStoreEmail, i as searchEmails, l as getEmailFromCache, m as deriveIndexKey, n as buildSearchIndexFromCache, o as addEmailsToCache, p as deleteOldestEmails, r as removeEmailFromSearchIndex, s as createCacheFromDB, t as addEmailToSearchIndex, u as closeDatabase, v as getAllEmailsSortedNewestFirst, w as openDatabase, x as getAndDecryptEmail, y as getAllEmailsSortedOldestFirst } from "./search-B9YM3XAA.mjs";
2
-
3
- export { addEmailToCache, addEmailToSearchIndex, addEmailsToCache, buildSearchIndexFromCache, closeDatabase, createCacheFromDB, deleteDatabase, deleteEmail, deleteEmailFromCache, deleteOldestEmails, deriveIndexKey, encryptAndStoreEmail, encryptAndStoreManyEmail, enforceMaxEmailNumber, getAllEmailsSortedNewestFirst, getAllEmailsSortedOldestFirst, getAndDecryptAllEmails, getAndDecryptEmail, getEmailBatch, getEmailCount, getEmailFromCache, openDatabase, removeEmailFromSearchIndex, searchEmails };