@zuplo/cli 7.15.5 → 7.15.7
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/node_modules/@hono/node-server/dist/serve-static.cjs +1 -1
- package/node_modules/@hono/node-server/dist/serve-static.mjs +1 -1
- package/node_modules/@hono/node-server/package.json +1 -1
- package/node_modules/@inquirer/ansi/package.json +4 -4
- package/node_modules/@inquirer/checkbox/package.json +8 -8
- package/node_modules/@inquirer/confirm/package.json +6 -6
- package/node_modules/@inquirer/core/dist/lib/make-theme.js +3 -0
- package/node_modules/@inquirer/core/package.json +8 -8
- package/node_modules/@inquirer/editor/package.json +7 -7
- package/node_modules/@inquirer/expand/package.json +6 -6
- package/node_modules/@inquirer/external-editor/package.json +4 -4
- package/node_modules/@inquirer/figures/package.json +4 -4
- package/node_modules/@inquirer/input/package.json +6 -6
- package/node_modules/@inquirer/number/dist/index.js +7 -2
- package/node_modules/@inquirer/number/package.json +6 -6
- package/node_modules/@inquirer/password/package.json +7 -7
- package/node_modules/@inquirer/rawlist/dist/index.js +3 -3
- package/node_modules/@inquirer/rawlist/package.json +6 -6
- package/node_modules/@inquirer/search/package.json +7 -7
- package/node_modules/@inquirer/select/dist/index.js +5 -1
- package/node_modules/@inquirer/select/package.json +8 -8
- package/node_modules/@inquirer/type/package.json +4 -4
- package/node_modules/@posthog/types/dist/feature-flags.d.ts +2 -0
- package/node_modules/@posthog/types/dist/feature-flags.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +3 -0
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/feature-flags.ts +2 -0
- package/node_modules/@posthog/types/src/posthog-config.ts +3 -0
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/brace-expansion/README.md +30 -0
- package/node_modules/brace-expansion/dist/commonjs/index.d.ts +2 -0
- package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/brace-expansion/dist/commonjs/index.js +222 -36
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.d.ts +2 -0
- package/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js +222 -36
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
- package/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/hono/dist/cjs/hono-base.js +7 -2
- package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +9 -10
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/mount/index.js +3 -2
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/cjs/utils/mount.js +18 -2
- package/node_modules/hono/dist/cjs/utils/url.js +8 -11
- package/node_modules/hono/dist/cjs/validator/validator.js +5 -5
- package/node_modules/hono/dist/hono-base.js +7 -2
- package/node_modules/hono/dist/middleware/body-limit/index.js +9 -10
- package/node_modules/hono/dist/middleware/language/language.js +1 -1
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +1 -1
- package/node_modules/hono/dist/middleware/mount/index.js +3 -2
- package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/types/hono-base.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/mount/index.d.ts +2 -1
- package/node_modules/hono/dist/types/utils/url.d.ts +0 -1
- package/node_modules/hono/dist/utils/mount.js +19 -3
- package/node_modules/hono/dist/utils/url.js +9 -11
- package/node_modules/hono/dist/validator/validator.js +5 -5
- package/node_modules/hono/package.json +1 -1
- package/node_modules/mute-stream/package.json +13 -20
- package/package.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,CAAW,CAAA;oBAC/B,IAAI,YAAY,IAAI,CAAC,CAAC;wBAAE,SAAQ;oBAChC,IACE,MAAM,CAAC,MAAM,IAAI,GAAG;wBACpB,YAAY,GAAG,CAAC,CAAC,MAAM,GAAG,SAAS,EACnC,CAAC;wBACD,MAAM,KAAK,CAAA;oBACb,CAAC;oBACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBACd,YAAY,IAAI,CAAC,CAAC,MAAM,CAAA;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;QAED,GAAG,GAAG,OAAO,CACX,GAAG,EACH,GAAG,EACH,MAAM,EACN,GAAG,EACH,SAAS,EACT,WAAW,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAC9B,CAAA;QACD,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;YAAE,MAAK;QACzB,GAAG,GAAG,CAAC,CAAC,IAAI,CAAA;IACd,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { balanced } from 'balanced-match'\n\nconst escSlash = '\\0SLASH' + Math.random() + '\\0'\nconst escOpen = '\\0OPEN' + Math.random() + '\\0'\nconst escClose = '\\0CLOSE' + Math.random() + '\\0'\nconst escComma = '\\0COMMA' + Math.random() + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random() + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\n// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An\n// input like `'{a,b}'.repeat(1500)` stays under that count - its output is\n// truncated to 100k results - while making every result ~1500 characters\n// long. The result set, and the intermediate arrays built while combining\n// brace sets, then grow large enough to exhaust memory and crash the process\n// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of\n// characters the accumulator may hold at any point, so memory stays flat no\n// matter how many brace groups are chained. The limit sits well above any\n// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M\n// characters) so legitimate input is unaffected.\nexport const EXPANSION_MAX_LENGTH = 4_000_000\n\n// `expand_` recurses once per level of brace *nesting* - both when expanding a\n// set's comma members and when re-wrapping a set whose body is a single part.\n// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one\n// level per chained group), which left nesting depth unbounded: about 3,100\n// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack\n// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser\n// will follow nesting. It sits far above any realistic pattern and well below\n// the depth at which the stack runs out.\nexport const EXPANSION_MAX_DEPTH = 1_000\n\n// Bash keeps a quirk where a brace group followed by a comma set still expands\n// (`{a},b}`). The parser implements it by rewriting the string and restarting\n// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`\n// full passes over a string that itself grows by one `escClose` sentinel each\n// time - quadratic in `n`, with a ~26x constant from the sentinel's length.\n// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27\n// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many\n// times the scan may restart. Real `{a},b}` input needs a handful.\nexport const EXPANSION_MAX_REWRITES = 1_000\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPattern, '{')\n .replace(escClosePattern, '}')\n .replace(escCommaPattern, ',')\n .replace(escPeriodPattern, '.')\n}\n\n// Like `target.push(...items)` but doesn't overflow the stack\nfunction pushAll(target: string[], items: string[]) {\n for (let i = 0; i < items.length; i++) {\n target.push(items[i] as string)\n }\n}\n\n/**\n * Basically just str.split(\",\"), but handling cases\n * where we have nested braced sections, which should be\n * treated as individual members, like {a,{b,c},d}\n */\nfunction parseCommaParts(str: string) {\n const parts: string[] = []\n\n // Walk the brace groups iteratively. Recursing on `post` once per group let a\n // chain of them exhaust the stack - the parsing-side counterpart to\n // the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or\n // `maxLength` can bound, since it happens before expansion.\n //\n // The part the next chunk continues\n let carry = ''\n\n for (;;) {\n const m = balanced('{', '}', str)\n\n if (!m) {\n const tail = str.split(',')\n tail[0] = carry + (tail[0] as string)\n pushAll(parts, tail)\n return parts\n }\n\n const { pre, body, post } = m\n const p = pre.split(',')\n p[0] = carry + (p[0] as string)\n p[p.length - 1] += '{' + body + '}'\n\n if (!post.length) {\n pushAll(parts, p)\n return parts\n }\n\n carry = p.pop() as string\n pushAll(parts, p)\n str = post\n }\n}\n\nexport type BraceExpansionOptions = {\n max?: number\n maxLength?: number\n maxDepth?: number\n maxRewrites?: number\n}\n\nexport function expand(str: string, options: BraceExpansionOptions = {}) {\n if (!str) {\n return []\n }\n\n const {\n max = EXPANSION_MAX,\n maxLength = EXPANSION_MAX_LENGTH,\n maxDepth = EXPANSION_MAX_DEPTH,\n maxRewrites = EXPANSION_MAX_REWRITES,\n } = options\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.slice(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.slice(2)\n }\n\n return expand_(\n escapeBraces(str),\n max,\n maxLength,\n maxDepth,\n 0,\n maxRewrites,\n true,\n ).map(unescapeBraces)\n}\n\nfunction embrace(str: string) {\n return '{' + str + '}'\n}\n\nfunction isPadded(el: string) {\n return /^-?0\\d/.test(el)\n}\n\nfunction lte(i: number, y: number) {\n return i <= y\n}\n\nfunction gte(i: number, y: number) {\n return i >= y\n}\n\n// Build `{ acc[a] + pre + values[v] }` for every combination, capping the\n// number of results at `max` and the total number of characters at `maxLength`.\n// This is the one place output grows, so bounding it here keeps the single\n// accumulator - and therefore memory - flat regardless of how many brace groups\n// are combined (CVE-2026-14257).\nfunction combine(\n acc: string[],\n pre: string,\n values: string[],\n max: number,\n maxLength: number,\n dropEmpties: boolean,\n): string[] {\n const out: string[] = []\n let length = 0\n for (let a = 0; a < acc.length; a++) {\n for (let v = 0; v < values.length; v++) {\n if (out.length >= max) return out\n const expansion = (acc[a] as string) + pre + values[v]\n // Bash drops empty results at the top level. Skip them before they count\n // against `max`, so `max` bounds the number of *kept* results.\n if (dropEmpties && !expansion) continue\n if (length + expansion.length > maxLength) return out\n out.push(expansion)\n length += expansion.length\n }\n }\n return out\n}\n\n// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)\n// sequence body.\nfunction expandSequence(\n body: string,\n isAlphaSequence: boolean,\n max: number,\n maxLength: number,\n): string[] {\n const n = body.split(/\\.\\./)\n const N: string[] = []\n // A sequence body always splits into two or three parts, but the compiler\n // can't know that.\n /* c8 ignore start */\n if (n[0] === undefined || n[1] === undefined) {\n return N\n }\n /* c8 ignore stop */\n const x = numeric(n[0])\n const y = numeric(n[1])\n const width = Math.max(n[0].length, n[1].length)\n let incr =\n n.length === 3 && n[2] !== undefined ?\n Math.max(Math.abs(numeric(n[2])), 1)\n : 1\n let test = lte\n const reverse = y < x\n if (reverse) {\n incr *= -1\n test = gte\n }\n const pad = n.some(isPadded)\n\n let length = 0\n for (let i = x; test(i, y) && N.length < max; i += incr) {\n let c\n if (isAlphaSequence) {\n c = String.fromCharCode(i)\n if (c === '\\\\') {\n c = ''\n }\n } else {\n c = String(i)\n if (pad) {\n const need = width - c.length\n if (need > 0) {\n const z = new Array(need + 1).join('0')\n if (i < 0) {\n c = '-' + z + c.slice(1)\n } else {\n c = z + c\n }\n }\n }\n }\n if (length + c.length > maxLength) break\n N.push(c)\n length += c.length\n }\n return N\n}\n\nfunction expand_(\n str: string,\n max: number,\n maxLength: number,\n maxDepth: number,\n depth: number,\n maxRewrites: number,\n isTop: boolean,\n): string[] {\n // Too deeply nested to keep following: treat the rest as literal, the same\n // way a group that cannot expand is already handled. Truncating rather than\n // throwing keeps `expand` total, matching `max` and `maxLength`.\n if (depth > maxDepth) {\n return [str]\n }\n\n // Consume the string's top-level brace groups left to right, threading a\n // running set of combined prefixes (`acc`). Expanding the tail iteratively -\n // rather than recursing on `m.post` once per group - keeps the native stack\n // depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no\n // longer overflow the stack, and leaves a single accumulator whose size\n // `maxLength` bounds directly (CVE-2026-14257).\n let acc: string[] = ['']\n\n // Bash drops empty results, but only when the *first* top-level group is a\n // comma set - a sequence like `{a..\\}` may legitimately yield ''. The drop\n // is on the final strings, so it is applied to whichever `combine` produces\n // them (the one with no brace set left in the tail).\n // How many times the `{a},b}` rewrite below has restarted the scan. Each pass\n // re-reads the whole string, so leaving this unbounded is quadratic.\n let rewrites = 0\n let dropEmpties = false\n let firstGroup = true\n\n for (;;) {\n const m = balanced('{', '}', str)\n\n // No brace set left: the rest of the string is literal.\n if (!m) {\n return combine(acc, str, [''], max, maxLength, dropEmpties)\n }\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = m.pre\n\n if (/\\$$/.test(pre)) {\n acc = combine(\n acc,\n pre + '{' + m.body + '}',\n [''],\n max,\n maxLength,\n dropEmpties && !m.post.length,\n )\n firstGroup = false\n if (!m.post.length) break\n str = m.post\n continue\n }\n\n const isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body)\n const isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(\n m.body,\n )\n const isSequence = isNumericSequence || isAlphaSequence\n const isOptions = m.body.indexOf(',') >= 0\n if (!isSequence && !isOptions) {\n // {a},b}\n if (rewrites < maxRewrites && m.post.match(/,(?!,).*\\}/)) {\n rewrites++\n str = m.pre + '{' + m.body + escClose + m.post\n isTop = true\n continue\n }\n // Nothing here expands, so the whole remaining string is literal.\n return combine(\n acc,\n pre + '{' + m.body + '}' + m.post,\n [''],\n max,\n maxLength,\n dropEmpties,\n )\n }\n\n if (firstGroup) {\n dropEmpties = isTop && !isSequence\n firstGroup = false\n }\n\n let values: string[]\n if (isSequence) {\n values = expandSequence(m.body, isAlphaSequence, max, maxLength)\n } else {\n let n = parseCommaParts(m.body)\n if (n.length === 1 && n[0] !== undefined) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand_(\n n[0],\n max,\n maxLength,\n maxDepth,\n depth + 1,\n maxRewrites,\n false,\n ).map(embrace)\n //XXX is this necessary? Can't seem to hit it in tests.\n /* c8 ignore start */\n if (n.length === 1) {\n acc = combine(\n acc,\n pre + n[0],\n [''],\n max,\n maxLength,\n dropEmpties && !m.post.length,\n )\n if (!m.post.length) break\n str = m.post\n continue\n }\n /* c8 ignore stop */\n }\n\n // Values that `combine` is going to drop as empty produce no result, so\n // they must not count against `max` - otherwise `{a,,b}` with `max: 2`\n // would stop at `['a', '']` and yield one result instead of two. Skipping\n // them outright keeps `values` bounded while leaving `max` a bound on\n // *kept* results.\n let dropsEmpties = dropEmpties && !m.post.length && !pre\n for (let d = 0; dropsEmpties && d < acc.length; d++) {\n if (acc[d]) {\n dropsEmpties = false\n }\n }\n\n values = []\n let valuesLength = 0\n outer: for (let j = 0; j < n.length; j++) {\n const expanded = expand_(\n n[j] as string,\n max,\n maxLength,\n maxDepth,\n depth + 1,\n maxRewrites,\n false,\n )\n for (let k = 0; k < expanded.length; k++) {\n const v = expanded[k] as string\n if (dropsEmpties && !v) continue\n if (\n values.length >= max ||\n valuesLength + v.length > maxLength\n ) {\n break outer\n }\n values.push(v)\n valuesLength += v.length\n }\n }\n }\n\n acc = combine(\n acc,\n pre,\n values,\n max,\n maxLength,\n dropEmpties && !m.post.length,\n )\n if (!m.post.length) break\n str = m.post\n }\n\n return acc\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;AAC7D,MAAM,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;AAC3D,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;AAC7D,MAAM,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;AAC7D,MAAM,SAAS,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;AAC/D,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjD,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;AAC/C,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjD,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjD,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;AACnD,MAAM,YAAY,GAA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n\nconst escSlash = '\\0SLASH' + Math.random().toFixed(16) + '\\0'\nconst escOpen = '\\0OPEN' + Math.random().toFixed(16) + '\\0'\nconst escClose = '\\0CLOSE' + Math.random().toFixed(16) + '\\0'\nconst escComma = '\\0COMMA' + Math.random().toFixed(16) + '\\0'\nconst escPeriod = '\\0PERIOD' + Math.random().toFixed(16) + '\\0'\nconst escSlashPattern = new RegExp(escSlash, 'g')\nconst escOpenPattern = new RegExp(escOpen, 'g')\nconst escClosePattern = new RegExp(escClose, 'g')\nconst escCommaPattern = new RegExp(escComma, 'g')\nconst escPeriodPattern = new RegExp(escPeriod, 'g')\nconst slashPattern = /\\\\\\\\/g\nconst openPattern = /\\\\{/g\nconst closePattern = /\\\\}/g\nconst commaPattern = /\\\\,/g\nconst periodPattern = /\\\\\\./g\n\nexport const EXPANSION_MAX = 100_000\n\n// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An\n// input like `'{a,b}'.repeat(1500)` stays under that count - its output is\n// truncated to 100k results - while making every result ~1500 characters\n// long. The result set, and the intermediate arrays built while combining\n// brace sets, then grow large enough to exhaust memory and crash the process\n// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of\n// characters the accumulator may hold at any point, so memory stays flat no\n// matter how many brace groups are chained. The limit sits well above any\n// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M\n// characters) so legitimate input is unaffected.\nexport const EXPANSION_MAX_LENGTH = 4_000_000\n\n// `expand_` recurses once per level of brace *nesting* - both when expanding a\n// set's comma members and when re-wrapping a set whose body is a single part.\n// The CVE-2026-14257 fix made the *tail* iterative (recursion on `m.post`, one\n// level per chained group), which left nesting depth unbounded: about 3,100\n// levels of `{{{...a,b...}}}` - only ~6KB of input - exhausted the native stack\n// and crashed the process. `EXPANSION_MAX_DEPTH` bounds how deep the parser\n// will follow nesting. It sits far above any realistic pattern and well below\n// the depth at which the stack runs out.\nexport const EXPANSION_MAX_DEPTH = 1_000\n\n// Bash keeps a quirk where a brace group followed by a comma set still expands\n// (`{a},b}`). The parser implements it by rewriting the string and restarting\n// the scan, absorbing one `}` per pass. `n` trailing braces therefore cost `n`\n// full passes over a string that itself grows by one `escClose` sentinel each\n// time - quadratic in `n`, with a ~26x constant from the sentinel's length.\n// 128KB of `'{a}' + '}'.repeat(n) + ',z}'` blocked the event loop for 27\n// seconds to produce two results. `EXPANSION_MAX_REWRITES` bounds how many\n// times the scan may restart. Real `{a},b}` input needs a handful.\nexport const EXPANSION_MAX_REWRITES = 1_000\n\n// `EXPANSION_MAX_STEPS` bounds the work one `expand` call does, which `max`,\n// `maxLength` and `maxDepth` don't: nested sets are rescanned at every level\n// and chained groups each rebuild up to `max` results, so 2KB of input could\n// block the event loop for over 30 seconds. Each character scanned, result\n// built and sequence value generated is a step, and each `expand_` call costs\n// `CALL_STEPS` more. Past the budget, the set being expanded and everything\n// after it stay literal. A glob needs a few hundred steps, and nesting all the\n// way to `EXPANSION_MAX_DEPTH` about 4M.\nexport const EXPANSION_MAX_STEPS = 20_000_000\n\n// What one `expand_` call costs on top of what it scans and builds. Setting\n// one up takes about as long as scanning 16 characters, and a set whose\n// results are wrapped to be expanded again makes one call per result, each\n// scanning and building next to nothing: 64KB of\n// `('{{' + ','.repeat(316) + '}{' + ','.repeat(316) + '}}').repeat(n)` made\n// 4M such calls, which spent the budget three times as slowly as anything\n// else.\nconst CALL_STEPS = 16\n\nfunction numeric(str: string) {\n return !isNaN(str as any) ? parseInt(str, 10) : str.charCodeAt(0)\n}\n\nfunction escapeBraces(str: string) {\n return str\n .replace(slashPattern, escSlash)\n .replace(openPattern, escOpen)\n .replace(closePattern, escClose)\n .replace(commaPattern, escComma)\n .replace(periodPattern, escPeriod)\n}\n\nfunction unescapeBraces(str: string) {\n return str\n .replace(escSlashPattern, '\\\\')\n .replace(escOpenPattern, '{')\n .replace(escClosePattern, '}')\n .replace(escCommaPattern, ',')\n .replace(escPeriodPattern, '.')\n}\n\n// Like `target.push(...items)` but doesn't overflow the stack\nfunction pushAll(target: string[], items: string[]) {\n for (let i = 0; i < items.length; i++) {\n target.push(items[i] as string)\n }\n}\n\n// The step budget for one `expand` call. It is a single counter shared by every\n// level of nesting and every brace group, rather than a per-level limit, so the\n// bound holds for the call as a whole - not `maxDepth * maxSteps`.\ntype Budget = { remaining: number }\n\n// `balanced`, run on `masked` (see `maskUnmatchedOpens`), sliced from `str`\n// and charged for the characters it walks: up to the group's `}`, or the\n// whole string when there is no match or unmatched `{` come first, which\n// `unmatched` then flags for masking. Once a call overdraws the budget, it\n// and every later one return undefined, so the rest stays literal.\nfunction balancedWithBudget(str: string, masked: string, budget: Budget) {\n if (budget.remaining < 0) {\n return undefined\n }\n const r = range('{', '}', masked)\n const unmatched = r !== undefined && masked.indexOf('{') < r[0]\n budget.remaining -= r && !unmatched ? r[1] + 1 : str.length\n if (!r || budget.remaining < 0) {\n return undefined\n }\n return {\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + 1, r[1]),\n post: str.slice(r[1] + 1),\n unmatched,\n }\n}\n\n// `masked` with every `{` that has no matching `}` swapped for a `\\0`, which\n// keeps the length, so a scan of it still lines up with the string it was\n// made from. Such a `{` is literal either way, but `balanced` only learns that\n// one is unmatched by reading to the end of the string, so with one at the\n// head of every group (`'{a,{b,c}'.repeat(n)`) each scan read the rest of the\n// input. That was quadratic, and once the step budget charged for it, it ran\n// out partway through and left the rest literal. A scan of the masked copy\n// stops at the group's `}`. It is one pass, charged as such.\nfunction maskUnmatchedOpens(masked: string, budget: Budget) {\n budget.remaining -= masked.length\n const open: number[] = []\n for (let i = 0; i < masked.length; i++) {\n const c = masked.charCodeAt(i)\n if (c === 0x7b) {\n open.push(i)\n } else if (c === 0x7d && open.length) {\n open.pop()\n }\n }\n let out = ''\n let last = 0\n for (let i = 0; i < open.length; i++) {\n const at = open[i] as number\n out += masked.slice(last, at) + '\\0'\n last = at + 1\n }\n return out + masked.slice(last)\n}\n\n// Whether `str` has a `,` not followed by another `,`, with a `}` after it on\n// the same line - what `/,(?!,).*\\}/.test(str)` asks, answered in one pass from\n// the end. The regex tries every `,` and backtracks through the rest of its\n// line from each, which is quadratic, and the `{a},b}` rewrite asks again on\n// every pass. Like a scan, it is charged for the whole string and refused if\n// that overdraws the budget.\nfunction commaSetFollows(str: string, budget: Budget) {\n budget.remaining -= str.length\n if (budget.remaining < 0) {\n return false\n }\n // Whether a `}` follows the current position before the line ends\n let close = false\n for (let i = str.length - 1; i >= 0; i--) {\n const c = str.charCodeAt(i)\n if (c === 0x7d) {\n close = true\n } else if (c === 0x0a || c === 0x0d || c === 0x2028 || c === 0x2029) {\n // A line terminator, which `.` does not match\n close = false\n } else if (c === 0x2c && close && str.charCodeAt(i + 1) !== 0x2c) {\n return true\n }\n }\n return false\n}\n\n/**\n * Basically just str.split(\",\"), but handling cases\n * where we have nested braced sections, which should be\n * treated as individual members, like {a,{b,c},d}\n *\n * Returns `undefined` if the step budget runs out before the whole set is\n * split, since splitting what is left on every comma would tear apart the\n * nested sets it still holds.\n */\nfunction parseCommaParts(str: string, budget: Budget) {\n const parts: string[] = []\n\n // Walk the brace groups iteratively. Recursing on `post` once per group let a\n // chain of them exhaust the stack - the parsing-side counterpart to\n // the `expand_` overflow fixed for CVE-2026-14257, and not something `max` or\n // `maxLength` can bound, since it happens before expansion.\n //\n // The part the next chunk continues\n let carry = ''\n\n for (;;) {\n // A set's body holds no unmatched `{`, so there is nothing to mask.\n const m = balancedWithBudget(str, str, budget)\n\n if (budget.remaining < 0) {\n return undefined\n }\n\n if (!m) {\n const tail = str.split(',')\n tail[0] = carry + (tail[0] as string)\n pushAll(parts, tail)\n return parts\n }\n\n const { pre, body, post } = m\n const p = pre.split(',')\n p[0] = carry + (p[0] as string)\n p[p.length - 1] += '{' + body + '}'\n\n if (!post.length) {\n pushAll(parts, p)\n return parts\n }\n\n carry = p.pop() as string\n pushAll(parts, p)\n str = post\n }\n}\n\nexport type BraceExpansionOptions = {\n max?: number\n maxLength?: number\n maxDepth?: number\n maxRewrites?: number\n maxSteps?: number\n}\n\n// An option that is left out, or that is NaN, gets its default. Every\n// comparison against NaN is false, so a NaN bound would never be reached:\n// `{ maxSteps: NaN }` let 15KB of input block the event loop for 16 seconds,\n// and `{ maxDepth: NaN }` overflowed the stack again (CVE-2026-102278). Pass\n// `Infinity` to lift a bound.\nfunction bound(value: number | undefined, fallback: number) {\n return value === undefined || isNaN(value) ? fallback : value\n}\n\nexport function expand(str: string, options: BraceExpansionOptions = {}) {\n if (!str) {\n return []\n }\n\n const max = bound(options.max, EXPANSION_MAX)\n const maxLength = bound(options.maxLength, EXPANSION_MAX_LENGTH)\n const maxDepth = bound(options.maxDepth, EXPANSION_MAX_DEPTH)\n const maxRewrites = bound(options.maxRewrites, EXPANSION_MAX_REWRITES)\n const maxSteps = bound(options.maxSteps, EXPANSION_MAX_STEPS)\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.slice(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.slice(2)\n }\n\n return expand_(\n escapeBraces(str),\n max,\n maxLength,\n maxDepth,\n 0,\n maxRewrites,\n { remaining: maxSteps },\n true,\n ).map(unescapeBraces)\n}\n\nfunction embrace(str: string) {\n return '{' + str + '}'\n}\n\nfunction isPadded(el: string) {\n return /^-?0\\d/.test(el)\n}\n\nfunction lte(i: number, y: number) {\n return i <= y\n}\n\nfunction gte(i: number, y: number) {\n return i >= y\n}\n\n// Build `{ acc[a] + pre + values[v] }` for every combination, capping the\n// number of results at `max` and the total number of characters at `maxLength`.\n// This is the one place output grows, so bounding it here keeps the single\n// accumulator - and therefore memory - flat regardless of how many brace groups\n// are combined (CVE-2026-14257). Each result built is a step, since `max` and\n// `maxLength` bound one combination, not how many brace groups are combined.\nfunction combine(\n acc: string[],\n pre: string,\n values: string[],\n max: number,\n maxLength: number,\n dropEmpties: boolean,\n budget: Budget,\n): string[] {\n const out: string[] = []\n let length = 0\n // Bash drops empty results at the top level, and they don't count against\n // `max`, so `max` bounds the number of *kept* results. Only an empty\n // `acc[a] + pre` can make one, so for those the empty values are skipped\n // without being visited. Visiting them one at a time let a set of empties\n // cost `acc.length * values.length` while keeping nothing.\n let nonEmpty: string[] | undefined\n outer: for (let a = 0; a < acc.length; a++) {\n const prefix = (acc[a] as string) + pre\n let vs = values\n if (dropEmpties && !prefix) {\n if (!nonEmpty) nonEmpty = values.filter(v => v)\n vs = nonEmpty\n }\n for (let v = 0; v < vs.length; v++) {\n if (out.length >= max) break outer\n const expansion = prefix + vs[v]\n if (length + expansion.length > maxLength) break outer\n out.push(expansion)\n length += expansion.length\n }\n }\n budget.remaining -= out.length\n return out\n}\n\n// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)\n// sequence body, or `undefined` if the step budget runs out generating them.\nfunction expandSequence(\n body: string,\n isAlphaSequence: boolean,\n max: number,\n maxLength: number,\n budget: Budget,\n): string[] | undefined {\n const n = body.split(/\\.\\./)\n const N: string[] = []\n // A sequence body always splits into two or three parts, but the compiler\n // can't know that.\n /* c8 ignore start */\n if (n[0] === undefined || n[1] === undefined) {\n return N\n }\n /* c8 ignore stop */\n const x = numeric(n[0])\n const y = numeric(n[1])\n const width = Math.max(n[0].length, n[1].length)\n let incr =\n n.length === 3 && n[2] !== undefined ?\n Math.max(Math.abs(numeric(n[2])), 1)\n : 1\n let test = lte\n const reverse = y < x\n if (reverse) {\n incr *= -1\n test = gte\n }\n const pad = n.some(isPadded)\n // A padded value is built a character at a time to `width`, which the input\n // sets, so it costs one step per character: 64KB of\n // `('{' + '0'.repeat(100) + '..99999}').repeat(n)` took 7 seconds charged\n // one step per value.\n const cost = pad ? width : 1\n\n let length = 0\n for (let i = x; test(i, y) && N.length < max; i += incr) {\n // Each value is a step. `max` and `maxLength` bound one sequence, but a\n // chain of them still generated up to `max` values each, however few\n // combining could keep.\n budget.remaining -= cost\n if (budget.remaining < 0) {\n return undefined\n }\n let c\n if (isAlphaSequence) {\n c = String.fromCharCode(i)\n if (c === '\\\\') {\n c = ''\n }\n } else {\n c = String(i)\n if (pad) {\n const need = width - c.length\n if (need > 0) {\n const z = new Array(need + 1).join('0')\n if (i < 0) {\n c = '-' + z + c.slice(1)\n } else {\n c = z + c\n }\n }\n }\n }\n if (length + c.length > maxLength) break\n N.push(c)\n length += c.length\n }\n return N\n}\n\nfunction expand_(\n str: string,\n max: number,\n maxLength: number,\n maxDepth: number,\n depth: number,\n maxRewrites: number,\n budget: Budget,\n isTop: boolean,\n): string[] {\n // An overdraft here makes the first scan refuse, so `str` stays literal.\n budget.remaining -= CALL_STEPS\n\n // Too deeply nested to keep following: treat the rest as literal, the same\n // way a group that cannot expand is already handled. Truncating rather than\n // throwing keeps `expand` total, matching `max` and `maxLength`.\n if (depth > maxDepth) {\n return [str]\n }\n\n // Consume the string's top-level brace groups left to right, threading a\n // running set of combined prefixes (`acc`). Expanding the tail iteratively -\n // rather than recursing on `m.post` once per group - keeps the native stack\n // depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no\n // longer overflow the stack, and leaves a single accumulator whose size\n // `maxLength` bounds directly (CVE-2026-14257).\n let acc: string[] = ['']\n\n // Bash drops empty results, but only when the *first* top-level group is a\n // comma set - a sequence like `{a..\\}` may legitimately yield ''. The drop\n // is on the final strings, so it is applied to whichever `combine` produces\n // them (the one with no brace set left in the tail).\n // How many times the `{a},b}` rewrite below has restarted the scan. Each pass\n // re-reads the whole string, so leaving this unbounded is quadratic.\n let rewrites = 0\n let dropEmpties = false\n let firstGroup = true\n // `str` with its unmatched `{` masked, once a scan has run into them\n let masked = str\n\n for (;;) {\n const m = balancedWithBudget(str, masked, budget)\n\n // No brace set left, or no step budget left to look for one: the rest of\n // the string is literal.\n if (!m) {\n return combine(acc, str, [''], max, maxLength, dropEmpties, budget)\n }\n if (m.unmatched) {\n masked = maskUnmatchedOpens(masked, budget)\n }\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n const pre = m.pre\n\n // This set and the rest of the string, literal: for a set that cannot\n // expand, and for one the step budget runs out on. Once it is overdrawn,\n // every set still being expanded, at every level, stays literal like this -\n // otherwise each level above would go on combining, and wrapping and\n // expanding again, results the budget was too small for.\n const literal = () =>\n combine(\n acc,\n pre + '{' + m.body + '}' + m.post,\n [''],\n max,\n maxLength,\n dropEmpties,\n budget,\n )\n\n if (/\\$$/.test(pre)) {\n acc = combine(\n acc,\n pre + '{' + m.body + '}',\n [''],\n max,\n maxLength,\n dropEmpties && !m.post.length,\n budget,\n )\n firstGroup = false\n if (!m.post.length) break\n str = m.post\n masked = masked.slice(m.end + 1)\n continue\n }\n\n const isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body)\n const isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(\n m.body,\n )\n const isSequence = isNumericSequence || isAlphaSequence\n const isOptions = m.body.indexOf(',') >= 0\n if (!isSequence && !isOptions) {\n // {a},b}\n if (rewrites < maxRewrites && commaSetFollows(m.post, budget)) {\n rewrites++\n str = m.pre + '{' + m.body + escClose + m.post\n // Taking a `}` away never gives an unmatched `{` a partner, so what\n // is masked stays unmatched. The `{` it closed can be left without\n // one, and the next scan masks it.\n masked =\n masked.slice(0, m.end) + escClose + masked.slice(m.end + 1)\n isTop = true\n continue\n }\n // Nothing here expands, so the whole remaining string is literal.\n return literal()\n }\n\n if (firstGroup) {\n dropEmpties = isTop && !isSequence\n firstGroup = false\n }\n\n let values: string[] | undefined\n if (isSequence) {\n values = expandSequence(\n m.body,\n isAlphaSequence,\n max,\n maxLength,\n budget,\n )\n if (!values) {\n return literal()\n }\n } else {\n let n = parseCommaParts(m.body, budget)\n // The step budget ran out partway through the set.\n if (!n) {\n return literal()\n }\n if (n.length === 1 && n[0] !== undefined) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand_(\n n[0],\n max,\n maxLength,\n maxDepth,\n depth + 1,\n maxRewrites,\n budget,\n false,\n ).map(embrace)\n // The step budget ran out expanding the set's only part.\n if (budget.remaining < 0) {\n return literal()\n }\n //XXX is this necessary? Can't seem to hit it in tests.\n /* c8 ignore start */\n if (n.length === 1) {\n const next = combine(\n acc,\n pre + n[0],\n [''],\n max,\n maxLength,\n dropEmpties && !m.post.length,\n budget,\n )\n if (budget.remaining < 0) {\n return literal()\n }\n acc = next\n if (!m.post.length) break\n str = m.post\n masked = masked.slice(m.end + 1)\n continue\n }\n /* c8 ignore stop */\n }\n\n // Values that `combine` is going to drop as empty produce no result, so\n // they must not count against `max` - otherwise `{a,,b}` with `max: 2`\n // would stop at `['a', '']` and yield one result instead of two. Skipping\n // them outright keeps `values` bounded while leaving `max` a bound on\n // *kept* results.\n let dropsEmpties = dropEmpties && !m.post.length && !pre\n for (let d = 0; dropsEmpties && d < acc.length; d++) {\n if (acc[d]) {\n dropsEmpties = false\n }\n }\n\n values = []\n let valuesLength = 0\n outer: for (let j = 0; j < n.length; j++) {\n const expanded = expand_(\n n[j] as string,\n max,\n maxLength,\n maxDepth,\n depth + 1,\n maxRewrites,\n budget,\n false,\n )\n // The step budget ran out expanding a member.\n if (budget.remaining < 0) {\n return literal()\n }\n for (let k = 0; k < expanded.length; k++) {\n const v = expanded[k] as string\n if (dropsEmpties && !v) continue\n if (\n values.length >= max ||\n valuesLength + v.length > maxLength\n ) {\n break outer\n }\n values.push(v)\n valuesLength += v.length\n }\n }\n }\n\n const next = combine(\n acc,\n pre,\n values,\n max,\n maxLength,\n dropEmpties && !m.post.length,\n budget,\n )\n // The step budget ran out combining the set's values in.\n if (budget.remaining < 0) {\n return literal()\n }\n acc = next\n if (!m.post.length) break\n str = m.post\n masked = masked.slice(m.end + 1)\n }\n\n return acc\n}\n"]}
|
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_compose = require("./compose.js");
|
|
3
3
|
const require_utils_url = require("./utils/url.js");
|
|
4
4
|
const require_context = require("./context.js");
|
|
5
|
+
const require_helper_route_index = require("./helper/route/index.js");
|
|
5
6
|
const require_router = require("./router.js");
|
|
6
7
|
const require_utils_constants = require("./utils/constants.js");
|
|
7
8
|
const require_utils_mount = require("./utils/mount.js");
|
|
@@ -185,6 +186,8 @@ var Hono = class Hono {
|
|
|
185
186
|
* @param {Function} applicationHandler - other Request Handler
|
|
186
187
|
* @param {MountOptions} [options] - options of `.mount()`
|
|
187
188
|
* @returns {Hono} mounted Hono instance
|
|
189
|
+
* @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
190
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
188
191
|
*
|
|
189
192
|
* @example
|
|
190
193
|
* ```ts
|
|
@@ -229,8 +232,10 @@ var Hono = class Hono {
|
|
|
229
232
|
} catch {}
|
|
230
233
|
return [c.env, executionContext];
|
|
231
234
|
};
|
|
232
|
-
const
|
|
233
|
-
|
|
235
|
+
const defaultReplaceRequest = (c) => {
|
|
236
|
+
const mountedRoutePath = require_helper_route_index.routePath(c);
|
|
237
|
+
return require_utils_mount.createMountedRequest(c, mountedRoutePath.replace(/\/?\*$/, ""), mountedRoutePath);
|
|
238
|
+
};
|
|
234
239
|
const handler = async (c, next) => {
|
|
235
240
|
const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
|
|
236
241
|
if (res) return res;
|
|
@@ -45,23 +45,22 @@ const bodyLimit = (options) => {
|
|
|
45
45
|
const hasTransferEncoding = c.req.raw.headers.has("transfer-encoding");
|
|
46
46
|
if (c.req.raw.headers.has("content-length") && !hasTransferEncoding) return parseInt(c.req.raw.headers.get("content-length") || "0", 10) > maxSize ? onError(c) : next();
|
|
47
47
|
let size = 0;
|
|
48
|
-
|
|
48
|
+
let buffer = /* @__PURE__ */ new Uint8Array(0);
|
|
49
49
|
const rawReader = c.req.raw.body.getReader();
|
|
50
50
|
for (;;) {
|
|
51
51
|
const { done, value } = await rawReader.read();
|
|
52
52
|
if (done) break;
|
|
53
|
+
const offset = size;
|
|
53
54
|
size += value.length;
|
|
54
55
|
if (size > maxSize) return onError(c);
|
|
55
|
-
|
|
56
|
+
if (size > buffer.length) {
|
|
57
|
+
const grown = new Uint8Array(Math.min(maxSize, Math.max(size, buffer.length * 2)));
|
|
58
|
+
grown.set(buffer.subarray(0, offset));
|
|
59
|
+
buffer = grown;
|
|
60
|
+
}
|
|
61
|
+
buffer.set(value, offset);
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
body: new ReadableStream({ start(controller) {
|
|
59
|
-
for (const chunk of chunks) controller.enqueue(chunk);
|
|
60
|
-
controller.close();
|
|
61
|
-
} }),
|
|
62
|
-
duplex: "half"
|
|
63
|
-
};
|
|
64
|
-
c.req.raw = new Request(c.req.raw, requestInit);
|
|
63
|
+
c.req.raw = new Request(c.req.raw, { body: buffer.subarray(0, size) });
|
|
65
64
|
return next();
|
|
66
65
|
};
|
|
67
66
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_helper_route_index = require("../../helper/route/index.js");
|
|
2
3
|
require("../../router.js");
|
|
3
4
|
const require_router_trie_router_router = require("../../router/trie-router/router.js");
|
|
4
5
|
require("../../router/trie-router/index.js");
|
|
5
|
-
const require_helper_route_index = require("../../helper/route/index.js");
|
|
6
6
|
//#region src/middleware/method-not-allowed/index.ts
|
|
7
7
|
/**
|
|
8
8
|
* Method Not Allowed Middleware for Hono.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_utils_mount = require("../../utils/mount.js");
|
|
3
2
|
const require_helper_route_index = require("../../helper/route/index.js");
|
|
3
|
+
const require_utils_mount = require("../../utils/mount.js");
|
|
4
4
|
//#region src/middleware/mount/index.ts
|
|
5
5
|
const defaultReplaceRequest = (c) => {
|
|
6
6
|
const path = require_helper_route_index.routePath(c);
|
|
@@ -21,7 +21,8 @@ const defaultGetOptions = (c) => {
|
|
|
21
21
|
* @param {Function} applicationHandler - other Request Handler
|
|
22
22
|
* @param {MountOptions} [options] - options of `mount()`
|
|
23
23
|
* @returns {MiddlewareHandler} handler to register with `app.all()`
|
|
24
|
-
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names.
|
|
24
|
+
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
25
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
25
26
|
*
|
|
26
27
|
* @example
|
|
27
28
|
* ```ts
|
|
@@ -25,8 +25,8 @@ const serveStatic = (options) => {
|
|
|
25
25
|
let filename;
|
|
26
26
|
if (options.path) filename = options.path;
|
|
27
27
|
else try {
|
|
28
|
-
if (!options.allowPercentInPath && c.req.path.includes("%")) throw new Error();
|
|
29
28
|
filename = require_utils_url.tryDecodeURI(c.req.path);
|
|
29
|
+
if (c.req.path.includes("%") && (!options.allowPercentInPath || filename !== c.req.path.replace(/%25/g, "%"))) throw new Error();
|
|
30
30
|
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) throw new Error();
|
|
31
31
|
} catch {
|
|
32
32
|
await options.onNotFound?.(c.req.path, c);
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_http_exception = require("../http-exception.js");
|
|
2
3
|
const require_request_constants = require("../request/constants.js");
|
|
3
4
|
const require_utils_url = require("./url.js");
|
|
4
5
|
//#region src/utils/mount.ts
|
|
6
|
+
const countTrailingSlashes = (path) => {
|
|
7
|
+
let index = path.length;
|
|
8
|
+
while (index > 0 && path.charCodeAt(index - 1) === 47) index--;
|
|
9
|
+
return path.length - index;
|
|
10
|
+
};
|
|
5
11
|
const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
6
12
|
if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
|
|
7
13
|
const path = c.req.path;
|
|
@@ -9,6 +15,7 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
9
15
|
const paramNames = /* @__PURE__ */ new Set();
|
|
10
16
|
let length = 0;
|
|
11
17
|
for (const part of require_utils_url.splitRoutingPath(pathPrefix)) {
|
|
18
|
+
if (part[0] === ":" && part.endsWith("}?")) throw new Error(`mount(): Optional regular expression parameters are not supported in "${routePath}".`);
|
|
12
19
|
const pattern = require_utils_url.getPattern(part);
|
|
13
20
|
if (pattern && pattern !== "*") {
|
|
14
21
|
const name = pattern[1];
|
|
@@ -27,8 +34,17 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
27
34
|
};
|
|
28
35
|
const createMountedRequest = (c, pathPrefix, routePath) => {
|
|
29
36
|
if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
|
|
30
|
-
const
|
|
31
|
-
|
|
37
|
+
const prefixLength = getPathPrefixLength(c, pathPrefix, routePath);
|
|
38
|
+
const path = c.req.path.slice(prefixLength) || "/";
|
|
39
|
+
if (prefixLength > c.req.path.length || path[0] !== "/" || /\/(?:\.|%2e){1,2}(?:\/|$)/i.test(path)) throw new require_http_exception.HTTPException(400, { message: "Invalid mounted path" });
|
|
40
|
+
const rawUrl = c.req.raw.url;
|
|
41
|
+
if (/^[^/?#]*\/\/[^/?#\\]*[?#\\]/.test(rawUrl)) throw new require_http_exception.HTTPException(400, { message: "Invalid mounted path" });
|
|
42
|
+
const rawPathEnd = rawUrl.search(/[?#]/);
|
|
43
|
+
const rawTrailingSlashes = countTrailingSlashes(rawPathEnd === -1 ? rawUrl : rawUrl.slice(0, rawPathEnd));
|
|
44
|
+
if (rawTrailingSlashes > 1 && countTrailingSlashes(c.req.path) === rawTrailingSlashes - 1) throw new require_http_exception.HTTPException(400, { message: "Invalid mounted path" });
|
|
45
|
+
const url = new URL(rawUrl);
|
|
46
|
+
url.pathname = path.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
47
|
+
if (path.includes("%")) {}
|
|
32
48
|
return new Request(url, c.req.raw);
|
|
33
49
|
};
|
|
34
50
|
//#endregion
|
|
@@ -81,6 +81,7 @@ const tryDecode = (str, decoder) => {
|
|
|
81
81
|
* tryDecodeURI('Hello%20World/%A4%A2') // 'Hello World/%A4%A2'
|
|
82
82
|
*/
|
|
83
83
|
const tryDecodeURI = (str) => tryDecode(str, decodeURI);
|
|
84
|
+
const decodeURIWithPreservedPercent = (value) => decodeURI(value.includes("%25") ? value.replace(/%25/g, "%2525") : value);
|
|
84
85
|
const getPath = (request) => {
|
|
85
86
|
const url = request.url;
|
|
86
87
|
const start = url.indexOf("/", url.indexOf(":") + 4);
|
|
@@ -92,7 +93,13 @@ const getPath = (request) => {
|
|
|
92
93
|
const hashIndex = url.indexOf("#", i);
|
|
93
94
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
94
95
|
const path = url.slice(start, end);
|
|
95
|
-
|
|
96
|
+
const decoded = tryDecode(path, decodeURIWithPreservedPercent);
|
|
97
|
+
if (/%(?![0-9A-Fa-f]{2})/.test(path)) {
|
|
98
|
+
const rewritten = new URL("http://localhost");
|
|
99
|
+
rewritten.pathname = decoded.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
100
|
+
if (tryDecode(rewritten.pathname, decodeURIWithPreservedPercent) !== decoded) return tryDecode(path.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), decodeURIWithPreservedPercent);
|
|
101
|
+
}
|
|
102
|
+
return decoded;
|
|
96
103
|
} else if (charCode === 63 || charCode === 35) break;
|
|
97
104
|
}
|
|
98
105
|
return url.slice(start, i);
|
|
@@ -111,15 +118,6 @@ const getPathNoStrict = (request) => {
|
|
|
111
118
|
const result = getPath(request);
|
|
112
119
|
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
113
120
|
};
|
|
114
|
-
const stripPathPrefix = (rawPath, decodedPath, prefixLength) => {
|
|
115
|
-
if (rawPath.at(-1) === "/" && decodedPath.at(-1) !== "/") rawPath = rawPath.slice(0, -1);
|
|
116
|
-
let index = 0;
|
|
117
|
-
for (let i = decodedPath.indexOf("/"); i !== -1 && i < prefixLength; i = decodedPath.indexOf("/", i + 1)) {
|
|
118
|
-
index = rawPath.indexOf("/", index + 1);
|
|
119
|
-
if (index === -1) return "/";
|
|
120
|
-
}
|
|
121
|
-
return rawPath.slice(index) || "/";
|
|
122
|
-
};
|
|
123
121
|
/**
|
|
124
122
|
* Merge paths.
|
|
125
123
|
* @param {string[]} ...paths - The paths to merge.
|
|
@@ -224,7 +222,6 @@ exports.getQueryStrings = getQueryStrings;
|
|
|
224
222
|
exports.mergePath = mergePath;
|
|
225
223
|
exports.splitPath = splitPath;
|
|
226
224
|
exports.splitRoutingPath = splitRoutingPath;
|
|
227
|
-
exports.stripPathPrefix = stripPathPrefix;
|
|
228
225
|
exports.tryDecode = tryDecode;
|
|
229
226
|
exports.tryDecodeURI = tryDecodeURI;
|
|
230
227
|
exports.tryDecodeURIComponent = tryDecodeURIComponent;
|
|
@@ -3,16 +3,16 @@ const require_http_exception = require("../http-exception.js");
|
|
|
3
3
|
const require_utils_buffer = require("../utils/buffer.js");
|
|
4
4
|
const require_helper_cookie_index = require("../helper/cookie/index.js");
|
|
5
5
|
//#region src/validator/validator.ts
|
|
6
|
-
const jsonRegex = /^application\/([
|
|
7
|
-
const
|
|
8
|
-
const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
6
|
+
const jsonRegex = /^application\/([\w.-]+\+)?json$/i;
|
|
7
|
+
const getMediaType = (contentType) => contentType.split(";")[0].trim().toLowerCase();
|
|
9
8
|
const validator = (target, validationFunc) => {
|
|
10
9
|
return async (c, next) => {
|
|
11
10
|
let value = {};
|
|
12
11
|
const contentType = c.req.header("Content-Type");
|
|
12
|
+
const mediaType = contentType ? getMediaType(contentType) : "";
|
|
13
13
|
switch (target) {
|
|
14
14
|
case "json":
|
|
15
|
-
if (!
|
|
15
|
+
if (!jsonRegex.test(mediaType)) break;
|
|
16
16
|
try {
|
|
17
17
|
value = await c.req.json();
|
|
18
18
|
} catch {
|
|
@@ -20,7 +20,7 @@ const validator = (target, validationFunc) => {
|
|
|
20
20
|
}
|
|
21
21
|
break;
|
|
22
22
|
case "form": {
|
|
23
|
-
if (
|
|
23
|
+
if (mediaType !== "multipart/form-data" && mediaType !== "application/x-www-form-urlencoded") break;
|
|
24
24
|
let formData;
|
|
25
25
|
if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
|
|
26
26
|
else try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { compose } from "./compose.js";
|
|
2
2
|
import { getPath, getPathNoStrict, mergePath } from "./utils/url.js";
|
|
3
3
|
import { Context } from "./context.js";
|
|
4
|
+
import { routePath } from "./helper/route/index.js";
|
|
4
5
|
import { METHODS } from "./router.js";
|
|
5
6
|
import { COMPOSED_HANDLER } from "./utils/constants.js";
|
|
6
7
|
import { createMountedRequest } from "./utils/mount.js";
|
|
@@ -184,6 +185,8 @@ var Hono = class Hono {
|
|
|
184
185
|
* @param {Function} applicationHandler - other Request Handler
|
|
185
186
|
* @param {MountOptions} [options] - options of `.mount()`
|
|
186
187
|
* @returns {Hono} mounted Hono instance
|
|
188
|
+
* @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
189
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
187
190
|
*
|
|
188
191
|
* @example
|
|
189
192
|
* ```ts
|
|
@@ -228,8 +231,10 @@ var Hono = class Hono {
|
|
|
228
231
|
} catch {}
|
|
229
232
|
return [c.env, executionContext];
|
|
230
233
|
};
|
|
231
|
-
const
|
|
232
|
-
|
|
234
|
+
const defaultReplaceRequest = (c) => {
|
|
235
|
+
const mountedRoutePath = routePath(c);
|
|
236
|
+
return createMountedRequest(c, mountedRoutePath.replace(/\/?\*$/, ""), mountedRoutePath);
|
|
237
|
+
};
|
|
233
238
|
const handler = async (c, next) => {
|
|
234
239
|
const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
|
|
235
240
|
if (res) return res;
|
|
@@ -44,23 +44,22 @@ const bodyLimit = (options) => {
|
|
|
44
44
|
const hasTransferEncoding = c.req.raw.headers.has("transfer-encoding");
|
|
45
45
|
if (c.req.raw.headers.has("content-length") && !hasTransferEncoding) return parseInt(c.req.raw.headers.get("content-length") || "0", 10) > maxSize ? onError(c) : next();
|
|
46
46
|
let size = 0;
|
|
47
|
-
|
|
47
|
+
let buffer = /* @__PURE__ */ new Uint8Array(0);
|
|
48
48
|
const rawReader = c.req.raw.body.getReader();
|
|
49
49
|
for (;;) {
|
|
50
50
|
const { done, value } = await rawReader.read();
|
|
51
51
|
if (done) break;
|
|
52
|
+
const offset = size;
|
|
52
53
|
size += value.length;
|
|
53
54
|
if (size > maxSize) return onError(c);
|
|
54
|
-
|
|
55
|
+
if (size > buffer.length) {
|
|
56
|
+
const grown = new Uint8Array(Math.min(maxSize, Math.max(size, buffer.length * 2)));
|
|
57
|
+
grown.set(buffer.subarray(0, offset));
|
|
58
|
+
buffer = grown;
|
|
59
|
+
}
|
|
60
|
+
buffer.set(value, offset);
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
body: new ReadableStream({ start(controller) {
|
|
58
|
-
for (const chunk of chunks) controller.enqueue(chunk);
|
|
59
|
-
controller.close();
|
|
60
|
-
} }),
|
|
61
|
-
duplex: "half"
|
|
62
|
-
};
|
|
63
|
-
c.req.raw = new Request(c.req.raw, requestInit);
|
|
62
|
+
c.req.raw = new Request(c.req.raw, { body: buffer.subarray(0, size) });
|
|
64
63
|
return next();
|
|
65
64
|
};
|
|
66
65
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCookie, setCookie } from "../../helper/cookie/index.js";
|
|
2
1
|
import { parseAccept } from "../../utils/accept.js";
|
|
2
|
+
import { getCookie, setCookie } from "../../helper/cookie/index.js";
|
|
3
3
|
//#region src/middleware/language/language.ts
|
|
4
4
|
const DEFAULT_OPTIONS = {
|
|
5
5
|
order: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { basePath, matchedRoutes } from "../../helper/route/index.js";
|
|
1
2
|
import "../../router.js";
|
|
2
3
|
import { TrieRouter } from "../../router/trie-router/router.js";
|
|
3
4
|
import "../../router/trie-router/index.js";
|
|
4
|
-
import { basePath, matchedRoutes } from "../../helper/route/index.js";
|
|
5
5
|
//#region src/middleware/method-not-allowed/index.ts
|
|
6
6
|
/**
|
|
7
7
|
* Method Not Allowed Middleware for Hono.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createMountedRequest } from "../../utils/mount.js";
|
|
2
1
|
import { routePath } from "../../helper/route/index.js";
|
|
2
|
+
import { createMountedRequest } from "../../utils/mount.js";
|
|
3
3
|
//#region src/middleware/mount/index.ts
|
|
4
4
|
const defaultReplaceRequest = (c) => {
|
|
5
5
|
const path = routePath(c);
|
|
@@ -20,7 +20,8 @@ const defaultGetOptions = (c) => {
|
|
|
20
20
|
* @param {Function} applicationHandler - other Request Handler
|
|
21
21
|
* @param {MountOptions} [options] - options of `mount()`
|
|
22
22
|
* @returns {MiddlewareHandler} handler to register with `app.all()`
|
|
23
|
-
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names.
|
|
23
|
+
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
24
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
24
25
|
*
|
|
25
26
|
* @example
|
|
26
27
|
* ```ts
|
|
@@ -24,8 +24,8 @@ const serveStatic = (options) => {
|
|
|
24
24
|
let filename;
|
|
25
25
|
if (options.path) filename = options.path;
|
|
26
26
|
else try {
|
|
27
|
-
if (!options.allowPercentInPath && c.req.path.includes("%")) throw new Error();
|
|
28
27
|
filename = tryDecodeURI(c.req.path);
|
|
28
|
+
if (c.req.path.includes("%") && (!options.allowPercentInPath || filename !== c.req.path.replace(/%25/g, "%"))) throw new Error();
|
|
29
29
|
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) throw new Error();
|
|
30
30
|
} catch {
|
|
31
31
|
await options.onNotFound?.(c.req.path, c);
|
|
@@ -160,6 +160,8 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
|
|
|
160
160
|
* @param {Function} applicationHandler - other Request Handler
|
|
161
161
|
* @param {MountOptions} [options] - options of `.mount()`
|
|
162
162
|
* @returns {Hono} mounted Hono instance
|
|
163
|
+
* @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
164
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
163
165
|
*
|
|
164
166
|
* @example
|
|
165
167
|
* ```ts
|
|
@@ -16,7 +16,8 @@ type MountOptions = MountOptionHandler | {
|
|
|
16
16
|
* @param {Function} applicationHandler - other Request Handler
|
|
17
17
|
* @param {MountOptions} [options] - options of `mount()`
|
|
18
18
|
* @returns {MiddlewareHandler} handler to register with `app.all()`
|
|
19
|
-
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names.
|
|
19
|
+
* @throws {Error} If the route ends with a wildcard inside a segment (e.g. `/assets*`), or automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
20
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
* ```ts
|
|
@@ -26,7 +26,6 @@ export declare const getPath: (request: Request) => string;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const getQueryStrings: (url: string) => string;
|
|
28
28
|
export declare const getPathNoStrict: (request: Request) => string;
|
|
29
|
-
export declare const stripPathPrefix: (rawPath: string, decodedPath: string, prefixLength: number) => string;
|
|
30
29
|
/**
|
|
31
30
|
* Merge paths.
|
|
32
31
|
* @param {string[]} ...paths - The paths to merge.
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { HTTPException } from "../http-exception.js";
|
|
1
2
|
import { GET_MATCH_RESULT } from "../request/constants.js";
|
|
2
|
-
import { getPattern, splitRoutingPath
|
|
3
|
+
import { getPattern, splitRoutingPath } from "./url.js";
|
|
3
4
|
//#region src/utils/mount.ts
|
|
5
|
+
const countTrailingSlashes = (path) => {
|
|
6
|
+
let index = path.length;
|
|
7
|
+
while (index > 0 && path.charCodeAt(index - 1) === 47) index--;
|
|
8
|
+
return path.length - index;
|
|
9
|
+
};
|
|
4
10
|
const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
5
11
|
if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
|
|
6
12
|
const path = c.req.path;
|
|
@@ -8,6 +14,7 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
8
14
|
const paramNames = /* @__PURE__ */ new Set();
|
|
9
15
|
let length = 0;
|
|
10
16
|
for (const part of splitRoutingPath(pathPrefix)) {
|
|
17
|
+
if (part[0] === ":" && part.endsWith("}?")) throw new Error(`mount(): Optional regular expression parameters are not supported in "${routePath}".`);
|
|
11
18
|
const pattern = getPattern(part);
|
|
12
19
|
if (pattern && pattern !== "*") {
|
|
13
20
|
const name = pattern[1];
|
|
@@ -26,8 +33,17 @@ const getPathPrefixLength = (c, pathPrefix, routePath) => {
|
|
|
26
33
|
};
|
|
27
34
|
const createMountedRequest = (c, pathPrefix, routePath) => {
|
|
28
35
|
if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
|
|
29
|
-
const
|
|
30
|
-
|
|
36
|
+
const prefixLength = getPathPrefixLength(c, pathPrefix, routePath);
|
|
37
|
+
const path = c.req.path.slice(prefixLength) || "/";
|
|
38
|
+
if (prefixLength > c.req.path.length || path[0] !== "/" || /\/(?:\.|%2e){1,2}(?:\/|$)/i.test(path)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
39
|
+
const rawUrl = c.req.raw.url;
|
|
40
|
+
if (/^[^/?#]*\/\/[^/?#\\]*[?#\\]/.test(rawUrl)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
41
|
+
const rawPathEnd = rawUrl.search(/[?#]/);
|
|
42
|
+
const rawTrailingSlashes = countTrailingSlashes(rawPathEnd === -1 ? rawUrl : rawUrl.slice(0, rawPathEnd));
|
|
43
|
+
if (rawTrailingSlashes > 1 && countTrailingSlashes(c.req.path) === rawTrailingSlashes - 1) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
44
|
+
const url = new URL(rawUrl);
|
|
45
|
+
url.pathname = path.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
46
|
+
if (path.includes("%")) {}
|
|
31
47
|
return new Request(url, c.req.raw);
|
|
32
48
|
};
|
|
33
49
|
//#endregion
|