internxt-crypto 1.2.0 → 1.3.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 (100) hide show
  1. package/README.md +4 -4
  2. package/dist/asymmetric-crypto.js +3 -4
  3. package/dist/asymmetric-crypto.js.map +1 -1
  4. package/dist/asymmetric-crypto.mjs +1 -2
  5. package/dist/asymmetric-crypto.mjs.map +1 -1
  6. package/dist/chunk-C13QxCFV.js +50 -0
  7. package/dist/chunk-CfYAbeIz.mjs +13 -0
  8. package/dist/constants.js +2 -3
  9. package/dist/constants.js.map +1 -1
  10. package/dist/constants.mjs +1 -1
  11. package/dist/derive-key.js +50 -5
  12. package/dist/derive-key.js.map +1 -0
  13. package/dist/derive-key.mjs +46 -2
  14. package/dist/derive-key.mjs.map +1 -0
  15. package/dist/{deriveKeysFromPassword-iMHv-tIA.js → derive-password-CbYRDq7V.js} +25 -30
  16. package/dist/derive-password-CbYRDq7V.js.map +1 -0
  17. package/dist/{deriveKeysFromPassword-DFzo2OII.mjs → derive-password-PED-YfwE.mjs} +27 -34
  18. package/dist/derive-password-PED-YfwE.mjs.map +1 -0
  19. package/dist/derive-password.js +5 -6
  20. package/dist/derive-password.mjs +2 -3
  21. package/dist/{emailKeys-BFI-paQq.js → email-crypto-Cr7znO1a.js} +116 -121
  22. package/dist/email-crypto-Cr7znO1a.js.map +1 -0
  23. package/dist/{emailKeys-BjIeINfC.mjs → email-crypto-cHDsjSb5.mjs} +7 -12
  24. package/dist/email-crypto-cHDsjSb5.mjs.map +1 -0
  25. package/dist/email-crypto.d.mts +1 -1
  26. package/dist/email-crypto.d.ts +1 -1
  27. package/dist/email-crypto.js +17 -18
  28. package/dist/email-crypto.mjs +2 -3
  29. package/dist/hash.js +3 -4
  30. package/dist/hash.js.map +1 -1
  31. package/dist/hash.mjs +1 -2
  32. package/dist/hash.mjs.map +1 -1
  33. package/dist/index.d.mts +3 -3
  34. package/dist/index.d.ts +3 -3
  35. package/dist/index.js +55 -55
  36. package/dist/index.mjs +7 -8
  37. package/dist/{emailEncryptionKey-D9sk_WKj.mjs → keystore-crypto-C6F-NQdX.mjs} +48 -64
  38. package/dist/keystore-crypto-C6F-NQdX.mjs.map +1 -0
  39. package/dist/keystore-crypto-CFiiGohl.js +238 -0
  40. package/dist/keystore-crypto-CFiiGohl.js.map +1 -0
  41. package/dist/keystore-crypto.d.mts +18 -19
  42. package/dist/keystore-crypto.d.mts.map +1 -1
  43. package/dist/keystore-crypto.d.ts +18 -19
  44. package/dist/keystore-crypto.d.ts.map +1 -1
  45. package/dist/keystore-crypto.js +11 -11
  46. package/dist/keystore-crypto.mjs +2 -3
  47. package/dist/post-quantum-crypto.js +3 -4
  48. package/dist/post-quantum-crypto.js.map +1 -1
  49. package/dist/post-quantum-crypto.mjs +1 -2
  50. package/dist/post-quantum-crypto.mjs.map +1 -1
  51. package/dist/storage-service.js +13 -15
  52. package/dist/storage-service.js.map +1 -1
  53. package/dist/storage-service.mjs +2 -4
  54. package/dist/storage-service.mjs.map +1 -1
  55. package/dist/symmetric-crypto.js +51 -5
  56. package/dist/symmetric-crypto.js.map +1 -0
  57. package/dist/symmetric-crypto.mjs +47 -2
  58. package/dist/symmetric-crypto.mjs.map +1 -0
  59. package/dist/types-4P0WII1D.d.ts +49 -0
  60. package/dist/types-4P0WII1D.d.ts.map +1 -0
  61. package/dist/types-DAPJQG8U.d.mts +49 -0
  62. package/dist/types-DAPJQG8U.d.mts.map +1 -0
  63. package/dist/types.d.mts +2 -49
  64. package/dist/types.d.ts +2 -49
  65. package/dist/types.js +2 -3
  66. package/dist/types.js.map +1 -1
  67. package/dist/types.mjs +1 -1
  68. package/dist/types.mjs.map +1 -1
  69. package/dist/utils.js +127 -14
  70. package/dist/utils.js.map +1 -0
  71. package/dist/utils.mjs +113 -2
  72. package/dist/utils.mjs.map +1 -0
  73. package/dist/{xwing-iRWVRtNE.js → xwing-7fEqAT7W.js} +18 -19
  74. package/dist/{xwing-iRWVRtNE.js.map → xwing-7fEqAT7W.js.map} +1 -1
  75. package/dist/{xwing-CQmQX6hn.mjs → xwing-B34h5e3Z.mjs} +2 -3
  76. package/dist/{xwing-CQmQX6hn.mjs.map → xwing-B34h5e3Z.mjs.map} +1 -1
  77. package/package.json +22 -22
  78. package/dist/aes-B8TA-JKq.mjs +0 -49
  79. package/dist/aes-B8TA-JKq.mjs.map +0 -1
  80. package/dist/aes-CuW_SPl-.js +0 -67
  81. package/dist/aes-CuW_SPl-.js.map +0 -1
  82. package/dist/chunk-DQk6qfdC.mjs +0 -18
  83. package/dist/chunk-EbLFQX5m.js +0 -60
  84. package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs +0 -49
  85. package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs.map +0 -1
  86. package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js +0 -67
  87. package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js.map +0 -1
  88. package/dist/deriveKeysFromPassword-DFzo2OII.mjs.map +0 -1
  89. package/dist/deriveKeysFromPassword-iMHv-tIA.js.map +0 -1
  90. package/dist/emailEncryptionKey-Cw-vW_Oq.js +0 -248
  91. package/dist/emailEncryptionKey-Cw-vW_Oq.js.map +0 -1
  92. package/dist/emailEncryptionKey-D9sk_WKj.mjs.map +0 -1
  93. package/dist/emailKeys-BFI-paQq.js.map +0 -1
  94. package/dist/emailKeys-BjIeINfC.mjs.map +0 -1
  95. package/dist/genID-D08K7JPr.mjs +0 -117
  96. package/dist/genID-D08K7JPr.mjs.map +0 -1
  97. package/dist/genID-cWOPmspk.js +0 -190
  98. package/dist/genID-cWOPmspk.js.map +0 -1
  99. package/dist/types.d.mts.map +0 -1
  100. package/dist/types.d.ts.map +0 -1
package/README.md CHANGED
@@ -131,12 +131,12 @@ expect(decryptedEmail).toStrictEqual(email);
131
131
 
132
132
  // keystore
133
133
  const userEmail = 'user email';
134
- const password = 'user password';
135
- const { encryptionKeystore, recoveryKeystore, recoveryCodes, salt } = await createEncryptionAndRecoveryKeystores(
134
+ const mnemonic = 'user mnemonic';
135
+ const { encryptionKeystore, recoveryKeystore, recoveryCodes } = await createEncryptionAndRecoveryKeystores(
136
136
  userEmail,
137
- password
137
+ mnemonic
138
138
  );
139
- const resultEnc = await openEncryptionKeystore(encryptionKeystore, password, salt);
139
+ const resultEnc = await openEncryptionKeystore(encryptionKeystore, mnemonic);
140
140
  const resultRec = await openRecoveryKeystore(recoveryCodes, recoveryKeystore);
141
141
 
142
142
  expect(resultEnc).toStrictEqual(resultRec);
@@ -1,7 +1,6 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_chunk = require('./chunk-EbLFQX5m.js');
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":";;;;;;;;;;;;AASA,eAAsB,gBAAgB,gBAA4B,cAA+C;AAC/G,KAAI;AACF,SAAO,MAAMA,kCAAO,gBAAgB,gBAAgB,aAAa;UAC1D,OAAO;AACd,QAAM,IAAI,MAAM,8CAA8C,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASnF,eAAsB,kBAA6E;AACjG,QAAOA,kCAAO,QAAQ"}
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":";;;;;;;;;;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"}
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: 'Module' });
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
@@ -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":";;;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"}
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"}
@@ -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
@@ -1,6 +1,51 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_deriveKeysFromMnemonic = require('./deriveKeysFromMnemonic-Dbx7VSBQ.js');
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
- exports.deriveKeyFromMnemonic = require_deriveKeysFromMnemonic.deriveKeyFromMnemonic;
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"}
@@ -1,3 +1,47 @@
1
- import { n as deriveSymmetricKeyFromContext, r as deriveSymmetricKeyFromTwoKeys, t as deriveKeyFromMnemonic } from "./deriveKeysFromMnemonic-DB0UHE-y.mjs";
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
- export { deriveKeyFromMnemonic, deriveSymmetricKeyFromContext, deriveSymmetricKeyFromTwoKeys };
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('./chunk-EbLFQX5m.js');
2
- const require_constants = require('./constants.js');
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 node_modules/hash-wasm/dist/index.umd.js
6
- var require_index_umd = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
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 = require_constants.ARGON2ID_PARALLELISM, iterations = require_constants.ARGON2ID_ITERATIONS, memorySize = require_constants.ARGON2ID_MEMORY_SIZE, hashLength = require_constants.ARGON2ID_OUTPUT_BYTE_LENGTH) {
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)(require_constants.ARGON2ID_SALT_BYTE_LENGTH);
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, 'generateSalt', {
2309
- enumerable: true,
2310
- get: function () {
2311
- return generateSalt;
2312
- }
2302
+ Object.defineProperty(exports, "generateSalt", {
2303
+ enumerable: true,
2304
+ get: function() {
2305
+ return generateSalt;
2306
+ }
2313
2307
  });
2314
- Object.defineProperty(exports, 'getKeyFromPassword', {
2315
- enumerable: true,
2316
- get: function () {
2317
- return getKeyFromPassword;
2318
- }
2308
+ Object.defineProperty(exports, "getKeyFromPassword", {
2309
+ enumerable: true,
2310
+ get: function() {
2311
+ return getKeyFromPassword;
2312
+ }
2319
2313
  });
2320
- Object.defineProperty(exports, 'getKeyFromPasswordAndSalt', {
2321
- enumerable: true,
2322
- get: function () {
2323
- return getKeyFromPasswordAndSalt;
2324
- }
2314
+ Object.defineProperty(exports, "getKeyFromPasswordAndSalt", {
2315
+ enumerable: true,
2316
+ get: function() {
2317
+ return getKeyFromPasswordAndSalt;
2318
+ }
2325
2319
  });
2326
- //# sourceMappingURL=deriveKeysFromPassword-iMHv-tIA.js.map
2320
+
2321
+ //# sourceMappingURL=derive-password-CbYRDq7V.js.map