internxt-crypto 1.2.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/README.md +4 -4
- 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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +55 -55
- package/dist/index.mjs +7 -8
- package/dist/{emailEncryptionKey-D9sk_WKj.mjs → keystore-crypto-C6F-NQdX.mjs} +48 -64
- package/dist/keystore-crypto-C6F-NQdX.mjs.map +1 -0
- package/dist/keystore-crypto-CFiiGohl.js +238 -0
- package/dist/keystore-crypto-CFiiGohl.js.map +1 -0
- package/dist/keystore-crypto.d.mts +18 -19
- package/dist/keystore-crypto.d.mts.map +1 -1
- package/dist/keystore-crypto.d.ts +18 -19
- package/dist/keystore-crypto.d.ts.map +1 -1
- package/dist/keystore-crypto.js +11 -11
- 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-Cw-vW_Oq.js +0 -248
- package/dist/emailEncryptionKey-Cw-vW_Oq.js.map +0 -1
- package/dist/emailEncryptionKey-D9sk_WKj.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-service.mjs","names":["get","set","removeItem","exists","clear"],"sources":["../src/storage-service/localStorageService.ts","../src/storage-service/sessionStorageService.ts"],"sourcesContent":["function get(key: string): string | null {\n return localStorage.getItem(key);\n}\n\nfunction set(key: string, value: string): void {\n return localStorage.setItem(key, value);\n}\n\nfunction removeItem(key: string): void {\n localStorage.removeItem(key);\n}\n\nfunction exists(key: string): boolean {\n return !!localStorage.getItem(key);\n}\n\nfunction clear(): void {\n localStorage.clear();\n}\n\nconst localStorageService = {\n set,\n get,\n removeItem,\n exists,\n clear,\n};\n\nexport default localStorageService;\n\nexport interface LocalStorageService {\n set: (key: string, value: string) => void;\n get: (key: string) => string | null;\n removeItem: (key: string) => void;\n exists: (key: string) => boolean;\n clear: () => void;\n}\n","function get(key: string): string | null {\n return sessionStorage.getItem(key);\n}\n\nfunction set(key: string, value: string): void {\n return sessionStorage.setItem(key, value);\n}\n\nfunction removeItem(key: string): void {\n sessionStorage.removeItem(key);\n}\n\nfunction exists(key: string): boolean {\n return !!sessionStorage.getItem(key);\n}\n\nfunction clear(): void {\n sessionStorage.clear();\n}\n\nconst sessionStorageService = {\n set,\n get,\n removeItem,\n exists,\n clear,\n};\n\nexport default sessionStorageService;\n\nexport interface SessionStorageService {\n set: (key: string, value: string) => void;\n get: (key: string) => string | null;\n removeItem: (key: string) => void;\n exists: (key: string) => boolean;\n clear: () => void;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage-service.mjs","names":["get","set","removeItem","exists","clear"],"sources":["../src/storage-service/localStorageService.ts","../src/storage-service/sessionStorageService.ts"],"sourcesContent":["function get(key: string): string | null {\n return localStorage.getItem(key);\n}\n\nfunction set(key: string, value: string): void {\n return localStorage.setItem(key, value);\n}\n\nfunction removeItem(key: string): void {\n localStorage.removeItem(key);\n}\n\nfunction exists(key: string): boolean {\n return !!localStorage.getItem(key);\n}\n\nfunction clear(): void {\n localStorage.clear();\n}\n\nconst localStorageService = {\n set,\n get,\n removeItem,\n exists,\n clear,\n};\n\nexport default localStorageService;\n\nexport interface LocalStorageService {\n set: (key: string, value: string) => void;\n get: (key: string) => string | null;\n removeItem: (key: string) => void;\n exists: (key: string) => boolean;\n clear: () => void;\n}\n","function get(key: string): string | null {\n return sessionStorage.getItem(key);\n}\n\nfunction set(key: string, value: string): void {\n return sessionStorage.setItem(key, value);\n}\n\nfunction removeItem(key: string): void {\n sessionStorage.removeItem(key);\n}\n\nfunction exists(key: string): boolean {\n return !!sessionStorage.getItem(key);\n}\n\nfunction clear(): void {\n sessionStorage.clear();\n}\n\nconst sessionStorageService = {\n set,\n get,\n removeItem,\n exists,\n clear,\n};\n\nexport default sessionStorageService;\n\nexport interface SessionStorageService {\n set: (key: string, value: string) => void;\n get: (key: string) => string | null;\n removeItem: (key: string) => void;\n exists: (key: string) => boolean;\n clear: () => void;\n}\n"],"mappings":";;;AAAA,SAASA,MAAI,KAA4B;AACvC,QAAO,aAAa,QAAQ,IAAI;;AAGlC,SAASC,MAAI,KAAa,OAAqB;AAC7C,QAAO,aAAa,QAAQ,KAAK,MAAM;;AAGzC,SAASC,aAAW,KAAmB;AACrC,cAAa,WAAW,IAAI;;AAG9B,SAASC,SAAO,KAAsB;AACpC,QAAO,CAAC,CAAC,aAAa,QAAQ,IAAI;;AAGpC,SAASC,UAAc;AACrB,cAAa,OAAO;;AAGtB,MAAM,sBAAsB;CAC1B,KAAA;CACA,KAAA;CACA,YAAA;CACA,QAAA;CACA,OAAA;CACD;;;;AC1BD,SAAS,IAAI,KAA4B;AACvC,QAAO,eAAe,QAAQ,IAAI;;AAGpC,SAAS,IAAI,KAAa,OAAqB;AAC7C,QAAO,eAAe,QAAQ,KAAK,MAAM;;AAG3C,SAAS,WAAW,KAAmB;AACrC,gBAAe,WAAW,IAAI;;AAGhC,SAAS,OAAO,KAAsB;AACpC,QAAO,CAAC,CAAC,eAAe,QAAQ,IAAI;;AAGtC,SAAS,QAAc;AACrB,gBAAe,OAAO;;AAGxB,MAAM,wBAAwB;CAC5B;CACA;CACA;CACA;CACA;CACD"}
|
package/dist/symmetric-crypto.js
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./chunk-C13QxCFV.js");
|
|
3
|
+
require("./constants.js");
|
|
4
|
+
let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
|
|
5
|
+
let _noble_ciphers_webcrypto_js = require("@noble/ciphers/webcrypto.js");
|
|
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)(12);
|
|
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 - 12);
|
|
34
|
+
return await (0, _noble_ciphers_webcrypto_js.gcm)(encryptionKey, encryptedMessage.slice(encryptedMessage.length - 12), 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)(32);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.decryptSymmetrically = decryptSymmetrically;
|
|
49
|
+
exports.encryptSymmetrically = encryptSymmetrically;
|
|
50
|
+
exports.genSymmetricKey = genSymmetricKey;
|
|
3
51
|
|
|
4
|
-
|
|
5
|
-
exports.encryptSymmetrically = require_aes.encryptSymmetrically;
|
|
6
|
-
exports.genSymmetricKey = require_aes.genSymmetricKey;
|
|
52
|
+
//# sourceMappingURL=symmetric-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symmetric-crypto.js","names":[],"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,MAAA,GAAA,uBAAA,aAAA,GAA8B;AAEpC,UAAA,GAAA,uBAAA,aAAmB,OAAA,GAAA,4BAAA,KADiB,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,SAAA,GAAsB;AAGpF,SAAO,OAAA,GAAA,4BAAA,KADyB,eADrB,iBAAiB,MAAM,iBAAiB,SAAA,GACF,EAAE,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,SAAA,GAAA,uBAAA,aAAA,GAAuC"}
|
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./constants.mjs";
|
|
2
|
+
import { concatBytes, randomBytes } from "@noble/hashes/utils.js";
|
|
3
|
+
import { gcm } from "@noble/ciphers/webcrypto.js";
|
|
4
|
+
//#region src/symmetric-crypto/aes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Symmetrically encrypts the message
|
|
7
|
+
*
|
|
8
|
+
* @param encryptionKey - The symmetric key used for message encryption
|
|
9
|
+
* @param message - The message to encrypt
|
|
10
|
+
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
11
|
+
* @returns The resulting ciphertext.
|
|
12
|
+
*/
|
|
13
|
+
async function encryptSymmetrically(encryptionKey, message, aux) {
|
|
14
|
+
try {
|
|
15
|
+
const iv = randomBytes(12);
|
|
16
|
+
return concatBytes(await gcm(encryptionKey, iv, aux).encrypt(message), iv);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new Error("Failed to encrypt symmetrically", { cause: error });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decryps symmetrically encrypted message
|
|
23
|
+
*
|
|
24
|
+
* @param encryptionKey - The symmetric key used for message encryption
|
|
25
|
+
* @param encryptedMessage - The ciphertext
|
|
26
|
+
* @param aux - The auxilary string (e.g., context string or timestamp) for AEAD.
|
|
27
|
+
* @returns The resulting ciphertext.
|
|
28
|
+
*/
|
|
29
|
+
async function decryptSymmetrically(encryptionKey, encryptedMessage, aux) {
|
|
30
|
+
try {
|
|
31
|
+
const ciphertext = encryptedMessage.slice(0, encryptedMessage.length - 12);
|
|
32
|
+
return await gcm(encryptionKey, encryptedMessage.slice(encryptedMessage.length - 12), aux).decrypt(ciphertext);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
throw new Error("Failed to decrypt symmetrically", { cause: error });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates symmetric key as Uint8Array
|
|
39
|
+
*
|
|
40
|
+
* @returns The generated Uint8Array.
|
|
41
|
+
*/
|
|
42
|
+
function genSymmetricKey() {
|
|
43
|
+
return randomBytes(32);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { decryptSymmetrically, encryptSymmetrically, genSymmetricKey };
|
|
2
47
|
|
|
3
|
-
|
|
48
|
+
//# sourceMappingURL=symmetric-crypto.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symmetric-crypto.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,YAAA,GAAyB;AAEpC,SAAO,YAAY,MADMA,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,SAAA,GAAsB;AAGpF,SAAO,MADcA,IAAW,eADrB,iBAAiB,MAAM,iBAAiB,SAAA,GACF,EAAE,IAAI,CAAC,QAAQ,WAAW;UAEpE,OAAO;AACd,QAAM,IAAI,MAAM,mCAAmC,EAAE,OAAO,OAAO,CAAC;;;;;;;;AASxE,SAAgB,kBAA8B;AAC5C,QAAO,YAAA,GAAgC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type EncryptedKeystore = {
|
|
3
|
+
userEmail: string;
|
|
4
|
+
type: KeystoreType;
|
|
5
|
+
publicKey: string;
|
|
6
|
+
privateKeyEncrypted: string;
|
|
7
|
+
};
|
|
8
|
+
type RecipientWithPublicKey = {
|
|
9
|
+
email: string;
|
|
10
|
+
publicHybridKey: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
type HybridKeyPair = {
|
|
13
|
+
publicKey: Uint8Array;
|
|
14
|
+
secretKey: Uint8Array;
|
|
15
|
+
};
|
|
16
|
+
type HybridEncryptedEmail = {
|
|
17
|
+
encryptedKey: HybridEncKey;
|
|
18
|
+
encEmailBody: EmailBodyEncrypted;
|
|
19
|
+
};
|
|
20
|
+
type PwdProtectedEmail = {
|
|
21
|
+
encryptedKey: PwdProtectedKey;
|
|
22
|
+
encEmailBody: EmailBodyEncrypted;
|
|
23
|
+
};
|
|
24
|
+
type HybridEncKey = {
|
|
25
|
+
hybridCiphertext: string;
|
|
26
|
+
encryptedKey: string;
|
|
27
|
+
encryptedForEmail: string;
|
|
28
|
+
};
|
|
29
|
+
type PwdProtectedKey = {
|
|
30
|
+
encryptedKey: string;
|
|
31
|
+
salt: string;
|
|
32
|
+
};
|
|
33
|
+
type EmailBodyEncrypted = {
|
|
34
|
+
encText: string;
|
|
35
|
+
encSubject: string;
|
|
36
|
+
encAttachments?: string[];
|
|
37
|
+
};
|
|
38
|
+
type EmailBody = {
|
|
39
|
+
text: string;
|
|
40
|
+
subject: string;
|
|
41
|
+
attachments?: string[];
|
|
42
|
+
};
|
|
43
|
+
declare enum KeystoreType {
|
|
44
|
+
ENCRYPTION = "Encryption",
|
|
45
|
+
RECOVERY = "Recovery"
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { HybridEncryptedEmail as a, PwdProtectedEmail as c, HybridEncKey as i, PwdProtectedKey as l, EmailBodyEncrypted as n, HybridKeyPair as o, EncryptedKeystore as r, KeystoreType as s, EmailBody as t, RecipientWithPublicKey as u };
|
|
49
|
+
//# sourceMappingURL=types-4P0WII1D.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-4P0WII1D.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,iBAAA;EACV,SAAA;EACA,IAAA,EAAM,YAAA;EACN,SAAA;EACA,mBAAA;AAAA;AAAA,KAGU,sBAAA;EACV,KAAA;EACA,eAAA,EAAiB,UAAA;AAAA;AAAA,KAGP,aAAA;EACV,SAAA,EAAW,UAAA;EACX,SAAA,EAAW,UAAA;AAAA;AAAA,KAGD,oBAAA;EACV,YAAA,EAAc,YAAA;EACd,YAAA,EAAc,kBAAA;AAAA;AAAA,KAGJ,iBAAA;EACV,YAAA,EAAc,eAAA;EACd,YAAA,EAAc,kBAAA;AAAA;AAAA,KAGJ,YAAA;EACV,gBAAA;EACA,YAAA;EACA,iBAAA;AAAA;AAAA,KAGU,eAAA;EACV,YAAA;EACA,IAAA;AAAA;AAAA,KAGU,kBAAA;EACV,OAAA;EACA,UAAA;EACA,cAAA;AAAA;AAAA,KAGU,SAAA;EACV,IAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,aAGU,YAAA;EACV,UAAA;EACA,QAAA;AAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type EncryptedKeystore = {
|
|
3
|
+
userEmail: string;
|
|
4
|
+
type: KeystoreType;
|
|
5
|
+
publicKey: string;
|
|
6
|
+
privateKeyEncrypted: string;
|
|
7
|
+
};
|
|
8
|
+
type RecipientWithPublicKey = {
|
|
9
|
+
email: string;
|
|
10
|
+
publicHybridKey: Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
type HybridKeyPair = {
|
|
13
|
+
publicKey: Uint8Array;
|
|
14
|
+
secretKey: Uint8Array;
|
|
15
|
+
};
|
|
16
|
+
type HybridEncryptedEmail = {
|
|
17
|
+
encryptedKey: HybridEncKey;
|
|
18
|
+
encEmailBody: EmailBodyEncrypted;
|
|
19
|
+
};
|
|
20
|
+
type PwdProtectedEmail = {
|
|
21
|
+
encryptedKey: PwdProtectedKey;
|
|
22
|
+
encEmailBody: EmailBodyEncrypted;
|
|
23
|
+
};
|
|
24
|
+
type HybridEncKey = {
|
|
25
|
+
hybridCiphertext: string;
|
|
26
|
+
encryptedKey: string;
|
|
27
|
+
encryptedForEmail: string;
|
|
28
|
+
};
|
|
29
|
+
type PwdProtectedKey = {
|
|
30
|
+
encryptedKey: string;
|
|
31
|
+
salt: string;
|
|
32
|
+
};
|
|
33
|
+
type EmailBodyEncrypted = {
|
|
34
|
+
encText: string;
|
|
35
|
+
encSubject: string;
|
|
36
|
+
encAttachments?: string[];
|
|
37
|
+
};
|
|
38
|
+
type EmailBody = {
|
|
39
|
+
text: string;
|
|
40
|
+
subject: string;
|
|
41
|
+
attachments?: string[];
|
|
42
|
+
};
|
|
43
|
+
declare enum KeystoreType {
|
|
44
|
+
ENCRYPTION = "Encryption",
|
|
45
|
+
RECOVERY = "Recovery"
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { HybridEncryptedEmail as a, PwdProtectedEmail as c, HybridEncKey as i, PwdProtectedKey as l, EmailBodyEncrypted as n, HybridKeyPair as o, EncryptedKeystore as r, KeystoreType as s, EmailBody as t, RecipientWithPublicKey as u };
|
|
49
|
+
//# sourceMappingURL=types-DAPJQG8U.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DAPJQG8U.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";KAAY,iBAAA;EACV,SAAA;EACA,IAAA,EAAM,YAAA;EACN,SAAA;EACA,mBAAA;AAAA;AAAA,KAGU,sBAAA;EACV,KAAA;EACA,eAAA,EAAiB,UAAA;AAAA;AAAA,KAGP,aAAA;EACV,SAAA,EAAW,UAAA;EACX,SAAA,EAAW,UAAA;AAAA;AAAA,KAGD,oBAAA;EACV,YAAA,EAAc,YAAA;EACd,YAAA,EAAc,kBAAA;AAAA;AAAA,KAGJ,iBAAA;EACV,YAAA,EAAc,eAAA;EACd,YAAA,EAAc,kBAAA;AAAA;AAAA,KAGJ,YAAA;EACV,gBAAA;EACA,YAAA;EACA,iBAAA;AAAA;AAAA,KAGU,eAAA;EACV,YAAA;EACA,IAAA;AAAA;AAAA,KAGU,kBAAA;EACV,OAAA;EACA,UAAA;EACA,cAAA;AAAA;AAAA,KAGU,SAAA;EACV,IAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,aAGU,YAAA;EACV,UAAA;EACA,QAAA;AAAA"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,49 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
userEmail: string;
|
|
4
|
-
type: KeystoreType;
|
|
5
|
-
publicKey: string;
|
|
6
|
-
privateKeyEncrypted: string;
|
|
7
|
-
};
|
|
8
|
-
type RecipientWithPublicKey = {
|
|
9
|
-
email: string;
|
|
10
|
-
publicHybridKey: Uint8Array;
|
|
11
|
-
};
|
|
12
|
-
type HybridKeyPair = {
|
|
13
|
-
publicKey: Uint8Array;
|
|
14
|
-
secretKey: Uint8Array;
|
|
15
|
-
};
|
|
16
|
-
type HybridEncryptedEmail = {
|
|
17
|
-
encryptedKey: HybridEncKey;
|
|
18
|
-
encEmailBody: EmailBodyEncrypted;
|
|
19
|
-
};
|
|
20
|
-
type PwdProtectedEmail = {
|
|
21
|
-
encryptedKey: PwdProtectedKey;
|
|
22
|
-
encEmailBody: EmailBodyEncrypted;
|
|
23
|
-
};
|
|
24
|
-
type HybridEncKey = {
|
|
25
|
-
hybridCiphertext: string;
|
|
26
|
-
encryptedKey: string;
|
|
27
|
-
encryptedForEmail: string;
|
|
28
|
-
};
|
|
29
|
-
type PwdProtectedKey = {
|
|
30
|
-
encryptedKey: string;
|
|
31
|
-
salt: string;
|
|
32
|
-
};
|
|
33
|
-
type EmailBodyEncrypted = {
|
|
34
|
-
encText: string;
|
|
35
|
-
encSubject: string;
|
|
36
|
-
encAttachments?: string[];
|
|
37
|
-
};
|
|
38
|
-
type EmailBody = {
|
|
39
|
-
text: string;
|
|
40
|
-
subject: string;
|
|
41
|
-
attachments?: string[];
|
|
42
|
-
};
|
|
43
|
-
declare enum KeystoreType {
|
|
44
|
-
ENCRYPTION = "Encryption",
|
|
45
|
-
RECOVERY = "Recovery"
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { EmailBody, EmailBodyEncrypted, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, HybridKeyPair, KeystoreType, PwdProtectedEmail, PwdProtectedKey, RecipientWithPublicKey };
|
|
49
|
-
//# sourceMappingURL=types.d.mts.map
|
|
1
|
+
import { a as HybridEncryptedEmail, c as PwdProtectedEmail, i as HybridEncKey, l as PwdProtectedKey, n as EmailBodyEncrypted, o as HybridKeyPair, r as EncryptedKeystore, s as KeystoreType, t as EmailBody, u as RecipientWithPublicKey } from "./types-DAPJQG8U.mjs";
|
|
2
|
+
export { EmailBody, EmailBodyEncrypted, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, HybridKeyPair, KeystoreType, PwdProtectedEmail, PwdProtectedKey, RecipientWithPublicKey };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,49 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
userEmail: string;
|
|
4
|
-
type: KeystoreType;
|
|
5
|
-
publicKey: string;
|
|
6
|
-
privateKeyEncrypted: string;
|
|
7
|
-
};
|
|
8
|
-
type RecipientWithPublicKey = {
|
|
9
|
-
email: string;
|
|
10
|
-
publicHybridKey: Uint8Array;
|
|
11
|
-
};
|
|
12
|
-
type HybridKeyPair = {
|
|
13
|
-
publicKey: Uint8Array;
|
|
14
|
-
secretKey: Uint8Array;
|
|
15
|
-
};
|
|
16
|
-
type HybridEncryptedEmail = {
|
|
17
|
-
encryptedKey: HybridEncKey;
|
|
18
|
-
encEmailBody: EmailBodyEncrypted;
|
|
19
|
-
};
|
|
20
|
-
type PwdProtectedEmail = {
|
|
21
|
-
encryptedKey: PwdProtectedKey;
|
|
22
|
-
encEmailBody: EmailBodyEncrypted;
|
|
23
|
-
};
|
|
24
|
-
type HybridEncKey = {
|
|
25
|
-
hybridCiphertext: string;
|
|
26
|
-
encryptedKey: string;
|
|
27
|
-
encryptedForEmail: string;
|
|
28
|
-
};
|
|
29
|
-
type PwdProtectedKey = {
|
|
30
|
-
encryptedKey: string;
|
|
31
|
-
salt: string;
|
|
32
|
-
};
|
|
33
|
-
type EmailBodyEncrypted = {
|
|
34
|
-
encText: string;
|
|
35
|
-
encSubject: string;
|
|
36
|
-
encAttachments?: string[];
|
|
37
|
-
};
|
|
38
|
-
type EmailBody = {
|
|
39
|
-
text: string;
|
|
40
|
-
subject: string;
|
|
41
|
-
attachments?: string[];
|
|
42
|
-
};
|
|
43
|
-
declare enum KeystoreType {
|
|
44
|
-
ENCRYPTION = "Encryption",
|
|
45
|
-
RECOVERY = "Recovery"
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
export { EmailBody, EmailBodyEncrypted, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, HybridKeyPair, KeystoreType, PwdProtectedEmail, PwdProtectedKey, RecipientWithPublicKey };
|
|
49
|
-
//# sourceMappingURL=types.d.ts.map
|
|
1
|
+
import { a as HybridEncryptedEmail, c as PwdProtectedEmail, i as HybridEncKey, l as PwdProtectedKey, n as EmailBodyEncrypted, o as HybridKeyPair, r as EncryptedKeystore, s as KeystoreType, t as EmailBody, u as RecipientWithPublicKey } from "./types-4P0WII1D.js";
|
|
2
|
+
export { EmailBody, EmailBodyEncrypted, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, HybridKeyPair, KeystoreType, PwdProtectedEmail, PwdProtectedKey, RecipientWithPublicKey };
|
package/dist/types.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
//#region src/types.ts
|
|
4
3
|
let KeystoreType = /* @__PURE__ */ function(KeystoreType) {
|
|
5
4
|
KeystoreType["ENCRYPTION"] = "Encryption";
|
|
6
5
|
KeystoreType["RECOVERY"] = "Recovery";
|
|
7
6
|
return KeystoreType;
|
|
8
7
|
}({});
|
|
9
|
-
|
|
10
8
|
//#endregion
|
|
11
9
|
exports.KeystoreType = KeystoreType;
|
|
10
|
+
|
|
12
11
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type EncryptedKeystore = {\n userEmail: string;\n type: KeystoreType;\n publicKey: string;\n privateKeyEncrypted: string;\n};\n\nexport type RecipientWithPublicKey = {\n email: string;\n publicHybridKey: Uint8Array;\n};\n\nexport type HybridKeyPair = {\n publicKey: Uint8Array;\n secretKey: Uint8Array;\n};\n\nexport type HybridEncryptedEmail = {\n encryptedKey: HybridEncKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type HybridEncKey = {\n hybridCiphertext: string;\n encryptedKey: string;\n encryptedForEmail: string;\n};\n\nexport type PwdProtectedKey = {\n encryptedKey: string;\n salt: string;\n};\n\nexport type EmailBodyEncrypted = {\n encText: string;\n encSubject: string;\n encAttachments?: string[];\n};\n\nexport type EmailBody = {\n text: string;\n subject: string;\n attachments?: string[];\n};\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type EncryptedKeystore = {\n userEmail: string;\n type: KeystoreType;\n publicKey: string;\n privateKeyEncrypted: string;\n};\n\nexport type RecipientWithPublicKey = {\n email: string;\n publicHybridKey: Uint8Array;\n};\n\nexport type HybridKeyPair = {\n publicKey: Uint8Array;\n secretKey: Uint8Array;\n};\n\nexport type HybridEncryptedEmail = {\n encryptedKey: HybridEncKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type HybridEncKey = {\n hybridCiphertext: string;\n encryptedKey: string;\n encryptedForEmail: string;\n};\n\nexport type PwdProtectedKey = {\n encryptedKey: string;\n salt: string;\n};\n\nexport type EmailBodyEncrypted = {\n encText: string;\n encSubject: string;\n encAttachments?: string[];\n};\n\nexport type EmailBody = {\n text: string;\n subject: string;\n attachments?: string[];\n};\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":";;AAkDA,IAAY,eAAL,yBAAA,cAAA;AACL,cAAA,gBAAA;AACA,cAAA,cAAA;;KACD"}
|
package/dist/types.mjs
CHANGED
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type EncryptedKeystore = {\n userEmail: string;\n type: KeystoreType;\n publicKey: string;\n privateKeyEncrypted: string;\n};\n\nexport type RecipientWithPublicKey = {\n email: string;\n publicHybridKey: Uint8Array;\n};\n\nexport type HybridKeyPair = {\n publicKey: Uint8Array;\n secretKey: Uint8Array;\n};\n\nexport type HybridEncryptedEmail = {\n encryptedKey: HybridEncKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type HybridEncKey = {\n hybridCiphertext: string;\n encryptedKey: string;\n encryptedForEmail: string;\n};\n\nexport type PwdProtectedKey = {\n encryptedKey: string;\n salt: string;\n};\n\nexport type EmailBodyEncrypted = {\n encText: string;\n encSubject: string;\n encAttachments?: string[];\n};\n\nexport type EmailBody = {\n text: string;\n subject: string;\n attachments?: string[];\n};\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":";AAkDA,IAAY,
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["export type EncryptedKeystore = {\n userEmail: string;\n type: KeystoreType;\n publicKey: string;\n privateKeyEncrypted: string;\n};\n\nexport type RecipientWithPublicKey = {\n email: string;\n publicHybridKey: Uint8Array;\n};\n\nexport type HybridKeyPair = {\n publicKey: Uint8Array;\n secretKey: Uint8Array;\n};\n\nexport type HybridEncryptedEmail = {\n encryptedKey: HybridEncKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n encEmailBody: EmailBodyEncrypted;\n};\n\nexport type HybridEncKey = {\n hybridCiphertext: string;\n encryptedKey: string;\n encryptedForEmail: string;\n};\n\nexport type PwdProtectedKey = {\n encryptedKey: string;\n salt: string;\n};\n\nexport type EmailBodyEncrypted = {\n encText: string;\n encSubject: string;\n encAttachments?: string[];\n};\n\nexport type EmailBody = {\n text: string;\n subject: string;\n attachments?: string[];\n};\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":";AAkDA,IAAY,eAAL,yBAAA,cAAA;AACL,cAAA,gBAAA;AACA,cAAA,cAAA;;KACD"}
|
package/dist/utils.js
CHANGED
|
@@ -1,15 +1,128 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chunk = require("./chunk-C13QxCFV.js");
|
|
3
|
+
require("./constants.js");
|
|
4
|
+
let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
|
|
5
|
+
let _scure_bip39 = require("@scure/bip39");
|
|
6
|
+
_scure_bip39 = require_chunk.__toESM(_scure_bip39);
|
|
7
|
+
let _scure_bip39_wordlists_english_js = require("@scure/bip39/wordlists/english.js");
|
|
8
|
+
let uuid = require("uuid");
|
|
9
|
+
//#region src/utils/converters.ts
|
|
10
|
+
/**
|
|
11
|
+
* Converts a Uint8Array into a hexadecimal string.
|
|
12
|
+
*
|
|
13
|
+
* @param array - The Uint8Array to convert.
|
|
14
|
+
* @returns The hexadecimal string representation of the array.
|
|
15
|
+
*/
|
|
16
|
+
function uint8ArrayToHex(array) {
|
|
17
|
+
return (0, _noble_hashes_utils_js.bytesToHex)(array);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Converts a UTF-8 string into a Uint8Array.
|
|
21
|
+
*
|
|
22
|
+
* @param str - The UTF-8 string to convert.
|
|
23
|
+
* @returns A Uint8Array created from the UTF-8 string.
|
|
24
|
+
*/
|
|
25
|
+
function UTF8ToUint8(str) {
|
|
26
|
+
return new TextEncoder().encode(str);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts an Uint8Array into a UTF-8 string.
|
|
30
|
+
*
|
|
31
|
+
* @param array - The Uint8Array to convert.
|
|
32
|
+
* @returns The UTF-8 string representation of the array.
|
|
33
|
+
*/
|
|
34
|
+
function uint8ToUTF8(array) {
|
|
35
|
+
return new TextDecoder().decode(array);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts a hexadecimal string into a Uint8Array.
|
|
39
|
+
*
|
|
40
|
+
* @param hex - The hexadecimal string to convert.
|
|
41
|
+
* @returns A Uint8Array created from the hex string.
|
|
42
|
+
*/
|
|
43
|
+
function hexToUint8Array(hex) {
|
|
44
|
+
return (0, _noble_hashes_utils_js.hexToBytes)(hex);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts a Uint8Array into a base64 string.
|
|
48
|
+
*
|
|
49
|
+
* @param array - The Uint8Array to convert.
|
|
50
|
+
* @returns The base64 string representation of the array.
|
|
51
|
+
*/
|
|
52
|
+
function uint8ArrayToBase64(buffer) {
|
|
53
|
+
const array = Uint16Array.from(buffer);
|
|
54
|
+
const binaryString = new TextDecoder("UTF-16").decode(array);
|
|
55
|
+
return btoa(binaryString);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Converts a base64 string into a Uint8Array.
|
|
59
|
+
*
|
|
60
|
+
* @param str - The base64 string to convert.
|
|
61
|
+
* @returns A Uint8Array created from the base64 string.
|
|
62
|
+
*/
|
|
63
|
+
function base64ToUint8Array(str) {
|
|
64
|
+
const binaryString = atob(str);
|
|
65
|
+
const len = binaryString.length;
|
|
66
|
+
const array = new Uint8Array(len);
|
|
67
|
+
for (let i = 0; i < len; i++) array[i] = binaryString.codePointAt(i);
|
|
68
|
+
return new Uint8Array(array.buffer);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/utils/genMnemonic.ts
|
|
72
|
+
/**
|
|
73
|
+
* Generates a mnemonic
|
|
74
|
+
*
|
|
75
|
+
* @returns The generated mnemonic.
|
|
76
|
+
*/
|
|
77
|
+
function genMnemonic() {
|
|
78
|
+
return _scure_bip39.generateMnemonic(_scure_bip39_wordlists_english_js.wordlist, 256);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Converts a mnemonic to Uint8Array
|
|
82
|
+
*
|
|
83
|
+
* @param mnemonic - The mnemonic to convert
|
|
84
|
+
* @returns The mnemonic as Uint8Array
|
|
85
|
+
*/
|
|
86
|
+
function mnemonicToBytes(mnemonic) {
|
|
87
|
+
return _scure_bip39.mnemonicToEntropy(mnemonic, _scure_bip39_wordlists_english_js.wordlist);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Converts a Uint8Array to a mnemonic
|
|
91
|
+
*
|
|
92
|
+
* @param bytes - The bytes to convert
|
|
93
|
+
* @returns The mnemonic string
|
|
94
|
+
*/
|
|
95
|
+
function bytesToMnemonic(bytes) {
|
|
96
|
+
return _scure_bip39.entropyToMnemonic(bytes, _scure_bip39_wordlists_english_js.wordlist);
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/utils/genID.ts
|
|
100
|
+
/**
|
|
101
|
+
* Creates a random identifier.
|
|
102
|
+
*
|
|
103
|
+
* @returns The resulting auxilary string
|
|
104
|
+
*/
|
|
105
|
+
function generateUuid() {
|
|
106
|
+
return (0, uuid.v4)();
|
|
107
|
+
}
|
|
108
|
+
function uuidToBytes(uuid$1) {
|
|
109
|
+
return (0, uuid.parse)(uuid$1);
|
|
110
|
+
}
|
|
111
|
+
function bytesToUuid(bytes) {
|
|
112
|
+
return (0, uuid.stringify)(bytes);
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
exports.UTF8ToUint8 = UTF8ToUint8;
|
|
116
|
+
exports.base64ToUint8Array = base64ToUint8Array;
|
|
117
|
+
exports.bytesToMnemonic = bytesToMnemonic;
|
|
118
|
+
exports.bytesToUuid = bytesToUuid;
|
|
119
|
+
exports.genMnemonic = genMnemonic;
|
|
120
|
+
exports.generateUuid = generateUuid;
|
|
121
|
+
exports.hexToUint8Array = hexToUint8Array;
|
|
122
|
+
exports.mnemonicToBytes = mnemonicToBytes;
|
|
123
|
+
exports.uint8ArrayToBase64 = uint8ArrayToBase64;
|
|
124
|
+
exports.uint8ArrayToHex = uint8ArrayToHex;
|
|
125
|
+
exports.uint8ToUTF8 = uint8ToUTF8;
|
|
126
|
+
exports.uuidToBytes = uuidToBytes;
|
|
3
127
|
|
|
4
|
-
|
|
5
|
-
exports.base64ToUint8Array = require_genID.base64ToUint8Array;
|
|
6
|
-
exports.bytesToMnemonic = require_genID.bytesToMnemonic;
|
|
7
|
-
exports.bytesToUuid = require_genID.bytesToUuid;
|
|
8
|
-
exports.genMnemonic = require_genID.genMnemonic;
|
|
9
|
-
exports.generateUuid = require_genID.generateUuid;
|
|
10
|
-
exports.hexToUint8Array = require_genID.hexToUint8Array;
|
|
11
|
-
exports.mnemonicToBytes = require_genID.mnemonicToBytes;
|
|
12
|
-
exports.uint8ArrayToBase64 = require_genID.uint8ArrayToBase64;
|
|
13
|
-
exports.uint8ArrayToHex = require_genID.uint8ArrayToHex;
|
|
14
|
-
exports.uint8ToUTF8 = require_genID.uint8ToUTF8;
|
|
15
|
-
exports.uuidToBytes = require_genID.uuidToBytes;
|
|
128
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["bip39","wordlist","uuid"],"sources":["../src/utils/converters.ts","../src/utils/genMnemonic.ts","../src/utils/genID.ts"],"sourcesContent":["import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js';\n\n/**\n * Converts a Uint8Array into a hexadecimal string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The hexadecimal string representation of the array.\n */\nexport function uint8ArrayToHex(array: Uint8Array): string {\n return bytesToHex(array);\n}\n\n/**\n * Converts a UTF-8 string into a Uint8Array.\n *\n * @param str - The UTF-8 string to convert.\n * @returns A Uint8Array created from the UTF-8 string.\n */\nexport function UTF8ToUint8(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n/**\n * Converts an Uint8Array into a UTF-8 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The UTF-8 string representation of the array.\n */\nexport function uint8ToUTF8(array: Uint8Array): string {\n return new TextDecoder().decode(array);\n}\n\n/**\n * Converts a hexadecimal string into a Uint8Array.\n *\n * @param hex - The hexadecimal string to convert.\n * @returns A Uint8Array created from the hex string.\n */\nexport function hexToUint8Array(hex: string): Uint8Array {\n return hexToBytes(hex);\n}\n\n/**\n * Converts a Uint8Array into a base64 string.\n *\n * @param array - The Uint8Array to convert.\n * @returns The base64 string representation of the array.\n */\nexport function uint8ArrayToBase64(buffer: Uint8Array): string {\n const array = Uint16Array.from(buffer);\n const binaryString = new TextDecoder('UTF-16').decode(array);\n return btoa(binaryString);\n}\n\n/**\n * Converts a base64 string into a Uint8Array.\n *\n * @param str - The base64 string to convert.\n * @returns A Uint8Array created from the base64 string.\n */\nexport function base64ToUint8Array(str: string): Uint8Array {\n const binaryString = atob(str);\n const len = binaryString.length;\n const array = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n array[i] = binaryString.codePointAt(i)!;\n }\n return new Uint8Array(array.buffer);\n}\n","import * as bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english.js';\nimport { AES_KEY_BYTE_LENGTH } from '../constants';\n/**\n * Generates a mnemonic\n *\n * @returns The generated mnemonic.\n */\nexport function genMnemonic(): string {\n return bip39.generateMnemonic(wordlist, AES_KEY_BYTE_LENGTH * 8);\n}\n\n/**\n * Converts a mnemonic to Uint8Array\n *\n * @param mnemonic - The mnemonic to convert\n * @returns The mnemonic as Uint8Array\n */\nexport function mnemonicToBytes(mnemonic: string): Uint8Array {\n return bip39.mnemonicToEntropy(mnemonic, wordlist);\n}\n\n/**\n * Converts a Uint8Array to a mnemonic\n *\n * @param bytes - The bytes to convert\n * @returns The mnemonic string\n */\nexport function bytesToMnemonic(bytes: Uint8Array): string {\n return bip39.entropyToMnemonic(bytes, wordlist);\n}\n","import { v4 as uuidv4, parse, stringify } from 'uuid';\n/**\n * Creates a random identifier.\n *\n * @returns The resulting auxilary string\n */\nexport function generateUuid(): string {\n return uuidv4();\n}\n\nexport function uuidToBytes(uuid: string): Uint8Array {\n return parse(uuid);\n}\n\nexport function bytesToUuid(bytes: Uint8Array): string {\n return stringify(bytes);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAQA,SAAgB,gBAAgB,OAA2B;AACzD,SAAA,GAAA,uBAAA,YAAkB,MAAM;;;;;;;;AAS1B,SAAgB,YAAY,KAAyB;AACnD,QAAO,IAAI,aAAa,CAAC,OAAO,IAAI;;;;;;;;AAStC,SAAgB,YAAY,OAA2B;AACrD,QAAO,IAAI,aAAa,CAAC,OAAO,MAAM;;;;;;;;AASxC,SAAgB,gBAAgB,KAAyB;AACvD,SAAA,GAAA,uBAAA,YAAkB,IAAI;;;;;;;;AASxB,SAAgB,mBAAmB,QAA4B;CAC7D,MAAM,QAAQ,YAAY,KAAK,OAAO;CACtC,MAAM,eAAe,IAAI,YAAY,SAAS,CAAC,OAAO,MAAM;AAC5D,QAAO,KAAK,aAAa;;;;;;;;AAS3B,SAAgB,mBAAmB,KAAyB;CAC1D,MAAM,eAAe,KAAK,IAAI;CAC9B,MAAM,MAAM,aAAa;CACzB,MAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,IACvB,OAAM,KAAK,aAAa,YAAY,EAAE;AAExC,QAAO,IAAI,WAAW,MAAM,OAAO;;;;;;;;;AC3DrC,SAAgB,cAAsB;AACpC,QAAOA,aAAM,iBAAiBC,kCAAAA,UAAAA,IAAkC;;;;;;;;AASlE,SAAgB,gBAAgB,UAA8B;AAC5D,QAAOD,aAAM,kBAAkB,UAAUC,kCAAAA,SAAS;;;;;;;;AASpD,SAAgB,gBAAgB,OAA2B;AACzD,QAAOD,aAAM,kBAAkB,OAAOC,kCAAAA,SAAS;;;;;;;;;ACvBjD,SAAgB,eAAuB;AACrC,SAAA,GAAA,KAAA,KAAe;;AAGjB,SAAgB,YAAY,QAA0B;AACpD,SAAA,GAAA,KAAA,OAAaC,OAAK;;AAGpB,SAAgB,YAAY,OAA2B;AACrD,SAAA,GAAA,KAAA,WAAiB,MAAM"}
|
package/dist/utils.mjs
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./constants.mjs";
|
|
2
|
+
import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
|
|
3
|
+
import * as bip39 from "@scure/bip39";
|
|
4
|
+
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
5
|
+
import { parse, stringify, v4 } from "uuid";
|
|
6
|
+
//#region src/utils/converters.ts
|
|
7
|
+
/**
|
|
8
|
+
* Converts a Uint8Array into a hexadecimal string.
|
|
9
|
+
*
|
|
10
|
+
* @param array - The Uint8Array to convert.
|
|
11
|
+
* @returns The hexadecimal string representation of the array.
|
|
12
|
+
*/
|
|
13
|
+
function uint8ArrayToHex(array) {
|
|
14
|
+
return bytesToHex(array);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Converts a UTF-8 string into a Uint8Array.
|
|
18
|
+
*
|
|
19
|
+
* @param str - The UTF-8 string to convert.
|
|
20
|
+
* @returns A Uint8Array created from the UTF-8 string.
|
|
21
|
+
*/
|
|
22
|
+
function UTF8ToUint8(str) {
|
|
23
|
+
return new TextEncoder().encode(str);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Converts an Uint8Array into a UTF-8 string.
|
|
27
|
+
*
|
|
28
|
+
* @param array - The Uint8Array to convert.
|
|
29
|
+
* @returns The UTF-8 string representation of the array.
|
|
30
|
+
*/
|
|
31
|
+
function uint8ToUTF8(array) {
|
|
32
|
+
return new TextDecoder().decode(array);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Converts a hexadecimal string into a Uint8Array.
|
|
36
|
+
*
|
|
37
|
+
* @param hex - The hexadecimal string to convert.
|
|
38
|
+
* @returns A Uint8Array created from the hex string.
|
|
39
|
+
*/
|
|
40
|
+
function hexToUint8Array(hex) {
|
|
41
|
+
return hexToBytes(hex);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts a Uint8Array into a base64 string.
|
|
45
|
+
*
|
|
46
|
+
* @param array - The Uint8Array to convert.
|
|
47
|
+
* @returns The base64 string representation of the array.
|
|
48
|
+
*/
|
|
49
|
+
function uint8ArrayToBase64(buffer) {
|
|
50
|
+
const array = Uint16Array.from(buffer);
|
|
51
|
+
const binaryString = new TextDecoder("UTF-16").decode(array);
|
|
52
|
+
return btoa(binaryString);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Converts a base64 string into a Uint8Array.
|
|
56
|
+
*
|
|
57
|
+
* @param str - The base64 string to convert.
|
|
58
|
+
* @returns A Uint8Array created from the base64 string.
|
|
59
|
+
*/
|
|
60
|
+
function base64ToUint8Array(str) {
|
|
61
|
+
const binaryString = atob(str);
|
|
62
|
+
const len = binaryString.length;
|
|
63
|
+
const array = new Uint8Array(len);
|
|
64
|
+
for (let i = 0; i < len; i++) array[i] = binaryString.codePointAt(i);
|
|
65
|
+
return new Uint8Array(array.buffer);
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/utils/genMnemonic.ts
|
|
69
|
+
/**
|
|
70
|
+
* Generates a mnemonic
|
|
71
|
+
*
|
|
72
|
+
* @returns The generated mnemonic.
|
|
73
|
+
*/
|
|
74
|
+
function genMnemonic() {
|
|
75
|
+
return bip39.generateMnemonic(wordlist, 256);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Converts a mnemonic to Uint8Array
|
|
79
|
+
*
|
|
80
|
+
* @param mnemonic - The mnemonic to convert
|
|
81
|
+
* @returns The mnemonic as Uint8Array
|
|
82
|
+
*/
|
|
83
|
+
function mnemonicToBytes(mnemonic) {
|
|
84
|
+
return bip39.mnemonicToEntropy(mnemonic, wordlist);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Converts a Uint8Array to a mnemonic
|
|
88
|
+
*
|
|
89
|
+
* @param bytes - The bytes to convert
|
|
90
|
+
* @returns The mnemonic string
|
|
91
|
+
*/
|
|
92
|
+
function bytesToMnemonic(bytes) {
|
|
93
|
+
return bip39.entropyToMnemonic(bytes, wordlist);
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/utils/genID.ts
|
|
97
|
+
/**
|
|
98
|
+
* Creates a random identifier.
|
|
99
|
+
*
|
|
100
|
+
* @returns The resulting auxilary string
|
|
101
|
+
*/
|
|
102
|
+
function generateUuid() {
|
|
103
|
+
return v4();
|
|
104
|
+
}
|
|
105
|
+
function uuidToBytes(uuid) {
|
|
106
|
+
return parse(uuid);
|
|
107
|
+
}
|
|
108
|
+
function bytesToUuid(bytes) {
|
|
109
|
+
return stringify(bytes);
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { UTF8ToUint8, base64ToUint8Array, bytesToMnemonic, bytesToUuid, genMnemonic, generateUuid, hexToUint8Array, mnemonicToBytes, uint8ArrayToBase64, uint8ArrayToHex, uint8ToUTF8, uuidToBytes };
|
|
2
113
|
|
|
3
|
-
|
|
114
|
+
//# sourceMappingURL=utils.mjs.map
|