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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "internxt-crypto",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -19,31 +19,31 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@eslint/js": "^10.0.1",
|
|
22
|
-
"@internxt/eslint-config-internxt": "2.0
|
|
23
|
-
"@internxt/prettier-config": "
|
|
24
|
-
"@playwright/test": "^1.
|
|
25
|
-
"@types/node": "^25.
|
|
26
|
-
"@vitest/browser-playwright": "^4.
|
|
27
|
-
"@vitest/coverage-istanbul": "^4.
|
|
28
|
-
"@vitest/coverage-v8": "^4.
|
|
29
|
-
"eslint": "^10.0
|
|
30
|
-
"knip": "^
|
|
31
|
-
"lint-staged": "^
|
|
32
|
-
"playwright": "^1.
|
|
33
|
-
"prettier": "^3.
|
|
34
|
-
"tsdown": "^0.
|
|
35
|
-
"typescript": "^
|
|
36
|
-
"vitest": "^4.
|
|
22
|
+
"@internxt/eslint-config-internxt": "^2.1.0",
|
|
23
|
+
"@internxt/prettier-config": "^2.0.1",
|
|
24
|
+
"@playwright/test": "^1.59.1",
|
|
25
|
+
"@types/node": "^25.6.0",
|
|
26
|
+
"@vitest/browser-playwright": "^4.1.5",
|
|
27
|
+
"@vitest/coverage-istanbul": "^4.1.5",
|
|
28
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
29
|
+
"eslint": "^10.3.0",
|
|
30
|
+
"knip": "^6.11.0",
|
|
31
|
+
"lint-staged": "^17.0.2",
|
|
32
|
+
"playwright": "^1.59.1",
|
|
33
|
+
"prettier": "^3.8.3",
|
|
34
|
+
"tsdown": "^0.21.10",
|
|
35
|
+
"typescript": "^6.0.3",
|
|
36
|
+
"vitest": "^4.1.5"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@noble/ciphers": "^2.
|
|
40
|
-
"@noble/curves": "^2.0
|
|
41
|
-
"@noble/hashes": "^2.0
|
|
42
|
-
"@noble/post-quantum": "^0.
|
|
43
|
-
"@scure/bip39": "^2.0
|
|
39
|
+
"@noble/ciphers": "^2.2.0",
|
|
40
|
+
"@noble/curves": "^2.2.0",
|
|
41
|
+
"@noble/hashes": "^2.2.0",
|
|
42
|
+
"@noble/post-quantum": "^0.6.1",
|
|
43
|
+
"@scure/bip39": "^2.2.0",
|
|
44
44
|
"hash-wasm": "^4.12.0",
|
|
45
45
|
"husky": "^9.1.7",
|
|
46
|
-
"uuid": "^
|
|
46
|
+
"uuid": "^14.0.0"
|
|
47
47
|
},
|
|
48
48
|
"exports": {
|
|
49
49
|
".": {
|
package/dist/aes-B8TA-JKq.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { AES_KEY_BYTE_LENGTH, IV_LEN_BYTES } from "./constants.mjs";
|
|
2
|
-
import { concatBytes, randomBytes } from "@noble/hashes/utils.js";
|
|
3
|
-
import { gcm } from "@noble/ciphers/webcrypto.js";
|
|
4
|
-
|
|
5
|
-
//#region src/symmetric-crypto/aes.ts
|
|
6
|
-
/**
|
|
7
|
-
* Symmetrically encrypts the message
|
|
8
|
-
*
|
|
9
|
-
* @param encryptionKey - The symmetric key used for message encryption
|
|
10
|
-
* @param message - The message to encrypt
|
|
11
|
-
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
12
|
-
* @returns The resulting ciphertext.
|
|
13
|
-
*/
|
|
14
|
-
async function encryptSymmetrically(encryptionKey, message, aux) {
|
|
15
|
-
try {
|
|
16
|
-
const iv = randomBytes(IV_LEN_BYTES);
|
|
17
|
-
return concatBytes(await gcm(encryptionKey, iv, aux).encrypt(message), iv);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
throw new Error("Failed to encrypt symmetrically", { cause: error });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Decryps symmetrically encrypted message
|
|
24
|
-
*
|
|
25
|
-
* @param encryptionKey - The symmetric key used for message encryption
|
|
26
|
-
* @param encryptedMessage - The ciphertext
|
|
27
|
-
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
28
|
-
* @returns The resulting ciphertext.
|
|
29
|
-
*/
|
|
30
|
-
async function decryptSymmetrically(encryptionKey, encryptedMessage, aux) {
|
|
31
|
-
try {
|
|
32
|
-
const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);
|
|
33
|
-
return await gcm(encryptionKey, encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES), aux).decrypt(ciphertext);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw new Error("Failed to decrypt symmetrically", { cause: error });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Generates symmetric key as Uint8Array
|
|
40
|
-
*
|
|
41
|
-
* @returns The generated Uint8Array.
|
|
42
|
-
*/
|
|
43
|
-
function genSymmetricKey() {
|
|
44
|
-
return randomBytes(AES_KEY_BYTE_LENGTH);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { encryptSymmetrically as n, genSymmetricKey as r, decryptSymmetrically as t };
|
|
49
|
-
//# sourceMappingURL=aes-B8TA-JKq.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aes-B8TA-JKq.mjs","names":["aeadCipher"],"sources":["../src/symmetric-crypto/aes.ts"],"sourcesContent":["import { concatBytes, randomBytes } from '@noble/hashes/utils.js';\nimport { IV_LEN_BYTES, AES_KEY_BYTE_LENGTH } from '../constants';\nimport { gcm as aeadCipher } from '@noble/ciphers/webcrypto.js';\n\n/**\n * Symmetrically encrypts the message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param message - The message to encrypt\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function encryptSymmetrically(\n encryptionKey: Uint8Array,\n message: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const iv = randomBytes(IV_LEN_BYTES);\n const ciphertext = await aeadCipher(encryptionKey, iv, aux).encrypt(message);\n return concatBytes(ciphertext, iv);\n } catch (error) {\n throw new Error('Failed to encrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Decryps symmetrically encrypted message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param encryptedMessage - The ciphertext\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function decryptSymmetrically(\n encryptionKey: Uint8Array,\n encryptedMessage: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);\n const iv = encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES);\n const result = await aeadCipher(encryptionKey, iv, aux).decrypt(ciphertext);\n return result;\n } catch (error) {\n throw new Error('Failed to decrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Generates symmetric key as Uint8Array\n *\n * @returns The generated Uint8Array.\n */\nexport function genSymmetricKey(): Uint8Array {\n return randomBytes(AES_KEY_BYTE_LENGTH);\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,eAAsB,qBACpB,eACA,SACA,KACqB;AACrB,KAAI;EACF,MAAM,KAAK,YAAY,aAAa;AAEpC,SAAO,YADY,MAAMA,IAAW,eAAe,IAAI,IAAI,CAAC,QAAQ,QAAQ,EAC7C,GAAG;UAC3B,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYxE,eAAsB,qBACpB,eACA,kBACA,KACqB;AACrB,KAAI;EACF,MAAM,aAAa,iBAAiB,MAAM,GAAG,iBAAiB,SAAS,aAAa;AAGpF,SADe,MAAMA,IAAW,eADrB,iBAAiB,MAAM,iBAAiB,SAAS,aAAa,EACtB,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,QAAO,YAAY,oBAAoB"}
|
package/dist/aes-CuW_SPl-.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-EbLFQX5m.js');
|
|
2
|
-
const require_constants = require('./constants.js');
|
|
3
|
-
let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
|
|
4
|
-
let _noble_ciphers_webcrypto_js = require("@noble/ciphers/webcrypto.js");
|
|
5
|
-
|
|
6
|
-
//#region src/symmetric-crypto/aes.ts
|
|
7
|
-
/**
|
|
8
|
-
* Symmetrically encrypts the message
|
|
9
|
-
*
|
|
10
|
-
* @param encryptionKey - The symmetric key used for message encryption
|
|
11
|
-
* @param message - The message to encrypt
|
|
12
|
-
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
13
|
-
* @returns The resulting ciphertext.
|
|
14
|
-
*/
|
|
15
|
-
async function encryptSymmetrically(encryptionKey, message, aux) {
|
|
16
|
-
try {
|
|
17
|
-
const iv = (0, _noble_hashes_utils_js.randomBytes)(require_constants.IV_LEN_BYTES);
|
|
18
|
-
return (0, _noble_hashes_utils_js.concatBytes)(await (0, _noble_ciphers_webcrypto_js.gcm)(encryptionKey, iv, aux).encrypt(message), iv);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error("Failed to encrypt symmetrically", { cause: error });
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Decryps symmetrically encrypted message
|
|
25
|
-
*
|
|
26
|
-
* @param encryptionKey - The symmetric key used for message encryption
|
|
27
|
-
* @param encryptedMessage - The ciphertext
|
|
28
|
-
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
29
|
-
* @returns The resulting ciphertext.
|
|
30
|
-
*/
|
|
31
|
-
async function decryptSymmetrically(encryptionKey, encryptedMessage, aux) {
|
|
32
|
-
try {
|
|
33
|
-
const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - require_constants.IV_LEN_BYTES);
|
|
34
|
-
return await (0, _noble_ciphers_webcrypto_js.gcm)(encryptionKey, encryptedMessage.slice(encryptedMessage.length - require_constants.IV_LEN_BYTES), aux).decrypt(ciphertext);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
throw new Error("Failed to decrypt symmetrically", { cause: error });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Generates symmetric key as Uint8Array
|
|
41
|
-
*
|
|
42
|
-
* @returns The generated Uint8Array.
|
|
43
|
-
*/
|
|
44
|
-
function genSymmetricKey() {
|
|
45
|
-
return (0, _noble_hashes_utils_js.randomBytes)(require_constants.AES_KEY_BYTE_LENGTH);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
Object.defineProperty(exports, 'decryptSymmetrically', {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return decryptSymmetrically;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, 'encryptSymmetrically', {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function () {
|
|
58
|
-
return encryptSymmetrically;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(exports, 'genSymmetricKey', {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: function () {
|
|
64
|
-
return genSymmetricKey;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=aes-CuW_SPl-.js.map
|
package/dist/aes-CuW_SPl-.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aes-CuW_SPl-.js","names":["IV_LEN_BYTES","AES_KEY_BYTE_LENGTH"],"sources":["../src/symmetric-crypto/aes.ts"],"sourcesContent":["import { concatBytes, randomBytes } from '@noble/hashes/utils.js';\nimport { IV_LEN_BYTES, AES_KEY_BYTE_LENGTH } from '../constants';\nimport { gcm as aeadCipher } from '@noble/ciphers/webcrypto.js';\n\n/**\n * Symmetrically encrypts the message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param message - The message to encrypt\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function encryptSymmetrically(\n encryptionKey: Uint8Array,\n message: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const iv = randomBytes(IV_LEN_BYTES);\n const ciphertext = await aeadCipher(encryptionKey, iv, aux).encrypt(message);\n return concatBytes(ciphertext, iv);\n } catch (error) {\n throw new Error('Failed to encrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Decryps symmetrically encrypted message\n *\n * @param encryptionKey - The symmetric key used for message encryption\n * @param encryptedMessage - The ciphertext\n * @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.\n * @returns The resulting ciphertext.\n */\nexport async function decryptSymmetrically(\n encryptionKey: Uint8Array,\n encryptedMessage: Uint8Array,\n aux?: Uint8Array,\n): Promise<Uint8Array> {\n try {\n const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - IV_LEN_BYTES);\n const iv = encryptedMessage.slice(encryptedMessage.length - IV_LEN_BYTES);\n const result = await aeadCipher(encryptionKey, iv, aux).decrypt(ciphertext);\n return result;\n } catch (error) {\n throw new Error('Failed to decrypt symmetrically', { cause: error });\n }\n}\n\n/**\n * Generates symmetric key as Uint8Array\n *\n * @returns The generated Uint8Array.\n */\nexport function genSymmetricKey(): Uint8Array {\n return randomBytes(AES_KEY_BYTE_LENGTH);\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,eAAsB,qBACpB,eACA,SACA,KACqB;AACrB,KAAI;EACF,MAAM,6CAAiBA,+BAAa;AAEpC,iDADmB,2CAAiB,eAAe,IAAI,IAAI,CAAC,QAAQ,QAAQ,EAC7C,GAAG;UAC3B,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AAYxE,eAAsB,qBACpB,eACA,kBACA,KACqB;AACrB,KAAI;EACF,MAAM,aAAa,iBAAiB,MAAM,GAAG,iBAAiB,SAASA,+BAAa;AAGpF,SADe,2CAAiB,eADrB,iBAAiB,MAAM,iBAAiB,SAASA,+BAAa,EACtB,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,gDAAmBC,sCAAoB"}
|
package/dist/chunk-DQk6qfdC.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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) {
|
|
6
|
-
__defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (!no_symbols) {
|
|
12
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
-
}
|
|
14
|
-
return target;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
export { __exportAll as t };
|
package/dist/chunk-EbLFQX5m.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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), mod.exports);
|
|
9
|
-
var __exportAll = (all, no_symbols) => {
|
|
10
|
-
let target = {};
|
|
11
|
-
for (var name in all) {
|
|
12
|
-
__defProp(target, name, {
|
|
13
|
-
get: all[name],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
if (!no_symbols) {
|
|
18
|
-
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
19
|
-
}
|
|
20
|
-
return target;
|
|
21
|
-
};
|
|
22
|
-
var __copyProps = (to, from, except, desc) => {
|
|
23
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
-
key = keys[i];
|
|
26
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
27
|
-
__defProp(to, key, {
|
|
28
|
-
get: ((k) => from[k]).bind(null, key),
|
|
29
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return to;
|
|
35
|
-
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
-
value: mod,
|
|
38
|
-
enumerable: true
|
|
39
|
-
}) : target, mod));
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
|
|
43
|
-
Object.defineProperty(exports, '__commonJSMin', {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return __commonJSMin;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(exports, '__exportAll', {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return __exportAll;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, '__toESM', {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function () {
|
|
58
|
-
return __toESM;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
@@ -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"}
|