internxt-crypto 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{symmetric-crypto-CrdS1Che.mjs → aes-DSDxP8uF.mjs} +4 -17
- package/dist/aes-DSDxP8uF.mjs.map +1 -0
- package/dist/{symmetric-crypto-D65zB396.js → aes-bOrKZuUC.js} +7 -25
- package/dist/aes-bOrKZuUC.js.map +1 -0
- package/dist/asymmetric-crypto.d.mts +1 -4
- package/dist/asymmetric-crypto.d.mts.map +1 -0
- package/dist/asymmetric-crypto.d.ts +1 -4
- package/dist/asymmetric-crypto.d.ts.map +1 -0
- package/dist/asymmetric-crypto.js +8 -7
- package/dist/asymmetric-crypto.mjs +1 -1
- package/dist/{chunk-DWirmd9C.mjs → chunk-DQk6qfdC.mjs} +3 -3
- package/dist/{chunk-Dt-PWiN7.js → chunk-EbLFQX5m.js} +3 -3
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +63 -30
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +33 -2
- package/dist/constants.mjs.map +1 -0
- package/dist/derive-key.d.mts +1 -4
- package/dist/derive-key.d.mts.map +1 -0
- package/dist/derive-key.d.ts +1 -4
- package/dist/derive-key.d.ts.map +1 -0
- package/dist/derive-key.js +12 -14
- package/dist/derive-key.mjs +1 -4
- package/dist/{derive-key-Be7hS-cN.mjs → deriveKeysFromPassword-DJRWZ8Rw.mjs} +5 -21
- package/dist/deriveKeysFromPassword-DJRWZ8Rw.mjs.map +1 -0
- package/dist/{derive-key-CBf2WxJd.js → deriveKeysFromPassword-Ko7NxkHM.js} +24 -45
- package/dist/deriveKeysFromPassword-Ko7NxkHM.js.map +1 -0
- package/dist/email-crypto.d.mts +2 -5
- package/dist/email-crypto.d.mts.map +1 -0
- package/dist/email-crypto.d.ts +2 -5
- package/dist/email-crypto.d.ts.map +1 -0
- package/dist/email-crypto.js +12 -16
- package/dist/email-crypto.mjs +1 -6
- package/dist/email-search.d.mts +2 -5
- package/dist/email-search.d.mts.map +1 -0
- package/dist/email-search.d.ts +2 -5
- package/dist/email-search.d.ts.map +1 -0
- package/dist/email-search.js +14 -52
- package/dist/email-search.js.map +1 -1
- package/dist/email-search.mjs +5 -39
- package/dist/email-search.mjs.map +1 -1
- package/dist/{keystore-crypto-Bjgriq9h.mjs → emailEncryptionKey-27mIHh18.mjs} +10 -19
- package/dist/emailEncryptionKey-27mIHh18.mjs.map +1 -0
- package/dist/{keystore-crypto-B4yCVo9l.js → emailEncryptionKey-DbaDAdoW.js} +25 -40
- package/dist/emailEncryptionKey-DbaDAdoW.js.map +1 -0
- package/dist/{email-crypto-BrT98taw.js → emailKeys-BJGdkLrg.js} +50 -74
- package/dist/emailKeys-BJGdkLrg.js.map +1 -0
- package/dist/{email-crypto-DJUEjTxA.mjs → emailKeys-Fp9WR3wl.mjs} +8 -33
- package/dist/emailKeys-Fp9WR3wl.mjs.map +1 -0
- package/dist/{utils-DS04iUcX.mjs → genID-3Er5IowC.mjs} +4 -24
- package/dist/genID-3Er5IowC.mjs.map +1 -0
- package/dist/{utils-CNs3cyDj.js → genID-YJSl3YhL.js} +6 -31
- package/dist/genID-YJSl3YhL.js.map +1 -0
- package/dist/hash.d.mts +1 -4
- package/dist/hash.d.mts.map +1 -0
- package/dist/hash.d.ts +1 -4
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +11 -10
- package/dist/hash.mjs +1 -1
- package/dist/index.d.mts +11 -31
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +11 -31
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -84
- package/dist/index.mjs +12 -14
- package/dist/{asymmetric-crypto-CyXsV4XT.mjs → keys-BfcaiAOv.mjs} +3 -15
- package/dist/keys-BfcaiAOv.mjs.map +1 -0
- package/dist/{asymmetric-crypto-BORmLhnx.js → keys-CinT7kEY.js} +2 -20
- package/dist/keys-CinT7kEY.js.map +1 -0
- package/dist/keystore-crypto.d.mts +2 -5
- package/dist/keystore-crypto.d.mts.map +1 -0
- package/dist/keystore-crypto.d.ts +2 -5
- package/dist/keystore-crypto.d.ts.map +1 -0
- package/dist/keystore-crypto.js +5 -10
- package/dist/keystore-crypto.mjs +1 -7
- package/dist/{post-quantum-crypto-Vv34t6gX.mjs → kyber1024-PpwE1rki.mjs} +3 -13
- package/dist/kyber1024-PpwE1rki.mjs.map +1 -0
- package/dist/{post-quantum-crypto-CAi-cEkV.js → kyber1024-jeKS8CXf.js} +2 -18
- package/dist/kyber1024-jeKS8CXf.js.map +1 -0
- package/dist/kyber768-DGBB_RS7.d.ts +32 -0
- package/dist/kyber768-DGBB_RS7.d.ts.map +1 -0
- package/dist/kyber768-DzIcGg1i.d.mts +32 -0
- package/dist/kyber768-DzIcGg1i.d.mts.map +1 -0
- package/dist/{hash-BoqwNkcd.js → mac-BMb1F0dN.js} +3 -23
- package/dist/mac-BMb1F0dN.js.map +1 -0
- package/dist/{hash-CXeGAwai.mjs → mac-ZpRlx8Fs.mjs} +3 -18
- package/dist/mac-ZpRlx8Fs.mjs.map +1 -0
- package/dist/post-quantum-crypto.d.mts +68 -2
- package/dist/post-quantum-crypto.d.mts.map +1 -0
- package/dist/post-quantum-crypto.d.ts +68 -2
- package/dist/post-quantum-crypto.d.ts.map +1 -0
- package/dist/post-quantum-crypto.js +7 -6
- package/dist/post-quantum-crypto.mjs +1 -1
- package/dist/storage-service.d.mts +47 -2
- package/dist/storage-service.d.mts.map +1 -0
- package/dist/storage-service.d.ts +47 -2
- package/dist/storage-service.d.ts.map +1 -0
- package/dist/storage-service.js +58 -4
- package/dist/storage-service.js.map +1 -0
- package/dist/storage-service.mjs +55 -2
- package/dist/storage-service.mjs.map +1 -0
- package/dist/symmetric-crypto.d.mts +1 -4
- package/dist/symmetric-crypto.d.mts.map +1 -0
- package/dist/symmetric-crypto.d.ts +1 -4
- package/dist/symmetric-crypto.d.ts.map +1 -0
- package/dist/symmetric-crypto.js +9 -9
- package/dist/symmetric-crypto.mjs +1 -2
- package/dist/types.d.mts +104 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/types.d.ts +104 -2
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -2
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +9 -2
- package/dist/types.mjs.map +1 -0
- package/dist/utils.d.mts +2 -5
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.d.ts +2 -5
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +16 -15
- package/dist/utils.mjs +1 -1
- package/package.json +23 -14
- package/dist/asymmetric-crypto-BORmLhnx.js.map +0 -1
- package/dist/asymmetric-crypto-CyXsV4XT.mjs.map +0 -1
- package/dist/constants-Ccp21E03.js +0 -208
- package/dist/constants-Ccp21E03.js.map +0 -1
- package/dist/constants-kTeX-2T0.mjs +0 -34
- package/dist/constants-kTeX-2T0.mjs.map +0 -1
- package/dist/derive-key-Be7hS-cN.mjs.map +0 -1
- package/dist/derive-key-CBf2WxJd.js.map +0 -1
- package/dist/email-crypto-BrT98taw.js.map +0 -1
- package/dist/email-crypto-DJUEjTxA.mjs.map +0 -1
- package/dist/hash-BoqwNkcd.js.map +0 -1
- package/dist/hash-CXeGAwai.mjs.map +0 -1
- package/dist/index-CQqgKsbX.d.ts +0 -50
- package/dist/index-CintVUbp.d.ts +0 -97
- package/dist/index-D5pBU_A5.d.mts +0 -50
- package/dist/index-MaOov-ag.d.mts +0 -97
- package/dist/keystore-crypto-B4yCVo9l.js.map +0 -1
- package/dist/keystore-crypto-Bjgriq9h.mjs.map +0 -1
- package/dist/keystore-service.d.mts +0 -48
- package/dist/keystore-service.d.ts +0 -48
- package/dist/keystore-service.js +0 -122
- package/dist/keystore-service.js.map +0 -1
- package/dist/keystore-service.mjs +0 -114
- package/dist/keystore-service.mjs.map +0 -1
- package/dist/post-quantum-crypto-CAi-cEkV.js.map +0 -1
- package/dist/post-quantum-crypto-Vv34t6gX.mjs.map +0 -1
- package/dist/storage-service-BgIK2aYZ.js +0 -82
- package/dist/storage-service-BgIK2aYZ.js.map +0 -1
- package/dist/storage-service-CubCbhY2.mjs +0 -65
- package/dist/storage-service-CubCbhY2.mjs.map +0 -1
- package/dist/symmetric-crypto-CrdS1Che.mjs.map +0 -1
- package/dist/symmetric-crypto-D65zB396.js.map +0 -1
- package/dist/types-52g887Zi.js +0 -16
- package/dist/types-52g887Zi.js.map +0 -1
- package/dist/types-BiEoleqw.mjs +0 -10
- package/dist/types-BiEoleqw.mjs.map +0 -1
- package/dist/types-Ds3ivE9W.d.ts +0 -104
- package/dist/types-DwQJtrTx.d.mts +0 -104
- package/dist/utils-CNs3cyDj.js.map +0 -1
- package/dist/utils-DS04iUcX.mjs.map +0 -1
package/dist/types-Ds3ivE9W.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
|
-
type EncryptedKeystore = {
|
|
3
|
-
userEmail: string;
|
|
4
|
-
type: KeystoreType;
|
|
5
|
-
encryptedKeys: EmailKeysEncrypted;
|
|
6
|
-
};
|
|
7
|
-
type User = {
|
|
8
|
-
email: string;
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
type UserWithPublicKeys = User & {
|
|
12
|
-
publicKeys: PublicKeys;
|
|
13
|
-
};
|
|
14
|
-
type PublicKeys = {
|
|
15
|
-
eccPublicKey: CryptoKey;
|
|
16
|
-
kyberPublicKey: Uint8Array;
|
|
17
|
-
};
|
|
18
|
-
type PublicKeysBase64 = {
|
|
19
|
-
eccPublicKeyBase64: string;
|
|
20
|
-
kyberPublicKeyBase64: string;
|
|
21
|
-
};
|
|
22
|
-
type PrivateKeys = {
|
|
23
|
-
eccPrivateKey: CryptoKey;
|
|
24
|
-
kyberPrivateKey: Uint8Array;
|
|
25
|
-
};
|
|
26
|
-
type PrivateKeysEncrypted = {
|
|
27
|
-
eccPrivateKeyBase64: string;
|
|
28
|
-
kyberPrivateKeyBase64: string;
|
|
29
|
-
};
|
|
30
|
-
type EmailKeys = {
|
|
31
|
-
publicKeys: PublicKeys;
|
|
32
|
-
privateKeys: PrivateKeys;
|
|
33
|
-
};
|
|
34
|
-
type EmailKeysEncrypted = {
|
|
35
|
-
publicKeys: PublicKeysBase64;
|
|
36
|
-
privateKeys: PrivateKeysEncrypted;
|
|
37
|
-
};
|
|
38
|
-
type HybridEncryptedEmail = {
|
|
39
|
-
encryptedKey: HybridEncKey;
|
|
40
|
-
enc: EmailBodyEncrypted;
|
|
41
|
-
recipientEmail: string;
|
|
42
|
-
params: EmailPublicParameters;
|
|
43
|
-
id: string;
|
|
44
|
-
isSubjectEncrypted: boolean;
|
|
45
|
-
};
|
|
46
|
-
type PwdProtectedEmail = {
|
|
47
|
-
encryptedKey: PwdProtectedKey;
|
|
48
|
-
enc: EmailBodyEncrypted;
|
|
49
|
-
params: EmailPublicParameters;
|
|
50
|
-
id: string;
|
|
51
|
-
isSubjectEncrypted: boolean;
|
|
52
|
-
};
|
|
53
|
-
type StoredEmail = {
|
|
54
|
-
params: EmailPublicParameters;
|
|
55
|
-
enc: EmailBodyEncrypted;
|
|
56
|
-
id: string;
|
|
57
|
-
};
|
|
58
|
-
type HybridEncKey = {
|
|
59
|
-
kyberCiphertext: string;
|
|
60
|
-
encryptedKey: string;
|
|
61
|
-
};
|
|
62
|
-
type PwdProtectedKey = {
|
|
63
|
-
encryptedKey: string;
|
|
64
|
-
salt: string;
|
|
65
|
-
};
|
|
66
|
-
type EmailBodyEncrypted = {
|
|
67
|
-
encText: string;
|
|
68
|
-
encAttachments?: string[];
|
|
69
|
-
};
|
|
70
|
-
type EmailBody = {
|
|
71
|
-
text: string;
|
|
72
|
-
attachments?: string[];
|
|
73
|
-
};
|
|
74
|
-
type EmailPublicParameters = {
|
|
75
|
-
subject: string;
|
|
76
|
-
createdAt: string;
|
|
77
|
-
sender: User;
|
|
78
|
-
recipient: User;
|
|
79
|
-
recipients?: User[];
|
|
80
|
-
replyToEmailID?: string;
|
|
81
|
-
labels?: string[];
|
|
82
|
-
};
|
|
83
|
-
type Email = {
|
|
84
|
-
id: string;
|
|
85
|
-
body: EmailBody;
|
|
86
|
-
params: EmailPublicParameters;
|
|
87
|
-
};
|
|
88
|
-
interface MailCache<Email> {
|
|
89
|
-
esCache: Map<string, Email>;
|
|
90
|
-
cacheSize: number;
|
|
91
|
-
isCacheLimited: boolean;
|
|
92
|
-
isCacheReady: boolean;
|
|
93
|
-
}
|
|
94
|
-
interface EmailSearchResult {
|
|
95
|
-
email: Email;
|
|
96
|
-
score?: number;
|
|
97
|
-
}
|
|
98
|
-
declare enum KeystoreType {
|
|
99
|
-
ENCRYPTION = "Encryption",
|
|
100
|
-
RECOVERY = "Recovery"
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
export { PwdProtectedEmail as _, EmailKeysEncrypted as a, User as b, EncryptedKeystore as c, KeystoreType as d, MailCache as f, PublicKeysBase64 as g, PublicKeys as h, EmailKeys as i, HybridEncKey as l, PrivateKeysEncrypted as m, EmailBody as n, EmailPublicParameters as o, PrivateKeys as p, EmailBodyEncrypted as r, EmailSearchResult as s, Email as t, HybridEncryptedEmail as u, PwdProtectedKey as v, UserWithPublicKeys as x, StoredEmail as y };
|
|
104
|
-
//# sourceMappingURL=types-Ds3ivE9W.d.ts.map
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
|
-
type EncryptedKeystore = {
|
|
3
|
-
userEmail: string;
|
|
4
|
-
type: KeystoreType;
|
|
5
|
-
encryptedKeys: EmailKeysEncrypted;
|
|
6
|
-
};
|
|
7
|
-
type User = {
|
|
8
|
-
email: string;
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
type UserWithPublicKeys = User & {
|
|
12
|
-
publicKeys: PublicKeys;
|
|
13
|
-
};
|
|
14
|
-
type PublicKeys = {
|
|
15
|
-
eccPublicKey: CryptoKey;
|
|
16
|
-
kyberPublicKey: Uint8Array;
|
|
17
|
-
};
|
|
18
|
-
type PublicKeysBase64 = {
|
|
19
|
-
eccPublicKeyBase64: string;
|
|
20
|
-
kyberPublicKeyBase64: string;
|
|
21
|
-
};
|
|
22
|
-
type PrivateKeys = {
|
|
23
|
-
eccPrivateKey: CryptoKey;
|
|
24
|
-
kyberPrivateKey: Uint8Array;
|
|
25
|
-
};
|
|
26
|
-
type PrivateKeysEncrypted = {
|
|
27
|
-
eccPrivateKeyBase64: string;
|
|
28
|
-
kyberPrivateKeyBase64: string;
|
|
29
|
-
};
|
|
30
|
-
type EmailKeys = {
|
|
31
|
-
publicKeys: PublicKeys;
|
|
32
|
-
privateKeys: PrivateKeys;
|
|
33
|
-
};
|
|
34
|
-
type EmailKeysEncrypted = {
|
|
35
|
-
publicKeys: PublicKeysBase64;
|
|
36
|
-
privateKeys: PrivateKeysEncrypted;
|
|
37
|
-
};
|
|
38
|
-
type HybridEncryptedEmail = {
|
|
39
|
-
encryptedKey: HybridEncKey;
|
|
40
|
-
enc: EmailBodyEncrypted;
|
|
41
|
-
recipientEmail: string;
|
|
42
|
-
params: EmailPublicParameters;
|
|
43
|
-
id: string;
|
|
44
|
-
isSubjectEncrypted: boolean;
|
|
45
|
-
};
|
|
46
|
-
type PwdProtectedEmail = {
|
|
47
|
-
encryptedKey: PwdProtectedKey;
|
|
48
|
-
enc: EmailBodyEncrypted;
|
|
49
|
-
params: EmailPublicParameters;
|
|
50
|
-
id: string;
|
|
51
|
-
isSubjectEncrypted: boolean;
|
|
52
|
-
};
|
|
53
|
-
type StoredEmail = {
|
|
54
|
-
params: EmailPublicParameters;
|
|
55
|
-
enc: EmailBodyEncrypted;
|
|
56
|
-
id: string;
|
|
57
|
-
};
|
|
58
|
-
type HybridEncKey = {
|
|
59
|
-
kyberCiphertext: string;
|
|
60
|
-
encryptedKey: string;
|
|
61
|
-
};
|
|
62
|
-
type PwdProtectedKey = {
|
|
63
|
-
encryptedKey: string;
|
|
64
|
-
salt: string;
|
|
65
|
-
};
|
|
66
|
-
type EmailBodyEncrypted = {
|
|
67
|
-
encText: string;
|
|
68
|
-
encAttachments?: string[];
|
|
69
|
-
};
|
|
70
|
-
type EmailBody = {
|
|
71
|
-
text: string;
|
|
72
|
-
attachments?: string[];
|
|
73
|
-
};
|
|
74
|
-
type EmailPublicParameters = {
|
|
75
|
-
subject: string;
|
|
76
|
-
createdAt: string;
|
|
77
|
-
sender: User;
|
|
78
|
-
recipient: User;
|
|
79
|
-
recipients?: User[];
|
|
80
|
-
replyToEmailID?: string;
|
|
81
|
-
labels?: string[];
|
|
82
|
-
};
|
|
83
|
-
type Email = {
|
|
84
|
-
id: string;
|
|
85
|
-
body: EmailBody;
|
|
86
|
-
params: EmailPublicParameters;
|
|
87
|
-
};
|
|
88
|
-
interface MailCache<Email> {
|
|
89
|
-
esCache: Map<string, Email>;
|
|
90
|
-
cacheSize: number;
|
|
91
|
-
isCacheLimited: boolean;
|
|
92
|
-
isCacheReady: boolean;
|
|
93
|
-
}
|
|
94
|
-
interface EmailSearchResult {
|
|
95
|
-
email: Email;
|
|
96
|
-
score?: number;
|
|
97
|
-
}
|
|
98
|
-
declare enum KeystoreType {
|
|
99
|
-
ENCRYPTION = "Encryption",
|
|
100
|
-
RECOVERY = "Recovery"
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
|
-
export { PwdProtectedEmail as _, EmailKeysEncrypted as a, User as b, EncryptedKeystore as c, KeystoreType as d, MailCache as f, PublicKeysBase64 as g, PublicKeys as h, EmailKeys as i, HybridEncKey as l, PrivateKeysEncrypted as m, EmailBody as n, EmailPublicParameters as o, PrivateKeys as p, EmailBodyEncrypted as r, EmailSearchResult as s, Email as t, HybridEncryptedEmail as u, PwdProtectedKey as v, UserWithPublicKeys as x, StoredEmail as y };
|
|
104
|
-
//# sourceMappingURL=types-DwQJtrTx.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-CNs3cyDj.js","names":["importPublicKey","exportPublicKey","bip39","wordlist","AES_KEY_BIT_LENGTH","uuid"],"sources":["../src/utils/converters.ts","../src/utils/keyConverters.ts","../src/utils/genMnemonic.ts","../src/utils/genID.ts","../src/utils/index.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 { uint8ArrayToBase64, base64ToUint8Array } from '.';\nimport { PublicKeys, PublicKeysBase64 } from '../types';\nimport { exportPublicKey, importPublicKey } from '../asymmetric-crypto';\n\n/**\n * Converts a base64 string into PublicKeys type.\n *\n * @param base64 - The base64 representation of the public key.\n * @returns The resulting PublicKeys.\n */\nexport async function base64ToPublicKey(base64: PublicKeysBase64): Promise<PublicKeys> {\n try {\n const eccPublicKeyBytes = base64ToUint8Array(base64.eccPublicKeyBase64);\n const eccPublicKey = await importPublicKey(eccPublicKeyBytes);\n const kyberPublicKey = base64ToUint8Array(base64.kyberPublicKeyBase64);\n return {\n eccPublicKey: eccPublicKey,\n kyberPublicKey: kyberPublicKey,\n };\n } catch (error) {\n throw new Error('Failed to convert base64 to PublicKeys', { cause: error });\n }\n}\n\n/**\n * Converts a PublicKeys type into PublicKeysBase64.\n *\n * @param key - The PublicKeys key.\n * @returns The resulting PublicKeysBase64.\n */\nexport async function publicKeyToBase64(key: PublicKeys): Promise<PublicKeysBase64> {\n try {\n const eccPublicKeyArray = await exportPublicKey(key.eccPublicKey);\n const keys = {\n eccPublicKeyBase64: uint8ArrayToBase64(eccPublicKeyArray),\n kyberPublicKeyBase64: uint8ArrayToBase64(key.kyberPublicKey),\n };\n return keys;\n } catch (error) {\n throw new Error('Failed to convert key of the type PublicKeys to PublicKeysBase64', { cause: error });\n }\n}\n","import * as bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english.js';\nimport { AES_KEY_BIT_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_BIT_LENGTH);\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","export * from './converters';\nexport * from './keyConverters';\nexport * from './genMnemonic';\nexport * from './genID';\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,SAAgB,gBAAgB,OAA2B;AACzD,+CAAkB,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,+CAAkB,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;;;;;;;;;;;ACzDrC,eAAsB,kBAAkB,QAA+C;AACrF,KAAI;AAIF,SAAO;GACL,cAHmB,MAAMA,0CADD,mBAAmB,OAAO,mBAAmB,CACV;GAI3D,gBAHqB,mBAAmB,OAAO,qBAAqB;GAIrE;UACM,OAAO;AACd,QAAM,IAAI,MAAM,0CAA0C,EAAE,OAAO,OAAO,CAAC;;;;;;;;;AAU/E,eAAsB,kBAAkB,KAA4C;AAClF,KAAI;AAMF,SAJa;GACX,oBAAoB,mBAFI,MAAMC,0CAAgB,IAAI,aAAa,CAEN;GACzD,sBAAsB,mBAAmB,IAAI,eAAe;GAC7D;UAEM,OAAO;AACd,QAAM,IAAI,MAAM,oEAAoE,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AC/BzG,SAAgB,cAAsB;AACpC,QAAOC,aAAM,iBAAiBC,4CAAUC,qCAAmB;;;;;;;;AAS7D,SAAgB,gBAAgB,UAA8B;AAC5D,QAAOF,aAAM,kBAAkB,UAAUC,2CAAS;;;;;;;;AASpD,SAAgB,gBAAgB,OAA2B;AACzD,QAAOD,aAAM,kBAAkB,OAAOC,2CAAS;;;;;;;;;;ACvBjD,SAAgB,eAAuB;AACrC,sBAAe;;AAGjB,SAAgB,YAAY,QAA0B;AACpD,wBAAaE,OAAK;;AAGpB,SAAgB,YAAY,OAA2B;AACrD,4BAAiB,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-DS04iUcX.mjs","names":["uuidv4"],"sources":["../src/utils/converters.ts","../src/utils/keyConverters.ts","../src/utils/genMnemonic.ts","../src/utils/genID.ts","../src/utils/index.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 { uint8ArrayToBase64, base64ToUint8Array } from '.';\nimport { PublicKeys, PublicKeysBase64 } from '../types';\nimport { exportPublicKey, importPublicKey } from '../asymmetric-crypto';\n\n/**\n * Converts a base64 string into PublicKeys type.\n *\n * @param base64 - The base64 representation of the public key.\n * @returns The resulting PublicKeys.\n */\nexport async function base64ToPublicKey(base64: PublicKeysBase64): Promise<PublicKeys> {\n try {\n const eccPublicKeyBytes = base64ToUint8Array(base64.eccPublicKeyBase64);\n const eccPublicKey = await importPublicKey(eccPublicKeyBytes);\n const kyberPublicKey = base64ToUint8Array(base64.kyberPublicKeyBase64);\n return {\n eccPublicKey: eccPublicKey,\n kyberPublicKey: kyberPublicKey,\n };\n } catch (error) {\n throw new Error('Failed to convert base64 to PublicKeys', { cause: error });\n }\n}\n\n/**\n * Converts a PublicKeys type into PublicKeysBase64.\n *\n * @param key - The PublicKeys key.\n * @returns The resulting PublicKeysBase64.\n */\nexport async function publicKeyToBase64(key: PublicKeys): Promise<PublicKeysBase64> {\n try {\n const eccPublicKeyArray = await exportPublicKey(key.eccPublicKey);\n const keys = {\n eccPublicKeyBase64: uint8ArrayToBase64(eccPublicKeyArray),\n kyberPublicKeyBase64: uint8ArrayToBase64(key.kyberPublicKey),\n };\n return keys;\n } catch (error) {\n throw new Error('Failed to convert key of the type PublicKeys to PublicKeysBase64', { cause: error });\n }\n}\n","import * as bip39 from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english.js';\nimport { AES_KEY_BIT_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_BIT_LENGTH);\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","export * from './converters';\nexport * from './keyConverters';\nexport * from './genMnemonic';\nexport * from './genID';\n"],"mappings":";;;;;;;;;;;;;;;AAQA,SAAgB,gBAAgB,OAA2B;AACzD,QAAO,WAAW,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,QAAO,WAAW,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;;;;;;;;;;;ACzDrC,eAAsB,kBAAkB,QAA+C;AACrF,KAAI;AAIF,SAAO;GACL,cAHmB,MAAM,gBADD,mBAAmB,OAAO,mBAAmB,CACV;GAI3D,gBAHqB,mBAAmB,OAAO,qBAAqB;GAIrE;UACM,OAAO;AACd,QAAM,IAAI,MAAM,0CAA0C,EAAE,OAAO,OAAO,CAAC;;;;;;;;;AAU/E,eAAsB,kBAAkB,KAA4C;AAClF,KAAI;AAMF,SAJa;GACX,oBAAoB,mBAFI,MAAM,gBAAgB,IAAI,aAAa,CAEN;GACzD,sBAAsB,mBAAmB,IAAI,eAAe;GAC7D;UAEM,OAAO;AACd,QAAM,IAAI,MAAM,oEAAoE,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;;AC/BzG,SAAgB,cAAsB;AACpC,QAAO,MAAM,iBAAiB,UAAU,mBAAmB;;;;;;;;AAS7D,SAAgB,gBAAgB,UAA8B;AAC5D,QAAO,MAAM,kBAAkB,UAAU,SAAS;;;;;;;;AASpD,SAAgB,gBAAgB,OAA2B;AACzD,QAAO,MAAM,kBAAkB,OAAO,SAAS;;;;;;;;;;ACvBjD,SAAgB,eAAuB;AACrC,QAAOA,IAAQ;;AAGjB,SAAgB,YAAY,MAA0B;AACpD,QAAO,MAAM,KAAK;;AAGpB,SAAgB,YAAY,OAA2B;AACrD,QAAO,UAAU,MAAM"}
|