internxt-crypto 0.0.14 → 1.0.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.
Files changed (144) hide show
  1. package/README.md +44 -72
  2. package/dist/aes-B8TA-JKq.mjs +49 -0
  3. package/dist/aes-B8TA-JKq.mjs.map +1 -0
  4. package/dist/aes-CuW_SPl-.js +67 -0
  5. package/dist/aes-CuW_SPl-.js.map +1 -0
  6. package/dist/asymmetric-crypto.d.mts +8 -31
  7. package/dist/asymmetric-crypto.d.mts.map +1 -1
  8. package/dist/asymmetric-crypto.d.ts +8 -31
  9. package/dist/asymmetric-crypto.d.ts.map +1 -1
  10. package/dist/asymmetric-crypto.js +30 -7
  11. package/dist/asymmetric-crypto.js.map +1 -0
  12. package/dist/asymmetric-crypto.mjs +28 -2
  13. package/dist/asymmetric-crypto.mjs.map +1 -0
  14. package/dist/constants.d.mts +3 -10
  15. package/dist/constants.d.mts.map +1 -1
  16. package/dist/constants.d.ts +3 -10
  17. package/dist/constants.d.ts.map +1 -1
  18. package/dist/constants.js +3 -17
  19. package/dist/constants.js.map +1 -1
  20. package/dist/constants.mjs +3 -10
  21. package/dist/constants.mjs.map +1 -1
  22. package/dist/core-Bj26rNdA.js +227 -0
  23. package/dist/core-Bj26rNdA.js.map +1 -0
  24. package/dist/core-pEGygy6S.mjs +173 -0
  25. package/dist/core-pEGygy6S.mjs.map +1 -0
  26. package/dist/derive-key.d.mts +1 -74
  27. package/dist/derive-key.d.mts.map +1 -1
  28. package/dist/derive-key.d.ts +1 -74
  29. package/dist/derive-key.d.ts.map +1 -1
  30. package/dist/derive-key.js +3 -11
  31. package/dist/derive-key.mjs +2 -2
  32. package/dist/derive-password.d.mts +22 -0
  33. package/dist/derive-password.d.mts.map +1 -0
  34. package/dist/derive-password.d.ts +22 -0
  35. package/dist/derive-password.d.ts.map +1 -0
  36. package/dist/derive-password.js +5 -0
  37. package/dist/derive-password.mjs +3 -0
  38. package/dist/deriveKeysFromKey-C4McqO6_.js +47 -0
  39. package/dist/deriveKeysFromKey-C4McqO6_.js.map +1 -0
  40. package/dist/deriveKeysFromKey-DPU_h7wr.mjs +35 -0
  41. package/dist/deriveKeysFromKey-DPU_h7wr.mjs.map +1 -0
  42. package/dist/{deriveKeysFromPassword-BYaiSGKL.js → deriveKeysFromPassword-C7xAGGsh.js} +5 -172
  43. package/dist/deriveKeysFromPassword-C7xAGGsh.js.map +1 -0
  44. package/dist/{deriveKeysFromPassword-XIwzErlL.mjs → deriveKeysFromPassword-DXgSvTNC.mjs} +6 -125
  45. package/dist/deriveKeysFromPassword-DXgSvTNC.mjs.map +1 -0
  46. package/dist/email-crypto.d.mts +24 -46
  47. package/dist/email-crypto.d.mts.map +1 -1
  48. package/dist/email-crypto.d.ts +24 -46
  49. package/dist/email-crypto.d.ts.map +1 -1
  50. package/dist/email-crypto.js +121 -12
  51. package/dist/email-crypto.js.map +1 -0
  52. package/dist/email-crypto.mjs +115 -2
  53. package/dist/email-crypto.mjs.map +1 -0
  54. package/dist/email-search.d.mts.map +1 -1
  55. package/dist/email-search.d.ts.map +1 -1
  56. package/dist/email-search.js +25 -597
  57. package/dist/email-search.mjs +2 -573
  58. package/dist/{emailEncryptionKey-B9xHw1h_.mjs → emailEncryptionKey-BtSPYd9M.mjs} +22 -45
  59. package/dist/emailEncryptionKey-BtSPYd9M.mjs.map +1 -0
  60. package/dist/{emailEncryptionKey-CQNe5W_T.js → emailEncryptionKey-C4X1Bwy4.js} +22 -45
  61. package/dist/emailEncryptionKey-C4X1Bwy4.js.map +1 -0
  62. package/dist/{genID-3Er5IowC.mjs → genID-D08K7JPr.mjs} +4 -40
  63. package/dist/genID-D08K7JPr.mjs.map +1 -0
  64. package/dist/{genID-YJSl3YhL.js → genID-cWOPmspk.js} +2 -50
  65. package/dist/genID-cWOPmspk.js.map +1 -0
  66. package/dist/hash.d.mts +24 -36
  67. package/dist/hash.d.mts.map +1 -1
  68. package/dist/hash.d.ts +24 -36
  69. package/dist/hash.d.ts.map +1 -1
  70. package/dist/hash.js +88 -10
  71. package/dist/hash.js.map +1 -0
  72. package/dist/hash.mjs +82 -2
  73. package/dist/hash.mjs.map +1 -0
  74. package/dist/index.d.mts +9 -8
  75. package/dist/index.d.mts.map +1 -1
  76. package/dist/index.d.ts +9 -8
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +56 -79
  79. package/dist/index.mjs +13 -11
  80. package/dist/keystore-crypto.d.mts +6 -6
  81. package/dist/keystore-crypto.d.mts.map +1 -1
  82. package/dist/keystore-crypto.d.ts +6 -6
  83. package/dist/keystore-crypto.d.ts.map +1 -1
  84. package/dist/keystore-crypto.js +1 -1
  85. package/dist/keystore-crypto.mjs +1 -1
  86. package/dist/post-quantum-crypto.js +49 -4
  87. package/dist/post-quantum-crypto.js.map +1 -0
  88. package/dist/post-quantum-crypto.mjs +46 -2
  89. package/dist/post-quantum-crypto.mjs.map +1 -0
  90. package/dist/search-B9YM3XAA.mjs +587 -0
  91. package/dist/search-B9YM3XAA.mjs.map +1 -0
  92. package/dist/search-DUTm4-rN.js +731 -0
  93. package/dist/search-DUTm4-rN.js.map +1 -0
  94. package/dist/symmetric-crypto.d.mts +11 -40
  95. package/dist/symmetric-crypto.d.mts.map +1 -1
  96. package/dist/symmetric-crypto.d.ts +11 -40
  97. package/dist/symmetric-crypto.d.ts.map +1 -1
  98. package/dist/symmetric-crypto.js +2 -6
  99. package/dist/symmetric-crypto.mjs +2 -2
  100. package/dist/types.d.mts +13 -40
  101. package/dist/types.d.mts.map +1 -1
  102. package/dist/types.d.ts +13 -40
  103. package/dist/types.d.ts.map +1 -1
  104. package/dist/types.js.map +1 -1
  105. package/dist/types.mjs.map +1 -1
  106. package/dist/utils.d.mts +1 -19
  107. package/dist/utils.d.mts.map +1 -1
  108. package/dist/utils.d.ts +1 -19
  109. package/dist/utils.d.ts.map +1 -1
  110. package/dist/utils.js +1 -3
  111. package/dist/utils.mjs +2 -2
  112. package/dist/xwing-CQmQX6hn.mjs +16 -0
  113. package/dist/xwing-CQmQX6hn.mjs.map +1 -0
  114. package/dist/xwing-iRWVRtNE.js +34 -0
  115. package/dist/xwing-iRWVRtNE.js.map +1 -0
  116. package/package.json +3 -2
  117. package/dist/aes-DCb9dJqb.mjs +0 -161
  118. package/dist/aes-DCb9dJqb.mjs.map +0 -1
  119. package/dist/aes-DQo1MyCz.js +0 -203
  120. package/dist/aes-DQo1MyCz.js.map +0 -1
  121. package/dist/deriveKeysFromPassword-BYaiSGKL.js.map +0 -1
  122. package/dist/deriveKeysFromPassword-XIwzErlL.mjs.map +0 -1
  123. package/dist/email-search.js.map +0 -1
  124. package/dist/email-search.mjs.map +0 -1
  125. package/dist/emailEncryptionKey-B9xHw1h_.mjs.map +0 -1
  126. package/dist/emailEncryptionKey-CQNe5W_T.js.map +0 -1
  127. package/dist/emailKeys-C0KhtfNP.js +0 -572
  128. package/dist/emailKeys-C0KhtfNP.js.map +0 -1
  129. package/dist/emailKeys-D4lp9NRv.mjs +0 -488
  130. package/dist/emailKeys-D4lp9NRv.mjs.map +0 -1
  131. package/dist/genID-3Er5IowC.mjs.map +0 -1
  132. package/dist/genID-YJSl3YhL.js.map +0 -1
  133. package/dist/keys-BfcaiAOv.mjs +0 -90
  134. package/dist/keys-BfcaiAOv.mjs.map +0 -1
  135. package/dist/keys-CinT7kEY.js +0 -125
  136. package/dist/keys-CinT7kEY.js.map +0 -1
  137. package/dist/kyber768-SXnIo-Nw.mjs +0 -47
  138. package/dist/kyber768-SXnIo-Nw.mjs.map +0 -1
  139. package/dist/kyber768-WUVc2fIR.js +0 -65
  140. package/dist/kyber768-WUVc2fIR.js.map +0 -1
  141. package/dist/mac-BMb1F0dN.js +0 -170
  142. package/dist/mac-BMb1F0dN.js.map +0 -1
  143. package/dist/mac-ZpRlx8Fs.mjs +0 -116
  144. package/dist/mac-ZpRlx8Fs.mjs.map +0 -1
@@ -1,80 +1,6 @@
1
- import { AES_KEY_BIT_LENGTH, ARGON2ID_ITERATIONS, ARGON2ID_MEMORY_SIZE, ARGON2ID_OUTPUT_BYTE_LENGTH, ARGON2ID_PARALLELISM, ARGON2ID_SALT_BYTE_LENGTH, CONTEXT_DERIVE } from "./constants.mjs";
2
- import { d as hexToUint8Array, l as UTF8ToUint8, p as uint8ArrayToHex } from "./genID-3Er5IowC.mjs";
3
- import { s as importSymmetricCryptoKey } from "./aes-DCb9dJqb.mjs";
4
- import { blake3 } from "@noble/hashes/blake3.js";
5
- import { randomBytes } from "@noble/post-quantum/utils.js";
1
+ import { ARGON2ID_ITERATIONS, ARGON2ID_MEMORY_SIZE, ARGON2ID_OUTPUT_BYTE_LENGTH, ARGON2ID_PARALLELISM, ARGON2ID_SALT_BYTE_LENGTH } from "./constants.mjs";
2
+ import { randomBytes } from "@noble/hashes/utils.js";
6
3
 
7
- //#region src/derive-key/deriveKeysFromKey.ts
8
- /**
9
- * Derives a symmetric key from the base key and context string
10
- *
11
- * @param context - The context string.
12
- * The context string should be hardcoded, globally unique, and application-specific.
13
- * @param baseKey - The base key (NOT PASSWORD!)
14
- * @returns The derived secret key
15
- */
16
- function deriveSymmetricKeyFromContext(context, baseKey) {
17
- return blake3(baseKey, { context: UTF8ToUint8(context) });
18
- }
19
- /**
20
- * Derives a symmetric CryptoKey from the base key and context string
21
- *
22
- * @param context - The context string.
23
- * The context string should be hardcoded, globally unique, and application-specific.
24
- * @param baseKey - The base key (NOT PASSWORD!)
25
- * @returns The derived secret CryptoKey
26
- */
27
- async function deriveSymmetricCryptoKeyFromContext(context, baseKey) {
28
- try {
29
- if (baseKey.length != AES_KEY_BIT_LENGTH / 8) throw new Error(`Base key length must be exactly ${AES_KEY_BIT_LENGTH / 8} bytes`);
30
- if (!context) throw new Error("Context is empry");
31
- return await importSymmetricCryptoKey(deriveSymmetricKeyFromContext(context, baseKey));
32
- } catch (error) {
33
- throw new Error("Failed to derive CryptoKey from base key and context", { cause: error });
34
- }
35
- }
36
- /**
37
- * Derives a symmetric key from two keys
38
- *
39
- * @param key1 - The 32-bytes key
40
- * @param key2 - The 32-bytes key
41
- * @returns The derived secret key
42
- */
43
- function deriveSymmetricKeyFromTwoKeys(key1, key2) {
44
- return deriveSymmetricKeyFromTwoKeysAndContext(key1, key2, CONTEXT_DERIVE);
45
- }
46
- /**
47
- * Derives a symmetric CryptoKey from two keys
48
- *
49
- * @param key1 - The 32-bytes key
50
- * @param key2 - The 32-bytes key
51
- * @returns The derived secret CryptoKey
52
- */
53
- async function deriveSymmetricCryptoKeyFromTwoKeys(key1, key2) {
54
- try {
55
- return await importSymmetricCryptoKey(deriveSymmetricKeyFromTwoKeys(key1, key2));
56
- } catch (error) {
57
- throw new Error("Failed to derive symmetric CryptoKey from two keys", { cause: error });
58
- }
59
- }
60
- /**
61
- * Derives a symmetric key from two keys and context
62
- *
63
- * @param key1 - The 32-bytes key
64
- * @param key2 - The 32-bytes key
65
- * @param context - The context string
66
- * @returns The derived symmetric key
67
- */
68
- function deriveSymmetricKeyFromTwoKeysAndContext(key1, key2, context) {
69
- try {
70
- if (key2.length != AES_KEY_BIT_LENGTH / 8 || key1.length != AES_KEY_BIT_LENGTH / 8) throw new Error(`Input key length must be exactly ${AES_KEY_BIT_LENGTH / 8} bytes`);
71
- return blake3(blake3(key1, { key: key2 }), { context: UTF8ToUint8(context) });
72
- } catch (error) {
73
- throw new Error("Failed to derive symmetric key from two keys and context", { cause: error });
74
- }
75
- }
76
-
77
- //#endregion
78
4
  //#region node_modules/hash-wasm/dist/index.esm.js
79
5
  /******************************************************************************
80
6
  Copyright (c) Microsoft Corporation.
@@ -614,7 +540,7 @@ const mutex$1 = new Mutex();
614
540
  const mutex = new Mutex();
615
541
 
616
542
  //#endregion
617
- //#region src/derive-key/core.ts
543
+ //#region src/derive-password/core.ts
618
544
  /**
619
545
  * Calculates hash using the argon2id password-hashing function
620
546
  *
@@ -647,7 +573,7 @@ function sampleSalt() {
647
573
  }
648
574
 
649
575
  //#endregion
650
- //#region src/derive-key/deriveKeysFromPassword.ts
576
+ //#region src/derive-password/deriveKeysFromPassword.ts
651
577
  /**
652
578
  * Derives a symmetric key from a user's password with a randomly sampled salt
653
579
  *
@@ -656,7 +582,6 @@ function sampleSalt() {
656
582
  */
657
583
  async function getKeyFromPassword(password) {
658
584
  try {
659
- if (!password) throw new Error("No password given");
660
585
  const salt = sampleSalt();
661
586
  return {
662
587
  key: await argon2(password, salt),
@@ -675,56 +600,12 @@ async function getKeyFromPassword(password) {
675
600
  */
676
601
  async function getKeyFromPasswordAndSalt(password, salt) {
677
602
  try {
678
- if (!salt.length) throw new Error("No salt given");
679
- if (!password) throw new Error("No password given");
680
603
  return await argon2(password, salt);
681
604
  } catch (error) {
682
605
  throw new Error("Failed to derive key from password and salt", { cause: error });
683
606
  }
684
607
  }
685
- /**
686
- * Derives a HEX symmetric key from a user's password with a randomly sampled salt
687
- *
688
- * @param password - The user's password
689
- * @returns The derived HEX secret key and randomly sampled HEX salt
690
- */
691
- async function getKeyFromPasswordHex(password) {
692
- try {
693
- const { key, salt } = await getKeyFromPassword(password);
694
- return {
695
- keyHex: uint8ArrayToHex(key),
696
- saltHex: uint8ArrayToHex(salt)
697
- };
698
- } catch (error) {
699
- throw new Error("Failed to derive key from password", { cause: error });
700
- }
701
- }
702
- /**
703
- * Derives a HEX symmetric key from a user's password and salt
704
- *
705
- * @param password - The user's password
706
- * @param saltHex - The given HEX salt
707
- * @returns The derived HEX secret key
708
- */
709
- async function getKeyFromPasswordAndSaltHex(password, saltHex) {
710
- try {
711
- return uint8ArrayToHex(await getKeyFromPasswordAndSalt(password, hexToUint8Array(saltHex)));
712
- } catch (error) {
713
- throw new Error("Failed to derive key from password and salt", { cause: error });
714
- }
715
- }
716
- /**
717
- * Verifies the derived key
718
- *
719
- * @param password - The user's password
720
- * @param saltHex - The given HEX salt
721
- * @param keyHex - The derived HEX key
722
- * @returns The result of the key verification
723
- */
724
- async function verifyKeyFromPasswordHex(password, saltHex, keyHex) {
725
- return keyHex === await getKeyFromPasswordAndSaltHex(password, saltHex);
726
- }
727
608
 
728
609
  //#endregion
729
- export { verifyKeyFromPasswordHex as a, deriveSymmetricKeyFromContext as c, getKeyFromPasswordHex as i, deriveSymmetricKeyFromTwoKeys as l, getKeyFromPasswordAndSalt as n, deriveSymmetricCryptoKeyFromContext as o, getKeyFromPasswordAndSaltHex as r, deriveSymmetricCryptoKeyFromTwoKeys as s, getKeyFromPassword as t, deriveSymmetricKeyFromTwoKeysAndContext as u };
730
- //# sourceMappingURL=deriveKeysFromPassword-XIwzErlL.mjs.map
610
+ export { getKeyFromPasswordAndSalt as n, getKeyFromPassword as t };
611
+ //# sourceMappingURL=deriveKeysFromPassword-DXgSvTNC.mjs.map