@langchain/core 0.3.59 → 0.3.61

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 (98) hide show
  1. package/dist/caches/base.cjs +28 -5
  2. package/dist/caches/base.d.ts +13 -1
  3. package/dist/caches/base.js +25 -2
  4. package/dist/callbacks/base.cjs +19 -9
  5. package/dist/callbacks/base.d.ts +37 -22
  6. package/dist/callbacks/dispatch/index.cjs +1 -2
  7. package/dist/callbacks/dispatch/web.cjs +1 -2
  8. package/dist/callbacks/manager.cjs +4 -4
  9. package/dist/callbacks/manager.d.ts +2 -2
  10. package/dist/errors/index.cjs +1 -2
  11. package/dist/example_selectors/conditional.cjs +3 -3
  12. package/dist/indexing/base.cjs +19 -7
  13. package/dist/indexing/base.d.ts +3 -0
  14. package/dist/indexing/base.js +14 -2
  15. package/dist/language_models/base.cjs +2 -2
  16. package/dist/language_models/chat_models.cjs +2 -2
  17. package/dist/load/import_map.cjs +17 -7
  18. package/dist/load/index.cjs +18 -9
  19. package/dist/load/map_keys.cjs +3 -4
  20. package/dist/load/serializable.cjs +2 -2
  21. package/dist/memory.cjs +2 -2
  22. package/dist/messages/ai.cjs +3 -3
  23. package/dist/messages/base.cjs +10 -10
  24. package/dist/messages/chat.cjs +3 -3
  25. package/dist/messages/content_blocks.cjs +9 -10
  26. package/dist/messages/function.cjs +3 -3
  27. package/dist/messages/human.cjs +3 -3
  28. package/dist/messages/system.cjs +3 -3
  29. package/dist/messages/tool.cjs +5 -5
  30. package/dist/messages/transformers.cjs +4 -5
  31. package/dist/messages/utils.cjs +6 -7
  32. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +4 -4
  33. package/dist/output_parsers/xml.cjs +2 -2
  34. package/dist/prompts/base.cjs +36 -3
  35. package/dist/runnables/base.cjs +7 -5
  36. package/dist/runnables/base.d.ts +1 -1
  37. package/dist/runnables/base.js +3 -1
  38. package/dist/runnables/config.cjs +6 -6
  39. package/dist/runnables/graph_mermaid.cjs +2 -3
  40. package/dist/runnables/iter.cjs +5 -5
  41. package/dist/runnables/iter.d.ts +1 -1
  42. package/dist/runnables/utils.cjs +2 -2
  43. package/dist/runnables/wrappers.cjs +1 -2
  44. package/dist/runnables/wrappers.d.ts +1 -1
  45. package/dist/singletons/async_local_storage/context.cjs +3 -3
  46. package/dist/singletons/callbacks.cjs +3 -4
  47. package/dist/singletons/callbacks.d.ts +1 -1
  48. package/dist/structured_query/utils.cjs +7 -8
  49. package/dist/tools/index.cjs +2 -2
  50. package/dist/tools/types.cjs +4 -5
  51. package/dist/tools/utils.cjs +3 -3
  52. package/dist/tracers/base.cjs +2 -2
  53. package/dist/tracers/base.d.ts +84 -84
  54. package/dist/tracers/initialize.cjs +2 -3
  55. package/dist/utils/async_caller.cjs +9 -9
  56. package/dist/utils/async_caller.js +9 -9
  57. package/dist/utils/env.cjs +4 -4
  58. package/dist/utils/event_source_parse.cjs +5 -5
  59. package/dist/utils/fast-json-patch/index.cjs +17 -7
  60. package/dist/utils/fast-json-patch/index.d.ts +4 -4
  61. package/dist/utils/fast-json-patch/src/core.cjs +8 -8
  62. package/dist/utils/fast-json-patch/src/duplex.cjs +4 -5
  63. package/dist/utils/fast-json-patch/src/helpers.cjs +10 -10
  64. package/dist/utils/fast-json-patch/src/helpers.d.ts +3 -3
  65. package/dist/utils/function_calling.cjs +3 -3
  66. package/dist/utils/hash.cjs +3 -1
  67. package/dist/utils/hash.d.ts +7 -0
  68. package/dist/utils/hash.js +1 -0
  69. package/dist/utils/js-sha1/hash.cjs +17 -0
  70. package/dist/utils/js-sha1/hash.d.ts +4 -0
  71. package/dist/utils/js-sha1/hash.js +17 -0
  72. package/dist/utils/js-sha256/hash.cjs +448 -0
  73. package/dist/utils/js-sha256/hash.d.ts +1 -0
  74. package/dist/utils/js-sha256/hash.js +445 -0
  75. package/dist/utils/json.cjs +2 -3
  76. package/dist/utils/json_schema.cjs +11 -4
  77. package/dist/utils/json_schema.js +9 -2
  78. package/dist/utils/math.cjs +6 -7
  79. package/dist/utils/ml-distance/distances.cjs +1 -2
  80. package/dist/utils/ml-distance/similarities.cjs +1 -2
  81. package/dist/utils/ml-distance-euclidean/euclidean.cjs +2 -3
  82. package/dist/utils/sax-js/sax.cjs +35 -35
  83. package/dist/utils/sax-js/sax.js +35 -35
  84. package/dist/utils/signal.cjs +1 -2
  85. package/dist/utils/stream.cjs +4 -4
  86. package/dist/utils/tiktoken.cjs +2 -3
  87. package/dist/utils/types/zod.cjs +251 -56
  88. package/dist/utils/types/zod.d.ts +40 -1
  89. package/dist/utils/types/zod.js +230 -39
  90. package/package.json +30 -4
  91. package/utils/hash/insecure.cjs +1 -0
  92. package/utils/hash/insecure.d.cts +1 -0
  93. package/utils/hash/insecure.d.ts +1 -0
  94. package/utils/hash/insecure.js +1 -0
  95. package/utils/hash/sha256.cjs +1 -0
  96. package/utils/hash/sha256.d.cts +1 -0
  97. package/utils/hash/sha256.d.ts +1 -0
  98. package/utils/hash/sha256.js +1 -0
@@ -0,0 +1,448 @@
1
+ // @ts-nocheck
2
+ // Inlined to deal with portability issues with importing crypto module
3
+ /**
4
+ * [js-sha256]{@link https://github.com/emn178/js-sha256}
5
+ *
6
+ * @version 0.11.1
7
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
8
+ * @copyright Chen, Yi-Cyuan 2014-2025
9
+ * @license MIT
10
+ */
11
+ /*jslint bitwise: true */
12
+ "use strict";
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.sha256 = void 0;
15
+ var HEX_CHARS = "0123456789abcdef".split("");
16
+ var EXTRA = [-2147483648, 8388608, 32768, 128];
17
+ var SHIFT = [24, 16, 8, 0];
18
+ var K = [
19
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
20
+ 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
21
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
22
+ 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
23
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
24
+ 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
25
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
26
+ 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
27
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
28
+ 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
29
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
30
+ ];
31
+ var OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"];
32
+ var blocks = [];
33
+ function Sha256(is224, sharedMemory) {
34
+ if (sharedMemory) {
35
+ blocks[0] =
36
+ blocks[16] =
37
+ blocks[1] =
38
+ blocks[2] =
39
+ blocks[3] =
40
+ blocks[4] =
41
+ blocks[5] =
42
+ blocks[6] =
43
+ blocks[7] =
44
+ blocks[8] =
45
+ blocks[9] =
46
+ blocks[10] =
47
+ blocks[11] =
48
+ blocks[12] =
49
+ blocks[13] =
50
+ blocks[14] =
51
+ blocks[15] =
52
+ 0;
53
+ this.blocks = blocks;
54
+ }
55
+ else {
56
+ this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
57
+ }
58
+ if (is224) {
59
+ this.h0 = 0xc1059ed8;
60
+ this.h1 = 0x367cd507;
61
+ this.h2 = 0x3070dd17;
62
+ this.h3 = 0xf70e5939;
63
+ this.h4 = 0xffc00b31;
64
+ this.h5 = 0x68581511;
65
+ this.h6 = 0x64f98fa7;
66
+ this.h7 = 0xbefa4fa4;
67
+ }
68
+ else {
69
+ // 256
70
+ this.h0 = 0x6a09e667;
71
+ this.h1 = 0xbb67ae85;
72
+ this.h2 = 0x3c6ef372;
73
+ this.h3 = 0xa54ff53a;
74
+ this.h4 = 0x510e527f;
75
+ this.h5 = 0x9b05688c;
76
+ this.h6 = 0x1f83d9ab;
77
+ this.h7 = 0x5be0cd19;
78
+ }
79
+ this.block = this.start = this.bytes = this.hBytes = 0;
80
+ this.finalized = this.hashed = false;
81
+ this.first = true;
82
+ this.is224 = is224;
83
+ }
84
+ Sha256.prototype.update = function (message) {
85
+ if (this.finalized) {
86
+ return;
87
+ }
88
+ var notString, type = typeof message;
89
+ if (type !== "string") {
90
+ if (type === "object") {
91
+ if (message === null) {
92
+ throw new Error(ERROR);
93
+ }
94
+ else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
95
+ message = new Uint8Array(message);
96
+ }
97
+ else if (!Array.isArray(message)) {
98
+ if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
99
+ throw new Error(ERROR);
100
+ }
101
+ }
102
+ }
103
+ else {
104
+ throw new Error(ERROR);
105
+ }
106
+ notString = true;
107
+ }
108
+ var code, index = 0, i, length = message.length, blocks = this.blocks;
109
+ while (index < length) {
110
+ if (this.hashed) {
111
+ this.hashed = false;
112
+ blocks[0] = this.block;
113
+ this.block =
114
+ blocks[16] =
115
+ blocks[1] =
116
+ blocks[2] =
117
+ blocks[3] =
118
+ blocks[4] =
119
+ blocks[5] =
120
+ blocks[6] =
121
+ blocks[7] =
122
+ blocks[8] =
123
+ blocks[9] =
124
+ blocks[10] =
125
+ blocks[11] =
126
+ blocks[12] =
127
+ blocks[13] =
128
+ blocks[14] =
129
+ blocks[15] =
130
+ 0;
131
+ }
132
+ if (notString) {
133
+ for (i = this.start; index < length && i < 64; ++index) {
134
+ blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];
135
+ }
136
+ }
137
+ else {
138
+ for (i = this.start; index < length && i < 64; ++index) {
139
+ code = message.charCodeAt(index);
140
+ if (code < 0x80) {
141
+ blocks[i >>> 2] |= code << SHIFT[i++ & 3];
142
+ }
143
+ else if (code < 0x800) {
144
+ blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];
145
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
146
+ }
147
+ else if (code < 0xd800 || code >= 0xe000) {
148
+ blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
149
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
150
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
151
+ }
152
+ else {
153
+ code =
154
+ 0x10000 +
155
+ (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
156
+ blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
157
+ blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
158
+ blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
159
+ blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
160
+ }
161
+ }
162
+ }
163
+ this.lastByteIndex = i;
164
+ this.bytes += i - this.start;
165
+ if (i >= 64) {
166
+ this.block = blocks[16];
167
+ this.start = i - 64;
168
+ this.hash();
169
+ this.hashed = true;
170
+ }
171
+ else {
172
+ this.start = i;
173
+ }
174
+ }
175
+ if (this.bytes > 4294967295) {
176
+ this.hBytes += (this.bytes / 4294967296) << 0;
177
+ this.bytes = this.bytes % 4294967296;
178
+ }
179
+ return this;
180
+ };
181
+ Sha256.prototype.finalize = function () {
182
+ if (this.finalized) {
183
+ return;
184
+ }
185
+ this.finalized = true;
186
+ var blocks = this.blocks, i = this.lastByteIndex;
187
+ blocks[16] = this.block;
188
+ blocks[i >>> 2] |= EXTRA[i & 3];
189
+ this.block = blocks[16];
190
+ if (i >= 56) {
191
+ if (!this.hashed) {
192
+ this.hash();
193
+ }
194
+ blocks[0] = this.block;
195
+ blocks[16] =
196
+ blocks[1] =
197
+ blocks[2] =
198
+ blocks[3] =
199
+ blocks[4] =
200
+ blocks[5] =
201
+ blocks[6] =
202
+ blocks[7] =
203
+ blocks[8] =
204
+ blocks[9] =
205
+ blocks[10] =
206
+ blocks[11] =
207
+ blocks[12] =
208
+ blocks[13] =
209
+ blocks[14] =
210
+ blocks[15] =
211
+ 0;
212
+ }
213
+ blocks[14] = (this.hBytes << 3) | (this.bytes >>> 29);
214
+ blocks[15] = this.bytes << 3;
215
+ this.hash();
216
+ };
217
+ Sha256.prototype.hash = function () {
218
+ var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc;
219
+ for (j = 16; j < 64; ++j) {
220
+ // rightrotate
221
+ t1 = blocks[j - 15];
222
+ s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
223
+ t1 = blocks[j - 2];
224
+ s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
225
+ blocks[j] = (blocks[j - 16] + s0 + blocks[j - 7] + s1) << 0;
226
+ }
227
+ bc = b & c;
228
+ for (j = 0; j < 64; j += 4) {
229
+ if (this.first) {
230
+ if (this.is224) {
231
+ ab = 300032;
232
+ t1 = blocks[0] - 1413257819;
233
+ h = (t1 - 150054599) << 0;
234
+ d = (t1 + 24177077) << 0;
235
+ }
236
+ else {
237
+ ab = 704751109;
238
+ t1 = blocks[0] - 210244248;
239
+ h = (t1 - 1521486534) << 0;
240
+ d = (t1 + 143694565) << 0;
241
+ }
242
+ this.first = false;
243
+ }
244
+ else {
245
+ s0 =
246
+ ((a >>> 2) | (a << 30)) ^
247
+ ((a >>> 13) | (a << 19)) ^
248
+ ((a >>> 22) | (a << 10));
249
+ s1 =
250
+ ((e >>> 6) | (e << 26)) ^
251
+ ((e >>> 11) | (e << 21)) ^
252
+ ((e >>> 25) | (e << 7));
253
+ ab = a & b;
254
+ maj = ab ^ (a & c) ^ bc;
255
+ ch = (e & f) ^ (~e & g);
256
+ t1 = h + s1 + ch + K[j] + blocks[j];
257
+ t2 = s0 + maj;
258
+ h = (d + t1) << 0;
259
+ d = (t1 + t2) << 0;
260
+ }
261
+ s0 =
262
+ ((d >>> 2) | (d << 30)) ^
263
+ ((d >>> 13) | (d << 19)) ^
264
+ ((d >>> 22) | (d << 10));
265
+ s1 =
266
+ ((h >>> 6) | (h << 26)) ^
267
+ ((h >>> 11) | (h << 21)) ^
268
+ ((h >>> 25) | (h << 7));
269
+ da = d & a;
270
+ maj = da ^ (d & b) ^ ab;
271
+ ch = (g & h) ^ (~g & e);
272
+ t1 = f + s1 + ch + K[j + 1] + blocks[j + 1];
273
+ t2 = s0 + maj;
274
+ g = (c + t1) << 0;
275
+ c = (t1 + t2) << 0;
276
+ s0 =
277
+ ((c >>> 2) | (c << 30)) ^
278
+ ((c >>> 13) | (c << 19)) ^
279
+ ((c >>> 22) | (c << 10));
280
+ s1 =
281
+ ((g >>> 6) | (g << 26)) ^
282
+ ((g >>> 11) | (g << 21)) ^
283
+ ((g >>> 25) | (g << 7));
284
+ cd = c & d;
285
+ maj = cd ^ (c & a) ^ da;
286
+ ch = (f & g) ^ (~f & h);
287
+ t1 = e + s1 + ch + K[j + 2] + blocks[j + 2];
288
+ t2 = s0 + maj;
289
+ f = (b + t1) << 0;
290
+ b = (t1 + t2) << 0;
291
+ s0 =
292
+ ((b >>> 2) | (b << 30)) ^
293
+ ((b >>> 13) | (b << 19)) ^
294
+ ((b >>> 22) | (b << 10));
295
+ s1 =
296
+ ((f >>> 6) | (f << 26)) ^
297
+ ((f >>> 11) | (f << 21)) ^
298
+ ((f >>> 25) | (f << 7));
299
+ bc = b & c;
300
+ maj = bc ^ (b & d) ^ cd;
301
+ ch = (f & g) ^ (~f & h);
302
+ t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];
303
+ t2 = s0 + maj;
304
+ e = (a + t1) << 0;
305
+ a = (t1 + t2) << 0;
306
+ this.chromeBugWorkAround = true;
307
+ }
308
+ this.h0 = (this.h0 + a) << 0;
309
+ this.h1 = (this.h1 + b) << 0;
310
+ this.h2 = (this.h2 + c) << 0;
311
+ this.h3 = (this.h3 + d) << 0;
312
+ this.h4 = (this.h4 + e) << 0;
313
+ this.h5 = (this.h5 + f) << 0;
314
+ this.h6 = (this.h6 + g) << 0;
315
+ this.h7 = (this.h7 + h) << 0;
316
+ };
317
+ Sha256.prototype.hex = function () {
318
+ this.finalize();
319
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7;
320
+ var hex = HEX_CHARS[(h0 >>> 28) & 0x0f] +
321
+ HEX_CHARS[(h0 >>> 24) & 0x0f] +
322
+ HEX_CHARS[(h0 >>> 20) & 0x0f] +
323
+ HEX_CHARS[(h0 >>> 16) & 0x0f] +
324
+ HEX_CHARS[(h0 >>> 12) & 0x0f] +
325
+ HEX_CHARS[(h0 >>> 8) & 0x0f] +
326
+ HEX_CHARS[(h0 >>> 4) & 0x0f] +
327
+ HEX_CHARS[h0 & 0x0f] +
328
+ HEX_CHARS[(h1 >>> 28) & 0x0f] +
329
+ HEX_CHARS[(h1 >>> 24) & 0x0f] +
330
+ HEX_CHARS[(h1 >>> 20) & 0x0f] +
331
+ HEX_CHARS[(h1 >>> 16) & 0x0f] +
332
+ HEX_CHARS[(h1 >>> 12) & 0x0f] +
333
+ HEX_CHARS[(h1 >>> 8) & 0x0f] +
334
+ HEX_CHARS[(h1 >>> 4) & 0x0f] +
335
+ HEX_CHARS[h1 & 0x0f] +
336
+ HEX_CHARS[(h2 >>> 28) & 0x0f] +
337
+ HEX_CHARS[(h2 >>> 24) & 0x0f] +
338
+ HEX_CHARS[(h2 >>> 20) & 0x0f] +
339
+ HEX_CHARS[(h2 >>> 16) & 0x0f] +
340
+ HEX_CHARS[(h2 >>> 12) & 0x0f] +
341
+ HEX_CHARS[(h2 >>> 8) & 0x0f] +
342
+ HEX_CHARS[(h2 >>> 4) & 0x0f] +
343
+ HEX_CHARS[h2 & 0x0f] +
344
+ HEX_CHARS[(h3 >>> 28) & 0x0f] +
345
+ HEX_CHARS[(h3 >>> 24) & 0x0f] +
346
+ HEX_CHARS[(h3 >>> 20) & 0x0f] +
347
+ HEX_CHARS[(h3 >>> 16) & 0x0f] +
348
+ HEX_CHARS[(h3 >>> 12) & 0x0f] +
349
+ HEX_CHARS[(h3 >>> 8) & 0x0f] +
350
+ HEX_CHARS[(h3 >>> 4) & 0x0f] +
351
+ HEX_CHARS[h3 & 0x0f] +
352
+ HEX_CHARS[(h4 >>> 28) & 0x0f] +
353
+ HEX_CHARS[(h4 >>> 24) & 0x0f] +
354
+ HEX_CHARS[(h4 >>> 20) & 0x0f] +
355
+ HEX_CHARS[(h4 >>> 16) & 0x0f] +
356
+ HEX_CHARS[(h4 >>> 12) & 0x0f] +
357
+ HEX_CHARS[(h4 >>> 8) & 0x0f] +
358
+ HEX_CHARS[(h4 >>> 4) & 0x0f] +
359
+ HEX_CHARS[h4 & 0x0f] +
360
+ HEX_CHARS[(h5 >>> 28) & 0x0f] +
361
+ HEX_CHARS[(h5 >>> 24) & 0x0f] +
362
+ HEX_CHARS[(h5 >>> 20) & 0x0f] +
363
+ HEX_CHARS[(h5 >>> 16) & 0x0f] +
364
+ HEX_CHARS[(h5 >>> 12) & 0x0f] +
365
+ HEX_CHARS[(h5 >>> 8) & 0x0f] +
366
+ HEX_CHARS[(h5 >>> 4) & 0x0f] +
367
+ HEX_CHARS[h5 & 0x0f] +
368
+ HEX_CHARS[(h6 >>> 28) & 0x0f] +
369
+ HEX_CHARS[(h6 >>> 24) & 0x0f] +
370
+ HEX_CHARS[(h6 >>> 20) & 0x0f] +
371
+ HEX_CHARS[(h6 >>> 16) & 0x0f] +
372
+ HEX_CHARS[(h6 >>> 12) & 0x0f] +
373
+ HEX_CHARS[(h6 >>> 8) & 0x0f] +
374
+ HEX_CHARS[(h6 >>> 4) & 0x0f] +
375
+ HEX_CHARS[h6 & 0x0f];
376
+ if (!this.is224) {
377
+ hex +=
378
+ HEX_CHARS[(h7 >>> 28) & 0x0f] +
379
+ HEX_CHARS[(h7 >>> 24) & 0x0f] +
380
+ HEX_CHARS[(h7 >>> 20) & 0x0f] +
381
+ HEX_CHARS[(h7 >>> 16) & 0x0f] +
382
+ HEX_CHARS[(h7 >>> 12) & 0x0f] +
383
+ HEX_CHARS[(h7 >>> 8) & 0x0f] +
384
+ HEX_CHARS[(h7 >>> 4) & 0x0f] +
385
+ HEX_CHARS[h7 & 0x0f];
386
+ }
387
+ return hex;
388
+ };
389
+ Sha256.prototype.toString = Sha256.prototype.hex;
390
+ Sha256.prototype.digest = function () {
391
+ this.finalize();
392
+ var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, h6 = this.h6, h7 = this.h7;
393
+ var arr = [
394
+ (h0 >>> 24) & 0xff,
395
+ (h0 >>> 16) & 0xff,
396
+ (h0 >>> 8) & 0xff,
397
+ h0 & 0xff,
398
+ (h1 >>> 24) & 0xff,
399
+ (h1 >>> 16) & 0xff,
400
+ (h1 >>> 8) & 0xff,
401
+ h1 & 0xff,
402
+ (h2 >>> 24) & 0xff,
403
+ (h2 >>> 16) & 0xff,
404
+ (h2 >>> 8) & 0xff,
405
+ h2 & 0xff,
406
+ (h3 >>> 24) & 0xff,
407
+ (h3 >>> 16) & 0xff,
408
+ (h3 >>> 8) & 0xff,
409
+ h3 & 0xff,
410
+ (h4 >>> 24) & 0xff,
411
+ (h4 >>> 16) & 0xff,
412
+ (h4 >>> 8) & 0xff,
413
+ h4 & 0xff,
414
+ (h5 >>> 24) & 0xff,
415
+ (h5 >>> 16) & 0xff,
416
+ (h5 >>> 8) & 0xff,
417
+ h5 & 0xff,
418
+ (h6 >>> 24) & 0xff,
419
+ (h6 >>> 16) & 0xff,
420
+ (h6 >>> 8) & 0xff,
421
+ h6 & 0xff,
422
+ ];
423
+ if (!this.is224) {
424
+ arr.push((h7 >>> 24) & 0xff, (h7 >>> 16) & 0xff, (h7 >>> 8) & 0xff, h7 & 0xff);
425
+ }
426
+ return arr;
427
+ };
428
+ Sha256.prototype.array = Sha256.prototype.digest;
429
+ Sha256.prototype.arrayBuffer = function () {
430
+ this.finalize();
431
+ var buffer = new ArrayBuffer(this.is224 ? 28 : 32);
432
+ var dataView = new DataView(buffer);
433
+ dataView.setUint32(0, this.h0);
434
+ dataView.setUint32(4, this.h1);
435
+ dataView.setUint32(8, this.h2);
436
+ dataView.setUint32(12, this.h3);
437
+ dataView.setUint32(16, this.h4);
438
+ dataView.setUint32(20, this.h5);
439
+ dataView.setUint32(24, this.h6);
440
+ if (!this.is224) {
441
+ dataView.setUint32(28, this.h7);
442
+ }
443
+ return buffer;
444
+ };
445
+ const sha256 = (...strings) => {
446
+ return new Sha256(false, true).update(strings.join("")).hex();
447
+ };
448
+ exports.sha256 = sha256;
@@ -0,0 +1 @@
1
+ export declare const sha256: (...strings: string[]) => any;