internxt-crypto 0.0.10-alpha → 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.
Files changed (158) hide show
  1. package/README.md +3 -4
  2. package/dist/aes-DSDxP8uF.mjs +184 -0
  3. package/dist/aes-DSDxP8uF.mjs.map +1 -0
  4. package/dist/aes-bOrKZuUC.js +226 -0
  5. package/dist/aes-bOrKZuUC.js.map +1 -0
  6. package/dist/asymmetric-crypto.d.mts +5 -2
  7. package/dist/asymmetric-crypto.d.mts.map +1 -0
  8. package/dist/asymmetric-crypto.d.ts +5 -2
  9. package/dist/asymmetric-crypto.d.ts.map +1 -0
  10. package/dist/asymmetric-crypto.js +9 -92
  11. package/dist/asymmetric-crypto.mjs +2 -84
  12. package/dist/chunk-DQk6qfdC.mjs +18 -0
  13. package/dist/chunk-EbLFQX5m.js +60 -0
  14. package/dist/constants.d.mts +5 -11
  15. package/dist/constants.d.mts.map +1 -0
  16. package/dist/constants.d.ts +5 -11
  17. package/dist/constants.d.ts.map +1 -0
  18. package/dist/constants.js +33 -49
  19. package/dist/constants.js.map +1 -1
  20. package/dist/constants.mjs +32 -40
  21. package/dist/constants.mjs.map +1 -1
  22. package/dist/derive-key.d.mts +11 -8
  23. package/dist/derive-key.d.mts.map +1 -0
  24. package/dist/derive-key.d.ts +11 -8
  25. package/dist/derive-key.d.ts.map +1 -0
  26. package/dist/derive-key.js +13 -795
  27. package/dist/derive-key.mjs +2 -783
  28. package/dist/deriveKeysFromPassword-DJRWZ8Rw.mjs +735 -0
  29. package/dist/deriveKeysFromPassword-DJRWZ8Rw.mjs.map +1 -0
  30. package/dist/deriveKeysFromPassword-Ko7NxkHM.js +2492 -0
  31. package/dist/deriveKeysFromPassword-Ko7NxkHM.js.map +1 -0
  32. package/dist/email-crypto.d.mts +55 -78
  33. package/dist/email-crypto.d.mts.map +1 -0
  34. package/dist/email-crypto.d.ts +55 -78
  35. package/dist/email-crypto.d.ts.map +1 -0
  36. package/dist/email-crypto.js +13 -1409
  37. package/dist/email-crypto.mjs +2 -1380
  38. package/dist/email-search.d.mts +36 -32
  39. package/dist/email-search.d.mts.map +1 -0
  40. package/dist/email-search.d.ts +36 -32
  41. package/dist/email-search.d.ts.map +1 -0
  42. package/dist/email-search.js +534 -540
  43. package/dist/email-search.js.map +1 -1
  44. package/dist/email-search.mjs +532 -538
  45. package/dist/email-search.mjs.map +1 -1
  46. package/dist/emailEncryptionKey-27mIHh18.mjs +150 -0
  47. package/dist/emailEncryptionKey-27mIHh18.mjs.map +1 -0
  48. package/dist/emailEncryptionKey-DbaDAdoW.js +167 -0
  49. package/dist/emailEncryptionKey-DbaDAdoW.js.map +1 -0
  50. package/dist/emailKeys-BJGdkLrg.js +593 -0
  51. package/dist/emailKeys-BJGdkLrg.js.map +1 -0
  52. package/dist/emailKeys-Fp9WR3wl.mjs +509 -0
  53. package/dist/emailKeys-Fp9WR3wl.mjs.map +1 -0
  54. package/dist/genID-3Er5IowC.mjs +153 -0
  55. package/dist/genID-3Er5IowC.mjs.map +1 -0
  56. package/dist/genID-YJSl3YhL.js +238 -0
  57. package/dist/genID-YJSl3YhL.js.map +1 -0
  58. package/dist/hash.d.mts +18 -15
  59. package/dist/hash.d.mts.map +1 -0
  60. package/dist/hash.d.ts +18 -15
  61. package/dist/hash.d.ts.map +1 -0
  62. package/dist/hash.js +12 -95
  63. package/dist/hash.mjs +2 -84
  64. package/dist/index.d.mts +15 -18
  65. package/dist/index.d.mts.map +1 -0
  66. package/dist/index.d.ts +15 -18
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +125 -2698
  69. package/dist/index.mjs +13 -2538
  70. package/dist/keys-BfcaiAOv.mjs +90 -0
  71. package/dist/keys-BfcaiAOv.mjs.map +1 -0
  72. package/dist/keys-CinT7kEY.js +125 -0
  73. package/dist/keys-CinT7kEY.js.map +1 -0
  74. package/dist/keystore-crypto.d.mts +17 -46
  75. package/dist/keystore-crypto.d.mts.map +1 -0
  76. package/dist/keystore-crypto.d.ts +17 -46
  77. package/dist/keystore-crypto.d.ts.map +1 -0
  78. package/dist/keystore-crypto.js +5 -529
  79. package/dist/keystore-crypto.mjs +2 -500
  80. package/dist/kyber1024-PpwE1rki.mjs +144 -0
  81. package/dist/kyber1024-PpwE1rki.mjs.map +1 -0
  82. package/dist/kyber1024-jeKS8CXf.js +173 -0
  83. package/dist/kyber1024-jeKS8CXf.js.map +1 -0
  84. package/dist/{kyber768-B87rMQ7u.d.mts → kyber768-DGBB_RS7.d.ts} +8 -6
  85. package/dist/kyber768-DGBB_RS7.d.ts.map +1 -0
  86. package/dist/{kyber768-B87rMQ7u.d.ts → kyber768-DzIcGg1i.d.mts} +8 -6
  87. package/dist/kyber768-DzIcGg1i.d.mts.map +1 -0
  88. package/dist/mac-BMb1F0dN.js +170 -0
  89. package/dist/mac-BMb1F0dN.js.map +1 -0
  90. package/dist/mac-ZpRlx8Fs.mjs +116 -0
  91. package/dist/mac-ZpRlx8Fs.mjs.map +1 -0
  92. package/dist/post-quantum-crypto.d.mts +23 -27
  93. package/dist/post-quantum-crypto.d.mts.map +1 -0
  94. package/dist/post-quantum-crypto.d.ts +23 -27
  95. package/dist/post-quantum-crypto.d.ts.map +1 -0
  96. package/dist/post-quantum-crypto.js +14 -92
  97. package/dist/post-quantum-crypto.mjs +2 -89
  98. package/dist/storage-service.d.mts +28 -34
  99. package/dist/storage-service.d.mts.map +1 -0
  100. package/dist/storage-service.d.ts +28 -34
  101. package/dist/storage-service.d.ts.map +1 -0
  102. package/dist/storage-service.js +51 -53
  103. package/dist/storage-service.js.map +1 -1
  104. package/dist/storage-service.mjs +40 -51
  105. package/dist/storage-service.mjs.map +1 -1
  106. package/dist/symmetric-crypto.d.mts +8 -7
  107. package/dist/symmetric-crypto.d.mts.map +1 -0
  108. package/dist/symmetric-crypto.d.ts +8 -7
  109. package/dist/symmetric-crypto.d.ts.map +1 -0
  110. package/dist/symmetric-crypto.js +10 -142
  111. package/dist/symmetric-crypto.mjs +2 -133
  112. package/dist/types.d.mts +71 -69
  113. package/dist/types.d.mts.map +1 -0
  114. package/dist/types.d.ts +71 -69
  115. package/dist/types.d.ts.map +1 -0
  116. package/dist/types.js +8 -10
  117. package/dist/types.js.map +1 -1
  118. package/dist/types.mjs +7 -9
  119. package/dist/types.mjs.map +1 -1
  120. package/dist/utils.d.mts +34 -78
  121. package/dist/utils.d.mts.map +1 -0
  122. package/dist/utils.d.ts +34 -78
  123. package/dist/utils.d.ts.map +1 -0
  124. package/dist/utils.js +17 -313
  125. package/dist/utils.mjs +2 -272
  126. package/package.json +21 -87
  127. package/dist/asymmetric-crypto.js.map +0 -1
  128. package/dist/asymmetric-crypto.mjs.map +0 -1
  129. package/dist/derive-key.js.map +0 -1
  130. package/dist/derive-key.mjs.map +0 -1
  131. package/dist/email-crypto.js.map +0 -1
  132. package/dist/email-crypto.mjs.map +0 -1
  133. package/dist/email-service.d.mts +0 -38
  134. package/dist/email-service.d.ts +0 -38
  135. package/dist/email-service.js +0 -154
  136. package/dist/email-service.js.map +0 -1
  137. package/dist/email-service.mjs +0 -147
  138. package/dist/email-service.mjs.map +0 -1
  139. package/dist/hash.js.map +0 -1
  140. package/dist/hash.mjs.map +0 -1
  141. package/dist/index.js.map +0 -1
  142. package/dist/index.mjs.map +0 -1
  143. package/dist/keystore-crypto.js.map +0 -1
  144. package/dist/keystore-crypto.mjs.map +0 -1
  145. package/dist/keystore-service.d.mts +0 -82
  146. package/dist/keystore-service.d.ts +0 -82
  147. package/dist/keystore-service.js +0 -349
  148. package/dist/keystore-service.js.map +0 -1
  149. package/dist/keystore-service.mjs +0 -342
  150. package/dist/keystore-service.mjs.map +0 -1
  151. package/dist/post-quantum-crypto.js.map +0 -1
  152. package/dist/post-quantum-crypto.mjs.map +0 -1
  153. package/dist/symmetric-crypto.js.map +0 -1
  154. package/dist/symmetric-crypto.mjs.map +0 -1
  155. package/dist/utils-BDaK_d6T.d.ts +0 -114
  156. package/dist/utils-v34IRTIx.d.mts +0 -114
  157. package/dist/utils.js.map +0 -1
  158. package/dist/utils.mjs.map +0 -1
@@ -0,0 +1,153 @@
1
+ import { AES_KEY_BIT_LENGTH } from "./constants.mjs";
2
+ import { a as importPublicKey, n as exportPublicKey } from "./keys-BfcaiAOv.mjs";
3
+ import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
4
+ import * as bip39 from "@scure/bip39";
5
+ import { wordlist } from "@scure/bip39/wordlists/english.js";
6
+ import { parse, stringify, v4 } from "uuid";
7
+
8
+ //#region src/utils/converters.ts
9
+ /**
10
+ * Converts a Uint8Array into a hexadecimal string.
11
+ *
12
+ * @param array - The Uint8Array to convert.
13
+ * @returns The hexadecimal string representation of the array.
14
+ */
15
+ function uint8ArrayToHex(array) {
16
+ return bytesToHex(array);
17
+ }
18
+ /**
19
+ * Converts a UTF-8 string into a Uint8Array.
20
+ *
21
+ * @param str - The UTF-8 string to convert.
22
+ * @returns A Uint8Array created from the UTF-8 string.
23
+ */
24
+ function UTF8ToUint8(str) {
25
+ return new TextEncoder().encode(str);
26
+ }
27
+ /**
28
+ * Converts an Uint8Array into a UTF-8 string.
29
+ *
30
+ * @param array - The Uint8Array to convert.
31
+ * @returns The UTF-8 string representation of the array.
32
+ */
33
+ function uint8ToUTF8(array) {
34
+ return new TextDecoder().decode(array);
35
+ }
36
+ /**
37
+ * Converts a hexadecimal string into a Uint8Array.
38
+ *
39
+ * @param hex - The hexadecimal string to convert.
40
+ * @returns A Uint8Array created from the hex string.
41
+ */
42
+ function hexToUint8Array(hex) {
43
+ return hexToBytes(hex);
44
+ }
45
+ /**
46
+ * Converts a Uint8Array into a base64 string.
47
+ *
48
+ * @param array - The Uint8Array to convert.
49
+ * @returns The base64 string representation of the array.
50
+ */
51
+ function uint8ArrayToBase64(buffer) {
52
+ const array = Uint16Array.from(buffer);
53
+ const binaryString = new TextDecoder("UTF-16").decode(array);
54
+ return btoa(binaryString);
55
+ }
56
+ /**
57
+ * Converts a base64 string into a Uint8Array.
58
+ *
59
+ * @param str - The base64 string to convert.
60
+ * @returns A Uint8Array created from the base64 string.
61
+ */
62
+ function base64ToUint8Array(str) {
63
+ const binaryString = atob(str);
64
+ const len = binaryString.length;
65
+ const array = new Uint8Array(len);
66
+ for (let i = 0; i < len; i++) array[i] = binaryString.codePointAt(i);
67
+ return new Uint8Array(array.buffer);
68
+ }
69
+
70
+ //#endregion
71
+ //#region src/utils/keyConverters.ts
72
+ /**
73
+ * Converts a base64 string into PublicKeys type.
74
+ *
75
+ * @param base64 - The base64 representation of the public key.
76
+ * @returns The resulting PublicKeys.
77
+ */
78
+ async function base64ToPublicKey(base64) {
79
+ try {
80
+ return {
81
+ eccPublicKey: await importPublicKey(base64ToUint8Array(base64.eccPublicKeyBase64)),
82
+ kyberPublicKey: base64ToUint8Array(base64.kyberPublicKeyBase64)
83
+ };
84
+ } catch (error) {
85
+ throw new Error("Failed to convert base64 to PublicKeys", { cause: error });
86
+ }
87
+ }
88
+ /**
89
+ * Converts a PublicKeys type into PublicKeysBase64.
90
+ *
91
+ * @param key - The PublicKeys key.
92
+ * @returns The resulting PublicKeysBase64.
93
+ */
94
+ async function publicKeyToBase64(key) {
95
+ try {
96
+ return {
97
+ eccPublicKeyBase64: uint8ArrayToBase64(await exportPublicKey(key.eccPublicKey)),
98
+ kyberPublicKeyBase64: uint8ArrayToBase64(key.kyberPublicKey)
99
+ };
100
+ } catch (error) {
101
+ throw new Error("Failed to convert key of the type PublicKeys to PublicKeysBase64", { cause: error });
102
+ }
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/utils/genMnemonic.ts
107
+ /**
108
+ * Generates a mnemonic
109
+ *
110
+ * @returns The generated mnemonic.
111
+ */
112
+ function genMnemonic() {
113
+ return bip39.generateMnemonic(wordlist, AES_KEY_BIT_LENGTH);
114
+ }
115
+ /**
116
+ * Converts a mnemonic to Uint8Array
117
+ *
118
+ * @param mnemonic - The mnemonic to convert
119
+ * @returns The mnemonic as Uint8Array
120
+ */
121
+ function mnemonicToBytes(mnemonic) {
122
+ return bip39.mnemonicToEntropy(mnemonic, wordlist);
123
+ }
124
+ /**
125
+ * Converts a Uint8Array to a mnemonic
126
+ *
127
+ * @param bytes - The bytes to convert
128
+ * @returns The mnemonic string
129
+ */
130
+ function bytesToMnemonic(bytes) {
131
+ return bip39.entropyToMnemonic(bytes, wordlist);
132
+ }
133
+
134
+ //#endregion
135
+ //#region src/utils/genID.ts
136
+ /**
137
+ * Creates a random identifier.
138
+ *
139
+ * @returns The resulting auxilary string
140
+ */
141
+ function generateUuid() {
142
+ return v4();
143
+ }
144
+ function uuidToBytes(uuid) {
145
+ return parse(uuid);
146
+ }
147
+ function bytesToUuid(bytes) {
148
+ return stringify(bytes);
149
+ }
150
+
151
+ //#endregion
152
+ export { genMnemonic as a, publicKeyToBase64 as c, hexToUint8Array as d, uint8ArrayToBase64 as f, bytesToMnemonic as i, UTF8ToUint8 as l, uint8ToUTF8 as m, generateUuid as n, mnemonicToBytes as o, uint8ArrayToHex as p, uuidToBytes as r, base64ToPublicKey as s, bytesToUuid as t, base64ToUint8Array as u };
153
+ //# sourceMappingURL=genID-3Er5IowC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genID-3Er5IowC.mjs","names":["uuidv4"],"sources":["../src/utils/converters.ts","../src/utils/keyConverters.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 { 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"],"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"}
@@ -0,0 +1,238 @@
1
+ const require_chunk = require('./chunk-EbLFQX5m.js');
2
+ const require_constants = require('./constants.js');
3
+ const require_keys = require('./keys-CinT7kEY.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
+
10
+ //#region src/utils/converters.ts
11
+ /**
12
+ * Converts a Uint8Array into a hexadecimal string.
13
+ *
14
+ * @param array - The Uint8Array to convert.
15
+ * @returns The hexadecimal string representation of the array.
16
+ */
17
+ function uint8ArrayToHex(array) {
18
+ return (0, _noble_hashes_utils_js.bytesToHex)(array);
19
+ }
20
+ /**
21
+ * Converts a UTF-8 string into a Uint8Array.
22
+ *
23
+ * @param str - The UTF-8 string to convert.
24
+ * @returns A Uint8Array created from the UTF-8 string.
25
+ */
26
+ function UTF8ToUint8(str) {
27
+ return new TextEncoder().encode(str);
28
+ }
29
+ /**
30
+ * Converts an Uint8Array into a UTF-8 string.
31
+ *
32
+ * @param array - The Uint8Array to convert.
33
+ * @returns The UTF-8 string representation of the array.
34
+ */
35
+ function uint8ToUTF8(array) {
36
+ return new TextDecoder().decode(array);
37
+ }
38
+ /**
39
+ * Converts a hexadecimal string into a Uint8Array.
40
+ *
41
+ * @param hex - The hexadecimal string to convert.
42
+ * @returns A Uint8Array created from the hex string.
43
+ */
44
+ function hexToUint8Array(hex) {
45
+ return (0, _noble_hashes_utils_js.hexToBytes)(hex);
46
+ }
47
+ /**
48
+ * Converts a Uint8Array into a base64 string.
49
+ *
50
+ * @param array - The Uint8Array to convert.
51
+ * @returns The base64 string representation of the array.
52
+ */
53
+ function uint8ArrayToBase64(buffer) {
54
+ const array = Uint16Array.from(buffer);
55
+ const binaryString = new TextDecoder("UTF-16").decode(array);
56
+ return btoa(binaryString);
57
+ }
58
+ /**
59
+ * Converts a base64 string into a Uint8Array.
60
+ *
61
+ * @param str - The base64 string to convert.
62
+ * @returns A Uint8Array created from the base64 string.
63
+ */
64
+ function base64ToUint8Array(str) {
65
+ const binaryString = atob(str);
66
+ const len = binaryString.length;
67
+ const array = new Uint8Array(len);
68
+ for (let i = 0; i < len; i++) array[i] = binaryString.codePointAt(i);
69
+ return new Uint8Array(array.buffer);
70
+ }
71
+
72
+ //#endregion
73
+ //#region src/utils/keyConverters.ts
74
+ /**
75
+ * Converts a base64 string into PublicKeys type.
76
+ *
77
+ * @param base64 - The base64 representation of the public key.
78
+ * @returns The resulting PublicKeys.
79
+ */
80
+ async function base64ToPublicKey(base64) {
81
+ try {
82
+ return {
83
+ eccPublicKey: await require_keys.importPublicKey(base64ToUint8Array(base64.eccPublicKeyBase64)),
84
+ kyberPublicKey: base64ToUint8Array(base64.kyberPublicKeyBase64)
85
+ };
86
+ } catch (error) {
87
+ throw new Error("Failed to convert base64 to PublicKeys", { cause: error });
88
+ }
89
+ }
90
+ /**
91
+ * Converts a PublicKeys type into PublicKeysBase64.
92
+ *
93
+ * @param key - The PublicKeys key.
94
+ * @returns The resulting PublicKeysBase64.
95
+ */
96
+ async function publicKeyToBase64(key) {
97
+ try {
98
+ return {
99
+ eccPublicKeyBase64: uint8ArrayToBase64(await require_keys.exportPublicKey(key.eccPublicKey)),
100
+ kyberPublicKeyBase64: uint8ArrayToBase64(key.kyberPublicKey)
101
+ };
102
+ } catch (error) {
103
+ throw new Error("Failed to convert key of the type PublicKeys to PublicKeysBase64", { cause: error });
104
+ }
105
+ }
106
+
107
+ //#endregion
108
+ //#region src/utils/genMnemonic.ts
109
+ /**
110
+ * Generates a mnemonic
111
+ *
112
+ * @returns The generated mnemonic.
113
+ */
114
+ function genMnemonic() {
115
+ return _scure_bip39.generateMnemonic(_scure_bip39_wordlists_english_js.wordlist, require_constants.AES_KEY_BIT_LENGTH);
116
+ }
117
+ /**
118
+ * Converts a mnemonic to Uint8Array
119
+ *
120
+ * @param mnemonic - The mnemonic to convert
121
+ * @returns The mnemonic as Uint8Array
122
+ */
123
+ function mnemonicToBytes(mnemonic) {
124
+ return _scure_bip39.mnemonicToEntropy(mnemonic, _scure_bip39_wordlists_english_js.wordlist);
125
+ }
126
+ /**
127
+ * Converts a Uint8Array to a mnemonic
128
+ *
129
+ * @param bytes - The bytes to convert
130
+ * @returns The mnemonic string
131
+ */
132
+ function bytesToMnemonic(bytes) {
133
+ return _scure_bip39.entropyToMnemonic(bytes, _scure_bip39_wordlists_english_js.wordlist);
134
+ }
135
+
136
+ //#endregion
137
+ //#region src/utils/genID.ts
138
+ /**
139
+ * Creates a random identifier.
140
+ *
141
+ * @returns The resulting auxilary string
142
+ */
143
+ function generateUuid() {
144
+ return (0, uuid.v4)();
145
+ }
146
+ function uuidToBytes(uuid$1) {
147
+ return (0, uuid.parse)(uuid$1);
148
+ }
149
+ function bytesToUuid(bytes) {
150
+ return (0, uuid.stringify)(bytes);
151
+ }
152
+
153
+ //#endregion
154
+ Object.defineProperty(exports, 'UTF8ToUint8', {
155
+ enumerable: true,
156
+ get: function () {
157
+ return UTF8ToUint8;
158
+ }
159
+ });
160
+ Object.defineProperty(exports, 'base64ToPublicKey', {
161
+ enumerable: true,
162
+ get: function () {
163
+ return base64ToPublicKey;
164
+ }
165
+ });
166
+ Object.defineProperty(exports, 'base64ToUint8Array', {
167
+ enumerable: true,
168
+ get: function () {
169
+ return base64ToUint8Array;
170
+ }
171
+ });
172
+ Object.defineProperty(exports, 'bytesToMnemonic', {
173
+ enumerable: true,
174
+ get: function () {
175
+ return bytesToMnemonic;
176
+ }
177
+ });
178
+ Object.defineProperty(exports, 'bytesToUuid', {
179
+ enumerable: true,
180
+ get: function () {
181
+ return bytesToUuid;
182
+ }
183
+ });
184
+ Object.defineProperty(exports, 'genMnemonic', {
185
+ enumerable: true,
186
+ get: function () {
187
+ return genMnemonic;
188
+ }
189
+ });
190
+ Object.defineProperty(exports, 'generateUuid', {
191
+ enumerable: true,
192
+ get: function () {
193
+ return generateUuid;
194
+ }
195
+ });
196
+ Object.defineProperty(exports, 'hexToUint8Array', {
197
+ enumerable: true,
198
+ get: function () {
199
+ return hexToUint8Array;
200
+ }
201
+ });
202
+ Object.defineProperty(exports, 'mnemonicToBytes', {
203
+ enumerable: true,
204
+ get: function () {
205
+ return mnemonicToBytes;
206
+ }
207
+ });
208
+ Object.defineProperty(exports, 'publicKeyToBase64', {
209
+ enumerable: true,
210
+ get: function () {
211
+ return publicKeyToBase64;
212
+ }
213
+ });
214
+ Object.defineProperty(exports, 'uint8ArrayToBase64', {
215
+ enumerable: true,
216
+ get: function () {
217
+ return uint8ArrayToBase64;
218
+ }
219
+ });
220
+ Object.defineProperty(exports, 'uint8ArrayToHex', {
221
+ enumerable: true,
222
+ get: function () {
223
+ return uint8ArrayToHex;
224
+ }
225
+ });
226
+ Object.defineProperty(exports, 'uint8ToUTF8', {
227
+ enumerable: true,
228
+ get: function () {
229
+ return uint8ToUTF8;
230
+ }
231
+ });
232
+ Object.defineProperty(exports, 'uuidToBytes', {
233
+ enumerable: true,
234
+ get: function () {
235
+ return uuidToBytes;
236
+ }
237
+ });
238
+ //# sourceMappingURL=genID-YJSl3YhL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genID-YJSl3YhL.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"],"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"],"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,6BADD,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,6BAAgB,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"}
package/dist/hash.d.mts CHANGED
@@ -1,19 +1,20 @@
1
+ //#region src/hash/blake3.d.ts
1
2
  /**
2
3
  * Hashes the given array of data
3
4
  *
4
5
  * @param data - The data to hash
5
6
  * @returns The resulting hash array
6
7
  */
7
- declare function hashData(data: Uint8Array[]): Uint8Array;
8
- declare function keyedHashHex(hashKey: Uint8Array, data: Uint8Array[]): string;
9
- declare function keyedHash(hashKey: Uint8Array, data: Uint8Array[]): Uint8Array;
8
+ declare function hashDataArray(data: Uint8Array[]): Uint8Array;
10
9
  /**
11
10
  * Hashes the given array of data
12
11
  *
13
12
  * @param data - The data to hash
14
13
  * @returns The resulting hash hex string
15
14
  */
16
- declare function hashDataHex(data: Uint8Array[]): string;
15
+ declare function hashDataArrayHex(data: Uint8Array[]): string;
16
+ declare function hashDataArrayWithKeyHex(hashKey: Uint8Array, data: Uint8Array[]): string;
17
+ declare function hashDataArrayWithKey(hashKey: Uint8Array, data: Uint8Array[]): Uint8Array;
17
18
  /**
18
19
  * Hashes the given array of data using blake3 algorithm
19
20
  *
@@ -21,7 +22,7 @@ declare function hashDataHex(data: Uint8Array[]): string;
21
22
  * @param data - The data to hash
22
23
  * @returns The resulting hash value
23
24
  */
24
- declare function getBytesFromData(bytes: number, data: Uint8Array[]): Uint8Array;
25
+ declare function getBytesFromDataArray(bytes: number, data: Uint8Array[]): Uint8Array;
25
26
  /**
26
27
  * Hashes the given array of data using blake3 algorithm
27
28
  *
@@ -29,24 +30,25 @@ declare function getBytesFromData(bytes: number, data: Uint8Array[]): Uint8Array
29
30
  * @param data - The data to hash
30
31
  * @returns The resulting hash value
31
32
  */
32
- declare function getBytesFromDataHex(bytes: number, data: Uint8Array[]): string;
33
+ declare function getBytesFromDataArrayHex(bytes: number, data: Uint8Array[]): string;
33
34
  /**
34
35
  * Hashes the given string using blake3 algorithm
35
36
  *
36
37
  * @param bytes - The desired output byte-length
37
- * @param value - The string to hash
38
+ * @param data - The data to hash
38
39
  * @returns The resulting hash value
39
40
  */
40
- declare function getBytesFromString(bytes: number, value: string): Uint8Array;
41
+ declare function getBytesFromData(bytes: number, data: Uint8Array): Uint8Array;
41
42
  /**
42
- * Hashes the given string using blake3 algorithm
43
+ * Hashes the given data using blake3 algorithm
43
44
  *
44
45
  * @param bytes - The desired output byte-length
45
- * @param value - The string to hash
46
+ * @param data - The data to hash
46
47
  * @returns The resulting hash value
47
48
  */
48
- declare function getBytesFromStrinHex(bytes: number, value: string): string;
49
-
49
+ declare function getBytesFromDataHex(bytes: number, data: Uint8Array): string;
50
+ //#endregion
51
+ //#region src/hash/mac.d.ts
50
52
  /**
51
53
  * Computes mac for the given key material and data
52
54
  *
@@ -54,6 +56,7 @@ declare function getBytesFromStrinHex(bytes: number, value: string): string;
54
56
  * @param data - The data to hash
55
57
  * @returns The resulting hash hex string
56
58
  */
57
- declare function computeMac(keyMaterial: string, data: Uint8Array[]): string;
58
-
59
- export { computeMac, getBytesFromData, getBytesFromDataHex, getBytesFromStrinHex, getBytesFromString, hashData, hashDataHex, keyedHash, keyedHashHex };
59
+ declare function computeMac(keyMaterial: Uint8Array, data: Uint8Array[]): string;
60
+ //#endregion
61
+ export { computeMac, getBytesFromData, getBytesFromDataArray, getBytesFromDataArrayHex, getBytesFromDataHex, hashDataArray, hashDataArrayHex, hashDataArrayWithKey, hashDataArrayWithKeyHex };
62
+ //# sourceMappingURL=hash.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.mts","names":[],"sources":["../src/hash/blake3.ts","../src/hash/mac.ts"],"mappings":";;AASA;;;;;iBAAgB,aAAA,CAAc,IAAA,EAAM,UAAA,KAAe,UAAA;;;;AAkBnD;;;iBAAgB,gBAAA,CAAiB,IAAA,EAAM,UAAA;AAAA,iBAIvB,uBAAA,CAAwB,OAAA,EAAS,UAAA,EAAY,IAAA,EAAM,UAAA;AAAA,iBASnD,oBAAA,CAAqB,OAAA,EAAS,UAAA,EAAY,IAAA,EAAM,UAAA,KAAe,UAAA;;;;;;;;iBAmB/D,qBAAA,CAAsB,KAAA,UAAe,IAAA,EAAM,UAAA,KAAe,UAAA;;AAnB1E;;;;;;iBAsCgB,wBAAA,CAAyB,KAAA,UAAe,IAAA,EAAM,UAAA;;;;;;;;iBAgB9C,gBAAA,CAAiB,KAAA,UAAe,IAAA,EAAM,UAAA,GAAa,UAAA;AAnCnE;;;;;;;AAAA,iBA8CgB,mBAAA,CAAoB,KAAA,UAAe,IAAA,EAAM,UAAA;;;;AAhGzD;;;;;;iBCEgB,UAAA,CAAW,WAAA,EAAa,UAAA,EAAY,IAAA,EAAM,UAAA"}
package/dist/hash.d.ts CHANGED
@@ -1,19 +1,20 @@
1
+ //#region src/hash/blake3.d.ts
1
2
  /**
2
3
  * Hashes the given array of data
3
4
  *
4
5
  * @param data - The data to hash
5
6
  * @returns The resulting hash array
6
7
  */
7
- declare function hashData(data: Uint8Array[]): Uint8Array;
8
- declare function keyedHashHex(hashKey: Uint8Array, data: Uint8Array[]): string;
9
- declare function keyedHash(hashKey: Uint8Array, data: Uint8Array[]): Uint8Array;
8
+ declare function hashDataArray(data: Uint8Array[]): Uint8Array;
10
9
  /**
11
10
  * Hashes the given array of data
12
11
  *
13
12
  * @param data - The data to hash
14
13
  * @returns The resulting hash hex string
15
14
  */
16
- declare function hashDataHex(data: Uint8Array[]): string;
15
+ declare function hashDataArrayHex(data: Uint8Array[]): string;
16
+ declare function hashDataArrayWithKeyHex(hashKey: Uint8Array, data: Uint8Array[]): string;
17
+ declare function hashDataArrayWithKey(hashKey: Uint8Array, data: Uint8Array[]): Uint8Array;
17
18
  /**
18
19
  * Hashes the given array of data using blake3 algorithm
19
20
  *
@@ -21,7 +22,7 @@ declare function hashDataHex(data: Uint8Array[]): string;
21
22
  * @param data - The data to hash
22
23
  * @returns The resulting hash value
23
24
  */
24
- declare function getBytesFromData(bytes: number, data: Uint8Array[]): Uint8Array;
25
+ declare function getBytesFromDataArray(bytes: number, data: Uint8Array[]): Uint8Array;
25
26
  /**
26
27
  * Hashes the given array of data using blake3 algorithm
27
28
  *
@@ -29,24 +30,25 @@ declare function getBytesFromData(bytes: number, data: Uint8Array[]): Uint8Array
29
30
  * @param data - The data to hash
30
31
  * @returns The resulting hash value
31
32
  */
32
- declare function getBytesFromDataHex(bytes: number, data: Uint8Array[]): string;
33
+ declare function getBytesFromDataArrayHex(bytes: number, data: Uint8Array[]): string;
33
34
  /**
34
35
  * Hashes the given string using blake3 algorithm
35
36
  *
36
37
  * @param bytes - The desired output byte-length
37
- * @param value - The string to hash
38
+ * @param data - The data to hash
38
39
  * @returns The resulting hash value
39
40
  */
40
- declare function getBytesFromString(bytes: number, value: string): Uint8Array;
41
+ declare function getBytesFromData(bytes: number, data: Uint8Array): Uint8Array;
41
42
  /**
42
- * Hashes the given string using blake3 algorithm
43
+ * Hashes the given data using blake3 algorithm
43
44
  *
44
45
  * @param bytes - The desired output byte-length
45
- * @param value - The string to hash
46
+ * @param data - The data to hash
46
47
  * @returns The resulting hash value
47
48
  */
48
- declare function getBytesFromStrinHex(bytes: number, value: string): string;
49
-
49
+ declare function getBytesFromDataHex(bytes: number, data: Uint8Array): string;
50
+ //#endregion
51
+ //#region src/hash/mac.d.ts
50
52
  /**
51
53
  * Computes mac for the given key material and data
52
54
  *
@@ -54,6 +56,7 @@ declare function getBytesFromStrinHex(bytes: number, value: string): string;
54
56
  * @param data - The data to hash
55
57
  * @returns The resulting hash hex string
56
58
  */
57
- declare function computeMac(keyMaterial: string, data: Uint8Array[]): string;
58
-
59
- export { computeMac, getBytesFromData, getBytesFromDataHex, getBytesFromStrinHex, getBytesFromString, hashData, hashDataHex, keyedHash, keyedHashHex };
59
+ declare function computeMac(keyMaterial: Uint8Array, data: Uint8Array[]): string;
60
+ //#endregion
61
+ export { computeMac, getBytesFromData, getBytesFromDataArray, getBytesFromDataArrayHex, getBytesFromDataHex, hashDataArray, hashDataArrayHex, hashDataArrayWithKey, hashDataArrayWithKeyHex };
62
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","names":[],"sources":["../src/hash/blake3.ts","../src/hash/mac.ts"],"mappings":";;AASA;;;;;iBAAgB,aAAA,CAAc,IAAA,EAAM,UAAA,KAAe,UAAA;;;;AAkBnD;;;iBAAgB,gBAAA,CAAiB,IAAA,EAAM,UAAA;AAAA,iBAIvB,uBAAA,CAAwB,OAAA,EAAS,UAAA,EAAY,IAAA,EAAM,UAAA;AAAA,iBASnD,oBAAA,CAAqB,OAAA,EAAS,UAAA,EAAY,IAAA,EAAM,UAAA,KAAe,UAAA;;;;;;;;iBAmB/D,qBAAA,CAAsB,KAAA,UAAe,IAAA,EAAM,UAAA,KAAe,UAAA;;AAnB1E;;;;;;iBAsCgB,wBAAA,CAAyB,KAAA,UAAe,IAAA,EAAM,UAAA;;;;;;;;iBAgB9C,gBAAA,CAAiB,KAAA,UAAe,IAAA,EAAM,UAAA,GAAa,UAAA;AAnCnE;;;;;;;AAAA,iBA8CgB,mBAAA,CAAoB,KAAA,UAAe,IAAA,EAAM,UAAA;;;;AAhGzD;;;;;;iBCEgB,UAAA,CAAW,WAAA,EAAa,UAAA,EAAY,IAAA,EAAM,UAAA"}