internxt-crypto 0.0.13 → 1.0.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.
Files changed (154) hide show
  1. package/README.md +44 -72
  2. package/dist/aes-B8TA-JKq.mjs +49 -0
  3. package/dist/aes-B8TA-JKq.mjs.map +1 -0
  4. package/dist/aes-CuW_SPl-.js +67 -0
  5. package/dist/aes-CuW_SPl-.js.map +1 -0
  6. package/dist/asymmetric-crypto.d.mts +8 -31
  7. package/dist/asymmetric-crypto.d.mts.map +1 -1
  8. package/dist/asymmetric-crypto.d.ts +8 -31
  9. package/dist/asymmetric-crypto.d.ts.map +1 -1
  10. package/dist/asymmetric-crypto.js +30 -7
  11. package/dist/asymmetric-crypto.js.map +1 -0
  12. package/dist/asymmetric-crypto.mjs +28 -2
  13. package/dist/asymmetric-crypto.mjs.map +1 -0
  14. package/dist/constants.d.mts +7 -14
  15. package/dist/constants.d.mts.map +1 -1
  16. package/dist/constants.d.ts +7 -14
  17. package/dist/constants.d.ts.map +1 -1
  18. package/dist/constants.js +11 -25
  19. package/dist/constants.js.map +1 -1
  20. package/dist/constants.mjs +7 -14
  21. package/dist/constants.mjs.map +1 -1
  22. package/dist/core-Bj26rNdA.js +227 -0
  23. package/dist/core-Bj26rNdA.js.map +1 -0
  24. package/dist/core-pEGygy6S.mjs +173 -0
  25. package/dist/core-pEGygy6S.mjs.map +1 -0
  26. package/dist/derive-key.d.mts +1 -74
  27. package/dist/derive-key.d.mts.map +1 -1
  28. package/dist/derive-key.d.ts +1 -74
  29. package/dist/derive-key.d.ts.map +1 -1
  30. package/dist/derive-key.js +3 -11
  31. package/dist/derive-key.mjs +2 -2
  32. package/dist/derive-password.d.mts +22 -0
  33. package/dist/derive-password.d.mts.map +1 -0
  34. package/dist/derive-password.d.ts +22 -0
  35. package/dist/derive-password.d.ts.map +1 -0
  36. package/dist/derive-password.js +5 -0
  37. package/dist/derive-password.mjs +3 -0
  38. package/dist/deriveKeysFromKey-C4McqO6_.js +47 -0
  39. package/dist/deriveKeysFromKey-C4McqO6_.js.map +1 -0
  40. package/dist/deriveKeysFromKey-DPU_h7wr.mjs +35 -0
  41. package/dist/deriveKeysFromKey-DPU_h7wr.mjs.map +1 -0
  42. package/dist/{deriveKeysFromPassword-Ko7NxkHM.js → deriveKeysFromPassword-C7xAGGsh.js} +5 -177
  43. package/dist/deriveKeysFromPassword-C7xAGGsh.js.map +1 -0
  44. package/dist/{deriveKeysFromPassword-DJRWZ8Rw.mjs → deriveKeysFromPassword-DXgSvTNC.mjs} +7 -131
  45. package/dist/deriveKeysFromPassword-DXgSvTNC.mjs.map +1 -0
  46. package/dist/email-crypto.d.mts +24 -46
  47. package/dist/email-crypto.d.mts.map +1 -1
  48. package/dist/email-crypto.d.ts +24 -46
  49. package/dist/email-crypto.d.ts.map +1 -1
  50. package/dist/email-crypto.js +121 -12
  51. package/dist/email-crypto.js.map +1 -0
  52. package/dist/email-crypto.mjs +115 -2
  53. package/dist/email-crypto.mjs.map +1 -0
  54. package/dist/email-search.d.mts +18 -18
  55. package/dist/email-search.d.mts.map +1 -1
  56. package/dist/email-search.d.ts +18 -18
  57. package/dist/email-search.d.ts.map +1 -1
  58. package/dist/email-search.js +25 -597
  59. package/dist/email-search.mjs +2 -573
  60. package/dist/{emailEncryptionKey-27mIHh18.mjs → emailEncryptionKey-BtSPYd9M.mjs} +23 -46
  61. package/dist/emailEncryptionKey-BtSPYd9M.mjs.map +1 -0
  62. package/dist/{emailEncryptionKey-DbaDAdoW.js → emailEncryptionKey-C4X1Bwy4.js} +22 -45
  63. package/dist/emailEncryptionKey-C4X1Bwy4.js.map +1 -0
  64. package/dist/{genID-3Er5IowC.mjs → genID-D08K7JPr.mjs} +4 -40
  65. package/dist/genID-D08K7JPr.mjs.map +1 -0
  66. package/dist/{genID-YJSl3YhL.js → genID-cWOPmspk.js} +2 -50
  67. package/dist/genID-cWOPmspk.js.map +1 -0
  68. package/dist/hash.d.mts +24 -36
  69. package/dist/hash.d.mts.map +1 -1
  70. package/dist/hash.d.ts +24 -36
  71. package/dist/hash.d.ts.map +1 -1
  72. package/dist/hash.js +88 -10
  73. package/dist/hash.js.map +1 -0
  74. package/dist/hash.mjs +82 -2
  75. package/dist/hash.mjs.map +1 -0
  76. package/dist/index.d.mts +17 -16
  77. package/dist/index.d.mts.map +1 -1
  78. package/dist/index.d.ts +17 -16
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +60 -83
  81. package/dist/index.mjs +13 -11
  82. package/dist/keystore-crypto.d.mts +6 -6
  83. package/dist/keystore-crypto.d.mts.map +1 -1
  84. package/dist/keystore-crypto.d.ts +6 -6
  85. package/dist/keystore-crypto.d.ts.map +1 -1
  86. package/dist/keystore-crypto.js +1 -1
  87. package/dist/keystore-crypto.mjs +1 -1
  88. package/dist/post-quantum-crypto.d.mts +5 -41
  89. package/dist/post-quantum-crypto.d.mts.map +1 -1
  90. package/dist/post-quantum-crypto.d.ts +5 -41
  91. package/dist/post-quantum-crypto.d.ts.map +1 -1
  92. package/dist/post-quantum-crypto.js +49 -16
  93. package/dist/post-quantum-crypto.js.map +1 -0
  94. package/dist/post-quantum-crypto.mjs +46 -2
  95. package/dist/post-quantum-crypto.mjs.map +1 -0
  96. package/dist/search-B9YM3XAA.mjs +587 -0
  97. package/dist/search-B9YM3XAA.mjs.map +1 -0
  98. package/dist/search-DUTm4-rN.js +731 -0
  99. package/dist/search-DUTm4-rN.js.map +1 -0
  100. package/dist/symmetric-crypto.d.mts +13 -42
  101. package/dist/symmetric-crypto.d.mts.map +1 -1
  102. package/dist/symmetric-crypto.d.ts +13 -42
  103. package/dist/symmetric-crypto.d.ts.map +1 -1
  104. package/dist/symmetric-crypto.js +2 -6
  105. package/dist/symmetric-crypto.mjs +2 -2
  106. package/dist/types.d.mts +16 -39
  107. package/dist/types.d.mts.map +1 -1
  108. package/dist/types.d.ts +16 -39
  109. package/dist/types.d.ts.map +1 -1
  110. package/dist/types.js.map +1 -1
  111. package/dist/types.mjs.map +1 -1
  112. package/dist/utils.d.mts +1 -19
  113. package/dist/utils.d.mts.map +1 -1
  114. package/dist/utils.d.ts +1 -19
  115. package/dist/utils.d.ts.map +1 -1
  116. package/dist/utils.js +1 -3
  117. package/dist/utils.mjs +2 -2
  118. package/dist/xwing-CQmQX6hn.mjs +16 -0
  119. package/dist/xwing-CQmQX6hn.mjs.map +1 -0
  120. package/dist/xwing-iRWVRtNE.js +34 -0
  121. package/dist/xwing-iRWVRtNE.js.map +1 -0
  122. package/package.json +4 -2
  123. package/dist/aes-DSDxP8uF.mjs +0 -184
  124. package/dist/aes-DSDxP8uF.mjs.map +0 -1
  125. package/dist/aes-bOrKZuUC.js +0 -226
  126. package/dist/aes-bOrKZuUC.js.map +0 -1
  127. package/dist/deriveKeysFromPassword-DJRWZ8Rw.mjs.map +0 -1
  128. package/dist/deriveKeysFromPassword-Ko7NxkHM.js.map +0 -1
  129. package/dist/email-search.js.map +0 -1
  130. package/dist/email-search.mjs.map +0 -1
  131. package/dist/emailEncryptionKey-27mIHh18.mjs.map +0 -1
  132. package/dist/emailEncryptionKey-DbaDAdoW.js.map +0 -1
  133. package/dist/emailKeys-BJGdkLrg.js +0 -593
  134. package/dist/emailKeys-BJGdkLrg.js.map +0 -1
  135. package/dist/emailKeys-Fp9WR3wl.mjs +0 -509
  136. package/dist/emailKeys-Fp9WR3wl.mjs.map +0 -1
  137. package/dist/genID-3Er5IowC.mjs.map +0 -1
  138. package/dist/genID-YJSl3YhL.js.map +0 -1
  139. package/dist/keys-BfcaiAOv.mjs +0 -90
  140. package/dist/keys-BfcaiAOv.mjs.map +0 -1
  141. package/dist/keys-CinT7kEY.js +0 -125
  142. package/dist/keys-CinT7kEY.js.map +0 -1
  143. package/dist/kyber1024-PpwE1rki.mjs +0 -144
  144. package/dist/kyber1024-PpwE1rki.mjs.map +0 -1
  145. package/dist/kyber1024-jeKS8CXf.js +0 -173
  146. package/dist/kyber1024-jeKS8CXf.js.map +0 -1
  147. package/dist/kyber768-DGBB_RS7.d.ts +0 -32
  148. package/dist/kyber768-DGBB_RS7.d.ts.map +0 -1
  149. package/dist/kyber768-DzIcGg1i.d.mts +0 -32
  150. package/dist/kyber768-DzIcGg1i.d.mts.map +0 -1
  151. package/dist/mac-BMb1F0dN.js +0 -170
  152. package/dist/mac-BMb1F0dN.js.map +0 -1
  153. package/dist/mac-ZpRlx8Fs.mjs +0 -116
  154. package/dist/mac-ZpRlx8Fs.mjs.map +0 -1
@@ -1,170 +0,0 @@
1
- const require_chunk = require('./chunk-EbLFQX5m.js');
2
- const require_constants = require('./constants.js');
3
- let _noble_hashes_blake3_js = require("@noble/hashes/blake3.js");
4
- let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
5
-
6
- //#region src/hash/blake3.ts
7
- /**
8
- * Hashes the given array of data
9
- *
10
- * @param data - The data to hash
11
- * @returns The resulting hash array
12
- */
13
- function hashDataArray(data) {
14
- try {
15
- const hasher = _noble_hashes_blake3_js.blake3.create();
16
- for (const d of data) hasher.update(d);
17
- return hasher.digest();
18
- } catch (error) {
19
- throw new Error("Failed to compute hash", { cause: error });
20
- }
21
- }
22
- /**
23
- * Hashes the given array of data
24
- *
25
- * @param data - The data to hash
26
- * @returns The resulting hash hex string
27
- */
28
- function hashDataArrayHex(data) {
29
- return (0, _noble_hashes_utils_js.bytesToHex)(hashDataArray(data));
30
- }
31
- function hashDataArrayWithKeyHex(hashKey, data) {
32
- try {
33
- return (0, _noble_hashes_utils_js.bytesToHex)(hashDataArrayWithKey(hashKey, data));
34
- } catch (error) {
35
- throw new Error("Failed to compute hash hex", { cause: error });
36
- }
37
- }
38
- function hashDataArrayWithKey(hashKey, data) {
39
- try {
40
- const hasher = _noble_hashes_blake3_js.blake3.create({ key: hashKey });
41
- for (const d of data) hasher.update(d);
42
- return hasher.digest();
43
- } catch (error) {
44
- throw new Error("Failed to compute hash", { cause: error });
45
- }
46
- }
47
- /**
48
- * Hashes the given array of data using blake3 algorithm
49
- *
50
- * @param bytes - The desired output byte-length
51
- * @param data - The data to hash
52
- * @returns The resulting hash value
53
- */
54
- function getBytesFromDataArray(bytes, data) {
55
- try {
56
- const hasher = _noble_hashes_blake3_js.blake3.create({ dkLen: bytes });
57
- for (const chunk of data) hasher.update(chunk);
58
- return hasher.digest();
59
- } catch (error) {
60
- throw new Error("Failed to get bytes from data", { cause: error });
61
- }
62
- }
63
- /**
64
- * Hashes the given array of data using blake3 algorithm
65
- *
66
- * @param bytes - The desired output byte-length
67
- * @param data - The data to hash
68
- * @returns The resulting hash value
69
- */
70
- function getBytesFromDataArrayHex(bytes, data) {
71
- try {
72
- return (0, _noble_hashes_utils_js.bytesToHex)(getBytesFromDataArray(bytes, data));
73
- } catch (error) {
74
- throw new Error("Failed to get bytes from data", { cause: error });
75
- }
76
- }
77
- /**
78
- * Hashes the given string using blake3 algorithm
79
- *
80
- * @param bytes - The desired output byte-length
81
- * @param data - The data to hash
82
- * @returns The resulting hash value
83
- */
84
- function getBytesFromData(bytes, data) {
85
- return (0, _noble_hashes_blake3_js.blake3)(data, { dkLen: bytes });
86
- }
87
- /**
88
- * Hashes the given data using blake3 algorithm
89
- *
90
- * @param bytes - The desired output byte-length
91
- * @param data - The data to hash
92
- * @returns The resulting hash value
93
- */
94
- function getBytesFromDataHex(bytes, data) {
95
- return (0, _noble_hashes_utils_js.bytesToHex)(getBytesFromData(bytes, data));
96
- }
97
-
98
- //#endregion
99
- //#region src/hash/mac.ts
100
- /**
101
- * Computes mac for the given key material and data
102
- *
103
- * @param keyMaterial - The key material
104
- * @param data - The data to hash
105
- * @returns The resulting hash hex string
106
- */
107
- function computeMac(keyMaterial, data) {
108
- try {
109
- return (0, _noble_hashes_utils_js.bytesToHex)(hashDataArrayWithKey(getBytesFromData(require_constants.AES_KEY_BIT_LENGTH / 8, keyMaterial), data));
110
- } catch (error) {
111
- throw new Error("Failed to compute mac", { cause: error });
112
- }
113
- }
114
-
115
- //#endregion
116
- Object.defineProperty(exports, 'computeMac', {
117
- enumerable: true,
118
- get: function () {
119
- return computeMac;
120
- }
121
- });
122
- Object.defineProperty(exports, 'getBytesFromData', {
123
- enumerable: true,
124
- get: function () {
125
- return getBytesFromData;
126
- }
127
- });
128
- Object.defineProperty(exports, 'getBytesFromDataArray', {
129
- enumerable: true,
130
- get: function () {
131
- return getBytesFromDataArray;
132
- }
133
- });
134
- Object.defineProperty(exports, 'getBytesFromDataArrayHex', {
135
- enumerable: true,
136
- get: function () {
137
- return getBytesFromDataArrayHex;
138
- }
139
- });
140
- Object.defineProperty(exports, 'getBytesFromDataHex', {
141
- enumerable: true,
142
- get: function () {
143
- return getBytesFromDataHex;
144
- }
145
- });
146
- Object.defineProperty(exports, 'hashDataArray', {
147
- enumerable: true,
148
- get: function () {
149
- return hashDataArray;
150
- }
151
- });
152
- Object.defineProperty(exports, 'hashDataArrayHex', {
153
- enumerable: true,
154
- get: function () {
155
- return hashDataArrayHex;
156
- }
157
- });
158
- Object.defineProperty(exports, 'hashDataArrayWithKey', {
159
- enumerable: true,
160
- get: function () {
161
- return hashDataArrayWithKey;
162
- }
163
- });
164
- Object.defineProperty(exports, 'hashDataArrayWithKeyHex', {
165
- enumerable: true,
166
- get: function () {
167
- return hashDataArrayWithKeyHex;
168
- }
169
- });
170
- //# sourceMappingURL=mac-BMb1F0dN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mac-BMb1F0dN.js","names":["blake3","AES_KEY_BIT_LENGTH"],"sources":["../src/hash/blake3.ts","../src/hash/mac.ts"],"sourcesContent":["import { blake3 } from '@noble/hashes/blake3.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\n/**\n * Hashes the given array of data\n *\n * @param data - The data to hash\n * @returns The resulting hash array\n */\nexport function hashDataArray(data: Uint8Array[]): Uint8Array {\n try {\n const hasher = blake3.create();\n for (const d of data) {\n hasher.update(d);\n }\n return hasher.digest();\n } catch (error) {\n throw new Error('Failed to compute hash', { cause: error });\n }\n}\n\n/**\n * Hashes the given array of data\n *\n * @param data - The data to hash\n * @returns The resulting hash hex string\n */\nexport function hashDataArrayHex(data: Uint8Array[]): string {\n return bytesToHex(hashDataArray(data));\n}\n\nexport function hashDataArrayWithKeyHex(hashKey: Uint8Array, data: Uint8Array[]): string {\n try {\n const hash = hashDataArrayWithKey(hashKey, data);\n return bytesToHex(hash);\n } catch (error) {\n throw new Error('Failed to compute hash hex', { cause: error });\n }\n}\n\nexport function hashDataArrayWithKey(hashKey: Uint8Array, data: Uint8Array[]): Uint8Array {\n try {\n const hasher = blake3.create({ key: hashKey });\n for (const d of data) {\n hasher.update(d);\n }\n return hasher.digest();\n } catch (error) {\n throw new Error('Failed to compute hash', { cause: error });\n }\n}\n\n/**\n * Hashes the given array of data using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromDataArray(bytes: number, data: Uint8Array[]): Uint8Array {\n try {\n const hasher = blake3.create({ dkLen: bytes });\n for (const chunk of data) {\n hasher.update(chunk);\n }\n return hasher.digest();\n } catch (error) {\n throw new Error('Failed to get bytes from data', { cause: error });\n }\n}\n\n/**\n * Hashes the given array of data using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromDataArrayHex(bytes: number, data: Uint8Array[]): string {\n try {\n const hash = getBytesFromDataArray(bytes, data);\n return bytesToHex(hash);\n } catch (error) {\n throw new Error('Failed to get bytes from data', { cause: error });\n }\n}\n\n/**\n * Hashes the given string using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromData(bytes: number, data: Uint8Array): Uint8Array {\n return blake3(data, { dkLen: bytes });\n}\n\n/**\n * Hashes the given data using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromDataHex(bytes: number, data: Uint8Array): string {\n return bytesToHex(getBytesFromData(bytes, data));\n}\n","import { bytesToHex } from '@noble/hashes/utils.js';\nimport { AES_KEY_BIT_LENGTH } from '../constants';\nimport { getBytesFromData, hashDataArrayWithKey } from './blake3';\n\n/**\n * Computes mac for the given key material and data\n *\n * @param keyMaterial - The key material\n * @param data - The data to hash\n * @returns The resulting hash hex string\n */\nexport function computeMac(keyMaterial: Uint8Array, data: Uint8Array[]): string {\n try {\n const key = getBytesFromData(AES_KEY_BIT_LENGTH / 8, keyMaterial);\n const hash = hashDataArrayWithKey(key, data);\n return bytesToHex(hash);\n } catch (error) {\n throw new Error('Failed to compute mac', { cause: error });\n }\n}\n"],"mappings":";;;;;;;;;;;;AASA,SAAgB,cAAc,MAAgC;AAC5D,KAAI;EACF,MAAM,SAASA,+BAAO,QAAQ;AAC9B,OAAK,MAAM,KAAK,KACd,QAAO,OAAO,EAAE;AAElB,SAAO,OAAO,QAAQ;UACf,OAAO;AACd,QAAM,IAAI,MAAM,0BAA0B,EAAE,OAAO,OAAO,CAAC;;;;;;;;;AAU/D,SAAgB,iBAAiB,MAA4B;AAC3D,+CAAkB,cAAc,KAAK,CAAC;;AAGxC,SAAgB,wBAAwB,SAAqB,MAA4B;AACvF,KAAI;AAEF,gDADa,qBAAqB,SAAS,KAAK,CACzB;UAChB,OAAO;AACd,QAAM,IAAI,MAAM,8BAA8B,EAAE,OAAO,OAAO,CAAC;;;AAInE,SAAgB,qBAAqB,SAAqB,MAAgC;AACxF,KAAI;EACF,MAAM,SAASA,+BAAO,OAAO,EAAE,KAAK,SAAS,CAAC;AAC9C,OAAK,MAAM,KAAK,KACd,QAAO,OAAO,EAAE;AAElB,SAAO,OAAO,QAAQ;UACf,OAAO;AACd,QAAM,IAAI,MAAM,0BAA0B,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;AAW/D,SAAgB,sBAAsB,OAAe,MAAgC;AACnF,KAAI;EACF,MAAM,SAASA,+BAAO,OAAO,EAAE,OAAO,OAAO,CAAC;AAC9C,OAAK,MAAM,SAAS,KAClB,QAAO,OAAO,MAAM;AAEtB,SAAO,OAAO,QAAQ;UACf,OAAO;AACd,QAAM,IAAI,MAAM,iCAAiC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;AAWtE,SAAgB,yBAAyB,OAAe,MAA4B;AAClF,KAAI;AAEF,gDADa,sBAAsB,OAAO,KAAK,CACxB;UAChB,OAAO;AACd,QAAM,IAAI,MAAM,iCAAiC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;AAWtE,SAAgB,iBAAiB,OAAe,MAA8B;AAC5E,4CAAc,MAAM,EAAE,OAAO,OAAO,CAAC;;;;;;;;;AAUvC,SAAgB,oBAAoB,OAAe,MAA0B;AAC3E,+CAAkB,iBAAiB,OAAO,KAAK,CAAC;;;;;;;;;;;;AC/FlD,SAAgB,WAAW,aAAyB,MAA4B;AAC9E,KAAI;AAGF,gDADa,qBADD,iBAAiBC,uCAAqB,GAAG,YAAY,EAC1B,KAAK,CACrB;UAChB,OAAO;AACd,QAAM,IAAI,MAAM,yBAAyB,EAAE,OAAO,OAAO,CAAC"}
@@ -1,116 +0,0 @@
1
- import { AES_KEY_BIT_LENGTH } from "./constants.mjs";
2
- import { blake3 } from "@noble/hashes/blake3.js";
3
- import { bytesToHex } from "@noble/hashes/utils.js";
4
-
5
- //#region src/hash/blake3.ts
6
- /**
7
- * Hashes the given array of data
8
- *
9
- * @param data - The data to hash
10
- * @returns The resulting hash array
11
- */
12
- function hashDataArray(data) {
13
- try {
14
- const hasher = blake3.create();
15
- for (const d of data) hasher.update(d);
16
- return hasher.digest();
17
- } catch (error) {
18
- throw new Error("Failed to compute hash", { cause: error });
19
- }
20
- }
21
- /**
22
- * Hashes the given array of data
23
- *
24
- * @param data - The data to hash
25
- * @returns The resulting hash hex string
26
- */
27
- function hashDataArrayHex(data) {
28
- return bytesToHex(hashDataArray(data));
29
- }
30
- function hashDataArrayWithKeyHex(hashKey, data) {
31
- try {
32
- return bytesToHex(hashDataArrayWithKey(hashKey, data));
33
- } catch (error) {
34
- throw new Error("Failed to compute hash hex", { cause: error });
35
- }
36
- }
37
- function hashDataArrayWithKey(hashKey, data) {
38
- try {
39
- const hasher = blake3.create({ key: hashKey });
40
- for (const d of data) hasher.update(d);
41
- return hasher.digest();
42
- } catch (error) {
43
- throw new Error("Failed to compute hash", { cause: error });
44
- }
45
- }
46
- /**
47
- * Hashes the given array of data using blake3 algorithm
48
- *
49
- * @param bytes - The desired output byte-length
50
- * @param data - The data to hash
51
- * @returns The resulting hash value
52
- */
53
- function getBytesFromDataArray(bytes, data) {
54
- try {
55
- const hasher = blake3.create({ dkLen: bytes });
56
- for (const chunk of data) hasher.update(chunk);
57
- return hasher.digest();
58
- } catch (error) {
59
- throw new Error("Failed to get bytes from data", { cause: error });
60
- }
61
- }
62
- /**
63
- * Hashes the given array of data using blake3 algorithm
64
- *
65
- * @param bytes - The desired output byte-length
66
- * @param data - The data to hash
67
- * @returns The resulting hash value
68
- */
69
- function getBytesFromDataArrayHex(bytes, data) {
70
- try {
71
- return bytesToHex(getBytesFromDataArray(bytes, data));
72
- } catch (error) {
73
- throw new Error("Failed to get bytes from data", { cause: error });
74
- }
75
- }
76
- /**
77
- * Hashes the given string using blake3 algorithm
78
- *
79
- * @param bytes - The desired output byte-length
80
- * @param data - The data to hash
81
- * @returns The resulting hash value
82
- */
83
- function getBytesFromData(bytes, data) {
84
- return blake3(data, { dkLen: bytes });
85
- }
86
- /**
87
- * Hashes the given data using blake3 algorithm
88
- *
89
- * @param bytes - The desired output byte-length
90
- * @param data - The data to hash
91
- * @returns The resulting hash value
92
- */
93
- function getBytesFromDataHex(bytes, data) {
94
- return bytesToHex(getBytesFromData(bytes, data));
95
- }
96
-
97
- //#endregion
98
- //#region src/hash/mac.ts
99
- /**
100
- * Computes mac for the given key material and data
101
- *
102
- * @param keyMaterial - The key material
103
- * @param data - The data to hash
104
- * @returns The resulting hash hex string
105
- */
106
- function computeMac(keyMaterial, data) {
107
- try {
108
- return bytesToHex(hashDataArrayWithKey(getBytesFromData(AES_KEY_BIT_LENGTH / 8, keyMaterial), data));
109
- } catch (error) {
110
- throw new Error("Failed to compute mac", { cause: error });
111
- }
112
- }
113
-
114
- //#endregion
115
- export { getBytesFromDataHex as a, hashDataArrayWithKey as c, getBytesFromDataArrayHex as i, hashDataArrayWithKeyHex as l, getBytesFromData as n, hashDataArray as o, getBytesFromDataArray as r, hashDataArrayHex as s, computeMac as t };
116
- //# sourceMappingURL=mac-ZpRlx8Fs.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mac-ZpRlx8Fs.mjs","names":[],"sources":["../src/hash/blake3.ts","../src/hash/mac.ts"],"sourcesContent":["import { blake3 } from '@noble/hashes/blake3.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\n/**\n * Hashes the given array of data\n *\n * @param data - The data to hash\n * @returns The resulting hash array\n */\nexport function hashDataArray(data: Uint8Array[]): Uint8Array {\n try {\n const hasher = blake3.create();\n for (const d of data) {\n hasher.update(d);\n }\n return hasher.digest();\n } catch (error) {\n throw new Error('Failed to compute hash', { cause: error });\n }\n}\n\n/**\n * Hashes the given array of data\n *\n * @param data - The data to hash\n * @returns The resulting hash hex string\n */\nexport function hashDataArrayHex(data: Uint8Array[]): string {\n return bytesToHex(hashDataArray(data));\n}\n\nexport function hashDataArrayWithKeyHex(hashKey: Uint8Array, data: Uint8Array[]): string {\n try {\n const hash = hashDataArrayWithKey(hashKey, data);\n return bytesToHex(hash);\n } catch (error) {\n throw new Error('Failed to compute hash hex', { cause: error });\n }\n}\n\nexport function hashDataArrayWithKey(hashKey: Uint8Array, data: Uint8Array[]): Uint8Array {\n try {\n const hasher = blake3.create({ key: hashKey });\n for (const d of data) {\n hasher.update(d);\n }\n return hasher.digest();\n } catch (error) {\n throw new Error('Failed to compute hash', { cause: error });\n }\n}\n\n/**\n * Hashes the given array of data using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromDataArray(bytes: number, data: Uint8Array[]): Uint8Array {\n try {\n const hasher = blake3.create({ dkLen: bytes });\n for (const chunk of data) {\n hasher.update(chunk);\n }\n return hasher.digest();\n } catch (error) {\n throw new Error('Failed to get bytes from data', { cause: error });\n }\n}\n\n/**\n * Hashes the given array of data using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromDataArrayHex(bytes: number, data: Uint8Array[]): string {\n try {\n const hash = getBytesFromDataArray(bytes, data);\n return bytesToHex(hash);\n } catch (error) {\n throw new Error('Failed to get bytes from data', { cause: error });\n }\n}\n\n/**\n * Hashes the given string using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromData(bytes: number, data: Uint8Array): Uint8Array {\n return blake3(data, { dkLen: bytes });\n}\n\n/**\n * Hashes the given data using blake3 algorithm\n *\n * @param bytes - The desired output byte-length\n * @param data - The data to hash\n * @returns The resulting hash value\n */\nexport function getBytesFromDataHex(bytes: number, data: Uint8Array): string {\n return bytesToHex(getBytesFromData(bytes, data));\n}\n","import { bytesToHex } from '@noble/hashes/utils.js';\nimport { AES_KEY_BIT_LENGTH } from '../constants';\nimport { getBytesFromData, hashDataArrayWithKey } from './blake3';\n\n/**\n * Computes mac for the given key material and data\n *\n * @param keyMaterial - The key material\n * @param data - The data to hash\n * @returns The resulting hash hex string\n */\nexport function computeMac(keyMaterial: Uint8Array, data: Uint8Array[]): string {\n try {\n const key = getBytesFromData(AES_KEY_BIT_LENGTH / 8, keyMaterial);\n const hash = hashDataArrayWithKey(key, data);\n return bytesToHex(hash);\n } catch (error) {\n throw new Error('Failed to compute mac', { cause: error });\n }\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,cAAc,MAAgC;AAC5D,KAAI;EACF,MAAM,SAAS,OAAO,QAAQ;AAC9B,OAAK,MAAM,KAAK,KACd,QAAO,OAAO,EAAE;AAElB,SAAO,OAAO,QAAQ;UACf,OAAO;AACd,QAAM,IAAI,MAAM,0BAA0B,EAAE,OAAO,OAAO,CAAC;;;;;;;;;AAU/D,SAAgB,iBAAiB,MAA4B;AAC3D,QAAO,WAAW,cAAc,KAAK,CAAC;;AAGxC,SAAgB,wBAAwB,SAAqB,MAA4B;AACvF,KAAI;AAEF,SAAO,WADM,qBAAqB,SAAS,KAAK,CACzB;UAChB,OAAO;AACd,QAAM,IAAI,MAAM,8BAA8B,EAAE,OAAO,OAAO,CAAC;;;AAInE,SAAgB,qBAAqB,SAAqB,MAAgC;AACxF,KAAI;EACF,MAAM,SAAS,OAAO,OAAO,EAAE,KAAK,SAAS,CAAC;AAC9C,OAAK,MAAM,KAAK,KACd,QAAO,OAAO,EAAE;AAElB,SAAO,OAAO,QAAQ;UACf,OAAO;AACd,QAAM,IAAI,MAAM,0BAA0B,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;AAW/D,SAAgB,sBAAsB,OAAe,MAAgC;AACnF,KAAI;EACF,MAAM,SAAS,OAAO,OAAO,EAAE,OAAO,OAAO,CAAC;AAC9C,OAAK,MAAM,SAAS,KAClB,QAAO,OAAO,MAAM;AAEtB,SAAO,OAAO,QAAQ;UACf,OAAO;AACd,QAAM,IAAI,MAAM,iCAAiC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;AAWtE,SAAgB,yBAAyB,OAAe,MAA4B;AAClF,KAAI;AAEF,SAAO,WADM,sBAAsB,OAAO,KAAK,CACxB;UAChB,OAAO;AACd,QAAM,IAAI,MAAM,iCAAiC,EAAE,OAAO,OAAO,CAAC;;;;;;;;;;AAWtE,SAAgB,iBAAiB,OAAe,MAA8B;AAC5E,QAAO,OAAO,MAAM,EAAE,OAAO,OAAO,CAAC;;;;;;;;;AAUvC,SAAgB,oBAAoB,OAAe,MAA0B;AAC3E,QAAO,WAAW,iBAAiB,OAAO,KAAK,CAAC;;;;;;;;;;;;AC/FlD,SAAgB,WAAW,aAAyB,MAA4B;AAC9E,KAAI;AAGF,SAAO,WADM,qBADD,iBAAiB,qBAAqB,GAAG,YAAY,EAC1B,KAAK,CACrB;UAChB,OAAO;AACd,QAAM,IAAI,MAAM,yBAAyB,EAAE,OAAO,OAAO,CAAC"}