internxt-crypto 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -73
- package/dist/asymmetric-crypto.js +3 -4
- package/dist/asymmetric-crypto.js.map +1 -1
- package/dist/asymmetric-crypto.mjs +1 -2
- package/dist/asymmetric-crypto.mjs.map +1 -1
- package/dist/chunk-C13QxCFV.js +50 -0
- package/dist/chunk-CfYAbeIz.mjs +13 -0
- package/dist/constants.js +2 -3
- package/dist/constants.js.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/derive-key.js +50 -5
- package/dist/derive-key.js.map +1 -0
- package/dist/derive-key.mjs +46 -2
- package/dist/derive-key.mjs.map +1 -0
- package/dist/{deriveKeysFromPassword-iMHv-tIA.js → derive-password-CbYRDq7V.js} +25 -30
- package/dist/derive-password-CbYRDq7V.js.map +1 -0
- package/dist/{deriveKeysFromPassword-DFzo2OII.mjs → derive-password-PED-YfwE.mjs} +27 -34
- package/dist/derive-password-PED-YfwE.mjs.map +1 -0
- package/dist/derive-password.js +5 -6
- package/dist/derive-password.mjs +2 -3
- package/dist/email-crypto-Di814Pbk.js +739 -0
- package/dist/email-crypto-Di814Pbk.js.map +1 -0
- package/dist/email-crypto-DpjfXDes.mjs +535 -0
- package/dist/email-crypto-DpjfXDes.mjs.map +1 -0
- package/dist/email-crypto.d.mts +138 -29
- package/dist/email-crypto.d.mts.map +1 -1
- package/dist/email-crypto.d.ts +138 -29
- package/dist/email-crypto.d.ts.map +1 -1
- package/dist/email-crypto.js +34 -18
- package/dist/email-crypto.mjs +2 -3
- package/dist/hash.js +3 -4
- package/dist/hash.js.map +1 -1
- package/dist/hash.mjs +1 -2
- package/dist/hash.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +72 -56
- package/dist/index.mjs +7 -8
- package/dist/{emailEncryptionKey-CYvr26FG.mjs → keystore-crypto-C6F-NQdX.mjs} +12 -15
- package/dist/keystore-crypto-C6F-NQdX.mjs.map +1 -0
- package/dist/{emailEncryptionKey-Ba95VuFO.js → keystore-crypto-CFiiGohl.js} +67 -70
- package/dist/keystore-crypto-CFiiGohl.js.map +1 -0
- package/dist/keystore-crypto.d.mts +1 -1
- package/dist/keystore-crypto.d.ts +1 -1
- package/dist/keystore-crypto.js +11 -12
- package/dist/keystore-crypto.mjs +2 -3
- package/dist/post-quantum-crypto.js +3 -4
- package/dist/post-quantum-crypto.js.map +1 -1
- package/dist/post-quantum-crypto.mjs +1 -2
- package/dist/post-quantum-crypto.mjs.map +1 -1
- package/dist/storage-service.js +13 -15
- package/dist/storage-service.js.map +1 -1
- package/dist/storage-service.mjs +2 -4
- package/dist/storage-service.mjs.map +1 -1
- package/dist/symmetric-crypto.js +51 -5
- package/dist/symmetric-crypto.js.map +1 -0
- package/dist/symmetric-crypto.mjs +47 -2
- package/dist/symmetric-crypto.mjs.map +1 -0
- package/dist/types-CrAiKyb0.d.ts +61 -0
- package/dist/types-CrAiKyb0.d.ts.map +1 -0
- package/dist/types-D6hsUfma.d.mts +61 -0
- package/dist/types-D6hsUfma.d.mts.map +1 -0
- package/dist/types.d.mts +2 -49
- package/dist/types.d.ts +2 -49
- package/dist/types.js +2 -3
- package/dist/types.js.map +1 -1
- package/dist/types.mjs +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/utils.js +127 -14
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +113 -2
- package/dist/utils.mjs.map +1 -0
- package/dist/{xwing-iRWVRtNE.js → xwing-7fEqAT7W.js} +18 -19
- package/dist/{xwing-iRWVRtNE.js.map → xwing-7fEqAT7W.js.map} +1 -1
- package/dist/{xwing-CQmQX6hn.mjs → xwing-B34h5e3Z.mjs} +2 -3
- package/dist/{xwing-CQmQX6hn.mjs.map → xwing-B34h5e3Z.mjs.map} +1 -1
- package/package.json +22 -22
- package/dist/aes-B8TA-JKq.mjs +0 -49
- package/dist/aes-B8TA-JKq.mjs.map +0 -1
- package/dist/aes-CuW_SPl-.js +0 -67
- package/dist/aes-CuW_SPl-.js.map +0 -1
- package/dist/chunk-DQk6qfdC.mjs +0 -18
- package/dist/chunk-EbLFQX5m.js +0 -60
- package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs +0 -49
- package/dist/deriveKeysFromMnemonic-DB0UHE-y.mjs.map +0 -1
- package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js +0 -67
- package/dist/deriveKeysFromMnemonic-Dbx7VSBQ.js.map +0 -1
- package/dist/deriveKeysFromPassword-DFzo2OII.mjs.map +0 -1
- package/dist/deriveKeysFromPassword-iMHv-tIA.js.map +0 -1
- package/dist/emailEncryptionKey-Ba95VuFO.js.map +0 -1
- package/dist/emailEncryptionKey-CYvr26FG.mjs.map +0 -1
- package/dist/emailKeys-BFI-paQq.js +0 -406
- package/dist/emailKeys-BFI-paQq.js.map +0 -1
- package/dist/emailKeys-BjIeINfC.mjs +0 -304
- package/dist/emailKeys-BjIeINfC.mjs.map +0 -1
- package/dist/genID-D08K7JPr.mjs +0 -117
- package/dist/genID-D08K7JPr.mjs.map +0 -1
- package/dist/genID-cWOPmspk.js +0 -190
- package/dist/genID-cWOPmspk.js.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
encEmail: EmailEncrypted;
|
|
19
|
+
};
|
|
20
|
+
type HybridEncryptedEmailAndSubject = {
|
|
21
|
+
encryptedKey: HybridEncKey;
|
|
22
|
+
encEmail: EmailAndSubjectEncrypted;
|
|
23
|
+
};
|
|
24
|
+
type PwdProtectedEmail = {
|
|
25
|
+
encryptedKey: PwdProtectedKey;
|
|
26
|
+
encEmail: EmailEncrypted;
|
|
27
|
+
};
|
|
28
|
+
type PwdProtectedEmailAndSubject = {
|
|
29
|
+
encryptedKey: PwdProtectedKey;
|
|
30
|
+
encEmail: EmailAndSubjectEncrypted;
|
|
31
|
+
};
|
|
32
|
+
type HybridEncKey = {
|
|
33
|
+
hybridCiphertext: string;
|
|
34
|
+
encryptedKey: string;
|
|
35
|
+
encryptedForEmail: string;
|
|
36
|
+
};
|
|
37
|
+
type PwdProtectedKey = {
|
|
38
|
+
encryptedKey: string;
|
|
39
|
+
salt: string;
|
|
40
|
+
};
|
|
41
|
+
type EmailEncrypted = {
|
|
42
|
+
encText: string;
|
|
43
|
+
encAttachments?: string[];
|
|
44
|
+
};
|
|
45
|
+
type EmailAndSubjectEncrypted = EmailEncrypted & {
|
|
46
|
+
encSubject: string;
|
|
47
|
+
};
|
|
48
|
+
type Email = {
|
|
49
|
+
text: string;
|
|
50
|
+
attachments?: string[];
|
|
51
|
+
};
|
|
52
|
+
type EmailAndSubject = Email & {
|
|
53
|
+
subject: string;
|
|
54
|
+
};
|
|
55
|
+
declare enum KeystoreType {
|
|
56
|
+
ENCRYPTION = "Encryption",
|
|
57
|
+
RECOVERY = "Recovery"
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { EncryptedKeystore as a, HybridEncryptedEmailAndSubject as c, PwdProtectedEmail as d, PwdProtectedEmailAndSubject as f, EmailEncrypted as i, HybridKeyPair as l, RecipientWithPublicKey as m, EmailAndSubject as n, HybridEncKey as o, PwdProtectedKey as p, EmailAndSubjectEncrypted as r, HybridEncryptedEmail as s, Email as t, KeystoreType as u };
|
|
61
|
+
//# sourceMappingURL=types-CrAiKyb0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CrAiKyb0.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,QAAA,EAAU,cAAA;AAAA;AAAA,KAGA,8BAAA;EACV,YAAA,EAAc,YAAA;EACd,QAAA,EAAU,wBAAA;AAAA;AAAA,KAGA,iBAAA;EACV,YAAA,EAAc,eAAA;EACd,QAAA,EAAU,cAAA;AAAA;AAAA,KAGA,2BAAA;EACV,YAAA,EAAc,eAAA;EACd,QAAA,EAAU,wBAAA;AAAA;AAAA,KAGA,YAAA;EACV,gBAAA;EACA,YAAA;EACA,iBAAA;AAAA;AAAA,KAGU,eAAA;EACV,YAAA;EACA,IAAA;AAAA;AAAA,KAGU,cAAA;EACV,OAAA;EACA,cAAA;AAAA;AAAA,KAGU,wBAAA,GAA2B,cAAA;EACrC,UAAA;AAAA;AAAA,KAGU,KAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,eAAA,GAAkB,KAAA;EAC5B,OAAA;AAAA;AAAA,aAGU,YAAA;EACV,UAAA;EACA,QAAA;AAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
encEmail: EmailEncrypted;
|
|
19
|
+
};
|
|
20
|
+
type HybridEncryptedEmailAndSubject = {
|
|
21
|
+
encryptedKey: HybridEncKey;
|
|
22
|
+
encEmail: EmailAndSubjectEncrypted;
|
|
23
|
+
};
|
|
24
|
+
type PwdProtectedEmail = {
|
|
25
|
+
encryptedKey: PwdProtectedKey;
|
|
26
|
+
encEmail: EmailEncrypted;
|
|
27
|
+
};
|
|
28
|
+
type PwdProtectedEmailAndSubject = {
|
|
29
|
+
encryptedKey: PwdProtectedKey;
|
|
30
|
+
encEmail: EmailAndSubjectEncrypted;
|
|
31
|
+
};
|
|
32
|
+
type HybridEncKey = {
|
|
33
|
+
hybridCiphertext: string;
|
|
34
|
+
encryptedKey: string;
|
|
35
|
+
encryptedForEmail: string;
|
|
36
|
+
};
|
|
37
|
+
type PwdProtectedKey = {
|
|
38
|
+
encryptedKey: string;
|
|
39
|
+
salt: string;
|
|
40
|
+
};
|
|
41
|
+
type EmailEncrypted = {
|
|
42
|
+
encText: string;
|
|
43
|
+
encAttachments?: string[];
|
|
44
|
+
};
|
|
45
|
+
type EmailAndSubjectEncrypted = EmailEncrypted & {
|
|
46
|
+
encSubject: string;
|
|
47
|
+
};
|
|
48
|
+
type Email = {
|
|
49
|
+
text: string;
|
|
50
|
+
attachments?: string[];
|
|
51
|
+
};
|
|
52
|
+
type EmailAndSubject = Email & {
|
|
53
|
+
subject: string;
|
|
54
|
+
};
|
|
55
|
+
declare enum KeystoreType {
|
|
56
|
+
ENCRYPTION = "Encryption",
|
|
57
|
+
RECOVERY = "Recovery"
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { EncryptedKeystore as a, HybridEncryptedEmailAndSubject as c, PwdProtectedEmail as d, PwdProtectedEmailAndSubject as f, EmailEncrypted as i, HybridKeyPair as l, RecipientWithPublicKey as m, EmailAndSubject as n, HybridEncKey as o, PwdProtectedKey as p, EmailAndSubjectEncrypted as r, HybridEncryptedEmail as s, Email as t, KeystoreType as u };
|
|
61
|
+
//# sourceMappingURL=types-D6hsUfma.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-D6hsUfma.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,QAAA,EAAU,cAAA;AAAA;AAAA,KAGA,8BAAA;EACV,YAAA,EAAc,YAAA;EACd,QAAA,EAAU,wBAAA;AAAA;AAAA,KAGA,iBAAA;EACV,YAAA,EAAc,eAAA;EACd,QAAA,EAAU,cAAA;AAAA;AAAA,KAGA,2BAAA;EACV,YAAA,EAAc,eAAA;EACd,QAAA,EAAU,wBAAA;AAAA;AAAA,KAGA,YAAA;EACV,gBAAA;EACA,YAAA;EACA,iBAAA;AAAA;AAAA,KAGU,eAAA;EACV,YAAA;EACA,IAAA;AAAA;AAAA,KAGU,cAAA;EACV,OAAA;EACA,cAAA;AAAA;AAAA,KAGU,wBAAA,GAA2B,cAAA;EACrC,UAAA;AAAA;AAAA,KAGU,KAAA;EACV,IAAA;EACA,WAAA;AAAA;AAAA,KAGU,eAAA,GAAkB,KAAA;EAC5B,OAAA;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 EncryptedKeystore, c as HybridEncryptedEmailAndSubject, d as PwdProtectedEmail, f as PwdProtectedEmailAndSubject, i as EmailEncrypted, l as HybridKeyPair, m as RecipientWithPublicKey, n as EmailAndSubject, o as HybridEncKey, p as PwdProtectedKey, r as EmailAndSubjectEncrypted, s as HybridEncryptedEmail, t as Email, u as KeystoreType } from "./types-D6hsUfma.mjs";
|
|
2
|
+
export { Email, EmailAndSubject, EmailAndSubjectEncrypted, EmailEncrypted, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, HybridEncryptedEmailAndSubject, HybridKeyPair, KeystoreType, PwdProtectedEmail, PwdProtectedEmailAndSubject, 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 EncryptedKeystore, c as HybridEncryptedEmailAndSubject, d as PwdProtectedEmail, f as PwdProtectedEmailAndSubject, i as EmailEncrypted, l as HybridKeyPair, m as RecipientWithPublicKey, n as EmailAndSubject, o as HybridEncKey, p as PwdProtectedKey, r as EmailAndSubjectEncrypted, s as HybridEncryptedEmail, t as Email, u as KeystoreType } from "./types-CrAiKyb0.js";
|
|
2
|
+
export { Email, EmailAndSubject, EmailAndSubjectEncrypted, EmailEncrypted, EncryptedKeystore, HybridEncKey, HybridEncryptedEmail, HybridEncryptedEmailAndSubject, HybridKeyPair, KeystoreType, PwdProtectedEmail, PwdProtectedEmailAndSubject, 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
|
|
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 encEmail: EmailEncrypted;\n};\n\nexport type HybridEncryptedEmailAndSubject = {\n encryptedKey: HybridEncKey;\n encEmail: EmailAndSubjectEncrypted;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n encEmail: EmailEncrypted;\n};\n\nexport type PwdProtectedEmailAndSubject = {\n encryptedKey: PwdProtectedKey;\n encEmail: EmailAndSubjectEncrypted;\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 EmailEncrypted = {\n encText: string;\n encAttachments?: string[];\n};\n\nexport type EmailAndSubjectEncrypted = EmailEncrypted & {\n encSubject: string;\n};\n\nexport type Email = {\n text: string;\n attachments?: string[];\n};\n\nexport type EmailAndSubject = Email & {\n subject: string;\n};\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":";;AAkEA,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
|
|
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 encEmail: EmailEncrypted;\n};\n\nexport type HybridEncryptedEmailAndSubject = {\n encryptedKey: HybridEncKey;\n encEmail: EmailAndSubjectEncrypted;\n};\n\nexport type PwdProtectedEmail = {\n encryptedKey: PwdProtectedKey;\n encEmail: EmailEncrypted;\n};\n\nexport type PwdProtectedEmailAndSubject = {\n encryptedKey: PwdProtectedKey;\n encEmail: EmailAndSubjectEncrypted;\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 EmailEncrypted = {\n encText: string;\n encAttachments?: string[];\n};\n\nexport type EmailAndSubjectEncrypted = EmailEncrypted & {\n encSubject: string;\n};\n\nexport type Email = {\n text: string;\n attachments?: string[];\n};\n\nexport type EmailAndSubject = Email & {\n subject: string;\n};\n\nexport enum KeystoreType {\n ENCRYPTION = 'Encryption',\n RECOVERY = 'Recovery',\n}\n"],"mappings":";AAkEA,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["uuidv4"],"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,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;;;;;;;;;AC3DrC,SAAgB,cAAsB;AACpC,QAAO,MAAM,iBAAiB,UAAA,IAAkC;;;;;;;;AASlE,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"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
require("./chunk-C13QxCFV.js");
|
|
2
2
|
let _noble_post_quantum_hybrid_js = require("@noble/post-quantum/hybrid.js");
|
|
3
|
-
|
|
4
3
|
//#region src/hybrid-crypto/xwing.ts
|
|
5
4
|
function genHybridKeys(seed) {
|
|
6
5
|
return _noble_post_quantum_hybrid_js.ml_kem768_x25519.keygen(seed);
|
|
@@ -11,24 +10,24 @@ function encapsulateHybrid(publicKey) {
|
|
|
11
10
|
function decapsulateHybrid(cipherText, secretKey) {
|
|
12
11
|
return _noble_post_quantum_hybrid_js.ml_kem768_x25519.decapsulate(cipherText, secretKey);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
//#endregion
|
|
16
|
-
Object.defineProperty(exports,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
Object.defineProperty(exports, "decapsulateHybrid", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function() {
|
|
17
|
+
return decapsulateHybrid;
|
|
18
|
+
}
|
|
21
19
|
});
|
|
22
|
-
Object.defineProperty(exports,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
Object.defineProperty(exports, "encapsulateHybrid", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return encapsulateHybrid;
|
|
24
|
+
}
|
|
27
25
|
});
|
|
28
|
-
Object.defineProperty(exports,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
Object.defineProperty(exports, "genHybridKeys", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
return genHybridKeys;
|
|
30
|
+
}
|
|
33
31
|
});
|
|
34
|
-
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=xwing-7fEqAT7W.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xwing-
|
|
1
|
+
{"version":3,"file":"xwing-7fEqAT7W.js","names":["hybridCipher"],"sources":["../src/hybrid-crypto/xwing.ts"],"sourcesContent":["import { ml_kem768_x25519 as hybridCipher } from '@noble/post-quantum/hybrid.js';\nimport { HybridKeyPair } from '../types';\n\nexport function genHybridKeys(seed?: Uint8Array): HybridKeyPair {\n return hybridCipher.keygen(seed);\n}\n\nexport function encapsulateHybrid(publicKey: Uint8Array): { cipherText: Uint8Array; sharedSecret: Uint8Array } {\n return hybridCipher.encapsulate(publicKey);\n}\n\nexport function decapsulateHybrid(cipherText: Uint8Array, secretKey: Uint8Array): Uint8Array {\n return hybridCipher.decapsulate(cipherText, secretKey);\n}\n"],"mappings":";;;AAGA,SAAgB,cAAc,MAAkC;AAC9D,QAAOA,8BAAAA,iBAAa,OAAO,KAAK;;AAGlC,SAAgB,kBAAkB,WAA6E;AAC7G,QAAOA,8BAAAA,iBAAa,YAAY,UAAU;;AAG5C,SAAgB,kBAAkB,YAAwB,WAAmC;AAC3F,QAAOA,8BAAAA,iBAAa,YAAY,YAAY,UAAU"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ml_kem768_x25519 } from "@noble/post-quantum/hybrid.js";
|
|
2
|
-
|
|
3
2
|
//#region src/hybrid-crypto/xwing.ts
|
|
4
3
|
function genHybridKeys(seed) {
|
|
5
4
|
return ml_kem768_x25519.keygen(seed);
|
|
@@ -10,7 +9,7 @@ function encapsulateHybrid(publicKey) {
|
|
|
10
9
|
function decapsulateHybrid(cipherText, secretKey) {
|
|
11
10
|
return ml_kem768_x25519.decapsulate(cipherText, secretKey);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
13
|
export { encapsulateHybrid as n, genHybridKeys as r, decapsulateHybrid as t };
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=xwing-B34h5e3Z.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xwing-
|
|
1
|
+
{"version":3,"file":"xwing-B34h5e3Z.mjs","names":["hybridCipher"],"sources":["../src/hybrid-crypto/xwing.ts"],"sourcesContent":["import { ml_kem768_x25519 as hybridCipher } from '@noble/post-quantum/hybrid.js';\nimport { HybridKeyPair } from '../types';\n\nexport function genHybridKeys(seed?: Uint8Array): HybridKeyPair {\n return hybridCipher.keygen(seed);\n}\n\nexport function encapsulateHybrid(publicKey: Uint8Array): { cipherText: Uint8Array; sharedSecret: Uint8Array } {\n return hybridCipher.encapsulate(publicKey);\n}\n\nexport function decapsulateHybrid(cipherText: Uint8Array, secretKey: Uint8Array): Uint8Array {\n return hybridCipher.decapsulate(cipherText, secretKey);\n}\n"],"mappings":";;AAGA,SAAgB,cAAc,MAAkC;AAC9D,QAAOA,iBAAa,OAAO,KAAK;;AAGlC,SAAgB,kBAAkB,WAA6E;AAC7G,QAAOA,iBAAa,YAAY,UAAU;;AAG5C,SAAgB,kBAAkB,YAAwB,WAAmC;AAC3F,QAAOA,iBAAa,YAAY,YAAY,UAAU"}
|