@nktkas/hyperliquid 0.17.3 → 0.18.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 (126) hide show
  1. package/README.md +49 -36
  2. package/{script/deps/jsr.io/@noble/hashes/1.7.1 → esm/deps/jsr.io/@noble/hashes/1.8.0}/src/_u64.d.ts +1 -1
  3. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +1 -0
  4. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/_u64.js +5 -4
  5. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts.map +1 -1
  6. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.d.ts +6 -5
  7. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +1 -0
  8. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.js +63 -52
  9. package/{script/deps/jsr.io/@noble/hashes/1.7.1 → esm/deps/jsr.io/@noble/hashes/1.8.0}/src/utils.d.ts +60 -19
  10. package/esm/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +1 -0
  11. package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/utils.js +94 -25
  12. package/esm/deps/jsr.io/@std/async/1.0.12/delay.d.ts +43 -0
  13. package/esm/deps/jsr.io/@std/async/1.0.12/delay.d.ts.map +1 -0
  14. package/esm/deps/jsr.io/@std/async/1.0.12/delay.js +63 -0
  15. package/{script/deps/jsr.io/@std/encoding/1.0.9 → esm/deps/jsr.io/@std/encoding/1.0.10}/_common16.d.ts +1 -1
  16. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +1 -0
  17. package/esm/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_common16.js +1 -1
  18. package/esm/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +1 -0
  19. package/esm/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +1 -0
  20. package/esm/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +1 -0
  21. package/esm/src/clients/wallet.d.ts +22 -12
  22. package/esm/src/clients/wallet.d.ts.map +1 -1
  23. package/esm/src/clients/wallet.js +85 -62
  24. package/esm/src/signing.d.ts +4 -1
  25. package/esm/src/signing.d.ts.map +1 -1
  26. package/esm/src/signing.js +47 -24
  27. package/esm/src/transports/http/http_transport.d.ts +18 -8
  28. package/esm/src/transports/http/http_transport.d.ts.map +1 -1
  29. package/esm/src/transports/http/http_transport.js +17 -18
  30. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts +3 -12
  31. package/esm/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  32. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts +20 -42
  33. package/esm/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  34. package/esm/src/transports/websocket/_reconnecting_websocket.js +127 -193
  35. package/esm/src/transports/websocket/websocket_transport.d.ts +6 -0
  36. package/esm/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  37. package/esm/src/transports/websocket/websocket_transport.js +23 -21
  38. package/esm/src/types/exchange/requests.d.ts +26 -2
  39. package/esm/src/types/exchange/requests.d.ts.map +1 -1
  40. package/esm/src/types/exchange/responses.d.ts +6 -6
  41. package/esm/src/types/exchange/responses.d.ts.map +1 -1
  42. package/esm/src/types/info/accounts.d.ts +14 -0
  43. package/esm/src/types/info/accounts.d.ts.map +1 -1
  44. package/esm/src/types/info/assets.d.ts +20 -0
  45. package/esm/src/types/info/assets.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/{esm/deps/jsr.io/@noble/hashes/1.7.1 → script/deps/jsr.io/@noble/hashes/1.8.0}/src/_u64.d.ts +1 -1
  48. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/_u64.d.ts.map +1 -0
  49. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/_u64.js +6 -5
  50. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts.map +1 -1
  51. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.d.ts +6 -5
  52. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/sha3.d.ts.map +1 -0
  53. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/sha3.js +69 -58
  54. package/{esm/deps/jsr.io/@noble/hashes/1.7.1 → script/deps/jsr.io/@noble/hashes/1.8.0}/src/utils.d.ts +60 -19
  55. package/script/deps/jsr.io/@noble/hashes/1.8.0/src/utils.d.ts.map +1 -0
  56. package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/utils.js +111 -34
  57. package/script/deps/jsr.io/@std/async/1.0.12/delay.d.ts +43 -0
  58. package/script/deps/jsr.io/@std/async/1.0.12/delay.d.ts.map +1 -0
  59. package/script/deps/jsr.io/@std/async/1.0.12/delay.js +76 -0
  60. package/{esm/deps/jsr.io/@std/encoding/1.0.9 → script/deps/jsr.io/@std/encoding/1.0.10}/_common16.d.ts +1 -1
  61. package/script/deps/jsr.io/@std/encoding/1.0.10/_common16.d.ts.map +1 -0
  62. package/script/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_common16.js +1 -1
  63. package/script/deps/jsr.io/@std/encoding/1.0.10/_common_detach.d.ts.map +1 -0
  64. package/script/deps/jsr.io/@std/encoding/1.0.10/_types.d.ts.map +1 -0
  65. package/script/deps/jsr.io/@std/encoding/1.0.10/hex.d.ts.map +1 -0
  66. package/script/src/clients/wallet.d.ts +22 -12
  67. package/script/src/clients/wallet.d.ts.map +1 -1
  68. package/script/src/clients/wallet.js +85 -62
  69. package/script/src/signing.d.ts +4 -1
  70. package/script/src/signing.d.ts.map +1 -1
  71. package/script/src/signing.js +47 -24
  72. package/script/src/transports/http/http_transport.d.ts +18 -8
  73. package/script/src/transports/http/http_transport.d.ts.map +1 -1
  74. package/script/src/transports/http/http_transport.js +17 -18
  75. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts +3 -12
  76. package/script/src/transports/websocket/_hyperliquid_event_target.d.ts.map +1 -1
  77. package/script/src/transports/websocket/_reconnecting_websocket.d.ts +20 -42
  78. package/script/src/transports/websocket/_reconnecting_websocket.d.ts.map +1 -1
  79. package/script/src/transports/websocket/_reconnecting_websocket.js +129 -195
  80. package/script/src/transports/websocket/websocket_transport.d.ts +6 -0
  81. package/script/src/transports/websocket/websocket_transport.d.ts.map +1 -1
  82. package/script/src/transports/websocket/websocket_transport.js +23 -21
  83. package/script/src/types/exchange/requests.d.ts +26 -2
  84. package/script/src/types/exchange/requests.d.ts.map +1 -1
  85. package/script/src/types/exchange/responses.d.ts +6 -6
  86. package/script/src/types/exchange/responses.d.ts.map +1 -1
  87. package/script/src/types/info/accounts.d.ts +14 -0
  88. package/script/src/types/info/accounts.d.ts.map +1 -1
  89. package/script/src/types/info/assets.d.ts +20 -0
  90. package/script/src/types/info/assets.d.ts.map +1 -1
  91. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +0 -23
  92. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +0 -1
  93. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +0 -43
  94. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +0 -1
  95. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +0 -1
  96. package/esm/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +0 -1
  97. package/esm/deps/jsr.io/@std/encoding/1.0.9/_common16.d.ts.map +0 -1
  98. package/esm/deps/jsr.io/@std/encoding/1.0.9/_common_detach.d.ts.map +0 -1
  99. package/esm/deps/jsr.io/@std/encoding/1.0.9/_types.d.ts.map +0 -1
  100. package/esm/deps/jsr.io/@std/encoding/1.0.9/hex.d.ts.map +0 -1
  101. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts +0 -23
  102. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.d.ts.map +0 -1
  103. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_assert.js +0 -59
  104. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/_u64.d.ts.map +0 -1
  105. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/sha3.d.ts.map +0 -1
  106. package/script/deps/jsr.io/@noble/hashes/1.7.1/src/utils.d.ts.map +0 -1
  107. package/script/deps/jsr.io/@std/encoding/1.0.9/_common16.d.ts.map +0 -1
  108. package/script/deps/jsr.io/@std/encoding/1.0.9/_common_detach.d.ts.map +0 -1
  109. package/script/deps/jsr.io/@std/encoding/1.0.9/_types.d.ts.map +0 -1
  110. package/script/deps/jsr.io/@std/encoding/1.0.9/hex.d.ts.map +0 -1
  111. /package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts +0 -0
  112. /package/esm/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.js +0 -0
  113. /package/esm/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_common_detach.d.ts +0 -0
  114. /package/esm/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_common_detach.js +0 -0
  115. /package/esm/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_types.d.ts +0 -0
  116. /package/esm/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_types.js +0 -0
  117. /package/esm/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/hex.d.ts +0 -0
  118. /package/esm/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/hex.js +0 -0
  119. /package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.d.ts +0 -0
  120. /package/script/deps/jsr.io/@noble/hashes/{1.7.1 → 1.8.0}/src/crypto.js +0 -0
  121. /package/script/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_common_detach.d.ts +0 -0
  122. /package/script/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_common_detach.js +0 -0
  123. /package/script/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_types.d.ts +0 -0
  124. /package/script/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/_types.js +0 -0
  125. /package/script/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/hex.d.ts +0 -0
  126. /package/script/deps/jsr.io/@std/encoding/{1.0.9 → 1.0.10}/hex.js +0 -0
@@ -4,7 +4,7 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./_assert.js", "./_u64.js", "./utils.js"], factory);
7
+ define(["require", "exports", "./_u64.js", "./utils.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -22,19 +22,21 @@
22
22
  * Check out `sha3-addons` module for cSHAKE, k12, and others.
23
23
  * @module
24
24
  */
25
- const _assert_js_1 = require("./_assert.js");
26
25
  const _u64_js_1 = require("./_u64.js");
26
+ // prettier-ignore
27
27
  const utils_js_1 = require("./utils.js");
28
+ // No __PURE__ annotations in sha3 header:
29
+ // EVERYTHING is in fact used on every export.
28
30
  // Various per round constants calculations
31
+ const _0n = BigInt(0);
32
+ const _1n = BigInt(1);
33
+ const _2n = BigInt(2);
34
+ const _7n = BigInt(7);
35
+ const _256n = BigInt(256);
36
+ const _0x71n = BigInt(0x71);
29
37
  const SHA3_PI = [];
30
38
  const SHA3_ROTL = [];
31
39
  const _SHA3_IOTA = [];
32
- const _0n = /* @__PURE__ */ BigInt(0);
33
- const _1n = /* @__PURE__ */ BigInt(1);
34
- const _2n = /* @__PURE__ */ BigInt(2);
35
- const _7n = /* @__PURE__ */ BigInt(7);
36
- const _256n = /* @__PURE__ */ BigInt(256);
37
- const _0x71n = /* @__PURE__ */ BigInt(0x71);
38
40
  for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
39
41
  // Pi
40
42
  [x, y] = [y, (2 * x + 3 * y) % 5];
@@ -50,7 +52,9 @@
50
52
  }
51
53
  _SHA3_IOTA.push(t);
52
54
  }
53
- const [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ (0, _u64_js_1.split)(_SHA3_IOTA, true);
55
+ const IOTAS = (0, _u64_js_1.split)(_SHA3_IOTA, true);
56
+ const SHA3_IOTA_H = IOTAS[0];
57
+ const SHA3_IOTA_L = IOTAS[1];
54
58
  // Left rotation (without 0, 32, 64)
55
59
  const rotlH = (h, l, s) => (s > 32 ? (0, _u64_js_1.rotlBH)(h, l, s) : (0, _u64_js_1.rotlSH)(h, l, s));
56
60
  const rotlL = (h, l, s) => (s > 32 ? (0, _u64_js_1.rotlBL)(h, l, s) : (0, _u64_js_1.rotlSL)(h, l, s));
@@ -98,101 +102,108 @@
98
102
  s[0] ^= SHA3_IOTA_H[round];
99
103
  s[1] ^= SHA3_IOTA_L[round];
100
104
  }
101
- B.fill(0);
105
+ (0, utils_js_1.clean)(B);
102
106
  }
103
107
  /** Keccak sponge function. */
104
108
  class Keccak extends utils_js_1.Hash {
105
109
  // NOTE: we accept arguments in bytes instead of bits here.
106
110
  constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
107
111
  super();
108
- Object.defineProperty(this, "blockLen", {
112
+ Object.defineProperty(this, "state", {
109
113
  enumerable: true,
110
114
  configurable: true,
111
115
  writable: true,
112
- value: blockLen
116
+ value: void 0
113
117
  });
114
- Object.defineProperty(this, "suffix", {
118
+ Object.defineProperty(this, "pos", {
115
119
  enumerable: true,
116
120
  configurable: true,
117
121
  writable: true,
118
- value: suffix
122
+ value: 0
119
123
  });
120
- Object.defineProperty(this, "outputLen", {
124
+ Object.defineProperty(this, "posOut", {
121
125
  enumerable: true,
122
126
  configurable: true,
123
127
  writable: true,
124
- value: outputLen
128
+ value: 0
125
129
  });
126
- Object.defineProperty(this, "enableXOF", {
130
+ Object.defineProperty(this, "finished", {
127
131
  enumerable: true,
128
132
  configurable: true,
129
133
  writable: true,
130
- value: enableXOF
134
+ value: false
131
135
  });
132
- Object.defineProperty(this, "rounds", {
136
+ Object.defineProperty(this, "state32", {
133
137
  enumerable: true,
134
138
  configurable: true,
135
139
  writable: true,
136
- value: rounds
140
+ value: void 0
137
141
  });
138
- Object.defineProperty(this, "state", {
142
+ Object.defineProperty(this, "destroyed", {
139
143
  enumerable: true,
140
144
  configurable: true,
141
145
  writable: true,
142
- value: void 0
146
+ value: false
143
147
  });
144
- Object.defineProperty(this, "pos", {
148
+ Object.defineProperty(this, "blockLen", {
145
149
  enumerable: true,
146
150
  configurable: true,
147
151
  writable: true,
148
- value: 0
152
+ value: void 0
149
153
  });
150
- Object.defineProperty(this, "posOut", {
154
+ Object.defineProperty(this, "suffix", {
151
155
  enumerable: true,
152
156
  configurable: true,
153
157
  writable: true,
154
- value: 0
158
+ value: void 0
155
159
  });
156
- Object.defineProperty(this, "finished", {
160
+ Object.defineProperty(this, "outputLen", {
157
161
  enumerable: true,
158
162
  configurable: true,
159
163
  writable: true,
160
- value: false
164
+ value: void 0
161
165
  });
162
- Object.defineProperty(this, "state32", {
166
+ Object.defineProperty(this, "enableXOF", {
163
167
  enumerable: true,
164
168
  configurable: true,
165
169
  writable: true,
166
- value: void 0
170
+ value: false
167
171
  });
168
- Object.defineProperty(this, "destroyed", {
172
+ Object.defineProperty(this, "rounds", {
169
173
  enumerable: true,
170
174
  configurable: true,
171
175
  writable: true,
172
- value: false
176
+ value: void 0
173
177
  });
178
+ this.blockLen = blockLen;
179
+ this.suffix = suffix;
180
+ this.outputLen = outputLen;
181
+ this.enableXOF = enableXOF;
182
+ this.rounds = rounds;
174
183
  // Can be passed from user as dkLen
175
- (0, _assert_js_1.anumber)(outputLen);
184
+ (0, utils_js_1.anumber)(outputLen);
176
185
  // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
177
186
  // 0 < blockLen < 200
178
- if (0 >= this.blockLen || this.blockLen >= 200)
179
- throw new Error('Sha3 supports only keccak-f1600 function');
187
+ if (!(0 < blockLen && blockLen < 200))
188
+ throw new Error('only keccak-f1600 function is supported');
180
189
  this.state = new Uint8Array(200);
181
190
  this.state32 = (0, utils_js_1.u32)(this.state);
182
191
  }
192
+ clone() {
193
+ return this._cloneInto();
194
+ }
183
195
  keccak() {
184
- if (!utils_js_1.isLE)
185
- (0, utils_js_1.byteSwap32)(this.state32);
196
+ (0, utils_js_1.swap32IfBE)(this.state32);
186
197
  keccakP(this.state32, this.rounds);
187
- if (!utils_js_1.isLE)
188
- (0, utils_js_1.byteSwap32)(this.state32);
198
+ (0, utils_js_1.swap32IfBE)(this.state32);
189
199
  this.posOut = 0;
190
200
  this.pos = 0;
191
201
  }
192
202
  update(data) {
193
- (0, _assert_js_1.aexists)(this);
194
- const { blockLen, state } = this;
203
+ (0, utils_js_1.aexists)(this);
195
204
  data = (0, utils_js_1.toBytes)(data);
205
+ (0, utils_js_1.abytes)(data);
206
+ const { blockLen, state } = this;
196
207
  const len = data.length;
197
208
  for (let pos = 0; pos < len;) {
198
209
  const take = Math.min(blockLen - this.pos, len - pos);
@@ -216,8 +227,8 @@
216
227
  this.keccak();
217
228
  }
218
229
  writeInto(out) {
219
- (0, _assert_js_1.aexists)(this, false);
220
- (0, _assert_js_1.abytes)(out);
230
+ (0, utils_js_1.aexists)(this, false);
231
+ (0, utils_js_1.abytes)(out);
221
232
  this.finish();
222
233
  const bufferOut = this.state;
223
234
  const { blockLen } = this;
@@ -238,11 +249,11 @@
238
249
  return this.writeInto(out);
239
250
  }
240
251
  xof(bytes) {
241
- (0, _assert_js_1.anumber)(bytes);
252
+ (0, utils_js_1.anumber)(bytes);
242
253
  return this.xofInto(new Uint8Array(bytes));
243
254
  }
244
255
  digestInto(out) {
245
- (0, _assert_js_1.aoutput)(out, this);
256
+ (0, utils_js_1.aoutput)(out, this);
246
257
  if (this.finished)
247
258
  throw new Error('digest() was already called');
248
259
  this.writeInto(out);
@@ -254,7 +265,7 @@
254
265
  }
255
266
  destroy() {
256
267
  this.destroyed = true;
257
- this.state.fill(0);
268
+ (0, utils_js_1.clean)(this.state);
258
269
  }
259
270
  _cloneInto(to) {
260
271
  const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
@@ -273,26 +284,26 @@
273
284
  }
274
285
  }
275
286
  exports.Keccak = Keccak;
276
- const gen = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructor)(() => new Keccak(blockLen, suffix, outputLen));
287
+ const gen = (suffix, blockLen, outputLen) => (0, utils_js_1.createHasher)(() => new Keccak(blockLen, suffix, outputLen));
277
288
  /** SHA3-224 hash function. */
278
- exports.sha3_224 = gen(0x06, 144, 224 / 8);
289
+ exports.sha3_224 = (() => gen(0x06, 144, 224 / 8))();
279
290
  /** SHA3-256 hash function. Different from keccak-256. */
280
- exports.sha3_256 = gen(0x06, 136, 256 / 8);
291
+ exports.sha3_256 = (() => gen(0x06, 136, 256 / 8))();
281
292
  /** SHA3-384 hash function. */
282
- exports.sha3_384 = gen(0x06, 104, 384 / 8);
293
+ exports.sha3_384 = (() => gen(0x06, 104, 384 / 8))();
283
294
  /** SHA3-512 hash function. */
284
- exports.sha3_512 = gen(0x06, 72, 512 / 8);
295
+ exports.sha3_512 = (() => gen(0x06, 72, 512 / 8))();
285
296
  /** keccak-224 hash function. */
286
- exports.keccak_224 = gen(0x01, 144, 224 / 8);
297
+ exports.keccak_224 = (() => gen(0x01, 144, 224 / 8))();
287
298
  /** keccak-256 hash function. Different from SHA3-256. */
288
- exports.keccak_256 = gen(0x01, 136, 256 / 8);
299
+ exports.keccak_256 = (() => gen(0x01, 136, 256 / 8))();
289
300
  /** keccak-384 hash function. */
290
- exports.keccak_384 = gen(0x01, 104, 384 / 8);
301
+ exports.keccak_384 = (() => gen(0x01, 104, 384 / 8))();
291
302
  /** keccak-512 hash function. */
292
- exports.keccak_512 = gen(0x01, 72, 512 / 8);
293
- const genShake = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapXOFConstructorWithOpts)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
303
+ exports.keccak_512 = (() => gen(0x01, 72, 512 / 8))();
304
+ const genShake = (suffix, blockLen, outputLen) => (0, utils_js_1.createXOFer)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));
294
305
  /** SHAKE128 XOF with 128-bit security. */
295
- exports.shake128 = genShake(0x1f, 168, 128 / 8);
306
+ exports.shake128 = (() => genShake(0x1f, 168, 128 / 8))();
296
307
  /** SHAKE256 XOF with 256-bit security. */
297
- exports.shake256 = genShake(0x1f, 136, 256 / 8);
308
+ exports.shake256 = (() => genShake(0x1f, 136, 256 / 8))();
298
309
  });
@@ -3,10 +3,27 @@
3
3
  * @module
4
4
  */
5
5
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
+ /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
6
7
  export declare function isBytes(a: unknown): a is Uint8Array;
8
+ /** Asserts something is positive integer. */
9
+ export declare function anumber(n: number): void;
10
+ /** Asserts something is Uint8Array. */
11
+ export declare function abytes(b: Uint8Array | undefined, ...lengths: number[]): void;
12
+ /** Asserts something is hash */
13
+ export declare function ahash(h: IHash): void;
14
+ /** Asserts a hash instance has not been destroyed / finished */
15
+ export declare function aexists(instance: any, checkFinished?: boolean): void;
16
+ /** Asserts output is properly-sized byte array */
17
+ export declare function aoutput(out: any, instance: any): void;
18
+ /** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */
7
19
  export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | Uint16Array | Int16Array | Uint32Array | Int32Array;
20
+ /** Cast u8 / u16 / u32 to u8. */
8
21
  export declare function u8(arr: TypedArray): Uint8Array;
22
+ /** Cast u8 / u16 / u32 to u32. */
9
23
  export declare function u32(arr: TypedArray): Uint32Array;
24
+ /** Zeroize a byte array. Warning: JS provides no guarantees. */
25
+ export declare function clean(...arrays: TypedArray[]): void;
26
+ /** Create DataView of an array for easy byte-level manipulation. */
10
27
  export declare function createView(arr: TypedArray): DataView;
11
28
  /** The rotate right (circular right shift) operation for uint32 */
12
29
  export declare function rotr(word: number, shift: number): number;
@@ -14,18 +31,22 @@ export declare function rotr(word: number, shift: number): number;
14
31
  export declare function rotl(word: number, shift: number): number;
15
32
  /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
16
33
  export declare const isLE: boolean;
34
+ /** The byte swap operation for uint32 */
17
35
  export declare function byteSwap(word: number): number;
18
36
  /** Conditionally byte swap if on a big-endian platform */
19
- export declare const byteSwapIfBE: (n: number) => number;
37
+ export declare const swap8IfBE: (n: number) => number;
38
+ /** @deprecated */
39
+ export declare const byteSwapIfBE: typeof swap8IfBE;
20
40
  /** In place byte swap for Uint32Array */
21
- export declare function byteSwap32(arr: Uint32Array): void;
41
+ export declare function byteSwap32(arr: Uint32Array): Uint32Array;
42
+ export declare const swap32IfBE: (u: Uint32Array) => Uint32Array;
22
43
  /**
23
- * Convert byte array to hex string.
44
+ * Convert byte array to hex string. Uses built-in function, when available.
24
45
  * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
25
46
  */
26
47
  export declare function bytesToHex(bytes: Uint8Array): string;
27
48
  /**
28
- * Convert hex string to byte array.
49
+ * Convert hex string to byte array. Uses built-in function, when available.
29
50
  * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
30
51
  */
31
52
  export declare function hexToBytes(hex: string): Uint8Array;
@@ -38,22 +59,41 @@ export declare const nextTick: () => Promise<void>;
38
59
  /** Returns control to thread each 'tick' ms to avoid blocking. */
39
60
  export declare function asyncLoop(iters: number, tick: number, cb: (i: number) => void): Promise<void>;
40
61
  /**
41
- * Convert JS string to byte array.
42
- * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
62
+ * Converts string to bytes using UTF8 encoding.
63
+ * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
43
64
  */
44
65
  export declare function utf8ToBytes(str: string): Uint8Array;
66
+ /**
67
+ * Converts bytes to string using UTF8 encoding.
68
+ * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'
69
+ */
70
+ export declare function bytesToUtf8(bytes: Uint8Array): string;
45
71
  /** Accepted input of hash functions. Strings are converted to byte arrays. */
46
- export type Input = Uint8Array | string;
72
+ export type Input = string | Uint8Array;
47
73
  /**
48
74
  * Normalizes (non-hex) string or Uint8Array to Uint8Array.
49
75
  * Warning: when Uint8Array is passed, it would NOT get copied.
50
76
  * Keep in mind for future mutable operations.
51
77
  */
52
78
  export declare function toBytes(data: Input): Uint8Array;
79
+ /** KDFs can accept string or Uint8Array for user convenience. */
80
+ export type KDFInput = string | Uint8Array;
53
81
  /**
54
- * Copies several Uint8Arrays into one.
82
+ * Helper for KDFs: consumes uint8array or string.
83
+ * When string is passed, does utf8 decoding, using TextDecoder.
55
84
  */
85
+ export declare function kdfInputToBytes(data: KDFInput): Uint8Array;
86
+ /** Copies several Uint8Arrays into one. */
56
87
  export declare function concatBytes(...arrays: Uint8Array[]): Uint8Array;
88
+ type EmptyObj = {};
89
+ export declare function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(defaults: T1, opts?: T2): T1 & T2;
90
+ /** Hash interface. */
91
+ export type IHash = {
92
+ (data: Uint8Array): Uint8Array;
93
+ blockLen: number;
94
+ outputLen: number;
95
+ create: any;
96
+ };
57
97
  /** For runtime check if class implements interface */
58
98
  export declare abstract class Hash<T extends Hash<T>> {
59
99
  abstract blockLen: number;
@@ -75,7 +115,7 @@ export declare abstract class Hash<T extends Hash<T>> {
75
115
  * There are no guarantees for clean-up because it's impossible in JS.
76
116
  */
77
117
  abstract _cloneInto(to?: T): T;
78
- clone(): T;
118
+ abstract clone(): T;
79
119
  }
80
120
  /**
81
121
  * XOF: streaming API to read digest in chunks.
@@ -87,33 +127,34 @@ export type HashXOF<T extends Hash<T>> = Hash<T> & {
87
127
  xof(bytes: number): Uint8Array;
88
128
  xofInto(buf: Uint8Array): Uint8Array;
89
129
  };
90
- type EmptyObj = {};
91
- export declare function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(defaults: T1, opts?: T2): T1 & T2;
92
130
  /** Hash function */
93
- export type CHash = ReturnType<typeof wrapConstructor>;
131
+ export type CHash = ReturnType<typeof createHasher>;
94
132
  /** Hash function with output */
95
- export type CHashO = ReturnType<typeof wrapConstructorWithOpts>;
133
+ export type CHashO = ReturnType<typeof createOptHasher>;
96
134
  /** XOF with output */
97
- export type CHashXO = ReturnType<typeof wrapXOFConstructorWithOpts>;
135
+ export type CHashXO = ReturnType<typeof createXOFer>;
98
136
  /** Wraps hash function, creating an interface on top of it */
99
- export declare function wrapConstructor<T extends Hash<T>>(hashCons: () => Hash<T>): {
137
+ export declare function createHasher<T extends Hash<T>>(hashCons: () => Hash<T>): {
100
138
  (msg: Input): Uint8Array;
101
139
  outputLen: number;
102
140
  blockLen: number;
103
141
  create(): Hash<T>;
104
142
  };
105
- export declare function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(hashCons: (opts?: T) => Hash<H>): {
143
+ export declare function createOptHasher<H extends Hash<H>, T extends Object>(hashCons: (opts?: T) => Hash<H>): {
106
144
  (msg: Input, opts?: T): Uint8Array;
107
145
  outputLen: number;
108
146
  blockLen: number;
109
- create(opts: T): Hash<H>;
147
+ create(opts?: T): Hash<H>;
110
148
  };
111
- export declare function wrapXOFConstructorWithOpts<H extends HashXOF<H>, T extends Object>(hashCons: (opts?: T) => HashXOF<H>): {
149
+ export declare function createXOFer<H extends HashXOF<H>, T extends Object>(hashCons: (opts?: T) => HashXOF<H>): {
112
150
  (msg: Input, opts?: T): Uint8Array;
113
151
  outputLen: number;
114
152
  blockLen: number;
115
- create(opts: T): HashXOF<H>;
153
+ create(opts?: T): HashXOF<H>;
116
154
  };
155
+ export declare const wrapConstructor: typeof createHasher;
156
+ export declare const wrapConstructorWithOpts: typeof createOptHasher;
157
+ export declare const wrapXOFConstructorWithOpts: typeof createXOFer;
117
158
  /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
118
159
  export declare function randomBytes(bytesLength?: number): Uint8Array;
119
160
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@noble/hashes/1.8.0/src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,sEAAsE;AAUtE,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAEnD;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAEvC;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAI5E;AAED,gCAAgC;AAChC,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAKpC;AAED,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,UAAO,GAAG,IAAI,CAGjE;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAMrD;AAED,uEAAuE;AAEvE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,iBAAiB,GAAG,UAAU,GACjE,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtD,iCAAiC;AACjC,wBAAgB,EAAE,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAE9C;AAED,kCAAkC;AAClC,wBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAEhD;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,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