internxt-crypto 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -73
- package/dist/asymmetric-crypto.js +3 -4
- package/dist/asymmetric-crypto.js.map +1 -1
- package/dist/asymmetric-crypto.mjs +1 -2
- package/dist/asymmetric-crypto.mjs.map +1 -1
- package/dist/chunk-C13QxCFV.js +50 -0
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/constants.js +2 -3
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/derive-key.js +50 -5
- package/dist/derive-key.js.map +1 -0
- package/dist/derive-key.mjs +46 -2
- package/dist/derive-key.mjs.map +1 -0
- package/dist/{deriveKeysFromPassword-iMHv-tIA.js → derive-password-CbYRDq7V.js} +25 -30
- package/dist/derive-password-CbYRDq7V.js.map +1 -0
- package/dist/{deriveKeysFromPassword-DFzo2OII.mjs → derive-password-PED-YfwE.mjs} +27 -34
- package/dist/derive-password-PED-YfwE.mjs.map +1 -0
- package/dist/derive-password.js +5 -6
- package/dist/derive-password.mjs +2 -3
- package/dist/email-crypto-Di814Pbk.js +739 -0
- package/dist/email-crypto-Di814Pbk.js.map +1 -0
- package/dist/email-crypto-DpjfXDes.mjs +535 -0
- package/dist/email-crypto-DpjfXDes.mjs.map +1 -0
- package/dist/email-crypto.d.mts +138 -29
- package/dist/email-crypto.d.mts.map +1 -1
- package/dist/email-crypto.d.ts +138 -29
- package/dist/email-crypto.d.ts.map +1 -1
- package/dist/email-crypto.js +34 -18
- package/dist/email-crypto.mjs +2 -3
- package/dist/hash.js +3 -4
- package/dist/hash.js.map +1 -1
- package/dist/hash.mjs +1 -2
- package/dist/hash.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +72 -56
- package/dist/index.mjs +7 -8
- package/dist/{emailEncryptionKey-CYvr26FG.mjs → keystore-crypto-C6F-NQdX.mjs} +12 -15
- package/dist/keystore-crypto-C6F-NQdX.mjs.map +1 -0
- package/dist/{emailEncryptionKey-Ba95VuFO.js → keystore-crypto-CFiiGohl.js} +67 -70
- package/dist/keystore-crypto-CFiiGohl.js.map +1 -0
- package/dist/keystore-crypto.d.mts +1 -1
- package/dist/keystore-crypto.d.ts +1 -1
- package/dist/keystore-crypto.js +11 -12
- package/dist/keystore-crypto.mjs +2 -3
- package/dist/post-quantum-crypto.js +3 -4
- package/dist/post-quantum-crypto.js.map +1 -1
- package/dist/post-quantum-crypto.mjs +1 -2
- package/dist/post-quantum-crypto.mjs.map +1 -1
- package/dist/storage-service.js +13 -15
- package/dist/storage-service.js.map +1 -1
- package/dist/storage-service.mjs +2 -4
- package/dist/storage-service.mjs.map +1 -1
- package/dist/symmetric-crypto.js +51 -5
- package/dist/symmetric-crypto.js.map +1 -0
- package/dist/symmetric-crypto.mjs +47 -2
- package/dist/symmetric-crypto.mjs.map +1 -0
- package/dist/types-CrAiKyb0.d.ts +61 -0
- package/dist/types-CrAiKyb0.d.ts.map +1 -0
- package/dist/types-D6hsUfma.d.mts +61 -0
- package/dist/types-D6hsUfma.d.mts.map +1 -0
- package/dist/types.d.mts +2 -49
- package/dist/types.d.ts +2 -49
- package/dist/types.js +2 -3
- package/dist/types.js.map +1 -1
- package/dist/types.mjs +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.js +127 -14
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +113 -2
- package/dist/utils.mjs.map +1 -0
- package/dist/{xwing-iRWVRtNE.js → xwing-7fEqAT7W.js} +18 -19
- package/dist/{xwing-iRWVRtNE.js.map → xwing-7fEqAT7W.js.map} +1 -1
- package/dist/{xwing-CQmQX6hn.mjs → xwing-B34h5e3Z.mjs} +2 -3
- package/dist/{xwing-CQmQX6hn.mjs.map → xwing-B34h5e3Z.mjs.map} +1 -1
- package/package.json +22 -22
- package/dist/aes-B8TA-JKq.mjs +0 -49
- package/dist/aes-B8TA-JKq.mjs.map +0 -1
- package/dist/aes-CuW_SPl-.js +0 -67
- package/dist/aes-CuW_SPl-.js.map +0 -1
- package/dist/chunk-DQk6qfdC.mjs +0 -18
- package/dist/chunk-EbLFQX5m.js +0 -60
- package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs +0 -49
- package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs.map +0 -1
- package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js +0 -67
- package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js.map +0 -1
- package/dist/deriveKeysFromPassword-DFzo2OII.mjs.map +0 -1
- package/dist/deriveKeysFromPassword-iMHv-tIA.js.map +0 -1
- package/dist/emailEncryptionKey-Ba95VuFO.js.map +0 -1
- package/dist/emailEncryptionKey-CYvr26FG.mjs.map +0 -1
- package/dist/emailKeys-BFI-paQq.js +0 -406
- package/dist/emailKeys-BFI-paQq.js.map +0 -1
- package/dist/emailKeys-BjIeINfC.mjs +0 -304
- package/dist/emailKeys-BjIeINfC.mjs.map +0 -1
- package/dist/genID-D08K7JPr.mjs +0 -117
- package/dist/genID-D08K7JPr.mjs.map +0 -1
- package/dist/genID-cWOPmspk.js +0 -190
- package/dist/genID-cWOPmspk.js.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/types.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -107,9 +107,9 @@ const password = 'your password';
|
|
|
107
107
|
const { key, salt } = await getKeyFromPassword(password);
|
|
108
108
|
|
|
109
109
|
// Hybrid email encryption
|
|
110
|
-
const email:
|
|
110
|
+
const email: Email = {
|
|
111
111
|
text: 'email text',
|
|
112
|
-
|
|
112
|
+
attachments: ['email attachements'],
|
|
113
113
|
};
|
|
114
114
|
const { secretKey: bobPrivateKeys, publicKey: bobPublicKeys } = await generateEmailKeys();
|
|
115
115
|
const bobWithPublicKeys = {
|
|
@@ -119,8 +119,19 @@ const bobWithPublicKeys = {
|
|
|
119
119
|
const encryptedEmail = await encryptEmailHybrid(email, bobWithPublicKeys);
|
|
120
120
|
const decryptedEmail = await decryptEmailHybrid(encryptedEmail, bobPrivateKeys);
|
|
121
121
|
|
|
122
|
-
expect(
|
|
123
|
-
|
|
122
|
+
expect(decryptedEmail).toStrictEqual(email);
|
|
123
|
+
|
|
124
|
+
// Hybrid email and subject encryption
|
|
125
|
+
const emailAndSubject: EmailAndSubject = {
|
|
126
|
+
text: 'email text',
|
|
127
|
+
subject: 'email subject'
|
|
128
|
+
attachments: ['email attachements'],
|
|
129
|
+
};
|
|
130
|
+
const encryptedEmailAndSubject = await encryptEmailAndSubjectHybrid(emailAndSubject, bobWithPublicKeys);
|
|
131
|
+
const decryptedEmailAndSubject = await decryptEmailAndSubjectHybrid(encryptedEmailAndSubject, bobPrivateKeys);
|
|
132
|
+
|
|
133
|
+
expect(encryptedEmailAndSubject.encEmail.encSubject).not.toBe(emailAndSubject.subject);
|
|
134
|
+
expect(decryptedEmailAndSubject).toStrictEqual(emailAndSubject);
|
|
124
135
|
|
|
125
136
|
|
|
126
137
|
// password-protected email
|
|
@@ -141,73 +152,4 @@ const resultRec = await openRecoveryKeystore(recoveryCodes, recoveryKeystore);
|
|
|
141
152
|
|
|
142
153
|
expect(resultEnc).toStrictEqual(resultRec);
|
|
143
154
|
|
|
144
|
-
// Email storage and search
|
|
145
|
-
|
|
146
|
-
// Between sessions emails are stored encrypted in IndexedDB. The encryption key is derived from user's mnemonic
|
|
147
|
-
// During the session, all emails are decrypted and stored in the cache (up to 600 MB, if excides - we delete oldests emails)
|
|
148
|
-
// For search, we build a search index from cache, then use Flexsearch for the search.
|
|
149
|
-
// The search is doen separately for email content, subject, sender and recivers.
|
|
150
|
-
|
|
151
|
-
// Open IndexedDB database
|
|
152
|
-
const userID = 'user ID';
|
|
153
|
-
const db = await openDatabase(userID);
|
|
154
|
-
const mnemonic = genMnemonic();
|
|
155
|
-
|
|
156
|
-
// Derive key for encrypting emails before storing them in a local database
|
|
157
|
-
const key = await deriveDatabaseKey(mnemonic);
|
|
158
|
-
|
|
159
|
-
// Derive key for encrypting email draft
|
|
160
|
-
const key = await deriveDatabaseKey(mnemonic);
|
|
161
|
-
|
|
162
|
-
// Encrypt and store one or several emails
|
|
163
|
-
await encryptAndStoreEmail(email, key, db);
|
|
164
|
-
await encryptAndStoreManyEmail(emails, key, db);
|
|
165
|
-
|
|
166
|
-
// Delete given email by its ID
|
|
167
|
-
await deleteEmail(emailID, db);
|
|
168
|
-
|
|
169
|
-
// Delete oldests emails
|
|
170
|
-
const number = 5;
|
|
171
|
-
await deleteOldestEmails(number, db);
|
|
172
|
-
|
|
173
|
-
// Get all emails with or without sorting
|
|
174
|
-
const allEmails = await getAndDecryptAllEmails(key, db);
|
|
175
|
-
const newestFirst = await getAllEmailsSortedNewestFirst(db, key);
|
|
176
|
-
const oldestFirst = await getAllEmailsSortedOldestFirst(db, key);
|
|
177
|
-
|
|
178
|
-
// Get the number of stored emails
|
|
179
|
-
const count = await getEmailCount(db);
|
|
180
|
-
|
|
181
|
-
// Close IndexedDB database
|
|
182
|
-
closeDatabase(db);
|
|
183
|
-
|
|
184
|
-
// Delete IndexedDB database
|
|
185
|
-
await deleteDatabase(userID);
|
|
186
|
-
|
|
187
|
-
// Create email cache
|
|
188
|
-
const esCache = await createCacheFromDB(key, db);
|
|
189
|
-
|
|
190
|
-
// Add one or multiple emails to cache
|
|
191
|
-
const result = addEmailToCache(email, esCache);
|
|
192
|
-
expect(result.success).toBe(true);
|
|
193
|
-
|
|
194
|
-
const result = addEmailsToCache(emails, esCache);
|
|
195
|
-
expect(result.success).toBe(true);
|
|
196
|
-
|
|
197
|
-
// Get email from cache by its ID
|
|
198
|
-
const email = await getEmailFromCache(emailID, esCache);
|
|
199
|
-
|
|
200
|
-
// Delete email from cache by its ID
|
|
201
|
-
await deleteEmailFromCache(emailID, esCache);
|
|
202
|
-
|
|
203
|
-
// Create search index and search by query
|
|
204
|
-
const searchIndex = await buildSearchIndexFromCache(esCache);
|
|
205
|
-
const query = 'keywords to search';
|
|
206
|
-
const options = {
|
|
207
|
-
fields: ['subject'], // in which fields to search, all by deafult (subject, body, from, to)
|
|
208
|
-
limit: 5, // result limit, 50 by default
|
|
209
|
-
boost: { subject: 3, body: 1, from: 2, to: 2 }, // custom waights for matches in different email parts
|
|
210
|
-
};
|
|
211
|
-
const result: EmailSearchResult = await searchEmails(query, esCache, searchIndex);
|
|
212
|
-
|
|
213
155
|
```
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./chunk-C13QxCFV.js");
|
|
3
3
|
let _noble_curves_webcrypto_js = require("@noble/curves/webcrypto.js");
|
|
4
|
-
|
|
5
4
|
//#region src/asymmetric-crypto/ellipticCurve.ts
|
|
6
5
|
/**
|
|
7
6
|
* Derives secret key from the other user's public key and own private key
|
|
@@ -25,8 +24,8 @@ async function deriveSecretKey(aliceSecretKey, bobPublicKey) {
|
|
|
25
24
|
async function generateEccKeys() {
|
|
26
25
|
return _noble_curves_webcrypto_js.x25519.keygen();
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
//#endregion
|
|
30
28
|
exports.deriveSecretKey = deriveSecretKey;
|
|
31
29
|
exports.generateEccKeys = generateEccKeys;
|
|
30
|
+
|
|
32
31
|
//# sourceMappingURL=asymmetric-crypto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asymmetric-crypto.js","names":["x25519"],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"sourcesContent":["import { x25519 } from '@noble/curves/webcrypto.js';\n\n/**\n * Derives secret key from the other user's public key and own private key\n *\n * @param aliceSecretKey - The secret key of the user deriving the shared secret key\n * @param bobPublicKey - The public key of the other user\n * @returns The derived secret key bits\n */\nexport async function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array> {\n try {\n return await x25519.getSharedSecret(aliceSecretKey, bobPublicKey);\n } catch (error) {\n throw new Error('Failed to derive elliptic curve secret key', { cause: error });\n }\n}\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<{ secretKey: Uint8Array; publicKey: Uint8Array }> {\n return x25519.keygen();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"asymmetric-crypto.js","names":["x25519"],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"sourcesContent":["import { x25519 } from '@noble/curves/webcrypto.js';\n\n/**\n * Derives secret key from the other user's public key and own private key\n *\n * @param aliceSecretKey - The secret key of the user deriving the shared secret key\n * @param bobPublicKey - The public key of the other user\n * @returns The derived secret key bits\n */\nexport async function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array> {\n try {\n return await x25519.getSharedSecret(aliceSecretKey, bobPublicKey);\n } catch (error) {\n throw new Error('Failed to derive elliptic curve secret key', { cause: error });\n }\n}\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<{ secretKey: Uint8Array; publicKey: Uint8Array }> {\n return x25519.keygen();\n}\n"],"mappings":";;;;;;;;;;;AASA,eAAsB,gBAAgB,gBAA4B,cAA+C;AAC/G,KAAI;AACF,SAAO,MAAMA,2BAAAA,OAAO,gBAAgB,gBAAgB,aAAa;UAC1D,OAAO;AACd,QAAM,IAAI,MAAM,8CAA8C,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASnF,eAAsB,kBAA6E;AACjG,QAAOA,2BAAAA,OAAO,QAAQ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { x25519 } from "@noble/curves/webcrypto.js";
|
|
2
|
-
|
|
3
2
|
//#region src/asymmetric-crypto/ellipticCurve.ts
|
|
4
3
|
/**
|
|
5
4
|
* Derives secret key from the other user's public key and own private key
|
|
@@ -23,7 +22,7 @@ async function deriveSecretKey(aliceSecretKey, bobPublicKey) {
|
|
|
23
22
|
async function generateEccKeys() {
|
|
24
23
|
return x25519.keygen();
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
//#endregion
|
|
28
26
|
export { deriveSecretKey, generateEccKeys };
|
|
27
|
+
|
|
29
28
|
//# sourceMappingURL=asymmetric-crypto.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asymmetric-crypto.mjs","names":[],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"sourcesContent":["import { x25519 } from '@noble/curves/webcrypto.js';\n\n/**\n * Derives secret key from the other user's public key and own private key\n *\n * @param aliceSecretKey - The secret key of the user deriving the shared secret key\n * @param bobPublicKey - The public key of the other user\n * @returns The derived secret key bits\n */\nexport async function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array> {\n try {\n return await x25519.getSharedSecret(aliceSecretKey, bobPublicKey);\n } catch (error) {\n throw new Error('Failed to derive elliptic curve secret key', { cause: error });\n }\n}\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<{ secretKey: Uint8Array; publicKey: Uint8Array }> {\n return x25519.keygen();\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"asymmetric-crypto.mjs","names":[],"sources":["../src/asymmetric-crypto/ellipticCurve.ts"],"sourcesContent":["import { x25519 } from '@noble/curves/webcrypto.js';\n\n/**\n * Derives secret key from the other user's public key and own private key\n *\n * @param aliceSecretKey - The secret key of the user deriving the shared secret key\n * @param bobPublicKey - The public key of the other user\n * @returns The derived secret key bits\n */\nexport async function deriveSecretKey(aliceSecretKey: Uint8Array, bobPublicKey: Uint8Array): Promise<Uint8Array> {\n try {\n return await x25519.getSharedSecret(aliceSecretKey, bobPublicKey);\n } catch (error) {\n throw new Error('Failed to derive elliptic curve secret key', { cause: error });\n }\n}\n\n/**\n * Generates elliptic curve key pair\n *\n * @returns The generated key pair\n */\nexport async function generateEccKeys(): Promise<{ secretKey: Uint8Array; publicKey: Uint8Array }> {\n return x25519.keygen();\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,gBAAgB,gBAA4B,cAA+C;AAC/G,KAAI;AACF,SAAO,MAAM,OAAO,gBAAgB,gBAAgB,aAAa;UAC1D,OAAO;AACd,QAAM,IAAI,MAAM,8CAA8C,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASnF,eAAsB,kBAA6E;AACjG,QAAO,OAAO,QAAQ"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
//#endregion
|
|
33
|
+
Object.defineProperty(exports, "__commonJSMin", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function() {
|
|
36
|
+
return __commonJSMin;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "__exportAll", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function() {
|
|
42
|
+
return __exportAll;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "__toESM", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function() {
|
|
48
|
+
return __toESM;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
package/dist/constants.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
//#region src/constants.ts
|
|
4
3
|
const AES_KEY_BYTE_LENGTH = 32;
|
|
5
4
|
const IV_LEN_BYTES = 12;
|
|
@@ -24,7 +23,6 @@ const XWING_PUBLIC_KEY_LENGTH = 1216;
|
|
|
24
23
|
const XWING_SECRET_KEY_LENGTH = 32;
|
|
25
24
|
const XWING_SEED_BYTE_LENGTH = 32;
|
|
26
25
|
const XWING_CIPHERTEXT_BYTE_LENGTH = 1120;
|
|
27
|
-
|
|
28
26
|
//#endregion
|
|
29
27
|
exports.AES_KEY_BYTE_LENGTH = AES_KEY_BYTE_LENGTH;
|
|
30
28
|
exports.ARGON2ID_ITERATIONS = ARGON2ID_ITERATIONS;
|
|
@@ -49,4 +47,5 @@ exports.XWING_CIPHERTEXT_BYTE_LENGTH = XWING_CIPHERTEXT_BYTE_LENGTH;
|
|
|
49
47
|
exports.XWING_PUBLIC_KEY_LENGTH = XWING_PUBLIC_KEY_LENGTH;
|
|
50
48
|
exports.XWING_SECRET_KEY_LENGTH = XWING_SECRET_KEY_LENGTH;
|
|
51
49
|
exports.XWING_SEED_BYTE_LENGTH = XWING_SEED_BYTE_LENGTH;
|
|
50
|
+
|
|
52
51
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const AES_KEY_BYTE_LENGTH = 32;\nexport const IV_LEN_BYTES = 12;\n\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_DATABASE = 'CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices';\nexport const CONTEXT_DRAFT = 'CRYPTO library 2026-04-23 10:56:00 key for protecting email drafts';\nexport const CONTEXT_TWO_KEYS = 'CRYPTO library 2025-08-27 17:08:00 derive one key from two 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 KYBER768_PUBLIC_KEY_LENGTH = 1184;\nexport const KYBER768_SECRET_KEY_LENGTH = 2400;\nexport const KYBER_SEED_LENGTH = 64;\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\nexport const XWING_PUBLIC_KEY_LENGTH = 1216;\nexport const XWING_SECRET_KEY_LENGTH = 32;\nexport const XWING_SEED_BYTE_LENGTH = 32;\nexport const XWING_CIPHERTEXT_BYTE_LENGTH = 1120;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const AES_KEY_BYTE_LENGTH = 32;\nexport const IV_LEN_BYTES = 12;\n\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_DATABASE = 'CRYPTO library 2025-07-30 17:20:00 key for protecting current search indices';\nexport const CONTEXT_DRAFT = 'CRYPTO library 2026-04-23 10:56:00 key for protecting email drafts';\nexport const CONTEXT_TWO_KEYS = 'CRYPTO library 2025-08-27 17:08:00 derive one key from two 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 KYBER768_PUBLIC_KEY_LENGTH = 1184;\nexport const KYBER768_SECRET_KEY_LENGTH = 2400;\nexport const KYBER_SEED_LENGTH = 64;\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\nexport const XWING_PUBLIC_KEY_LENGTH = 1216;\nexport const XWING_SECRET_KEY_LENGTH = 32;\nexport const XWING_SEED_BYTE_LENGTH = 32;\nexport const XWING_CIPHERTEXT_BYTE_LENGTH = 1120;\n"],"mappings":";;AAAA,MAAa,sBAAsB;AACnC,MAAa,eAAe;AAE5B,MAAa,uBAAuB;AACpC,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAGhC,MAAa,uBAAuB;AACpC,MAAa,sBAAsB;AACnC,MAAa,uBAAuB;AACpC,MAAa,4BAA4B;AACzC,MAAa,8BAA8B;AAE3C,MAAa,6BAA6B;AAC1C,MAAa,6BAA6B;AAC1C,MAAa,oBAAoB;AAEjC,MAAa,iBAAiB;AAC9B,MAAa,sBAAsB;AACnC,MAAa,WAAW;AACxB,MAAa,aAAa;AAE1B,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AACtC,MAAa,+BAA+B"}
|
package/dist/constants.mjs
CHANGED
|
@@ -22,7 +22,7 @@ const XWING_PUBLIC_KEY_LENGTH = 1216;
|
|
|
22
22
|
const XWING_SECRET_KEY_LENGTH = 32;
|
|
23
23
|
const XWING_SEED_BYTE_LENGTH = 32;
|
|
24
24
|
const XWING_CIPHERTEXT_BYTE_LENGTH = 1120;
|
|
25
|
-
|
|
26
25
|
//#endregion
|
|
27
26
|
export { AES_KEY_BYTE_LENGTH, ARGON2ID_ITERATIONS, ARGON2ID_MEMORY_SIZE, ARGON2ID_OUTPUT_BYTE_LENGTH, ARGON2ID_PARALLELISM, ARGON2ID_SALT_BYTE_LENGTH, CONTEXT_DATABASE, CONTEXT_DRAFT, CONTEXT_ENC_KEYSTORE, CONTEXT_RECOVERY, CONTEXT_TWO_KEYS, DB_LABEL, DB_VERSION, IV_LEN_BYTES, KYBER768_PUBLIC_KEY_LENGTH, KYBER768_SECRET_KEY_LENGTH, KYBER_SEED_LENGTH, MAX_CACHE_SIZE, MAX_EMAIL_PER_BATCH, XWING_CIPHERTEXT_BYTE_LENGTH, XWING_PUBLIC_KEY_LENGTH, XWING_SECRET_KEY_LENGTH, XWING_SEED_BYTE_LENGTH };
|
|
27
|
+
|
|
28
28
|
//# sourceMappingURL=constants.mjs.map
|
package/dist/derive-key.js
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./chunk-C13QxCFV.js");
|
|
3
|
+
const require_constants = require("./constants.js");
|
|
4
|
+
const require_utils = require("./utils.js");
|
|
5
|
+
let _noble_hashes_blake3_js = require("@noble/hashes/blake3.js");
|
|
6
|
+
//#region src/derive-key/deriveKeysFromKey.ts
|
|
7
|
+
/**
|
|
8
|
+
* Derives a symmetric key from the base key and context string
|
|
9
|
+
*
|
|
10
|
+
* @param context - The context string.
|
|
11
|
+
* The context string should be hardcoded, globally unique, and application-specific.
|
|
12
|
+
* @param baseKey - The base key (NOT PASSWORD!)
|
|
13
|
+
* @returns The derived secret key
|
|
14
|
+
*/
|
|
15
|
+
function deriveSymmetricKeyFromContext(context, baseKey) {
|
|
16
|
+
return (0, _noble_hashes_blake3_js.blake3)(baseKey, { context: require_utils.UTF8ToUint8(context) });
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Derives a symmetric key from two keys
|
|
20
|
+
*
|
|
21
|
+
* @param key1 - The 32-bytes key
|
|
22
|
+
* @param key2 - The 32-bytes key
|
|
23
|
+
* @returns The derived secret key
|
|
24
|
+
*/
|
|
25
|
+
function deriveSymmetricKeyFromTwoKeys(key1, key2) {
|
|
26
|
+
try {
|
|
27
|
+
if (key2.length !== 32 || key1.length !== 32) throw new Error(`Input key length must be exactly 32 bytes`);
|
|
28
|
+
return deriveSymmetricKeyFromContext(require_constants.CONTEXT_TWO_KEYS, (0, _noble_hashes_blake3_js.blake3)(key1, { key: key2 }));
|
|
29
|
+
} catch (error) {
|
|
30
|
+
throw new Error("Failed to derive symmetric key from two keys and context", { cause: error });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/derive-key/deriveKeysFromMnemonic.ts
|
|
35
|
+
/**
|
|
36
|
+
* Derives encryption key from the user's mnemonic and context string
|
|
37
|
+
*
|
|
38
|
+
* @param mnemonic - The user's mnemonic (machine-generated with secure PRNG)
|
|
39
|
+
* @param context - The context string.
|
|
40
|
+
* The context string should be hardcoded, globally unique, and application-specific.
|
|
41
|
+
* @returns The symmetric key for protecting database
|
|
42
|
+
*/
|
|
43
|
+
const deriveKeyFromMnemonic = async (mnemonic, context) => {
|
|
44
|
+
return deriveSymmetricKeyFromContext(context, require_utils.mnemonicToBytes(mnemonic));
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.deriveKeyFromMnemonic = deriveKeyFromMnemonic;
|
|
48
|
+
exports.deriveSymmetricKeyFromContext = deriveSymmetricKeyFromContext;
|
|
49
|
+
exports.deriveSymmetricKeyFromTwoKeys = deriveSymmetricKeyFromTwoKeys;
|
|
3
50
|
|
|
4
|
-
|
|
5
|
-
exports.deriveSymmetricKeyFromContext = require_deriveKeysFromMnemonic.deriveSymmetricKeyFromContext;
|
|
6
|
-
exports.deriveSymmetricKeyFromTwoKeys = require_deriveKeysFromMnemonic.deriveSymmetricKeyFromTwoKeys;
|
|
51
|
+
//# sourceMappingURL=derive-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-key.js","names":["UTF8ToUint8","CONTEXT_TWO_KEYS","mnemonicToBytes"],"sources":["../src/derive-key/deriveKeysFromKey.ts","../src/derive-key/deriveKeysFromMnemonic.ts"],"sourcesContent":["import { blake3 } from '@noble/hashes/blake3.js';\nimport { AES_KEY_BYTE_LENGTH, CONTEXT_TWO_KEYS } from '../constants';\nimport { UTF8ToUint8 } from '../utils';\n\n/**\n * Derives a symmetric key from the base key and context string\n *\n * @param context - The context string.\n * The context string should be hardcoded, globally unique, and application-specific.\n * @param baseKey - The base key (NOT PASSWORD!)\n * @returns The derived secret key\n */\nexport function deriveSymmetricKeyFromContext(context: string, baseKey: Uint8Array): Uint8Array {\n return blake3(baseKey, { context: UTF8ToUint8(context) });\n}\n\n/**\n * Derives a symmetric key from two keys\n *\n * @param key1 - The 32-bytes key\n * @param key2 - The 32-bytes key\n * @returns The derived secret key\n */\nexport function deriveSymmetricKeyFromTwoKeys(key1: Uint8Array, key2: Uint8Array): Uint8Array {\n try {\n if (key2.length !== AES_KEY_BYTE_LENGTH || key1.length !== AES_KEY_BYTE_LENGTH) {\n throw new Error(`Input key length must be exactly ${AES_KEY_BYTE_LENGTH} bytes`);\n }\n const key = blake3(key1, { key: key2 });\n return deriveSymmetricKeyFromContext(CONTEXT_TWO_KEYS, key);\n } catch (error) {\n throw new Error('Failed to derive symmetric key from two keys and context', { cause: error });\n }\n}\n","import { mnemonicToBytes } from '../utils';\nimport { deriveSymmetricKeyFromContext } from './deriveKeysFromKey';\n\n/**\n * Derives encryption key from the user's mnemonic and context string\n *\n * @param mnemonic - The user's mnemonic (machine-generated with secure PRNG)\n * @param context - The context string.\n * The context string should be hardcoded, globally unique, and application-specific.\n * @returns The symmetric key for protecting database\n */\nexport const deriveKeyFromMnemonic = async (mnemonic: string, context: string): Promise<Uint8Array> => {\n // mnemonic is always machine-generated with secure PRNG, so it is safe to convert it to bytes without additional processing\n const entropy = mnemonicToBytes(mnemonic);\n return deriveSymmetricKeyFromContext(context, entropy);\n};\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,8BAA8B,SAAiB,SAAiC;AAC9F,SAAA,GAAA,wBAAA,QAAc,SAAS,EAAE,SAASA,cAAAA,YAAY,QAAQ,EAAE,CAAC;;;;;;;;;AAU3D,SAAgB,8BAA8B,MAAkB,MAA8B;AAC5F,KAAI;AACF,MAAI,KAAK,WAAA,MAAkC,KAAK,WAAA,GAC9C,OAAM,IAAI,MAAM,4CAAgE;AAGlF,SAAO,8BAA8BC,kBAAAA,mBAAAA,GAAAA,wBAAAA,QADlB,MAAM,EAAE,KAAK,MAAM,CACoB,CAAC;UACpD,OAAO;AACd,QAAM,IAAI,MAAM,4DAA4D,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;;;ACpBjG,MAAa,wBAAwB,OAAO,UAAkB,YAAyC;AAGrG,QAAO,8BAA8B,SADrBC,cAAAA,gBAAgB,SACqB,CAAC"}
|
package/dist/derive-key.mjs
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTEXT_TWO_KEYS } from "./constants.mjs";
|
|
2
|
+
import { UTF8ToUint8, mnemonicToBytes } from "./utils.mjs";
|
|
3
|
+
import { blake3 } from "@noble/hashes/blake3.js";
|
|
4
|
+
//#region src/derive-key/deriveKeysFromKey.ts
|
|
5
|
+
/**
|
|
6
|
+
* Derives a symmetric key from the base key and context string
|
|
7
|
+
*
|
|
8
|
+
* @param context - The context string.
|
|
9
|
+
* The context string should be hardcoded, globally unique, and application-specific.
|
|
10
|
+
* @param baseKey - The base key (NOT PASSWORD!)
|
|
11
|
+
* @returns The derived secret key
|
|
12
|
+
*/
|
|
13
|
+
function deriveSymmetricKeyFromContext(context, baseKey) {
|
|
14
|
+
return blake3(baseKey, { context: UTF8ToUint8(context) });
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Derives a symmetric key from two keys
|
|
18
|
+
*
|
|
19
|
+
* @param key1 - The 32-bytes key
|
|
20
|
+
* @param key2 - The 32-bytes key
|
|
21
|
+
* @returns The derived secret key
|
|
22
|
+
*/
|
|
23
|
+
function deriveSymmetricKeyFromTwoKeys(key1, key2) {
|
|
24
|
+
try {
|
|
25
|
+
if (key2.length !== 32 || key1.length !== 32) throw new Error(`Input key length must be exactly 32 bytes`);
|
|
26
|
+
return deriveSymmetricKeyFromContext(CONTEXT_TWO_KEYS, blake3(key1, { key: key2 }));
|
|
27
|
+
} catch (error) {
|
|
28
|
+
throw new Error("Failed to derive symmetric key from two keys and context", { cause: error });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/derive-key/deriveKeysFromMnemonic.ts
|
|
33
|
+
/**
|
|
34
|
+
* Derives encryption key from the user's mnemonic and context string
|
|
35
|
+
*
|
|
36
|
+
* @param mnemonic - The user's mnemonic (machine-generated with secure PRNG)
|
|
37
|
+
* @param context - The context string.
|
|
38
|
+
* The context string should be hardcoded, globally unique, and application-specific.
|
|
39
|
+
* @returns The symmetric key for protecting database
|
|
40
|
+
*/
|
|
41
|
+
const deriveKeyFromMnemonic = async (mnemonic, context) => {
|
|
42
|
+
return deriveSymmetricKeyFromContext(context, mnemonicToBytes(mnemonic));
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { deriveKeyFromMnemonic, deriveSymmetricKeyFromContext, deriveSymmetricKeyFromTwoKeys };
|
|
2
46
|
|
|
3
|
-
|
|
47
|
+
//# sourceMappingURL=derive-key.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-key.mjs","names":[],"sources":["../src/derive-key/deriveKeysFromKey.ts","../src/derive-key/deriveKeysFromMnemonic.ts"],"sourcesContent":["import { blake3 } from '@noble/hashes/blake3.js';\nimport { AES_KEY_BYTE_LENGTH, CONTEXT_TWO_KEYS } from '../constants';\nimport { UTF8ToUint8 } from '../utils';\n\n/**\n * Derives a symmetric key from the base key and context string\n *\n * @param context - The context string.\n * The context string should be hardcoded, globally unique, and application-specific.\n * @param baseKey - The base key (NOT PASSWORD!)\n * @returns The derived secret key\n */\nexport function deriveSymmetricKeyFromContext(context: string, baseKey: Uint8Array): Uint8Array {\n return blake3(baseKey, { context: UTF8ToUint8(context) });\n}\n\n/**\n * Derives a symmetric key from two keys\n *\n * @param key1 - The 32-bytes key\n * @param key2 - The 32-bytes key\n * @returns The derived secret key\n */\nexport function deriveSymmetricKeyFromTwoKeys(key1: Uint8Array, key2: Uint8Array): Uint8Array {\n try {\n if (key2.length !== AES_KEY_BYTE_LENGTH || key1.length !== AES_KEY_BYTE_LENGTH) {\n throw new Error(`Input key length must be exactly ${AES_KEY_BYTE_LENGTH} bytes`);\n }\n const key = blake3(key1, { key: key2 });\n return deriveSymmetricKeyFromContext(CONTEXT_TWO_KEYS, key);\n } catch (error) {\n throw new Error('Failed to derive symmetric key from two keys and context', { cause: error });\n }\n}\n","import { mnemonicToBytes } from '../utils';\nimport { deriveSymmetricKeyFromContext } from './deriveKeysFromKey';\n\n/**\n * Derives encryption key from the user's mnemonic and context string\n *\n * @param mnemonic - The user's mnemonic (machine-generated with secure PRNG)\n * @param context - The context string.\n * The context string should be hardcoded, globally unique, and application-specific.\n * @returns The symmetric key for protecting database\n */\nexport const deriveKeyFromMnemonic = async (mnemonic: string, context: string): Promise<Uint8Array> => {\n // mnemonic is always machine-generated with secure PRNG, so it is safe to convert it to bytes without additional processing\n const entropy = mnemonicToBytes(mnemonic);\n return deriveSymmetricKeyFromContext(context, entropy);\n};\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,8BAA8B,SAAiB,SAAiC;AAC9F,QAAO,OAAO,SAAS,EAAE,SAAS,YAAY,QAAQ,EAAE,CAAC;;;;;;;;;AAU3D,SAAgB,8BAA8B,MAAkB,MAA8B;AAC5F,KAAI;AACF,MAAI,KAAK,WAAA,MAAkC,KAAK,WAAA,GAC9C,OAAM,IAAI,MAAM,4CAAgE;AAGlF,SAAO,8BAA8B,kBADzB,OAAO,MAAM,EAAE,KAAK,MAAM,CACoB,CAAC;UACpD,OAAO;AACd,QAAM,IAAI,MAAM,4DAA4D,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;;;ACpBjG,MAAa,wBAAwB,OAAO,UAAkB,YAAyC;AAGrG,QAAO,8BAA8B,SADrB,gBAAgB,SACqB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_chunk = require(
|
|
2
|
-
const require_constants = require(
|
|
1
|
+
const require_chunk = require("./chunk-C13QxCFV.js");
|
|
2
|
+
const require_constants = require("./constants.js");
|
|
3
3
|
let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
|
|
4
|
-
|
|
5
|
-
//#region
|
|
6
|
-
var
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/derive-password/core.ts
|
|
6
|
+
var import_index_umd = (/* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
|
|
7
7
|
/*!
|
|
8
8
|
* hash-wasm (https://www.npmjs.com/package/hash-wasm)
|
|
9
9
|
* (c) Dani Biro
|
|
@@ -2234,11 +2234,7 @@ var require_index_umd = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
2234
2234
|
exports$1.xxhash32 = xxhash32;
|
|
2235
2235
|
exports$1.xxhash64 = xxhash64;
|
|
2236
2236
|
}));
|
|
2237
|
-
}));
|
|
2238
|
-
|
|
2239
|
-
//#endregion
|
|
2240
|
-
//#region src/derive-password/core.ts
|
|
2241
|
-
var import_index_umd = require_index_umd();
|
|
2237
|
+
})))();
|
|
2242
2238
|
/**
|
|
2243
2239
|
* Calculates hash using the argon2id password-hashing function
|
|
2244
2240
|
*
|
|
@@ -2250,7 +2246,7 @@ var import_index_umd = require_index_umd();
|
|
|
2250
2246
|
* @param hashLength - The desired hash byte length
|
|
2251
2247
|
* @returns The resulting hash
|
|
2252
2248
|
*/
|
|
2253
|
-
async function argon2(password, salt, parallelism =
|
|
2249
|
+
async function argon2(password, salt, parallelism = 3, iterations = 4, memorySize = require_constants.ARGON2ID_MEMORY_SIZE, hashLength = 32) {
|
|
2254
2250
|
return (0, import_index_umd.argon2id)({
|
|
2255
2251
|
password,
|
|
2256
2252
|
salt,
|
|
@@ -2261,7 +2257,6 @@ async function argon2(password, salt, parallelism = require_constants.ARGON2ID_P
|
|
|
2261
2257
|
outputType: "binary"
|
|
2262
2258
|
});
|
|
2263
2259
|
}
|
|
2264
|
-
|
|
2265
2260
|
//#endregion
|
|
2266
2261
|
//#region src/derive-password/deriveKeysFromPassword.ts
|
|
2267
2262
|
/**
|
|
@@ -2270,7 +2265,7 @@ async function argon2(password, salt, parallelism = require_constants.ARGON2ID_P
|
|
|
2270
2265
|
* @returns The salt
|
|
2271
2266
|
*/
|
|
2272
2267
|
function generateSalt() {
|
|
2273
|
-
return (0, _noble_hashes_utils_js.randomBytes)(
|
|
2268
|
+
return (0, _noble_hashes_utils_js.randomBytes)(16);
|
|
2274
2269
|
}
|
|
2275
2270
|
/**
|
|
2276
2271
|
* Derives a symmetric key from a user's password with a randomly sampled salt
|
|
@@ -2303,24 +2298,24 @@ async function getKeyFromPasswordAndSalt(password, salt) {
|
|
|
2303
2298
|
throw new Error("Failed to derive key from password and salt", { cause: error });
|
|
2304
2299
|
}
|
|
2305
2300
|
}
|
|
2306
|
-
|
|
2307
2301
|
//#endregion
|
|
2308
|
-
Object.defineProperty(exports,
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2302
|
+
Object.defineProperty(exports, "generateSalt", {
|
|
2303
|
+
enumerable: true,
|
|
2304
|
+
get: function() {
|
|
2305
|
+
return generateSalt;
|
|
2306
|
+
}
|
|
2313
2307
|
});
|
|
2314
|
-
Object.defineProperty(exports,
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2308
|
+
Object.defineProperty(exports, "getKeyFromPassword", {
|
|
2309
|
+
enumerable: true,
|
|
2310
|
+
get: function() {
|
|
2311
|
+
return getKeyFromPassword;
|
|
2312
|
+
}
|
|
2319
2313
|
});
|
|
2320
|
-
Object.defineProperty(exports,
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2314
|
+
Object.defineProperty(exports, "getKeyFromPasswordAndSalt", {
|
|
2315
|
+
enumerable: true,
|
|
2316
|
+
get: function() {
|
|
2317
|
+
return getKeyFromPasswordAndSalt;
|
|
2318
|
+
}
|
|
2325
2319
|
});
|
|
2326
|
-
|
|
2320
|
+
|
|
2321
|
+
//# sourceMappingURL=derive-password-CbYRDq7V.js.map
|