internxt-crypto 0.0.14 → 1.0.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/README.md +44 -72
- package/dist/aes-B8TA-JKq.mjs +49 -0
- package/dist/aes-B8TA-JKq.mjs.map +1 -0
- package/dist/aes-CuW_SPl-.js +67 -0
- package/dist/aes-CuW_SPl-.js.map +1 -0
- package/dist/asymmetric-crypto.d.mts +8 -31
- package/dist/asymmetric-crypto.d.mts.map +1 -1
- package/dist/asymmetric-crypto.d.ts +8 -31
- package/dist/asymmetric-crypto.d.ts.map +1 -1
- package/dist/asymmetric-crypto.js +30 -7
- package/dist/asymmetric-crypto.js.map +1 -0
- package/dist/asymmetric-crypto.mjs +28 -2
- package/dist/asymmetric-crypto.mjs.map +1 -0
- package/dist/constants.d.mts +3 -10
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.d.ts +3 -10
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -17
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +3 -10
- package/dist/constants.mjs.map +1 -1
- package/dist/core-Bj26rNdA.js +227 -0
- package/dist/core-Bj26rNdA.js.map +1 -0
- package/dist/core-pEGygy6S.mjs +173 -0
- package/dist/core-pEGygy6S.mjs.map +1 -0
- package/dist/derive-key.d.mts +1 -74
- package/dist/derive-key.d.mts.map +1 -1
- package/dist/derive-key.d.ts +1 -74
- package/dist/derive-key.d.ts.map +1 -1
- package/dist/derive-key.js +3 -11
- package/dist/derive-key.mjs +2 -2
- package/dist/derive-password.d.mts +22 -0
- package/dist/derive-password.d.mts.map +1 -0
- package/dist/derive-password.d.ts +22 -0
- package/dist/derive-password.d.ts.map +1 -0
- package/dist/derive-password.js +5 -0
- package/dist/derive-password.mjs +3 -0
- package/dist/deriveKeysFromKey-C4McqO6_.js +47 -0
- package/dist/deriveKeysFromKey-C4McqO6_.js.map +1 -0
- package/dist/deriveKeysFromKey-DPU_h7wr.mjs +35 -0
- package/dist/deriveKeysFromKey-DPU_h7wr.mjs.map +1 -0
- package/dist/{deriveKeysFromPassword-BYaiSGKL.js → deriveKeysFromPassword-C7xAGGsh.js} +5 -172
- package/dist/deriveKeysFromPassword-C7xAGGsh.js.map +1 -0
- package/dist/{deriveKeysFromPassword-XIwzErlL.mjs → deriveKeysFromPassword-DXgSvTNC.mjs} +6 -125
- package/dist/deriveKeysFromPassword-DXgSvTNC.mjs.map +1 -0
- package/dist/email-crypto.d.mts +24 -46
- package/dist/email-crypto.d.mts.map +1 -1
- package/dist/email-crypto.d.ts +24 -46
- package/dist/email-crypto.d.ts.map +1 -1
- package/dist/email-crypto.js +121 -12
- package/dist/email-crypto.js.map +1 -0
- package/dist/email-crypto.mjs +115 -2
- package/dist/email-crypto.mjs.map +1 -0
- package/dist/email-search.d.mts.map +1 -1
- package/dist/email-search.d.ts.map +1 -1
- package/dist/email-search.js +25 -597
- package/dist/email-search.mjs +2 -573
- package/dist/{emailEncryptionKey-B9xHw1h_.mjs → emailEncryptionKey-BtSPYd9M.mjs} +22 -45
- package/dist/emailEncryptionKey-BtSPYd9M.mjs.map +1 -0
- package/dist/{emailEncryptionKey-CQNe5W_T.js → emailEncryptionKey-C4X1Bwy4.js} +22 -45
- package/dist/emailEncryptionKey-C4X1Bwy4.js.map +1 -0
- package/dist/{genID-3Er5IowC.mjs → genID-D08K7JPr.mjs} +4 -40
- package/dist/genID-D08K7JPr.mjs.map +1 -0
- package/dist/{genID-YJSl3YhL.js → genID-cWOPmspk.js} +2 -50
- package/dist/genID-cWOPmspk.js.map +1 -0
- package/dist/hash.d.mts +24 -36
- package/dist/hash.d.mts.map +1 -1
- package/dist/hash.d.ts +24 -36
- package/dist/hash.d.ts.map +1 -1
- package/dist/hash.js +88 -10
- package/dist/hash.js.map +1 -0
- package/dist/hash.mjs +82 -2
- package/dist/hash.mjs.map +1 -0
- package/dist/index.d.mts +9 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -79
- package/dist/index.mjs +13 -11
- package/dist/keystore-crypto.d.mts +6 -6
- package/dist/keystore-crypto.d.mts.map +1 -1
- package/dist/keystore-crypto.d.ts +6 -6
- package/dist/keystore-crypto.d.ts.map +1 -1
- package/dist/keystore-crypto.js +1 -1
- package/dist/keystore-crypto.mjs +1 -1
- package/dist/post-quantum-crypto.js +49 -4
- package/dist/post-quantum-crypto.js.map +1 -0
- package/dist/post-quantum-crypto.mjs +46 -2
- package/dist/post-quantum-crypto.mjs.map +1 -0
- package/dist/search-B9YM3XAA.mjs +587 -0
- package/dist/search-B9YM3XAA.mjs.map +1 -0
- package/dist/search-DUTm4-rN.js +731 -0
- package/dist/search-DUTm4-rN.js.map +1 -0
- package/dist/symmetric-crypto.d.mts +11 -40
- package/dist/symmetric-crypto.d.mts.map +1 -1
- package/dist/symmetric-crypto.d.ts +11 -40
- package/dist/symmetric-crypto.d.ts.map +1 -1
- package/dist/symmetric-crypto.js +2 -6
- package/dist/symmetric-crypto.mjs +2 -2
- package/dist/types.d.mts +13 -40
- package/dist/types.d.mts.map +1 -1
- package/dist/types.d.ts +13 -40
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.d.mts +1 -19
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.d.ts +1 -19
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -3
- package/dist/utils.mjs +2 -2
- package/dist/xwing-CQmQX6hn.mjs +16 -0
- package/dist/xwing-CQmQX6hn.mjs.map +1 -0
- package/dist/xwing-iRWVRtNE.js +34 -0
- package/dist/xwing-iRWVRtNE.js.map +1 -0
- package/package.json +4 -3
- package/dist/aes-DCb9dJqb.mjs +0 -161
- package/dist/aes-DCb9dJqb.mjs.map +0 -1
- package/dist/aes-DQo1MyCz.js +0 -203
- package/dist/aes-DQo1MyCz.js.map +0 -1
- package/dist/deriveKeysFromPassword-BYaiSGKL.js.map +0 -1
- package/dist/deriveKeysFromPassword-XIwzErlL.mjs.map +0 -1
- package/dist/email-search.js.map +0 -1
- package/dist/email-search.mjs.map +0 -1
- package/dist/emailEncryptionKey-B9xHw1h_.mjs.map +0 -1
- package/dist/emailEncryptionKey-CQNe5W_T.js.map +0 -1
- package/dist/emailKeys-C0KhtfNP.js +0 -572
- package/dist/emailKeys-C0KhtfNP.js.map +0 -1
- package/dist/emailKeys-D4lp9NRv.mjs +0 -488
- package/dist/emailKeys-D4lp9NRv.mjs.map +0 -1
- package/dist/genID-3Er5IowC.mjs.map +0 -1
- package/dist/genID-YJSl3YhL.js.map +0 -1
- package/dist/keys-BfcaiAOv.mjs +0 -90
- package/dist/keys-BfcaiAOv.mjs.map +0 -1
- package/dist/keys-CinT7kEY.js +0 -125
- package/dist/keys-CinT7kEY.js.map +0 -1
- package/dist/kyber768-SXnIo-Nw.mjs +0 -47
- package/dist/kyber768-SXnIo-Nw.mjs.map +0 -1
- package/dist/kyber768-WUVc2fIR.js +0 -65
- package/dist/kyber768-WUVc2fIR.js.map +0 -1
- package/dist/mac-BMb1F0dN.js +0 -170
- package/dist/mac-BMb1F0dN.js.map +0 -1
- package/dist/mac-ZpRlx8Fs.mjs +0 -116
- package/dist/mac-ZpRlx8Fs.mjs.map +0 -1
package/dist/derive-key.d.ts
CHANGED
|
@@ -8,15 +8,6 @@
|
|
|
8
8
|
* @returns The derived secret key
|
|
9
9
|
*/
|
|
10
10
|
declare function deriveSymmetricKeyFromContext(context: string, baseKey: Uint8Array): Uint8Array;
|
|
11
|
-
/**
|
|
12
|
-
* Derives a symmetric CryptoKey from the base key and context string
|
|
13
|
-
*
|
|
14
|
-
* @param context - The context string.
|
|
15
|
-
* The context string should be hardcoded, globally unique, and application-specific.
|
|
16
|
-
* @param baseKey - The base key (NOT PASSWORD!)
|
|
17
|
-
* @returns The derived secret CryptoKey
|
|
18
|
-
*/
|
|
19
|
-
declare function deriveSymmetricCryptoKeyFromContext(context: string, baseKey: Uint8Array): Promise<CryptoKey>;
|
|
20
11
|
/**
|
|
21
12
|
* Derives a symmetric key from two keys
|
|
22
13
|
*
|
|
@@ -25,70 +16,6 @@ declare function deriveSymmetricCryptoKeyFromContext(context: string, baseKey: U
|
|
|
25
16
|
* @returns The derived secret key
|
|
26
17
|
*/
|
|
27
18
|
declare function deriveSymmetricKeyFromTwoKeys(key1: Uint8Array, key2: Uint8Array): Uint8Array;
|
|
28
|
-
/**
|
|
29
|
-
* Derives a symmetric CryptoKey from two keys
|
|
30
|
-
*
|
|
31
|
-
* @param key1 - The 32-bytes key
|
|
32
|
-
* @param key2 - The 32-bytes key
|
|
33
|
-
* @returns The derived secret CryptoKey
|
|
34
|
-
*/
|
|
35
|
-
declare function deriveSymmetricCryptoKeyFromTwoKeys(key1: Uint8Array, key2: Uint8Array): Promise<CryptoKey>;
|
|
36
|
-
/**
|
|
37
|
-
* Derives a symmetric key from two keys and context
|
|
38
|
-
*
|
|
39
|
-
* @param key1 - The 32-bytes key
|
|
40
|
-
* @param key2 - The 32-bytes key
|
|
41
|
-
* @param context - The context string
|
|
42
|
-
* @returns The derived symmetric key
|
|
43
|
-
*/
|
|
44
|
-
declare function deriveSymmetricKeyFromTwoKeysAndContext(key1: Uint8Array, key2: Uint8Array, context: string): Uint8Array;
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/derive-key/deriveKeysFromPassword.d.ts
|
|
47
|
-
/**
|
|
48
|
-
* Derives a symmetric key from a user's password with a randomly sampled salt
|
|
49
|
-
*
|
|
50
|
-
* @param password - The user's password
|
|
51
|
-
* @returns The derived secret key and randomly sampled salt
|
|
52
|
-
*/
|
|
53
|
-
declare function getKeyFromPassword(password: string): Promise<{
|
|
54
|
-
key: Uint8Array;
|
|
55
|
-
salt: Uint8Array;
|
|
56
|
-
}>;
|
|
57
|
-
/**
|
|
58
|
-
* Derives a symmetric key from a user's password and salt
|
|
59
|
-
*
|
|
60
|
-
* @param password - The user's password
|
|
61
|
-
* @param salt - The given salt
|
|
62
|
-
* @returns The derived secret key
|
|
63
|
-
*/
|
|
64
|
-
declare function getKeyFromPasswordAndSalt(password: string, salt: Uint8Array): Promise<Uint8Array>;
|
|
65
|
-
/**
|
|
66
|
-
* Derives a HEX symmetric key from a user's password with a randomly sampled salt
|
|
67
|
-
*
|
|
68
|
-
* @param password - The user's password
|
|
69
|
-
* @returns The derived HEX secret key and randomly sampled HEX salt
|
|
70
|
-
*/
|
|
71
|
-
declare function getKeyFromPasswordHex(password: string): Promise<{
|
|
72
|
-
keyHex: string;
|
|
73
|
-
saltHex: string;
|
|
74
|
-
}>;
|
|
75
|
-
/**
|
|
76
|
-
* Derives a HEX symmetric key from a user's password and salt
|
|
77
|
-
*
|
|
78
|
-
* @param password - The user's password
|
|
79
|
-
* @param saltHex - The given HEX salt
|
|
80
|
-
* @returns The derived HEX secret key
|
|
81
|
-
*/
|
|
82
|
-
declare function getKeyFromPasswordAndSaltHex(password: string, saltHex: string): Promise<string>;
|
|
83
|
-
/**
|
|
84
|
-
* Verifies the derived key
|
|
85
|
-
*
|
|
86
|
-
* @param password - The user's password
|
|
87
|
-
* @param saltHex - The given HEX salt
|
|
88
|
-
* @param keyHex - The derived HEX key
|
|
89
|
-
* @returns The result of the key verification
|
|
90
|
-
*/
|
|
91
|
-
declare function verifyKeyFromPasswordHex(password: string, saltHex: string, keyHex: string): Promise<boolean>;
|
|
92
19
|
//#endregion
|
|
93
|
-
export {
|
|
20
|
+
export { deriveSymmetricKeyFromContext, deriveSymmetricKeyFromTwoKeys };
|
|
94
21
|
//# sourceMappingURL=derive-key.d.ts.map
|
package/dist/derive-key.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive-key.d.ts","names":[],"sources":["../src/derive-key/deriveKeysFromKey.ts"
|
|
1
|
+
{"version":3,"file":"derive-key.d.ts","names":[],"sources":["../src/derive-key/deriveKeysFromKey.ts"],"mappings":";;AAYA;;;;;;;iBAAgB,6BAAA,CAA8B,OAAA,UAAiB,OAAA,EAAS,UAAA,GAAa,UAAA;;;AAWrF;;;;;iBAAgB,6BAAA,CAA8B,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,UAAA,GAAa,UAAA"}
|
package/dist/derive-key.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_deriveKeysFromKey = require('./deriveKeysFromKey-C4McqO6_.js');
|
|
3
3
|
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.deriveSymmetricKeyFromContext = require_deriveKeysFromPassword.deriveSymmetricKeyFromContext;
|
|
7
|
-
exports.deriveSymmetricKeyFromTwoKeys = require_deriveKeysFromPassword.deriveSymmetricKeyFromTwoKeys;
|
|
8
|
-
exports.deriveSymmetricKeyFromTwoKeysAndContext = require_deriveKeysFromPassword.deriveSymmetricKeyFromTwoKeysAndContext;
|
|
9
|
-
exports.getKeyFromPassword = require_deriveKeysFromPassword.getKeyFromPassword;
|
|
10
|
-
exports.getKeyFromPasswordAndSalt = require_deriveKeysFromPassword.getKeyFromPasswordAndSalt;
|
|
11
|
-
exports.getKeyFromPasswordAndSaltHex = require_deriveKeysFromPassword.getKeyFromPasswordAndSaltHex;
|
|
12
|
-
exports.getKeyFromPasswordHex = require_deriveKeysFromPassword.getKeyFromPasswordHex;
|
|
13
|
-
exports.verifyKeyFromPasswordHex = require_deriveKeysFromPassword.verifyKeyFromPasswordHex;
|
|
4
|
+
exports.deriveSymmetricKeyFromContext = require_deriveKeysFromKey.deriveSymmetricKeyFromContext;
|
|
5
|
+
exports.deriveSymmetricKeyFromTwoKeys = require_deriveKeysFromKey.deriveSymmetricKeyFromTwoKeys;
|
package/dist/derive-key.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as deriveSymmetricKeyFromTwoKeys, t as deriveSymmetricKeyFromContext } from "./deriveKeysFromKey-DPU_h7wr.mjs";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { deriveSymmetricKeyFromContext, deriveSymmetricKeyFromTwoKeys };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/derive-password/deriveKeysFromPassword.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Derives a symmetric key from a user's password with a randomly sampled salt
|
|
4
|
+
*
|
|
5
|
+
* @param password - The user's password
|
|
6
|
+
* @returns The derived secret key and randomly sampled salt
|
|
7
|
+
*/
|
|
8
|
+
declare function getKeyFromPassword(password: string): Promise<{
|
|
9
|
+
key: Uint8Array;
|
|
10
|
+
salt: Uint8Array;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Derives a symmetric key from a user's password and salt
|
|
14
|
+
*
|
|
15
|
+
* @param password - The user's password
|
|
16
|
+
* @param salt - The given salt
|
|
17
|
+
* @returns The derived secret key
|
|
18
|
+
*/
|
|
19
|
+
declare function getKeyFromPasswordAndSalt(password: string, salt: Uint8Array): Promise<Uint8Array>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getKeyFromPassword, getKeyFromPasswordAndSalt };
|
|
22
|
+
//# sourceMappingURL=derive-password.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-password.d.mts","names":[],"sources":["../src/derive-password/deriveKeysFromPassword.ts"],"mappings":";;AAQA;;;;;iBAAsB,kBAAA,CAAmB,QAAA,WAAmB,OAAA;EAAU,GAAA,EAAK,UAAA;EAAY,IAAA,EAAM,UAAA;AAAA;;;;;;;;iBAiBvE,yBAAA,CAA0B,QAAA,UAAkB,IAAA,EAAM,UAAA,GAAa,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/derive-password/deriveKeysFromPassword.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Derives a symmetric key from a user's password with a randomly sampled salt
|
|
4
|
+
*
|
|
5
|
+
* @param password - The user's password
|
|
6
|
+
* @returns The derived secret key and randomly sampled salt
|
|
7
|
+
*/
|
|
8
|
+
declare function getKeyFromPassword(password: string): Promise<{
|
|
9
|
+
key: Uint8Array;
|
|
10
|
+
salt: Uint8Array;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Derives a symmetric key from a user's password and salt
|
|
14
|
+
*
|
|
15
|
+
* @param password - The user's password
|
|
16
|
+
* @param salt - The given salt
|
|
17
|
+
* @returns The derived secret key
|
|
18
|
+
*/
|
|
19
|
+
declare function getKeyFromPasswordAndSalt(password: string, salt: Uint8Array): Promise<Uint8Array>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { getKeyFromPassword, getKeyFromPasswordAndSalt };
|
|
22
|
+
//# sourceMappingURL=derive-password.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-password.d.ts","names":[],"sources":["../src/derive-password/deriveKeysFromPassword.ts"],"mappings":";;AAQA;;;;;iBAAsB,kBAAA,CAAmB,QAAA,WAAmB,OAAA;EAAU,GAAA,EAAK,UAAA;EAAY,IAAA,EAAM,UAAA;AAAA;;;;;;;;iBAiBvE,yBAAA,CAA0B,QAAA,UAAkB,IAAA,EAAM,UAAA,GAAa,OAAA,CAAQ,UAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_deriveKeysFromPassword = require('./deriveKeysFromPassword-C7xAGGsh.js');
|
|
3
|
+
|
|
4
|
+
exports.getKeyFromPassword = require_deriveKeysFromPassword.getKeyFromPassword;
|
|
5
|
+
exports.getKeyFromPasswordAndSalt = require_deriveKeysFromPassword.getKeyFromPasswordAndSalt;
|
|
@@ -0,0 +1,47 @@
|
|
|
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_DERIVE, (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
|
+
Object.defineProperty(exports, 'deriveSymmetricKeyFromContext', {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () {
|
|
38
|
+
return deriveSymmetricKeyFromContext;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, 'deriveSymmetricKeyFromTwoKeys', {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () {
|
|
44
|
+
return deriveSymmetricKeyFromTwoKeys;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=deriveKeysFromKey-C4McqO6_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveKeysFromKey-C4McqO6_.js","names":["UTF8ToUint8","AES_KEY_BYTE_LENGTH","CONTEXT_DERIVE"],"sources":["../src/derive-key/deriveKeysFromKey.ts"],"sourcesContent":["import { blake3 } from '@noble/hashes/blake3.js';\nimport { AES_KEY_BYTE_LENGTH, CONTEXT_DERIVE } 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_DERIVE, key);\n } catch (error) {\n throw new Error('Failed to derive symmetric key from two keys and context', { cause: error });\n }\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,UAAUC,yCAAuB,KAAK,UAAUA,sCACvD,OAAM,IAAI,MAAM,oCAAoCA,sCAAoB,QAAQ;AAGlF,SAAO,8BAA8BC,sEADlB,MAAM,EAAE,KAAK,MAAM,CAAC,CACkB;UAClD,OAAO;AACd,QAAM,IAAI,MAAM,4DAA4D,EAAE,OAAO,OAAO,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AES_KEY_BYTE_LENGTH, CONTEXT_DERIVE } from "./constants.mjs";
|
|
2
|
+
import { 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_DERIVE, 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
|
+
export { deriveSymmetricKeyFromTwoKeys as n, deriveSymmetricKeyFromContext as t };
|
|
35
|
+
//# sourceMappingURL=deriveKeysFromKey-DPU_h7wr.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deriveKeysFromKey-DPU_h7wr.mjs","names":[],"sources":["../src/derive-key/deriveKeysFromKey.ts"],"sourcesContent":["import { blake3 } from '@noble/hashes/blake3.js';\nimport { AES_KEY_BYTE_LENGTH, CONTEXT_DERIVE } 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_DERIVE, key);\n } catch (error) {\n throw new Error('Failed to derive symmetric key from two keys and context', { cause: error });\n }\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,UAAU,uBAAuB,KAAK,UAAU,oBACvD,OAAM,IAAI,MAAM,oCAAoC,oBAAoB,QAAQ;AAGlF,SAAO,8BAA8B,gBADzB,OAAO,MAAM,EAAE,KAAK,MAAM,CAAC,CACkB;UAClD,OAAO;AACd,QAAM,IAAI,MAAM,4DAA4D,EAAE,OAAO,OAAO,CAAC"}
|
|
@@ -1,81 +1,7 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-EbLFQX5m.js');
|
|
2
2
|
const require_constants = require('./constants.js');
|
|
3
|
-
|
|
4
|
-
const require_aes = require('./aes-DQo1MyCz.js');
|
|
5
|
-
let _noble_hashes_blake3_js = require("@noble/hashes/blake3.js");
|
|
6
|
-
let _noble_post_quantum_utils_js = require("@noble/post-quantum/utils.js");
|
|
3
|
+
let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
|
|
7
4
|
|
|
8
|
-
//#region src/derive-key/deriveKeysFromKey.ts
|
|
9
|
-
/**
|
|
10
|
-
* Derives a symmetric key from the base key and context string
|
|
11
|
-
*
|
|
12
|
-
* @param context - The context string.
|
|
13
|
-
* The context string should be hardcoded, globally unique, and application-specific.
|
|
14
|
-
* @param baseKey - The base key (NOT PASSWORD!)
|
|
15
|
-
* @returns The derived secret key
|
|
16
|
-
*/
|
|
17
|
-
function deriveSymmetricKeyFromContext(context, baseKey) {
|
|
18
|
-
return (0, _noble_hashes_blake3_js.blake3)(baseKey, { context: require_genID.UTF8ToUint8(context) });
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Derives a symmetric CryptoKey from the base key and context string
|
|
22
|
-
*
|
|
23
|
-
* @param context - The context string.
|
|
24
|
-
* The context string should be hardcoded, globally unique, and application-specific.
|
|
25
|
-
* @param baseKey - The base key (NOT PASSWORD!)
|
|
26
|
-
* @returns The derived secret CryptoKey
|
|
27
|
-
*/
|
|
28
|
-
async function deriveSymmetricCryptoKeyFromContext(context, baseKey) {
|
|
29
|
-
try {
|
|
30
|
-
if (baseKey.length != require_constants.AES_KEY_BIT_LENGTH / 8) throw new Error(`Base key length must be exactly ${require_constants.AES_KEY_BIT_LENGTH / 8} bytes`);
|
|
31
|
-
if (!context) throw new Error("Context is empry");
|
|
32
|
-
return await require_aes.importSymmetricCryptoKey(deriveSymmetricKeyFromContext(context, baseKey));
|
|
33
|
-
} catch (error) {
|
|
34
|
-
throw new Error("Failed to derive CryptoKey from base key and context", { cause: error });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Derives a symmetric key from two keys
|
|
39
|
-
*
|
|
40
|
-
* @param key1 - The 32-bytes key
|
|
41
|
-
* @param key2 - The 32-bytes key
|
|
42
|
-
* @returns The derived secret key
|
|
43
|
-
*/
|
|
44
|
-
function deriveSymmetricKeyFromTwoKeys(key1, key2) {
|
|
45
|
-
return deriveSymmetricKeyFromTwoKeysAndContext(key1, key2, require_constants.CONTEXT_DERIVE);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Derives a symmetric CryptoKey from two keys
|
|
49
|
-
*
|
|
50
|
-
* @param key1 - The 32-bytes key
|
|
51
|
-
* @param key2 - The 32-bytes key
|
|
52
|
-
* @returns The derived secret CryptoKey
|
|
53
|
-
*/
|
|
54
|
-
async function deriveSymmetricCryptoKeyFromTwoKeys(key1, key2) {
|
|
55
|
-
try {
|
|
56
|
-
return await require_aes.importSymmetricCryptoKey(deriveSymmetricKeyFromTwoKeys(key1, key2));
|
|
57
|
-
} catch (error) {
|
|
58
|
-
throw new Error("Failed to derive symmetric CryptoKey from two keys", { cause: error });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Derives a symmetric key from two keys and context
|
|
63
|
-
*
|
|
64
|
-
* @param key1 - The 32-bytes key
|
|
65
|
-
* @param key2 - The 32-bytes key
|
|
66
|
-
* @param context - The context string
|
|
67
|
-
* @returns The derived symmetric key
|
|
68
|
-
*/
|
|
69
|
-
function deriveSymmetricKeyFromTwoKeysAndContext(key1, key2, context) {
|
|
70
|
-
try {
|
|
71
|
-
if (key2.length != require_constants.AES_KEY_BIT_LENGTH / 8 || key1.length != require_constants.AES_KEY_BIT_LENGTH / 8) throw new Error(`Input key length must be exactly ${require_constants.AES_KEY_BIT_LENGTH / 8} bytes`);
|
|
72
|
-
return (0, _noble_hashes_blake3_js.blake3)((0, _noble_hashes_blake3_js.blake3)(key1, { key: key2 }), { context: require_genID.UTF8ToUint8(context) });
|
|
73
|
-
} catch (error) {
|
|
74
|
-
throw new Error("Failed to derive symmetric key from two keys and context", { cause: error });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
5
|
//#region node_modules/hash-wasm/dist/index.umd.js
|
|
80
6
|
var require_index_umd = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, module) => {
|
|
81
7
|
/*!
|
|
@@ -2311,7 +2237,7 @@ var require_index_umd = /* @__PURE__ */ require_chunk.__commonJSMin(((exports, m
|
|
|
2311
2237
|
}));
|
|
2312
2238
|
|
|
2313
2239
|
//#endregion
|
|
2314
|
-
//#region src/derive-
|
|
2240
|
+
//#region src/derive-password/core.ts
|
|
2315
2241
|
var import_index_umd = require_index_umd();
|
|
2316
2242
|
/**
|
|
2317
2243
|
* Calculates hash using the argon2id password-hashing function
|
|
@@ -2341,11 +2267,11 @@ async function argon2(password, salt, parallelism = require_constants.ARGON2ID_P
|
|
|
2341
2267
|
* @returns The salt
|
|
2342
2268
|
*/
|
|
2343
2269
|
function sampleSalt() {
|
|
2344
|
-
return (0,
|
|
2270
|
+
return (0, _noble_hashes_utils_js.randomBytes)(require_constants.ARGON2ID_SALT_BYTE_LENGTH);
|
|
2345
2271
|
}
|
|
2346
2272
|
|
|
2347
2273
|
//#endregion
|
|
2348
|
-
//#region src/derive-
|
|
2274
|
+
//#region src/derive-password/deriveKeysFromPassword.ts
|
|
2349
2275
|
/**
|
|
2350
2276
|
* Derives a symmetric key from a user's password with a randomly sampled salt
|
|
2351
2277
|
*
|
|
@@ -2354,7 +2280,6 @@ function sampleSalt() {
|
|
|
2354
2280
|
*/
|
|
2355
2281
|
async function getKeyFromPassword(password) {
|
|
2356
2282
|
try {
|
|
2357
|
-
if (!password) throw new Error("No password given");
|
|
2358
2283
|
const salt = sampleSalt();
|
|
2359
2284
|
return {
|
|
2360
2285
|
key: await argon2(password, salt),
|
|
@@ -2373,87 +2298,13 @@ async function getKeyFromPassword(password) {
|
|
|
2373
2298
|
*/
|
|
2374
2299
|
async function getKeyFromPasswordAndSalt(password, salt) {
|
|
2375
2300
|
try {
|
|
2376
|
-
if (!salt.length) throw new Error("No salt given");
|
|
2377
|
-
if (!password) throw new Error("No password given");
|
|
2378
2301
|
return await argon2(password, salt);
|
|
2379
2302
|
} catch (error) {
|
|
2380
2303
|
throw new Error("Failed to derive key from password and salt", { cause: error });
|
|
2381
2304
|
}
|
|
2382
2305
|
}
|
|
2383
|
-
/**
|
|
2384
|
-
* Derives a HEX symmetric key from a user's password with a randomly sampled salt
|
|
2385
|
-
*
|
|
2386
|
-
* @param password - The user's password
|
|
2387
|
-
* @returns The derived HEX secret key and randomly sampled HEX salt
|
|
2388
|
-
*/
|
|
2389
|
-
async function getKeyFromPasswordHex(password) {
|
|
2390
|
-
try {
|
|
2391
|
-
const { key, salt } = await getKeyFromPassword(password);
|
|
2392
|
-
return {
|
|
2393
|
-
keyHex: require_genID.uint8ArrayToHex(key),
|
|
2394
|
-
saltHex: require_genID.uint8ArrayToHex(salt)
|
|
2395
|
-
};
|
|
2396
|
-
} catch (error) {
|
|
2397
|
-
throw new Error("Failed to derive key from password", { cause: error });
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
/**
|
|
2401
|
-
* Derives a HEX symmetric key from a user's password and salt
|
|
2402
|
-
*
|
|
2403
|
-
* @param password - The user's password
|
|
2404
|
-
* @param saltHex - The given HEX salt
|
|
2405
|
-
* @returns The derived HEX secret key
|
|
2406
|
-
*/
|
|
2407
|
-
async function getKeyFromPasswordAndSaltHex(password, saltHex) {
|
|
2408
|
-
try {
|
|
2409
|
-
return require_genID.uint8ArrayToHex(await getKeyFromPasswordAndSalt(password, require_genID.hexToUint8Array(saltHex)));
|
|
2410
|
-
} catch (error) {
|
|
2411
|
-
throw new Error("Failed to derive key from password and salt", { cause: error });
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
/**
|
|
2415
|
-
* Verifies the derived key
|
|
2416
|
-
*
|
|
2417
|
-
* @param password - The user's password
|
|
2418
|
-
* @param saltHex - The given HEX salt
|
|
2419
|
-
* @param keyHex - The derived HEX key
|
|
2420
|
-
* @returns The result of the key verification
|
|
2421
|
-
*/
|
|
2422
|
-
async function verifyKeyFromPasswordHex(password, saltHex, keyHex) {
|
|
2423
|
-
return keyHex === await getKeyFromPasswordAndSaltHex(password, saltHex);
|
|
2424
|
-
}
|
|
2425
2306
|
|
|
2426
2307
|
//#endregion
|
|
2427
|
-
Object.defineProperty(exports, 'deriveSymmetricCryptoKeyFromContext', {
|
|
2428
|
-
enumerable: true,
|
|
2429
|
-
get: function () {
|
|
2430
|
-
return deriveSymmetricCryptoKeyFromContext;
|
|
2431
|
-
}
|
|
2432
|
-
});
|
|
2433
|
-
Object.defineProperty(exports, 'deriveSymmetricCryptoKeyFromTwoKeys', {
|
|
2434
|
-
enumerable: true,
|
|
2435
|
-
get: function () {
|
|
2436
|
-
return deriveSymmetricCryptoKeyFromTwoKeys;
|
|
2437
|
-
}
|
|
2438
|
-
});
|
|
2439
|
-
Object.defineProperty(exports, 'deriveSymmetricKeyFromContext', {
|
|
2440
|
-
enumerable: true,
|
|
2441
|
-
get: function () {
|
|
2442
|
-
return deriveSymmetricKeyFromContext;
|
|
2443
|
-
}
|
|
2444
|
-
});
|
|
2445
|
-
Object.defineProperty(exports, 'deriveSymmetricKeyFromTwoKeys', {
|
|
2446
|
-
enumerable: true,
|
|
2447
|
-
get: function () {
|
|
2448
|
-
return deriveSymmetricKeyFromTwoKeys;
|
|
2449
|
-
}
|
|
2450
|
-
});
|
|
2451
|
-
Object.defineProperty(exports, 'deriveSymmetricKeyFromTwoKeysAndContext', {
|
|
2452
|
-
enumerable: true,
|
|
2453
|
-
get: function () {
|
|
2454
|
-
return deriveSymmetricKeyFromTwoKeysAndContext;
|
|
2455
|
-
}
|
|
2456
|
-
});
|
|
2457
2308
|
Object.defineProperty(exports, 'getKeyFromPassword', {
|
|
2458
2309
|
enumerable: true,
|
|
2459
2310
|
get: function () {
|
|
@@ -2466,22 +2317,4 @@ Object.defineProperty(exports, 'getKeyFromPasswordAndSalt', {
|
|
|
2466
2317
|
return getKeyFromPasswordAndSalt;
|
|
2467
2318
|
}
|
|
2468
2319
|
});
|
|
2469
|
-
|
|
2470
|
-
enumerable: true,
|
|
2471
|
-
get: function () {
|
|
2472
|
-
return getKeyFromPasswordAndSaltHex;
|
|
2473
|
-
}
|
|
2474
|
-
});
|
|
2475
|
-
Object.defineProperty(exports, 'getKeyFromPasswordHex', {
|
|
2476
|
-
enumerable: true,
|
|
2477
|
-
get: function () {
|
|
2478
|
-
return getKeyFromPasswordHex;
|
|
2479
|
-
}
|
|
2480
|
-
});
|
|
2481
|
-
Object.defineProperty(exports, 'verifyKeyFromPasswordHex', {
|
|
2482
|
-
enumerable: true,
|
|
2483
|
-
get: function () {
|
|
2484
|
-
return verifyKeyFromPasswordHex;
|
|
2485
|
-
}
|
|
2486
|
-
});
|
|
2487
|
-
//# sourceMappingURL=deriveKeysFromPassword-BYaiSGKL.js.map
|
|
2320
|
+
//# sourceMappingURL=deriveKeysFromPassword-C7xAGGsh.js.map
|