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.
- 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/{emailKeys-BFI-paQq.js → email-crypto-Cr7znO1a.js} +116 -121
- package/dist/email-crypto-Cr7znO1a.js.map +1 -0
- package/dist/{emailKeys-BjIeINfC.mjs → email-crypto-cHDsjSb5.mjs} +7 -12
- package/dist/email-crypto-cHDsjSb5.mjs.map +1 -0
- package/dist/email-crypto.d.mts +1 -1
- package/dist/email-crypto.d.ts +1 -1
- package/dist/email-crypto.js +17 -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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -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-4P0WII1D.d.ts +49 -0
- package/dist/types-4P0WII1D.d.ts.map +1 -0
- package/dist/types-DAPJQG8U.d.mts +49 -0
- package/dist/types-DAPJQG8U.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.map +0 -1
- 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
|
@@ -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"}
|