@langchain/core 1.2.9 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/callbacks/dispatch/index.cjs +2 -1
- package/dist/callbacks/dispatch/index.cjs.map +1 -1
- package/dist/callbacks/dispatch/index.js +2 -1
- package/dist/callbacks/dispatch/index.js.map +1 -1
- package/dist/indexing/base.cjs +10 -6
- package/dist/indexing/base.cjs.map +1 -1
- package/dist/indexing/base.js +10 -6
- package/dist/indexing/base.js.map +1 -1
- package/dist/language_models/base.cjs +1 -1
- package/dist/language_models/base.cjs.map +1 -1
- package/dist/language_models/base.js +1 -1
- package/dist/language_models/base.js.map +1 -1
- package/dist/language_models/chat_models.cjs +22 -17
- package/dist/language_models/chat_models.cjs.map +1 -1
- package/dist/language_models/chat_models.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/language_models/chat_models.js +23 -18
- package/dist/language_models/chat_models.js.map +1 -1
- package/dist/language_models/stream.cjs +0 -2
- package/dist/language_models/stream.cjs.map +1 -1
- package/dist/language_models/stream.js +0 -2
- package/dist/language_models/stream.js.map +1 -1
- package/dist/load/index.cjs +7 -5
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.js +7 -5
- package/dist/load/index.js.map +1 -1
- package/dist/load/serializable.cjs +2 -1
- package/dist/load/serializable.cjs.map +1 -1
- package/dist/load/serializable.js +2 -1
- package/dist/load/serializable.js.map +1 -1
- package/dist/load/validation.cjs +4 -3
- package/dist/load/validation.cjs.map +1 -1
- package/dist/load/validation.js +4 -3
- package/dist/load/validation.js.map +1 -1
- package/dist/messages/base.cjs +13 -18
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +13 -18
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/block_translators/anthropic.cjs.map +1 -1
- package/dist/messages/block_translators/anthropic.js.map +1 -1
- package/dist/messages/block_translators/google.cjs +10 -9
- package/dist/messages/block_translators/google.cjs.map +1 -1
- package/dist/messages/block_translators/google.js +10 -9
- package/dist/messages/block_translators/google.js.map +1 -1
- package/dist/messages/block_translators/google_vertexai.cjs +14 -12
- package/dist/messages/block_translators/google_vertexai.cjs.map +1 -1
- package/dist/messages/block_translators/google_vertexai.js +14 -12
- package/dist/messages/block_translators/google_vertexai.js.map +1 -1
- package/dist/messages/block_translators/openai.cjs +212 -164
- package/dist/messages/block_translators/openai.cjs.map +1 -1
- package/dist/messages/block_translators/openai.js +212 -164
- package/dist/messages/block_translators/openai.js.map +1 -1
- package/dist/messages/message.cjs.map +1 -1
- package/dist/messages/message.d.cts.map +1 -1
- package/dist/messages/message.d.ts.map +1 -1
- package/dist/messages/message.js.map +1 -1
- package/dist/messages/transformers.cjs +12 -8
- package/dist/messages/transformers.cjs.map +1 -1
- package/dist/messages/transformers.js +12 -8
- package/dist/messages/transformers.js.map +1 -1
- package/dist/output_parsers/transform.cjs.map +1 -1
- package/dist/prompts/chat.cjs +2 -1
- package/dist/prompts/chat.cjs.map +1 -1
- package/dist/prompts/chat.js +2 -1
- package/dist/prompts/chat.js.map +1 -1
- package/dist/prompts/few_shot.cjs +6 -4
- package/dist/prompts/few_shot.cjs.map +1 -1
- package/dist/prompts/few_shot.js +6 -4
- package/dist/prompts/few_shot.js.map +1 -1
- package/dist/prompts/image.cjs +2 -1
- package/dist/prompts/image.cjs.map +1 -1
- package/dist/prompts/image.js +2 -1
- package/dist/prompts/image.js.map +1 -1
- package/dist/prompts/prompt.cjs.map +1 -1
- package/dist/prompts/prompt.d.cts.map +1 -1
- package/dist/prompts/prompt.d.ts.map +1 -1
- package/dist/prompts/prompt.js.map +1 -1
- package/dist/prompts/string.cjs +2 -1
- package/dist/prompts/string.cjs.map +1 -1
- package/dist/prompts/string.js +2 -1
- package/dist/prompts/string.js.map +1 -1
- package/dist/prompts/template.cjs.map +1 -1
- package/dist/prompts/template.js.map +1 -1
- package/dist/runnables/base.cjs +60 -40
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.js +60 -40
- package/dist/runnables/base.js.map +1 -1
- package/dist/runnables/branch.cjs +16 -12
- package/dist/runnables/branch.cjs.map +1 -1
- package/dist/runnables/branch.js +16 -12
- package/dist/runnables/branch.js.map +1 -1
- package/dist/runnables/config.cjs +28 -23
- package/dist/runnables/config.cjs.map +1 -1
- package/dist/runnables/config.js +28 -23
- package/dist/runnables/config.js.map +1 -1
- package/dist/runnables/graph.cjs +2 -1
- package/dist/runnables/graph.cjs.map +1 -1
- package/dist/runnables/graph.js +2 -1
- package/dist/runnables/graph.js.map +1 -1
- package/dist/runnables/passthrough.cjs +8 -6
- package/dist/runnables/passthrough.cjs.map +1 -1
- package/dist/runnables/passthrough.js +8 -6
- package/dist/runnables/passthrough.js.map +1 -1
- package/dist/singletons/async_local_storage/context.cjs.map +1 -1
- package/dist/singletons/tracer.cjs +4 -1
- package/dist/singletons/tracer.cjs.map +1 -1
- package/dist/singletons/tracer.js +4 -1
- package/dist/singletons/tracer.js.map +1 -1
- package/dist/tools/index.cjs +22 -20
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +22 -20
- package/dist/tools/index.js.map +1 -1
- package/dist/tracers/base.cjs +11 -10
- package/dist/tracers/base.cjs.map +1 -1
- package/dist/tracers/base.js +11 -10
- package/dist/tracers/base.js.map +1 -1
- package/dist/tracers/log_stream.cjs +7 -6
- package/dist/tracers/log_stream.cjs.map +1 -1
- package/dist/tracers/log_stream.js +7 -6
- package/dist/tracers/log_stream.js.map +1 -1
- package/dist/tracers/tracer_langchain.cjs.map +1 -1
- package/dist/utils/env.cjs.map +1 -1
- package/dist/utils/env.d.cts.map +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/event_source_parse.cjs +1 -3
- package/dist/utils/event_source_parse.cjs.map +1 -1
- package/dist/utils/event_source_parse.js +1 -3
- package/dist/utils/event_source_parse.js.map +1 -1
- package/dist/utils/fast-json-patch/src/core.cjs +4 -2
- package/dist/utils/fast-json-patch/src/core.cjs.map +1 -1
- package/dist/utils/fast-json-patch/src/core.js +4 -2
- package/dist/utils/fast-json-patch/src/core.js.map +1 -1
- package/dist/utils/fast-json-patch/src/helpers.cjs.map +1 -1
- package/dist/utils/fast-json-patch/src/helpers.js.map +1 -1
- package/dist/utils/js-sha256/hash.cjs.map +1 -1
- package/dist/utils/js-sha256/hash.js.map +1 -1
- package/dist/utils/json_schema.cjs +4 -2
- package/dist/utils/json_schema.cjs.map +1 -1
- package/dist/utils/json_schema.js +4 -2
- package/dist/utils/json_schema.js.map +1 -1
- package/dist/utils/sax-js/sax.cjs +41 -35
- package/dist/utils/sax-js/sax.cjs.map +1 -1
- package/dist/utils/sax-js/sax.js +41 -35
- package/dist/utils/sax-js/sax.js.map +1 -1
- package/dist/utils/testing/chat_models.cjs +2 -1
- package/dist/utils/testing/chat_models.cjs.map +1 -1
- package/dist/utils/testing/chat_models.js +2 -1
- package/dist/utils/testing/chat_models.js.map +1 -1
- package/dist/utils/tiktoken.cjs.map +1 -1
- package/dist/utils/types/zod.cjs.map +1 -1
- package/dist/utils/types/zod.js.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +9 -9
- package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/bigint.js +9 -9
- package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/date.cjs +1 -3
- package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/date.js +1 -3
- package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/number.cjs +9 -9
- package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/number.js +9 -9
- package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/string.cjs +3 -13
- package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/string.js +3 -13
- package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","names":[],"sources":["../../../src/utils/js-sha256/hash.ts"],"sourcesContent":["// @ts-nocheck\n\n// Inlined to deal with portability issues with importing crypto module\n\n/**\n * [js-sha256]{@link https://github.com/emn178/js-sha256}\n *\n * @version 0.11.1\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2014-2025\n * @license MIT\n */\n/*jslint bitwise: true */\n\"use strict\";\n\nvar HEX_CHARS = \"0123456789abcdef\".split(\"\");\nvar EXTRA = [-2147483648, 8388608, 32768, 128];\nvar SHIFT = [24, 16, 8, 0];\nvar K = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,\n 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\n 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,\n 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,\n 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\n 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,\n 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,\n 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\n 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n];\nvar OUTPUT_TYPES = [\"hex\", \"array\", \"digest\", \"arrayBuffer\"];\n\nvar blocks = [];\n\nfunction Sha256(is224, sharedMemory) {\n if (sharedMemory) {\n blocks[0] =\n blocks[16] =\n blocks[1] =\n blocks[2] =\n blocks[3] =\n blocks[4] =\n blocks[5] =\n blocks[6] =\n blocks[7] =\n blocks[8] =\n blocks[9] =\n blocks[10] =\n blocks[11] =\n blocks[12] =\n blocks[13] =\n blocks[14] =\n blocks[15] =\n 0;\n this.blocks = blocks;\n } else {\n this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n }\n\n if (is224) {\n this.h0 = 0xc1059ed8;\n this.h1 = 0x367cd507;\n this.h2 = 0x3070dd17;\n this.h3 = 0xf70e5939;\n this.h4 = 0xffc00b31;\n this.h5 = 0x68581511;\n this.h6 = 0x64f98fa7;\n this.h7 = 0xbefa4fa4;\n } else {\n // 256\n this.h0 = 0x6a09e667;\n this.h1 = 0xbb67ae85;\n this.h2 = 0x3c6ef372;\n this.h3 = 0xa54ff53a;\n this.h4 = 0x510e527f;\n this.h5 = 0x9b05688c;\n this.h6 = 0x1f83d9ab;\n this.h7 = 0x5be0cd19;\n }\n\n this.block = this.start = this.bytes = this.hBytes = 0;\n this.finalized = this.hashed = false;\n this.first = true;\n this.is224 = is224;\n}\n\nSha256.prototype.update = function (message) {\n if (this.finalized) {\n return;\n }\n var notString,\n type = typeof message;\n if (type !== \"string\") {\n if (type === \"object\") {\n if (message === null) {\n throw new Error(ERROR);\n } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {\n message = new Uint8Array(message);\n } else if (!Array.isArray(message)) {\n if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {\n throw new Error(ERROR);\n }\n }\n } else {\n throw new Error(ERROR);\n }\n notString = true;\n }\n var code,\n index = 0,\n i,\n length = message.length,\n blocks = this.blocks;\n while (index < length) {\n if (this.hashed) {\n this.hashed = false;\n blocks[0] = this.block;\n this.block =\n blocks[16] =\n blocks[1] =\n blocks[2] =\n blocks[3] =\n blocks[4] =\n blocks[5] =\n blocks[6] =\n blocks[7] =\n blocks[8] =\n blocks[9] =\n blocks[10] =\n blocks[11] =\n blocks[12] =\n blocks[13] =\n blocks[14] =\n blocks[15] =\n 0;\n }\n\n if (notString) {\n for (i = this.start; index < length && i < 64; ++index) {\n blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];\n }\n } else {\n for (i = this.start; index < length && i < 64; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n blocks[i >>> 2] |= code << SHIFT[i++ & 3];\n } else if (code < 0x800) {\n blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else if (code < 0xd800 || code >= 0xe000) {\n blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else {\n code =\n 0x10000 +\n (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n }\n }\n }\n\n this.lastByteIndex = i;\n this.bytes += i - this.start;\n if (i >= 64) {\n this.block = blocks[16];\n this.start = i - 64;\n this.hash();\n this.hashed = true;\n } else {\n this.start = i;\n }\n }\n if (this.bytes > 4294967295) {\n this.hBytes += (this.bytes / 4294967296) << 0;\n this.bytes = this.bytes % 4294967296;\n }\n return this;\n};\n\nSha256.prototype.finalize = function () {\n if (this.finalized) {\n return;\n }\n this.finalized = true;\n var blocks = this.blocks,\n i = this.lastByteIndex;\n blocks[16] = this.block;\n blocks[i >>> 2] |= EXTRA[i & 3];\n this.block = blocks[16];\n if (i >= 56) {\n if (!this.hashed) {\n this.hash();\n }\n blocks[0] = this.block;\n blocks[16] =\n blocks[1] =\n blocks[2] =\n blocks[3] =\n blocks[4] =\n blocks[5] =\n blocks[6] =\n blocks[7] =\n blocks[8] =\n blocks[9] =\n blocks[10] =\n blocks[11] =\n blocks[12] =\n blocks[13] =\n blocks[14] =\n blocks[15] =\n 0;\n }\n blocks[14] = (this.hBytes << 3) | (this.bytes >>> 29);\n blocks[15] = this.bytes << 3;\n this.hash();\n};\n\nSha256.prototype.hash = function () {\n var a = this.h0,\n b = this.h1,\n c = this.h2,\n d = this.h3,\n e = this.h4,\n f = this.h5,\n g = this.h6,\n h = this.h7,\n blocks = this.blocks,\n j,\n s0,\n s1,\n maj,\n t1,\n t2,\n ch,\n ab,\n da,\n cd,\n bc;\n\n for (j = 16; j < 64; ++j) {\n // rightrotate\n t1 = blocks[j - 15];\n s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);\n t1 = blocks[j - 2];\n s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);\n blocks[j] = (blocks[j - 16] + s0 + blocks[j - 7] + s1) << 0;\n }\n\n bc = b & c;\n for (j = 0; j < 64; j += 4) {\n if (this.first) {\n if (this.is224) {\n ab = 300032;\n t1 = blocks[0] - 1413257819;\n h = (t1 - 150054599) << 0;\n d = (t1 + 24177077) << 0;\n } else {\n ab = 704751109;\n t1 = blocks[0] - 210244248;\n h = (t1 - 1521486534) << 0;\n d = (t1 + 143694565) << 0;\n }\n this.first = false;\n } else {\n s0 =\n ((a >>> 2) | (a << 30)) ^\n ((a >>> 13) | (a << 19)) ^\n ((a >>> 22) | (a << 10));\n s1 =\n ((e >>> 6) | (e << 26)) ^\n ((e >>> 11) | (e << 21)) ^\n ((e >>> 25) | (e << 7));\n ab = a & b;\n maj = ab ^ (a & c) ^ bc;\n ch = (e & f) ^ (~e & g);\n t1 = h + s1 + ch + K[j] + blocks[j];\n t2 = s0 + maj;\n h = (d + t1) << 0;\n d = (t1 + t2) << 0;\n }\n s0 =\n ((d >>> 2) | (d << 30)) ^\n ((d >>> 13) | (d << 19)) ^\n ((d >>> 22) | (d << 10));\n s1 =\n ((h >>> 6) | (h << 26)) ^\n ((h >>> 11) | (h << 21)) ^\n ((h >>> 25) | (h << 7));\n da = d & a;\n maj = da ^ (d & b) ^ ab;\n ch = (g & h) ^ (~g & e);\n t1 = f + s1 + ch + K[j + 1] + blocks[j + 1];\n t2 = s0 + maj;\n g = (c + t1) << 0;\n c = (t1 + t2) << 0;\n s0 =\n ((c >>> 2) | (c << 30)) ^\n ((c >>> 13) | (c << 19)) ^\n ((c >>> 22) | (c << 10));\n s1 =\n ((g >>> 6) | (g << 26)) ^\n ((g >>> 11) | (g << 21)) ^\n ((g >>> 25) | (g << 7));\n cd = c & d;\n maj = cd ^ (c & a) ^ da;\n ch = (f & g) ^ (~f & h);\n t1 = e + s1 + ch + K[j + 2] + blocks[j + 2];\n t2 = s0 + maj;\n f = (b + t1) << 0;\n b = (t1 + t2) << 0;\n s0 =\n ((b >>> 2) | (b << 30)) ^\n ((b >>> 13) | (b << 19)) ^\n ((b >>> 22) | (b << 10));\n s1 =\n ((f >>> 6) | (f << 26)) ^\n ((f >>> 11) | (f << 21)) ^\n ((f >>> 25) | (f << 7));\n bc = b & c;\n maj = bc ^ (b & d) ^ cd;\n ch = (f & g) ^ (~f & h);\n t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];\n t2 = s0 + maj;\n e = (a + t1) << 0;\n a = (t1 + t2) << 0;\n this.chromeBugWorkAround = true;\n }\n\n this.h0 = (this.h0 + a) << 0;\n this.h1 = (this.h1 + b) << 0;\n this.h2 = (this.h2 + c) << 0;\n this.h3 = (this.h3 + d) << 0;\n this.h4 = (this.h4 + e) << 0;\n this.h5 = (this.h5 + f) << 0;\n this.h6 = (this.h6 + g) << 0;\n this.h7 = (this.h7 + h) << 0;\n};\n\nSha256.prototype.hex = function () {\n this.finalize();\n\n var h0 = this.h0,\n h1 = this.h1,\n h2 = this.h2,\n h3 = this.h3,\n h4 = this.h4,\n h5 = this.h5,\n h6 = this.h6,\n h7 = this.h7;\n\n var hex =\n HEX_CHARS[(h0 >>> 28) & 0x0f] +\n HEX_CHARS[(h0 >>> 24) & 0x0f] +\n HEX_CHARS[(h0 >>> 20) & 0x0f] +\n HEX_CHARS[(h0 >>> 16) & 0x0f] +\n HEX_CHARS[(h0 >>> 12) & 0x0f] +\n HEX_CHARS[(h0 >>> 8) & 0x0f] +\n HEX_CHARS[(h0 >>> 4) & 0x0f] +\n HEX_CHARS[h0 & 0x0f] +\n HEX_CHARS[(h1 >>> 28) & 0x0f] +\n HEX_CHARS[(h1 >>> 24) & 0x0f] +\n HEX_CHARS[(h1 >>> 20) & 0x0f] +\n HEX_CHARS[(h1 >>> 16) & 0x0f] +\n HEX_CHARS[(h1 >>> 12) & 0x0f] +\n HEX_CHARS[(h1 >>> 8) & 0x0f] +\n HEX_CHARS[(h1 >>> 4) & 0x0f] +\n HEX_CHARS[h1 & 0x0f] +\n HEX_CHARS[(h2 >>> 28) & 0x0f] +\n HEX_CHARS[(h2 >>> 24) & 0x0f] +\n HEX_CHARS[(h2 >>> 20) & 0x0f] +\n HEX_CHARS[(h2 >>> 16) & 0x0f] +\n HEX_CHARS[(h2 >>> 12) & 0x0f] +\n HEX_CHARS[(h2 >>> 8) & 0x0f] +\n HEX_CHARS[(h2 >>> 4) & 0x0f] +\n HEX_CHARS[h2 & 0x0f] +\n HEX_CHARS[(h3 >>> 28) & 0x0f] +\n HEX_CHARS[(h3 >>> 24) & 0x0f] +\n HEX_CHARS[(h3 >>> 20) & 0x0f] +\n HEX_CHARS[(h3 >>> 16) & 0x0f] +\n HEX_CHARS[(h3 >>> 12) & 0x0f] +\n HEX_CHARS[(h3 >>> 8) & 0x0f] +\n HEX_CHARS[(h3 >>> 4) & 0x0f] +\n HEX_CHARS[h3 & 0x0f] +\n HEX_CHARS[(h4 >>> 28) & 0x0f] +\n HEX_CHARS[(h4 >>> 24) & 0x0f] +\n HEX_CHARS[(h4 >>> 20) & 0x0f] +\n HEX_CHARS[(h4 >>> 16) & 0x0f] +\n HEX_CHARS[(h4 >>> 12) & 0x0f] +\n HEX_CHARS[(h4 >>> 8) & 0x0f] +\n HEX_CHARS[(h4 >>> 4) & 0x0f] +\n HEX_CHARS[h4 & 0x0f] +\n HEX_CHARS[(h5 >>> 28) & 0x0f] +\n HEX_CHARS[(h5 >>> 24) & 0x0f] +\n HEX_CHARS[(h5 >>> 20) & 0x0f] +\n HEX_CHARS[(h5 >>> 16) & 0x0f] +\n HEX_CHARS[(h5 >>> 12) & 0x0f] +\n HEX_CHARS[(h5 >>> 8) & 0x0f] +\n HEX_CHARS[(h5 >>> 4) & 0x0f] +\n HEX_CHARS[h5 & 0x0f] +\n HEX_CHARS[(h6 >>> 28) & 0x0f] +\n HEX_CHARS[(h6 >>> 24) & 0x0f] +\n HEX_CHARS[(h6 >>> 20) & 0x0f] +\n HEX_CHARS[(h6 >>> 16) & 0x0f] +\n HEX_CHARS[(h6 >>> 12) & 0x0f] +\n HEX_CHARS[(h6 >>> 8) & 0x0f] +\n HEX_CHARS[(h6 >>> 4) & 0x0f] +\n HEX_CHARS[h6 & 0x0f];\n if (!this.is224) {\n hex +=\n HEX_CHARS[(h7 >>> 28) & 0x0f] +\n HEX_CHARS[(h7 >>> 24) & 0x0f] +\n HEX_CHARS[(h7 >>> 20) & 0x0f] +\n HEX_CHARS[(h7 >>> 16) & 0x0f] +\n HEX_CHARS[(h7 >>> 12) & 0x0f] +\n HEX_CHARS[(h7 >>> 8) & 0x0f] +\n HEX_CHARS[(h7 >>> 4) & 0x0f] +\n HEX_CHARS[h7 & 0x0f];\n }\n return hex;\n};\n\nSha256.prototype.toString = Sha256.prototype.hex;\n\nSha256.prototype.digest = function () {\n this.finalize();\n\n var h0 = this.h0,\n h1 = this.h1,\n h2 = this.h2,\n h3 = this.h3,\n h4 = this.h4,\n h5 = this.h5,\n h6 = this.h6,\n h7 = this.h7;\n\n var arr = [\n (h0 >>> 24) & 0xff,\n (h0 >>> 16) & 0xff,\n (h0 >>> 8) & 0xff,\n h0 & 0xff,\n (h1 >>> 24) & 0xff,\n (h1 >>> 16) & 0xff,\n (h1 >>> 8) & 0xff,\n h1 & 0xff,\n (h2 >>> 24) & 0xff,\n (h2 >>> 16) & 0xff,\n (h2 >>> 8) & 0xff,\n h2 & 0xff,\n (h3 >>> 24) & 0xff,\n (h3 >>> 16) & 0xff,\n (h3 >>> 8) & 0xff,\n h3 & 0xff,\n (h4 >>> 24) & 0xff,\n (h4 >>> 16) & 0xff,\n (h4 >>> 8) & 0xff,\n h4 & 0xff,\n (h5 >>> 24) & 0xff,\n (h5 >>> 16) & 0xff,\n (h5 >>> 8) & 0xff,\n h5 & 0xff,\n (h6 >>> 24) & 0xff,\n (h6 >>> 16) & 0xff,\n (h6 >>> 8) & 0xff,\n h6 & 0xff,\n ];\n if (!this.is224) {\n arr.push(\n (h7 >>> 24) & 0xff,\n (h7 >>> 16) & 0xff,\n (h7 >>> 8) & 0xff,\n h7 & 0xff\n );\n }\n return arr;\n};\n\nSha256.prototype.array = Sha256.prototype.digest;\n\nSha256.prototype.arrayBuffer = function () {\n this.finalize();\n\n var buffer = new ArrayBuffer(this.is224 ? 28 : 32);\n var dataView = new DataView(buffer);\n dataView.setUint32(0, this.h0);\n dataView.setUint32(4, this.h1);\n dataView.setUint32(8, this.h2);\n dataView.setUint32(12, this.h3);\n dataView.setUint32(16, this.h4);\n dataView.setUint32(20, this.h5);\n dataView.setUint32(24, this.h6);\n if (!this.is224) {\n dataView.setUint32(28, this.h7);\n }\n return buffer;\n};\n\nexport const sha256 = (...strings: string[]) => {\n return new Sha256(false, true).update(strings.join(\"\")).hex();\n};\n"],"mappings":";;;;;;;;;AAeA,IAAI,YAAY,mBAAmB,MAAM,EAAE;AAC3C,IAAI,QAAQ;CAAC;CAAa;CAAS;CAAO;AAAG;AAC7C,IAAI,QAAQ;CAAC;CAAI;CAAI;CAAG;AAAC;AACzB,IAAI,IAAI;CACN;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;AACtC;AAGA,IAAI,SAAS,CAAC;AAEd,SAAS,OAAO,OAAO,cAAc;CACnC,IAAI,cAAc;EAChB,OAAO,KACL,OAAO,MACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,MACP,OAAO,MACP,OAAO,MACP,OAAO,MACP,OAAO,MACP,OAAO,MACL;EACJ,KAAK,SAAS;CAChB,OACE,KAAK,SAAS;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;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AAE;CAC9B,SAAS,UAAU,IAAI,KAAK,EAAE;CAC9B,SAAS,UAAU,IAAI,KAAK,EAAE;CAC9B,IAAI,CAAC,KAAK,OACR,SAAS,UAAU,IAAI,KAAK,EAAE;CAEhC,OAAO;AACT;AAEA,MAAa,UAAU,GAAG,YAAsB;CAC9C,OAAO,IAAI,OAAO,OAAO,IAAI,CAAC,CAAC,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI;AAC9D"}
|
|
1
|
+
{"version":3,"file":"hash.js","names":[],"sources":["../../../src/utils/js-sha256/hash.ts"],"sourcesContent":["// @ts-nocheck\n\n// Inlined to deal with portability issues with importing crypto module\n\n/**\n * [js-sha256]{@link https://github.com/emn178/js-sha256}\n *\n * @version 0.11.1\n * @author Chen, Yi-Cyuan [emn178@gmail.com]\n * @copyright Chen, Yi-Cyuan 2014-2025\n * @license MIT\n */\n/*jslint bitwise: true */\n\"use strict\";\n\nvar HEX_CHARS = \"0123456789abcdef\".split(\"\");\nvar EXTRA = [-2147483648, 8388608, 32768, 128];\nvar SHIFT = [24, 16, 8, 0];\nvar K = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,\n 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\n 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,\n 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,\n 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\n 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,\n 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,\n 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\n 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n];\nvar OUTPUT_TYPES = [\"hex\", \"array\", \"digest\", \"arrayBuffer\"];\n\nvar blocks = [];\n\nfunction Sha256(is224, sharedMemory) {\n if (sharedMemory) {\n blocks[0] =\n blocks[16] =\n blocks[1] =\n blocks[2] =\n blocks[3] =\n blocks[4] =\n blocks[5] =\n blocks[6] =\n blocks[7] =\n blocks[8] =\n blocks[9] =\n blocks[10] =\n blocks[11] =\n blocks[12] =\n blocks[13] =\n blocks[14] =\n blocks[15] =\n 0;\n this.blocks = blocks;\n } else {\n this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n }\n\n if (is224) {\n this.h0 = 0xc1059ed8;\n this.h1 = 0x367cd507;\n this.h2 = 0x3070dd17;\n this.h3 = 0xf70e5939;\n this.h4 = 0xffc00b31;\n this.h5 = 0x68581511;\n this.h6 = 0x64f98fa7;\n this.h7 = 0xbefa4fa4;\n } else {\n // 256\n this.h0 = 0x6a09e667;\n this.h1 = 0xbb67ae85;\n this.h2 = 0x3c6ef372;\n this.h3 = 0xa54ff53a;\n this.h4 = 0x510e527f;\n this.h5 = 0x9b05688c;\n this.h6 = 0x1f83d9ab;\n this.h7 = 0x5be0cd19;\n }\n\n this.block = this.start = this.bytes = this.hBytes = 0;\n this.finalized = this.hashed = false;\n this.first = true;\n this.is224 = is224;\n}\n\nSha256.prototype.update = function (message) {\n if (this.finalized) {\n return;\n }\n var notString,\n type = typeof message;\n if (type !== \"string\") {\n if (type === \"object\") {\n if (message === null) {\n throw new Error(ERROR);\n } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {\n message = new Uint8Array(message);\n } else if (!Array.isArray(message)) {\n if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {\n throw new Error(ERROR);\n }\n }\n } else {\n throw new Error(ERROR);\n }\n notString = true;\n }\n var code,\n index = 0,\n i,\n length = message.length,\n blocks = this.blocks;\n while (index < length) {\n if (this.hashed) {\n this.hashed = false;\n blocks[0] = this.block;\n this.block =\n blocks[16] =\n blocks[1] =\n blocks[2] =\n blocks[3] =\n blocks[4] =\n blocks[5] =\n blocks[6] =\n blocks[7] =\n blocks[8] =\n blocks[9] =\n blocks[10] =\n blocks[11] =\n blocks[12] =\n blocks[13] =\n blocks[14] =\n blocks[15] =\n 0;\n }\n\n if (notString) {\n for (i = this.start; index < length && i < 64; ++index) {\n blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];\n }\n } else {\n for (i = this.start; index < length && i < 64; ++index) {\n code = message.charCodeAt(index);\n if (code < 0x80) {\n blocks[i >>> 2] |= code << SHIFT[i++ & 3];\n } else if (code < 0x800) {\n blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else if (code < 0xd800 || code >= 0xe000) {\n blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n } else {\n code =\n 0x10000 +\n (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));\n blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];\n blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];\n }\n }\n }\n\n this.lastByteIndex = i;\n this.bytes += i - this.start;\n if (i >= 64) {\n this.block = blocks[16];\n this.start = i - 64;\n this.hash();\n this.hashed = true;\n } else {\n this.start = i;\n }\n }\n if (this.bytes > 4294967295) {\n this.hBytes += (this.bytes / 4294967296) << 0;\n this.bytes = this.bytes % 4294967296;\n }\n return this;\n};\n\nSha256.prototype.finalize = function () {\n if (this.finalized) {\n return;\n }\n this.finalized = true;\n var blocks = this.blocks,\n i = this.lastByteIndex;\n blocks[16] = this.block;\n blocks[i >>> 2] |= EXTRA[i & 3];\n this.block = blocks[16];\n if (i >= 56) {\n if (!this.hashed) {\n this.hash();\n }\n blocks[0] = this.block;\n blocks[16] =\n blocks[1] =\n blocks[2] =\n blocks[3] =\n blocks[4] =\n blocks[5] =\n blocks[6] =\n blocks[7] =\n blocks[8] =\n blocks[9] =\n blocks[10] =\n blocks[11] =\n blocks[12] =\n blocks[13] =\n blocks[14] =\n blocks[15] =\n 0;\n }\n blocks[14] = (this.hBytes << 3) | (this.bytes >>> 29);\n blocks[15] = this.bytes << 3;\n this.hash();\n};\n\nSha256.prototype.hash = function () {\n var a = this.h0,\n b = this.h1,\n c = this.h2,\n d = this.h3,\n e = this.h4,\n f = this.h5,\n g = this.h6,\n h = this.h7,\n blocks = this.blocks,\n j,\n s0,\n s1,\n maj,\n t1,\n t2,\n ch,\n ab,\n da,\n cd,\n bc;\n\n for (j = 16; j < 64; ++j) {\n // rightrotate\n t1 = blocks[j - 15];\n s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);\n t1 = blocks[j - 2];\n s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);\n blocks[j] = (blocks[j - 16] + s0 + blocks[j - 7] + s1) << 0;\n }\n\n bc = b & c;\n for (j = 0; j < 64; j += 4) {\n if (this.first) {\n if (this.is224) {\n ab = 300032;\n t1 = blocks[0] - 1413257819;\n h = (t1 - 150054599) << 0;\n d = (t1 + 24177077) << 0;\n } else {\n ab = 704751109;\n t1 = blocks[0] - 210244248;\n h = (t1 - 1521486534) << 0;\n d = (t1 + 143694565) << 0;\n }\n this.first = false;\n } else {\n s0 =\n ((a >>> 2) | (a << 30)) ^\n ((a >>> 13) | (a << 19)) ^\n ((a >>> 22) | (a << 10));\n s1 =\n ((e >>> 6) | (e << 26)) ^\n ((e >>> 11) | (e << 21)) ^\n ((e >>> 25) | (e << 7));\n ab = a & b;\n maj = ab ^ (a & c) ^ bc;\n ch = (e & f) ^ (~e & g);\n t1 = h + s1 + ch + K[j] + blocks[j];\n t2 = s0 + maj;\n h = (d + t1) << 0;\n d = (t1 + t2) << 0;\n }\n s0 =\n ((d >>> 2) | (d << 30)) ^\n ((d >>> 13) | (d << 19)) ^\n ((d >>> 22) | (d << 10));\n s1 =\n ((h >>> 6) | (h << 26)) ^\n ((h >>> 11) | (h << 21)) ^\n ((h >>> 25) | (h << 7));\n da = d & a;\n maj = da ^ (d & b) ^ ab;\n ch = (g & h) ^ (~g & e);\n t1 = f + s1 + ch + K[j + 1] + blocks[j + 1];\n t2 = s0 + maj;\n g = (c + t1) << 0;\n c = (t1 + t2) << 0;\n s0 =\n ((c >>> 2) | (c << 30)) ^\n ((c >>> 13) | (c << 19)) ^\n ((c >>> 22) | (c << 10));\n s1 =\n ((g >>> 6) | (g << 26)) ^\n ((g >>> 11) | (g << 21)) ^\n ((g >>> 25) | (g << 7));\n cd = c & d;\n maj = cd ^ (c & a) ^ da;\n ch = (f & g) ^ (~f & h);\n t1 = e + s1 + ch + K[j + 2] + blocks[j + 2];\n t2 = s0 + maj;\n f = (b + t1) << 0;\n b = (t1 + t2) << 0;\n s0 =\n ((b >>> 2) | (b << 30)) ^\n ((b >>> 13) | (b << 19)) ^\n ((b >>> 22) | (b << 10));\n s1 =\n ((f >>> 6) | (f << 26)) ^\n ((f >>> 11) | (f << 21)) ^\n ((f >>> 25) | (f << 7));\n bc = b & c;\n maj = bc ^ (b & d) ^ cd;\n ch = (f & g) ^ (~f & h);\n t1 = e + s1 + ch + K[j + 3] + blocks[j + 3];\n t2 = s0 + maj;\n e = (a + t1) << 0;\n a = (t1 + t2) << 0;\n this.chromeBugWorkAround = true;\n }\n\n this.h0 = (this.h0 + a) << 0;\n this.h1 = (this.h1 + b) << 0;\n this.h2 = (this.h2 + c) << 0;\n this.h3 = (this.h3 + d) << 0;\n this.h4 = (this.h4 + e) << 0;\n this.h5 = (this.h5 + f) << 0;\n this.h6 = (this.h6 + g) << 0;\n this.h7 = (this.h7 + h) << 0;\n};\n\nSha256.prototype.hex = function () {\n this.finalize();\n\n var h0 = this.h0,\n h1 = this.h1,\n h2 = this.h2,\n h3 = this.h3,\n h4 = this.h4,\n h5 = this.h5,\n h6 = this.h6,\n h7 = this.h7;\n\n var hex =\n HEX_CHARS[(h0 >>> 28) & 0x0f] +\n HEX_CHARS[(h0 >>> 24) & 0x0f] +\n HEX_CHARS[(h0 >>> 20) & 0x0f] +\n HEX_CHARS[(h0 >>> 16) & 0x0f] +\n HEX_CHARS[(h0 >>> 12) & 0x0f] +\n HEX_CHARS[(h0 >>> 8) & 0x0f] +\n HEX_CHARS[(h0 >>> 4) & 0x0f] +\n HEX_CHARS[h0 & 0x0f] +\n HEX_CHARS[(h1 >>> 28) & 0x0f] +\n HEX_CHARS[(h1 >>> 24) & 0x0f] +\n HEX_CHARS[(h1 >>> 20) & 0x0f] +\n HEX_CHARS[(h1 >>> 16) & 0x0f] +\n HEX_CHARS[(h1 >>> 12) & 0x0f] +\n HEX_CHARS[(h1 >>> 8) & 0x0f] +\n HEX_CHARS[(h1 >>> 4) & 0x0f] +\n HEX_CHARS[h1 & 0x0f] +\n HEX_CHARS[(h2 >>> 28) & 0x0f] +\n HEX_CHARS[(h2 >>> 24) & 0x0f] +\n HEX_CHARS[(h2 >>> 20) & 0x0f] +\n HEX_CHARS[(h2 >>> 16) & 0x0f] +\n HEX_CHARS[(h2 >>> 12) & 0x0f] +\n HEX_CHARS[(h2 >>> 8) & 0x0f] +\n HEX_CHARS[(h2 >>> 4) & 0x0f] +\n HEX_CHARS[h2 & 0x0f] +\n HEX_CHARS[(h3 >>> 28) & 0x0f] +\n HEX_CHARS[(h3 >>> 24) & 0x0f] +\n HEX_CHARS[(h3 >>> 20) & 0x0f] +\n HEX_CHARS[(h3 >>> 16) & 0x0f] +\n HEX_CHARS[(h3 >>> 12) & 0x0f] +\n HEX_CHARS[(h3 >>> 8) & 0x0f] +\n HEX_CHARS[(h3 >>> 4) & 0x0f] +\n HEX_CHARS[h3 & 0x0f] +\n HEX_CHARS[(h4 >>> 28) & 0x0f] +\n HEX_CHARS[(h4 >>> 24) & 0x0f] +\n HEX_CHARS[(h4 >>> 20) & 0x0f] +\n HEX_CHARS[(h4 >>> 16) & 0x0f] +\n HEX_CHARS[(h4 >>> 12) & 0x0f] +\n HEX_CHARS[(h4 >>> 8) & 0x0f] +\n HEX_CHARS[(h4 >>> 4) & 0x0f] +\n HEX_CHARS[h4 & 0x0f] +\n HEX_CHARS[(h5 >>> 28) & 0x0f] +\n HEX_CHARS[(h5 >>> 24) & 0x0f] +\n HEX_CHARS[(h5 >>> 20) & 0x0f] +\n HEX_CHARS[(h5 >>> 16) & 0x0f] +\n HEX_CHARS[(h5 >>> 12) & 0x0f] +\n HEX_CHARS[(h5 >>> 8) & 0x0f] +\n HEX_CHARS[(h5 >>> 4) & 0x0f] +\n HEX_CHARS[h5 & 0x0f] +\n HEX_CHARS[(h6 >>> 28) & 0x0f] +\n HEX_CHARS[(h6 >>> 24) & 0x0f] +\n HEX_CHARS[(h6 >>> 20) & 0x0f] +\n HEX_CHARS[(h6 >>> 16) & 0x0f] +\n HEX_CHARS[(h6 >>> 12) & 0x0f] +\n HEX_CHARS[(h6 >>> 8) & 0x0f] +\n HEX_CHARS[(h6 >>> 4) & 0x0f] +\n HEX_CHARS[h6 & 0x0f];\n if (!this.is224) {\n hex +=\n HEX_CHARS[(h7 >>> 28) & 0x0f] +\n HEX_CHARS[(h7 >>> 24) & 0x0f] +\n HEX_CHARS[(h7 >>> 20) & 0x0f] +\n HEX_CHARS[(h7 >>> 16) & 0x0f] +\n HEX_CHARS[(h7 >>> 12) & 0x0f] +\n HEX_CHARS[(h7 >>> 8) & 0x0f] +\n HEX_CHARS[(h7 >>> 4) & 0x0f] +\n HEX_CHARS[h7 & 0x0f];\n }\n return hex;\n};\n\nSha256.prototype.toString = Sha256.prototype.hex;\n\nSha256.prototype.digest = function () {\n this.finalize();\n\n var h0 = this.h0,\n h1 = this.h1,\n h2 = this.h2,\n h3 = this.h3,\n h4 = this.h4,\n h5 = this.h5,\n h6 = this.h6,\n h7 = this.h7;\n\n var arr = [\n (h0 >>> 24) & 0xff,\n (h0 >>> 16) & 0xff,\n (h0 >>> 8) & 0xff,\n h0 & 0xff,\n (h1 >>> 24) & 0xff,\n (h1 >>> 16) & 0xff,\n (h1 >>> 8) & 0xff,\n h1 & 0xff,\n (h2 >>> 24) & 0xff,\n (h2 >>> 16) & 0xff,\n (h2 >>> 8) & 0xff,\n h2 & 0xff,\n (h3 >>> 24) & 0xff,\n (h3 >>> 16) & 0xff,\n (h3 >>> 8) & 0xff,\n h3 & 0xff,\n (h4 >>> 24) & 0xff,\n (h4 >>> 16) & 0xff,\n (h4 >>> 8) & 0xff,\n h4 & 0xff,\n (h5 >>> 24) & 0xff,\n (h5 >>> 16) & 0xff,\n (h5 >>> 8) & 0xff,\n h5 & 0xff,\n (h6 >>> 24) & 0xff,\n (h6 >>> 16) & 0xff,\n (h6 >>> 8) & 0xff,\n h6 & 0xff,\n ];\n if (!this.is224) {\n arr.push(\n (h7 >>> 24) & 0xff,\n (h7 >>> 16) & 0xff,\n (h7 >>> 8) & 0xff,\n h7 & 0xff\n );\n }\n return arr;\n};\n\nSha256.prototype.array = Sha256.prototype.digest;\n\nSha256.prototype.arrayBuffer = function () {\n this.finalize();\n\n var buffer = new ArrayBuffer(this.is224 ? 28 : 32);\n var dataView = new DataView(buffer);\n dataView.setUint32(0, this.h0);\n dataView.setUint32(4, this.h1);\n dataView.setUint32(8, this.h2);\n dataView.setUint32(12, this.h3);\n dataView.setUint32(16, this.h4);\n dataView.setUint32(20, this.h5);\n dataView.setUint32(24, this.h6);\n if (!this.is224) {\n dataView.setUint32(28, this.h7);\n }\n return buffer;\n};\n\nexport const sha256 = (...strings: string[]) => {\n return new Sha256(false, true).update(strings.join(\"\")).hex();\n};\n"],"mappings":";;;;;;;;;AAeA,IAAI,YAAY,mBAAmB,MAAM,EAAE;AAC3C,IAAI,QAAQ;CAAC;CAAa;CAAS;CAAO;AAAG;AAC7C,IAAI,QAAQ;CAAC;CAAI;CAAI;CAAG;AAAC;AACzB,IAAI,IAAI;CACN;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;CAAY;CAAY;CAC5D;CAAY;CAAY;CAAY;AACtC;AAGA,IAAI,SAAS,CAAC;AAEd,SAAS,OAAO,OAAO,cAAc;CACnC,IAAI,cAAc;EAChB,OAAO,KACL,OAAO,MACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,KACP,OAAO,MACP,OAAO,MACP,OAAO,MACP,OAAO,MACP,OAAO,MACP,OAAO,MACL;EACJ,KAAK,SAAS;CAChB,OACE,KAAK,SAAS;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;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UAAU,IAAI,KAAK,EAAE;CAC9B,SAAS,UAAU,IAAI,KAAK,EAAE;CAC9B,SAAS,UAAU,IAAI,KAAK,EAAE;CAC9B,IAAI,CAAC,KAAK,OACR,SAAS,UAAU,IAAI,KAAK,EAAE;CAEhC,OAAO;AACT;AAEA,MAAa,UAAU,GAAG,YAAsB;CAC9C,OAAO,IAAI,OAAO,OAAO,IAAI,CAAC,CAAC,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI;AAC9D"}
|
|
@@ -46,8 +46,10 @@ function toJsonSchema(schema, params) {
|
|
|
46
46
|
if (require_utils_standard_schema.isStandardJsonSchema(schema) && !require_zod.isZodSchemaV4(schema)) result = schema["~standard"].jsonSchema.input({ target: "draft-07" });
|
|
47
47
|
else if (require_zod.isZodSchemaV4(schema)) {
|
|
48
48
|
const inputSchema = require_zod.interopZodTransformInputSchema(schema, true);
|
|
49
|
-
if (require_zod.isZodObjectV4(inputSchema))
|
|
50
|
-
|
|
49
|
+
if (require_zod.isZodObjectV4(inputSchema)) {
|
|
50
|
+
const strictSchema = require_zod.interopZodObjectStrict(inputSchema, true);
|
|
51
|
+
result = (0, zod_v4_core.toJSONSchema)(strictSchema, params);
|
|
52
|
+
} else result = (0, zod_v4_core.toJSONSchema)(schema, params);
|
|
51
53
|
} else if (require_zod.isZodSchemaV3(schema)) result = require_zodToJsonSchema.zodToJsonSchema(schema);
|
|
52
54
|
else result = schema;
|
|
53
55
|
if (canCache && result != null && typeof result === "object") _jsonSchemaCache.set(schema, result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_schema.cjs","names":["isStandardJsonSchema","isZodSchemaV4","interopZodTransformInputSchema","isZodObjectV4","interopZodObjectStrict","isZodSchemaV3","zodToJsonSchema"],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema, type $ZodType } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * WeakMap cache for Zod/Standard-Schema → JSON Schema conversions.\n *\n * Keyed on the schema object reference. Since Zod schemas are immutable and\n * the same `tool.schema` reference is passed on every LLM call, this\n * eliminates redundant serializations. For example, an agent with 6 tools\n * doing 15 steps across 3 parallel subagents would otherwise run 270\n * identical conversions per invocation.\n *\n * Only used when no custom `params` are passed (the common case for tool\n * binding). WeakMap ensures cached entries are GC'd when the schema goes\n * out of scope.\n *\n * @internal\n */\nconst _jsonSchemaCache = new WeakMap<object, JSONSchema>();\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * Results are cached by schema reference when no custom params are passed.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n // Cache when no custom params are passed (the default for tool binding).\n // Params can change the output (e.g., different target draft), so we\n // bypass the cache when they're provided.\n const canCache = !params && schema != null && typeof schema === \"object\";\n\n if (canCache) {\n const cached = _jsonSchemaCache.get(schema);\n if (cached) return cached;\n }\n\n let result: JSONSchema;\n\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n result = schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n } else if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(inputSchema, true);\n result = toJSONSchema(strictSchema as unknown as $ZodType, params);\n } else {\n result = toJSONSchema(schema as unknown as $ZodType, params);\n }\n } else if (isZodSchemaV3(schema)) {\n result = zodToJsonSchema(schema as never);\n } else {\n result = schema as JSONSchema;\n }\n\n if (canCache && result != null && typeof result === \"object\") {\n _jsonSchemaCache.set(schema, result);\n }\n\n return result;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,mCAAmB,IAAI,QAA4B;;;;;;;;AASzD,SAAgB,aACd,QACA,QACY;CAIZ,MAAM,WAAW,CAAC,UAAU,UAAU,QAAQ,OAAO,WAAW;CAEhE,IAAI,UAAU;EACZ,MAAM,SAAS,iBAAiB,IAAI,MAAM;EAC1C,IAAI,QAAQ,OAAO;CACrB;CAEA,IAAI;CAEJ,IAAIA,8BAAAA,qBAAqB,MAAM,KAAK,CAACC,YAAAA,cAAc,MAAM,GACvD,SAAS,OAAO,YAAY,CAAC,WAAW,MAAM,EAC5C,QAAQ,WACV,CAAC;MACI,IAAIA,YAAAA,cAAc,MAAM,GAAG;EAChC,MAAM,cAAcC,YAAAA,+BAA+B,QAAQ,IAAI;EAC/D,IAAIC,YAAAA,cAAc,WAAW,
|
|
1
|
+
{"version":3,"file":"json_schema.cjs","names":["isStandardJsonSchema","isZodSchemaV4","interopZodTransformInputSchema","isZodObjectV4","interopZodObjectStrict","toJSONSchema","isZodSchemaV3","zodToJsonSchema","dereference"],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema, type $ZodType } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * WeakMap cache for Zod/Standard-Schema → JSON Schema conversions.\n *\n * Keyed on the schema object reference. Since Zod schemas are immutable and\n * the same `tool.schema` reference is passed on every LLM call, this\n * eliminates redundant serializations. For example, an agent with 6 tools\n * doing 15 steps across 3 parallel subagents would otherwise run 270\n * identical conversions per invocation.\n *\n * Only used when no custom `params` are passed (the common case for tool\n * binding). WeakMap ensures cached entries are GC'd when the schema goes\n * out of scope.\n *\n * @internal\n */\nconst _jsonSchemaCache = new WeakMap<object, JSONSchema>();\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * Results are cached by schema reference when no custom params are passed.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n // Cache when no custom params are passed (the default for tool binding).\n // Params can change the output (e.g., different target draft), so we\n // bypass the cache when they're provided.\n const canCache = !params && schema != null && typeof schema === \"object\";\n\n if (canCache) {\n const cached = _jsonSchemaCache.get(schema);\n if (cached) return cached;\n }\n\n let result: JSONSchema;\n\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n result = schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n } else if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(inputSchema, true);\n result = toJSONSchema(strictSchema as unknown as $ZodType, params);\n } else {\n result = toJSONSchema(schema as unknown as $ZodType, params);\n }\n } else if (isZodSchemaV3(schema)) {\n result = zodToJsonSchema(schema as never);\n } else {\n result = schema as JSONSchema;\n }\n\n if (canCache && result != null && typeof result === \"object\") {\n _jsonSchemaCache.set(schema, result);\n }\n\n return result;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,mCAAmB,IAAI,QAA4B;;;;;;;;AASzD,SAAgB,aACd,QACA,QACY;CAIZ,MAAM,WAAW,CAAC,UAAU,UAAU,QAAQ,OAAO,WAAW;CAEhE,IAAI,UAAU;EACZ,MAAM,SAAS,iBAAiB,IAAI,MAAM;EAC1C,IAAI,QAAQ,OAAO;CACrB;CAEA,IAAI;CAEJ,IAAIA,8BAAAA,qBAAqB,MAAM,KAAK,C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KAC/C,WAAW,UAAU,MAAM,QAAQ,OAAO,KAAK,GAChD;EACA,MAAM,aACJ,WAAW,SAAS,OAAO,QAAQ,OAAO;EAI5C,OACE,WAAW,SAAS,KACpB,WAAW,OAAO,cAAc,qBAAqB,SAAS,CAAC;CAEnE;CAGA,IAAI,SAAS,QACX,OAAO;CAGT,IAAI,UAAU,UAAU,OAAO,OAAO,SAAS,UAAU;EACvD,MAAM,MAAM,OAAO;EACnB,MAAM,YAAA,GAAWC,sBAAAA,YAAAA,CAAY,MAAgB;EAC7C,IAAI,SAAS,MACX,OAAO,qBAAqB,SAAS,IAAI;EAE3C,OAAO;CACT;CAKA,OAAO;AACT"}
|
|
@@ -45,8 +45,10 @@ function toJsonSchema(schema, params) {
|
|
|
45
45
|
if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) result = schema["~standard"].jsonSchema.input({ target: "draft-07" });
|
|
46
46
|
else if (isZodSchemaV4(schema)) {
|
|
47
47
|
const inputSchema = interopZodTransformInputSchema(schema, true);
|
|
48
|
-
if (isZodObjectV4(inputSchema))
|
|
49
|
-
|
|
48
|
+
if (isZodObjectV4(inputSchema)) {
|
|
49
|
+
const strictSchema = interopZodObjectStrict(inputSchema, true);
|
|
50
|
+
result = toJSONSchema(strictSchema, params);
|
|
51
|
+
} else result = toJSONSchema(schema, params);
|
|
50
52
|
} else if (isZodSchemaV3(schema)) result = zodToJsonSchema(schema);
|
|
51
53
|
else result = schema;
|
|
52
54
|
if (canCache && result != null && typeof result === "object") _jsonSchemaCache.set(schema, result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json_schema.js","names":[],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema, type $ZodType } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * WeakMap cache for Zod/Standard-Schema → JSON Schema conversions.\n *\n * Keyed on the schema object reference. Since Zod schemas are immutable and\n * the same `tool.schema` reference is passed on every LLM call, this\n * eliminates redundant serializations. For example, an agent with 6 tools\n * doing 15 steps across 3 parallel subagents would otherwise run 270\n * identical conversions per invocation.\n *\n * Only used when no custom `params` are passed (the common case for tool\n * binding). WeakMap ensures cached entries are GC'd when the schema goes\n * out of scope.\n *\n * @internal\n */\nconst _jsonSchemaCache = new WeakMap<object, JSONSchema>();\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * Results are cached by schema reference when no custom params are passed.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n // Cache when no custom params are passed (the default for tool binding).\n // Params can change the output (e.g., different target draft), so we\n // bypass the cache when they're provided.\n const canCache = !params && schema != null && typeof schema === \"object\";\n\n if (canCache) {\n const cached = _jsonSchemaCache.get(schema);\n if (cached) return cached;\n }\n\n let result: JSONSchema;\n\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n result = schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n } else if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(inputSchema, true);\n result = toJSONSchema(strictSchema as unknown as $ZodType, params);\n } else {\n result = toJSONSchema(schema as unknown as $ZodType, params);\n }\n } else if (isZodSchemaV3(schema)) {\n result = zodToJsonSchema(schema as never);\n } else {\n result = schema as JSONSchema;\n }\n\n if (canCache && result != null && typeof result === \"object\") {\n _jsonSchemaCache.set(schema, result);\n }\n\n return result;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,mCAAmB,IAAI,QAA4B;;;;;;;;AASzD,SAAgB,aACd,QACA,QACY;CAIZ,MAAM,WAAW,CAAC,UAAU,UAAU,QAAQ,OAAO,WAAW;CAEhE,IAAI,UAAU;EACZ,MAAM,SAAS,iBAAiB,IAAI,MAAM;EAC1C,IAAI,QAAQ,OAAO;CACrB;CAEA,IAAI;CAEJ,IAAI,qBAAqB,MAAM,KAAK,CAAC,cAAc,MAAM,GACvD,SAAS,OAAO,YAAY,CAAC,WAAW,MAAM,EAC5C,QAAQ,WACV,CAAC;MACI,IAAI,cAAc,MAAM,GAAG;EAChC,MAAM,cAAc,+BAA+B,QAAQ,IAAI;EAC/D,IAAI,cAAc,WAAW,
|
|
1
|
+
{"version":3,"file":"json_schema.js","names":[],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema, type $ZodType } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * WeakMap cache for Zod/Standard-Schema → JSON Schema conversions.\n *\n * Keyed on the schema object reference. Since Zod schemas are immutable and\n * the same `tool.schema` reference is passed on every LLM call, this\n * eliminates redundant serializations. For example, an agent with 6 tools\n * doing 15 steps across 3 parallel subagents would otherwise run 270\n * identical conversions per invocation.\n *\n * Only used when no custom `params` are passed (the common case for tool\n * binding). WeakMap ensures cached entries are GC'd when the schema goes\n * out of scope.\n *\n * @internal\n */\nconst _jsonSchemaCache = new WeakMap<object, JSONSchema>();\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * Results are cached by schema reference when no custom params are passed.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n // Cache when no custom params are passed (the default for tool binding).\n // Params can change the output (e.g., different target draft), so we\n // bypass the cache when they're provided.\n const canCache = !params && schema != null && typeof schema === \"object\";\n\n if (canCache) {\n const cached = _jsonSchemaCache.get(schema);\n if (cached) return cached;\n }\n\n let result: JSONSchema;\n\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n result = schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n } else if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(inputSchema, true);\n result = toJSONSchema(strictSchema as unknown as $ZodType, params);\n } else {\n result = toJSONSchema(schema as unknown as $ZodType, params);\n }\n } else if (isZodSchemaV3(schema)) {\n result = zodToJsonSchema(schema as never);\n } else {\n result = schema as JSONSchema;\n }\n\n if (canCache && result != null && typeof result === \"object\") {\n _jsonSchemaCache.set(schema, result);\n }\n\n return result;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,mCAAmB,IAAI,QAA4B;;;;;;;;AASzD,SAAgB,aACd,QACA,QACY;CAIZ,MAAM,WAAW,CAAC,UAAU,UAAU,QAAQ,OAAO,WAAW;CAEhE,IAAI,UAAU;EACZ,MAAM,SAAS,iBAAiB,IAAI,MAAM;EAC1C,IAAI,QAAQ,OAAO;CACrB;CAEA,IAAI;CAEJ,IAAI,qBAAqB,MAAM,KAAK,CAAC,cAAc,MAAM,GACvD,SAAS,OAAO,YAAY,CAAC,WAAW,MAAM,EAC5C,QAAQ,WACV,CAAC;MACI,IAAI,cAAc,MAAM,GAAG;EAChC,MAAM,cAAc,+BAA+B,QAAQ,IAAI;EAC/D,IAAI,cAAc,WAAW,GAAG;GAC9B,MAAM,eAAe,uBAAuB,aAAa,IAAI;GAC7D,SAAS,aAAa,cAAqC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AS,IAAI;EAE3C,OAAO;CACT;CAKA,OAAO;AACT"}
|
|
@@ -7,7 +7,7 @@ const initializeSax = function() {
|
|
|
7
7
|
sax.SAXParser = SAXParser;
|
|
8
8
|
sax.SAXStream = SAXStream;
|
|
9
9
|
sax.createStream = createStream;
|
|
10
|
-
sax.MAX_BUFFER_LENGTH =
|
|
10
|
+
sax.MAX_BUFFER_LENGTH = 65536;
|
|
11
11
|
const buffers = [
|
|
12
12
|
"comment",
|
|
13
13
|
"sgmlDecl",
|
|
@@ -597,13 +597,15 @@ const initializeSax = function() {
|
|
|
597
597
|
var qn = qname(parser.attribName, true);
|
|
598
598
|
var prefix = qn.prefix;
|
|
599
599
|
var local = qn.local;
|
|
600
|
-
if (prefix === "xmlns")
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
600
|
+
if (prefix === "xmlns") {
|
|
601
|
+
if (local === "xml" && parser.attribValue !== XML_NAMESPACE) strictFail(parser, "xml: prefix must be bound to " + XML_NAMESPACE + "\nActual: " + parser.attribValue);
|
|
602
|
+
else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) strictFail(parser, "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\nActual: " + parser.attribValue);
|
|
603
|
+
else {
|
|
604
|
+
var tag = parser.tag;
|
|
605
|
+
var parent = parser.tags[parser.tags.length - 1] || parser;
|
|
606
|
+
if (tag.ns === parent.ns) tag.ns = Object.create(parent.ns);
|
|
607
|
+
tag.ns[local] = parser.attribValue;
|
|
608
|
+
}
|
|
607
609
|
}
|
|
608
610
|
parser.attribList.push([parser.attribName, parser.attribValue]);
|
|
609
611
|
} else {
|
|
@@ -729,14 +731,16 @@ const initializeSax = function() {
|
|
|
729
731
|
if (parser.ENTITIES[entity]) return parser.ENTITIES[entity];
|
|
730
732
|
if (parser.ENTITIES[entityLC]) return parser.ENTITIES[entityLC];
|
|
731
733
|
entity = entityLC;
|
|
732
|
-
if (entity.charAt(0) === "#")
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
734
|
+
if (entity.charAt(0) === "#") {
|
|
735
|
+
if (entity.charAt(1) === "x") {
|
|
736
|
+
entity = entity.slice(2);
|
|
737
|
+
num = parseInt(entity, 16);
|
|
738
|
+
numStr = num.toString(16);
|
|
739
|
+
} else {
|
|
740
|
+
entity = entity.slice(1);
|
|
741
|
+
num = parseInt(entity, 10);
|
|
742
|
+
numStr = num.toString(10);
|
|
743
|
+
}
|
|
740
744
|
}
|
|
741
745
|
entity = entity.replace(/^0+/, "");
|
|
742
746
|
if (isNaN(num) || numStr.toLowerCase() !== entity) {
|
|
@@ -1088,13 +1092,15 @@ const initializeSax = function() {
|
|
|
1088
1092
|
else parser.state = S.ATTRIB;
|
|
1089
1093
|
continue;
|
|
1090
1094
|
case S.CLOSE_TAG:
|
|
1091
|
-
if (!parser.tagName)
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1095
|
+
if (!parser.tagName) {
|
|
1096
|
+
if (isWhitespace(c)) continue;
|
|
1097
|
+
else if (notMatch(nameStart, c)) {
|
|
1098
|
+
if (parser.script) {
|
|
1099
|
+
parser.script += "</" + c;
|
|
1100
|
+
parser.state = S.SCRIPT;
|
|
1101
|
+
} else strictFail(parser, "Invalid tagname in closing tag.");
|
|
1102
|
+
} else parser.tagName = c;
|
|
1103
|
+
} else if (c === ">") closeTag(parser);
|
|
1098
1104
|
else if (isMatch(nameBody, c)) parser.tagName += c;
|
|
1099
1105
|
else if (parser.script) {
|
|
1100
1106
|
parser.script += "</" + parser.tagName;
|
|
@@ -1127,19 +1133,19 @@ const initializeSax = function() {
|
|
|
1127
1133
|
case S.ATTRIB_VALUE_ENTITY_U:
|
|
1128
1134
|
returnState = S.ATTRIB_VALUE_UNQUOTED;
|
|
1129
1135
|
buffer = "attribValue";
|
|
1130
|
-
break;
|
|
1131
|
-
}
|
|
1132
|
-
if (c === ";") if (parser.opt.unparsedEntities) {
|
|
1133
|
-
var parsedEntity = parseEntity(parser);
|
|
1134
|
-
parser.entity = "";
|
|
1135
|
-
parser.state = returnState;
|
|
1136
|
-
parser.write(parsedEntity);
|
|
1137
|
-
} else {
|
|
1138
|
-
parser[buffer] += parseEntity(parser);
|
|
1139
|
-
parser.entity = "";
|
|
1140
|
-
parser.state = returnState;
|
|
1141
1136
|
}
|
|
1142
|
-
|
|
1137
|
+
if (c === ";") {
|
|
1138
|
+
if (parser.opt.unparsedEntities) {
|
|
1139
|
+
var parsedEntity = parseEntity(parser);
|
|
1140
|
+
parser.entity = "";
|
|
1141
|
+
parser.state = returnState;
|
|
1142
|
+
parser.write(parsedEntity);
|
|
1143
|
+
} else {
|
|
1144
|
+
parser[buffer] += parseEntity(parser);
|
|
1145
|
+
parser.entity = "";
|
|
1146
|
+
parser.state = returnState;
|
|
1147
|
+
}
|
|
1148
|
+
} else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) parser.entity += c;
|
|
1143
1149
|
else {
|
|
1144
1150
|
strictFail(parser, "Invalid character in entity name");
|
|
1145
1151
|
parser[buffer] += "&" + parser.entity + c;
|