internxt-crypto 1.3.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 (96) hide show
  1. package/dist/asymmetric-crypto.js +3 -4
  2. package/dist/asymmetric-crypto.js.map +1 -1
  3. package/dist/asymmetric-crypto.mjs +1 -2
  4. package/dist/asymmetric-crypto.mjs.map +1 -1
  5. package/dist/chunk-C13QxCFV.js +50 -0
  6. package/dist/chunk-CfYAbeIz.mjs +13 -0
  7. package/dist/constants.js +2 -3
  8. package/dist/constants.js.map +1 -1
  9. package/dist/constants.mjs +1 -1
  10. package/dist/derive-key.js +50 -5
  11. package/dist/derive-key.js.map +1 -0
  12. package/dist/derive-key.mjs +46 -2
  13. package/dist/derive-key.mjs.map +1 -0
  14. package/dist/{deriveKeysFromPassword-iMHv-tIA.js → derive-password-CbYRDq7V.js} +25 -30
  15. package/dist/derive-password-CbYRDq7V.js.map +1 -0
  16. package/dist/{deriveKeysFromPassword-DFzo2OII.mjs → derive-password-PED-YfwE.mjs} +27 -34
  17. package/dist/derive-password-PED-YfwE.mjs.map +1 -0
  18. package/dist/derive-password.js +5 -6
  19. package/dist/derive-password.mjs +2 -3
  20. package/dist/{emailKeys-BFI-paQq.js → email-crypto-Cr7znO1a.js} +116 -121
  21. package/dist/email-crypto-Cr7znO1a.js.map +1 -0
  22. package/dist/{emailKeys-BjIeINfC.mjs → email-crypto-cHDsjSb5.mjs} +7 -12
  23. package/dist/email-crypto-cHDsjSb5.mjs.map +1 -0
  24. package/dist/email-crypto.d.mts +1 -1
  25. package/dist/email-crypto.d.ts +1 -1
  26. package/dist/email-crypto.js +17 -18
  27. package/dist/email-crypto.mjs +2 -3
  28. package/dist/hash.js +3 -4
  29. package/dist/hash.js.map +1 -1
  30. package/dist/hash.mjs +1 -2
  31. package/dist/hash.mjs.map +1 -1
  32. package/dist/index.d.mts +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +55 -56
  35. package/dist/index.mjs +7 -8
  36. package/dist/{emailEncryptionKey-CYvr26FG.mjs → keystore-crypto-C6F-NQdX.mjs} +12 -15
  37. package/dist/keystore-crypto-C6F-NQdX.mjs.map +1 -0
  38. package/dist/{emailEncryptionKey-Ba95VuFO.js → keystore-crypto-CFiiGohl.js} +67 -70
  39. package/dist/keystore-crypto-CFiiGohl.js.map +1 -0
  40. package/dist/keystore-crypto.d.mts +1 -1
  41. package/dist/keystore-crypto.d.ts +1 -1
  42. package/dist/keystore-crypto.js +11 -12
  43. package/dist/keystore-crypto.mjs +2 -3
  44. package/dist/post-quantum-crypto.js +3 -4
  45. package/dist/post-quantum-crypto.js.map +1 -1
  46. package/dist/post-quantum-crypto.mjs +1 -2
  47. package/dist/post-quantum-crypto.mjs.map +1 -1
  48. package/dist/storage-service.js +13 -15
  49. package/dist/storage-service.js.map +1 -1
  50. package/dist/storage-service.mjs +2 -4
  51. package/dist/storage-service.mjs.map +1 -1
  52. package/dist/symmetric-crypto.js +51 -5
  53. package/dist/symmetric-crypto.js.map +1 -0
  54. package/dist/symmetric-crypto.mjs +47 -2
  55. package/dist/symmetric-crypto.mjs.map +1 -0
  56. package/dist/types-4P0WII1D.d.ts +49 -0
  57. package/dist/types-4P0WII1D.d.ts.map +1 -0
  58. package/dist/types-DAPJQG8U.d.mts +49 -0
  59. package/dist/types-DAPJQG8U.d.mts.map +1 -0
  60. package/dist/types.d.mts +2 -49
  61. package/dist/types.d.ts +2 -49
  62. package/dist/types.js +2 -3
  63. package/dist/types.js.map +1 -1
  64. package/dist/types.mjs +1 -1
  65. package/dist/types.mjs.map +1 -1
  66. package/dist/utils.js +127 -14
  67. package/dist/utils.js.map +1 -0
  68. package/dist/utils.mjs +113 -2
  69. package/dist/utils.mjs.map +1 -0
  70. package/dist/{xwing-iRWVRtNE.js → xwing-7fEqAT7W.js} +18 -19
  71. package/dist/{xwing-iRWVRtNE.js.map → xwing-7fEqAT7W.js.map} +1 -1
  72. package/dist/{xwing-CQmQX6hn.mjs → xwing-B34h5e3Z.mjs} +2 -3
  73. package/dist/{xwing-CQmQX6hn.mjs.map → xwing-B34h5e3Z.mjs.map} +1 -1
  74. package/package.json +22 -22
  75. package/dist/aes-B8TA-JKq.mjs +0 -49
  76. package/dist/aes-B8TA-JKq.mjs.map +0 -1
  77. package/dist/aes-CuW_SPl-.js +0 -67
  78. package/dist/aes-CuW_SPl-.js.map +0 -1
  79. package/dist/chunk-DQk6qfdC.mjs +0 -18
  80. package/dist/chunk-EbLFQX5m.js +0 -60
  81. package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs +0 -49
  82. package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs.map +0 -1
  83. package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js +0 -67
  84. package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js.map +0 -1
  85. package/dist/deriveKeysFromPassword-DFzo2OII.mjs.map +0 -1
  86. package/dist/deriveKeysFromPassword-iMHv-tIA.js.map +0 -1
  87. package/dist/emailEncryptionKey-Ba95VuFO.js.map +0 -1
  88. package/dist/emailEncryptionKey-CYvr26FG.mjs.map +0 -1
  89. package/dist/emailKeys-BFI-paQq.js.map +0 -1
  90. package/dist/emailKeys-BjIeINfC.mjs.map +0 -1
  91. package/dist/genID-D08K7JPr.mjs +0 -117
  92. package/dist/genID-D08K7JPr.mjs.map +0 -1
  93. package/dist/genID-cWOPmspk.js +0 -190
  94. package/dist/genID-cWOPmspk.js.map +0 -1
  95. package/dist/types.d.mts.map +0 -1
  96. package/dist/types.d.ts.map +0 -1
@@ -1,49 +0,0 @@
1
- import { AES_KEY_BYTE_LENGTH, CONTEXT_TWO_KEYS } from "./constants.mjs";
2
- import { o as mnemonicToBytes, s as UTF8ToUint8 } from "./genID-D08K7JPr.mjs";
3
- import { blake3 } from "@noble/hashes/blake3.js";
4
-
5
- //#region src/derive-key/deriveKeysFromKey.ts
6
- /**
7
- * Derives a symmetric key from the base key and context string
8
- *
9
- * @param context - The context string.
10
- * The context string should be hardcoded, globally unique, and application-specific.
11
- * @param baseKey - The base key (NOT PASSWORD!)
12
- * @returns The derived secret key
13
- */
14
- function deriveSymmetricKeyFromContext(context, baseKey) {
15
- return blake3(baseKey, { context: UTF8ToUint8(context) });
16
- }
17
- /**
18
- * Derives a symmetric key from two keys
19
- *
20
- * @param key1 - The 32-bytes key
21
- * @param key2 - The 32-bytes key
22
- * @returns The derived secret key
23
- */
24
- function deriveSymmetricKeyFromTwoKeys(key1, key2) {
25
- try {
26
- if (key2.length !== AES_KEY_BYTE_LENGTH || key1.length !== AES_KEY_BYTE_LENGTH) throw new Error(`Input key length must be exactly ${AES_KEY_BYTE_LENGTH} bytes`);
27
- return deriveSymmetricKeyFromContext(CONTEXT_TWO_KEYS, blake3(key1, { key: key2 }));
28
- } catch (error) {
29
- throw new Error("Failed to derive symmetric key from two keys and context", { cause: error });
30
- }
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, mnemonicToBytes(mnemonic));
45
- };
46
-
47
- //#endregion
48
- export { deriveSymmetricKeyFromContext as n, deriveSymmetricKeyFromTwoKeys as r, deriveKeyFromMnemonic as t };
49
- //# sourceMappingURL=deriveKeysFromMnemonic-DB0UHE-y.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deriveKeysFromMnemonic-DB0UHE-y.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,WAAW,uBAAuB,KAAK,WAAW,oBACzD,OAAM,IAAI,MAAM,oCAAoC,oBAAoB,QAAQ;AAGlF,SAAO,8BAA8B,kBADzB,OAAO,MAAM,EAAE,KAAK,MAAM,CAAC,CACoB;UACpD,OAAO;AACd,QAAM,IAAI,MAAM,4DAA4D,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;;;;ACpBjG,MAAa,wBAAwB,OAAO,UAAkB,YAAyC;AAGrG,QAAO,8BAA8B,SADrB,gBAAgB,SAAS,CACa"}
@@ -1,67 +0,0 @@
1
- const require_chunk = require('./chunk-EbLFQX5m.js');
2
- const require_constants = require('./constants.js');
3
- const require_genID = require('./genID-cWOPmspk.js');
4
- let _noble_hashes_blake3_js = require("@noble/hashes/blake3.js");
5
-
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_genID.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 !== require_constants.AES_KEY_BYTE_LENGTH || key1.length !== require_constants.AES_KEY_BYTE_LENGTH) throw new Error(`Input key length must be exactly ${require_constants.AES_KEY_BYTE_LENGTH} 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
-
34
- //#endregion
35
- //#region src/derive-key/deriveKeysFromMnemonic.ts
36
- /**
37
- * Derives encryption key from the user's mnemonic and context string
38
- *
39
- * @param mnemonic - The user's mnemonic (machine-generated with secure PRNG)
40
- * @param context - The context string.
41
- * The context string should be hardcoded, globally unique, and application-specific.
42
- * @returns The symmetric key for protecting database
43
- */
44
- const deriveKeyFromMnemonic = async (mnemonic, context) => {
45
- return deriveSymmetricKeyFromContext(context, require_genID.mnemonicToBytes(mnemonic));
46
- };
47
-
48
- //#endregion
49
- Object.defineProperty(exports, 'deriveKeyFromMnemonic', {
50
- enumerable: true,
51
- get: function () {
52
- return deriveKeyFromMnemonic;
53
- }
54
- });
55
- Object.defineProperty(exports, 'deriveSymmetricKeyFromContext', {
56
- enumerable: true,
57
- get: function () {
58
- return deriveSymmetricKeyFromContext;
59
- }
60
- });
61
- Object.defineProperty(exports, 'deriveSymmetricKeyFromTwoKeys', {
62
- enumerable: true,
63
- get: function () {
64
- return deriveSymmetricKeyFromTwoKeys;
65
- }
66
- });
67
- //# sourceMappingURL=deriveKeysFromMnemonic-Dbx7VSBQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deriveKeysFromMnemonic-Dbx7VSBQ.js","names":["UTF8ToUint8","AES_KEY_BYTE_LENGTH","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,4CAAc,SAAS,EAAE,SAASA,0BAAY,QAAQ,EAAE,CAAC;;;;;;;;;AAU3D,SAAgB,8BAA8B,MAAkB,MAA8B;AAC5F,KAAI;AACF,MAAI,KAAK,WAAWC,yCAAuB,KAAK,WAAWA,sCACzD,OAAM,IAAI,MAAM,oCAAoCA,sCAAoB,QAAQ;AAGlF,SAAO,8BAA8BC,wEADlB,MAAM,EAAE,KAAK,MAAM,CAAC,CACoB;UACpD,OAAO;AACd,QAAM,IAAI,MAAM,4DAA4D,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;;;;ACpBjG,MAAa,wBAAwB,OAAO,UAAkB,YAAyC;AAGrG,QAAO,8BAA8B,SADrBC,8BAAgB,SAAS,CACa"}